CODE STYLE class.solr.php

This commit is contained in:
Fernando Ontiveros
2012-10-09 13:23:16 -04:00
parent f11a2fdd93
commit afa04ae6a8

View File

@@ -1,6 +1,6 @@
<?php <?php
/** /**
*
* ProcessMaker Open Source Edition * ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2012 Colosa Inc.23 * Copyright (C) 2004 - 2012 Colosa Inc.23
* *
@@ -19,12 +19,11 @@
* *
* For more information, contact Colosa Inc, 5304 Ventura Drive, * For more information, contact Colosa Inc, 5304 Ventura Drive,
* Delray Beach, FL, 33484, USA, or email info@colosa.com. * Delray Beach, FL, 33484, USA, or email info@colosa.com.
*
*/ */
/** /**
* Interface to the Solr Search server * Interface to the Solr Search server
*
* @author Herbert Saal Gutierrez * @author Herbert Saal Gutierrez
* *
*/ */
@@ -53,6 +52,7 @@ class BpmnEngine_SearchIndexAccess_Solr
{ {
// verify solr server response // verify solr server response
return $this->_solrIsEnabled; return $this->_solrIsEnabled;
} }
@@ -62,8 +62,7 @@ class BpmnEngine_SearchIndexAccess_Solr
* @rest = false * @rest = false
* @background = false * @background = false
* *
* @param * @param workspace: workspace name
* workspace: workspace name
* @return total * @return total
*/ */
public function getNumberDocuments ($workspace) public function getNumberDocuments ($workspace)
@@ -72,6 +71,7 @@ class BpmnEngine_SearchIndexAccess_Solr
return; return;
// get configuration information in base to workspace parameter // get configuration information in base to workspace parameter
// get total number of documents in registry // get total number of documents in registry
$solrIntruct = (substr( $this->_solrHost, - 1 ) == "/") ? $this->_solrHost : $this->_solrHost . "/"; $solrIntruct = (substr( $this->_solrHost, - 1 ) == "/") ? $this->_solrHost : $this->_solrHost . "/";
$solrIntruct .= $workspace; $solrIntruct .= $workspace;
@@ -92,7 +92,8 @@ class BpmnEngine_SearchIndexAccess_Solr
if ($sysConf['proxy_user'] != '') { if ($sysConf['proxy_user'] != '') {
curl_setopt( $handlerTotal, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : '') ); curl_setopt( $handlerTotal, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : '') );
} }
curl_setopt($handlerTotal, CURLOPT_HTTPHEADER, array('Expect:')); curl_setopt( $handlerTotal, CURLOPT_HTTPHEADER, array ('Expect:'
) );
} }
$responseTotal = curl_exec( $handlerTotal ); $responseTotal = curl_exec( $handlerTotal );
@@ -175,7 +176,8 @@ class BpmnEngine_SearchIndexAccess_Solr
if ($sysConf['proxy_user'] != '') { if ($sysConf['proxy_user'] != '') {
curl_setopt( $handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : '') ); curl_setopt( $handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : '') );
} }
curl_setopt($handler, CURLOPT_HTTPHEADER, array('Expect:')); curl_setopt( $handler, CURLOPT_HTTPHEADER, array ('Expect:'
) );
} }
$response = curl_exec( $handler ); $response = curl_exec( $handler );
@@ -210,12 +212,12 @@ class BpmnEngine_SearchIndexAccess_Solr
$handler = curl_init( $solrIntruct ); $handler = curl_init( $solrIntruct );
curl_setopt( $handler, CURLOPT_RETURNTRANSFER, true ); curl_setopt( $handler, CURLOPT_RETURNTRANSFER, true );
curl_setopt ($handler, CURLOPT_HTTPHEADER, array ( curl_setopt( $handler, CURLOPT_HTTPHEADER, array ('Content-type:application/xml'
'Content-type:application/xml'
) ); // -H ) ); // -H
curl_setopt( $handler, CURLOPT_BINARYTRANSFER, TRUE ); // --data-binary curl_setopt( $handler, CURLOPT_BINARYTRANSFER, TRUE ); // --data-binary
curl_setopt( $handler, CURLOPT_POSTFIELDS, $solrUpdateDocument->document ); // data curl_setopt( $handler, CURLOPT_POSTFIELDS, $solrUpdateDocument->document ); // data
//Apply proxy settings //Apply proxy settings
$sysConf = System::getSystemConfiguration(); $sysConf = System::getSystemConfiguration();
if ($sysConf['proxy_host'] != '') { if ($sysConf['proxy_host'] != '') {
@@ -226,7 +228,8 @@ class BpmnEngine_SearchIndexAccess_Solr
if ($sysConf['proxy_user'] != '') { if ($sysConf['proxy_user'] != '') {
curl_setopt( $handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : '') ); curl_setopt( $handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : '') );
} }
curl_setopt($handler, CURLOPT_HTTPHEADER, array('Expect:')); curl_setopt( $handler, CURLOPT_HTTPHEADER, array ('Expect:'
) );
} }
$response = curl_exec( $handler ); $response = curl_exec( $handler );
@@ -258,12 +261,12 @@ class BpmnEngine_SearchIndexAccess_Solr
$handler = curl_init( $solrIntruct ); $handler = curl_init( $solrIntruct );
curl_setopt( $handler, CURLOPT_RETURNTRANSFER, true ); curl_setopt( $handler, CURLOPT_RETURNTRANSFER, true );
curl_setopt ($handler, CURLOPT_HTTPHEADER, array ( curl_setopt( $handler, CURLOPT_HTTPHEADER, array ('Content-type:application/xml'
'Content-type:application/xml'
) ); // -H ) ); // -H
curl_setopt( $handler, CURLOPT_BINARYTRANSFER, TRUE ); // --data-binary curl_setopt( $handler, CURLOPT_BINARYTRANSFER, TRUE ); // --data-binary
curl_setopt( $handler, CURLOPT_POSTFIELDS, "<commit/>" ); // data curl_setopt( $handler, CURLOPT_POSTFIELDS, "<commit/>" ); // data
//Apply proxy settings //Apply proxy settings
$sysConf = System::getSystemConfiguration(); $sysConf = System::getSystemConfiguration();
if ($sysConf['proxy_host'] != '') { if ($sysConf['proxy_host'] != '') {
@@ -274,7 +277,8 @@ class BpmnEngine_SearchIndexAccess_Solr
if ($sysConf['proxy_user'] != '') { if ($sysConf['proxy_user'] != '') {
curl_setopt( $handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : '') ); curl_setopt( $handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : '') );
} }
curl_setopt($handler, CURLOPT_HTTPHEADER, array('Expect:')); curl_setopt( $handler, CURLOPT_HTTPHEADER, array ('Expect:'
) );
} }
$response = curl_exec( $handler ); $response = curl_exec( $handler );
@@ -307,12 +311,12 @@ class BpmnEngine_SearchIndexAccess_Solr
$handler = curl_init( $solrIntruct ); $handler = curl_init( $solrIntruct );
curl_setopt( $handler, CURLOPT_RETURNTRANSFER, true ); curl_setopt( $handler, CURLOPT_RETURNTRANSFER, true );
curl_setopt ($handler, CURLOPT_HTTPHEADER, array ( curl_setopt( $handler, CURLOPT_HTTPHEADER, array ('Content-type:application/xml'
'Content-type:application/xml'
) ); // -H ) ); // -H
curl_setopt( $handler, CURLOPT_BINARYTRANSFER, TRUE ); // --data-binary curl_setopt( $handler, CURLOPT_BINARYTRANSFER, TRUE ); // --data-binary
curl_setopt( $handler, CURLOPT_POSTFIELDS, "<rollback/>" ); // data curl_setopt( $handler, CURLOPT_POSTFIELDS, "<rollback/>" ); // data
//Apply proxy settings //Apply proxy settings
$sysConf = System::getSystemConfiguration(); $sysConf = System::getSystemConfiguration();
if ($sysConf['proxy_host'] != '') { if ($sysConf['proxy_host'] != '') {
@@ -323,7 +327,8 @@ class BpmnEngine_SearchIndexAccess_Solr
if ($sysConf['proxy_user'] != '') { if ($sysConf['proxy_user'] != '') {
curl_setopt( $handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : '') ); curl_setopt( $handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : '') );
} }
curl_setopt($handler, CURLOPT_HTTPHEADER, array('Expect:')); curl_setopt( $handler, CURLOPT_HTTPHEADER, array ('Expect:'
) );
} }
$response = curl_exec( $handler ); $response = curl_exec( $handler );
@@ -356,12 +361,12 @@ class BpmnEngine_SearchIndexAccess_Solr
$handler = curl_init( $solrIntruct ); $handler = curl_init( $solrIntruct );
curl_setopt( $handler, CURLOPT_RETURNTRANSFER, true ); curl_setopt( $handler, CURLOPT_RETURNTRANSFER, true );
curl_setopt ($handler, CURLOPT_HTTPHEADER, array ( curl_setopt( $handler, CURLOPT_HTTPHEADER, array ('Content-type:application/xml'
'Content-type:application/xml'
) ); // -H ) ); // -H
curl_setopt( $handler, CURLOPT_BINARYTRANSFER, TRUE ); // --data-binary curl_setopt( $handler, CURLOPT_BINARYTRANSFER, TRUE ); // --data-binary
curl_setopt( $handler, CURLOPT_POSTFIELDS, "<optimize/>" ); // data curl_setopt( $handler, CURLOPT_POSTFIELDS, "<optimize/>" ); // data
//Apply proxy settings //Apply proxy settings
$sysConf = System::getSystemConfiguration(); $sysConf = System::getSystemConfiguration();
if ($sysConf['proxy_host'] != '') { if ($sysConf['proxy_host'] != '') {
@@ -372,7 +377,8 @@ class BpmnEngine_SearchIndexAccess_Solr
if ($sysConf['proxy_user'] != '') { if ($sysConf['proxy_user'] != '') {
curl_setopt( $handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : '') ); curl_setopt( $handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : '') );
} }
curl_setopt($handler, CURLOPT_HTTPHEADER, array('Expect:')); curl_setopt( $handler, CURLOPT_HTTPHEADER, array ('Expect:'
) );
} }
$response = curl_exec( $handler ); $response = curl_exec( $handler );
@@ -387,8 +393,7 @@ class BpmnEngine_SearchIndexAccess_Solr
/** /**
* Return the list of the stored fields in Solr * Return the list of the stored fields in Solr
* *
* @param string $workspace * @param string $workspace Solr instance name
* Solr instance name
* @throws Exception * @throws Exception
* @return void mixed of field names * @return void mixed of field names
*/ */
@@ -416,7 +421,8 @@ class BpmnEngine_SearchIndexAccess_Solr
if ($sysConf['proxy_user'] != '') { if ($sysConf['proxy_user'] != '') {
curl_setopt( $handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : '') ); curl_setopt( $handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : '') );
} }
curl_setopt($handler, CURLOPT_HTTPHEADER, array('Expect:')); curl_setopt( $handler, CURLOPT_HTTPHEADER, array ('Expect:'
) );
} }
$response = curl_exec( $handler ); $response = curl_exec( $handler );
@@ -443,6 +449,7 @@ class BpmnEngine_SearchIndexAccess_Solr
return; return;
// $registry = Zend_Registry::getInstance(); // $registry = Zend_Registry::getInstance();
$solrIntruct = ''; $solrIntruct = '';
// get configuration information in base to workspace parameter // get configuration information in base to workspace parameter
$solrIntruct = (substr( $this->_solrHost, - 1 ) == "/") ? $this->_solrHost : $this->_solrHost . "/"; $solrIntruct = (substr( $this->_solrHost, - 1 ) == "/") ? $this->_solrHost : $this->_solrHost . "/";
@@ -451,12 +458,12 @@ class BpmnEngine_SearchIndexAccess_Solr
$handler = curl_init( $solrIntruct ); $handler = curl_init( $solrIntruct );
curl_setopt( $handler, CURLOPT_RETURNTRANSFER, true ); curl_setopt( $handler, CURLOPT_RETURNTRANSFER, true );
curl_setopt ($handler, CURLOPT_HTTPHEADER, array ( curl_setopt( $handler, CURLOPT_HTTPHEADER, array ('Content-type:application/xml'
'Content-type:application/xml'
) ); // -H ) ); // -H
curl_setopt( $handler, CURLOPT_BINARYTRANSFER, TRUE ); // --data-binary curl_setopt( $handler, CURLOPT_BINARYTRANSFER, TRUE ); // --data-binary
curl_setopt( $handler, CURLOPT_POSTFIELDS, "<delete><query>*:*</query></delete>" ); // data curl_setopt( $handler, CURLOPT_POSTFIELDS, "<delete><query>*:*</query></delete>" ); // data
//Apply proxy settings //Apply proxy settings
$sysConf = System::getSystemConfiguration(); $sysConf = System::getSystemConfiguration();
if ($sysConf['proxy_host'] != '') { if ($sysConf['proxy_host'] != '') {
@@ -467,7 +474,8 @@ class BpmnEngine_SearchIndexAccess_Solr
if ($sysConf['proxy_user'] != '') { if ($sysConf['proxy_user'] != '') {
curl_setopt( $handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : '') ); curl_setopt( $handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : '') );
} }
curl_setopt($handler, CURLOPT_HTTPHEADER, array('Expect:')); curl_setopt( $handler, CURLOPT_HTTPHEADER, array ('Expect:'
) );
} }
$response = curl_exec( $handler ); $response = curl_exec( $handler );
@@ -494,6 +502,7 @@ class BpmnEngine_SearchIndexAccess_Solr
return; return;
// $registry = Zend_Registry::getInstance(); // $registry = Zend_Registry::getInstance();
$solrIntruct = ''; $solrIntruct = '';
// get configuration information in base to workspace parameter // get configuration information in base to workspace parameter
$solrIntruct = (substr( $this->_solrHost, - 1 ) == "/") ? $this->_solrHost : $this->_solrHost . "/"; $solrIntruct = (substr( $this->_solrHost, - 1 ) == "/") ? $this->_solrHost : $this->_solrHost . "/";
@@ -502,12 +511,12 @@ class BpmnEngine_SearchIndexAccess_Solr
$handler = curl_init( $solrIntruct ); $handler = curl_init( $solrIntruct );
curl_setopt( $handler, CURLOPT_RETURNTRANSFER, true ); curl_setopt( $handler, CURLOPT_RETURNTRANSFER, true );
curl_setopt ($handler, CURLOPT_HTTPHEADER, array ( curl_setopt( $handler, CURLOPT_HTTPHEADER, array ('Content-type:application/xml'
'Content-type:application/xml'
) ); // -H ) ); // -H
curl_setopt( $handler, CURLOPT_BINARYTRANSFER, TRUE ); // --data-binary curl_setopt( $handler, CURLOPT_BINARYTRANSFER, TRUE ); // --data-binary
curl_setopt( $handler, CURLOPT_POSTFIELDS, "<delete><query>" . $idQuery . "</query></delete>" ); // data curl_setopt( $handler, CURLOPT_POSTFIELDS, "<delete><query>" . $idQuery . "</query></delete>" ); // data
//Apply proxy settings //Apply proxy settings
$sysConf = System::getSystemConfiguration(); $sysConf = System::getSystemConfiguration();
if ($sysConf['proxy_host'] != '') { if ($sysConf['proxy_host'] != '') {
@@ -518,7 +527,8 @@ class BpmnEngine_SearchIndexAccess_Solr
if ($sysConf['proxy_user'] != '') { if ($sysConf['proxy_user'] != '') {
curl_setopt( $handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : '') ); curl_setopt( $handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : '') );
} }
curl_setopt($handler, CURLOPT_HTTPHEADER, array('Expect:')); curl_setopt( $handler, CURLOPT_HTTPHEADER, array ('Expect:'
) );
} }
$response = curl_exec( $handler ); $response = curl_exec( $handler );
@@ -575,6 +585,7 @@ class BpmnEngine_SearchIndexAccess_Solr
} }
// echo "<pre>"; // echo "<pre>";
$resultFormat = '&wt=json'; $resultFormat = '&wt=json';
$solrIntruct = (substr( $this->_solrHost, - 1 ) == "/") ? $this->_solrHost : $this->_solrHost . "/"; $solrIntruct = (substr( $this->_solrHost, - 1 ) == "/") ? $this->_solrHost : $this->_solrHost . "/";
@@ -603,7 +614,8 @@ class BpmnEngine_SearchIndexAccess_Solr
if ($sysConf['proxy_user'] != '') { if ($sysConf['proxy_user'] != '') {
curl_setopt( $handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : '') ); curl_setopt( $handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : '') );
} }
curl_setopt($handler, CURLOPT_HTTPHEADER, array('Expect:')); curl_setopt( $handler, CURLOPT_HTTPHEADER, array ('Expect:'
) );
} }
$response = curl_exec( $handler ); $response = curl_exec( $handler );