Commit 0ed9c71e71cc1b97022b96ce1529b0565df7bc5f

Authored by Paul Barrett
1 parent 93601409

Story ID: 702240. Created base CMIS repository service helpers and underlying CM…

…IS classes required for read only access. Created ktcmis interface for utilising these service helpers and classes. Created classes required for consumption of interface output by web services (soap only)

Committed by: Paul Barrett
Showing 31 changed files with 3521 additions and 46 deletions
ktcmis/classes/CMISBaseObject.inc.php 0 → 100644
  1 +<?php
  2 +/**
  3 + * CMIS Repository Base Object API class for KnowledgeTree.
  4 + *
  5 + * KnowledgeTree Community Edition
  6 + * Document Management Made Simple
  7 + * Copyright (C) 2008,2009 KnowledgeTree Inc.
  8 + * Portions copyright The Jam Warehouse Software (Pty) Limited
  9 + *
  10 + * This program is free software; you can redistribute it and/or modify it under
  11 + * the terms of the GNU General Public License version 3 as published by the
  12 + * Free Software Foundation.
  13 + *
  14 + * This program is distributed in the hope that it will be useful, but WITHOUT
  15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  16 + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  17 + * details.
  18 + *
  19 + * You should have received a copy of the GNU General Public License
  20 + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21 + *
  22 + * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
  23 + * California 94120-7775, or email info@knowledgetree.com.
  24 + *
  25 + * The interactive user interfaces in modified source and object code versions
  26 + * of this program must display Appropriate Legal Notices, as required under
  27 + * Section 5 of the GNU General Public License version 3.
  28 + *
  29 + * In accordance with Section 7(b) of the GNU General Public License version 3,
  30 + * these Appropriate Legal Notices must retain the display of the "Powered by
  31 + * KnowledgeTree" logo and retain the original copyright notice. If the display of the
  32 + * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
  33 + * must display the words "Powered by KnowledgeTree" and retain the original
  34 + * copyright notice.
  35 + *
  36 + * @copyright 2008-2009, KnowledgeTree Inc.
  37 + * @license GNU General Public License version 3
  38 + * @author KnowledgeTree Team
  39 + * @package KTCMIS
  40 + * @version Version 0.1
  41 + */
  42 +
  43 +require_once(CMIS_DIR . '/classes/CMISObject.inc.php');
  44 +
  45 +// NOTE chemistry class was abstract but this has gone in a different direction anyway
  46 +abstract class CMISBaseObject implements CMISObject {
  47 +
  48 + protected $typeId;
  49 + protected $queryName;
  50 + protected $displayName;
  51 + protected $baseType;
  52 + protected $baseTypeQueryName;
  53 + protected $parentId;
  54 + protected $description;
  55 + protected $creatable;
  56 + protected $fileable;
  57 + protected $queryable;
  58 + protected $includedInSupertypeQuery;
  59 + protected $controllable; // NOTE deprecated? part of policy objects specification, policy objects are indicated as TODO remove
  60 +
  61 + protected $properties; // list of property objects which define the additional properties for this object
  62 +
  63 + // TODO all we have here so far is getAttributes & getProperties :)
  64 + // add all the other methods as we go along
  65 +
  66 + function __construct()
  67 + {
  68 +// $propertyDef = new PropertyDefinition();
  69 +// $this->properties[] = $propertyDef;
  70 + }
  71 +
  72 + /**
  73 + * Returns a listing of all attributes in an array
  74 + *
  75 + * @return array $attributes
  76 + */
  77 + function getAttributes()
  78 + {
  79 + $attributes = array();
  80 +
  81 + // TODO look at how chemistry does this and implement something similar
  82 + // for now this is fine as we are just trying to get things up and running :)
  83 + $attributes['typeId'] = $this->typeId;
  84 + $attributes['queryName'] = $this->queryName;
  85 + $attributes['displayName'] = $this->displayName;
  86 + $attributes['baseType'] = $this->baseType;
  87 + $attributes['baseTypeQueryName'] = $this->baseTypeQueryName;
  88 + $attributes['parentId'] = $this->parentId;
  89 + $attributes['description'] = $this->description;
  90 + $attributes['creatable'] = $this->creatable;
  91 + $attributes['fileable'] = $this->fileable;
  92 + $attributes['queryable'] = $this->queryable;
  93 + $attributes['includedInSupertypeQuery'] = $this->includedInSupertypeQuery;
  94 + $attributes['controllable'] = $this->includedInSupertypeQuery;
  95 +
  96 + return $attributes;
  97 + }
  98 +
  99 + function getAttribute($field)
  100 + {
  101 + return $this->{$field};
  102 + }
  103 +
  104 + /**
  105 + * Sets properties for this type
  106 + * Obeys the rules as specified in the property definitions (once implemented)
  107 + */
  108 + function setProperty($field, $value)
  109 + {
  110 + $this->properties->setValue($field, $value);
  111 + }
  112 +
  113 + /**
  114 + * Sets properties for this type - internal only function which allows
  115 + * setting of properties by object on initialisation or re-query
  116 + *
  117 + * This will bypass the property definition checks for updateability (once implemented)
  118 + */
  119 + protected function _setPropertyInternal($field, $value)
  120 + {
  121 + $this->properties->setValue($field, $value);
  122 + }
  123 +
  124 + /**
  125 + * Fetches properties for this object type
  126 + */
  127 + function getProperties()
  128 + {
  129 + return $this->properties;
  130 + }
  131 +
  132 +}
  133 +
  134 +?>
ktcmis/classes/CMISDocumentPropertyCollection.inc.php 0 → 100644
  1 +<?php
  2 +/**
  3 + * CMIS Repository Document Object Property Collection API class for KnowledgeTree.
  4 + *
  5 + * KnowledgeTree Community Edition
  6 + * Document Management Made Simple
  7 + * Copyright (C) 2008,2009 KnowledgeTree Inc.
  8 + * Portions copyright The Jam Warehouse Software (Pty) Limited
  9 + *
  10 + * This program is free software; you can redistribute it and/or modify it under
  11 + * the terms of the GNU General Public License version 3 as published by the
  12 + * Free Software Foundation.
  13 + *
  14 + * This program is distributed in the hope that it will be useful, but WITHOUT
  15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  16 + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  17 + * details.
  18 + *
  19 + * You should have received a copy of the GNU General Public License
  20 + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21 + *
  22 + * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
  23 + * California 94120-7775, or email info@knowledgetree.com.
  24 + *
  25 + * The interactive user interfaces in modified source and object code versions
  26 + * of this program must display Appropriate Legal Notices, as required under
  27 + * Section 5 of the GNU General Public License version 3.
  28 + *
  29 + * In accordance with Section 7(b) of the GNU General Public License version 3,
  30 + * these Appropriate Legal Notices must retain the display of the "Powered by
  31 + * KnowledgeTree" logo and retain the original copyright notice. If the display of the
  32 + * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
  33 + * must display the words "Powered by KnowledgeTree" and retain the original
  34 + * copyright notice.
  35 + *
  36 + * @copyright 2008-2009, KnowledgeTree Inc.
  37 + * @license GNU General Public License version 3
  38 + * @author KnowledgeTree Team
  39 + * @package KTCMIS
  40 + * @version Version 0.1
  41 + */
  42 +
  43 +require_once(CMIS_DIR . '/classes/CMISPropertyCollection.inc.php');
  44 +
  45 +/**
  46 + * This class contains the document object properties
  47 + */
  48 +class CMISDocumentPropertyCollection extends CMISPropertyCollection {
  49 +
  50 + static $name;
  51 + static $isImmutable;
  52 + static $isLatestVersion;
  53 + static $isMajorVersion;
  54 + static $isLatestMajorVersion;
  55 + static $versionLabel;
  56 + static $versionSeriesId;
  57 + static $isVersionSeriesCheckedOut;
  58 + static $versionSeriesCheckedOutBy;
  59 + static $versionSeriesCheckedOutId;
  60 + static $checkinComment;
  61 + static $contentStreamLength;
  62 + static $contentStreamMimeType;
  63 + static $contentStreamFilename;
  64 + static $contentStreamUri;
  65 +
  66 +}
  67 +
  68 +?>
ktcmis/classes/CMISFolderPropertyCollection.inc.php 0 → 100644
  1 +<?php
  2 +/**
  3 + * CMIS Repository Folder Object Property Collection API class for KnowledgeTree.
  4 + *
  5 + * KnowledgeTree Community Edition
  6 + * Document Management Made Simple
  7 + * Copyright (C) 2008,2009 KnowledgeTree Inc.
  8 + * Portions copyright The Jam Warehouse Software (Pty) Limited
  9 + *
  10 + * This program is free software; you can redistribute it and/or modify it under
  11 + * the terms of the GNU General Public License version 3 as published by the
  12 + * Free Software Foundation.
  13 + *
  14 + * This program is distributed in the hope that it will be useful, but WITHOUT
  15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  16 + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  17 + * details.
  18 + *
  19 + * You should have received a copy of the GNU General Public License
  20 + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21 + *
  22 + * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
  23 + * California 94120-7775, or email info@knowledgetree.com.
  24 + *
  25 + * The interactive user interfaces in modified source and object code versions
  26 + * of this program must display Appropriate Legal Notices, as required under
  27 + * Section 5 of the GNU General Public License version 3.
  28 + *
  29 + * In accordance with Section 7(b) of the GNU General Public License version 3,
  30 + * these Appropriate Legal Notices must retain the display of the "Powered by
  31 + * KnowledgeTree" logo and retain the original copyright notice. If the display of the
  32 + * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
  33 + * must display the words "Powered by KnowledgeTree" and retain the original
  34 + * copyright notice.
  35 + *
  36 + * @copyright 2008-2009, KnowledgeTree Inc.
  37 + * @license GNU General Public License version 3
  38 + * @author KnowledgeTree Team
  39 + * @package KTCMIS
  40 + * @version Version 0.1
  41 + */
  42 +
  43 +require_once(CMIS_DIR . '/classes/CMISPropertyCollection.inc.php');
  44 +
  45 +/**
  46 + * This class contains the folder object properties
  47 + */
  48 +class CMISFolderPropertyCollection extends CMISPropertyCollection {
  49 +
  50 + static $name;
  51 + static $parentId;
  52 + static $allowedChildObjectTypeIds;
  53 +
  54 +}
  55 +
  56 +?>
ktcmis/classes/CMISObject.inc.php 0 → 100644
  1 +<?php
  2 +
  3 +// TODO Property Type Definitions (only done Attributes up to now)
  4 +
  5 +interface CMISObject {
  6 +
  7 + /*
  8 + * ----- Object Services -----
  9 + */
  10 +
  11 + /**
  12 + * Moves this filed object from one folder to another.
  13 + * <p>
  14 + * The target folder is that into which the object has to be moved. When the
  15 + * object is multi-filed, a source folder to be moved out of must be
  16 + * specified.
  17 + *
  18 + * @param targetFolder the target folder
  19 + * @param sourceFolder the source folder, or {@code null}
  20 + */
  21 +// function move($targetFolder, $sourceFolder = null);
  22 +
  23 + /**
  24 + * Deletes this object.
  25 + * <p>
  26 + * When a filed object is deleted, it is removed from all folders it is
  27 + * filed in.
  28 + * <p>
  29 + * This deletes a specific version of a document object. To delete all
  30 + * versions, use {@link #deleteAllVersions}.
  31 + * <p>
  32 + * Deletion of a private working copy (checked out version) is the same as
  33 + * to cancel checkout.
  34 + */
  35 +// function delete();
  36 +
  37 + /**
  38 + * Unfiles this non-folder object.
  39 + * <p>
  40 + * This removes this object from all folders it is filed in, but never
  41 + * deletes the object, which means that if unfiling is not supported, an
  42 + * exception will be thrown.
  43 + * <p>
  44 + * If this object is a folder then an exception will be thrown.
  45 + *
  46 + * @see #delete
  47 + * @see Folder#remove
  48 + */
  49 +// function unfile();
  50 +
  51 + /*
  52 + * ----- Navigation Services -----
  53 + */
  54 +
  55 + /**
  56 + * Gets the parent folder, or the single folder in which the object is
  57 + * filed.
  58 + * <p>
  59 + * For a folder, returns the parent folder, or {@code null} if there is no
  60 + * parent (for the root folder).
  61 + * <p>
  62 + * For a non-folder, if the object is single-filed then the folder in which
  63 + * it is filed is returned, otherwise if the folder is unfiled then {@code
  64 + * null} is returned. An exception is raised if the object is multi-filed,
  65 + * so in doubt use {@link #getParents}.
  66 + *
  67 + * @return the parent folder, or {@code null}.
  68 + *
  69 + * @see #getParents
  70 + * @see Folder#getAncestors
  71 + */
  72 +// function getParent();
  73 +
  74 +// /**
  75 +// * Gets the direct parents of this object.
  76 +// * <p>
  77 +// * The object must be a non-folder, fileable object.
  78 +// *
  79 +// * @return the collection of parent folders
  80 +// *
  81 +// * @see #getParent
  82 +// * @see Folder#getAncestors
  83 +// */
  84 +// function getParents();
  85 +//
  86 +// /*
  87 +// * ----- Relationship Services -----
  88 +// */
  89 +//
  90 +// /**
  91 +// * Gets the relationships having as source or target this object.
  92 +// * <p>
  93 +// * Returns a list of relationships associated with this object, optionally
  94 +// * of a specified relationship type, and optionally in a specified
  95 +// * direction.
  96 +// * <p>
  97 +// * If typeId is {@code null}, returns relationships of any type.
  98 +// * <p>
  99 +// * Ordering is repository specific but consistent across requests.
  100 +// *
  101 +// * @param direction the direction of relationships to include
  102 +// * @param typeId the type ID, or {@code null}
  103 +// * @param includeSubRelationshipTypes {@code true} if relationships of any
  104 +// * sub-type of typeId are to be returned as well
  105 +// * @return the list of relationships
  106 +// */
  107 +// function getRelationships($direction, $typeId, $includeSubRelationshipTypes);
  108 +//
  109 +// /*
  110 +// * ----- Policy Services -----
  111 +// */
  112 +//
  113 +// /**
  114 +// * Applies a policy to this object.
  115 +// * <p>
  116 +// * The object must be controllable.
  117 +// *
  118 +// * @param policy the policy
  119 +// */
  120 +// function applyPolicy(Policy policy);
  121 +//
  122 +// /**
  123 +// * Removes a policy from this object.
  124 +// * <p>
  125 +// * Removes a previously applied policy from the object. The policy is not
  126 +// * deleted, and may still be applied to other objects.
  127 +// * <p>
  128 +// * The object must be controllable.
  129 +// *
  130 +// * @param policy the policy
  131 +// */
  132 +// function removePolicy(Policy policy);
  133 +//
  134 +// /**
  135 +// * Gets the policies applied to this object.
  136 +// * <p>
  137 +// * Returns the list of policy objects currently applied to the object. Only
  138 +// * policies that are directly (explicitly) applied to the object are
  139 +// * returned.
  140 +// * <p>
  141 +// * The object must be controllable.
  142 +// */
  143 +// function getPolicies();
  144 +//
  145 + /*
  146 + * ----- data access -----
  147 + */
  148 +
  149 + /**
  150 + * The object's type definition.
  151 + */
  152 +// function getType();
  153 +
  154 + /**
  155 + * Gets a property.
  156 + *
  157 + * @param name the property name
  158 + * @return the property
  159 + */
  160 +// function getProperty($name);
  161 +
  162 + /**
  163 + * Gets all the properties.
  164 + *
  165 + * @return a map of the properties
  166 + */
  167 +// function getProperties();
  168 +
  169 + /**
  170 + * Gets a property value.
  171 + *
  172 + * @param name the property name
  173 + * @return the property value
  174 + */
  175 +// function getValue($name);
  176 +
  177 +// /**
  178 +// * Sets a property value.
  179 +// * <p>
  180 +// * Setting a {@code null} value removes the property.
  181 +// * <p>
  182 +// * Whether the value is saved immediately or not is repository-specific, see
  183 +// * {@link #save()}.
  184 +// *
  185 +// * @param name the property name
  186 +// * @param value the property value, or {@code null}
  187 +// */
  188 +// function setValue($name, $value);
  189 +//
  190 +// /**
  191 +// * Sets several property values.
  192 +// * <p>
  193 +// * Setting a {@code null} value removes a property.
  194 +// * <p>
  195 +// * Whether the values are saved immediately or not is repository-specific,
  196 +// * see {@link #save()}.
  197 +// *
  198 +// * @param values the property values
  199 +// */
  200 +// function setValues($values);
  201 +//
  202 +// /**
  203 +// * Saves the modifications done to the object through {@link #setValue},
  204 +// * {@link #setValues} and {@link Document#setContentStream}.
  205 +// * <p>
  206 +// * Note that a repository is not required to wait until a {@link #save} is
  207 +// * called to actually save the modifications, it may do so as soon as
  208 +// * {@link #setValue} is called.
  209 +// * <p>
  210 +// * Calling {#link #save} is needed for objects newly created through
  211 +// * {@link Connection#newDocument} and similar methods.
  212 +// */
  213 +// function save();
  214 +//
  215 +// /*
  216 +// * ----- convenience methods -----
  217 +// */
  218 +//
  219 +// function getString($name);
  220 +//
  221 +// function getStrings($name);
  222 +//
  223 +// function getDecimal($name);
  224 +//
  225 +// function getDecimals($name);
  226 +//
  227 +// function getInteger($name);
  228 +//
  229 +// function getIntegers($name);
  230 +//
  231 +// function getBoolean($name);
  232 +//
  233 +// function getBooleans($name);
  234 +//
  235 +// function getDateTime($name);
  236 +//
  237 +// function getDateTimes($name);
  238 +//
  239 +// function getURI($name);
  240 +//
  241 +// function getURIs($name);
  242 +//
  243 +// function getId($name);
  244 +//
  245 +// function getIds($name);
  246 +//
  247 +// function getXML($name);
  248 +//
  249 +// function getXMLs($name);
  250 +//
  251 +// function getHTML($name);
  252 +//
  253 +// function getHTMLs($name);
  254 +//
  255 +// /*
  256 +// * ----- convenience methods for specific properties -----
  257 +// */
  258 +//
  259 +// function getId();
  260 +//
  261 +// function getURI();
  262 +//
  263 +// function getTypeId();
  264 +//
  265 +// function getCreatedBy();
  266 +//
  267 +// function getCreationDate();
  268 +//
  269 +// function getLastModifiedBy();
  270 +//
  271 +// function getLastModificationDate();
  272 +//
  273 +// function getChangeToken();
  274 +//
  275 +// function getName();
  276 +//
  277 +// function isImmutable();
  278 +//
  279 +// function isLatestVersion();
  280 +//
  281 +// function isMajorVersion();
  282 +//
  283 +// function isLatestMajorVersion();
  284 +//
  285 +// function getVersionLabel();
  286 +//
  287 +// function getVersionSeriesId();
  288 +//
  289 +// function isVersionSeriesCheckedOut();
  290 +//
  291 +// function getVersionSeriesCheckedOutBy();
  292 +//
  293 +// function getVersionSeriesCheckedOutId();
  294 +//
  295 +// function getCheckinComment();
  296 +//
  297 +// /*
  298 +// * ----- convenience methods for specific properties (setter) -----
  299 +// */
  300 +//
  301 +// function setName($name);
  302 +
  303 +}
  304 +
  305 +?>
