This project has retired. For details please refer to its
Attic page.
AtomLinkInfoProvider 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.inmemory.server;
20
21 import java.util.List;
22
23 import org.apache.chemistry.opencmis.commons.data.ObjectData;
24 import org.apache.chemistry.opencmis.commons.data.ObjectInFolderContainer;
25 import org.apache.chemistry.opencmis.commons.data.ObjectInFolderData;
26 import org.apache.chemistry.opencmis.commons.data.ObjectInFolderList;
27 import org.apache.chemistry.opencmis.commons.data.ObjectList;
28 import org.apache.chemistry.opencmis.commons.data.ObjectParentData;
29 import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
30 import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
31 import org.apache.chemistry.opencmis.commons.impl.server.ObjectInfoImpl;
32 import org.apache.chemistry.opencmis.commons.server.ObjectInfoHandler;
33 import org.apache.chemistry.opencmis.inmemory.storedobj.api.Content;
34 import org.apache.chemistry.opencmis.inmemory.storedobj.api.DocumentVersion;
35 import org.apache.chemistry.opencmis.inmemory.storedobj.api.Filing;
36 import org.apache.chemistry.opencmis.inmemory.storedobj.api.ObjectStore;
37 import org.apache.chemistry.opencmis.inmemory.storedobj.api.StoreManager;
38 import org.apache.chemistry.opencmis.inmemory.storedobj.api.StoredObject;
39 import org.apache.chemistry.opencmis.inmemory.storedobj.api.VersionedDocument;
40 import org.apache.chemistry.opencmis.inmemory.types.PropertyCreationHelper;
41
42
43
44
45
46
47
48
49
50 public class AtomLinkInfoProvider {
51
52 private final StoreManager fStoreManager;
53
54 public AtomLinkInfoProvider(StoreManager storeManager) {
55 fStoreManager = storeManager;
56 }
57
58
59
60
61
62
63
64
65
66
67
68
69 public void fillInformationForAtomLinks(String repositoryId, StoredObject so, ObjectData od, ObjectInfoImpl objInfo) {
70 if (null == objInfo || null == so) {
71 return;
72 }
73 TypeDefinition typeDef = fStoreManager.getTypeById(repositoryId, so.getTypeId()).getTypeDefinition();
74
75
76 objInfo.setId(so.getId());
77 objInfo.setName(so.getName());
78 objInfo.setCreatedBy(so.getCreatedBy());
79 objInfo.setCreationDate(so.getCreatedAt());
80 objInfo.setLastModificationDate(so.getModifiedAt());
81 objInfo.setTypeId(so.getTypeId());
82 objInfo.setBaseType(typeDef.getBaseTypeId());
83 objInfo.setObject(od);
84
85
86 if (so instanceof DocumentVersion) {
87 DocumentVersion ver = (DocumentVersion) so;
88 DocumentVersion pwc = ver.getParentDocument().getPwc();
89 objInfo.setIsCurrentVersion(ver == ver.getParentDocument().getLatestVersion(false));
90 objInfo.setVersionSeriesId(ver.getParentDocument().getId());
91 objInfo.setWorkingCopyId(pwc == null ? null : pwc.getId());
92 objInfo.setWorkingCopyOriginalId(pwc == ver ? ver.getParentDocument().getLatestVersion(false).getId()
93 : null);
94 } else if (so instanceof VersionedDocument) {
95 VersionedDocument doc = (VersionedDocument) so;
96 DocumentVersion pwc = doc.getPwc();
97 objInfo.setIsCurrentVersion(false);
98 objInfo.setVersionSeriesId(doc.getId());
99 objInfo.setWorkingCopyId(pwc == null ? null : pwc.getId());
100 objInfo.setWorkingCopyOriginalId(null);
101 } else {
102 objInfo.setIsCurrentVersion(true);
103 objInfo.setVersionSeriesId(null);
104 objInfo.setWorkingCopyId(null);
105 objInfo.setWorkingCopyOriginalId(null);
106 }
107
108 if (so instanceof Content) {
109 Content cont = ((Content) so);
110 objInfo.setHasContent(cont.getContent(0, -1) != null);
111 objInfo.setContentType(cont.getContent(0, -1) != null ? cont.getContent(0, -1).getMimeType() : null);
112 objInfo.setFileName(cont.getContent(0, -1) != null ? cont.getContent(0, -1).getFileName() : null);
113 } else {
114 objInfo.setHasContent(false);
115 objInfo.setContentType(null);
116 objInfo.setFileName(null);
117 }
118
119
120 if (so instanceof Filing) {
121 Filing sop = ((Filing) so);
122 objInfo.setHasParent(sop.hasParent());
123 } else {
124 objInfo.setHasParent(false);
125 }
126
127
128 objInfo.setRenditionInfos(null);
129
130
131 objInfo.setSupportsRelationships(false);
132 objInfo.setRelationshipSourceIds(null);
133 objInfo.setRelationshipTargetIds(null);
134
135
136 objInfo.setSupportsPolicies(false);
137
138
139 objInfo.setHasAcl(true);
140
141 objInfo.setSupportsDescendants(true);
142 objInfo.setSupportsFolderTree(true);
143
144 }
145
146 public void fillInformationForAtomLinks(String repositoryId, StoredObject so, ObjectInfoImpl objectInfo) {
147 TypeDefinition td = fStoreManager.getTypeById(repositoryId, so.getTypeId()).getTypeDefinition();
148 ObjectData od = PropertyCreationHelper.getObjectData(td, so, null, null, false,
149 IncludeRelationships.NONE, null, false, false, null);
150 fillInformationForAtomLinks(repositoryId, so, od, objectInfo);
151 }
152
153
154
155
156
157
158
159
160
161
162
163
164 public void fillInformationForAtomLinks(String repositoryId, String objectId, ObjectInfoImpl objectInfo) {
165 if (null == objectInfo || null == objectId) {
166 return;
167 }
168
169 ObjectStore objectStore = fStoreManager.getObjectStore(repositoryId);
170 StoredObject so = objectStore.getObjectById(objectId);
171 fillInformationForAtomLinks(repositoryId, so, objectInfo);
172 }
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188 public void fillInformationForAtomLinks(String repositoryId, String objectId, ObjectInfoHandler objectInfos,
189 ObjectInFolderList objList) {
190
191 if (null == objectInfos || null == objList || null == objectId) {
192 return;
193 }
194
195
196
197 ObjectInfoImpl objectInfo = new ObjectInfoImpl();
198 fillInformationForAtomLinks(repositoryId, objectId, objectInfo);
199 objectInfos.addObjectInfo(objectInfo);
200
201
202 for (ObjectInFolderData object : objList.getObjects()) {
203 objectInfo = new ObjectInfoImpl();
204 fillInformationForAtomLinks(repositoryId, object.getObject().getId(), objectInfo);
205 objectInfos.addObjectInfo(objectInfo);
206 }
207 }
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222 public void fillInformationForAtomLinks(String repositoryId, String objectId, ObjectInfoHandler objectInfos,
223 ObjectList objList) {
224
225 ObjectInfoImpl objectInfo = new ObjectInfoImpl();
226 if (null != objectId) {
227
228 fillInformationForAtomLinks(repositoryId, objectId, objectInfo);
229 objectInfos.addObjectInfo(objectInfo);
230 }
231
232 if (null != objList && null != objList.getObjects()) {
233
234 List<ObjectData> listObjects = objList.getObjects();
235 if (null != listObjects) {
236 for (ObjectData object : listObjects) {
237 objectInfo = new ObjectInfoImpl();
238 fillInformationForAtomLinks(repositoryId, object.getId(), objectInfo);
239 objectInfos.addObjectInfo(objectInfo);
240 }
241 }
242 }
243
244 }
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259 private void fillInformationForAtomLinks(String repositoryId, ObjectInfoHandler objectInfos,
260 ObjectInFolderContainer oifc) {
261
262 if (null == objectInfos || null == oifc) {
263 return;
264 }
265
266
267 fillInformationForAtomLinks(repositoryId, objectInfos, oifc.getObject());
268
269 if (null != oifc.getChildren()) {
270 for (ObjectInFolderContainer object : oifc.getChildren()) {
271
272 ObjectInfoImpl objectInfo = new ObjectInfoImpl();
273 fillInformationForAtomLinks(repositoryId, objectInfos, object);
274 objectInfos.addObjectInfo(objectInfo);
275 }
276 }
277 }
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292 public void fillInformationForAtomLinks(String repositoryId, String objectId, ObjectInfoHandler objectInfos,
293 List<ObjectInFolderContainer> oifcList) {
294
295 if (null == objectInfos || null == oifcList || null == objectId) {
296 return;
297 }
298
299 ObjectInfoImpl objectInfo = new ObjectInfoImpl();
300
301 fillInformationForAtomLinks(repositoryId, objectId, objectInfo);
302 objectInfos.addObjectInfo(objectInfo);
303
304 for (ObjectInFolderContainer object : oifcList) {
305 fillInformationForAtomLinks(repositoryId, objectInfos, object);
306 }
307 }
308
309 private void fillInformationForAtomLinks(String repositoryId, ObjectInfoHandler objectInfos,
310 ObjectInFolderData object) {
311
312 ObjectInfoImpl objectInfo = new ObjectInfoImpl();
313 fillInformationForAtomLinks(repositoryId, object.getObject().getId(), objectInfo);
314 objectInfos.addObjectInfo(objectInfo);
315 }
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330 public void fillInformationForAtomLinksGetParents(String repositoryId, String objectId,
331 ObjectInfoHandler objectInfos, List<ObjectParentData> objParents) {
332
333 if (null == objectInfos || null == objParents || null == objectId) {
334 return;
335 }
336
337
338 ObjectInfoImpl objectInfo = new ObjectInfoImpl();
339 fillInformationForAtomLinks(repositoryId, objectId, objectInfo);
340
341 for (ObjectParentData object : objParents) {
342 objectInfo = new ObjectInfoImpl();
343 fillInformationForAtomLinks(repositoryId, object.getObject().getId(), objectInfo);
344 objectInfos.addObjectInfo(objectInfo);
345 }
346 }
347
348 }