Esempio n. 1
0
 /**
  * Constructor
  *
  * @param $searchHandler string The search handler URL. We assume the embedded server
  *  as a default.
  * @param $username string The HTTP BASIC authentication username.
  * @param $password string The corresponding password.
  * @param $instId string The unique ID of this OJS installation to partition
  *  a shared index.
  */
 function SolrWebService($searchHandler, $username, $password, $instId)
 {
     parent::XmlWebService();
     // Configure the web service.
     $this->setAuthUsername($username);
     $this->setAuthPassword($password);
     // Remove trailing slashes.
     assert(is_string($searchHandler) && !empty($searchHandler));
     $searchHandler = rtrim($searchHandler, '/');
     // Parse the search handler URL.
     $searchHandlerParts = explode('/', $searchHandler);
     $this->_solrSearchHandler = array_pop($searchHandlerParts);
     $this->_solrCore = array_pop($searchHandlerParts);
     $this->_solrServer = implode('/', $searchHandlerParts) . '/';
     // Set the installation ID.
     assert(is_string($instId) && !empty($instId));
     $this->_instId = $instId;
 }
 /**
  * Call web service with the given parameters
  * @param $params array GET or POST parameters
  * @return DOMDocument or null in case of error
  */
 function &callWebService($url, &$params, $returnType = XSL_TRANSFORMER_DOCTYPE_DOM, $method = 'GET')
 {
     // Create a request
     $webServiceRequest = new WebServiceRequest($url, $params, $method);
     // Configure and call the web service
     $xmlWebService = new XmlWebService();
     $xmlWebService->setReturnType($returnType);
     $result =& $xmlWebService->call($webServiceRequest);
     if (is_null($result)) {
         // Construct a helpful error message including
         // the offending webservice url for get requests.
         $webserviceUrl = $url;
         if ($method == 'GET') {
             $keyValuePairs = array();
             foreach ($params as $key => $value) {
                 $keyValuePairs[] = $key . '=' . $value;
             }
             $webserviceUrl .= '?' . implode('&', $keyValuePairs);
         }
         $translationParams = array('filterName' => $this->getDisplayName(), 'webserviceUrl' => $webserviceUrl, 'httpMethod' => $method);
         $this->addError(__('submission.citations.filter.webserviceError', $translationParams));
     }
     return $result;
 }
 /**
  * Call web service with the given parameters
  * @param $params array GET or POST parameters
  * @return DOMDocument or null in case of error
  */
 function &callWebService($url, &$params, $returnType = XSL_TRANSFORMER_DOCTYPE_DOM, $method = 'GET')
 {
     // Create a request
     $webServiceRequest = new WebServiceRequest($url, $params, $method);
     // Configure and call the web service
     $xmlWebService = new XmlWebService();
     $xmlWebService->setReturnType($returnType);
     $result =& $xmlWebService->call($webServiceRequest);
     return $result;
 }