ktcmis/classes/CMISObjectTypes.inc.php 0 → 100644
  1 +<?php
  2 +
  3 +class CMISObjectTypes {
  4 +
  5 + /**
  6 + *
  7 + * @var array $objects The array of supported object types
  8 + */
  9 + private $objects;
  10 + private $path;
  11 +
  12 + function __construct()
  13 + {
  14 + // TODO Set path dynamically instead of statically? i.e. via config as with search
  15 + $this->path = CMIS_DIR . '/objecttypes';
  16 + $this->registerObjects();
  17 + }
  18 +
  19 + function registerObjects()
  20 + {
  21 + // read object types directory to find supported object types
  22 + $this->objects = array();
  23 +
  24 + // TODO check search code for correctPath function and see if similar is needed here
  25 + $dir = opendir($this->path);
  26 + while (($file = readdir($dir)) !== false)
  27 + {
  28 + if (substr($file,-14) == 'Object.inc.php')
  29 + {
  30 + // TODO check what if anything here is useful and reinstate
  31 +// require_once($this->path . '/' . $file);
  32 +// $class = substr($file, 0, -8);
  33 +//
  34 +// if (!class_exists($class))
  35 +// {
  36 +// continue;
  37 +// }
  38 +//
  39 +// $field = new $class;
  40 +// if (is_null($field) || !($field instanceof FieldExpr))
  41 +// {
  42 +// continue;
  43 +// }
  44 +
  45 + $this->objects[] = str_replace('CMIS', '', substr($file,0,-14));
  46 + }
  47 + }
  48 +
  49 + closedir($dir);
  50 + }
  51 +
  52 + /**
  53 + * return a list of all supported objects
  54 + */
  55 + function getObjectTypes()
  56 + {
  57 + return $this->objects;
  58 + }
  59 +}
  60 +
  61 +?>
ktcmis/classes/CMISPropertyCollection.inc.php 0 → 100644
  1 +<?php
  2 +/**
  3 + * CMIS Repository Base Object Property Collection API class for KnowledgeTree.
  4 + *
  5 + * KnowledgeTree Community Edition
  6 + * Document Management Made Simple
  7 + * Copyright (C) 2008,2009 KnowledgeTree Inc.
  8 + * Portions copyright The Jam Warehouse Software (Pty) Limited
  9 + *
  10 + * This program is free software; you can redistribute it and/or modify it under
  11 + * the terms of the GNU General Public License version 3 as published by the
  12 + * Free Software Foundation.
  13 + *
  14 + * This program is distributed in the hope that it will be useful, but WITHOUT
  15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  16 + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  17 + * details.
  18 + *
  19 + * You should have received a copy of the GNU General Public License
  20 + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21 + *
  22 + * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
  23 + * California 94120-7775, or email info@knowledgetree.com.
  24 + *
  25 + * The interactive user interfaces in modified source and object code versions
  26 + * of this program must display Appropriate Legal Notices, as required under
  27 + * Section 5 of the GNU General Public License version 3.
  28 + *
  29 + * In accordance with Section 7(b) of the GNU General Public License version 3,
  30 + * these Appropriate Legal Notices must retain the display of the "Powered by
  31 + * KnowledgeTree" logo and retain the original copyright notice. If the display of the
  32 + * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
  33 + * must display the words "Powered by KnowledgeTree" and retain the original
  34 + * copyright notice.
  35 + *
  36 + * @copyright 2008-2009, KnowledgeTree Inc.
  37 + * @license GNU General Public License version 3
  38 + * @author KnowledgeTree Team
  39 + * @package KTCMIS
  40 + * @version Version 0.1
  41 + */
  42 +
  43 +/**
  44 + * This class contains the base properties shared by all object types
  45 + */
  46 +abstract class CMISPropertyCollection {
  47 +
  48 + static $objectId;
  49 + static $URI;
  50 + static $typeId;
  51 + static $createdBy;
  52 + static $creationDate;
  53 + static $lastModifiedBy;
  54 + static $lastModificationDate;
  55 + static $changeToken;
  56 +
  57 + /**
  58 + * Gets the property value.
  59 + */
  60 + function getValue($field)
  61 + {
  62 + return $this->{$field};
  63 + }
  64 +
  65 + /**
  66 + * Sets the property value.
  67 + */
  68 + // for connection-tied live objects
  69 + function setValue($field, $value)
  70 + {
  71 + $this->{$field} = $value;
  72 + }
  73 +
  74 +}
  75 +
  76 +?>
ktcmis/classes/CMISRepository.inc.php 0 → 100644
  1 +<?php
  2 +
  3 +/**
  4 +* CMIS Repository API class for KnowledgeTree.
  5 +*
  6 +* KnowledgeTree Community Edition
  7 +* Document Management Made Simple
  8 +* Copyright (C) 2008,2009 KnowledgeTree Inc.
  9 +* Portions copyright The Jam Warehouse Software (Pty) Limited
  10 +*
  11 +* This program is free software; you can redistribute it and/or modify it under
  12 +* the terms of the GNU General Public License version 3 as published by the
  13 +* Free Software Foundation.
  14 +*
  15 +* This program is distributed in the hope that it will be useful, but WITHOUT
  16 +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  17 +* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  18 +* details.
  19 +*
  20 +* You should have received a copy of the GNU General Public License
  21 +* along with this program. If not, see <http://www.gnu.org/licenses/>.
  22 +*
  23 +* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
  24 +* California 94120-7775, or email info@knowledgetree.com.
  25 +*
  26 +* The interactive user interfaces in modified source and object code versions
  27 +* of this program must display Appropriate Legal Notices, as required under
  28 +* Section 5 of the GNU General Public License version 3.
  29 +*
  30 +* In accordance with Section 7(b) of the GNU General Public License version 3,
  31 +* these Appropriate Legal Notices must retain the display of the "Powered by
  32 +* KnowledgeTree" logo and retain the original copyright notice. If the display of the
  33 +* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
  34 +* must display the words "Powered by KnowledgeTree" and retain the original
  35 +* copyright notice.
  36 +*
  37 +* @copyright 2008-2009, KnowledgeTree Inc.
  38 +* @license GNU General Public License version 3
  39 +* @author KnowledgeTree Team
  40 +* @package KTCMIS
  41 +* @version Version 0.1
  42 +*/
  43 +
  44 +require_once(CMIS_DIR . '/classes/CMISRepositoryInfo.inc.php');
  45 +
  46 +/**
  47 + * A CMIS Repository.
  48 + */
  49 +class CMISRepository {
  50 +
  51 + private $repositoryId;
  52 + private $repositoryURI;
  53 +
  54 + /**
  55 + * @var $RepositoryInfo The class holding information about this repository
  56 + */
  57 + private $RepositoryInfo;
  58 + /**
  59 + *
  60 + * @var object $objectTypes The supported object types
  61 + */
  62 + private $objectTypes;
  63 +
  64 + function CMISRepository($repositoryId, $config = null)
  65 + {
  66 + $this->repositoryId = $repositoryId;
  67 + $this->RepositoryInfo = new CMISRepositoryInfo();
  68 + $this->getConfig($config);
  69 + }
  70 +
  71 + function getConfig($config = null)
  72 + {
  73 + // if not supplied config xml
  74 + if (is_null($config))
  75 + {
  76 + // fetch configuration file
  77 + // TODO what if file does not exist?
  78 + $xml = simplexml_load_file(CMIS_DIR . '/config/repositories.xml');
  79 +
  80 + foreach($xml->repository as $repository)
  81 + {
  82 + $currentRepo = $repository->repositoryInfo[0]->repositoryId;
  83 + if ((int)$currentRepo == $this->repositoryId)
  84 + {
  85 + $config = $repository;
  86 + break;
  87 + }
  88 + }
  89 + }
  90 +
  91 + // set URI
  92 + $this->repositoryURI = (string)$config->repositoryURI[0];
  93 +
  94 + // set info
  95 + foreach($config->repositoryInfo[0] as $field => $value)
  96 + {
  97 + $this->setRepositoryInfoField($field, (string)$value);
  98 + }
  99 +
  100 + // set capabilities
  101 + foreach($config->repositoryCapabilities->children() as $field => $value)
  102 + {
  103 + $this->setCapabilityField($field, (string)$value);
  104 + }
  105 +
  106 + // set supported document types
  107 + foreach($config->supportedTypes->children() as $field => $value)
  108 + {
  109 + $this->objectTypes[] = (string)$value;
  110 + }
  111 + }
  112 +
  113 + /**
  114 + * Set a single value for RepositoryInfo
  115 + *
  116 + * @param string $field
  117 + * @param string/int $value
  118 + */
  119 + function setRepositoryInfoField($field, $value)
  120 + {
  121 + $this->RepositoryInfo->setFieldValue($field, $value);
  122 + }
  123 +
  124 + /**
  125 + * Set multiple values for RepositoryInfo
  126 + *
  127 + * @param array $info
  128 + */
  129 + function setRepositoryInfo($info)
  130 + {
  131 + $this->RepositoryInfo->setInfo($info);
  132 + }
  133 +
  134 + /**
  135 + * Set a single value for RepositoryCapabilities
  136 + *
  137 + * @param string $field
  138 + * @param string/int $value
  139 + */
  140 + function setCapabilityField($field, $value)
  141 + {
  142 + $this->RepositoryInfo->setCapabilityValue($field, $value);
  143 + }
  144 +
  145 + function getRepositoryID()
  146 + {
  147 + return $this->RepositoryInfo->getRepositoryID();
  148 + }
  149 +
  150 + function getRepositoryName()
  151 + {
  152 + return $this->RepositoryInfo->getRepositoryName();
  153 + }
  154 +
  155 + function getRepositoryURI()
  156 + {
  157 + return $this->repositoryURI;
  158 + }
  159 +
  160 + function getRepositoryInfo()
  161 + {
  162 + return $this->RepositoryInfo;
  163 + }
  164 +
  165 + function getTypes()
  166 + {
  167 + return $this->objectTypes;
  168 + }
  169 +
  170 +// // TODO this function MUST accept the same arguments as the calling functions and respond accordingly
  171 +// // TODO consider moving this into the RepositoryService class:
  172 +// // anything which requires a repository id seems like it does not belong in the repository class
  173 +// function getTypes()
  174 +// {
  175 +// $objectTypes = $this->objectTypes->getObjectTypes();
  176 +//
  177 +// // fetch the attributes for each type
  178 +// foreach ($objectTypes as $key => $objectType)
  179 +// {
  180 +// $objectTypes[$key] = $this->getTypeDefinition($this->repositoryId, $objectType);
  181 +// }
  182 +//
  183 +// return $objectTypes;
  184 +// }
  185 +
  186 +// // TODO consider moving this into the RepositoryService class:
  187 +// // anything which requires a repository id seems like it does not belong in the repository class
  188 +// function getTypeDefinition($repositoryId, $typeId)
  189 +// {
  190 +// // TODO is this the best way of doing this?
  191 +// switch ($typeId)
  192 +// {
  193 +// case 'Document':
  194 +// require_once(CMIS_DIR . '/objecttypes/CMISDocumentObject.inc.php');
  195 +// $tmpObject = new DocumentObject();
  196 +// $objectAttributes = $tmpObject->getProperties();
  197 +// break;
  198 +// case 'Folder':
  199 +// require_once(CMIS_DIR . '/objecttypes/CMISFolderObject.inc.php');
  200 +// $tmpObject = new FolderObject();
  201 +// $objectAttributes = $tmpObject->getProperties();
  202 +// break;
  203 +// }
  204 +//
  205 +// return $objectAttributes;
  206 +// }
  207 +
  208 +}
  209 +
  210 +?>
