This project has retired. For details please refer to its
Attic page.
CmisServiceWrapper xref
1 package org.apache.chemistry.opencmis.server.support;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 import java.math.BigInteger;
25 import java.util.List;
26
27 import org.apache.chemistry.opencmis.commons.PropertyIds;
28 import org.apache.chemistry.opencmis.commons.data.Acl;
29 import org.apache.chemistry.opencmis.commons.data.AllowableActions;
30 import org.apache.chemistry.opencmis.commons.data.ContentStream;
31 import org.apache.chemistry.opencmis.commons.data.ExtensionsData;
32 import org.apache.chemistry.opencmis.commons.data.FailedToDeleteData;
33 import org.apache.chemistry.opencmis.commons.data.ObjectData;
34 import org.apache.chemistry.opencmis.commons.data.ObjectInFolderContainer;
35 import org.apache.chemistry.opencmis.commons.data.ObjectInFolderList;
36 import org.apache.chemistry.opencmis.commons.data.ObjectList;
37 import org.apache.chemistry.opencmis.commons.data.ObjectParentData;
38 import org.apache.chemistry.opencmis.commons.data.Properties;
39 import org.apache.chemistry.opencmis.commons.data.PropertyData;
40 import org.apache.chemistry.opencmis.commons.data.RenditionData;
41 import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
42 import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
43 import org.apache.chemistry.opencmis.commons.definitions.TypeDefinitionContainer;
44 import org.apache.chemistry.opencmis.commons.definitions.TypeDefinitionList;
45 import org.apache.chemistry.opencmis.commons.enums.AclPropagation;
46 import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
47 import org.apache.chemistry.opencmis.commons.enums.RelationshipDirection;
48 import org.apache.chemistry.opencmis.commons.enums.UnfileObject;
49 import org.apache.chemistry.opencmis.commons.enums.VersioningState;
50 import org.apache.chemistry.opencmis.commons.exceptions.CmisBaseException;
51 import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
52 import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
53 import org.apache.chemistry.opencmis.commons.server.CmisService;
54 import org.apache.chemistry.opencmis.commons.server.ObjectInfo;
55 import org.apache.chemistry.opencmis.commons.spi.Holder;
56 import org.apache.commons.logging.Log;
57 import org.apache.commons.logging.LogFactory;
58
59
60
61
62 public class CmisServiceWrapper<T extends CmisService> implements CmisService {
63
64 public static final BigInteger MINUS_ONE = BigInteger.valueOf(-1);
65
66 private static final Log log = LogFactory.getLog(CmisServiceWrapper.class);
67
68 private BigInteger defaultTypesMaxItems = null;
69 private BigInteger defaultTypesDepth = MINUS_ONE;
70
71 private BigInteger defaultMaxItems = null;
72 private BigInteger defaultDepth = MINUS_ONE;
73
74 private final T service;
75
76
77
78
79 public CmisServiceWrapper(T service, BigInteger defaultTypesMaxItems, BigInteger defaultTypesDepth,
80 BigInteger defaultMaxItems, BigInteger defaultDepth) {
81 if (service == null) {
82 throw new IllegalArgumentException("Service must be set!");
83 }
84
85 this.service = service;
86
87 setDefaultTypesMaxItems(defaultTypesMaxItems);
88 setDefaultTypesDepth(defaultTypesDepth);
89 setDefaultMaxItems(defaultMaxItems);
90 setDefaultDepth(defaultDepth);
91 }
92
93
94
95
96
97
98 protected void setDefaultTypesMaxItems(BigInteger defaultTypesMaxItems) {
99 this.defaultTypesMaxItems = defaultTypesMaxItems;
100 }
101
102
103
104
105 protected void setDefaultTypesDepth(BigInteger defaultTypesDepth) {
106 this.defaultTypesDepth = defaultTypesDepth;
107 }
108
109
110
111
112 protected void setDefaultMaxItems(BigInteger defaultMaxItems) {
113 this.defaultMaxItems = defaultMaxItems;
114 }
115
116
117
118
119 protected void setDefaultDepth(BigInteger defaultDepth) {
120 this.defaultDepth = defaultDepth;
121 }
122
123
124
125
126 protected CmisBaseException createCmisException(Exception e) {
127 if (e == null) {
128
129
130
131 return new CmisRuntimeException("Unknown exception!");
132 } else if (e instanceof CmisBaseException) {
133 return (CmisBaseException) e;
134 } else {
135
136
137 log.warn(e);
138
139 return new CmisRuntimeException(e.getMessage(), e);
140 }
141 }
142
143
144
145
146 protected void checkId(String name, String id) {
147 if (id == null) {
148 throw new CmisInvalidArgumentException(name + " must be set!");
149 }
150
151 if (id.length() == 0) {
152 throw new CmisInvalidArgumentException(name + " must not be empty!");
153 }
154 }
155
156
157
158
159 protected void checkIds(String name, String... ids) {
160 for (String id : ids) {
161 if (id != null && id.length() > 0) {
162 return;
163 }
164 }
165
166 throw new CmisInvalidArgumentException(name + " must be set!");
167 }
168
169
170
171
172
173 protected void checkHolderId(String name, Holder<String> holder) {
174 if (holder == null) {
175 throw new CmisInvalidArgumentException(name + " must be set!");
176 }
177
178 checkId(name, holder.getValue());
179 }
180
181
182
183
184 protected void checkRepositoryId(String repositoryId) {
185 checkId("Repository Id", repositoryId);
186 }
187
188
189
190
191 protected void checkPath(String name, String path) {
192 if (path == null) {
193 throw new CmisInvalidArgumentException(name + " must be set!");
194 }
195
196 if (path.length() == 0) {
197 throw new CmisInvalidArgumentException(name + " must not be empty!");
198 }
199
200 if (path.charAt(0) != '/') {
201 throw new CmisInvalidArgumentException(name + " must start with '/'!");
202 }
203 }
204
205
206
207
208 protected void checkProperties(Properties properties) {
209 if (properties == null) {
210 throw new CmisInvalidArgumentException("Properties must be set!");
211 }
212 }
213
214
215
216
217 protected void checkProperty(Properties properties, String propertyId, Class<?> clazz) {
218 if (properties.getProperties() == null) {
219 throw new CmisInvalidArgumentException("Property " + propertyId + " must be set!");
220 }
221
222 PropertyData<?> property = properties.getProperties().get(propertyId);
223 if (property == null) {
224 throw new CmisInvalidArgumentException("Property " + propertyId + " must be set!");
225 }
226
227 Object value = property.getFirstValue();
228 if (value == null) {
229 throw new CmisInvalidArgumentException("Property " + propertyId + " must have a value!");
230 }
231
232 if (!clazz.isAssignableFrom(value.getClass())) {
233 throw new CmisInvalidArgumentException("Property " + propertyId + " has the wrong type!");
234 }
235 }
236
237
238
239
240 protected void checkContentStream(ContentStream content) {
241 if (content == null) {
242 throw new CmisInvalidArgumentException("Content must be set!");
243 }
244 }
245
246
247
248
249
250 protected void checkQueryStatement(String statement) {
251 if (statement == null) {
252 throw new CmisInvalidArgumentException("Statement must be set!");
253 }
254
255 if (statement.length() == 0) {
256 throw new CmisInvalidArgumentException("Statement must not be empty!");
257 }
258 }
259
260
261
262
263 protected Boolean getDefaultTrue(Boolean value) {
264 if (value == null) {
265 return Boolean.TRUE;
266 }
267
268 return value;
269 }
270
271
272
273
274 protected Boolean getDefaultFalse(Boolean value) {
275 if (value == null) {
276 return Boolean.FALSE;
277 }
278
279 return value;
280 }
281
282
283
284
285
286 protected IncludeRelationships getDefault(IncludeRelationships value) {
287 if (value == null) {
288 return IncludeRelationships.NONE;
289 }
290
291 return value;
292 }
293
294
295
296
297
298 protected VersioningState getDefault(VersioningState value) {
299 if (value == null) {
300 return VersioningState.MAJOR;
301 }
302
303 return value;
304 }
305
306
307
308
309
310 protected UnfileObject getDefault(UnfileObject value) {
311 if (value == null) {
312 return UnfileObject.DELETE;
313 }
314
315 return value;
316 }
317
318
319
320
321
322
323 protected AclPropagation getDefault(AclPropagation value) {
324 if (value == null) {
325 return AclPropagation.REPOSITORYDETERMINED;
326 }
327
328 return value;
329 }
330
331
332
333
334
335
336 protected RelationshipDirection getDefault(RelationshipDirection value) {
337 if (value == null) {
338 return RelationshipDirection.SOURCE;
339 }
340
341 return value;
342 }
343
344
345
346
347
348 protected String getDefaultRenditionFilter(String value) {
349 if ((value == null) || (value.length() == 0)) {
350 return "cmis:none";
351 }
352
353 return value;
354 }
355
356
357
358
359
360
361 protected BigInteger getTypesMaxItems(BigInteger maxItems) {
362 if (maxItems == null) {
363 return defaultTypesMaxItems;
364 }
365
366 if (maxItems.compareTo(BigInteger.ZERO) == -1) {
367 throw new CmisInvalidArgumentException("maxItems must not be negative!");
368 }
369
370 return maxItems;
371 }
372
373
374
375
376
377 protected BigInteger getTypesDepth(BigInteger depth) {
378 if (depth == null) {
379 return defaultTypesDepth;
380 }
381
382 if (depth.compareTo(BigInteger.ZERO) == 0) {
383 throw new CmisInvalidArgumentException("depth must not be 0!");
384 }
385
386 if (depth.compareTo(MINUS_ONE) == -1) {
387 throw new CmisInvalidArgumentException("depth must not be <-1!");
388 }
389
390 return depth;
391 }
392
393
394
395
396
397
398 protected BigInteger getMaxItems(BigInteger maxItems) {
399 if (maxItems == null) {
400 return defaultMaxItems;
401 }
402
403 if (maxItems.compareTo(BigInteger.ZERO) == -1) {
404 throw new CmisInvalidArgumentException("maxItems must not be negative!");
405 }
406
407 return maxItems;
408 }
409
410
411
412
413
414
415 protected BigInteger getSkipCount(BigInteger skipCount) {
416 if (skipCount == null) {
417 return BigInteger.ZERO;
418 }
419
420 if (skipCount.compareTo(BigInteger.ZERO) == -1) {
421 throw new CmisInvalidArgumentException("skipCount must not be negative!");
422 }
423
424 return skipCount;
425 }
426
427
428
429
430
431 protected BigInteger getDepth(BigInteger depth) {
432 if (depth == null) {
433 return defaultDepth;
434 }
435
436 if (depth.compareTo(BigInteger.ZERO) == 0) {
437 throw new CmisInvalidArgumentException("depth must not be 0!");
438 }
439
440 if (depth.compareTo(MINUS_ONE) == -1) {
441 throw new CmisInvalidArgumentException("depth must not be <-1!");
442 }
443
444 return depth;
445 }
446
447
448
449
450 protected void checkNullOrPositive(String name, BigInteger value) {
451 if (value == null) {
452 return;
453 }
454
455 if (value.compareTo(BigInteger.ZERO) == -1) {
456 throw new CmisInvalidArgumentException(name + " must not be negative!");
457 }
458 }
459
460
461
462 public T getWrappedService() {
463 return service;
464 }
465
466 public ObjectInfo getObjectInfo(String repositoryId, String objectId) {
467 return service.getObjectInfo(repositoryId, objectId);
468 }
469
470 public void close() {
471 service.close();
472 }
473
474
475
476 public RepositoryInfo getRepositoryInfo(String repositoryId, ExtensionsData extension) {
477 checkRepositoryId(repositoryId);
478
479 try {
480 return service.getRepositoryInfo(repositoryId, extension);
481 } catch (Exception e) {
482 throw createCmisException(e);
483 }
484 }
485
486 public List<RepositoryInfo> getRepositoryInfos(ExtensionsData extension) {
487 try {
488 return service.getRepositoryInfos(extension);
489 } catch (Exception e) {
490 throw createCmisException(e);
491 }
492 }
493
494 public TypeDefinitionList getTypeChildren(String repositoryId, String typeId, Boolean includePropertyDefinitions,
495 BigInteger maxItems, BigInteger skipCount, ExtensionsData extension) {
496 checkRepositoryId(repositoryId);
497 includePropertyDefinitions = getDefaultFalse(includePropertyDefinitions);
498 maxItems = getTypesMaxItems(maxItems);
499 skipCount = getSkipCount(skipCount);
500
501 try {
502 return service.getTypeChildren(repositoryId, typeId, includePropertyDefinitions, maxItems, skipCount,
503 extension);
504 } catch (Exception e) {
505 throw createCmisException(e);
506 }
507 }
508
509 public TypeDefinition getTypeDefinition(String repositoryId, String typeId, ExtensionsData extension) {
510 checkRepositoryId(repositoryId);
511 checkId("Type Id", typeId);
512
513 try {
514 return service.getTypeDefinition(repositoryId, typeId, extension);
515 } catch (Exception e) {
516 throw createCmisException(e);
517 }
518 }
519
520 public List<TypeDefinitionContainer> getTypeDescendants(String repositoryId, String typeId, BigInteger depth,
521 Boolean includePropertyDefinitions, ExtensionsData extension) {
522 checkRepositoryId(repositoryId);
523 includePropertyDefinitions = getDefaultFalse(includePropertyDefinitions);
524 depth = getTypesDepth(depth);
525
526 try {
527 return service.getTypeDescendants(repositoryId, typeId, depth, includePropertyDefinitions, extension);
528 } catch (Exception e) {
529 throw createCmisException(e);
530 }
531 }
532
533
534
535 public ObjectList getCheckedOutDocs(String repositoryId, String folderId, String filter, String orderBy,
536 Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter,
537 BigInteger maxItems, BigInteger skipCount, ExtensionsData extension) {
538 checkRepositoryId(repositoryId);
539 includeAllowableActions = getDefaultFalse(includeAllowableActions);
540 includeRelationships = getDefault(includeRelationships);
541 renditionFilter = getDefaultRenditionFilter(renditionFilter);
542 maxItems = getMaxItems(maxItems);
543 skipCount = getSkipCount(skipCount);
544
545 try {
546 return service.getCheckedOutDocs(repositoryId, folderId, filter, orderBy, includeAllowableActions,
547 includeRelationships, renditionFilter, maxItems, skipCount, extension);
548 } catch (Exception e) {
549 throw createCmisException(e);
550 }
551 }
552
553 public ObjectInFolderList getChildren(String repositoryId, String folderId, String filter, String orderBy,
554 Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter,
555 Boolean includePathSegment, BigInteger maxItems, BigInteger skipCount, ExtensionsData extension) {
556 checkRepositoryId(repositoryId);
557 checkId("Folder Id", folderId);
558 includeAllowableActions = getDefaultFalse(includeAllowableActions);
559 includeRelationships = getDefault(includeRelationships);
560 renditionFilter = getDefaultRenditionFilter(renditionFilter);
561 includePathSegment = getDefaultFalse(includePathSegment);
562 maxItems = getMaxItems(maxItems);
563 skipCount = getSkipCount(skipCount);
564
565 try {
566 return service.getChildren(repositoryId, folderId, filter, orderBy, includeAllowableActions,
567 includeRelationships, renditionFilter, includePathSegment, maxItems, skipCount, extension);
568 } catch (Exception e) {
569 throw createCmisException(e);
570 }
571 }
572
573 public List<ObjectInFolderContainer> getDescendants(String repositoryId, String folderId, BigInteger depth,
574 String filter, Boolean includeAllowableActions, IncludeRelationships includeRelationships,
575 String renditionFilter, Boolean includePathSegment, ExtensionsData extension) {
576 checkRepositoryId(repositoryId);
577 checkId("Folder Id", folderId);
578 depth = getDepth(depth);
579 includeAllowableActions = getDefaultFalse(includeAllowableActions);
580 includeRelationships = getDefault(includeRelationships);
581 renditionFilter = getDefaultRenditionFilter(renditionFilter);
582 includePathSegment = getDefaultFalse(includePathSegment);
583
584 try {
585 return service.getDescendants(repositoryId, folderId, depth, filter, includeAllowableActions,
586 includeRelationships, renditionFilter, includePathSegment, extension);
587 } catch (Exception e) {
588 throw createCmisException(e);
589 }
590 }
591
592 public ObjectData getFolderParent(String repositoryId, String folderId, String filter, ExtensionsData extension) {
593 checkRepositoryId(repositoryId);
594 checkId("Folder Id", folderId);
595
596 try {
597 return service.getFolderParent(repositoryId, folderId, filter, extension);
598 } catch (Exception e) {
599 throw createCmisException(e);
600 }
601 }
602
603 public List<ObjectInFolderContainer> getFolderTree(String repositoryId, String folderId, BigInteger depth,
604 String filter, Boolean includeAllowableActions, IncludeRelationships includeRelationships,
605 String renditionFilter, Boolean includePathSegment, ExtensionsData extension) {
606 checkRepositoryId(repositoryId);
607 checkId("Folder Id", folderId);
608 depth = getDepth(depth);
609 includeAllowableActions = getDefaultFalse(includeAllowableActions);
610 includeRelationships = getDefault(includeRelationships);
611 renditionFilter = getDefaultRenditionFilter(renditionFilter);
612 includePathSegment = getDefaultFalse(includePathSegment);
613
614 try {
615 return service.getFolderTree(repositoryId, folderId, depth, filter, includeAllowableActions,
616 includeRelationships, renditionFilter, includePathSegment, extension);
617 } catch (Exception e) {
618 throw createCmisException(e);
619 }
620 }
621
622 public List<ObjectParentData> getObjectParents(String repositoryId, String objectId, String filter,
623 Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter,
624 Boolean includeRelativePathSegment, ExtensionsData extension) {
625 checkRepositoryId(repositoryId);
626 checkId("Object Id", objectId);
627 includeAllowableActions = getDefaultFalse(includeAllowableActions);
628 includeRelationships = getDefault(includeRelationships);
629 renditionFilter = getDefaultRenditionFilter(renditionFilter);
630 includeRelativePathSegment = getDefaultFalse(includeRelativePathSegment);
631
632 try {
633 return service.getObjectParents(repositoryId, objectId, filter, includeAllowableActions,
634 includeRelationships, renditionFilter, includeRelativePathSegment, extension);
635 } catch (Exception e) {
636 throw createCmisException(e);
637 }
638 }
639
640
641
642 public String create(String repositoryId, Properties properties, String folderId, ContentStream contentStream,
643 VersioningState versioningState, List<String> policies, ExtensionsData extension) {
644 checkRepositoryId(repositoryId);
645 checkProperties(properties);
646 checkProperty(properties, PropertyIds.OBJECT_TYPE_ID, String.class);
647 versioningState = getDefault(versioningState);
648
649 try {
650 return service.create(repositoryId, properties, folderId, contentStream, versioningState, policies,
651 extension);
652 } catch (Exception e) {
653 throw createCmisException(e);
654 }
655 }
656
657 public String createDocument(String repositoryId, Properties properties, String folderId,
658 ContentStream contentStream, VersioningState versioningState, List<String> policies, Acl addAces,
659 Acl removeAces, ExtensionsData extension) {
660 checkRepositoryId(repositoryId);
661 checkProperties(properties);
662 checkProperty(properties, PropertyIds.OBJECT_TYPE_ID, String.class);
663 versioningState = getDefault(versioningState);
664
665 try {
666 return service.createDocument(repositoryId, properties, folderId, contentStream, versioningState, policies,
667 addAces, removeAces, extension);
668 } catch (Exception e) {
669 throw createCmisException(e);
670 }
671 }
672
673 public String createDocumentFromSource(String repositoryId, String sourceId, Properties properties,
674 String folderId, VersioningState versioningState, List<String> policies, Acl addAces, Acl removeAces,
675 ExtensionsData extension) {
676 checkRepositoryId(repositoryId);
677 checkId("Source Id", sourceId);
678 versioningState = getDefault(versioningState);
679
680 try {
681 return service.createDocumentFromSource(repositoryId, sourceId, properties, folderId, versioningState,
682 policies, addAces, removeAces, extension);
683 } catch (Exception e) {
684 throw createCmisException(e);
685 }
686 }
687
688 public String createFolder(String repositoryId, Properties properties, String folderId, List<String> policies,
689 Acl addAces, Acl removeAces, ExtensionsData extension) {
690 checkRepositoryId(repositoryId);
691 checkProperties(properties);
692 checkProperty(properties, PropertyIds.OBJECT_TYPE_ID, String.class);
693 checkId("Folder Id", folderId);
694
695 try {
696 return service.createFolder(repositoryId, properties, folderId, policies, addAces, removeAces, extension);
697 } catch (Exception e) {
698 throw createCmisException(e);
699 }
700 }
701
702 public String createPolicy(String repositoryId, Properties properties, String folderId, List<String> policies,
703 Acl addAces, Acl removeAces, ExtensionsData extension) {
704 checkRepositoryId(repositoryId);
705 checkProperties(properties);
706 checkProperty(properties, PropertyIds.OBJECT_TYPE_ID, String.class);
707
708 try {
709 return service.createPolicy(repositoryId, properties, folderId, policies, addAces, removeAces, extension);
710 } catch (Exception e) {
711 throw createCmisException(e);
712 }
713 }
714
715 public String createRelationship(String repositoryId, Properties properties, List<String> policies, Acl addAces,
716 Acl removeAces, ExtensionsData extension) {
717 checkRepositoryId(repositoryId);
718 checkProperties(properties);
719 checkProperty(properties, PropertyIds.OBJECT_TYPE_ID, String.class);
720
721
722
723 try {
724 return service.createRelationship(repositoryId, properties, policies, addAces, removeAces, extension);
725 } catch (Exception e) {
726 throw createCmisException(e);
727 }
728 }
729
730 public void deleteContentStream(String repositoryId, Holder<String> objectId, Holder<String> changeToken,
731 ExtensionsData extension) {
732 checkRepositoryId(repositoryId);
733 checkHolderId("Object Id", objectId);
734
735 try {
736 service.deleteContentStream(repositoryId, objectId, changeToken, extension);
737 } catch (Exception e) {
738 throw createCmisException(e);
739 }
740 }
741
742 public void deleteObject(String repositoryId, String objectId, Boolean allVersions, ExtensionsData extension) {
743 checkRepositoryId(repositoryId);
744 checkId("Object Id", objectId);
745 allVersions = getDefaultTrue(allVersions);
746
747 try {
748 service.deleteObjectOrCancelCheckOut(repositoryId, objectId, allVersions, extension);
749 } catch (Exception e) {
750 throw createCmisException(e);
751 }
752 }
753
754 public void deleteObjectOrCancelCheckOut(String repositoryId, String objectId, Boolean allVersions,
755 ExtensionsData extension) {
756 checkRepositoryId(repositoryId);
757 checkId("Object Id", objectId);
758 allVersions = getDefaultTrue(allVersions);
759
760 try {
761 service.deleteObjectOrCancelCheckOut(repositoryId, objectId, allVersions, extension);
762 } catch (Exception e) {
763 throw createCmisException(e);
764 }
765 }
766
767 public FailedToDeleteData deleteTree(String repositoryId, String folderId, Boolean allVersions,
768 UnfileObject unfileObjects, Boolean continueOnFailure, ExtensionsData extension) {
769 checkRepositoryId(repositoryId);
770 checkId("Folder Id", folderId);
771 allVersions = getDefaultTrue(allVersions);
772 unfileObjects = getDefault(unfileObjects);
773 continueOnFailure = getDefaultFalse(continueOnFailure);
774
775 try {
776 return service.deleteTree(repositoryId, folderId, allVersions, unfileObjects, continueOnFailure, extension);
777 } catch (Exception e) {
778 throw createCmisException(e);
779 }
780 }
781
782 public AllowableActions getAllowableActions(String repositoryId, String objectId, ExtensionsData extension) {
783 checkRepositoryId(repositoryId);
784 checkId("Object Id", objectId);
785
786 try {
787 return service.getAllowableActions(repositoryId, objectId, extension);
788 } catch (Exception e) {
789 throw createCmisException(e);
790 }
791 }
792
793 public ContentStream getContentStream(String repositoryId, String objectId, String streamId, BigInteger offset,
794 BigInteger length, ExtensionsData extension) {
795 checkRepositoryId(repositoryId);
796 checkId("Object Id", objectId);
797 checkNullOrPositive("Offset", offset);
798 checkNullOrPositive("Length", length);
799
800 try {
801 return service.getContentStream(repositoryId, objectId, streamId, offset, length, extension);
802 } catch (Exception e) {
803 throw createCmisException(e);
804 }
805 }
806
807 public ObjectData getObject(String repositoryId, String objectId, String filter, Boolean includeAllowableActions,
808 IncludeRelationships includeRelationships, String renditionFilter, Boolean includePolicyIds,
809 Boolean includeAcl, ExtensionsData extension) {
810 checkRepositoryId(repositoryId);
811 checkId("Object Id", objectId);
812 includeAllowableActions = getDefaultFalse(includeAllowableActions);
813 includeRelationships = getDefault(includeRelationships);
814 renditionFilter = getDefaultRenditionFilter(renditionFilter);
815 includePolicyIds = getDefaultFalse(includePolicyIds);
816 includeAcl = getDefaultFalse(includeAcl);
817
818 try {
819 return service.getObject(repositoryId, objectId, filter, includeAllowableActions, includeRelationships,
820 renditionFilter, includePolicyIds, includeAcl, extension);
821 } catch (Exception e) {
822 throw createCmisException(e);
823 }
824 }
825
826 public ObjectData getObjectByPath(String repositoryId, String path, String filter, Boolean includeAllowableActions,
827 IncludeRelationships includeRelationships, String renditionFilter, Boolean includePolicyIds,
828 Boolean includeAcl, ExtensionsData extension) {
829 checkRepositoryId(repositoryId);
830 checkPath("Path", path);
831 includeAllowableActions = getDefaultFalse(includeAllowableActions);
832 includeRelationships = getDefault(includeRelationships);
833 renditionFilter = getDefaultRenditionFilter(renditionFilter);
834 includePolicyIds = getDefaultFalse(includePolicyIds);
835 includeAcl = getDefaultFalse(includeAcl);
836
837 try {
838 return service.getObjectByPath(repositoryId, path, filter, includeAllowableActions, includeRelationships,
839 renditionFilter, includePolicyIds, includeAcl, extension);
840 } catch (Exception e) {
841 throw createCmisException(e);
842 }
843 }
844
845 public Properties getProperties(String repositoryId, String objectId, String filter, ExtensionsData extension) {
846 checkRepositoryId(repositoryId);
847 checkId("Object Id", objectId);
848
849 try {
850 return service.getProperties(repositoryId, objectId, filter, extension);
851 } catch (Exception e) {
852 throw createCmisException(e);
853 }
854 }
855
856 public List<RenditionData> getRenditions(String repositoryId, String objectId, String renditionFilter,
857 BigInteger maxItems, BigInteger skipCount, ExtensionsData extension) {
858 checkRepositoryId(repositoryId);
859 checkId("Object Id", objectId);
860 renditionFilter = getDefaultRenditionFilter(renditionFilter);
861 maxItems = getMaxItems(maxItems);
862 skipCount = getSkipCount(skipCount);
863
864 try {
865 return service.getRenditions(repositoryId, objectId, renditionFilter, maxItems, skipCount, extension);
866 } catch (Exception e) {
867 throw createCmisException(e);
868 }
869 }
870
871 public void moveObject(String repositoryId, Holder<String> objectId, String targetFolderId, String sourceFolderId,
872 ExtensionsData extension) {
873 checkRepositoryId(repositoryId);
874 checkHolderId("Object Id", objectId);
875 checkId("Target Folder Id", targetFolderId);
876
877 try {
878 service.moveObject(repositoryId, objectId, targetFolderId, sourceFolderId, extension);
879 } catch (Exception e) {
880 throw createCmisException(e);
881 }
882 }
883
884 public void setContentStream(String repositoryId, Holder<String> objectId, Boolean overwriteFlag,
885 Holder<String> changeToken, ContentStream contentStream, ExtensionsData extension) {
886 checkRepositoryId(repositoryId);
887 checkHolderId("Object Id", objectId);
888 overwriteFlag = getDefaultTrue(overwriteFlag);
889 checkContentStream(contentStream);
890
891 try {
892 service.setContentStream(repositoryId, objectId, overwriteFlag, changeToken, contentStream, extension);
893 } catch (Exception e) {
894 throw createCmisException(e);
895 }
896 }
897
898 public void updateProperties(String repositoryId, Holder<String> objectId, Holder<String> changeToken,
899 Properties properties, ExtensionsData extension) {
900 checkRepositoryId(repositoryId);
901 checkHolderId("Object Id", objectId);
902 checkProperties(properties);
903
904 try {
905 service.updateProperties(repositoryId, objectId, changeToken, properties, extension);
906 } catch (Exception e) {
907 throw createCmisException(e);
908 }
909 }
910
911
912
913 public void cancelCheckOut(String repositoryId, String objectId, ExtensionsData extension) {
914 checkRepositoryId(repositoryId);
915 checkId("Object Id", objectId);
916
917 try {
918 service.cancelCheckOut(repositoryId, objectId, extension);
919 } catch (Exception e) {
920 throw createCmisException(e);
921 }
922 }
923
924 public void checkIn(String repositoryId, Holder<String> objectId, Boolean major, Properties properties,
925 ContentStream contentStream, String checkinComment, List<String> policies, Acl addAces, Acl removeAces,
926 ExtensionsData extension) {
927 checkRepositoryId(repositoryId);
928 checkHolderId("Object Id", objectId);
929 major = getDefaultTrue(major);
930
931 try {
932 service.checkIn(repositoryId, objectId, major, properties, contentStream, checkinComment, policies,
933 addAces, removeAces, extension);
934 } catch (Exception e) {
935 throw createCmisException(e);
936 }
937 }
938
939 public void checkOut(String repositoryId, Holder<String> objectId, ExtensionsData extension,
940 Holder<Boolean> contentCopied) {
941 checkRepositoryId(repositoryId);
942 checkHolderId("Object Id", objectId);
943
944 try {
945 service.checkOut(repositoryId, objectId, extension, contentCopied);
946 } catch (Exception e) {
947 throw createCmisException(e);
948 }
949 }
950
951 public ObjectData getObjectOfLatestVersion(String repositoryId, String objectId, String versionSeriesId,
952 Boolean major, String filter, Boolean includeAllowableActions, IncludeRelationships includeRelationships,
953 String renditionFilter, Boolean includePolicyIds, Boolean includeAcl, ExtensionsData extension) {
954 checkRepositoryId(repositoryId);
955 checkIds("Version Series Id", objectId, versionSeriesId);
956 major = getDefaultFalse(major);
957 includeAllowableActions = getDefaultFalse(includeAllowableActions);
958 includeRelationships = getDefault(includeRelationships);
959 renditionFilter = getDefaultRenditionFilter(renditionFilter);
960 includePolicyIds = getDefaultFalse(includePolicyIds);
961 includeAcl = getDefaultFalse(includeAcl);
962
963 try {
964 return service.getObjectOfLatestVersion(repositoryId, objectId, versionSeriesId, major, filter,
965 includeAllowableActions, includeRelationships, renditionFilter, includePolicyIds, includeAcl,
966 extension);
967 } catch (Exception e) {
968 throw createCmisException(e);
969 }
970 }
971
972 public Properties getPropertiesOfLatestVersion(String repositoryId, String objectId, String versionSeriesId,
973 Boolean major, String filter, ExtensionsData extension) {
974 checkRepositoryId(repositoryId);
975 checkIds("Version Series Id", objectId, versionSeriesId);
976 major = getDefaultFalse(major);
977
978 try {
979 return service.getPropertiesOfLatestVersion(repositoryId, objectId, versionSeriesId, major, filter,
980 extension);
981 } catch (Exception e) {
982 throw createCmisException(e);
983 }
984 }
985
986 public List<ObjectData> getAllVersions(String repositoryId, String objectId, String versionSeriesId, String filter,
987 Boolean includeAllowableActions, ExtensionsData extension) {
988 checkRepositoryId(repositoryId);
989 checkIds("Version Series Id", objectId, versionSeriesId);
990 includeAllowableActions = getDefaultFalse(includeAllowableActions);
991
992 try {
993 return service.getAllVersions(repositoryId, objectId, versionSeriesId, filter, includeAllowableActions,
994 extension);
995 } catch (Exception e) {
996 throw createCmisException(e);
997 }
998 }
999
1000
1001
1002 public ObjectList getContentChanges(String repositoryId, Holder<String> changeLogToken, Boolean includeProperties,
1003 String filter, Boolean includePolicyIds, Boolean includeAcl, BigInteger maxItems, ExtensionsData extension) {
1004 checkRepositoryId(repositoryId);
1005 includeProperties = getDefaultFalse(includeProperties);
1006 includePolicyIds = getDefaultFalse(includePolicyIds);
1007 includeAcl = getDefaultFalse(includeAcl);
1008 maxItems = getMaxItems(maxItems);
1009
1010 try {
1011 return service.getContentChanges(repositoryId, changeLogToken, includeProperties, filter, includePolicyIds,
1012 includeAcl, maxItems, extension);
1013 } catch (Exception e) {
1014 throw createCmisException(e);
1015 }
1016 }
1017
1018 public ObjectList query(String repositoryId, String statement, Boolean searchAllVersions,
1019 Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter,
1020 BigInteger maxItems, BigInteger skipCount, ExtensionsData extension) {
1021 checkRepositoryId(repositoryId);
1022 checkQueryStatement(statement);
1023 searchAllVersions = getDefaultFalse(searchAllVersions);
1024 includeAllowableActions = getDefaultFalse(includeAllowableActions);
1025 includeRelationships = getDefault(includeRelationships);
1026 renditionFilter = getDefaultRenditionFilter(renditionFilter);
1027 maxItems = getMaxItems(maxItems);
1028 skipCount = getSkipCount(skipCount);
1029
1030 try {
1031 return service.query(repositoryId, statement, searchAllVersions, includeAllowableActions,
1032 includeRelationships, renditionFilter, maxItems, skipCount, extension);
1033 } catch (Exception e) {
1034 throw createCmisException(e);
1035 }
1036 }
1037
1038
1039
1040 public void addObjectToFolder(String repositoryId, String objectId, String folderId, Boolean allVersions,
1041 ExtensionsData extension) {
1042 checkRepositoryId(repositoryId);
1043 checkId("Object Id", objectId);
1044 checkId("Folder Id", folderId);
1045 allVersions = getDefaultTrue(allVersions);
1046
1047 try {
1048 service.addObjectToFolder(repositoryId, objectId, folderId, allVersions, extension);
1049 } catch (Exception e) {
1050 throw createCmisException(e);
1051 }
1052 }
1053
1054 public void removeObjectFromFolder(String repositoryId, String objectId, String folderId, ExtensionsData extension) {
1055 checkRepositoryId(repositoryId);
1056 checkId("Object Id", objectId);
1057
1058 try {
1059 service.removeObjectFromFolder(repositoryId, objectId, folderId, extension);
1060 } catch (Exception e) {
1061 throw createCmisException(e);
1062 }
1063 }
1064
1065
1066
1067 public ObjectList getObjectRelationships(String repositoryId, String objectId, Boolean includeSubRelationshipTypes,
1068 RelationshipDirection relationshipDirection, String typeId, String filter, Boolean includeAllowableActions,
1069 BigInteger maxItems, BigInteger skipCount, ExtensionsData extension) {
1070 checkRepositoryId(repositoryId);
1071 checkId("Object Id", objectId);
1072 includeSubRelationshipTypes = getDefaultFalse(includeSubRelationshipTypes);
1073 relationshipDirection = getDefault(relationshipDirection);
1074 includeAllowableActions = getDefaultFalse(includeAllowableActions);
1075 maxItems = getMaxItems(maxItems);
1076 skipCount = getSkipCount(skipCount);
1077
1078 try {
1079 return service.getObjectRelationships(repositoryId, objectId, includeSubRelationshipTypes,
1080 relationshipDirection, typeId, filter, includeAllowableActions, maxItems, skipCount, extension);
1081 } catch (Exception e) {
1082 throw createCmisException(e);
1083 }
1084 }
1085
1086
1087
1088 public Acl applyAcl(String repositoryId, String objectId, Acl aces, AclPropagation aclPropagation) {
1089 checkRepositoryId(repositoryId);
1090 checkId("Object Id", objectId);
1091 aclPropagation = getDefault(aclPropagation);
1092
1093 try {
1094 return service.applyAcl(repositoryId, objectId, aces, aclPropagation);
1095 } catch (Exception e) {
1096 throw createCmisException(e);
1097 }
1098 }
1099
1100 public Acl applyAcl(String repositoryId, String objectId, Acl addAces, Acl removeAces,
1101 AclPropagation aclPropagation, ExtensionsData extension) {
1102 checkRepositoryId(repositoryId);
1103 checkId("Object Id", objectId);
1104 aclPropagation = getDefault(aclPropagation);
1105
1106 try {
1107 return service.applyAcl(repositoryId, objectId, addAces, removeAces, aclPropagation, extension);
1108 } catch (Exception e) {
1109 throw createCmisException(e);
1110 }
1111 }
1112
1113 public Acl getAcl(String repositoryId, String objectId, Boolean onlyBasicPermissions, ExtensionsData extension) {
1114 checkRepositoryId(repositoryId);
1115 checkId("Object Id", objectId);
1116 onlyBasicPermissions = getDefaultTrue(onlyBasicPermissions);
1117
1118 try {
1119 return service.getAcl(repositoryId, objectId, onlyBasicPermissions, extension);
1120 } catch (Exception e) {
1121 throw createCmisException(e);
1122 }
1123 }
1124
1125
1126
1127 public void applyPolicy(String repositoryId, String policyId, String objectId, ExtensionsData extension) {
1128 checkRepositoryId(repositoryId);
1129 checkId("Policy Id", policyId);
1130 checkId("Object Id", objectId);
1131
1132 try {
1133 service.applyPolicy(repositoryId, policyId, objectId, extension);
1134 } catch (Exception e) {
1135 throw createCmisException(e);
1136 }
1137 }
1138
1139 public List<ObjectData> getAppliedPolicies(String repositoryId, String objectId, String filter,
1140 ExtensionsData extension) {
1141 checkRepositoryId(repositoryId);
1142 checkId("Object Id", objectId);
1143
1144 try {
1145 return service.getAppliedPolicies(repositoryId, objectId, filter, extension);
1146 } catch (Exception e) {
1147 throw createCmisException(e);
1148 }
1149 }
1150
1151 public void removePolicy(String repositoryId, String policyId, String objectId, ExtensionsData extension) {
1152 checkRepositoryId(repositoryId);
1153 checkId("Policy Id", policyId);
1154 checkId("Object Id", objectId);
1155
1156 try {
1157 service.removePolicy(repositoryId, policyId, objectId, extension);
1158 } catch (Exception e) {
1159 throw createCmisException(e);
1160 }
1161 }
1162 }