/**
  * Deals with GET actions for checkedout documents. 
  */
 public function GET_action()
 {
     $RepositoryService = new RepositoryService();
     $NavigationService = new NavigationService(KT_cmis_atom_service_helper::getKt());
     $repositories = $RepositoryService->getRepositories();
     $repositoryId = $repositories[0]['repositoryId'];
     $checkedout = $NavigationService->getCheckedOutDocs($repositoryId);
     //print_r($checkedout);exit;
     //Create a new response feed
     $feed = new KT_cmis_atom_responseFeed_GET(CMIS_APP_BASE_URI);
     $workspace = $feed->getWorkspace();
     $feed->newField('title', 'Checked out Documents', $feed);
     // TODO dynamic?
     $feedElement = $feed->newField('author');
     $element = $feed->newField('name', 'admin', $feedElement);
     $feed->appendChild($feedElement);
     $feed->appendChild($feed->newElement('id', 'urn:uuid:checkedout'));
     // TODO get actual most recent update time, only use current if no other available
     $feed->appendChild($feed->newElement('updated', KT_cmis_atom_service_helper::formatDatestamp()));
     $link = $feed->newElement('link');
     $link->appendChild($feed->newAttr('rel', 'self'));
     $link->appendChild($feed->newAttr('href', CMIS_APP_BASE_URI . $workspace . '/checkedout'));
     $feed->appendChild($link);
     $link = $feed->newElement('link');
     $link->appendChild($feed->newAttr('rel', 'first'));
     $link->appendChild($feed->newAttr('href', CMIS_APP_BASE_URI . $workspace . '/checkedout/pageNo=1&pageSize=0'));
     $link->appendChild($feed->newAttr('type', 'application/atom+xml;type=feed'));
     $feed->appendChild($link);
     $link = $feed->newElement('link');
     $link->appendChild($feed->newAttr('rel', 'last'));
     // TODO set page number correctly - to be done when we support paging the the API
     $link->appendChild($feed->newAttr('href', CMIS_APP_BASE_URI . $workspace . '/checkedout/pageNo=1&pageSize=0'));
     $link->appendChild($feed->newAttr('type', 'application/atom+xml;type=feed'));
     $feed->appendChild($link);
     foreach ($checkedout as $cmisEntry) {
         KT_cmis_atom_service_helper::createObjectEntry($feed, $cmisEntry, $folderName, true);
         //			// after each entry, add app:edited tag
         //           	$feed->newField('app:edited', KT_cmis_atom_service_helper::formatDatestamp(), $feed);
     }
     $feed->newField('cmis:hasMoreItems', 'false', $feed);
     //        $entry = null;
     //        $feed->newField('cmis:hasMoreItems', 'false', $entry, true);
     //Expose the responseFeed
     $this->responseFeed = $feed;
 }
 /**
  * Retrieves the list of types|type definition as a CMIS AtomPub feed
  *
  * @param string $typeDef Type requested - 'All Types' indicates a listing, else only a specific type
  * @param array $types The types found
  * @return string CMIS AtomPub feed
  */
 public static function getTypeFeed($typeDef, $types)
 {
     $typesString = '';
     $typesHeading = '';
     switch ($typeDef) {
         case 'all':
         case 'children':
         case 'descendants':
             $typesString = 'types-' . $typeDef;
             $typesHeading = 'All Types';
             break;
         default:
             $typesString = 'type-' . $typeDef;
             $typesHeading = $typeDef;
             break;
     }
     //Create a new response feed
     $feed = new KT_cmis_atom_responseFeed_GET(CMIS_APP_BASE_URI);
     $workspace = $feed->getWorkspace();
     $feed->newField('title', $typesHeading, $feed);
     $feed->newField('id', 'urn:uuid:' . $typesString, $feed);
     // TODO set page number correctly - to be done when we support paging the the API
     // author
     // TODO generate this dynamically (based on???)\
     $feedElement = $feed->newField('author');
     $element = $feed->newField('name', 'admin', $feedElement);
     $feed->appendChild($feedElement);
     // NOTE spec says this link MUST be present but is vague on where it points
     //      as of 0.61c:
     //      "The source link relation points to the underlying CMIS Type Definition as Atom Entry"
     //      so what is the underlying CMIS Type Definition for a collection of base types?
     //      suspect that it only applies when not listing all types, i.e. a base type is asked for
     /*
             $link = $feed->newElement('link');
             $link->appendChild($feed->newAttr('rel','source'));
             $link->appendChild($feed->newAttr('href', CMIS_APP_BASE_URI . $workspace . '/type/' . strtolower($type['typeId'])));
             $feed->appendChild($link);
     */
     // current time: format = 2009-07-13T14:49:27.659+02:00
     $feed->appendChild($feed->newElement('updated', self::formatDatestamp()));
     foreach ($types as $type) {
         $entry = $feed->newEntry();
         $feedElement = $feed->newField('author');
         $element = $feed->newField('name', 'admin', $feedElement);
         $entry->appendChild($feedElement);
         $feedElement = $feed->newField('content', $type['typeId']);
         $entry->appendChild($feedElement);
         $feed->newField('id', 'urn:uuid:type-' . $type['typeId'], $feed);
         // TODO add parents link when not selecting a base type.
         // TODO add children link when type has children
         // TODO add descendants link when type has children
         // NOTE KnowledgeTree currently only supports base types so these are not important at the present time.
         // links
         $link = $feed->newElement('link');
         $link->appendChild($feed->newAttr('rel', 'self'));
         $link->appendChild($feed->newAttr('href', CMIS_APP_BASE_URI . $workspace . '/type/' . strtolower($type['typeId'])));
         $entry->appendChild($link);
         // TODO type link MUST point to base type
         //      KnowledgeTree currently only supports base types so this is not important
         //      at the present time as it will always point at the base type.
         $link = $feed->newElement('link');
         $link->appendChild($feed->newAttr('rel', 'type'));
         $link->appendChild($feed->newAttr('href', CMIS_APP_BASE_URI . $workspace . '/type/' . strtolower($type['typeId'])));
         $entry->appendChild($link);
         $link = $feed->newElement('link');
         $link->appendChild($feed->newAttr('rel', 'repository'));
         $link->appendChild($feed->newAttr('href', CMIS_APP_BASE_URI . '/servicedocument'));
         $entry->appendChild($link);
         $entry->appendChild($feed->newElement('summary', $type['typeId'] . ' Type'));
         $entry->appendChild($feed->newElement('title', $type['typeId']));
         $entry->appendChild($feed->newElement('updated', self::formatDatestamp()));
         // main CMIS entry
         $feedElement = $feed->newElement('cmis:' . strtolower($type['typeId']) . 'Type');
         foreach ($type as $property => $value) {
             $feed->newField('cmis:' . $property, CMISUtil::boolToString($value), $feedElement);
         }
         $entry->appendChild($feedElement);
         // after every entry, append a cmis:terminator tag
         $entry->appendChild($feed->newElement('cmis:terminator'));
     }
     return $feed;
 }