ktcmis/classes/CMISRepositoryCapabilities.inc.php 0 → 100644
  1 +<?php
  2 +
  3 +/**
  4 + * CMIS Repository Capabilities API class for KnowledgeTree.
  5 + *
  6 + * KnowledgeTree Community Edition
  7 + * Document Management Made Simple
  8 + * Copyright (C) 2008,2009 KnowledgeTree Inc.
  9 + * Portions copyright The Jam Warehouse Software (Pty) Limited
  10 + *
  11 + * This program is free software; you can redistribute it and/or modify it under
  12 + * the terms of the GNU General Public License version 3 as published by the
  13 + * Free Software Foundation.
  14 + *
  15 + * This program is distributed in the hope that it will be useful, but WITHOUT
  16 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  17 + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  18 + * details.
  19 + *
  20 + * You should have received a copy of the GNU General Public License
  21 + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  22 + *
  23 + * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
  24 + * California 94120-7775, or email info@knowledgetree.com.
  25 + *
  26 + * The interactive user interfaces in modified source and object code versions
  27 + * of this program must display Appropriate Legal Notices, as required under
  28 + * Section 5 of the GNU General Public License version 3.
  29 + *
  30 + * In accordance with Section 7(b) of the GNU General Public License version 3,
  31 + * these Appropriate Legal Notices must retain the display of the "Powered by
  32 + * KnowledgeTree" logo and retain the original copyright notice. If the display of the
  33 + * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
  34 + * must display the words "Powered by KnowledgeTree" and retain the original
  35 + * copyright notice.
  36 + *
  37 + * @copyright 2008-2009, KnowledgeTree Inc.
  38 + * @license GNU General Public License version 3
  39 + * @author KnowledgeTree Team
  40 + * @package KTCMIS
  41 + * @version Version 0.1
  42 + */
  43 +
  44 +class CMISRepositoryCapabilities {
  45 +
  46 + // boolean values
  47 + protected $capabilityMultifiling;
  48 + protected $capabilityUnfiling;
  49 + protected $capabilityVersionSpecificFiling;
  50 + protected $capabilityPWCUpdateable;
  51 + protected $capabilityPWCSearchable;
  52 + protected $capabilityAllVersionsSearchable;
  53 +
  54 + // non-boolean values
  55 + // TODO these should be defined as classes/enums which will only accept the defined values when set
  56 + protected $capabilityQuery;
  57 + protected $capabilityFullText;
  58 + protected $capabilityJoin;
  59 +
  60 + /**
  61 + * Set a single field value
  62 + *
  63 + * @param string $field
  64 + * @param string/int $value
  65 + * @return a collection of repository entries
  66 + */
  67 + function setFieldValue($field, $value)
  68 + {
  69 + $this->{$field} = ($value == 'true' ? true : ($value == 'false' ? false : $value));
  70 + }
  71 +
  72 + /**
  73 + * Gets the value of the capabilityMultifiling property.
  74 + *
  75 + */
  76 + public function hasCapabilityMultifiling() {
  77 + return $this->capabilityMultifiling;
  78 + }
  79 +
  80 + /**
  81 + * Sets the value of the capabilityMultifiling property.
  82 + *
  83 + */
  84 + public function setCapabilityMultifiling($value) {
  85 + $this->capabilityMultifiling = $value;
  86 + }
  87 +
  88 + /**
  89 + * Gets the value of the capabilityUnfiling property.
  90 + *
  91 + */
  92 + public function hasCapabilityUnfiling() {
  93 + return $this->capabilityUnfiling;
  94 + }
  95 +
  96 + /**
  97 + * Sets the value of the capabilityUnfiling property.
  98 + *
  99 + */
  100 + public function setCapabilityUnfiling($value) {
  101 + $this->capabilityUnfiling = $value;
  102 + }
  103 +
  104 + /**
  105 + * Gets the value of the capabilityVersionSpecificFiling property.
  106 + *
  107 + */
  108 + public function hasCapabilityVersionSpecificFiling() {
  109 + return $this->capabilityVersionSpecificFiling;
  110 + }
  111 +
  112 + /**
  113 + * Sets the value of the capabilityVersionSpecificFiling property.
  114 + *
  115 + */
  116 + public function setCapabilityVersionSpecificFiling($value) {
  117 + $this->capabilityVersionSpecificFiling = $value;
  118 + }
  119 +
  120 + /**
  121 + * Gets the value of the capabilityPWCUpdateable property.
  122 + *
  123 + */
  124 + public function hasCapabilityPWCUpdateable() {
  125 + return $this->capabilityPWCUpdateable;
  126 + }
  127 +
  128 + /**
  129 + * Sets the value of the capabilityPWCUpdateable property.
  130 + *
  131 + */
  132 + public function setCapabilityPWCUpdateable($value) {
  133 + $this->capabilityPWCUpdateable = $value;
  134 + }
  135 +
  136 + /**
  137 + * Gets the value of the capabilityPWCSearchable property.
  138 + *
  139 + */
  140 + public function hasCapabilityPWCSearchable() {
  141 + return $this->capabilityPWCSearchable;
  142 + }
  143 +
  144 + /**
  145 + * Sets the value of the capabilityPWCSearchable property.
  146 + *
  147 + */
  148 + public function setCapabilityPWCSearchable($value) {
  149 + $this->capabilityPWCSearchable = $value;
  150 + }
  151 +
  152 + /**
  153 + * Gets the value of the capabilityAllVersionsSearchable property.
  154 + *
  155 + */
  156 + public function hasCapabilityAllVersionsSearchable() {
  157 + return $this->capabilityAllVersionsSearchable;
  158 + }
  159 +
  160 + /**
  161 + * Sets the value of the capabilityAllVersionsSearchable property.
  162 + *
  163 + */
  164 + public function setCapabilityAllVersionsSearchable($value) {
  165 + $this->capabilityAllVersionsSearchable = $value;
  166 + }
  167 +
  168 + /**
  169 + * Gets the value of the capabilityQuery property.
  170 + *
  171 + * @return
  172 + * possible object is
  173 + * {@link EnumCapabilityQuery }
  174 + *
  175 + */
  176 + public function getCapabilityQuery() {
  177 + return $this->capabilityQuery;
  178 + }
  179 +
  180 + /**
  181 + * Sets the value of the capabilityQuery property.
  182 + *
  183 + * @param value
  184 + * allowed object is
  185 + * {@link EnumCapabilityQuery }
  186 + *
  187 + */
  188 + public function setCapabilityQuery($value) {
  189 + $this->capabilityQuery = $value;
  190 + }
  191 +
  192 + /**
  193 + * Gets the value of the capabilityJoin property.
  194 + *
  195 + * @return
  196 + * possible object is
  197 + * {@link EnumCapabilityJoin }
  198 + *
  199 + */
  200 + public function getCapabilityJoin() {
  201 + return $this->capabilityJoin;
  202 + }
  203 +
  204 + /**
  205 + * Sets the value of the capabilityJoin property.
  206 + *
  207 + * @param value
  208 + * allowed object is
  209 + * {@link EnumCapabilityJoin }
  210 + *
  211 + */
  212 + public function setCapabilityJoin($value) {
  213 + $this->capabilityJoin = $value;
  214 + }
  215 +
  216 + /**
  217 + * Gets the value of the capabilityFullText property.
  218 + *
  219 + * @return
  220 + * possible object is
  221 + * {@link EnumCapabilityFullText }
  222 + *
  223 + */
  224 + public function getCapabilityFullText() {
  225 + return $this->capabilityFullText;
  226 + }
  227 +
  228 + /**
  229 + * Sets the value of the capabilityFullText property.
  230 + *
  231 + * @param value
  232 + * allowed object is
  233 + * {@link EnumCapabilityFullText }
  234 + *
  235 + */
  236 + public function setCapabilityFullText($value) {
  237 + $this->capabilityFullText = $value;
  238 + }
  239 +
  240 +// /**
  241 +// * Gets the value of the any property.
  242 +// *
  243 +// * <p>
  244 +// * This accessor method returns a reference to the live list,
  245 +// * not a snapshot. Therefore any modification you make to the
  246 +// * returned list will be present inside the JAXB object.
  247 +// * This is why there is not a <CODE>set</CODE> method for the any property.
  248 +// *
  249 +// * <p>
  250 +// * For example, to add a new item, do as follows:
  251 +// * <pre>
  252 +// * getAny().add(newItem);
  253 +// * </pre>
  254 +// *
  255 +// *
  256 +// * <p>
  257 +// * Objects of the following type(s) are allowed in the list
  258 +// * {@link Element }
  259 +// *
  260 +// *
  261 +// */
  262 +// public List<Element> getAny() {
  263 +// if (any == null) {
  264 +// any = new ArrayList<Element>();
  265 +// }
  266 +// return $this->any;
  267 +// }
  268 +
  269 +// /**
  270 +// * Gets a map that contains attributes that aren't bound to any typed property on this class.
  271 +// *
  272 +// * <p>
  273 +// * the map is keyed by the name of the attribute and
  274 +// * the value is the string value of the attribute.
  275 +// *
  276 +// * the map returned by this method is live, and you can add new attribute
  277 +// * by updating the map directly. Because of this design, there's no setter.
  278 +// *
  279 +// *
  280 +// * @return
  281 +// * always non-null
  282 +// */
  283 +// public Map<QName, String> getOtherAttributes() {
  284 +// return $this->otherAttributes;
  285 +// }
  286 +
  287 +}
  288 +
  289 +?>
ktcmis/classes/CMISRepositoryInfo.inc.php 0 → 100644
  1 +<?php
  2 +
  3 +/**
  4 + * CMIS Repository Info API class for KnowledgeTree.
  5 + *
  6 + * KnowledgeTree Community Edition
  7 + * Document Management Made Simple
  8 + * Copyright (C) 2008,2009 KnowledgeTree Inc.
  9 + * Portions copyright The Jam Warehouse Software (Pty) Limited
  10 + *
  11 + * This program is free software; you can redistribute it and/or modify it under
  12 + * the terms of the GNU General Public License version 3 as published by the
  13 + * Free Software Foundation.
  14 + *
  15 + * This program is distributed in the hope that it will be useful, but WITHOUT
  16 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  17 + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  18 + * details.
  19 + *
  20 + * You should have received a copy of the GNU General Public License
  21 + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  22 + *
  23 + * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
  24 + * California 94120-7775, or email info@knowledgetree.com.
  25 + *
  26 + * The interactive user interfaces in modified source and object code versions
  27 + * of this program must display Appropriate Legal Notices, as required under
  28 + * Section 5 of the GNU General Public License version 3.
  29 + *
  30 + * In accordance with Section 7(b) of the GNU General Public License version 3,
  31 + * these Appropriate Legal Notices must retain the display of the "Powered by
  32 + * KnowledgeTree" logo and retain the original copyright notice. If the display of the
  33 + * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
  34 + * must display the words "Powered by KnowledgeTree" and retain the original
  35 + * copyright notice.
  36 + *
  37 + * @copyright 2008-2009, KnowledgeTree Inc.
  38 + * @license GNU General Public License version 3
  39 + * @author KnowledgeTree Team
  40 + * @package KTCMIS
  41 + * @version Version 0.1
  42 + */
  43 +
  44 +require_once(CMIS_DIR . '/classes/CMISRepositoryCapabilities.inc.php');
  45 +
  46 +/**
  47 + * CMIS Repository Service.
  48 + */
  49 +class CMISRepositoryInfo {
  50 +
  51 + protected $repositoryId; // The identifier for the Repository
  52 + protected $repositoryName; // A display name for the Repository
  53 + protected $repositoryRelationship; // A string that MAY describe how this repository relates to other repositories.
  54 + protected $repositoryDescription; // A display description for the Repository.
  55 + protected $vendorName; // A display name for the vendor of the Repository’s underlying application.
  56 + protected $productName; // A display name for the Repository’s underlying application.
  57 + protected $productVersion; // A display name for the version number of the Repository’s underlying application.
  58 + protected $rootFolderId; // The ID of the Root Folder Object for the Repository.
  59 +
  60 + protected $capabilities;
  61 +
  62 + protected $cmisVersionsSupported; // String that indicates what versions of the CMIS specification the repository can support
  63 + protected $repositorySpecificInformation; // XML format; MAY be used by the Repository to return additional XML.
  64 +
  65 + function __construct()
  66 + {
  67 + $this->capabilities = new CMISRepositoryCapabilities();
  68 + }
  69 +
  70 + /**
  71 + * Set a single field value
  72 + *
  73 + * @param string $field
  74 + * @param string/int $value
  75 + * @return a collection of repository entries
  76 + */
  77 + function setFieldValue($field, $value)
  78 + {
  79 + $this->{$field} = $value;
  80 + }
  81 +
  82 + /**
  83 + * Set multiple field values
  84 + *
  85 + * @param array $info
  86 + */
  87 + function setInfo($info)
  88 + {
  89 + foreach($info as $field => $value)
  90 + {
  91 + $this->setFieldValue($field, $value);
  92 + }
  93 + }
  94 +
  95 + /**
  96 + * Set a single capability field value
  97 + *
  98 + * @param string $field
  99 + * @param string/int $value
  100 + * @return a collection of repository entries
  101 + */
  102 + function setCapabilityValue($field, $value)
  103 + {
  104 + $this->capabilities->setFieldValue($field, $value);
  105 + }
  106 +
  107 + /**
  108 + * Sets the capabilities from an existing capabilities object
  109 + *
  110 + * @param object $capabilities
  111 + */
  112 + function setCapabilities($capabilities)
  113 + {
  114 + $this->capabilities = $capabilities;
  115 + }
  116 +
  117 + function getRepositoryId()
  118 + {
  119 + return $this->repositoryId;
  120 + }
  121 +
  122 + function getRepositoryName()
  123 + {
  124 + return $this->repositoryName;
  125 + }
  126 +
  127 + function getCapabilities()
  128 + {
  129 + return $this->capabilities;
  130 + }
  131 +
  132 + function getRepositoryRelationship()
  133 + {
  134 + return $this->repositoryRelationship;
  135 + }
  136 +
  137 + function getRepositoryDescription()
  138 + {
  139 + return $this->repositoryDescription;
  140 + }
  141 +
  142 + function getVendorName()
  143 + {
  144 + return $this->vendorName;
  145 + }
  146 +
  147 + function getProductName()
  148 + {
  149 + return $this->productName;
  150 + }
  151 +
  152 + function getProductVersion()
  153 + {
  154 + return $this->productVersion;
  155 + }
  156 +
  157 + function getRootFolderId()
  158 + {
  159 + return $this->rootFolderId;
  160 + }
  161 +
  162 + function getcmisVersionsSupported()
  163 + {
  164 + return $this->cmisVersionsSupported;
  165 + }
  166 +
  167 +}
  168 +
  169 +?>
ktcmis/config/repositories.xml 0 → 100644
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +
  3 +<!--
  4 + Document : repositories.xml
  5 + Created on : 25 May 2009, 10:33 AM
  6 + Author : KnowledgeTree Team
  7 + Description:
  8 + Contains definitions for all repositories accessible via the CMIS API.
  9 +-->
  10 +
  11 +<root>
  12 + <repository>
  13 + <repositoryURI>http://127.0.0.1/</repositoryURI>
  14 + <repositoryInfo>
  15 + <repositoryId>1</repositoryId>
  16 + <repositoryName>KnowledgeTree</repositoryName>
  17 + <repositoryRelationship>self</repositoryRelationship>
  18 + <repositoryDescription>KnowledgeTree Repository</repositoryDescription>
  19 + <vendorName>KnowledgeTree</vendorName>
  20 + <productName>KnowledgeTree</productName>
  21 + <productVersion>3.6.2</productVersion>
  22 + <rootFolderId>1</rootFolderId>
  23 + <cmisVersionsSupported>cmis 0.61c</cmisVersionsSupported>
  24 + </repositoryInfo>
  25 + <repositoryCapabilities>
  26 + <capabilityMultifiling>false</capabilityMultifiling>
  27 + <capabilityUnfiling>false</capabilityUnfiling>
  28 + <capabilityVersionSpecificFiling>false</capabilityVersionSpecificFiling>
  29 + <capabilityPWCUpdateable>false</capabilityPWCUpdateable>
  30 + <capabilityPWCSearchable>false</capabilityPWCSearchable>
  31 + <capabilityAllVersionsSearchable>false</capabilityAllVersionsSearchable>
  32 + <capabilityQuery>None</capabilityQuery>
  33 + <capabilityFullText>None</capabilityFullText>
  34 + <capabilityJoin>NoJoin</capabilityJoin>
  35 + </repositoryCapabilities>
  36 + <supportedTypes>
  37 + <objectType>Document</objectType>
  38 + <objectType>Folder</objectType>
  39 + </supportedTypes>
  40 + </repository>
  41 + <repository>
  42 + <repositoryURI>http://12s7.w0.0.1/</repositoryURI>
  43 + <repositoryInfo>
  44 + <repositoryId>44</repositoryId>
  45 + <repositoryName>asdasdasd</repositoryName>
  46 + <repositoryRelationship>self</repositoryRelationship>
  47 + <repositoryDescription>KnowledgeTree Repository</repositoryDescription>
  48 + <vendorName>KnowledgeTree</vendorName>
  49 + <productName>KnowledgeTree</productName>
  50 + <productVersion>3.6.1</productVersion>
  51 + <rootFolderId>1</rootFolderId>
  52 + <cmisVersionsSupported>0.61</cmisVersionsSupported>
  53 + </repositoryInfo>
  54 + <repositoryCapabilities>
  55 + <capabilityMultifiling>false</capabilityMultifiling>
  56 + <capabilityUnfiling>false</capabilityUnfiling>
  57 + <capabilityVersionSpecificFiling>false</capabilityVersionSpecificFiling>
  58 + <capabilityPWCUpdateable>false</capabilityPWCUpdateable>
  59 + <capabilityPWCSearchable>false</capabilityPWCSearchable>
  60 + <capabilityAllVersionsSearchable>false</capabilityAllVersionsSearchable>
  61 + <capabilityQuery>None</capabilityQuery>
  62 + <capabilityFullText>None</capabilityFullText>
  63 + <capabilityJoin>NoJoin</capabilityJoin>
  64 + </repositoryCapabilities>
  65 + <supportedTypes>
  66 + <objectType>Document</objectType>
  67 + <objectType>Folder</objectType>
  68 + </supportedTypes>
  69 + </repository>
  70 +</root>
