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
20 package org.apache.chemistry.opencmis.client.bindings.impl;
21
22 import java.io.Serializable;
23 import java.math.BigInteger;
24 import java.util.List;
25
26 import org.apache.chemistry.opencmis.client.bindings.spi.CmisSpi;
27 import org.apache.chemistry.opencmis.client.bindings.spi.BindingSession;
28 import org.apache.chemistry.opencmis.commons.data.ExtensionsData;
29 import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
30 import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
31 import org.apache.chemistry.opencmis.commons.definitions.TypeDefinitionContainer;
32 import org.apache.chemistry.opencmis.commons.definitions.TypeDefinitionList;
33 import org.apache.chemistry.opencmis.commons.spi.RepositoryService;
34
35
36
37
38
39
40 public class RepositoryServiceImpl implements RepositoryService, Serializable {
41
42 private static final long serialVersionUID = 1L;
43
44 private final BindingSession session;
45
46
47
48
49 public RepositoryServiceImpl(BindingSession session) {
50 this.session = session;
51 }
52
53 public RepositoryInfo getRepositoryInfo(String repositoryId, ExtensionsData extension) {
54 RepositoryInfo result = null;
55 boolean hasExtension = (extension != null) && (!extension.getExtensions().isEmpty());
56
57 RepositoryInfoCache cache = CmisBindingsHelper.getRepositoryInfoCache(session);
58
59
60 if (!hasExtension) {
61 result = cache.get(repositoryId);
62 if (result != null) {
63 return result;
64 }
65 }
66
67
68 CmisSpi spi = CmisBindingsHelper.getSPI(session);
69 result = spi.getRepositoryService().getRepositoryInfo(repositoryId, extension);
70
71
72 if (!hasExtension) {
73 cache.put(result);
74 }
75
76 return result;
77 }
78
79 public List<RepositoryInfo> getRepositoryInfos(ExtensionsData extension) {
80 List<RepositoryInfo> result = null;
81 boolean hasExtension = (extension != null) && (!extension.getExtensions().isEmpty());
82
83
84 CmisSpi spi = CmisBindingsHelper.getSPI(session);
85 result = spi.getRepositoryService().getRepositoryInfos(extension);
86
87
88 if (!hasExtension && (result != null)) {
89 RepositoryInfoCache cache = CmisBindingsHelper.getRepositoryInfoCache(session);
90 for (RepositoryInfo rid : result) {
91 cache.put(rid);
92 }
93 }
94
95 return result;
96 }
97
98 public TypeDefinitionList getTypeChildren(String repositoryId, String typeId, Boolean includePropertyDefinitions,
99 BigInteger maxItems, BigInteger skipCount, ExtensionsData extension) {
100 TypeDefinitionList result = null;
101 boolean hasExtension = (extension != null) && (!extension.getExtensions().isEmpty());
102 boolean propDefs = (includePropertyDefinitions == null ? false : includePropertyDefinitions.booleanValue());
103
104
105 CmisSpi spi = CmisBindingsHelper.getSPI(session);
106 result = spi.getRepositoryService().getTypeChildren(repositoryId, typeId, includePropertyDefinitions, maxItems,
107 skipCount, extension);
108
109
110 if (!hasExtension && propDefs && (result != null)) {
111 TypeDefinitionCache cache = CmisBindingsHelper.getTypeDefinitionCache(session);
112
113 for (TypeDefinition tdd : result.getList()) {
114 cache.put(repositoryId, tdd);
115 }
116 }
117
118 return result;
119 }
120
121 public TypeDefinition getTypeDefinition(String repositoryId, String typeId, ExtensionsData extension) {
122 TypeDefinition result = null;
123 boolean hasExtension = (extension != null) && (!extension.getExtensions().isEmpty());
124
125 TypeDefinitionCache cache = CmisBindingsHelper.getTypeDefinitionCache(session);
126
127
128 if (!hasExtension) {
129 result = cache.get(repositoryId, typeId);
130 if (result != null) {
131 return result;
132 }
133 }
134
135
136 CmisSpi spi = CmisBindingsHelper.getSPI(session);
137 result = spi.getRepositoryService().getTypeDefinition(repositoryId, typeId, extension);
138
139
140 if (!hasExtension && (result != null)) {
141 cache.put(repositoryId, result);
142 }
143
144 return result;
145 }
146
147 public List<TypeDefinitionContainer> getTypeDescendants(String repositoryId, String typeId, BigInteger depth,
148 Boolean includePropertyDefinitions, ExtensionsData extension) {
149 List<TypeDefinitionContainer> result = null;
150 boolean hasExtension = (extension != null) && (!extension.getExtensions().isEmpty());
151 boolean propDefs = (includePropertyDefinitions == null ? false : includePropertyDefinitions.booleanValue());
152
153
154 CmisSpi spi = CmisBindingsHelper.getSPI(session);
155 result = spi.getRepositoryService().getTypeDescendants(repositoryId, typeId, depth, includePropertyDefinitions,
156 extension);
157
158
159 if (!hasExtension && propDefs && (result != null)) {
160 TypeDefinitionCache cache = CmisBindingsHelper.getTypeDefinitionCache(session);
161 addToTypeCache(cache, repositoryId, result);
162 }
163
164 return result;
165 }
166
167 private void addToTypeCache(TypeDefinitionCache cache, String repositoryId, List<TypeDefinitionContainer> containers) {
168 if (containers == null) {
169 return;
170 }
171
172 for (TypeDefinitionContainer container : containers) {
173 cache.put(repositoryId, container.getTypeDefinition());
174 addToTypeCache(cache, repositoryId, container.getChildren());
175 }
176 }
177 }