/**
  * Checks in a checked out document
  * 
  * @param string $repositoryId
  * @param string $documentId
  * @param boolean $major
  * @param string $changeToken [optional]
  * @param array $properties [optional]
  * @param contentStream $contentStream [optional]
  * @param string $checkinComment [optional]
  * @return string $documentId
  */
 public function checkIn($repositoryId, $documentId, $major, $changeToken = '', $properties = array(), $contentStream = null, $checkinComment = '')
 {
     $result = parent::checkIn($repositoryId, $documentId, $major, $changeToken, $properties, $contentStream, $checkinComment);
     if ($result['status_code'] == 0) {
         return $result['results'];
     } else {
         return new PEAR_Error($result['message']);
     }
 }
Exemple #2
0
 function testVersioningService()
 {
     $VersioningService = new KTVersioningService($this->ktapi);
     $NavigationService = new KTNavigationService($this->ktapi);
     // set up the folder/doc tree structure with which we will be testing
     $this->createFolderDocStructure();
     $RepositoryService = new KTRepositoryService();
     $response = $RepositoryService->getRepositories();
     $this->assertEqual($response['status_code'], 0);
     $this->assertNotNull($response['results'][0]);
     //
     // we only expect one repository
     $repository = $response['results'][0];
     $repositoryId = $repository['repositoryId'];
     // test deletion of document via deleteAllVersions
     $versionSeriesId = 'D' . $this->docs[0]->get_documentid();
     $response = $VersioningService->deleteAllVersions($repositoryId, $versionSeriesId);
     $this->assertEqual($response['status_code'], 0);
     $this->assertNotNull($response['results']);
     // TODO test checkout of document
     $documentId = CMISUtil::encodeObjectId('Document', $this->docs[1]->get_documentid());
     $response = $VersioningService->checkOut($repositoryId, $documentId);
     $this->assertEqual($response['status_code'], 0);
     $this->assertNotNull($response['results']);
     ////        // use this id for cancel checkout and checkin, not the original document id
     ////        $pwcId = $response['results'];
     $pwcId = CMISUtil::encodeObjectId(DOCUMENT, $this->docs[1]->get_documentid());
     // try again, this time it should fail - not working at the moment as ktapi registers the same user for download
     // even if already checked out, so no error is generated unless a different user attempts to do a checkout
     /*
     $response = $VersioningService->checkOut($repositoryId, $documentId);
     $this->assertEqual($response['status_code'], 1);
     $this->assertNotNull($response['message']);
     */
     // test cancel checkout
     //        echo "WITH: $pwcId<BR>";
     $response = $VersioningService->cancelCheckOut($repositoryId, $pwcId);
     $this->assertEqual($response['status_code'], 0);
     $this->assertNotNull($response['results']);
     // test cancel checkout of document no longer checked out
     $response = $VersioningService->cancelCheckOut($repositoryId, $pwcId);
     $this->assertEqual($response['status_code'], 1);
     $this->assertNotNull($response['message']);
     // test listing of checked out documents
     // first check out the document again :)
     $response = $VersioningService->checkOut($repositoryId, $documentId);
     // now check that it appears in the listing
     $response = $NavigationService->getCheckedOutDocs($repositoryId, false, false);
     $this->assertEqual($response['status_code'], 0);
     $this->assertNotNull($response['results']);
     $this->assertTrue($this->findInPropertiesArray('ObjectId', $documentId, $response['results']));
     // now let's cancel the checkout so that we can delete later during cleanup :)
     $response = $VersioningService->cancelCheckOut($repositoryId, $pwcId);
     // TODO test checkin
     // TODO add testing of failure conditions - e.g. checked out/immutable document (for all appropriate functions)
     // tear down the folder/doc tree structure with which we were testing
     $this->cleanupFolderDocStructure();
 }