ktcmis/ktcmis.inc.php 0 → 100644
  1 +<?php
  2 +/**
  3 +* Implements a CMIS wrapper API for KnowledgeTree.
  4 +*
  5 +* KnowledgeTree Community Edition
  6 +* Document Management Made Simple
  7 +* Copyright (C) 2008,2009 KnowledgeTree Inc.
  8 +* Portions copyright The Jam Warehouse Software (Pty) Limited
  9 +*
  10 +* This program is free software; you can redistribute it and/or modify it under
  11 +* the terms of the GNU General Public License version 3 as published by the
  12 +* Free Software Foundation.
  13 +*
  14 +* This program is distributed in the hope that it will be useful, but WITHOUT
  15 +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  16 +* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  17 +* details.
  18 +*
  19 +* You should have received a copy of the GNU General Public License
  20 +* along with this program. If not, see <http://www.gnu.org/licenses/>.
  21 +*
  22 +* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
  23 +* California 94120-7775, or email info@knowledgetree.com.
  24 +*
  25 +* The interactive user interfaces in modified source and object code versions
  26 +* of this program must display Appropriate Legal Notices, as required under
  27 +* Section 5 of the GNU General Public License version 3.
  28 +*
  29 +* In accordance with Section 7(b) of the GNU General Public License version 3,
  30 +* these Appropriate Legal Notices must retain the display of the "Powered by
  31 +* KnowledgeTree" logo and retain the original copyright notice. If the display of the
  32 +* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
  33 +* must display the words "Powered by KnowledgeTree" and retain the original
  34 +* copyright notice.
  35 +*
  36 +* @copyright 2008-2009, KnowledgeTree Inc.
  37 +* @license GNU General Public License version 3
  38 +* @author KnowledgeTree Team
  39 +* @package KTCMIS
  40 +* @version Version 0.9
  41 +*/
  42 +
  43 +// TODO implement exceptions in various calls (in the underlying classes)
  44 +// FIXME none of the error handling actually does anything, it's leftover from copy/paste of some ktapi code
  45 +
  46 +require_once(realpath(dirname(__FILE__) . '/../config/dmsDefaults.php'));
  47 +require_once(KT_DIR . '/ktapi/ktapi.inc.php');
  48 +
  49 +define ('CMIS_DIR', KT_DIR . '/ktcmis');
  50 +require_once(CMIS_DIR . '/services/CMISRepositoryService.inc.php');
  51 +require_once(CMIS_DIR . '/services/CMISNavigationService.inc.php');
  52 +require_once(CMIS_DIR . '/services/CMISObjectService.inc.php');
  53 +require_once(CMIS_DIR . '/util/CMISUtil.inc.php');
  54 +
  55 +class KTCMIS {
  56 +
  57 + /**
  58 + * Class for CMIS Repository Services
  59 + *
  60 + * @var object
  61 + */
  62 + protected $RepositoryService;
  63 + /**
  64 + * Class for CMIS Navigation Services
  65 + *
  66 + * @var object
  67 + */
  68 + protected $NavigationService;
  69 + /**
  70 + * Class for CMIS Object Services
  71 + *
  72 + * @var object
  73 + */
  74 + protected $ObjectService;
  75 + /**
  76 + * KnowledgeTree API instance
  77 + *
  78 + * @var object
  79 + */
  80 + protected $ktapi;
  81 + /**
  82 + * KnowledgeTree API Session Identifier
  83 + *
  84 + * @var object
  85 + */
  86 + protected $session;
  87 +
  88 + function __construct(&$ktapi = null, $user = '', $password = '')
  89 + {
  90 + // ktapi interface
  91 + $this->session = null;
  92 +// if (is_null($ktapi))
  93 +// {
  94 +// // TODO this should probably throw an exception instead
  95 +// return PEAR::RaiseError('Cannot continue without KTAPI instance');
  96 + // FIXME this CANNOT be allowed in a live environment
  97 + // possibly we should insist on a ktapi instance being passed
  98 + // or at least user/pass for logging in here, if one or other
  99 + // not sent, return error
  100 + $user = 'admin';
  101 + $password = 'admin';
  102 + $this->ktapi = new KTAPI();
  103 + $this->session = $this->ktapi->start_session($user, $password);
  104 +// }
  105 +// else
  106 +// {
  107 +// $this->ktapi = $ktapi;
  108 +// }
  109 +
  110 + // instantiate services
  111 + $this->RepositoryService = new CMISRepositoryService();
  112 + $this->NavigationService = new CMISNavigationService($this->ktapi);
  113 + $this->ObjectService = new CMISObjectService($this->ktapi);
  114 + }
  115 +
  116 + function __destruct()
  117 + {
  118 +// if ($this->session instanceOf KTAPI_UserSession)
  119 +// {
  120 +// try
  121 +// {
  122 +// $this->session->logout();
  123 +// }
  124 +// catch (Exception $e)
  125 +// {
  126 +// // no output
  127 +// }
  128 +// }
  129 + }
  130 +
  131 + // Repository service functions
  132 +
  133 + /**
  134 + * Fetch a list of all available repositories
  135 + *
  136 + * NOTE Since we only have one repository at the moment, this is expected to only return one result
  137 + *
  138 + * @return repositoryList[]
  139 + */
  140 + function getRepositories()
  141 + {
  142 + $repositories = $this->RepositoryService->getRepositories();
  143 + if (PEAR::isError($repositories))
  144 + {
  145 + return array(
  146 + "status_code" => 1,
  147 + "message" => "Failed getting repositories"
  148 + );
  149 + }
  150 +
  151 + // extract the required info fields into array format for easy encoding;
  152 + $count = 0;
  153 + $repositoryList = array();
  154 + foreach ($repositories as $repository)
  155 + {
  156 + $repositoryList[$count]['repositoryId'] = $repository->getRepositoryId();
  157 + $repositoryList[$count]['repositoryName'] = $repository->getRepositoryName();
  158 + $repositoryList[$count]['repositoryURI'] = $repository->getRepositoryURI();
  159 + ++$count;
  160 + }
  161 +
  162 + return array(
  163 + "status_code" => 0,
  164 + "results" => $repositoryList
  165 + );
  166 + }
  167 +
  168 + /**
  169 + * Fetches information about the selected repository
  170 + *
  171 + * @param string $repositoryId
  172 + */
  173 + function getRepositoryInfo($repositoryId)
  174 + {
  175 + $repositoryInfo = $this->RepositoryService->getRepositoryInfo($repositoryId);
  176 + if (PEAR::isError($repositoryInfo))
  177 + {
  178 + return array(
  179 + "status_code" => 1,
  180 + "message" => "Failed getting repository information"
  181 + );
  182 + }
  183 +
  184 + // TODO output this manually, the function works but only for some objects so rather avoid it completely
  185 + // NOTE the fact that it works for this instance is irrelevant...
  186 + return array (
  187 + "status_code" => 0,
  188 + "results" => CMISUtil::objectToArray($repositoryInfo)
  189 + );
  190 + }
  191 +
  192 + /**
  193 + * Fetch the list of supported object types for the selected repository
  194 + *
  195 + * @param string $repositoryId
  196 + */
  197 + function getTypes($repositoryId, $typeId = '', $returnPropertyDefinitions = false,
  198 + $maxItems = 0, $skipCount = 0, &$hasMoreItems = false)
  199 + {
  200 + $repositoryObjectTypeResult = $this->RepositoryService->getTypes($repositoryId, $typeId, $returnPropertyDefinitions,
  201 + $maxItems, $skipCount, $hasMoreItems);
  202 + if (PEAR::isError($repositoryObjectTypeResult))
  203 + {
  204 + return array(
  205 + "status_code" => 1,
  206 + "message" => "Failed getting supported object types"
  207 + );
  208 + }
  209 +
  210 + // format as array style output
  211 + // NOTE only concerned with attributes at this time
  212 + // TODO add support for properties
  213 + foreach($repositoryObjectTypeResult as $key => $objectType)
  214 + {
  215 + $repositoryObjectTypes[$key] = $objectType['attributes'];
  216 + // TODO properties
  217 + // $repositoryObjectTypes[$key]['properties'] = $objectType['properties'];
  218 + }
  219 +
  220 + return array (
  221 + "status_code" => 0,
  222 + "results" => $repositoryObjectTypes
  223 + );
  224 + }
  225 +
  226 + /**
  227 + * Fetch the object type definition for the requested type
  228 + *
  229 + * @param string $repositoryId
  230 + * @param string $typeId
  231 + */
  232 + function getTypeDefinition($repositoryId, $typeId)
  233 + {
  234 + $typeDefinitionResult = $this->RepositoryService->getTypeDefinition($repositoryId, $typeId);
  235 +
  236 + if (PEAR::isError($typeDefinitionResult))
  237 + {
  238 + return array(
  239 + "status_code" => 1,
  240 + "message" => "Failed getting object type definition for $typeId"
  241 + );
  242 + }
  243 +
  244 + // format as array style output
  245 + // NOTE only concerned with attributes at this time
  246 + // TODO add support for properties
  247 + $typeDefinition = $typeDefinitionResult['attributes'];
  248 +
  249 + return array (
  250 + "status_code" => 0,
  251 + "results" => $typeDefinition
  252 + );
  253 + }
  254 +
  255 + // Navigation service functions
  256 +
  257 + /**
  258 + * Get descendents of the specified folder, up to the depth indicated
  259 + *
  260 + * @param string $repositoryId
  261 + * @param string $folderId
  262 + * @param bool $includeAllowableActions
  263 + * @param bool $includeRelationships
  264 + * @param string $typeID
  265 + * @param int $depth
  266 + * @param string $filter
  267 + * @return array $descendants
  268 + */
  269 + function getDescendants($repositoryId, $folderId, $includeAllowableActions, $includeRelationships,
  270 + $depth = 1, $typeID = 'Any', $filter = '')
  271 + {
  272 + // TODO optional parameters
  273 + $descendantsResult = $this->NavigationService->getDescendants($repositoryId, $folderId, $includeAllowableActions,
  274 + $includeRelationships, $depth);
  275 +
  276 + if (PEAR::isError($descendantsResult))
  277 + {
  278 + return array(
  279 + "status_code" => 1,
  280 + "message" => "Failed getting descendants for folder"
  281 + );
  282 + }
  283 +
  284 + // format for webservices consumption
  285 + // NOTE this will almost definitely be changing in the future, this is just to get something working
  286 + $descendants = CMISUtil::decodeObjectHierarchy($descendantsResult, 'child');
  287 +// $descendants = array(array('properties' => array('objectId' => 'D2', 'typeId' => 'Document', 'name' => 'test document'),
  288 +// 'child' => array(array('properties' => array('objectId' => 'D7',
  289 +// 'typeId' => 'Document', 'name' => 'CHILD document'), 'child' => null),
  290 +// array('properties' => array('objectId' => 'F34',
  291 +// 'typeId' => 'Folder', 'name' => 'CHILD FOLDER'), 'child' => null))));
  292 +
  293 + return array (
  294 + "status_code" => 0,
  295 + "results" => $descendants
  296 + );
  297 + }
  298 +
  299 + /**
  300 + * Get direct children of the specified folder
  301 + *
  302 + * @param string $repositoryId
  303 + * @param string $folderId
  304 + * @param bool $includeAllowableActions
  305 + * @param bool $includeRelationships
  306 + * @param string $typeID
  307 + * @param string $filter
  308 + * @param int $maxItems
  309 + * @param int $skipCount
  310 + * @return array $descendants
  311 + */
  312 + function getChildren($repositoryId, $folderId, $includeAllowableActions, $includeRelationships,
  313 + $typeID = 'Any', $filter = '', $maxItems = 0, $skipCount = 0)
  314 + {
  315 + // TODO paging
  316 + // TODO optional parameters
  317 + $childrenResult = $this->NavigationService->getChildren($repositoryId, $folderId, $includeAllowableActions, $includeRelationships);
  318 +
  319 + if (PEAR::isError($childrenResult))
  320 + {
  321 + return array(
  322 + "status_code" => 1,
  323 + "message" => "Failed getting descendants for folder"
  324 + );
  325 + }
  326 +
  327 + $children = CMISUtil::decodeObjectHierarchy($childrenResult, 'child');
  328 +// $children = array(array('properties' => array('objectId' => 'D2', 'typeId' => 'Document', 'name' => 'test document'),
  329 +// 'child' => null));
  330 +
  331 + return array(
  332 + "status_code" => 0,
  333 + "results" => $children
  334 + );
  335 + }
  336 +
  337 + /**
  338 + * Gets the parent of the selected folder
  339 + *
  340 + * @param string $repositoryId
  341 + * @param string $folderId
  342 + * @param bool $includeAllowableActions
  343 + * @param bool $includeRelationships
  344 + * @param bool $returnToRoot
  345 + * @param string $filter
  346 + * @return ancestry[]
  347 + */
  348 + function getFolderParent($repositoryId, $folderId, $includeAllowableActions, $includeRelationships, $returnToRoot, $filter = '')
  349 + {
  350 + $ancestryResult = $this->NavigationService->getFolderParent($repositoryId, $folderId, $includeAllowableActions,
  351 + $includeRelationships, $returnToRoot);
  352 +
  353 + if (PEAR::isError($ancestryResult))
  354 + {
  355 + return array(
  356 + "status_code" => 1,
  357 + "message" => "Failed getting ancestry for folder"
  358 + );
  359 + }
  360 +
  361 + $ancestry = CMISUtil::decodeObjectHierarchy($ancestryResult, 'child');
  362 +// $ancestry = array(array('properties' => array('objectId' => 'D2', 'typeId' => 'Document', 'name' => 'test document'),
  363 +// 'child' => null));
  364 +
  365 + return array(
  366 + "status_code" => 0,
  367 + "results" => $ancestry
  368 + );
  369 + }
  370 +
  371 + /**
  372 + * Gets the parents for the selected object
  373 + *
  374 + * @param string $repositoryId
  375 + * @param string $folderId
  376 + * @param bool $includeAllowableActions
  377 + * @param bool $includeRelationships
  378 + * @param string $filter
  379 + * @return ancestry[]
  380 + */
  381 + function getObjectParents($repositoryId, $objectId, $includeAllowableActions, $includeRelationships, $filter = '')
  382 + {
  383 + $ancestryResult = $this->NavigationService->getObjectParents($repositoryId, $objectId, $includeAllowableActions,
  384 + $includeRelationships);
  385 +
  386 + if (PEAR::isError($ancestryResult))
  387 + {
  388 + return array(
  389 + "status_code" => 1,
  390 + "message" => "Failed getting ancestry for object"
  391 + );
  392 + }
  393 +
  394 + $ancestry = CMISUtil::decodeObjectHierarchy($ancestryResult, 'child');
  395 +// $ancestry = array(array('properties' => array('objectId' => 'D2', 'typeId' => 'Document', 'name' => 'test document'),
  396 +// 'child' => null));
  397 +
  398 +// $ancestry = array(array('properties' => array(array('property' => array('name' => 'objectId', $value => 'D2')),
  399 +// array('property' => array('name' => 'typeId', $value => 'Document')),
  400 +// array('property' => array('name' => 'name', $value => 'test document')))),
  401 +// 'child' => null);
  402 +
  403 + return array(
  404 + "status_code" => 0,
  405 + "results" => $ancestry
  406 + );
  407 + }
  408 +
  409 + /**
  410 + * Gets the properties for the selected object
  411 + *
  412 + * @param string $repositoryId
  413 + * @param string $objectId
  414 + * @param bool $includeAllowableActions
  415 + * @param bool $includeRelationships
  416 + * @param string $returnVersion
  417 + * @param string $filter
  418 + * @return properties[]
  419 + */
  420 + function getProperties($repositoryId, $objectId, $includeAllowableActions, $includeRelationships,
  421 + $returnVersion = false, $filter = '')
  422 + {
  423 + $propertiesResult = $this->ObjectService->getProperties($repositoryId, $objectId, $includeAllowableActions, $includeRelationships);
  424 +
  425 + if (PEAR::isError($propertiesResult))
  426 + {
  427 + return array(
  428 + "status_code" => 1,
  429 + "message" => "Failed getting properties for object"
  430 + );
  431 + }
  432 +// echo '<pre>'.print_r($propertiesResult, true).'</pre>';
  433 + // will need to convert to array format, so:
  434 + $propertyCollection['objectId'] = $propertiesResult->getValue('objectId');
  435 + $propertyCollection['URI'] = $propertiesResult->getValue('URI');
  436 + $propertyCollection['typeId'] = $propertiesResult->getValue('typeId');
  437 + $propertyCollection['createdBy'] = $propertiesResult->getValue('createdBy');
  438 + $propertyCollection['creationDate'] = $propertiesResult->getValue('creationDate');
  439 + $propertyCollection['lastModifiedBy'] = $propertiesResult->getValue('lastModifiedBy');
  440 + $propertyCollection['lastModificationDate'] = $propertiesResult->getValue('lastModificationDate');
  441 + $propertyCollection['changeToken'] = $propertiesResult->getValue('changeToken');
  442 +
  443 + $properties = array(array('properties' => $propertyCollection, 'child' => null));
  444 +// echo '<pre>'.print_r($properties, true).'</pre>';
  445 +//
  446 +// $properties = array(array('properties' => array('objectId' => 'F2', 'URI' => '', 'typeId' => 'Document',
  447 +// 'createdBy' => 'Administrator', 'creationDate' => '1 June 2009',
  448 +// 'lastModifiedBy' => 'Administrator', 'lastModificationDate' => '1 June 2009',
  449 +// 'changeToken' => ''),
  450 +// 'child' => null));
  451 +
  452 + return array(
  453 + "status_code" => 0,
  454 + "results" => $properties
  455 + );
  456 + }
  457 +}
  458 +
  459 +?>
