From 2cbb04a11b21fa996697cef251656a661340e905 Mon Sep 17 00:00:00 2001 From: Conrad Vermeulen Date: Wed, 28 Nov 2007 21:41:05 +0000 Subject: [PATCH] WSA-49 "Improve the document_detail and folder_detail records to incorporate more fields available on the document" Updated. --- ktwebservice/webservice.php | 382 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 1 file changed, 141 insertions(+), 241 deletions(-) diff --git a/ktwebservice/webservice.php b/ktwebservice/webservice.php index c0c321d..e953f92 100644 --- a/ktwebservice/webservice.php +++ b/ktwebservice/webservice.php @@ -182,6 +182,9 @@ class KTWebService 'id' => 'int', 'item_type' => 'string', + 'custom_document_no' => 'string', + 'oem_document_no' => 'string', + 'title' => 'string', 'document_type' => 'string', 'filename' => 'string', @@ -261,6 +264,10 @@ class KTWebService 'message'=>'string', 'document_id' => 'int', + + 'custom_document_no' => 'string', + 'oem_document_no' => 'string', + 'title' => 'string', 'document_type' => 'string', 'full_path' => 'string', @@ -279,7 +286,7 @@ class KTWebService 'owned_by'=>'string', - 'version' => 'string', + 'version' => 'float', 'is_immutable'=>'boolean', 'permissions' => 'string', @@ -293,6 +300,7 @@ class KTWebService 'storage_path' => 'string', + 'metadata' => "{urn:$this->namespace}kt_metadata_fieldsets", 'links' => "{urn:$this->namespace}kt_linked_documents", 'transitions' => "{urn:$this->namespace}kt_workflow_transitions", @@ -304,17 +312,13 @@ class KTWebService if (defined('HAS_SEARCH_FUNCTIONALITY')) { - - - - - - - $this->__typedef["{urn:$this->namespace}kt_search_result_item"] = array( 'document_id' => 'int', + 'custom_document_no' => 'string', + 'oem_document_no' => 'string', + 'relevance' => 'float', 'text' => 'string', @@ -336,7 +340,7 @@ class KTWebService 'owned_by' => 'string', - 'version' => 'string', + 'version' => 'float', 'is_immutable' => 'boolean', 'permissions' => 'string', @@ -462,11 +466,28 @@ class KTWebService 'datetime' => 'string' ); + if ($this->version >= 2) + { + $this->__typedef["{urn:$this->namespace}kt_document_transaction_history_item"] = + array( + 'transaction_name'=>'string', + 'username'=>'string', + 'version' => 'float', + 'comment' => 'string', + 'datetime' => 'string' + ); + } + + $this->__typedef["{urn:$this->namespace}kt_linked_document"] = array( 'document_id'=>'int', - 'title'=>'string', - 'size' => 'int', + 'custom_document_no' => 'string', + 'oem_document_no' => 'string', + 'title'=>'string', + 'document_type'=>'string', + 'filesize' => 'int', + 'version' => 'float', 'workflow' => 'string', 'workflow_state' => 'string', 'link_type' => 'string' @@ -508,6 +529,17 @@ class KTWebService 'content_version'=>'string', ); + if ($this->version >= 2) + { + $this->__typedef["{urn:$this->namespace}kt_document_version_history_item"] = + array( + 'user'=>'string', + 'metadata_version'=>'int', + 'content_version'=>'float', + ); + } + + $this->__typedef["{urn:$this->namespace}kt_document_version_history"] = array( array( @@ -1023,6 +1055,12 @@ class KTWebService 'out' => array( 'return' => "{urn:$this->namespace}kt_client_policies_response" ), ); + if ($this->version >= 2) + { + $this->__dispatch_map['get_client_policies']['in'] = array('session_id'=>'string', 'client'=>'string'); + + } + } @@ -1717,35 +1755,59 @@ class KTWebService $detail['version_history'] = array(); $detail['transaction_history'] = array(); - if (stripos($detailstr,'M') !== false) { $response = $this->get_document_metadata($session_id, $document_id); $detail['metadata'] = $response->value['metadata']; + $detail['metadata']->name = 'metadata'; + } + else + { + $detail['metadata'] = KTWebService::_encode_metadata_fields($detail['metadata']); } if (stripos($detailstr,'L') !== false) { - $response = $this->get_document_metadata($session_id, $document_id); + $response = $this->get_document_links($session_id, $document_id); $detail['links'] = $response->value['links']; + $detail['links']->name = 'links'; + } + else + { + $detail['links'] = KTWebService::_encode_document_links($detail['links']); } if (stripos($detailstr,'T') !== false) { $response = $this->get_document_workflow_transitions($session_id, $document_id); - $detail['transitions'] = $response->value['transitions']; + $detail['transitions'] = $response->value['transitions'] ; + $detail['transitions']->name = 'transitions'; + } + else + { + $detail['transitions'] = KTWebService::_encode_document_workflow_transitions($detail['transitions']); } if (stripos($detailstr,'V') !== false) { $response = $this->get_document_version_history($session_id, $document_id); - $detail['version_history'] = $response->value['history']; + $detail['version_history'] = $response->value['history']; + $detail['version_history']->name = 'version_history'; + } + else + { + $detail['version_history'] = KTWebService::_encode_version_history($detail['version_history'],'version_history'); } if (stripos($detailstr,'H') !== false) { $response = $this->get_document_transaction_history($session_id, $document_id); - $detail['transaction_history'] = $response->value['history']; + $detail['transaction_history'] = $response->value['history']; + $detail['transaction_history']->name = 'transaction_history'; + } + else + { + $detail['transaction_history'] = KTWebService::_encode_transaction_history($detail['transaction_history'],'transaction_history'); } } @@ -1826,65 +1888,10 @@ class KTWebService return new SOAP_Value('return',"{urn:$this->namespace}kt_document_detail", $response); } - $detailstr = $detail; - - $detail = $document->get_detail(); - if (PEAR::isError($detail)) - { - $response['status_code'] = KTWS_ERR_PROBLEM; - $response['message'] = $detail->getMessage(); - - $this->debug("get_document_detail_by_name - cannot get document detail - " . $detail->getMessage(), $session_id); - - return new SOAP_Value('return',"{urn:$this->namespace}kt_document_detail", $response); - } - - $detail['status_code']=KTWS_SUCCESS; - $detail['message']=''; - - - if ($this->version >= 2) - { - - $detail['metadata'] = array(); - $detail['links'] = array(); - $detail['transitions'] = array(); - $detail['version_history'] = array(); - $detail['transaction_history'] = array(); - - if (stripos($detailstr,'M') !== false) - { - $response = $this->get_document_metadata($session_id, $document_id); - $detail['metadata'] = $response->value['metadata']; - } - - if (stripos($detailstr,'L') !== false) - { - $response = $this->get_document_metadata($session_id, $document_id); - $detail['links'] = $response->value['links']; - } - - if (stripos($detailstr,'T') !== false) - { - $response = $this->get_document_workflow_transitions($session_id, $document_id); - $detail['transitions'] = $response->value['transitions']; - } + return $this->get_document_detail($session_id, $document->documentid, $detail); + } - if (stripos($detailstr,'V') !== false) - { - $response = $this->get_document_version_history($session_id, $document_id); - $detail['version_history'] = $response->value['history']; - } - if (stripos($detailstr,'H') !== false) - { - $response = $this->get_document_transaction_history($session_id, $document_id); - $detail['transaction_history'] = $response->value['history']; - } - } - - return new SOAP_Value('return',"{urn:$this->namespace}kt_document_detail", $detail); - } /** * Adds a document to the repository. @@ -3174,100 +3181,42 @@ class KTWebService } /** - * Encodes the array as a kt_metadata_selection_item - * - * @param aray $item - * @param string $name - * @return SOAP_Value of kt_metadata_selection_item - * @access private - * @static - */ - function _encode_metadata_selection_item($item, $name='item') - { - if (!is_null($item['id'])) - { - $item['id'] = (int) $item['id']; - } - - if (!is_null($item['parent_id'])) - { - $item['parent_id'] = (int) $item['parent_id']; - } - - return new SOAP_Value($name,"{urn:$this->namespace}kt_metadata_selection_item", $item); - } - - /** - * Encode an array as kt_metadata_selection + * Encode an array as kt_metadata_fields * - * @param array $selection + * @param array $fields * @param string $name - * @return SOAP_Value of kt_metadata_selection + * @return SOAP_Value of kt_metadata_fields * @access private * @static */ - - function _encode_metadata_selection($selection, $name='selection') + function _encode_metadata_fields($fields, $name='fields') { - $encoded=array(); - foreach($selection as $field) - { - $encoded[] = KTWebService::_encode_metadata_selection_item($field); - } - if (empty($encoded)) + foreach($fields as $key=>$field) { - $encoded=null; - } + $selection = $field['selection']; + foreach($selection as $skey=>$sitem) + { + if (!is_null($item['id'])) + { + $sitem['id'] = (int) $sitem['id']; + } + + if (!is_null($sitem['parent_id'])) + { + $sitem['parent_id'] = (int) $sitem['parent_id']; + } + $selection[$skey] = new SOAP_Value($name,"{urn:$this->namespace}kt_metadata_selection_item", $sitem); + } - return new SOAP_Value($name,"{urn:$this->namespace}kt_metadata_selection", $encoded); - } + $field['selection'] = new SOAP_Value($name,"{urn:$this->namespace}kt_metadata_selection", $selection); - /** - * Encode an array as kt_metadata_field - * - * @param arra $field - * @param string $name - * @return SOAP_Value of kt_metadata_field - * @access private - * @static - */ + $field['required'] = is_null($field['required'])?false:(bool) $field['required']; - function _encode_metadata_field($field, $name='field') - { - if (!empty($field['selection'])) - { - $field['selection'] = KTWebService::_encode_metadata_selection($field['selection']); - } - if (!is_null($field['required'])) - { - $field['required'] = (bool) $field['required']; + $fields[$key] = new SOAP_Value($name,"{urn:$this->namespace}kt_metadata_field", $field); } - return new SOAP_Value($name,"{urn:$this->namespace}kt_metadata_field", $field); - } - - /** - * Encode an array as kt_metadata_fields - * - * @param array $fields - * @param string $name - * @return SOAP_Value of kt_metadata_fields - * @access private - * @static - */ - function _encode_metadata_fields($fields, $name='fields') - { - $encoded=array(); - foreach($fields as $field) - { - $encoded[] = KTWebService::_encode_metadata_field($field); - } - if (empty($encoded)) - { - $encoded=null; - } - return new SOAP_Value($name,"{urn:$this->namespace}kt_metadata_fields", $encoded); + return new SOAP_Value($name,"{urn:$this->namespace}kt_metadata_fields", $fields); } /** @@ -3558,11 +3507,16 @@ class KTWebService } $response['status_code'] = KTWS_SUCCESS; - $response['transitions'] = $result; + $response['transitions'] = KTWebService::_encode_document_workflow_transitions($result); return new SOAP_Value('return',"{urn:$this->namespace}kt_workflow_transitions_response", $response); } + function _encode_document_workflow_transitions($transitions, $name='transitions') + { + return new SOAP_Value($name,"{urn:$this->namespace}kt_workflow_transitions", $transitions); + } + /** * Returns the current state that the document is in. * @@ -3608,20 +3562,6 @@ class KTWebService } /** - * Encode an array as kt_document_transaction_history_item - * - * @param array $item - * @param string $name - * @return SOAP_Value of kt_document_transaction_history_item - * @access private - * @static - */ - function _encode_transaction_history_item($item, $name='item') - { - return new SOAP_Value($name,"{urn:$this->namespace}kt_document_transaction_history_item", $item); - } - - /** * Encode an array as kt_document_transaction_history * * @param array $history @@ -3632,29 +3572,12 @@ class KTWebService */ function _encode_transaction_history($history, $name='history') { - $encoded=array(); - foreach($history as $item) + foreach($history as $key=>$item) { - $encoded[] = KTWebService::_encode_transaction_history_item($item); + $history[$key] = new SOAP_Value('item',"{urn:$this->namespace}kt_document_transaction_history_item", $item); } - return new SOAP_Value($name,"{urn:$this->namespace}kt_document_transaction_history", $encoded); - } - - /** - * Encode an array as kt_document_transaction_history_response - * - * @param array $response - * @param string $name - * @return SOAP_Value of kt_document_transaction_history_response - * @access private - * @static - */ - function _encode_transaction_history_response($response, $name='return') - { - $response['history'] = KTWebService::_encode_transaction_history($response['history']); - - return new SOAP_Value($name,"{urn:$this->namespace}kt_document_transaction_history_response", $response); + return new SOAP_Value($name,"{urn:$this->namespace}kt_document_transaction_history", $history); } /** @@ -3695,23 +3618,9 @@ class KTWebService } $response['status_code'] = KTWS_SUCCESS; - $response['history'] = $result; + $response['history'] = KTWebService::_encode_transaction_history($result); - return KTWebService::_encode_transaction_history_response($response); - } - - /** - * Encode an array as kt_document_version_history_item - * - * @param array $item - * @param string $name - * @return SOAP_Value of kt_document_version_history_item - * @access private - * @static - */ - function _encode_version_history_item($item, $name='item') - { - return new SOAP_Value($name,"{urn:$this->namespace}kt_document_version_history_item", $item); + return new SOAP_Value('return',"{urn:$this->namespace}kt_document_transaction_history_response", $response); } /** @@ -3725,33 +3634,15 @@ class KTWebService */ function _encode_version_history($history, $name='history') { - $encoded=array(); - foreach($history as $item) + foreach($history as $key=>$item) { - $encoded[] = KTWebService::_encode_version_history_item($item); + $history[$key] = new SOAP_Value('item',"{urn:$this->namespace}kt_document_version_history_item", $item); } - return new SOAP_Value($name,"{urn:$this->namespace}kt_document_version_history", $encoded); + return new SOAP_Value($name,"{urn:$this->namespace}kt_document_version_history", $history); } /** - * Encode an array as kt_document_version_history_response - * - * @param array $response - * @param string $name - * @return SOAP_Value of kt_document_version_history_response - * @access private - * @static - */ - function _encode_version_history_response($response, $name='return') - { - $response['history'] = KTWebService::_encode_version_history($response['history']); - - return new SOAP_Value($name,"{urn:$this->namespace}kt_document_version_history_response", $response); - } - - - /** * Returns the version history. * * @param string $session_id @@ -3790,9 +3681,9 @@ class KTWebService } $response['status_code'] = KTWS_SUCCESS; - $response['history'] = $result; + $response['history'] =KTWebService::_encode_version_history($result); - return KTWebService::_encode_version_history_response($response); + return new SOAP_Value('return',"{urn:$this->namespace}kt_document_version_history_response", $response); } @@ -3830,12 +3721,26 @@ class KTWebService } $links = $document->get_linked_documents(); - $response['links'] = new SOAP_Value('links',"{urn:$this->namespace}kt_linked_documents", $links); + $response['links'] = KTWebService::_encode_document_links($links); $response['status_code'] = KTWS_SUCCESS; return new SOAP_Value('return',"{urn:$this->namespace}kt_linked_document_response", $response); } + function _encode_document_links($links, $name='links') + { + foreach($links as $key=>$link) + { + $link['document_id'] = (int) $link['document_id']; + $link['filesize'] = (int) $link['filesize']; + + $links[$key] = new SOAP_Value('links',"{urn:$this->namespace}kt_linked_document", $link); + } + + return new SOAP_Value($name,"{urn:$this->namespace}kt_linked_documents", $links); + } + + /** * Removes a link between documents * @@ -3940,17 +3845,13 @@ class KTWebService } function _encode_client_policies($policies) - { - $encoded=array(); - foreach($policies as $policy) - { - $encoded[] = new SOAP_Value('policy',"{urn:$this->namespace}kt_client_policy", $policy); - } - if (empty($encoded)) + { + foreach($policies as $key=>$policy) { - $encoded=null; + $policies[$key] = new SOAP_Value('policy',"{urn:$this->namespace}kt_client_policy", $policy); } - return new SOAP_Value('policies',"{urn:$this->namespace}kt_client_policies_array", $encoded); + + return new SOAP_Value('policies',"{urn:$this->namespace}kt_client_policies_array", $policies); } /** @@ -3959,7 +3860,7 @@ class KTWebService * @param string $session_id * @return kt_client_policies_response */ - function get_client_policies($session_id) + function get_client_policies($session_id, $client=null) { $this->debug("get_client_policies('$session_id')"); $config = KTConfig::getSingleton(); @@ -4227,8 +4128,7 @@ class KTWebService } - $webservice = new KTWebService(); $webservice->run(); -?> +?> \ No newline at end of file -- libgit2 0.21.4