ObjectService.inc.php
5.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<?php
require_once KT_LIB_DIR . '/api/ktcmis/ktcmis.inc.php';
/**
* CMIS Service class which hooks into the KnowledgeTree interface
* for processing of CMIS queries and responses via atompub/webservices
*/
class ObjectService extends KTObjectService {
/**
* Fetches the properties for the specified object
*
* @param string $repositoryId
* @param string $objectId
* @param boolean $includeAllowableActions
* @param boolean $includeRelationships
* @param boolean $returnVersion
* @param string $filter
* @return object CMIS object properties
*/
public function getProperties($repositoryId, $objectId, $includeAllowableActions, $includeRelationships,
$returnVersion = false, $filter = '')
{
$result = parent::getProperties($repositoryId, $objectId, $includeAllowableActions,
$returnVersion, $filter);
if ($result['status_code'] == 0) {
return $result['results'];
}
}
/**
* Creates a new folder within the repository
*
* @param string $repositoryId The repository to which the folder must be added
* @param string $typeId Object Type id for the folder object being created
* @param array $properties Array of properties which must be applied to the created folder object
* @param string $folderId The id of the folder which will be the parent of the created folder object
* @return string $objectId The id of the created folder object
*/
function createFolder($repositoryId, $typeId, $properties, $folderId)
{
$result = parent::createFolder($repositoryId, $typeId, $properties, $folderId);
if ($result['status_code'] == 0) {
return $result['results'];
}
else {
return $result;
}
}
/**
* Creates a new document within the repository
*
* @param string $repositoryId The repository to which the document must be added
* @param string $typeId Object Type id for the document object being created
* @param array $properties Array of properties which must be applied to the created document object
* @param string $folderId The id of the folder which will be the parent of the created document object
* This parameter is optional IF unfilingCapability is supported
* @param contentStream $contentStream optional content stream data
* @param string $versioningState optional version state value: checkedout/major/minor
* @return string $objectId The id of the created folder object
*/
// TODO throw ConstraintViolationException if:
// value of any of the properties violates the min/max/required/length constraints
// specified in the property definition in the Object-Type.
function createDocument($repositoryId, $typeId, $properties, $folderId = null,
$contentStream = null, $versioningState = null)
{
$result = parent::createDocument($repositoryId, $typeId, $properties, $folderId, $contentStream, $versioningState);
if ($result['status_code'] == 0) {
return $result['results'];
}
else {
return $result;
}
}
/**
* Deletes an object from the repository
*
* @param string $repositoryId
* @param string $objectId
* @param string $changeToken [optional]
* @return boolean true on success, false on failure
*/
// NOTE Invoking this service method on an object SHALL not delete the entire version series for a Document Object.
// To delete an entire version series, use the deleteAllVersions() service
function deleteObject($repositoryId, $objectId, $changeToken = null)
{
$result = parent::deleteObject($repositoryId, $objectId, $changeToken);
if ($result['status_code'] == 0) {
return $result['results'];
}
else {
return new PEAR_Error($result['message']);
}
}
/**
* Deletes an entire tree including all subfolders and other filed objects
*
* @param string $repositoryId
* @param string $objectId
* @param string $changeToken [optional]
* @param boolean $unfileNonfolderObject [optional] - note that since KnowledgeTree does not allow unfiling this will be ignored
* @param boolean $continueOnFailure [optional] - note that since KnowledgeTree does not allow continue on failure this will be ignored
* @return array $failedToDelete A list of identifiers of objects in the folder tree that were not deleted.
*/
public function deleteTree($repositoryId, $objectId, $changeToken = null, $unfileNonfolderObject = 'delete', $continueOnFailure = false)
{
$result = parent::deleteTree($repositoryId, $objectId, $changeToken, $unfileNonfolderObject, $continueOnFailure);
if ($result['status_code'] == 0) {
return $result['results'];
}
else if (is_array($result['message'])) {
return $result['message'];
}
else {
return new PEAR_Error($result['message']);
}
}
}
?>