ktcmis/objecttypes/CMISDocumentObject.inc.php 0 → 100644
  1 +<?php
  2 +/**
  3 + * CMIS Repository Document Object API class for KnowledgeTree.
  4 + *
  5 + * KnowledgeTree Community Edition
  6 + * Document Management Made Simple
  7 + * Copyright (C) 2008,2009 KnowledgeTree Inc.
  8 + * Portions copyright The Jam Warehouse Software (Pty) Limited
  9 + *
  10 + * This program is free software; you can redistribute it and/or modify it under
  11 + * the terms of the GNU General Public License version 3 as published by the
  12 + * Free Software Foundation.
  13 + *
  14 + * This program is distributed in the hope that it will be useful, but WITHOUT
  15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  16 + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  17 + * details.
  18 + *
  19 + * You should have received a copy of the GNU General Public License
  20 + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21 + *
  22 + * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
  23 + * California 94120-7775, or email info@knowledgetree.com.
  24 + *
  25 + * The interactive user interfaces in modified source and object code versions
  26 + * of this program must display Appropriate Legal Notices, as required under
  27 + * Section 5 of the GNU General Public License version 3.
  28 + *
  29 + * In accordance with Section 7(b) of the GNU General Public License version 3,
  30 + * these Appropriate Legal Notices must retain the display of the "Powered by
  31 + * KnowledgeTree" logo and retain the original copyright notice. If the display of the
  32 + * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
  33 + * must display the words "Powered by KnowledgeTree" and retain the original
  34 + * copyright notice.
  35 + *
  36 + * @copyright 2008-2009, KnowledgeTree Inc.
  37 + * @license GNU General Public License version 3
  38 + * @author KnowledgeTree Team
  39 + * @package KTCMIS
  40 + * @version Version 0.1
  41 + */
  42 +
  43 +require_once(CMIS_DIR . '/classes/CMISBaseObject.inc.php');
  44 +require_once(CMIS_DIR . '/classes/CMISDocumentPropertyCollection.inc.php');
  45 +require_once(CMIS_DIR . '/util/CMISUtil.inc.php');
  46 +
  47 +// TODO Property Type Definitions (only done Attributes up to now)
  48 +
  49 +class CMISDocumentObject extends CMISBaseObject {
  50 +
  51 + private $versionable;
  52 + private $contentStreamAllowed;
  53 + private $ktapi;
  54 + private $uri;
  55 +
  56 + // TODO some of this should probably come from configuration files as it is repository specific
  57 + function CMISDocumentObject(&$ktapi = null, $uri = null)
  58 + {
  59 + $this->ktapi = $ktapi;
  60 + // uri to use for document links
  61 + $this->uri = $uri;
  62 +
  63 + // attributes
  64 + $this->typeId = 'Document'; // <repository-specific>
  65 + $this->queryName = 'Document';
  66 + $this->displayName = ''; // <repository-specific>
  67 + $this->baseType = 'document';
  68 + $this->baseTypeQueryName = 'Document';
  69 + $this->parentId = null; // MUST NOT be set
  70 + $this->description = ''; // <repository-specific>
  71 + $this->creatable = ''; // <repository-specific>
  72 + /*
  73 + * fileable SHOULD be set as follows:
  74 + * If the repository does NOT support the “un-filing” capability:
  75 + * TRUE
  76 + * If the repository does support the “un-filing” capability:
  77 + * <repository-specific>, but SHOULD be TRUE
  78 + */
  79 + $this->fileable = true; // TODO implement check for whether un-filing is supported
  80 + $this->queryable = true; // SHOULD be true
  81 + $this->includedInSupertypeQuery = true; //
  82 + // TODO determine what these next 3 should be
  83 + $this->controllable = false; // <repository-specific>
  84 + $this->versionable = false; // <repository-specific>
  85 + $this->contentStreamAllowed = false; // <repository-specific>
  86 +
  87 + // properties
  88 + $this->properties = new CMISDocumentPropertyCollection();
  89 +
  90 + // set base object property definitions
  91 +// parent::__construct();
  92 +
  93 + // set document specific property definitions
  94 +
  95 + }
  96 +
  97 + function get($objectId)
  98 + {
  99 + $object = $this->ktapi->get_document_by_id($objectId);
  100 +
  101 + // error?
  102 + if (PEAR::isError($object))
  103 + {
  104 + // throw an exception?
  105 + return $object;
  106 + }
  107 +
  108 + $objectProperties = $object->get_detail();
  109 +
  110 + $this->_setPropertyInternal('objectId', CMISUtil::encodeObjectId($this->typeId, $objectProperties['document_id']));
  111 + // prevent doubled '/' chars
  112 + $uri = preg_replace_callback('/([^:]\/)\//',
  113 + create_function('$matches', 'return $matches[1];'),
  114 + $this->uri
  115 + . 'action.php?kt_path_info=ktnetwork.inlineview.actions.view&fDocumentId='
  116 + . $objectProperties['document_id']);
  117 + // NOTE what about instead creating a downloadable version with appropriate link? see ktapi::download_document
  118 + // also ktapidocument::get_download_url
  119 + $this->_setPropertyInternal('Uri', $uri);
  120 + // TODO what is this? Assuming it is the object type id, and not OUR document type?
  121 + $this->_setPropertyInternal('typeId', $this->getAttribute('typeId'));
  122 + $this->_setPropertyInternal('createdBy', $objectProperties['created_by']);
  123 + $this->_setPropertyInternal('creationDate', $objectProperties['created_date']);
  124 + $this->_setPropertyInternal('lastModifiedBy', $objectProperties['modified_by']);
  125 + $this->_setPropertyInternal('lastModificationDate', $objectProperties['modified_date']);
  126 + $this->_setPropertyInternal('changeToken', null);
  127 + $this->_setPropertyInternal('name', $objectProperties['title']);
  128 + $this->_setPropertyInternal('isImmutable', $objectProperties['is_immutable']);
  129 + // NOTE if access to older versions is allowed, this will need to be checked, else just set to yes
  130 + // see ktapi::get_document_version_history
  131 + // NOTE see ktapi::is_latest_version
  132 + $this->_setPropertyInternal('isLatestVersion', true);
  133 + $this->_setPropertyInternal('isMajorVersion', (strstr($objectProperties['version'], '.') ? false : true));
  134 + // NOTE if access to older versions is allowed, this will need to be checked, else just set to yes
  135 + // see ktapi::get_document_version_history
  136 + // NOTE see ktapi::is_latest_version
  137 + $this->_setPropertyInternal('isLatestMajorVersion', true);
  138 + $this->_setPropertyInternal('versionLabel', $objectProperties['version']);
  139 + // TODO what determines this, do we have anything?
  140 + $this->_setPropertyInternal('versionSeriesId', null);
  141 + if ($objectProperties['checked_out_by'] != 'n/a')
  142 + {
  143 + $checkedOut = true;
  144 + $checkedOutBy = $objectProperties['checked_out_by'];
  145 + // TODO this is not what it will actually be, just a convenient placeholder
  146 + $checkedOutId = $objectProperties['version'];
  147 + }
  148 + else
  149 + {
  150 + $checkedOut = false;
  151 + $checkedOutBy = null;
  152 + $checkedOutId = null;
  153 + }
  154 + $this->_setPropertyInternal('isVersionSeriesCheckedOut', $checkedOut);
  155 + $this->_setPropertyInternal('versionSeriesCheckedOutBy', $checkedOutBy);
  156 + // TODO presumably this is the ID of the Private Working Copy created on checkout?
  157 + // will find out more when we do checkout/checkin
  158 + $this->_setPropertyInternal('versionSeriesCheckedOutId', $checkedOutId);
  159 + // TODO currently not returned by KnowledgeTree?
  160 + $this->_setPropertyInternal('checkinComment', null);
  161 + // TODO if we implement content streams
  162 + $this->_setPropertyInternal('contentStreamLength', null);
  163 + $this->_setPropertyInternal('contentStreamMimeType', null);
  164 + $this->_setPropertyInternal('contentStreamFilename', null);
  165 + $this->_setPropertyInternal('contentStreamUri', null);
  166 + }
  167 +
  168 +}
  169 +
  170 +?>
ktcmis/objecttypes/CMISFolderObject.inc.php 0 → 100644
  1 +<?php
  2 +/**
  3 + * CMIS Repository Folder Object API class for KnowledgeTree.
  4 + *
  5 + * KnowledgeTree Community Edition
  6 + * Document Management Made Simple
  7 + * Copyright (C) 2008,2009 KnowledgeTree Inc.
  8 + * Portions copyright The Jam Warehouse Software (Pty) Limited
  9 + *
  10 + * This program is free software; you can redistribute it and/or modify it under
  11 + * the terms of the GNU General Public License version 3 as published by the
  12 + * Free Software Foundation.
  13 + *
  14 + * This program is distributed in the hope that it will be useful, but WITHOUT
  15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  16 + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  17 + * details.
  18 + *
  19 + * You should have received a copy of the GNU General Public License
  20 + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21 + *
  22 + * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
  23 + * California 94120-7775, or email info@knowledgetree.com.
  24 + *
  25 + * The interactive user interfaces in modified source and object code versions
  26 + * of this program must display Appropriate Legal Notices, as required under
  27 + * Section 5 of the GNU General Public License version 3.
  28 + *
  29 + * In accordance with Section 7(b) of the GNU General Public License version 3,
  30 + * these Appropriate Legal Notices must retain the display of the "Powered by
  31 + * KnowledgeTree" logo and retain the original copyright notice. If the display of the
  32 + * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
  33 + * must display the words "Powered by KnowledgeTree" and retain the original
  34 + * copyright notice.
  35 + *
  36 + * @copyright 2008-2009, KnowledgeTree Inc.
  37 + * @license GNU General Public License version 3
  38 + * @author KnowledgeTree Team
  39 + * @package KTCMIS
  40 + * @version Version 0.1
  41 + */
  42 +
  43 +require_once(CMIS_DIR . '/classes/CMISBaseObject.inc.php');
  44 +require_once(CMIS_DIR . '/classes/CMISFolderPropertyCollection.inc.php');
  45 +require_once(CMIS_DIR . '/util/CMISUtil.inc.php');
  46 +
  47 +class CMISFolderObject extends CMISBaseObject {
  48 +
  49 + var $ktapi;
  50 + var $uri;
  51 +
  52 + function CMISFolderObject(&$ktapi = null, $uri = null)
  53 + {
  54 + $this->ktapi = $ktapi;
  55 + $this->uri = $uri;
  56 +
  57 + $this->typeId = 'Folder'; // <repository-specific>
  58 + $this->queryName = 'Folder';
  59 + $this->displayName = ''; // <repository-specific>
  60 + $this->baseType = 'folder';
  61 + $this->baseTypeQueryName = 'Folder';
  62 + $this->parentId = null; // MUST NOT be set
  63 + $this->description = ''; // <repository-specific>
  64 + $this->creatable = ''; // <repository-specific>
  65 + $this->fileable = true;
  66 + $this->queryable = true; // SHOULD be true
  67 + $this->includedInSupertypeQuery = true; //
  68 + $this->controllable = ''; // <repository-specific>
  69 +
  70 + // properties
  71 + $this->properties = new CMISFolderPropertyCollection();
  72 + }
  73 +
  74 + function get($objectId)
  75 + {
  76 + $object = $this->ktapi->get_folder_by_id($objectId);
  77 +
  78 + // error?
  79 + if (PEAR::isError($object))
  80 + {
  81 + // throw an exception?
  82 + return $object;
  83 + }
  84 +
  85 +// static $allowedChildObjectTypeIds;
  86 +
  87 + $objectProperties = $object->get_detail();
  88 +
  89 + $this->_setPropertyInternal('objectId', CMISUtil::encodeObjectId($this->typeId, $objectProperties['id']));
  90 + // prevent doubled '/' chars
  91 + $uri = preg_replace_callback('/([^:]\/)\//',
  92 + create_function('$matches', 'return $matches[1];'),
  93 + $this->uri
  94 + . '/browse.php?fFolderId='
  95 + . $objectProperties['id']);
  96 + // TODO this url is probably incorrect...needs to be checked
  97 + $this->_setPropertyInternal('Uri', $uri);
  98 + // TODO what is this? Assuming it is the object type id, and not OUR document type?
  99 + $this->_setPropertyInternal('typeId', $this->getAttribute('typeId'));
  100 + $this->_setPropertyInternal('createdBy', $objectProperties['created_by']);
  101 + // TODO cannot currently retrieve via ktapi or regular folder code - add as with created by
  102 + $this->_setPropertyInternal('creationDate', $objectProperties['created_date']);
  103 + // TODO cannot currently retrieve via ktapi or regular folder code - add as with created by
  104 + $this->_setPropertyInternal('lastModifiedBy', $objectProperties['modified_by']);
  105 + // TODO cannot currently retrieve via ktapi or regular folder code - add as with created by
  106 + $this->_setPropertyInternal('lastModificationDate', $objectProperties['modified_date']);
  107 + $this->_setPropertyInternal('changeToken', null);
  108 + $this->_setPropertyInternal('name', $objectProperties['folder_name']);
  109 + $this->_setPropertyInternal('parentId', $objectProperties['parent_id']);
  110 + $this->_setPropertyInternal('allowedChildObjectTypeIds', array('Document', 'Folder'));
  111 + }
  112 +
  113 +}
  114 +
  115 +?>
