Commit 2af67809bbcad69fc99009d09e541abae036ccad

Authored by Paul Barrett
1 parent b49c3655

CMIS Versioning Services bubbling up exceptions and applying status code mapping

Story ID:2713417. CMIS working with PHP client

Committed by: Paul Barrett
lib/api/ktcmis/ktVersioningService.inc.php
... ... @@ -88,23 +88,16 @@ class KTVersioningService extends KTCMISBase {
88 88 * @return array results
89 89 */
90 90 // TODO set up delivery of content stream? or is that up to the CMIS client?
91   - public function checkOut($repositoryId, $objectId)
  91 + public function checkOut($repositoryId, &$objectId)
92 92 {
93 93 try {
94 94 $result = $this->VersioningService->checkOut($repositoryId, $objectId);
95 95 }
96   - catch (Exception $e)
97   - {
98   - return array(
99   - "status_code" => 1,
100   - "message" => $e->getMessage()
101   - );
  96 + catch (Exception $e) {
  97 + throw $e;
102 98 }
103 99  
104   - return array(
105   - 'status_code' => 0,
106   - 'results' => (!empty($result) ? $result : 'Document Checked Out')
107   - );
  100 + return $result;
108 101 }
109 102  
110 103 /**
... ... @@ -113,28 +106,14 @@ class KTVersioningService extends KTCMISBase {
113 106 * @param string $repositoryId
114 107 * @param string $objectId
115 108 */
116   - // TODO exceptions:
117   - // • ConstraintViolationException: The Repository SHALL throw this exception if ANY of the following conditions are met:
118   - // o The Document’s Object-Type definition’s versionable attribute is FALSE.
119   - // • updateConflictException
120   - // • versioningException
121 109 public function cancelCheckOut($repositoryId, $objectId)
122 110 {
123 111 try {
124 112 $result = $this->VersioningService->cancelCheckOut($repositoryId, $objectId);
125 113 }
126   - catch (Exception $e)
127   - {
128   - return array(
129   - "status_code" => 1,
130   - "message" => $e->getMessage()
131   - );
  114 + catch (Exception $e) {
  115 + throw $e;
132 116 }
133   -
134   - return array(
135   - 'status_code' => 0,
136   - 'results' => (!empty($result) ? $result : 'Document Checkout Cancelled')
137   - );
138 117 }
139 118  
140 119 /**
... ... @@ -155,21 +134,14 @@ class KTVersioningService extends KTCMISBase {
155 134 $checkinComment = '', $policies = array(), $addACEs = array(), $removeACEs = array())
156 135 {
157 136 try {
158   - $result = $this->VersioningService->checkIn($repositoryId, $objectId, $major, $properties, $contentStream,
159   - $checkinComment, $policies, $addACEs, $removeACEs);
  137 + $objectId = $this->VersioningService->checkIn($repositoryId, $objectId, $major, $properties, $contentStream,
  138 + $checkinComment, $policies, $addACEs, $removeACEs);
160 139 }
161   - catch (Exception $e)
162   - {
163   - return array(
164   - "status_code" => 1,
165   - "message" => $e->getMessage()
166   - );
  140 + catch (Exception $e) {
  141 + throw $e;
167 142 }
168 143  
169   - return array(
170   - 'status_code' => 0,
171   - 'results' => (!empty($result) ? $result : 'Document Checked In Successfully')
172   - );
  144 + return $objectId;
173 145 }
174 146  
175 147 }
... ...
lib/api/ktcmis/services/CMISVersioningService.inc.php
... ... @@ -99,8 +99,6 @@ class CMISVersioningService {
99 99 * @param string $repositoryId
100 100 * @param string $objectId
101 101 */
102   - // TODO exceptions:
103   - // • versioningException - The repository MAY throw this exception if the object is a non-current Document Version.
104 102 public function cancelCheckOut($repositoryId, $objectId)
105 103 {
106 104 $objectId = CMISUtil::decodeObjectId($objectId, $typeId);
... ... @@ -158,7 +156,6 @@ class CMISVersioningService {
158 156 public function checkIn($repositoryId, $objectId, $major = true, $properties = array(), $contentStream = null,
159 157 $checkinComment = '', $policies = array(), $addACEs = array(), $removeACEs = array())
160 158 {
161   -
162 159 $objectId = CMISUtil::decodeObjectId($objectId, $typeId);
163 160  
164 161 // throw updateConflictException if the operation is attempting to update an object that is no longer current (as determined by the repository).
... ...
webservice/atompub/cmis/KT_cmis_atom_server.services.inc.php
... ... @@ -530,12 +530,11 @@ class KT_cmis_atom_service_pwc extends KT_cmis_atom_service {
530 530 $repositoryId = KT_cmis_atom_service_helper::getRepositoryId($RepositoryService);
531 531 $VersioningService = new KTVersioningService(KT_cmis_atom_service_helper::getKt());
532 532  
533   - $response = $VersioningService->cancelCheckout($repositoryId, $this->params[0]);
534   -
535   - if ($response['status_code'] == 1) {
536   - $feed = KT_cmis_atom_service_helper::getErrorFeed($this, self::STATUS_SERVER_ERROR, $response['message']);
537   - // Expose the responseFeed
538   - $this->responseFeed = $feed;
  533 + try {
  534 + $response = $VersioningService->cancelCheckout($repositoryId, $this->params[0]);
  535 + }
  536 + catch (Exception $e) {
  537 + $this->responseFeed = KT_cmis_atom_service_helper::getErrorFeed($this, $this->getStatusCode($e), $e->getMessage());
539 538 return null;
540 539 }
541 540  
... ... @@ -677,15 +676,14 @@ class KT_cmis_atom_service_checkedout extends KT_cmis_atom_service {
677 676 return null;
678 677 }
679 678  
680   - $response = $VersioningService->checkOut($repositoryId, $cmisObjectProperties['cmis:objectId']);
681   -
682   - if ($response['status_code'] == 1) {
683   - $feed = KT_cmis_atom_service_helper::getErrorFeed($this, self::STATUS_SERVER_ERROR, 'No object was specified for checkout');
684   - // Expose the responseFeed
685   - $this->responseFeed = $feed;
  679 + try {
  680 + $response = $VersioningService->checkOut($repositoryId, $cmisObjectProperties['cmis:objectId']);
  681 + }
  682 + catch (Exception $e) {
  683 + $this->responseFeed = KT_cmis_atom_service_helper::getErrorFeed($this, $this->getStatusCode($e), $e->getMessage());
686 684 return null;
687 685 }
688   -
  686 +
689 687 $this->setStatus(self::STATUS_CREATED);
690 688 $feed = KT_cmis_atom_service_helper::getObjectFeed($this, $ObjectService, $repositoryId, $cmisObjectProperties['cmis:objectId'], 'POST');
691 689  
... ...