servicedocument.inc.php
2.38 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
<?php
/**
* Creates the CMIS AtomPub service document
*
* NOTE Includes the results of a repositoryInfo call as well as service links
*/
// NOTE currently we only support one repository, which will be the first one found in the repositories.xml config
// TODO multiple repositories as individual workspaces
include 'services/cmis/RepositoryService.inc.php';
$RepositoryService = new RepositoryService();
// fetch data for response
$repositories = $RepositoryService->getRepositories();
// fetch for default first repo; NOTE that this will probably have to change at some point, quick and dirty for now
$repositoryInfo = $RepositoryService->getRepositoryInfo($repositories[0]['repositoryId']);
// generate service document
$service = new KTCMISAPPServiceDoc(KT_APP_BASE_URI);
$ws = $service->newWorkspace($repositoryInfo['repositoryName']);
$ws->appendChild($service->newAttr('cmis:repositoryRelationship', $repositoryInfo['repositoryRelationship']));
// repository information
$element = $service->newElement('cmis:repositoryInfo');
foreach($repositoryInfo as $key => $repoData)
{
if ($key == 'rootFolderId')
{
$repoData = CMIS_BASE_URI . 'folder/' . $repoData;
}
if (!is_array($repoData))
{
$element->appendChild($service->newElement('cmis:' . $key, $repoData));
}
else
{
$elementSub = $service->newElement('cmis:' . $key);
foreach($repoData as $key2 => $data)
{
$elementSub->appendChild($service->newElement('cmis:' . $key2, CMISUtil::boolToString($data)));
}
$element->appendChild($elementSub);
}
}
$ws->appendChild($element);
// collection links
$col = $service->newCollection(CMIS_BASE_URI . 'folder/' . $repositoryInfo['rootFolderId'] . '/children',
'Root Folder Children Collection', 'root-children', $ws);
$col = $service->newCollection(CMIS_BASE_URI . 'folder/' . $repositoryInfo['rootFolderId'] . '/descendants',
'Root Folder Descendant Collection', 'root-descendants', $ws);
$col = $service->newCollection(CMIS_BASE_URI . 'checkedout', 'Checked Out Document Collection', 'checkedout', $ws);
$col = $service->newCollection(CMIS_BASE_URI . 'types', 'Object Type Collection', 'types-children', $ws);
$col = $service->newCollection(CMIS_BASE_URI . 'types', 'Object Type Collection', 'types-descendants', $ws);
$output = $service->getAPPdoc();
?>