ktcmis/services/CMISNavigationService.inc.php 0 → 100644
  1 +<?php
  2 +/**
  3 + * CMIS Repository Navigation API class for KnowledgeTree.
  4 + *
  5 + * KnowledgeTree Community Edition
  6 + * Document Management Made Simple
  7 + * Copyright (C) 2008,2009 KnowledgeTree Inc.
  8 + * Portions copyright The Jam Warehouse Software (Pty) Limited
  9 + *
  10 + * This program is free software; you can redistribute it and/or modify it under
  11 + * the terms of the GNU General Public License version 3 as published by the
  12 + * Free Software Foundation.
  13 + *
  14 + * This program is distributed in the hope that it will be useful, but WITHOUT
  15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  16 + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  17 + * details.
  18 + *
  19 + * You should have received a copy of the GNU General Public License
  20 + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21 + *
  22 + * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
  23 + * California 94120-7775, or email info@knowledgetree.com.
  24 + *
  25 + * The interactive user interfaces in modified source and object code versions
  26 + * of this program must display Appropriate Legal Notices, as required under
  27 + * Section 5 of the GNU General Public License version 3.
  28 + *
  29 + * In accordance with Section 7(b) of the GNU General Public License version 3,
  30 + * these Appropriate Legal Notices must retain the display of the "Powered by
  31 + * KnowledgeTree" logo and retain the original copyright notice. If the display of the
  32 + * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
  33 + * must display the words "Powered by KnowledgeTree" and retain the original
  34 + * copyright notice.
  35 + *
  36 + * @copyright 2008-2009, KnowledgeTree Inc.
  37 + * @license GNU General Public License version 3
  38 + * @author KnowledgeTree Team
  39 + * @package KTCMIS
  40 + * @version Version 0.1
  41 + */
  42 +
  43 +// really wanted to keep KT code out of here but I don't see how
  44 +require_once(KT_DIR . '/ktapi/ktapi.inc.php');
  45 +require_once(CMIS_DIR . '/util/CMISUtil.inc.php');
  46 +
  47 +class CMISNavigationService {
  48 +
  49 + protected $ktapi;
  50 +
  51 + function CMISNavigationService(&$ktapi)
  52 + {
  53 + $this->ktapi = $ktapi;
  54 + }
  55 +
  56 + /**
  57 + * Get descendents of the specified folder, up to the depth indicated
  58 + *
  59 + * @param string $repositoryId
  60 + * @param string $folderId
  61 + * @param bool $includeAllowableActions
  62 + * @param bool $includeRelationships
  63 + * @param string $typeId
  64 + * @param int $depth
  65 + * @param string $filter
  66 + * @return array $descendants
  67 + */
  68 +
  69 + // NOTE This method does NOT support paging as defined in the paging section
  70 + // NOTE If the Repository supports the optional “VersionSpecificFiling” capability,
  71 + // then the repository SHALL return the document versions filed in the specified folder or its descendant folders.
  72 + // Otherwise, the latest version of the documents SHALL be returned.
  73 +
  74 + // TODO FilterNotValidException: The Repository SHALL throw this exception if this property filter input parameter is not valid
  75 + function getDescendants($repositoryId, $folderId, $includeAllowableActions, $includeRelationships,
  76 + $depth = 1, $typeId = 'Any', $filter = '')
  77 + {
  78 + // TODO optional parameters
  79 + $descendants = array();
  80 + $repository = new CMISRepository($repositoryId);
  81 +
  82 + // if this is not a folder, cannot get descendants
  83 + $type = CMISUtil::decodeObjectId($folderId);
  84 +
  85 + if ($type != 'Folder')
  86 + {
  87 + return $descendants;
  88 + }
  89 +
  90 + $folder = $this->ktapi->get_folder_by_id($folderId);
  91 + $descendants = $folder->get_listing($depth);
  92 +
  93 + // parse ktapi descendants result into a list of CMIS objects
  94 + $descendants = CMISUtil::createChildObjectHierarchy($descendants, $repository->getRepositoryURI, $this->ktapi);
  95 +
  96 + return $descendants;
  97 + }
  98 +
  99 + /**
  100 + * Get direct children of the specified folder
  101 + *
  102 + * @param string $repositoryId
  103 + * @param string $folderId
  104 + * @param bool $includeAllowableActions
  105 + * @param bool $includeRelationships
  106 + * @param string $typeId
  107 + * @param string $filter
  108 + * @param int $maxItems
  109 + * @param int $skipCount
  110 + * @return array $descendants
  111 + */
  112 + // NOTE If the Repository supports the optional “VersionSpecificFiling” capability,
  113 + // then the repository SHALL return the document versions filed in the specified folder or its descendant folders.
  114 + // Otherwise, the latest version of the documents SHALL be returned.
  115 + // TODO FilterNotValidException: The Repository SHALL throw this exception if this property filter input parameter is not valid
  116 + function getChildren($repositoryId, $folderId, $includeAllowableActions, $includeRelationships,
  117 + $typeId = 'Any', $filter = '', $maxItems = 0, $skipCount = 0)
  118 + {
  119 + // TODO paging
  120 + // TODO optional parameters
  121 + $children = array();
  122 + $repository = new CMISRepository($repositoryId);
  123 +
  124 + // if this is not a folder, cannot get children
  125 + $type = CMISUtil::decodeObjectId($folderId);
  126 + // NOTE this will quite possibly break the webservices
  127 + if ($type != 'Folder')
  128 + {
  129 + return $children;
  130 + }
  131 +
  132 + $folder = $this->ktapi->get_folder_by_id($folderId);
  133 + $children = $folder->get_listing();
  134 +
  135 + $children = CMISUtil::createChildObjectHierarchy($children, $repository->getRepositoryURI, $this->ktapi);
  136 +
  137 + return $children;
  138 + }
  139 +
  140 + /**
  141 + * Fetches the folder parent and optional ancestors
  142 + *
  143 + * @param string $repositoryId
  144 + * @param string $folderId
  145 + * @param bool $includeAllowableActions
  146 + * @param bool $includeRelationships
  147 + * @param bool $returnToRoot If TRUE, then the repository SHALL return all folder objects
  148 + * that are ancestors of the specified folder.
  149 + * If FALSE, the repository SHALL return only the parent folder of the specified folder.
  150 + * @param string $filter
  151 + * @return array $ancestry
  152 + */
  153 + // TODO FilterNotValidException: The Repository SHALL throw this exception if this property filter input parameter is not valid
  154 + // NOTE SHOULD always include the “ObjectId” and “ParentId” properties for all objects returned
  155 + // NOTE If this service method is invoked on the root folder of the Repository, then the Repository shall return an empty result set.
  156 + function getFolderParent($repositoryId, $folderId, $includeAllowableActions, $includeRelationships, $returnToRoot, $filter = '')
  157 + {
  158 + $ancestry = array();
  159 + $repository = new CMISRepository($repositoryId);
  160 +
  161 + // if this is not a folder, cannot get folder parent :)
  162 + $type = CMISUtil::decodeObjectId($folderId);
  163 + // NOTE this will quite possibly break the webservices
  164 + if ($type != 'Folder')
  165 + {
  166 + return $ancestry;
  167 + }
  168 +
  169 + $ktapiFolder = $this->ktapi->get_folder_by_id($folderId);
  170 +
  171 + // TODO return full ancestry on $returnToRoot == true
  172 + if ($returnToRoot)
  173 + {
  174 + $folder = $ktapiFolder->get_folder();
  175 + $parents = $folder->generateFolderIDs($folderId);
  176 + // remove the id of the requesting folder and convert to array
  177 + $ancestry = explode(',', str_replace(','.$folderId, '', $parents));
  178 + // reverse to get bottom up listing? don't think so with the current implementation
  179 + // specifying that objectTypes may have children but do not have parents listed.
  180 +// $ancestry = array_reverse($ancestry);
  181 + }
  182 + else
  183 + {
  184 + $parent = $ktapiFolder->get_parent_folder_id();
  185 + $ancestry[] = $parent;
  186 + }
  187 +
  188 + // need some info about the parent(s) in order to correctly create the hierarchy
  189 + $tmpArray = array();
  190 + foreach ($ancestry as $key => $ancestor)
  191 + {
  192 + $tmpArray[$key] = $this->ktapi->get_folder_by_id($ancestor);
  193 + }
  194 + $ancestry = $tmpArray;
  195 + unset($tmpArray);
  196 +
  197 + $ancestry = CMISUtil::createParentObjectHierarchy($ancestry, $repository->getRepositoryURI, $this->ktapi);
  198 +
  199 + return $ancestry;
  200 + }
  201 +
  202 + /**
  203 + *
  204 + * @param string $repositoryId
  205 + * @param string $objectId
  206 + * @param bool $includeAllowableActions
  207 + * @param bool $includeRelationships
  208 + * @param string $filter
  209 + * @return array $parents
  210 + */
  211 + // TODO ConstraintViolationException: The Repository SHALL throw this exception if this method is invoked
  212 + // on an object who Object-Type Defintion specifies that it is not fileable.
  213 + // FilterNotValidException: The Repository SHALL throw this exception if this property filter input parameter is not valid.
  214 + function getObjectParents($repositoryId, $objectId, $includeAllowableActions, $includeRelationships, $filter = '')
  215 + {
  216 + $ancestry = array();
  217 +
  218 + $typeId = CMISUtil::decodeObjectId($objectId);
  219 +
  220 + // TODO - what about other types? only implementing folders and documents at the moment so ignore for now
  221 + switch($typeId)
  222 + {
  223 + case 'Document':
  224 + $document = $this->ktapi->get_document_by_id($objectId);
  225 + $parent = $document->ktapi_folder;
  226 + $ancestry[] = $parent;
  227 + break;
  228 + case 'Folder':
  229 + $folder = $this->ktapi->get_folder_by_id($objectId);
  230 + $parent = $this->ktapi->get_folder_by_id($folder->get_parent_folder_id());
  231 + $ancestry[] = $parent;
  232 + break;
  233 + }
  234 +
  235 +// echo 'PARENT<BR><pre>'.print_r($parent, true).'</pre>';
  236 +//
  237 +//echo '<pre>'.print_r($ancestry, true).'</pre>';
  238 +// // need some info about the parent(s) in order to correctly create the hierarchy
  239 +// $tmpArray = array();
  240 +// foreach ($ancestry as $key => $ancestor)
  241 +// {
  242 +// echo '<pre>'.print_r($ancestor, true).'</pre>';
  243 +// $tmpArray[$key] = $this->ktapi->get_folder_by_id($ancestor);
  244 +// }
  245 +// $ancestry = $tmpArray;
  246 +// unset($tmpArray);
  247 +
  248 + $ancestry = CMISUtil::createParentObjectHierarchy($ancestry, $repository->getRepositoryURI, $this->ktapi);
  249 +
  250 + return $ancestry;
  251 + }
  252 +
  253 +}
  254 +
  255 +?>
ktcmis/services/CMISObjectService.inc.php 0 → 100644
  1 +<?php
  2 +
  3 +// really wanted to keep KT code out of here but I don't see how
  4 +require_once(KT_DIR . '/ktapi/ktapi.inc.php');
  5 +require_once(CMIS_DIR . '/objecttypes/CMISDocumentObject.inc.php');
  6 +require_once(CMIS_DIR . '/objecttypes/CMISFolderObject.inc.php');
  7 +require_once(CMIS_DIR . '/classes/CMISRepository.inc.php');
  8 +require_once(CMIS_DIR . '/util/CMISUtil.inc.php');
  9 +
  10 +class CMISObjectService {
  11 +
  12 + protected $ktapi;
  13 +
  14 + function CMISObjectService(&$ktapi)
  15 + {
  16 + $this->ktapi = $ktapi;
  17 + }
  18 +
  19 + /**
  20 + * Fetches the properties for the specified object
  21 + *
  22 + * @param string $repositoryId
  23 + * @param string $objectId
  24 + * @param bool $includeAllowableActions
  25 + * @param bool $includeRelationships
  26 + * @param bool $returnVersion
  27 + * @param string $filter
  28 + * @return object CMIS object properties
  29 + */
  30 + // TODO optional parameter support
  31 + // TODO FilterNotValidException: The Repository SHALL throw this exception if this property filter input parameter is not valid
  32 + function getProperties($repositoryId, $objectId, $includeAllowableActions, $includeRelationships,
  33 + $returnVersion = false, $filter = '')
  34 + {
  35 + $repository = new CMISRepository($repositoryId);
  36 +
  37 + // TODO a better default value?
  38 + $properties = array();
  39 +
  40 + $typeId = CMISUtil::decodeObjectId($objectId);
  41 +
  42 + switch($typeId)
  43 + {
  44 + case 'Document':
  45 + $CMISObject = new CMISDocumentObject($this->ktapi, $repository->getRepositoryURI());
  46 + break;
  47 + case 'Folder':
  48 + $CMISObject = new CMISFolderObject($this->ktapi, $repository->getRepositoryURI());
  49 + break;
  50 + }
  51 +
  52 + $CMISObject->get($objectId);
  53 + $properties = $CMISObject->getProperties();
  54 +
  55 + return $properties;
  56 + }
  57 +
  58 +}
  59 +
  60 +?>
ktcmis/services/CMISRepositoryService.inc.php 0 → 100644
  1 +<?php
  2 +
  3 +/**
  4 +* CMIS Repository Service API class for KnowledgeTree.
  5 +*
  6 +* KnowledgeTree Community Edition
  7 +* Document Management Made Simple
  8 +* Copyright (C) 2008,2009 KnowledgeTree Inc.
  9 +* Portions copyright The Jam Warehouse Software (Pty) Limited
  10 +*
  11 +* This program is free software; you can redistribute it and/or modify it under
  12 +* the terms of the GNU General Public License version 3 as published by the
  13 +* Free Software Foundation.
  14 +*
  15 +* This program is distributed in the hope that it will be useful, but WITHOUT
  16 +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  17 +* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  18 +* details.
  19 +*
  20 +* You should have received a copy of the GNU General Public License
  21 +* along with this program. If not, see <http://www.gnu.org/licenses/>.
  22 +*
  23 +* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
  24 +* California 94120-7775, or email info@knowledgetree.com.
  25 +*
  26 +* The interactive user interfaces in modified source and object code versions
  27 +* of this program must display Appropriate Legal Notices, as required under
  28 +* Section 5 of the GNU General Public License version 3.
  29 +*
  30 +* In accordance with Section 7(b) of the GNU General Public License version 3,
  31 +* these Appropriate Legal Notices must retain the display of the "Powered by
  32 +* KnowledgeTree" logo and retain the original copyright notice. If the display of the
  33 +* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
  34 +* must display the words "Powered by KnowledgeTree" and retain the original
  35 +* copyright notice.
  36 +*
  37 +* @copyright 2008-2009, KnowledgeTree Inc.
  38 +* @license GNU General Public License version 3
  39 +* @author KnowledgeTree Team
  40 +* @package KTCMIS
  41 +* @version Version 0.1
  42 +*/
  43 +
  44 +require_once(CMIS_DIR . '/classes/CMISRepository.inc.php');
  45 +require_once(CMIS_DIR . '/classes/CMISObjectTypes.inc.php');
  46 +
  47 +/**
  48 + * CMIS Repository Service.
  49 + */
  50 +class CMISRepositoryService {
  51 +
  52 + /**
  53 + * Gets a list of available repositories.
  54 + *
  55 + * @return a collection of repository entries
  56 + */
  57 + function getRepositories()
  58 + {
  59 + $repositories = array();
  60 +
  61 + // read the repositories config file to get the list of available repositories
  62 + // TODO what if file does not exist?
  63 + $xml = simplexml_load_file(CMIS_DIR . '/config/repositories.xml');
  64 +
  65 + foreach($xml->repository as $repositoryXML)
  66 + {
  67 + $repositoryId = (string)$repositoryXML->repositoryInfo[0]->repositoryId;
  68 + $Repository = new CMISRepository($repositoryId, $repositoryXML);
  69 + $repositories[] = $Repository;
  70 + }
  71 +
  72 + return $repositories;
  73 + }
  74 +
  75 + /**
  76 + * Fetches the RepositoryInfo object for a specified repository
  77 + *
  78 + * @param string $repositoryId
  79 + * @return object $repositoryInfo
  80 + */
  81 + function getRepositoryInfo($repositoryId)
  82 + {
  83 + $Repository = new CMISRepository($repositoryId);
  84 + $repositoryInfo = $Repository->getRepositoryInfo();
  85 +
  86 + return $repositoryInfo;
  87 + }
  88 +
  89 + /**
  90 + * Gets a list of object types supported by the repository
  91 + *
  92 + * @param string $repositoryId The ID of the repository for which object types must be returned
  93 + * @param string $typeId The type to return, ALL if not set
  94 + * @param boolean $returnPropertyDefinitions Return property definitions as well if TRUE
  95 + * @param int $maxItems The maximum number of items to return
  96 + * @param int $skipCount The number of items to skip before starting to return results
  97 + * @param boolean $hasMoreItems TRUE if there are more items to return than were requested
  98 + * @return array $objectTypes
  99 + */
  100 + // NOTE this code may fit better within the Repository Class
  101 + function getTypes($repositoryId, $typeId = '', $returnPropertyDefinitions = false,
  102 + $maxItems = 0, $skipCount = 0, &$hasMoreItems = false)
  103 + {
  104 + // TODO throw invalidArgumentException if invalid typeId submitted
  105 +
  106 + $repository = new CMISRepository($repositoryId);
  107 + $supportedTypes = $repository->getTypes();
  108 +
  109 + $types = array();
  110 +
  111 + // determine which types are actually supported based on available class definitions
  112 + // compared with the repository's declaration of the types it supports
  113 + $objectTypes = new CMISObjectTypes();
  114 + $types = $objectTypes->getObjectTypes();
  115 +
  116 + foreach ($types as $key => $objectType)
  117 + {
  118 + // filter this list according to what is defined for the selected repository
  119 + // additionally filter based on typeId if set
  120 + if (!in_array($objectType, $supportedTypes) || (($typeId != '') && ($typeId != $objectType)))
  121 + {
  122 + unset($types[$key]);
  123 + continue;
  124 + }
  125 + $types[$key] = $this->getTypeDefinition($repositoryId, $objectType);
  126 + // only return properties if explicitly requested
  127 + if (!$returnPropertyDefinitions)
  128 + {
  129 + unset($types[$key]['properties']);
  130 + }
  131 + }
  132 +
  133 + return $types;
  134 + }
  135 +
  136 + /**
  137 + * Fetches the object type definition for the requested type
  138 + *
  139 + * @param string $repositoryId The ID of the repository
  140 + * @param string $typeId The ID of the object type requested
  141 + * @return $array $typeDefinition
  142 + */
  143 + function getTypeDefinition($repositoryId, $typeId)
  144 + {
  145 + $typeDefinition = array();
  146 +
  147 + require_once(CMIS_DIR . '/objecttypes/CMIS' . $typeId . 'Object.inc.php');
  148 + $object = 'CMIS' . $typeId . 'Object';
  149 + $tmpObject = new $object;
  150 + $typeDefinition['attributes'] = $tmpObject->getAttributes();
  151 + $typeDefinition['properties'] = $tmpObject->getProperties();
  152 +
  153 + return $typeDefinition;
  154 + }
  155 +
  156 +}
  157 +
  158 +?>
