This project has retired. For details please refer to its
Attic page.
RepositoryServiceImpl xref
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.chemistry.opencmis.client.bindings.spi.browser;
20
21 import java.math.BigInteger;
22 import java.util.List;
23 import java.util.Map;
24
25 import org.apache.chemistry.opencmis.client.bindings.spi.BindingSession;
26 import org.apache.chemistry.opencmis.client.bindings.spi.http.HttpUtils;
27 import org.apache.chemistry.opencmis.commons.data.ExtensionsData;
28 import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
29 import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
30 import org.apache.chemistry.opencmis.commons.definitions.TypeDefinitionContainer;
31 import org.apache.chemistry.opencmis.commons.definitions.TypeDefinitionList;
32 import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
33 import org.apache.chemistry.opencmis.commons.impl.Constants;
34 import org.apache.chemistry.opencmis.commons.impl.JSONConverter;
35 import org.apache.chemistry.opencmis.commons.impl.UrlBuilder;
36 import org.apache.chemistry.opencmis.commons.spi.RepositoryService;
37
38
39
40
41 public class RepositoryServiceImpl extends AbstractBrowserBindingService implements RepositoryService {
42
43
44
45
46 public RepositoryServiceImpl(BindingSession session) {
47 setSession(session);
48 }
49
50 public List<RepositoryInfo> getRepositoryInfos(ExtensionsData extension) {
51 return getRepositoriesInternal(null);
52 }
53
54 public RepositoryInfo getRepositoryInfo(String repositoryId, ExtensionsData extension) {
55 List<RepositoryInfo> repositoryInfos = getRepositoriesInternal(repositoryId);
56
57
58 for (RepositoryInfo info : repositoryInfos) {
59 if (info.getId() == null) {
60 continue;
61 }
62
63 if (info.getId().equals(repositoryId)) {
64 return info;
65 }
66 }
67
68 throw new CmisObjectNotFoundException("Repository not found!");
69 }
70
71 public TypeDefinition getTypeDefinition(String repositoryId, String typeId, ExtensionsData extension) {
72 return getTypeDefinitionInternal(repositoryId, typeId);
73 }
74
75 public TypeDefinitionList getTypeChildren(String repositoryId, String typeId, Boolean includePropertyDefinitions,
76 BigInteger maxItems, BigInteger skipCount, ExtensionsData extension) {
77
78 UrlBuilder url = getRepositoryUrl(repositoryId, Constants.SELECTOR_TYPE_CHILDREN);
79 url.addParameter(Constants.PARAM_TYPE_ID, typeId);
80 url.addParameter(Constants.PARAM_PROPERTY_DEFINITIONS, includePropertyDefinitions);
81 url.addParameter(Constants.PARAM_MAX_ITEMS, maxItems);
82 url.addParameter(Constants.PARAM_SKIP_COUNT, skipCount);
83
84
85 HttpUtils.Response resp = read(url);
86 Map<String, Object> json = parseObject(resp.getStream(), resp.getCharset());
87
88 return JSONConverter.convertTypeChildren(json);
89 }
90
91 public List<TypeDefinitionContainer> getTypeDescendants(String repositoryId, String typeId, BigInteger depth,
92 Boolean includePropertyDefinitions, ExtensionsData extension) {
93
94 UrlBuilder url = getRepositoryUrl(repositoryId, Constants.SELECTOR_TYPE_DESCENDANTS);
95 url.addParameter(Constants.PARAM_TYPE_ID, typeId);
96 url.addParameter(Constants.PARAM_DEPTH, depth);
97 url.addParameter(Constants.PARAM_PROPERTY_DEFINITIONS, includePropertyDefinitions);
98
99
100 HttpUtils.Response resp = read(url);
101 List<Object> json = parseArray(resp.getStream(), resp.getCharset());
102
103 return JSONConverter.convertTypeDescendants(json);
104 }
105 }