0 \ No newline at end of file 159 \ No newline at end of file
ktcmis/util/CMISUtil.inc.php 0 → 100644
  1 +<?php
  2 +/**
  3 + * CMIS Helper class for KnowledgeTree.
  4 + *
  5 + * KnowledgeTree Community Edition
  6 + * Document Management Made Simple
  7 + * Copyright (C) 2008,2009 KnowledgeTree Inc.
  8 + * Portions copyright The Jam Warehouse Software (Pty) Limited
  9 + *
  10 + * This program is free software; you can redistribute it and/or modify it under
  11 + * the terms of the GNU General Public License version 3 as published by the
  12 + * Free Software Foundation.
  13 + *
  14 + * This program is distributed in the hope that it will be useful, but WITHOUT
  15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  16 + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  17 + * details.
  18 + *
  19 + * You should have received a copy of the GNU General Public License
  20 + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21 + *
  22 + * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
  23 + * California 94120-7775, or email info@knowledgetree.com.
  24 + *
  25 + * The interactive user interfaces in modified source and object code versions
  26 + * of this program must display Appropriate Legal Notices, as required under
  27 + * Section 5 of the GNU General Public License version 3.
  28 + *
  29 + * In accordance with Section 7(b) of the GNU General Public License version 3,
  30 + * these Appropriate Legal Notices must retain the display of the "Powered by
  31 + * KnowledgeTree" logo and retain the original copyright notice. If the display of the
  32 + * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
  33 + * must display the words "Powered by KnowledgeTree" and retain the original
  34 + * copyright notice.
  35 + *
  36 + * @copyright 2008-2009, KnowledgeTree Inc.
  37 + * @license GNU General Public License version 3
  38 + * @author KnowledgeTree Team
  39 + * @package KTCMIS
  40 + * @version Version 0.1
  41 + */
  42 +
  43 +require_once(CMIS_DIR . '/objecttypes/CMISDocumentObject.inc.php');
  44 +require_once(CMIS_DIR . '/objecttypes/CMISFolderObject.inc.php');
  45 +
  46 +class CMISUtil {
  47 +
  48 + /**
  49 + * Adds a text identifier to the object ID in order to easily
  50 + * verify which object type we are working with on a return request
  51 + *
  52 + * @param string $typeId
  53 + * @param string $objectId
  54 + * @return string $encoded
  55 + */
  56 + static function encodeObjectId($typeId, $objectId)
  57 + {
  58 + $encoded = null;
  59 +
  60 + switch ($typeId)
  61 + {
  62 + case 'D':
  63 + case 'Document':
  64 + $encoded = 'D' . $objectId;
  65 + break;
  66 + case 'F':
  67 + case 'Folder':
  68 + $encoded = 'F' . $objectId;
  69 + break;
  70 + default:
  71 + $encoded = $objectId;
  72 + break;
  73 + }
  74 +
  75 + return $encoded;
  76 + }
  77 +
  78 + /**
  79 + * Decodes the identifier created by encodeObjectId to return an object type
  80 + * and a system useable ID
  81 + *
  82 + * The decoded object ID is returned by reference via the argument list
  83 + *
  84 + * @param string $objectId
  85 + * @return string $typeId
  86 + */
  87 + static function decodeObjectId(&$objectId)
  88 + {
  89 + $typeId = null;
  90 +
  91 + preg_match('/(\D)(\d*)/', $objectId, $matches);
  92 + $type = $matches[1];
  93 + $objectId = $matches[2];
  94 +
  95 + switch($type)
  96 + {
  97 + case 'D':
  98 + $typeId = 'Document';
  99 + break;
  100 + case 'F':
  101 + $typeId = 'Folder';
  102 + break;
  103 + default:
  104 + $typeId = 'Unknown';
  105 + break;
  106 + }
  107 +
  108 + return $typeId;
  109 + }
  110 +
  111 + /**
  112 + * Takes an array of KnowledgeTree KTAPI objects and returns an array of CMIS objects of the same type
  113 + *
  114 + * Utilises the descending structure already present within KTAPI
  115 + *
  116 + * @param array $input
  117 + * @param string $repositoryURI
  118 + * @param object $ktapi // reference to ktapi instance
  119 + * @return array $CMISArray
  120 + */
  121 + static function createChildObjectHierarchy($input, $repositoryURI, &$ktapi)
  122 + {
  123 + $CMISArray = array();
  124 +
  125 + $count = -1;
  126 + foreach($input as $object)
  127 + {
  128 + ++$count;
  129 + if (is_array($object))
  130 + {
  131 + if (isset($object['id']))
  132 + {
  133 + switch($object['item_type'])
  134 + {
  135 + case 'D':
  136 + $CMISObject = new CMISDocumentObject($ktapi, $repositoryURI);
  137 + break;
  138 + case 'F':
  139 + $CMISObject = new CMISFolderObject($ktapi, $repositoryURI);
  140 + break;
  141 + }
  142 + $CMISObject->get($object['id']);
  143 + $CMISArray[$count]['object'] = $CMISObject;
  144 +
  145 + // if sub-array
  146 + if (count($object['items']) > 0)
  147 + {
  148 + $CMISArray[$count]['items'] = CMISUtil::createChildObjectHierarchy($object['items'], $repositoryURI, $ktapi);
  149 + }
  150 + }
  151 + else
  152 + {
  153 + // NOTE why is this necessary? That's what you get for not commenting it at the time
  154 + // TODO comment this properly
  155 + $CMISArray[$count] = CMISUtil::createChildObjectHierarchy($object, $repositoryURI, $ktapi);
  156 + }
  157 + }
  158 + }
  159 +
  160 + return $CMISArray;
  161 + }
  162 +
  163 + /**
  164 + * Takes an array of KnowledgeTree KTAPI objects and returns an array of CMIS objects of the same type
  165 + *
  166 + * As there is no corresponding hierarchy setup for parent trees, this works differently to the child
  167 + * hirerarchy function
  168 + *
  169 + * @param array $input
  170 + * @param string $repositoryURI
  171 + * @param object $ktapi // reference to ktapi instance
  172 + * @return array $CMISArray
  173 + */
  174 + // NOTE this will have to change if we implement multi-filing
  175 + static function createParentObjectHierarchy($input, $repositoryURI, &$ktapi)
  176 + {
  177 + $CMISArray = array();
  178 +
  179 + if (count($input) <= 0) return $CMISArray;
  180 +
  181 + $object = array_shift($input);
  182 + $detail = $object->get_detail();
  183 +
  184 + if (isset($detail['id']))
  185 + {
  186 + $CMISObject = new CMISFolderObject($ktapi, $repositoryURI);
  187 + $CMISObject->get($detail['id']);
  188 + $CMISElement['object'] = $CMISObject;
  189 +
  190 + // if more parent elements
  191 + if (count($input) > 0)
  192 + {
  193 + $CMISElement['items'] = CMISUtil::createParentObjectHierarchy($input, $repositoryURI, $ktapi);
  194 + }
  195 +
  196 + $CMISArray[] = $CMISElement;
  197 + }
  198 +
  199 + return $CMISArray;
  200 + }
  201 +
  202 + /**
  203 + * Parses a hierarchy of CMIS objects to return an array format of a subset of information
  204 + * required for a webservice response
  205 + *
  206 + * Essentially a reversal of createChildObjectHierarchy and createParentObjectHierarchy,
  207 + * though the output may well be different to what went into that function
  208 + *
  209 + * @param array $input // input hierarchy to decode
  210 + * @param string $linkText // 'child' or 'parent' - indicates direction of hierarchy => descending or ascending
  211 + * @return array $hierarchy
  212 + */
  213 + static function decodeObjectHierarchy($input, $linkText)
  214 + {
  215 + $hierarchy = array();
  216 +
  217 + // first, run through the base array to get the initial children
  218 + foreach ($input as $key => $entry)
  219 + {
  220 + $object = $entry['object'];
  221 + $properties = $object->getProperties();
  222 +
  223 + $hierarchy[$key]['properties']['objectId'] = $properties->getValue('objectId');
  224 + $hierarchy[$key]['properties']['typeId'] = $properties->getValue('typeId');
  225 + $hierarchy[$key]['properties']['name'] = $properties->getValue('name');
  226 +
  227 + // if we have found a child/parent with one or more children/parents, recurse into the child/parent object
  228 + if (count($entry['items']) > 0)
  229 + {
  230 + $hierarchy[$key][$linkText] = CMISUtil::decodeObjectHierarchy($entry['items'], $linkText);
  231 + }
  232 + // NOTE may need to set a null value here in case webservices don't like it unset
  233 + // so we'll set it just in case...
  234 + else
  235 + {
  236 + $hierarchy[$key][$linkText] = null;
  237 + }
  238 + }
  239 +
  240 + return $hierarchy;
  241 + }
  242 +
  243 + /**
  244 + * This function takes a class object and converts it to an array structure
  245 + * via var_export (which returns a useable PHP string for creating the object from array content)
  246 + * and regular expressions to extract the array definitions and structure without the class specific code
  247 + *
  248 + * NOTE this function is not reliable for objects which contain ktapi instances, as it appears there is a recursive reference
  249 + * TODO attempt to deal with recursive references?
  250 + *
  251 + * @param object $data
  252 + * @return array $array
  253 + */
  254 + static function objectToArray($data)
  255 + {
  256 + $array = array();
  257 +
  258 + $stringdata = var_export($data, true);
  259 + // clean up ", )" - NOTE this may not be necessary
  260 + $stringdata = preg_replace('/, *\r?\n? *\)/', ')', $stringdata);
  261 +
  262 + // NOTE is this while loop even needed?
  263 + while (preg_match('/\b[\w]*::__set_state\(/', $stringdata, $matches))
  264 + {
  265 + $stringdata = preg_replace('/\b[\w]*::__set_state\(/', $matches[1], $stringdata);
  266 + }
  267 +
  268 + // remove end parentheses, should come in pairs to be reduced by 1
  269 + $stringdata = '$array = ' . preg_replace('/\)\)/', ')', $stringdata) . ';';
  270 + eval($stringdata);
  271 +
  272 + return $array;
  273 + }
  274 +
  275 +}
  276 +
  277 +?>
tests/runtests.php
@@ -7,15 +7,18 @@ class UnitTests extends TestSuite { @@ -7,15 +7,18 @@ class UnitTests extends TestSuite {
7 7
8 $this->TestSuite('Unit tests'); 8 $this->TestSuite('Unit tests');
9 9
  10 + // CMIS API
  11 + $this->addFile('ktcmis/testCmisApi.php');
  12 +
10 // KTAPI 13 // KTAPI
11 // Some of these tests will fail if Electronic Signatures are enabled for the API. 14 // Some of these tests will fail if Electronic Signatures are enabled for the API.
12 // To fix, check the failing functions and add 'admin', 'admin' as username and password, 15 // To fix, check the failing functions and add 'admin', 'admin' as username and password,
13 // and where necessary send 'Testing API' as a reason 16 // and where necessary send 'Testing API' as a reason
14 - $this->addFile('api/testApi.php');  
15 - $this->addFile('api/testAuto.php');  
16 - $this->addFile('api/testSavedSearches.php');  
17 - $this->addFile('api/testAcl.php');  
18 - $this->addFile('api/testAuthentication.php'); 17 +// $this->addFile('api/testApi.php');
  18 +// $this->addFile('api/testAuto.php');
  19 +// $this->addFile('api/testSavedSearches.php');
  20 +// $this->addFile('api/testAcl.php');
  21 +// $this->addFile('api/testAuthentication.php');
19 22
20 // the next two appear to not use the ktapi functions which require signatures, 23 // the next two appear to not use the ktapi functions which require signatures,
21 // e.g. the move function is called directly on the document ($document->move()) 24 // e.g. the move function is called directly on the document ($document->move())
@@ -26,14 +29,14 @@ class UnitTests extends TestSuite { @@ -26,14 +29,14 @@ class UnitTests extends TestSuite {
26 // $this->addFile('api/testDocument.php'); 29 // $this->addFile('api/testDocument.php');
27 // $this->addFile('api/testFolder.php'); 30 // $this->addFile('api/testFolder.php');
28 31
29 - $this->addFile('api/testBulkActions.php');  
30 - $this->addFile('api/testCollection.php'); 32 +// $this->addFile('api/testBulkActions.php');
  33 +// $this->addFile('api/testCollection.php');
31 34
32 // While the original tests for esignatures have been set up to work 35 // While the original tests for esignatures have been set up to work
33 // if Electronic Signatures are NOT enabled for the API, new tests may not 36 // if Electronic Signatures are NOT enabled for the API, new tests may not
34 // include the check which allows the tests to be bypassed when esignatures 37 // include the check which allows the tests to be bypassed when esignatures
35 // are not on, so if you have failures, check there first :) 38 // are not on, so if you have failures, check there first :)
36 - $this->addFile('api/testElectronicSignatures.php'); 39 +// $this->addFile('api/testElectronicSignatures.php');
37 40
38 // $this->addFile('SQLFile/test_sqlfile.php'); 41 // $this->addFile('SQLFile/test_sqlfile.php');
39 // $this->addFile('cache/testCache.php'); 42 // $this->addFile('cache/testCache.php');
webservice/classes/soap/config.php
1 -<?php  
2 -  
3 -/* All the allowed webservice classes */  
4 -$WSClasses = array(  
5 - "contactManager",  
6 - "RestService"  
7 -  
8 -  
9 -);  
10 -  
11 -/* The classmap associative array. When you want to allow objects as a parameter for  
12 - * your webservice method. ie. saveObject($object). By default $object will now be  
13 - * a stdClass, but when you add a classname defined in the type description in the @param  
14 - * documentation tag and add your class to the classmap below, the object will be of the  
15 - * given type. Requires PHP 5.0.3+  
16 - */  
17 -$WSStructures = array(  
18 - "contact" => "contact",  
19 - "address" => "address",  
20 -  
21 -);  
22 - 1 +<?php
  2 +
  3 +/* All the allowed webservice classes */
  4 +$WSClasses = array(
  5 + "contactManager",
  6 + "CMISService"
  7 +
  8 +);
  9 +
  10 +/* The classmap associative array. When you want to allow objects as a parameter for
  11 + * your webservice method. ie. saveObject($object). By default $object will now be
  12 + * a stdClass, but when you add a classname defined in the type description in the @param
  13 + * documentation tag and add your class to the classmap below, the object will be of the
  14 + * given type. Requires PHP 5.0.3+
  15 + */
  16 +$WSStructures = array(
  17 + "contact" => "contact",
  18 + "address" => "address",
  19 + "cmisRepositoryEntryType" => "cmisRepositoryEntryType",
  20 + "cmisRepositoryInfoType" => "cmisRepositoryInfoType",
  21 + "cmisRepositoryCapabilitiesType" => "cmisRepositoryCapabilitiesType",
  22 + "cmisTypeDefinitionType" => "cmisTypeDefinitionType",
  23 + "cmisPropertyDefinitionType" => "cmisPropertyDefinitionType",
  24 + "cmisObjectType" => "cmisObjectType",
  25 + "cmisPropertiesType" => "cmisPropertiesType",
  26 +);
  27 +
23 ?> 28 ?>
24 \ No newline at end of file 29 \ No newline at end of file
webservice/classes/soap/model/CMISObjectPropertiesType.class.php 0 → 100644
  1 +<?php
  2 +
  3 +/**
  4 + * Contains basic data for a repository object
  5 + */
  6 +
  7 +// NOTE this implementation will probably change substantially once more of the CMIS
  8 +// functionality is in place
  9 +
  10 +class CMISObjectPropertiesType {
  11 + /** @var cmisPropertyCollectionType */
  12 + public $properties;
  13 +
  14 + /** @var cmisObjectType[] */
  15 + public $child;
  16 +}
  17 +
  18 +?>
0 \ No newline at end of file 19 \ No newline at end of file
webservice/classes/soap/model/CMISObjectType.class.php 0 → 100644
  1 +<?php
  2 +
  3 +/**
  4 + * Contains basic data for a repository object
  5 + */
  6 +
  7 +// NOTE this implementation will probably change substantially once more of the CMIS
  8 +// functionality is in place
  9 +
  10 +class CMISObjectType {
  11 + /** @var cmisPropertiesType */
  12 + public $properties;
  13 +
  14 + /** @var cmisObjectType[] */
  15 + public $child;
  16 +}
  17 +
  18 +?>
0 \ No newline at end of file 19 \ No newline at end of file
webservice/classes/soap/model/CMISPropertiesType.class.php 0 → 100644
  1 +<?php
  2 +
  3 +/**
  4 + * Contains property data for a repository object
  5 + */
  6 +
  7 +class CMISPropertiesType {
  8 + /** @var string */
  9 + public $objectId;
  10 +
  11 + /** @var string */
  12 + public $typeId;
  13 +
  14 + /** @var string */
  15 + public $name;
  16 +
  17 +// /** @var cmisProperty[] */
  18 +// public $property;
  19 +}
  20 +
  21 +?>
0 \ No newline at end of file 22 \ No newline at end of file
webservice/classes/soap/model/CMISProperty.class.php 0 → 100644
  1 +<?php
  2 +
  3 +/**
  4 + * Contains basic data for a repository
  5 + */
  6 +
  7 +class CMISProperty {
  8 + /** @var string */
  9 + public $name;
  10 +
  11 + /** @var string */
  12 + public $value;
  13 +}
  14 +
  15 +?>
0 \ No newline at end of file 16 \ No newline at end of file
webservice/classes/soap/model/CMISPropertyCollectionType.class.php 0 → 100644
  1 +<?php
  2 +
  3 +/**
  4 + * Contains property data for a repository object
  5 + *
  6 + * NOTE this is a temporary measure until we get properties implement properly from the webservices point of view;
  7 + * no time right now to take the riskj of breaking substantial amounts of functionality...
  8 + */
  9 +
  10 +class CMISPropertyCollectionType {
  11 + /** @var string */
  12 + public $objectId;
  13 +
  14 + /** @var string */
  15 + public $URI;
  16 +
  17 + /** @var string */
  18 + public $typeId;
  19 +
  20 + /** @var string */
  21 + public $createdBy;
  22 +
  23 + /** @var string */
  24 + public $creationDate;
  25 +
  26 + /** @var string */
  27 + public $lastModifiedBy;
  28 +
  29 + /** @var string */
  30 + public $lastModificationDate;
  31 +
  32 + /** @var string */
  33 + public $changeToken;
  34 +}
  35 +
  36 +?>
0 \ No newline at end of file 37 \ No newline at end of file
webservice/classes/soap/model/CMISPropertyDefinitionType.class.php 0 → 100644
  1 +<?php
  2 +
  3 +/**
  4 + * Contains property definitions for a repository
  5 + *
  6 + * Since we are not returning this at the moment, we'll worry about the definitions later
  7 + */
  8 +
  9 +class CMISRepositoryEntryType {
  10 +
  11 +}
  12 +
  13 +?>
0 \ No newline at end of file 14 \ No newline at end of file
webservice/classes/soap/model/CMISRepositoryCapabilitiesType.class.php 0 → 100644
  1 +<?php
  2 +
  3 +/**
  4 + * Contains information about capabilities of the selected repository
  5 + */
  6 +
  7 +class CMISRepositoryCapabilitiesType {
  8 + /** @var boolean */
  9 + public $capabilityMultifiling;
  10 +
  11 + /** @var boolean */
  12 + public $capabilityUnfiling;
  13 +
  14 + /** @var boolean */
  15 + public $capabilityVersionSpecificFiling;
  16 +
  17 + /** @var boolean */
  18 + public $capabilityPWCUpdateable;
  19 +
  20 + /** @var boolean */
  21 + public $capabilityPWCSearchable;
  22 +
  23 + /** @var boolean */
  24 + public $capabilityAllVersionsSearchable;
  25 +
  26 + /** @var string */
  27 + public $capabilityQuery;
  28 +
  29 + /** @var string */
  30 + public $capabilityJoin;
  31 +
  32 + /** @var string */
  33 + public $capabilityFullText;
  34 +}
  35 +
  36 +?>
0 \ No newline at end of file 37 \ No newline at end of file
webservice/classes/soap/model/CMISRepositoryEntryType.class.php 0 → 100644
  1 +<?php
  2 +
  3 +/**
  4 + * Contains basic data for a repository
  5 + */
  6 +
  7 +class CMISRepositoryEntryType {
  8 + /** @var string */
  9 + public $repositoryId;
  10 +
  11 + /** @var string */
  12 + public $repositoryName;
  13 +
  14 + /** @var string */
  15 + public $repositoryURI;
  16 +}
  17 +
  18 +?>
0 \ No newline at end of file 19 \ No newline at end of file
webservice/classes/soap/model/CMISRepositoryInfoType.class.php 0 → 100644
  1 +<?php
  2 +
  3 +/**
  4 + * Contains information about the selected repository
  5 + */
  6 +
  7 +class CMISRepositoryInfoType {
  8 + /** @var string */
  9 + public $repositoryId;
  10 +
  11 + /** @var string */
  12 + public $repositoryName;
  13 +
  14 + /** @var string */
  15 + public $repositoryRelationship;
  16 +
  17 + /** @var string */
  18 + public $repositoryDescription;
  19 +
  20 + /** @var string */
  21 + public $vendorName;
  22 +
  23 + /** @var string */
  24 + public $productName;
  25 +
  26 + /** @var string */
  27 + public $productVersion;
  28 +
  29 + /** @var string */
  30 + public $rootFolderId;
  31 +
  32 + /** @var cmisRepositoryCapabilitiesType */
  33 + public $capabilities;
  34 +
  35 + /** @var string */
  36 + public $cmisVersionsSupported;
  37 +
  38 + /** @var string */
  39 + public $repositorySpecificInformation;
  40 +}
  41 +
  42 +?>
0 \ No newline at end of file 43 \ No newline at end of file
webservice/classes/soap/model/CMISService.class.php 0 → 100644
  1 +<?php
  2 +
  3 +require_once(realpath(dirname(__FILE__)) . '/../../../../ktcmis/ktcmis.inc.php');
  4 +
  5 +/**
  6 + * CMIS Service class which hooks into the KnowledgeTree interface
  7 + * for processing of CMIS queries and responses via webservices
  8 + */
  9 +
  10 +class CMISService extends KTCMIS {
  11 +
  12 + /**
  13 + * Fetches a list of available repositories
  14 + *
  15 + * @return cmisRepositoryEntryType[]
  16 + */
  17 + function getRepositories()
  18 + {
  19 + $result = parent::getRepositories();
  20 +
  21 + if ($result['status_code'] == 0)
  22 + {
  23 + return $result['results'];
  24 + }
  25 + }
  26 +
  27 + /**
  28 + * Fetches information about the selected repository
  29 + *
  30 + * @param string $repositoryId
  31 + * @return cmisRepositoryInfoType
  32 + */
  33 + function getRepositoryInfo($repositoryId)
  34 + {
  35 + $result = parent::getRepositoryInfo($repositoryId);
  36 +
  37 + if ($result['status_code'] == 0)
  38 + {
  39 + return $result['results'];
  40 + }
  41 + }
  42 +
  43 + /**
  44 + * Fetch the list of supported object types for the selected repository
  45 + *
  46 + * @param string $repositoryId The ID of the repository for which object types must be returned
  47 + * @param string $typeId The type to return, ALL if not set
  48 + * @param boolean $returnPropertyDefinitions Return property definitions as well if TRUE
  49 + * @param int $maxItems The maximum number of items to return
  50 + * @param int $skipCount The number of items to skip before starting to return results
  51 + * @param boolean $hasMoreItems TRUE if there are more items to return than were requested
  52 + * @return cmisTypeDefinitionType[]
  53 + */
  54 + function getTypes($repositoryId, $typeId = '', $returnPropertyDefinitions = false,
  55 + $maxItems = 0, $skipCount = 0, &$hasMoreItems = false)
  56 + {
  57 + $result = parent::getTypes($repositoryId, $typeId, $returnPropertyDefinitions,
  58 + $maxItems, $skipCount, $hasMoreItems);
  59 +
  60 + if ($result['status_code'] == 0)
  61 + {
  62 + return $result['results'];
  63 + }
  64 + }
  65 +
  66 + /**
  67 + * Fetch the object type definition for the requested type
  68 + *
  69 + * @param string $repositoryId
  70 + * @param string $typeId
  71 + * @return cmisTypeDefinitionType
  72 + */
  73 + function getTypeDefinition($repositoryId, $typeId)
  74 + {
  75 + $result = parent::getTypeDefinition($repositoryId, $typeId);
  76 +
  77 + if ($result['status_code'] == 0)
  78 + {
  79 + return $result['results'];
  80 + }
  81 + }
  82 +
  83 + // Navigation service functions
  84 +
  85 + /**
  86 + * Get descendents of the specified folder, up to the depth indicated
  87 + *
  88 + * @param string $repositoryId
  89 + * @param string $folderId
  90 + * @param boolean $includeAllowableActions
  91 + * @param boolean $includeRelationships
  92 + * @param string $typeID
  93 + * @param int $depth
  94 + * @param string $filter
  95 + * @return cmisObjectType[]
  96 + */
  97 + function getDescendants($repositoryId, $folderId, $includeAllowableActions, $includeRelationships,
  98 + $depth = 1, $typeID = 'Any', $filter = '')
  99 + {
  100 + $result = parent::getDescendants($repositoryId, $folderId, $includeAllowableActions,
  101 + $includeRelationships, $depth, $typeID, $filter);
  102 +
  103 + if ($result['status_code'] == 0)
  104 + {
  105 + return $result['results'];
  106 + }
  107 + }
  108 +
  109 + /**
  110 + * Get direct children of the specified folder
  111 + *
  112 + * @param string $repositoryId
  113 + * @param string $folderId
  114 + * @param boolean $includeAllowableActions
  115 + * @param boolean $includeRelationships
  116 + * @param string $typeID
  117 + * @param string $filter
  118 + * @param int $maxItems
  119 + * @param int $skipCount
  120 + * @return cmisObjectType[]
  121 + */
  122 + function getChildren($repositoryId, $folderId, $includeAllowableActions, $includeRelationships,
  123 + $typeID = 'Any', $filter = '', $maxItems = 0, $skipCount = 0)
  124 + {
  125 + $result = parent::getChildren($repositoryId, $folderId, $includeAllowableActions, $includeRelationships,
  126 + $typeID, $filter, $maxItems, $skipCount);
  127 +
  128 + if ($result['status_code'] == 0)
  129 + {
  130 + return $result['results'];
  131 + }
  132 + }
  133 +
  134 + /**
  135 + * Gets the parent of the selected folder
  136 + *
  137 + * @param string $repositoryId
  138 + * @param string $folderId
  139 + * @param boolean $includeAllowableActions
  140 + * @param boolean $includeRelationships
  141 + * @param boolean $returnToRoot
  142 + * @param string $filter
  143 + * @return cmisObjectType[]
  144 + */
  145 + function getFolderParent($repositoryId, $folderId, $includeAllowableActions, $includeRelationships, $returnToRoot, $filter = '')
  146 + {
  147 + $result = parent::getFolderParent($repositoryId, $folderId, $includeAllowableActions, $includeRelationships, $returnToRoot, $filter);
  148 +
  149 + if ($result['status_code'] == 0)
  150 + {
  151 + return $result['results'];
  152 + }
  153 + }
  154 +
  155 + /**
  156 + * Gets the parents for the selected object
  157 + *
  158 + * @param string $repositoryId
  159 + * @param string $folderId
  160 + * @param boolean $includeAllowableActions
  161 + * @param boolean $includeRelationships
  162 + * @param string $filter
  163 + * @return cmisObjectType[]
  164 + */
  165 + function getObjectParents($repositoryId, $objectId, $includeAllowableActions, $includeRelationships, $filter = '')
  166 + {
  167 + $result = parent::getObjectParents($repositoryId, $objectId, $includeAllowableActions, $includeRelationships, $filter);
  168 +
  169 + if ($result['status_code'] == 0)
  170 + {
  171 + return $result['results'];
  172 + }
  173 + }
  174 +
  175 + /**
  176 + * Gets the properties for the selected object
  177 + *
  178 + * @param string $repositoryId
  179 + * @param string $objectId
  180 + * @param boolean $includeAllowableActions
  181 + * @param boolean $includeRelationships
  182 + * @param string $returnVersion
  183 + * @param string $filter
  184 + * @return cmisObjectPropertiesType[]
  185 + */
  186 + function getProperties($repositoryId, $objectId, $includeAllowableActions, $includeRelationships,
  187 + $returnVersion = false, $filter = '')
  188 + {
  189 + $result = parent::getProperties($repositoryId, $objectId, $includeAllowableActions, $includeRelationships, $returnVersion, $filter);
  190 +
  191 + if ($result['status_code'] == 0)
  192 + {
  193 + return $result['results'];
  194 + }
  195 + }
  196 +}
  197 +
  198 +?>
webservice/classes/soap/model/CMISTypeDefinitionType.class.php 0 → 100644
  1 +<?php
  2 +
  3 +/**
  4 + * Contains type definitions for a repository
  5 + */
  6 +
  7 +class CMISTypeDefinitionType {
  8 + /** @var string */
  9 + public $typeId;
  10 +
  11 + /** @var string */
  12 + public $queryName;
  13 +
  14 + /** @var string */
  15 + public $displayName;
  16 +
  17 + /** @var string */
  18 + public $baseType;
  19 +
  20 + /** @var string */
  21 + public $baseTypeQueryName;
  22 +
  23 + /** @var string */
  24 + public $parentId;
  25 +
  26 + /** @var string */
  27 + public $description;
  28 +
  29 + /** @var boolean */
  30 + public $creatable;
  31 +
  32 + /** @var boolean */
  33 + public $fileable;
  34 +
  35 + /** @var boolean */
  36 + public $queryable;
  37 +
  38 + /** @var boolean */
  39 + public $controllable;
  40 +
  41 + /** @var boolean */
  42 + public $includedInSupertypeQuery;
  43 +
  44 + // worry about property definitions later...
  45 +// /** @var cmisPropertyDefinitionType */
  46 +// public $propertyDefinition;
  47 +
  48 +}
  49 +
  50 +?>
0 \ No newline at end of file 51 \ No newline at end of file
webservice/tests/webservice.php
1 -<?php  
2 -$wsdl = "http://".$_SERVER['HTTP_HOST']."/webservice/service.php?class=contactManager&wsdl";  
3 -echo "<strong>WSDL file:</strong> ".$wsdl."<br>\n";  
4 -  
5 -$options = Array('actor' =>'http://www.knowledgetree.pr',  
6 - 'trace' => true);  
7 -$client = new SoapClient($wsdl,$options);  
8 -  
9 -echo "<hr> <strong>Result from getContacts call:</strong><br>";  
10 -  
11 -$res = $client->getContacts();  
12 -print_r($res);  
13 -echo "<hr><strong>Raw Soap response:</strong><br>";  
14 -echo htmlentities($client->__getLastResponse());  
15 -echo "<hr><strong>SoapFault asking for an unknown contact:</strong><br>";  
16 -$client->newContact(); 1 +<?php
  2 +$wsdl = "http://".$_SERVER['HTTP_HOST']."/webservice/webservice.php?class=CMISService&wsdl";
  3 +echo "<strong>WSDL file:</strong> ".$wsdl."<br>\n";
  4 +
  5 +$options = Array('actor' =>'http://127.0.0.1',
  6 + 'trace' => true);
  7 +$client = new SoapClient($wsdl,$options);
  8 +
  9 +
  10 +
  11 +echo "<hr> <strong>Result from getrepositories call:</strong><br>";
  12 +$res = $client->getRepositories();
  13 +print_r($res);
  14 +echo "<hr><strong>Raw Soap response:</strong><br>";
  15 +echo htmlentities($client->__getLastResponse());
  16 +
  17 +echo "<hr> <strong>Result from getrepositoryinfo call:</strong><br>";
  18 +
  19 +$res = $client->getRepositoryInfo('1');
  20 +print_r($res);
  21 +echo "<hr><strong>Raw Soap response:</strong><br>";
  22 +echo htmlentities($client->__getLastResponse());
  23 +
  24 +echo "<hr> <strong>Result from gettypes call:</strong><br>";
  25 +
  26 +$res = $client->getTypes('1');
  27 +print_r($res);
  28 +echo "<hr><strong>Raw Soap response:</strong><br>";
  29 +echo htmlentities($client->__getLastResponse());
  30 +
  31 +echo "<hr> <strong>Result from gettypedefinition (document) call:</strong><br>";
  32 +
  33 +$res = $client->getTypeDefinition('1', 'Document');
  34 +print_r($res);
  35 +echo "<hr><strong>Raw Soap response:</strong><br>";
  36 +echo htmlentities($client->__getLastResponse());
  37 +
  38 +echo "<hr> <strong>Result from gettypedefinition (folder) call:</strong><br>";
  39 +
  40 +$res = $client->getTypeDefinition('1', 'Folder');
  41 +print_r($res);
  42 +echo "<hr><strong>Raw Soap response:</strong><br>";
  43 +echo htmlentities($client->__getLastResponse());
  44 +
  45 +/*
  46 +
  47 +echo "<hr> <strong>Result from getdescendants call:</strong><br>";
  48 +
  49 +$res = $client->getDescendants('1', 'F1', false, false, 3);
  50 +print_r($res);
  51 +echo "<hr><strong>Raw Soap response:</strong><br>";
  52 +echo htmlentities($client->__getLastResponse());
  53 +
  54 +echo "<hr> <strong>Result from getchildren call:</strong><br>";
  55 +
  56 +$res = $client->getChildren('1', 'F1', false, false);
  57 +print_r($res);
  58 +echo "<hr><strong>Raw Soap response:</strong><br>";
  59 +echo htmlentities($client->__getLastResponse());
  60 +// *
  61 +// */
  62 +
  63 +/*
  64 +echo "<hr> <strong>Result from getfolderparent call:</strong><br>";
  65 +
  66 +$res = $client->getFolderParent('1', 'F566', false, false, false);
  67 +print_r($res);
  68 +echo "<hr><strong>Raw Soap response:</strong><br>";
  69 +echo htmlentities($client->__getLastResponse());
  70 +
  71 +//echo "<hr><strong>Result from getobjectparents call:</strong><br>";
  72 +//
  73 +//$res = $client->getObjectParents('1', 'F566', false, false);
  74 +//print_r($res);
  75 +//echo "<hr><strong>Raw Soap response:</strong><br>";
  76 +//echo htmlentities($client->__getLastResponse());
  77 +
  78 +echo "<hr><strong>Result from getobjectparents call:</strong><br>";
  79 +
  80 +$res = $client->getProperties('1', 'F566', false, false);
  81 +print_r($res);
  82 +echo "<hr><strong>Raw Soap response:</strong><br>";
  83 +echo htmlentities($client->__getLastResponse());
  84 +*/
  85 +// TODO add test of returnToRoot? would need known existing folder other than DroppedDocuments (F566)
  86 +
17 ?> 87 ?>
18 \ No newline at end of file 88 \ No newline at end of file