This project has retired. For details please refer to its
Attic page.
Converter 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.commons.impl;
20
21 import java.io.IOException;
22 import java.io.InputStream;
23 import java.io.OutputStream;
24 import java.lang.reflect.Method;
25 import java.math.BigDecimal;
26 import java.math.BigInteger;
27 import java.util.ArrayList;
28 import java.util.EnumSet;
29 import java.util.GregorianCalendar;
30 import java.util.HashMap;
31 import java.util.LinkedHashMap;
32 import java.util.List;
33 import java.util.Map;
34 import java.util.Set;
35
36 import javax.activation.DataHandler;
37 import javax.activation.DataSource;
38 import javax.xml.datatype.DatatypeConfigurationException;
39 import javax.xml.datatype.DatatypeFactory;
40 import javax.xml.datatype.XMLGregorianCalendar;
41 import javax.xml.parsers.DocumentBuilder;
42 import javax.xml.parsers.DocumentBuilderFactory;
43
44 import org.apache.chemistry.opencmis.commons.data.Ace;
45 import org.apache.chemistry.opencmis.commons.data.Acl;
46 import org.apache.chemistry.opencmis.commons.data.AclCapabilities;
47 import org.apache.chemistry.opencmis.commons.data.AllowableActions;
48 import org.apache.chemistry.opencmis.commons.data.CmisExtensionElement;
49 import org.apache.chemistry.opencmis.commons.data.ContentStream;
50 import org.apache.chemistry.opencmis.commons.data.ExtensionsData;
51 import org.apache.chemistry.opencmis.commons.data.FailedToDeleteData;
52 import org.apache.chemistry.opencmis.commons.data.ObjectData;
53 import org.apache.chemistry.opencmis.commons.data.ObjectInFolderContainer;
54 import org.apache.chemistry.opencmis.commons.data.ObjectInFolderData;
55 import org.apache.chemistry.opencmis.commons.data.ObjectInFolderList;
56 import org.apache.chemistry.opencmis.commons.data.ObjectList;
57 import org.apache.chemistry.opencmis.commons.data.ObjectParentData;
58 import org.apache.chemistry.opencmis.commons.data.PermissionMapping;
59 import org.apache.chemistry.opencmis.commons.data.PolicyIdList;
60 import org.apache.chemistry.opencmis.commons.data.Properties;
61 import org.apache.chemistry.opencmis.commons.data.PropertyBoolean;
62 import org.apache.chemistry.opencmis.commons.data.PropertyData;
63 import org.apache.chemistry.opencmis.commons.data.PropertyDateTime;
64 import org.apache.chemistry.opencmis.commons.data.PropertyDecimal;
65 import org.apache.chemistry.opencmis.commons.data.PropertyHtml;
66 import org.apache.chemistry.opencmis.commons.data.PropertyId;
67 import org.apache.chemistry.opencmis.commons.data.PropertyInteger;
68 import org.apache.chemistry.opencmis.commons.data.PropertyString;
69 import org.apache.chemistry.opencmis.commons.data.PropertyUri;
70 import org.apache.chemistry.opencmis.commons.data.RenditionData;
71 import org.apache.chemistry.opencmis.commons.data.RepositoryCapabilities;
72 import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
73 import org.apache.chemistry.opencmis.commons.definitions.Choice;
74 import org.apache.chemistry.opencmis.commons.definitions.DocumentTypeDefinition;
75 import org.apache.chemistry.opencmis.commons.definitions.FolderTypeDefinition;
76 import org.apache.chemistry.opencmis.commons.definitions.PermissionDefinition;
77 import org.apache.chemistry.opencmis.commons.definitions.PolicyTypeDefinition;
78 import org.apache.chemistry.opencmis.commons.definitions.PropertyBooleanDefinition;
79 import org.apache.chemistry.opencmis.commons.definitions.PropertyDateTimeDefinition;
80 import org.apache.chemistry.opencmis.commons.definitions.PropertyDecimalDefinition;
81 import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
82 import org.apache.chemistry.opencmis.commons.definitions.PropertyHtmlDefinition;
83 import org.apache.chemistry.opencmis.commons.definitions.PropertyIdDefinition;
84 import org.apache.chemistry.opencmis.commons.definitions.PropertyIntegerDefinition;
85 import org.apache.chemistry.opencmis.commons.definitions.PropertyStringDefinition;
86 import org.apache.chemistry.opencmis.commons.definitions.PropertyUriDefinition;
87 import org.apache.chemistry.opencmis.commons.definitions.RelationshipTypeDefinition;
88 import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
89 import org.apache.chemistry.opencmis.commons.definitions.TypeDefinitionContainer;
90 import org.apache.chemistry.opencmis.commons.definitions.TypeDefinitionList;
91 import org.apache.chemistry.opencmis.commons.enums.AclPropagation;
92 import org.apache.chemistry.opencmis.commons.enums.Action;
93 import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
94 import org.apache.chemistry.opencmis.commons.enums.CapabilityAcl;
95 import org.apache.chemistry.opencmis.commons.enums.CapabilityChanges;
96 import org.apache.chemistry.opencmis.commons.enums.CapabilityContentStreamUpdates;
97 import org.apache.chemistry.opencmis.commons.enums.CapabilityJoin;
98 import org.apache.chemistry.opencmis.commons.enums.CapabilityQuery;
99 import org.apache.chemistry.opencmis.commons.enums.CapabilityRenditions;
100 import org.apache.chemistry.opencmis.commons.enums.Cardinality;
101 import org.apache.chemistry.opencmis.commons.enums.ChangeType;
102 import org.apache.chemistry.opencmis.commons.enums.ContentStreamAllowed;
103 import org.apache.chemistry.opencmis.commons.enums.DateTimeResolution;
104 import org.apache.chemistry.opencmis.commons.enums.PropertyType;
105 import org.apache.chemistry.opencmis.commons.enums.SupportedPermissions;
106 import org.apache.chemistry.opencmis.commons.enums.Updatability;
107 import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
108 import org.apache.chemistry.opencmis.commons.impl.dataobjects.AbstractPropertyData;
109 import org.apache.chemistry.opencmis.commons.impl.dataobjects.AbstractPropertyDefinition;
110 import org.apache.chemistry.opencmis.commons.impl.dataobjects.AbstractTypeDefinition;
111 import org.apache.chemistry.opencmis.commons.impl.dataobjects.AccessControlEntryImpl;
112 import org.apache.chemistry.opencmis.commons.impl.dataobjects.AccessControlListImpl;
113 import org.apache.chemistry.opencmis.commons.impl.dataobjects.AccessControlPrincipalDataImpl;
114 import org.apache.chemistry.opencmis.commons.impl.dataobjects.AclCapabilitiesDataImpl;
115 import org.apache.chemistry.opencmis.commons.impl.dataobjects.AllowableActionsImpl;
116 import org.apache.chemistry.opencmis.commons.impl.dataobjects.ChangeEventInfoDataImpl;
117 import org.apache.chemistry.opencmis.commons.impl.dataobjects.ChoiceImpl;
118 import org.apache.chemistry.opencmis.commons.impl.dataobjects.CmisExtensionElementImpl;
119 import org.apache.chemistry.opencmis.commons.impl.dataobjects.ContentStreamImpl;
120 import org.apache.chemistry.opencmis.commons.impl.dataobjects.DocumentTypeDefinitionImpl;
121 import org.apache.chemistry.opencmis.commons.impl.dataobjects.ExtensionDataImpl;
122 import org.apache.chemistry.opencmis.commons.impl.dataobjects.FailedToDeleteDataImpl;
123 import org.apache.chemistry.opencmis.commons.impl.dataobjects.FolderTypeDefinitionImpl;
124 import org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectDataImpl;
125 import org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectInFolderContainerImpl;
126 import org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectInFolderDataImpl;
127 import org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectInFolderListImpl;
128 import org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectListImpl;
129 import org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectParentDataImpl;
130 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PermissionDefinitionDataImpl;
131 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PermissionMappingDataImpl;
132 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PolicyIdListImpl;
133 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PolicyTypeDefinitionImpl;
134 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertiesImpl;
135 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyBooleanDefinitionImpl;
136 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyBooleanImpl;
137 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyDateTimeDefinitionImpl;
138 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyDateTimeImpl;
139 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyDecimalDefinitionImpl;
140 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyDecimalImpl;
141 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyHtmlDefinitionImpl;
142 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyHtmlImpl;
143 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyIdDefinitionImpl;
144 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyIdImpl;
145 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyIntegerDefinitionImpl;
146 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyIntegerImpl;
147 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyStringDefinitionImpl;
148 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyStringImpl;
149 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyUriDefinitionImpl;
150 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyUriImpl;
151 import org.apache.chemistry.opencmis.commons.impl.dataobjects.RelationshipTypeDefinitionImpl;
152 import org.apache.chemistry.opencmis.commons.impl.dataobjects.RenditionDataImpl;
153 import org.apache.chemistry.opencmis.commons.impl.dataobjects.RepositoryCapabilitiesImpl;
154 import org.apache.chemistry.opencmis.commons.impl.dataobjects.RepositoryInfoImpl;
155 import org.apache.chemistry.opencmis.commons.impl.dataobjects.TypeDefinitionContainerImpl;
156 import org.apache.chemistry.opencmis.commons.impl.dataobjects.TypeDefinitionListImpl;
157 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisACLCapabilityType;
158 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisACLType;
159 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisAccessControlEntryType;
160 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisAccessControlListType;
161 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisAccessControlPrincipalType;
162 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisAllowableActionsType;
163 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisChangeEventType;
164 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisChoiceBoolean;
165 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisChoiceDateTime;
166 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisChoiceDecimal;
167 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisChoiceHtml;
168 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisChoiceId;
169 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisChoiceInteger;
170 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisChoiceString;
171 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisChoiceUri;
172 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisContentStreamType;
173 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisExtensionType;
174 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisListOfIdsType;
175 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisObjectInFolderContainerType;
176 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisObjectInFolderListType;
177 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisObjectInFolderType;
178 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisObjectListType;
179 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisObjectParentsType;
180 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisObjectType;
181 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisPermissionDefinition;
182 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisPermissionMapping;
183 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisPropertiesType;
184 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisProperty;
185 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisPropertyBoolean;
186 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisPropertyBooleanDefinitionType;
187 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisPropertyDateTime;
188 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisPropertyDateTimeDefinitionType;
189 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisPropertyDecimal;
190 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisPropertyDecimalDefinitionType;
191 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisPropertyDefinitionType;
192 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisPropertyHtml;
193 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisPropertyHtmlDefinitionType;
194 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisPropertyId;
195 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisPropertyIdDefinitionType;
196 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisPropertyInteger;
197 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisPropertyIntegerDefinitionType;
198 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisPropertyString;
199 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisPropertyStringDefinitionType;
200 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisPropertyUri;
201 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisPropertyUriDefinitionType;
202 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisRenditionType;
203 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisRepositoryCapabilitiesType;
204 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisRepositoryInfoType;
205 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisTypeContainer;
206 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisTypeDefinitionListType;
207 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisTypeDefinitionType;
208 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisTypeDocumentDefinitionType;
209 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisTypeFolderDefinitionType;
210 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisTypePolicyDefinitionType;
211 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisTypeRelationshipDefinitionType;
212 import org.apache.chemistry.opencmis.commons.impl.jaxb.DeleteTreeResponse;
213 import org.apache.chemistry.opencmis.commons.impl.jaxb.EnumACLPropagation;
214 import org.apache.chemistry.opencmis.commons.impl.jaxb.EnumAllowableActionsKey;
215 import org.apache.chemistry.opencmis.commons.impl.jaxb.EnumBaseObjectTypeIds;
216 import org.apache.chemistry.opencmis.commons.impl.jaxb.EnumCapabilityACL;
217 import org.apache.chemistry.opencmis.commons.impl.jaxb.EnumCapabilityChanges;
218 import org.apache.chemistry.opencmis.commons.impl.jaxb.EnumCapabilityContentStreamUpdates;
219 import org.apache.chemistry.opencmis.commons.impl.jaxb.EnumCapabilityJoin;
220 import org.apache.chemistry.opencmis.commons.impl.jaxb.EnumCapabilityQuery;
221 import org.apache.chemistry.opencmis.commons.impl.jaxb.EnumCapabilityRendition;
222 import org.apache.chemistry.opencmis.commons.impl.jaxb.EnumCardinality;
223 import org.apache.chemistry.opencmis.commons.impl.jaxb.EnumContentStreamAllowed;
224 import org.apache.chemistry.opencmis.commons.impl.jaxb.EnumDateTimeResolution;
225 import org.apache.chemistry.opencmis.commons.impl.jaxb.EnumPropertyType;
226 import org.apache.chemistry.opencmis.commons.impl.jaxb.EnumSupportedPermissions;
227 import org.apache.chemistry.opencmis.commons.impl.jaxb.EnumTypeOfChanges;
228 import org.apache.chemistry.opencmis.commons.impl.jaxb.EnumUpdatability;
229 import org.apache.chemistry.opencmis.commons.spi.Holder;
230 import org.w3c.dom.Document;
231 import org.w3c.dom.Element;
232 import org.w3c.dom.Node;
233 import org.w3c.dom.NodeList;
234
235 import com.sun.xml.ws.developer.StreamingDataHandler;
236
237
238
239
240 public final class Converter {
241
242 private static final String DEFAULT_EXTENSION_NS = "http://chemistry.apache.org/opencmis/extension";
243
244
245
246
247 private Converter() {
248 }
249
250
251
252
253
254
255
256
257 public static RepositoryInfo convert(CmisRepositoryInfoType repositoryInfo) {
258 if (repositoryInfo == null) {
259 return null;
260 }
261
262 RepositoryInfoImpl result = new RepositoryInfoImpl();
263
264 result.setAclCapabilities(convert(repositoryInfo.getAclCapability()));
265 result.setChangesIncomplete(repositoryInfo.isChangesIncomplete());
266 List<BaseTypeId> baseObjectTypeIds = new ArrayList<BaseTypeId>();
267 for (EnumBaseObjectTypeIds bot : repositoryInfo.getChangesOnType()) {
268 baseObjectTypeIds.add(convert(BaseTypeId.class, bot));
269 }
270 result.setChangesOnType(baseObjectTypeIds);
271 result.setCmisVersionSupported(repositoryInfo.getCmisVersionSupported());
272 result.setLatestChangeLogToken(repositoryInfo.getLatestChangeLogToken());
273 result.setPrincipalAnonymous(repositoryInfo.getPrincipalAnonymous());
274 result.setPrincipalAnyone(repositoryInfo.getPrincipalAnyone());
275 result.setProductName(repositoryInfo.getProductName());
276 result.setProductVersion(repositoryInfo.getProductVersion());
277 result.setCapabilities(convert(repositoryInfo.getCapabilities()));
278 result.setDescription(repositoryInfo.getRepositoryDescription());
279 result.setId(repositoryInfo.getRepositoryId());
280 result.setName(repositoryInfo.getRepositoryName());
281 result.setRootFolder(repositoryInfo.getRootFolderId());
282 result.setThinClientUri(repositoryInfo.getThinClientURI());
283 result.setVendorName(repositoryInfo.getVendorName());
284
285
286 convertExtension(repositoryInfo, result);
287
288 return result;
289 }
290
291
292
293
294 public static RepositoryCapabilities convert(CmisRepositoryCapabilitiesType capabilities) {
295 if (capabilities == null) {
296 return null;
297 }
298
299 RepositoryCapabilitiesImpl result = new RepositoryCapabilitiesImpl();
300
301 result.setAllVersionsSearchable(capabilities.isCapabilityAllVersionsSearchable());
302 result.setCapabilityAcl(convert(CapabilityAcl.class, capabilities.getCapabilityACL()));
303 result.setCapabilityChanges(convert(CapabilityChanges.class, capabilities.getCapabilityChanges()));
304 result.setCapabilityContentStreamUpdates(convert(CapabilityContentStreamUpdates.class,
305 capabilities.getCapabilityContentStreamUpdatability()));
306 result.setCapabilityJoin(convert(CapabilityJoin.class, capabilities.getCapabilityJoin()));
307 result.setCapabilityQuery(convert(CapabilityQuery.class, capabilities.getCapabilityQuery()));
308 result.setCapabilityRendition(convert(CapabilityRenditions.class, capabilities.getCapabilityRenditions()));
309 result.setIsPwcSearchable(capabilities.isCapabilityPWCSearchable());
310 result.setIsPwcUpdatable(capabilities.isCapabilityPWCUpdatable());
311 result.setSupportsGetDescendants(capabilities.isCapabilityGetDescendants());
312 result.setSupportsGetFolderTree(capabilities.isCapabilityGetFolderTree());
313 result.setSupportsMultifiling(capabilities.isCapabilityMultifiling());
314 result.setSupportsUnfiling(capabilities.isCapabilityUnfiling());
315 result.setSupportsVersionSpecificFiling(capabilities.isCapabilityVersionSpecificFiling());
316
317
318 convertExtension(capabilities, result);
319
320 return result;
321 }
322
323
324
325
326 public static AclCapabilities convert(CmisACLCapabilityType aclCapabilities) {
327 if (aclCapabilities == null) {
328 return null;
329 }
330
331 AclCapabilitiesDataImpl result = new AclCapabilitiesDataImpl();
332
333 result.setSupportedPermissions(convert(SupportedPermissions.class, aclCapabilities.getSupportedPermissions()));
334
335 result.setAclPropagation(convert(AclPropagation.class, aclCapabilities.getPropagation()));
336
337 List<PermissionDefinition> permissionDefinitionList = new ArrayList<PermissionDefinition>();
338 for (CmisPermissionDefinition permDef : aclCapabilities.getPermissions()) {
339 PermissionDefinitionDataImpl permDefData = new PermissionDefinitionDataImpl();
340 permDefData.setPermission(permDef.getPermission());
341 permDefData.setDescription(permDef.getDescription());
342 convertExtension(permDef, permDefData);
343
344 permissionDefinitionList.add(permDefData);
345 }
346 result.setPermissionDefinitionData(permissionDefinitionList);
347
348 Map<String, PermissionMapping> permissionMapping = new LinkedHashMap<String, PermissionMapping>();
349 for (CmisPermissionMapping permMapping : aclCapabilities.getMapping()) {
350 if (permMapping.getKey() != null) {
351 PermissionMappingDataImpl permMappingData = new PermissionMappingDataImpl();
352 String key = permMapping.getKey().value();
353 permMappingData.setKey(key);
354 permMappingData.setPermissions(permMapping.getPermission());
355 convertExtension(permMapping, permMappingData);
356 permissionMapping.put(key, permMappingData);
357 }
358 }
359 result.setPermissionMappingData(permissionMapping);
360
361
362 convertExtension(aclCapabilities, result);
363
364 return result;
365 }
366
367
368
369
370 public static CmisRepositoryInfoType convert(RepositoryInfo repositoryInfo) {
371 if (repositoryInfo == null) {
372 return null;
373 }
374
375 CmisRepositoryInfoType result = new CmisRepositoryInfoType();
376
377 result.setAclCapability(convert(repositoryInfo.getAclCapabilities()));
378 result.setCapabilities(convert(repositoryInfo.getCapabilities()));
379 result.setChangesIncomplete(repositoryInfo.getChangesIncomplete());
380 result.setCmisVersionSupported(repositoryInfo.getCmisVersionSupported());
381 result.setLatestChangeLogToken(repositoryInfo.getLatestChangeLogToken());
382 result.setPrincipalAnonymous(repositoryInfo.getPrincipalIdAnonymous());
383 result.setPrincipalAnyone(repositoryInfo.getPrincipalIdAnyone());
384 result.setProductName(repositoryInfo.getProductName());
385 result.setProductVersion(repositoryInfo.getProductVersion());
386 result.setRepositoryDescription(repositoryInfo.getDescription());
387 result.setRepositoryId(repositoryInfo.getId());
388 result.setRepositoryName(repositoryInfo.getName());
389 result.setRootFolderId(repositoryInfo.getRootFolderId());
390 result.setThinClientURI(repositoryInfo.getThinClientUri());
391 result.setVendorName(repositoryInfo.getVendorName());
392
393 if (repositoryInfo.getChangesOnType() != null) {
394 for (BaseTypeId boti : repositoryInfo.getChangesOnType()) {
395 result.getChangesOnType().add(convert(EnumBaseObjectTypeIds.class, boti));
396 }
397 }
398
399
400 convertExtension(repositoryInfo, result);
401
402 return result;
403 }
404
405
406
407
408 public static CmisRepositoryCapabilitiesType convert(RepositoryCapabilities capabilities) {
409 if (capabilities == null) {
410 return null;
411 }
412
413 CmisRepositoryCapabilitiesType result = new CmisRepositoryCapabilitiesType();
414
415 result.setCapabilityACL(convert(EnumCapabilityACL.class, capabilities.getAclCapability()));
416 result.setCapabilityAllVersionsSearchable(capabilities.isAllVersionsSearchableSupported());
417 result.setCapabilityChanges(convert(EnumCapabilityChanges.class, capabilities.getChangesCapability()));
418 result.setCapabilityContentStreamUpdatability(convert(EnumCapabilityContentStreamUpdates.class,
419 capabilities.getContentStreamUpdatesCapability()));
420 result.setCapabilityGetDescendants(capabilities.isGetDescendantsSupported());
421 result.setCapabilityGetFolderTree(capabilities.isGetFolderTreeSupported());
422 result.setCapabilityJoin(convert(EnumCapabilityJoin.class, capabilities.getJoinCapability()));
423 result.setCapabilityMultifiling(capabilities.isMultifilingSupported());
424 result.setCapabilityPWCSearchable(capabilities.isPwcSearchableSupported());
425 result.setCapabilityPWCUpdatable(capabilities.isPwcUpdatableSupported());
426 result.setCapabilityQuery(convert(EnumCapabilityQuery.class, capabilities.getQueryCapability()));
427 result.setCapabilityRenditions(convert(EnumCapabilityRendition.class, capabilities.getRenditionsCapability()));
428 result.setCapabilityUnfiling(capabilities.isUnfilingSupported());
429 result.setCapabilityVersionSpecificFiling(capabilities.isVersionSpecificFilingSupported());
430
431
432 convertExtension(capabilities, result);
433
434 return result;
435 }
436
437
438
439
440 public static CmisACLCapabilityType convert(AclCapabilities aclCapabilities) {
441 if (aclCapabilities == null) {
442 return null;
443 }
444
445 CmisACLCapabilityType result = new CmisACLCapabilityType();
446
447 result.setSupportedPermissions(convert(EnumSupportedPermissions.class,
448 aclCapabilities.getSupportedPermissions()));
449
450 result.setPropagation(convert(EnumACLPropagation.class, aclCapabilities.getAclPropagation()));
451
452 if (aclCapabilities.getPermissions() != null) {
453 for (PermissionDefinition pdd : aclCapabilities.getPermissions()) {
454 CmisPermissionDefinition permDef = new CmisPermissionDefinition();
455 permDef.setDescription(pdd.getDescription());
456 permDef.setPermission(pdd.getId());
457 convertExtension(pdd, permDef);
458
459 result.getPermissions().add(permDef);
460 }
461 }
462
463 if (aclCapabilities.getPermissionMapping() != null) {
464 for (PermissionMapping pmd : aclCapabilities.getPermissionMapping().values()) {
465 CmisPermissionMapping permMap = new CmisPermissionMapping();
466 permMap.setKey(EnumAllowableActionsKey.fromValue(pmd.getKey()));
467
468 if (pmd.getPermissions() != null) {
469 for (String permission : pmd.getPermissions()) {
470 permMap.getPermission().add(permission);
471 }
472 }
473
474 convertExtension(pmd, permMap);
475
476 result.getMapping().add(permMap);
477 }
478 }
479
480
481 convertExtension(aclCapabilities, result);
482
483 return result;
484 }
485
486
487
488
489
490
491
492
493 public static TypeDefinition convert(CmisTypeDefinitionType typeDefinition) {
494 if (typeDefinition == null) {
495 return null;
496 }
497
498 AbstractTypeDefinition result = null;
499
500 if (typeDefinition instanceof CmisTypeFolderDefinitionType) {
501 result = new FolderTypeDefinitionImpl();
502 } else if (typeDefinition instanceof CmisTypeDocumentDefinitionType) {
503 result = new DocumentTypeDefinitionImpl();
504
505 ((DocumentTypeDefinitionImpl) result).setContentStreamAllowed(convert(ContentStreamAllowed.class,
506 ((CmisTypeDocumentDefinitionType) typeDefinition).getContentStreamAllowed()));
507 ((DocumentTypeDefinitionImpl) result).setIsVersionable(((CmisTypeDocumentDefinitionType) typeDefinition)
508 .isVersionable());
509 } else if (typeDefinition instanceof CmisTypeRelationshipDefinitionType) {
510 result = new RelationshipTypeDefinitionImpl();
511
512 ((RelationshipTypeDefinitionImpl) result)
513 .setAllowedSourceTypes(((CmisTypeRelationshipDefinitionType) typeDefinition)
514 .getAllowedSourceTypes());
515 ((RelationshipTypeDefinitionImpl) result)
516 .setAllowedTargetTypes(((CmisTypeRelationshipDefinitionType) typeDefinition)
517 .getAllowedTargetTypes());
518 } else if (typeDefinition instanceof CmisTypePolicyDefinitionType) {
519 result = new PolicyTypeDefinitionImpl();
520 } else {
521 throw new CmisRuntimeException("Type '" + typeDefinition.getId() + "' does not match a base type!");
522 }
523
524 result.setBaseTypeId(convert(BaseTypeId.class, typeDefinition.getBaseId()));
525 result.setDescription(typeDefinition.getDescription());
526 result.setDisplayName(typeDefinition.getDisplayName());
527 result.setId(typeDefinition.getId());
528 result.setIsControllableAcl(typeDefinition.isControllableACL());
529 result.setIsControllablePolicy(typeDefinition.isControllablePolicy());
530 result.setIsCreatable(typeDefinition.isCreatable());
531 result.setIsFileable(typeDefinition.isFileable());
532 result.setIsFulltextIndexed(typeDefinition.isFulltextIndexed());
533 result.setIsIncludedInSupertypeQuery(typeDefinition.isIncludedInSupertypeQuery());
534 result.setIsQueryable(typeDefinition.isQueryable());
535 result.setLocalName(typeDefinition.getLocalName());
536 result.setLocalNamespace(typeDefinition.getLocalNamespace());
537 result.setParentTypeId(typeDefinition.getParentId());
538 result.setQueryName(typeDefinition.getQueryName());
539
540 for (CmisPropertyDefinitionType propertyDefinition : typeDefinition.getPropertyDefinition()) {
541 result.addPropertyDefinition(convert(propertyDefinition));
542 }
543
544
545 convertExtension(typeDefinition, result);
546
547 return result;
548 }
549
550
551
552
553 public static PropertyDefinition<?> convert(CmisPropertyDefinitionType propertyDefinition) {
554 if (propertyDefinition == null) {
555 return null;
556 }
557
558 AbstractPropertyDefinition<?> result = null;
559
560 if (propertyDefinition instanceof CmisPropertyStringDefinitionType) {
561 result = new PropertyStringDefinitionImpl();
562
563 ((PropertyStringDefinitionImpl) result)
564 .setChoices(convertChoiceStringList(((CmisPropertyStringDefinitionType) propertyDefinition)
565 .getChoice()));
566
567 CmisPropertyString prop = ((CmisPropertyStringDefinitionType) propertyDefinition).getDefaultValue();
568 if (prop != null) {
569 ((PropertyStringDefinitionImpl) result).setDefaultValue(prop.getValue());
570 }
571
572
573 ((PropertyStringDefinitionImpl) result)
574 .setMaxLength(((CmisPropertyStringDefinitionType) propertyDefinition).getMaxLength());
575 } else if (propertyDefinition instanceof CmisPropertyIdDefinitionType) {
576 result = new PropertyIdDefinitionImpl();
577
578 ((PropertyIdDefinitionImpl) result)
579 .setChoices(convertChoiceIdList(((CmisPropertyIdDefinitionType) propertyDefinition).getChoice()));
580
581 CmisPropertyId prop = ((CmisPropertyIdDefinitionType) propertyDefinition).getDefaultValue();
582 if (prop != null) {
583 ((PropertyIdDefinitionImpl) result).setDefaultValue(prop.getValue());
584 }
585 } else if (propertyDefinition instanceof CmisPropertyIntegerDefinitionType) {
586 result = new PropertyIntegerDefinitionImpl();
587
588 ((PropertyIntegerDefinitionImpl) result)
589 .setChoices(convertChoiceIntegerList(((CmisPropertyIntegerDefinitionType) propertyDefinition)
590 .getChoice()));
591
592 CmisPropertyInteger prop = ((CmisPropertyIntegerDefinitionType) propertyDefinition).getDefaultValue();
593 if (prop != null) {
594 ((PropertyIntegerDefinitionImpl) result).setDefaultValue(prop.getValue());
595 }
596
597
598 ((PropertyIntegerDefinitionImpl) result)
599 .setMinValue(((CmisPropertyIntegerDefinitionType) propertyDefinition).getMinValue());
600 ((PropertyIntegerDefinitionImpl) result)
601 .setMaxValue(((CmisPropertyIntegerDefinitionType) propertyDefinition).getMaxValue());
602 } else if (propertyDefinition instanceof CmisPropertyDecimalDefinitionType) {
603 result = new PropertyDecimalDefinitionImpl();
604
605 ((PropertyDecimalDefinitionImpl) result)
606 .setChoices(convertChoiceDecimalList(((CmisPropertyDecimalDefinitionType) propertyDefinition)
607 .getChoice()));
608
609 CmisPropertyDecimal prop = ((CmisPropertyDecimalDefinitionType) propertyDefinition).getDefaultValue();
610 if (prop != null) {
611 ((PropertyDecimalDefinitionImpl) result).setDefaultValue(prop.getValue());
612 }
613
614
615 ((PropertyDecimalDefinitionImpl) result)
616 .setMinValue(((CmisPropertyDecimalDefinitionType) propertyDefinition).getMinValue());
617 ((PropertyDecimalDefinitionImpl) result)
618 .setMaxValue(((CmisPropertyDecimalDefinitionType) propertyDefinition).getMaxValue());
619
620 } else if (propertyDefinition instanceof CmisPropertyBooleanDefinitionType) {
621 result = new PropertyBooleanDefinitionImpl();
622
623 ((PropertyBooleanDefinitionImpl) result)
624 .setChoices(convertChoiceBooleanList(((CmisPropertyBooleanDefinitionType) propertyDefinition)
625 .getChoice()));
626
627 CmisPropertyBoolean prop = ((CmisPropertyBooleanDefinitionType) propertyDefinition).getDefaultValue();
628 if (prop != null) {
629 ((PropertyBooleanDefinitionImpl) result).setDefaultValue(prop.getValue());
630 }
631 } else if (propertyDefinition instanceof CmisPropertyDateTimeDefinitionType) {
632 result = new PropertyDateTimeDefinitionImpl();
633
634 ((PropertyDateTimeDefinitionImpl) result)
635 .setChoices(convertChoiceDateTimeList(((CmisPropertyDateTimeDefinitionType) propertyDefinition)
636 .getChoice()));
637
638 CmisPropertyDateTime prop = ((CmisPropertyDateTimeDefinitionType) propertyDefinition).getDefaultValue();
639 if (prop != null) {
640 ((PropertyDateTimeDefinitionImpl) result).setDefaultValue(convertXMLCalendar(prop.getValue()));
641 }
642
643
644 ((PropertyDateTimeDefinitionImpl) result).setDateTimeResolution(convert(DateTimeResolution.class,
645 ((CmisPropertyDateTimeDefinitionType) propertyDefinition).getResolution()));
646 } else if (propertyDefinition instanceof CmisPropertyHtmlDefinitionType) {
647 result = new PropertyHtmlDefinitionImpl();
648
649 ((PropertyHtmlDefinitionImpl) result)
650 .setChoices(convertChoiceHtmlList(((CmisPropertyHtmlDefinitionType) propertyDefinition).getChoice()));
651
652 CmisPropertyHtml prop = ((CmisPropertyHtmlDefinitionType) propertyDefinition).getDefaultValue();
653 if (prop != null) {
654 ((PropertyHtmlDefinitionImpl) result).setDefaultValue(prop.getValue());
655 }
656 } else if (propertyDefinition instanceof CmisPropertyUriDefinitionType) {
657 result = new PropertyUriDefinitionImpl();
658
659 ((PropertyUriDefinitionImpl) result)
660 .setChoices(convertChoiceUriList(((CmisPropertyUriDefinitionType) propertyDefinition).getChoice()));
661
662 CmisPropertyUri prop = ((CmisPropertyUriDefinitionType) propertyDefinition).getDefaultValue();
663 if (prop != null) {
664 ((PropertyUriDefinitionImpl) result).setDefaultValue(prop.getValue());
665 }
666 } else {
667 return null;
668 }
669
670 result.setCardinality(convert(Cardinality.class, propertyDefinition.getCardinality()));
671 result.setDescription(propertyDefinition.getDescription());
672 result.setDisplayName(propertyDefinition.getDisplayName());
673 result.setId(propertyDefinition.getId());
674 result.setIsInherited(propertyDefinition.isInherited());
675 result.setIsOpenChoice(propertyDefinition.isOpenChoice());
676 result.setIsQueryable(propertyDefinition.isQueryable());
677 result.setIsOrderable(propertyDefinition.isOrderable());
678 result.setIsRequired(propertyDefinition.isRequired());
679 result.setLocalName(propertyDefinition.getLocalName());
680 result.setLocalNamespace(propertyDefinition.getLocalNamespace());
681 result.setPropertyType(convert(PropertyType.class, propertyDefinition.getPropertyType()));
682 result.setQueryName(propertyDefinition.getQueryName());
683 result.setUpdatability(convert(Updatability.class, propertyDefinition.getUpdatability()));
684
685
686 convertExtension(propertyDefinition, result);
687
688 return result;
689 }
690
691
692
693
694 public static CmisTypeDefinitionType convert(TypeDefinition typeDefinition) {
695 if (typeDefinition == null) {
696 return null;
697 }
698
699 CmisTypeDefinitionType result = null;
700
701 if (typeDefinition instanceof DocumentTypeDefinition) {
702 result = new CmisTypeDocumentDefinitionType();
703
704 DocumentTypeDefinition docTypeDefintion = (DocumentTypeDefinition) typeDefinition;
705 ((CmisTypeDocumentDefinitionType) result).setVersionable(convertBoolean(docTypeDefintion.isVersionable(),
706 false));
707 ((CmisTypeDocumentDefinitionType) result).setContentStreamAllowed(convert(EnumContentStreamAllowed.class,
708 docTypeDefintion.getContentStreamAllowed()));
709 } else if (typeDefinition instanceof FolderTypeDefinition) {
710 result = new CmisTypeFolderDefinitionType();
711 } else if (typeDefinition instanceof RelationshipTypeDefinition) {
712 result = new CmisTypeRelationshipDefinitionType();
713
714 RelationshipTypeDefinition relationshipTypeDefinition = (RelationshipTypeDefinition) typeDefinition;
715
716 if (relationshipTypeDefinition.getAllowedSourceTypeIds() != null) {
717 for (String type : relationshipTypeDefinition.getAllowedSourceTypeIds()) {
718 ((CmisTypeRelationshipDefinitionType) result).getAllowedSourceTypes().add(type);
719 }
720 }
721
722 if (relationshipTypeDefinition.getAllowedTargetTypeIds() != null) {
723 for (String type : relationshipTypeDefinition.getAllowedTargetTypeIds()) {
724 ((CmisTypeRelationshipDefinitionType) result).getAllowedTargetTypes().add(type);
725 }
726 }
727 } else if (typeDefinition instanceof PolicyTypeDefinition) {
728 result = new CmisTypePolicyDefinitionType();
729 } else {
730 return null;
731 }
732
733 result.setBaseId(convert(EnumBaseObjectTypeIds.class, typeDefinition.getBaseTypeId()));
734 result.setControllableACL(convertBoolean(typeDefinition.isControllableAcl(), false));
735 result.setControllablePolicy(convertBoolean(typeDefinition.isControllablePolicy(), false));
736 result.setCreatable(convertBoolean(typeDefinition.isCreatable(), false));
737 result.setDescription(typeDefinition.getDescription());
738 result.setDisplayName(typeDefinition.getDisplayName());
739 result.setFileable(convertBoolean(typeDefinition.isFileable(), false));
740 result.setFulltextIndexed(convertBoolean(typeDefinition.isFulltextIndexed(), false));
741 result.setId(typeDefinition.getId());
742 result.setIncludedInSupertypeQuery(convertBoolean(typeDefinition.isIncludedInSupertypeQuery(), false));
743 result.setLocalName(typeDefinition.getLocalName());
744 result.setLocalNamespace(typeDefinition.getLocalNamespace());
745 result.setParentId(typeDefinition.getParentTypeId());
746 result.setQueryable(convertBoolean(typeDefinition.isQueryable(), false));
747 result.setQueryName(typeDefinition.getQueryName());
748
749 if (typeDefinition.getPropertyDefinitions() != null) {
750 for (PropertyDefinition<?> propDef : typeDefinition.getPropertyDefinitions().values()) {
751 result.getPropertyDefinition().add(convert(propDef));
752 }
753 }
754
755
756 convertExtension(typeDefinition, result);
757
758 return result;
759 }
760
761
762
763
764 public static CmisPropertyDefinitionType convert(PropertyDefinition<?> propertyDefinition) {
765 if (propertyDefinition == null) {
766 return null;
767 }
768
769 CmisPropertyDefinitionType result = null;
770
771 if (propertyDefinition instanceof PropertyStringDefinition) {
772 result = new CmisPropertyStringDefinitionType();
773
774 PropertyStringDefinition source = (PropertyStringDefinition) propertyDefinition;
775 CmisPropertyStringDefinitionType target = (CmisPropertyStringDefinitionType) result;
776
777 convertChoiceStringList(source.getChoices(), target.getChoice());
778
779 if (source.getDefaultValue() != null) {
780 CmisPropertyString defaultValue = new CmisPropertyString();
781 defaultValue.setPropertyDefinitionId(propertyDefinition.getId());
782 for (String value : source.getDefaultValue()) {
783 defaultValue.getValue().add(value);
784 }
785 target.setDefaultValue(defaultValue);
786 }
787
788
789 target.setMaxLength(source.getMaxLength());
790 } else if (propertyDefinition instanceof PropertyIdDefinition) {
791 result = new CmisPropertyIdDefinitionType();
792
793 PropertyIdDefinition source = (PropertyIdDefinition) propertyDefinition;
794 CmisPropertyIdDefinitionType target = (CmisPropertyIdDefinitionType) result;
795
796 convertChoiceIdList(source.getChoices(), target.getChoice());
797
798 if (source.getDefaultValue() != null) {
799 CmisPropertyId defaultValue = new CmisPropertyId();
800 defaultValue.setPropertyDefinitionId(propertyDefinition.getId());
801 for (String value : source.getDefaultValue()) {
802 defaultValue.getValue().add(value);
803 }
804 target.setDefaultValue(defaultValue);
805 }
806 } else if (propertyDefinition instanceof PropertyIntegerDefinition) {
807 result = new CmisPropertyIntegerDefinitionType();
808
809 PropertyIntegerDefinition source = (PropertyIntegerDefinition) propertyDefinition;
810 CmisPropertyIntegerDefinitionType target = (CmisPropertyIntegerDefinitionType) result;
811
812 convertChoiceIntegerList(source.getChoices(), target.getChoice());
813
814 if (source.getDefaultValue() != null) {
815 CmisPropertyInteger defaultValue = new CmisPropertyInteger();
816 defaultValue.setPropertyDefinitionId(propertyDefinition.getId());
817 for (BigInteger value : source.getDefaultValue()) {
818 defaultValue.getValue().add(value);
819 }
820 target.setDefaultValue(defaultValue);
821 }
822
823
824 target.setMinValue(source.getMinValue());
825 target.setMaxValue(source.getMaxValue());
826 } else if (propertyDefinition instanceof PropertyDecimalDefinition) {
827 result = new CmisPropertyDecimalDefinitionType();
828
829 PropertyDecimalDefinition source = (PropertyDecimalDefinition) propertyDefinition;
830 CmisPropertyDecimalDefinitionType target = (CmisPropertyDecimalDefinitionType) result;
831
832 convertChoiceDecimalList(source.getChoices(), target.getChoice());
833
834 if (source.getDefaultValue() != null) {
835 CmisPropertyDecimal defaultValue = new CmisPropertyDecimal();
836 defaultValue.setPropertyDefinitionId(propertyDefinition.getId());
837 for (BigDecimal value : source.getDefaultValue()) {
838 defaultValue.getValue().add(value);
839 }
840 target.setDefaultValue(defaultValue);
841 }
842
843
844 target.setMinValue(source.getMinValue());
845 target.setMaxValue(source.getMaxValue());
846 if (source.getPrecision() != null) {
847 target.setPrecision(source.getPrecision().value());
848 }
849 } else if (propertyDefinition instanceof PropertyBooleanDefinition) {
850 result = new CmisPropertyBooleanDefinitionType();
851
852 PropertyBooleanDefinition source = (PropertyBooleanDefinition) propertyDefinition;
853 CmisPropertyBooleanDefinitionType target = (CmisPropertyBooleanDefinitionType) result;
854
855 convertChoiceBooleanList(source.getChoices(), target.getChoice());
856
857 if (source.getDefaultValue() != null) {
858 CmisPropertyBoolean defaultValue = new CmisPropertyBoolean();
859 defaultValue.setPropertyDefinitionId(propertyDefinition.getId());
860 for (Boolean value : source.getDefaultValue()) {
861 defaultValue.getValue().add(value);
862 }
863 target.setDefaultValue(defaultValue);
864 }
865 } else if (propertyDefinition instanceof PropertyDateTimeDefinition) {
866 result = new CmisPropertyDateTimeDefinitionType();
867
868 PropertyDateTimeDefinition source = (PropertyDateTimeDefinition) propertyDefinition;
869 CmisPropertyDateTimeDefinitionType target = (CmisPropertyDateTimeDefinitionType) result;
870
871 convertChoiceDateTimeList(source.getChoices(), target.getChoice());
872
873 if (source.getDefaultValue() != null) {
874 CmisPropertyDateTime defaultValue = new CmisPropertyDateTime();
875 defaultValue.setPropertyDefinitionId(propertyDefinition.getId());
876 for (XMLGregorianCalendar value : convertCalendar(source.getDefaultValue())) {
877 defaultValue.getValue().add(value);
878 }
879 target.setDefaultValue(defaultValue);
880 }
881
882
883 target.setResolution(convert(EnumDateTimeResolution.class, source.getDateTimeResolution()));
884 } else if (propertyDefinition instanceof PropertyHtmlDefinition) {
885 result = new CmisPropertyHtmlDefinitionType();
886
887 PropertyHtmlDefinition source = (PropertyHtmlDefinition) propertyDefinition;
888 CmisPropertyHtmlDefinitionType target = (CmisPropertyHtmlDefinitionType) result;
889
890 convertChoiceHtmlList(source.getChoices(), target.getChoice());
891
892 if (source.getDefaultValue() != null) {
893 CmisPropertyHtml defaultValue = new CmisPropertyHtml();
894 defaultValue.setPropertyDefinitionId(propertyDefinition.getId());
895 for (String value : source.getDefaultValue()) {
896 defaultValue.getValue().add(value);
897 }
898 target.setDefaultValue(defaultValue);
899 }
900 } else if (propertyDefinition instanceof PropertyUriDefinition) {
901 result = new CmisPropertyUriDefinitionType();
902
903 PropertyUriDefinition source = (PropertyUriDefinition) propertyDefinition;
904 CmisPropertyUriDefinitionType target = (CmisPropertyUriDefinitionType) result;
905
906 convertChoiceUriList(source.getChoices(), target.getChoice());
907
908 if (source.getDefaultValue() != null) {
909 CmisPropertyUri defaultValue = new CmisPropertyUri();
910 defaultValue.setPropertyDefinitionId(propertyDefinition.getId());
911 for (String value : source.getDefaultValue()) {
912 defaultValue.getValue().add(value);
913 }
914 target.setDefaultValue(defaultValue);
915 }
916 } else {
917 return null;
918 }
919
920 result.setCardinality(convert(EnumCardinality.class, propertyDefinition.getCardinality()));
921 result.setDescription(propertyDefinition.getDescription());
922 result.setDisplayName(propertyDefinition.getDisplayName());
923 result.setId(propertyDefinition.getId());
924 result.setInherited(propertyDefinition.isInherited());
925 result.setLocalName(propertyDefinition.getLocalName());
926 result.setLocalNamespace(propertyDefinition.getLocalNamespace());
927 result.setOpenChoice(propertyDefinition.isOpenChoice());
928 result.setOrderable(convertBoolean(propertyDefinition.isOrderable(), false));
929 result.setPropertyType(convert(EnumPropertyType.class, propertyDefinition.getPropertyType()));
930 result.setQueryable(convertBoolean(propertyDefinition.isQueryable(), false));
931 result.setQueryName(propertyDefinition.getQueryName());
932 result.setRequired(convertBoolean(propertyDefinition.isRequired(), false));
933 result.setUpdatability(convert(EnumUpdatability.class, propertyDefinition.getUpdatability()));
934
935
936 convertExtension(propertyDefinition, result);
937
938 return result;
939 }
940
941
942
943
944
945
946
947
948 private static List<Choice<String>> convertChoiceStringList(List<CmisChoiceString> choices) {
949 if (choices == null) {
950 return null;
951 }
952
953 List<Choice<String>> result = new ArrayList<Choice<String>>();
954
955 for (CmisChoiceString choice : choices) {
956 ChoiceImpl<String> newChoice = new ChoiceImpl<String>();
957
958 newChoice.setChoice(convertChoiceStringList(choice.getChoice()));
959 newChoice.setDisplayName(choice.getDisplayName());
960 newChoice.setValue(choice.getValue());
961
962 result.add(newChoice);
963 }
964
965 return result;
966 }
967
968
969
970
971 private static void convertChoiceStringList(List<Choice<String>> choices, List<CmisChoiceString> target) {
972 if (choices == null) {
973 return;
974 }
975
976 for (Choice<String> choice : choices) {
977 CmisChoiceString newChoice = new CmisChoiceString();
978
979 convertChoiceStringList(choice.getChoice(), newChoice.getChoice());
980 newChoice.setDisplayName(choice.getDisplayName());
981
982 if (choice.getValue() != null) {
983 for (String value : choice.getValue()) {
984 newChoice.getValue().add(value);
985 }
986 }
987
988 target.add(newChoice);
989 }
990 }
991
992
993
994
995 private static List<Choice<String>> convertChoiceIdList(List<CmisChoiceId> choices) {
996 if (choices == null) {
997 return null;
998 }
999
1000 List<Choice<String>> result = new ArrayList<Choice<String>>();
1001
1002 for (CmisChoiceId choice : choices) {
1003 ChoiceImpl<String> newChoice = new ChoiceImpl<String>();
1004
1005 newChoice.setChoice(convertChoiceIdList(choice.getChoice()));
1006 newChoice.setDisplayName(choice.getDisplayName());
1007 newChoice.setValue(choice.getValue());
1008
1009 result.add(newChoice);
1010 }
1011
1012 return result;
1013 }
1014
1015
1016
1017
1018 private static void convertChoiceIdList(List<Choice<String>> choices, List<CmisChoiceId> target) {
1019 if (choices == null) {
1020 return;
1021 }
1022
1023 for (Choice<String> choice : choices) {
1024 CmisChoiceId newChoice = new CmisChoiceId();
1025
1026 convertChoiceIdList(choice.getChoice(), newChoice.getChoice());
1027 newChoice.setDisplayName(choice.getDisplayName());
1028
1029 if (choice.getValue() != null) {
1030 for (String value : choice.getValue()) {
1031 newChoice.getValue().add(value);
1032 }
1033 }
1034
1035 target.add(newChoice);
1036 }
1037 }
1038
1039
1040
1041
1042 private static List<Choice<BigInteger>> convertChoiceIntegerList(List<CmisChoiceInteger> choices) {
1043 if (choices == null) {
1044 return null;
1045 }
1046
1047 List<Choice<BigInteger>> result = new ArrayList<Choice<BigInteger>>();
1048
1049 for (CmisChoiceInteger choice : choices) {
1050 ChoiceImpl<BigInteger> newChoice = new ChoiceImpl<BigInteger>();
1051
1052 newChoice.setChoice(convertChoiceIntegerList(choice.getChoice()));
1053 newChoice.setDisplayName(choice.getDisplayName());
1054 newChoice.setValue(choice.getValue());
1055
1056 result.add(newChoice);
1057 }
1058
1059 return result;
1060 }
1061
1062
1063
1064
1065 private static void convertChoiceIntegerList(List<Choice<BigInteger>> choices, List<CmisChoiceInteger> target) {
1066 if (choices == null) {
1067 return;
1068 }
1069
1070 for (Choice<BigInteger> choice : choices) {
1071 CmisChoiceInteger newChoice = new CmisChoiceInteger();
1072
1073 convertChoiceIntegerList(choice.getChoice(), newChoice.getChoice());
1074 newChoice.setDisplayName(choice.getDisplayName());
1075
1076 if (choice.getValue() != null) {
1077 for (BigInteger value : choice.getValue()) {
1078 newChoice.getValue().add(value);
1079 }
1080 }
1081
1082 target.add(newChoice);
1083 }
1084 }
1085
1086
1087
1088
1089 private static List<Choice<BigDecimal>> convertChoiceDecimalList(List<CmisChoiceDecimal> choices) {
1090 if (choices == null) {
1091 return null;
1092 }
1093
1094 List<Choice<BigDecimal>> result = new ArrayList<Choice<BigDecimal>>();
1095
1096 for (CmisChoiceDecimal choice : choices) {
1097 ChoiceImpl<BigDecimal> newChoice = new ChoiceImpl<BigDecimal>();
1098
1099 newChoice.setChoice(convertChoiceDecimalList(choice.getChoice()));
1100 newChoice.setDisplayName(choice.getDisplayName());
1101 newChoice.setValue(choice.getValue());
1102
1103 result.add(newChoice);
1104 }
1105
1106 return result;
1107 }
1108
1109
1110
1111
1112 private static void convertChoiceDecimalList(List<Choice<BigDecimal>> choices, List<CmisChoiceDecimal> target) {
1113 if (choices == null) {
1114 return;
1115 }
1116
1117 for (Choice<BigDecimal> choice : choices) {
1118 CmisChoiceDecimal newChoice = new CmisChoiceDecimal();
1119
1120 convertChoiceDecimalList(choice.getChoice(), newChoice.getChoice());
1121 newChoice.setDisplayName(choice.getDisplayName());
1122
1123 if (choice.getValue() != null) {
1124 for (BigDecimal value : choice.getValue()) {
1125 newChoice.getValue().add(value);
1126 }
1127 }
1128
1129 target.add(newChoice);
1130 }
1131 }
1132
1133
1134
1135
1136 private static List<Choice<Boolean>> convertChoiceBooleanList(List<CmisChoiceBoolean> choices) {
1137 if (choices == null) {
1138 return null;
1139 }
1140
1141 List<Choice<Boolean>> result = new ArrayList<Choice<Boolean>>();
1142
1143 for (CmisChoiceBoolean choice : choices) {
1144 ChoiceImpl<Boolean> newChoice = new ChoiceImpl<Boolean>();
1145
1146 newChoice.setChoice(convertChoiceBooleanList(choice.getChoice()));
1147 newChoice.setDisplayName(choice.getDisplayName());
1148 newChoice.setValue(choice.getValue());
1149
1150 result.add(newChoice);
1151 }
1152
1153 return result;
1154 }
1155
1156
1157
1158
1159 private static void convertChoiceBooleanList(List<Choice<Boolean>> choices, List<CmisChoiceBoolean> target) {
1160 if (choices == null) {
1161 return;
1162 }
1163
1164 for (Choice<Boolean> choice : choices) {
1165 CmisChoiceBoolean newChoice = new CmisChoiceBoolean();
1166
1167 convertChoiceBooleanList(choice.getChoice(), newChoice.getChoice());
1168 newChoice.setDisplayName(choice.getDisplayName());
1169
1170 if (choice.getValue() != null) {
1171 for (Boolean value : choice.getValue()) {
1172 newChoice.getValue().add(value);
1173 }
1174 }
1175
1176 target.add(newChoice);
1177 }
1178 }
1179
1180
1181
1182
1183 private static List<Choice<GregorianCalendar>> convertChoiceDateTimeList(List<CmisChoiceDateTime> choices) {
1184 if (choices == null) {
1185 return null;
1186 }
1187
1188 List<Choice<GregorianCalendar>> result = new ArrayList<Choice<GregorianCalendar>>();
1189
1190 for (CmisChoiceDateTime choice : choices) {
1191 ChoiceImpl<GregorianCalendar> newChoice = new ChoiceImpl<GregorianCalendar>();
1192
1193 newChoice.setChoice(convertChoiceDateTimeList(choice.getChoice()));
1194 newChoice.setDisplayName(choice.getDisplayName());
1195 newChoice.setValue(convertXMLCalendar(choice.getValue()));
1196
1197 result.add(newChoice);
1198 }
1199
1200 return result;
1201 }
1202
1203
1204
1205
1206 private static void convertChoiceDateTimeList(List<Choice<GregorianCalendar>> choices,
1207 List<CmisChoiceDateTime> target) {
1208 if (choices == null) {
1209 return;
1210 }
1211
1212 for (Choice<GregorianCalendar> choice : choices) {
1213 CmisChoiceDateTime newChoice = new CmisChoiceDateTime();
1214
1215 convertChoiceDateTimeList(choice.getChoice(), newChoice.getChoice());
1216 newChoice.setDisplayName(choice.getDisplayName());
1217
1218 if (choice.getValue() != null) {
1219 for (XMLGregorianCalendar value : convertCalendar(choice.getValue())) {
1220 newChoice.getValue().add(value);
1221 }
1222 }
1223
1224 target.add(newChoice);
1225 }
1226 }
1227
1228
1229
1230
1231 private static List<Choice<String>> convertChoiceHtmlList(List<CmisChoiceHtml> choices) {
1232 if (choices == null) {
1233 return null;
1234 }
1235
1236 List<Choice<String>> result = new ArrayList<Choice<String>>();
1237
1238 for (CmisChoiceHtml choice : choices) {
1239 ChoiceImpl<String> newChoice = new ChoiceImpl<String>();
1240
1241 newChoice.setChoice(convertChoiceHtmlList(choice.getChoice()));
1242 newChoice.setDisplayName(choice.getDisplayName());
1243 newChoice.setValue(choice.getValue());
1244
1245 result.add(newChoice);
1246 }
1247
1248 return result;
1249 }
1250
1251
1252
1253
1254 private static void convertChoiceHtmlList(List<Choice<String>> choices, List<CmisChoiceHtml> target) {
1255 if (choices == null) {
1256 return;
1257 }
1258
1259 for (Choice<String> choice : choices) {
1260 CmisChoiceHtml newChoice = new CmisChoiceHtml();
1261
1262 convertChoiceHtmlList(choice.getChoice(), newChoice.getChoice());
1263 newChoice.setDisplayName(choice.getDisplayName());
1264
1265 if (choice.getValue() != null) {
1266 for (String value : choice.getValue()) {
1267 newChoice.getValue().add(value);
1268 }
1269 }
1270
1271 target.add(newChoice);
1272 }
1273 }
1274
1275
1276
1277
1278 private static List<Choice<String>> convertChoiceUriList(List<CmisChoiceUri> choices) {
1279 if (choices == null) {
1280 return null;
1281 }
1282
1283 List<Choice<String>> result = new ArrayList<Choice<String>>();
1284
1285 for (CmisChoiceUri choice : choices) {
1286 ChoiceImpl<String> newChoice = new ChoiceImpl<String>();
1287
1288 newChoice.setChoice(convertChoiceUriList(choice.getChoice()));
1289 newChoice.setDisplayName(choice.getDisplayName());
1290 newChoice.setValue(choice.getValue());
1291
1292 result.add(newChoice);
1293 }
1294
1295 return result;
1296 }
1297
1298
1299
1300
1301 private static void convertChoiceUriList(List<Choice<String>> choices, List<CmisChoiceUri> target) {
1302 if (choices == null) {
1303 return;
1304 }
1305
1306 for (Choice<String> choice : choices) {
1307 CmisChoiceUri newChoice = new CmisChoiceUri();
1308
1309 convertChoiceUriList(choice.getChoice(), newChoice.getChoice());
1310 newChoice.setDisplayName(choice.getDisplayName());
1311
1312 if (choice.getValue() != null) {
1313 for (String value : choice.getValue()) {
1314 newChoice.getValue().add(value);
1315 }
1316 }
1317
1318 target.add(newChoice);
1319 }
1320 }
1321
1322
1323
1324
1325
1326
1327
1328
1329 public static ObjectData convert(CmisObjectType object) {
1330 if (object == null) {
1331 return null;
1332 }
1333
1334 ObjectDataImpl result = new ObjectDataImpl();
1335
1336 result.setAcl(convert(object.getAcl(), object.isExactACL()));
1337 result.setAllowableActions(convert(object.getAllowableActions()));
1338 if (object.getChangeEventInfo() != null) {
1339 ChangeEventInfoDataImpl changeEventInfo = new ChangeEventInfoDataImpl();
1340 if (object.getChangeEventInfo().getChangeTime() != null) {
1341 changeEventInfo.setChangeTime(object.getChangeEventInfo().getChangeTime().toGregorianCalendar());
1342 }
1343 changeEventInfo.setChangeType(convert(ChangeType.class, object.getChangeEventInfo().getChangeType()));
1344 convertExtension(object.getChangeEventInfo(), changeEventInfo);
1345
1346 result.setChangeEventInfo(changeEventInfo);
1347 }
1348 result.setIsExactAcl(object.isExactACL());
1349 result.setPolicyIds(convert(object.getPolicyIds()));
1350 result.setProperties(convert(object.getProperties()));
1351 List<ObjectData> relationships = new ArrayList<ObjectData>();
1352 for (CmisObjectType cmisObject : object.getRelationship()) {
1353 relationships.add(convert(cmisObject));
1354 }
1355 result.setRelationships(relationships);
1356 List<RenditionData> renditions = new ArrayList<RenditionData>();
1357 for (CmisRenditionType rendition : object.getRendition()) {
1358 renditions.add(convert(rendition));
1359 }
1360 result.setRenditions(renditions);
1361
1362
1363 convertExtension(object, result);
1364
1365 return result;
1366 }
1367
1368
1369
1370
1371 public static Properties convert(CmisPropertiesType properties) {
1372 if (properties == null) {
1373 return null;
1374 }
1375
1376 PropertiesImpl result = new PropertiesImpl();
1377
1378 for (CmisProperty property : properties.getProperty()) {
1379 result.addProperty(convert(property));
1380 }
1381
1382
1383 convertExtension(properties, result);
1384
1385 return result;
1386 }
1387
1388
1389
1390
1391 public static PropertyData<?> convert(CmisProperty property) {
1392 if (property == null) {
1393 return null;
1394 }
1395
1396 PropertyData<?> result = null;
1397
1398 if (property instanceof CmisPropertyString) {
1399 result = new PropertyStringImpl(property.getPropertyDefinitionId(),
1400 ((CmisPropertyString) property).getValue());
1401 } else if (property instanceof CmisPropertyId) {
1402 result = new PropertyIdImpl(property.getPropertyDefinitionId(), ((CmisPropertyId) property).getValue());
1403 } else if (property instanceof CmisPropertyInteger) {
1404 result = new PropertyIntegerImpl(property.getPropertyDefinitionId(),
1405 ((CmisPropertyInteger) property).getValue());
1406 } else if (property instanceof CmisPropertyDecimal) {
1407 result = new PropertyDecimalImpl(property.getPropertyDefinitionId(),
1408 ((CmisPropertyDecimal) property).getValue());
1409 } else if (property instanceof CmisPropertyBoolean) {
1410 result = new PropertyBooleanImpl(property.getPropertyDefinitionId(),
1411 ((CmisPropertyBoolean) property).getValue());
1412 } else if (property instanceof CmisPropertyDateTime) {
1413 result = new PropertyDateTimeImpl(property.getPropertyDefinitionId(),
1414 convertXMLCalendar(((CmisPropertyDateTime) property).getValue()));
1415 } else if (property instanceof CmisPropertyHtml) {
1416 result = new PropertyHtmlImpl(property.getPropertyDefinitionId(), ((CmisPropertyHtml) property).getValue());
1417 } else if (property instanceof CmisPropertyUri) {
1418 result = new PropertyUriImpl(property.getPropertyDefinitionId(), ((CmisPropertyUri) property).getValue());
1419 } else {
1420 return null;
1421 }
1422
1423 ((AbstractPropertyData<?>) result).setLocalName(property.getLocalName());
1424 ((AbstractPropertyData<?>) result).setQueryName(property.getQueryName());
1425 ((AbstractPropertyData<?>) result).setDisplayName(property.getDisplayName());
1426
1427
1428 convertExtension(property, result);
1429
1430 return result;
1431 }
1432
1433
1434
1435
1436 public static CmisPropertiesType convert(Properties properties) {
1437 if (properties == null) {
1438 return null;
1439 }
1440
1441 CmisPropertiesType result = new CmisPropertiesType();
1442
1443 if (properties.getProperties() != null) {
1444 for (PropertyData<?> property : properties.getPropertyList()) {
1445 result.getProperty().add(convert(property));
1446 }
1447 }
1448
1449
1450 convertExtension(properties, result);
1451
1452 return result;
1453 }
1454
1455
1456
1457
1458 public static CmisProperty convert(PropertyData<?> property) {
1459 if (property == null) {
1460 return null;
1461 }
1462
1463 CmisProperty result = null;
1464
1465 if (property instanceof PropertyString) {
1466 result = new CmisPropertyString();
1467 ((CmisPropertyString) result).getValue().addAll(((PropertyString) property).getValues());
1468 } else if (property instanceof PropertyId) {
1469 result = new CmisPropertyId();
1470 ((CmisPropertyId) result).getValue().addAll(((PropertyId) property).getValues());
1471 } else if (property instanceof PropertyInteger) {
1472 result = new CmisPropertyInteger();
1473 ((CmisPropertyInteger) result).getValue().addAll(((PropertyInteger) property).getValues());
1474 } else if (property instanceof PropertyDecimal) {
1475 result = new CmisPropertyDecimal();
1476 ((CmisPropertyDecimal) result).getValue().addAll(((PropertyDecimal) property).getValues());
1477 } else if (property instanceof PropertyBoolean) {
1478 result = new CmisPropertyBoolean();
1479 ((CmisPropertyBoolean) result).getValue().addAll(((PropertyBoolean) property).getValues());
1480 } else if (property instanceof PropertyDateTime) {
1481 result = new CmisPropertyDateTime();
1482 ((CmisPropertyDateTime) result).getValue().addAll(
1483 convertCalendar(((PropertyDateTime) property).getValues()));
1484 } else if (property instanceof PropertyHtml) {
1485 result = new CmisPropertyHtml();
1486 ((CmisPropertyHtml) result).getValue().addAll(((PropertyHtml) property).getValues());
1487 } else if (property instanceof PropertyUri) {
1488 result = new CmisPropertyUri();
1489 ((CmisPropertyUri) result).getValue().addAll(((PropertyUri) property).getValues());
1490 } else {
1491 return null;
1492 }
1493
1494 result.setPropertyDefinitionId(property.getId());
1495 result.setLocalName(property.getLocalName());
1496 result.setQueryName(property.getQueryName());
1497 result.setDisplayName(property.getDisplayName());
1498
1499 return result;
1500 }
1501
1502
1503
1504
1505 public static RenditionData convert(CmisRenditionType rendition) {
1506 if (rendition == null) {
1507 return null;
1508 }
1509
1510 RenditionDataImpl result = new RenditionDataImpl();
1511
1512 result.setBigHeight(rendition.getHeight());
1513 result.setKind(rendition.getKind());
1514 result.setBigLength(rendition.getLength());
1515 result.setMimeType(rendition.getMimetype());
1516 result.setRenditionDocumentId(rendition.getRenditionDocumentId());
1517 result.setStreamId(rendition.getStreamId());
1518 result.setTitle(rendition.getTitle());
1519 result.setBigWidth(rendition.getWidth());
1520
1521
1522 convertExtension(rendition, result);
1523
1524 return result;
1525 }
1526
1527
1528
1529
1530 public static CmisRenditionType convert(RenditionData rendition) {
1531 if (rendition == null) {
1532 return null;
1533 }
1534
1535 CmisRenditionType result = new CmisRenditionType();
1536
1537 result.setHeight(rendition.getBigHeight());
1538 result.setKind(rendition.getKind());
1539 result.setLength(rendition.getBigLength());
1540 result.setMimetype(rendition.getMimeType());
1541 result.setRenditionDocumentId(rendition.getRenditionDocumentId());
1542 result.setStreamId(rendition.getStreamId());
1543 result.setTitle(rendition.getTitle());
1544 result.setWidth(rendition.getBigWidth());
1545
1546
1547 convertExtension(rendition, result);
1548
1549 return result;
1550 }
1551
1552
1553
1554
1555 public static CmisObjectType convert(ObjectData object) {
1556 if (object == null) {
1557 return null;
1558 }
1559
1560 CmisObjectType result = new CmisObjectType();
1561
1562 result.setAcl(convert(object.getAcl()));
1563 result.setAllowableActions(convert(object.getAllowableActions()));
1564 if (object.getChangeEventInfo() != null) {
1565 CmisChangeEventType changeEventInfo = new CmisChangeEventType();
1566
1567 changeEventInfo
1568 .setChangeType(convert(EnumTypeOfChanges.class, object.getChangeEventInfo().getChangeType()));
1569 changeEventInfo.setChangeTime(convertCalendar(object.getChangeEventInfo().getChangeTime()));
1570
1571 convertExtension(object.getChangeEventInfo(), changeEventInfo);
1572
1573 result.setChangeEventInfo(changeEventInfo);
1574 }
1575 result.setExactACL(object.getAcl() == null ? null : object.getAcl().isExact());
1576 result.setPolicyIds(convert(object.getPolicyIds()));
1577 result.setProperties(convert(object.getProperties()));
1578 if (object.getRelationships() != null) {
1579 for (ObjectData relationship : object.getRelationships()) {
1580 result.getRelationship().add(convert(relationship));
1581 }
1582 }
1583 if (object.getRenditions() != null) {
1584 for (RenditionData rendition : object.getRenditions()) {
1585 result.getRendition().add(convert(rendition));
1586 }
1587 }
1588
1589
1590 convertExtension(object, result);
1591
1592 return result;
1593 }
1594
1595
1596
1597
1598
1599
1600
1601
1602 public static Acl convert(CmisAccessControlListType acl, Boolean isExact) {
1603 if (acl == null) {
1604 return null;
1605 }
1606
1607 AccessControlListImpl result = new AccessControlListImpl();
1608
1609 List<Ace> aces = new ArrayList<Ace>();
1610 for (CmisAccessControlEntryType entry : acl.getPermission()) {
1611 if (entry == null) {
1612 continue;
1613 }
1614
1615 AccessControlEntryImpl ace = new AccessControlEntryImpl();
1616 ace.setDirect(entry.isDirect());
1617 ace.setPermissions(entry.getPermission());
1618 AccessControlPrincipalDataImpl principal = new AccessControlPrincipalDataImpl(
1619 entry.getPrincipal() == null ? null : entry.getPrincipal().getPrincipalId());
1620 convertExtension(entry.getPrincipal(), principal);
1621 ace.setPrincipal(principal);
1622
1623
1624 convertExtension(entry, ace);
1625
1626 aces.add(ace);
1627 }
1628
1629 result.setAces(aces);
1630
1631 result.setExact(isExact);
1632
1633
1634 convertExtension(acl, result);
1635
1636 return result;
1637 }
1638
1639
1640
1641
1642 public static CmisAccessControlListType convert(Acl acl) {
1643 if (acl == null) {
1644 return null;
1645 }
1646
1647 CmisAccessControlListType result = new CmisAccessControlListType();
1648
1649 if (acl.getAces() != null) {
1650 for (Ace ace : acl.getAces()) {
1651 if (ace == null) {
1652 continue;
1653 }
1654
1655 CmisAccessControlEntryType entry = new CmisAccessControlEntryType();
1656
1657 if (ace.getPrincipal() != null) {
1658 CmisAccessControlPrincipalType pincipal = new CmisAccessControlPrincipalType();
1659
1660 pincipal.setPrincipalId(ace.getPrincipal().getId());
1661 convertExtension(pincipal, ace.getPrincipal());
1662
1663 entry.setPrincipal(pincipal);
1664 }
1665
1666 entry.setDirect(ace.isDirect());
1667 entry.getPermission().addAll(ace.getPermissions());
1668
1669 convertExtension(ace, entry);
1670
1671 result.getPermission().add(entry);
1672 }
1673 }
1674
1675
1676 convertExtension(acl, result);
1677
1678 return result;
1679 }
1680
1681
1682
1683
1684 public static AllowableActions convert(CmisAllowableActionsType allowableActions) {
1685 if (allowableActions == null) {
1686 return null;
1687 }
1688
1689 AllowableActionsImpl result = new AllowableActionsImpl();
1690
1691 Set<Action> set = EnumSet.noneOf(Action.class);
1692
1693 if (Boolean.TRUE.equals(allowableActions.isCanAddObjectToFolder())) {
1694 set.add(Action.CAN_ADD_OBJECT_TO_FOLDER);
1695 }
1696 if (Boolean.TRUE.equals(allowableActions.isCanApplyACL())) {
1697 set.add(Action.CAN_APPLY_ACL);
1698 }
1699 if (Boolean.TRUE.equals(allowableActions.isCanApplyPolicy())) {
1700 set.add(Action.CAN_APPLY_POLICY);
1701 }
1702 if (Boolean.TRUE.equals(allowableActions.isCanCancelCheckOut())) {
1703 set.add(Action.CAN_CANCEL_CHECK_OUT);
1704 }
1705 if (Boolean.TRUE.equals(allowableActions.isCanCheckIn())) {
1706 set.add(Action.CAN_CHECK_IN);
1707 }
1708 if (Boolean.TRUE.equals(allowableActions.isCanCheckOut())) {
1709 set.add(Action.CAN_CHECK_OUT);
1710 }
1711 if (Boolean.TRUE.equals(allowableActions.isCanCreateDocument())) {
1712 set.add(Action.CAN_CREATE_DOCUMENT);
1713 }
1714 if (Boolean.TRUE.equals(allowableActions.isCanCreateFolder())) {
1715 set.add(Action.CAN_CREATE_FOLDER);
1716 }
1717 if (Boolean.TRUE.equals(allowableActions.isCanCreateRelationship())) {
1718 set.add(Action.CAN_CREATE_RELATIONSHIP);
1719 }
1720 if (Boolean.TRUE.equals(allowableActions.isCanDeleteContentStream())) {
1721 set.add(Action.CAN_DELETE_CONTENT_STREAM);
1722 }
1723 if (Boolean.TRUE.equals(allowableActions.isCanDeleteObject())) {
1724 set.add(Action.CAN_DELETE_OBJECT);
1725 }
1726 if (Boolean.TRUE.equals(allowableActions.isCanDeleteTree())) {
1727 set.add(Action.CAN_DELETE_TREE);
1728 }
1729 if (Boolean.TRUE.equals(allowableActions.isCanGetACL())) {
1730 set.add(Action.CAN_GET_ACL);
1731 }
1732 if (Boolean.TRUE.equals(allowableActions.isCanGetAllVersions())) {
1733 set.add(Action.CAN_GET_ALL_VERSIONS);
1734 }
1735 if (Boolean.TRUE.equals(allowableActions.isCanGetAppliedPolicies())) {
1736 set.add(Action.CAN_GET_APPLIED_POLICIES);
1737 }
1738 if (Boolean.TRUE.equals(allowableActions.isCanGetChildren())) {
1739 set.add(Action.CAN_GET_CHILDREN);
1740 }
1741 if (Boolean.TRUE.equals(allowableActions.isCanGetContentStream())) {
1742 set.add(Action.CAN_GET_CONTENT_STREAM);
1743 }
1744 if (Boolean.TRUE.equals(allowableActions.isCanGetDescendants())) {
1745 set.add(Action.CAN_GET_DESCENDANTS);
1746 }
1747 if (Boolean.TRUE.equals(allowableActions.isCanGetFolderParent())) {
1748 set.add(Action.CAN_GET_FOLDER_PARENT);
1749 }
1750 if (Boolean.TRUE.equals(allowableActions.isCanGetFolderTree())) {
1751 set.add(Action.CAN_GET_FOLDER_TREE);
1752 }
1753 if (Boolean.TRUE.equals(allowableActions.isCanGetObjectParents())) {
1754 set.add(Action.CAN_GET_OBJECT_PARENTS);
1755 }
1756 if (Boolean.TRUE.equals(allowableActions.isCanGetObjectRelationships())) {
1757 set.add(Action.CAN_GET_OBJECT_RELATIONSHIPS);
1758 }
1759 if (Boolean.TRUE.equals(allowableActions.isCanGetProperties())) {
1760 set.add(Action.CAN_GET_PROPERTIES);
1761 }
1762 if (Boolean.TRUE.equals(allowableActions.isCanGetRenditions())) {
1763 set.add(Action.CAN_GET_RENDITIONS);
1764 }
1765 if (Boolean.TRUE.equals(allowableActions.isCanMoveObject())) {
1766 set.add(Action.CAN_MOVE_OBJECT);
1767 }
1768 if (Boolean.TRUE.equals(allowableActions.isCanRemoveObjectFromFolder())) {
1769 set.add(Action.CAN_REMOVE_OBJECT_FROM_FOLDER);
1770 }
1771 if (Boolean.TRUE.equals(allowableActions.isCanRemovePolicy())) {
1772 set.add(Action.CAN_REMOVE_POLICY);
1773 }
1774 if (Boolean.TRUE.equals(allowableActions.isCanSetContentStream())) {
1775 set.add(Action.CAN_SET_CONTENT_STREAM);
1776 }
1777 if (Boolean.TRUE.equals(allowableActions.isCanUpdateProperties())) {
1778 set.add(Action.CAN_UPDATE_PROPERTIES);
1779 }
1780
1781 result.setAllowableActions(set);
1782
1783
1784 convertExtension(allowableActions, result);
1785
1786 return result;
1787 }
1788
1789
1790
1791
1792 public static CmisAllowableActionsType convert(AllowableActions allowableActions) {
1793 if (allowableActions == null) {
1794 return null;
1795 }
1796
1797 CmisAllowableActionsType result = new CmisAllowableActionsType();
1798
1799 if (allowableActions.getAllowableActions() != null) {
1800 Set<Action> set = allowableActions.getAllowableActions();
1801
1802 result.setCanAddObjectToFolder(set.contains(Action.CAN_ADD_OBJECT_TO_FOLDER));
1803 result.setCanApplyACL(set.contains(Action.CAN_APPLY_ACL));
1804 result.setCanApplyPolicy(set.contains(Action.CAN_APPLY_POLICY));
1805 result.setCanCancelCheckOut(set.contains(Action.CAN_CANCEL_CHECK_OUT));
1806 result.setCanCheckIn(set.contains(Action.CAN_CHECK_IN));
1807 result.setCanCheckOut(set.contains(Action.CAN_CHECK_OUT));
1808 result.setCanCreateDocument(set.contains(Action.CAN_CREATE_DOCUMENT));
1809 result.setCanCreateFolder(set.contains(Action.CAN_CREATE_FOLDER));
1810 result.setCanCreateRelationship(set.contains(Action.CAN_CREATE_RELATIONSHIP));
1811 result.setCanDeleteContentStream(set.contains(Action.CAN_DELETE_CONTENT_STREAM));
1812 result.setCanDeleteObject(set.contains(Action.CAN_DELETE_OBJECT));
1813 result.setCanDeleteTree(set.contains(Action.CAN_DELETE_TREE));
1814 result.setCanGetACL(set.contains(Action.CAN_GET_ACL));
1815 result.setCanGetAllVersions(set.contains(Action.CAN_GET_ALL_VERSIONS));
1816 result.setCanGetAppliedPolicies(set.contains(Action.CAN_GET_APPLIED_POLICIES));
1817 result.setCanGetChildren(set.contains(Action.CAN_GET_CHILDREN));
1818 result.setCanGetContentStream(set.contains(Action.CAN_GET_CONTENT_STREAM));
1819 result.setCanGetDescendants(set.contains(Action.CAN_GET_DESCENDANTS));
1820 result.setCanGetFolderParent(set.contains(Action.CAN_GET_FOLDER_PARENT));
1821 result.setCanGetFolderTree(set.contains(Action.CAN_GET_FOLDER_TREE));
1822 result.setCanGetObjectParents(set.contains(Action.CAN_GET_OBJECT_PARENTS));
1823 result.setCanGetObjectRelationships(set.contains(Action.CAN_GET_OBJECT_RELATIONSHIPS));
1824 result.setCanGetProperties(set.contains(Action.CAN_GET_PROPERTIES));
1825 result.setCanGetRenditions(set.contains(Action.CAN_GET_RENDITIONS));
1826 result.setCanMoveObject(set.contains(Action.CAN_MOVE_OBJECT));
1827 result.setCanRemoveObjectFromFolder(set.contains(Action.CAN_REMOVE_OBJECT_FROM_FOLDER));
1828 result.setCanRemovePolicy(set.contains(Action.CAN_REMOVE_POLICY));
1829 result.setCanSetContentStream(set.contains(Action.CAN_SET_CONTENT_STREAM));
1830 result.setCanUpdateProperties(set.contains(Action.CAN_UPDATE_PROPERTIES));
1831
1832 }
1833
1834
1835 convertExtension(allowableActions, result);
1836
1837 return result;
1838 }
1839
1840
1841
1842
1843 public static PolicyIdList convert(CmisListOfIdsType policyIds) {
1844 if (policyIds == null) {
1845 return null;
1846 }
1847
1848 PolicyIdListImpl result = new PolicyIdListImpl();
1849 result.setPolicyIds(policyIds.getId());
1850
1851
1852 convertExtension(policyIds, result);
1853
1854 return result;
1855 }
1856
1857
1858
1859
1860 public static CmisListOfIdsType convert(PolicyIdList policyIds) {
1861 if (policyIds == null) {
1862 return null;
1863 }
1864
1865 CmisListOfIdsType result = new CmisListOfIdsType();
1866 if (policyIds.getPolicyIds() != null) {
1867 for (String id : policyIds.getPolicyIds()) {
1868 result.getId().add(id);
1869 }
1870 }
1871
1872
1873 convertExtension(policyIds, result);
1874
1875 return result;
1876 }
1877
1878
1879
1880
1881 public static CmisListOfIdsType convertPolicyIds(List<String> policyIds) {
1882 if (policyIds == null) {
1883 return null;
1884 }
1885
1886 CmisListOfIdsType result = new CmisListOfIdsType();
1887 result.getId().addAll(policyIds);
1888
1889 return result;
1890 }
1891
1892
1893
1894
1895
1896
1897
1898
1899 public static List<GregorianCalendar> convertXMLCalendar(List<XMLGregorianCalendar> calendar) {
1900 if (calendar == null) {
1901 return null;
1902 }
1903
1904 List<GregorianCalendar> result = new ArrayList<GregorianCalendar>();
1905 for (XMLGregorianCalendar cal : calendar) {
1906 if (cal != null) {
1907 result.add(cal.toGregorianCalendar());
1908 }
1909 }
1910
1911 return result;
1912 }
1913
1914
1915
1916
1917 public static List<XMLGregorianCalendar> convertCalendar(List<GregorianCalendar> calendar) {
1918 if (calendar == null) {
1919 return null;
1920 }
1921
1922 DatatypeFactory df;
1923 try {
1924 df = DatatypeFactory.newInstance();
1925 } catch (DatatypeConfigurationException e) {
1926 throw new CmisRuntimeException("Convert exception: " + e.getMessage(), e);
1927 }
1928
1929 List<XMLGregorianCalendar> result = new ArrayList<XMLGregorianCalendar>();
1930 for (GregorianCalendar cal : calendar) {
1931 result.add(df.newXMLGregorianCalendar(cal));
1932 }
1933
1934 return result;
1935 }
1936
1937
1938
1939
1940 public static XMLGregorianCalendar convertCalendar(GregorianCalendar calendar) {
1941 if (calendar == null) {
1942 return null;
1943 }
1944
1945 DatatypeFactory df;
1946 try {
1947 df = DatatypeFactory.newInstance();
1948 } catch (DatatypeConfigurationException e) {
1949 throw new CmisRuntimeException("Convert exception: " + e.getMessage(), e);
1950 }
1951
1952 return df.newXMLGregorianCalendar(calendar);
1953 }
1954
1955
1956
1957
1958 public static TypeDefinitionList convert(CmisTypeDefinitionListType typeList) {
1959 if (typeList == null) {
1960 return null;
1961 }
1962
1963 TypeDefinitionListImpl result = new TypeDefinitionListImpl();
1964 List<TypeDefinition> types = new ArrayList<TypeDefinition>();
1965 for (CmisTypeDefinitionType typeDefinition : typeList.getTypes()) {
1966 types.add(convert(typeDefinition));
1967 }
1968
1969 result.setList(types);
1970 result.setHasMoreItems(typeList.isHasMoreItems());
1971 result.setNumItems(typeList.getNumItems());
1972
1973
1974 convertExtension(typeList, result);
1975
1976 return result;
1977 }
1978
1979
1980
1981
1982 public static CmisTypeDefinitionListType convert(TypeDefinitionList typeList) {
1983 if (typeList == null) {
1984 return null;
1985 }
1986
1987 CmisTypeDefinitionListType result = new CmisTypeDefinitionListType();
1988
1989 if (typeList.getList() != null) {
1990 for (TypeDefinition tdd : typeList.getList()) {
1991 result.getTypes().add(convert(tdd));
1992 }
1993 }
1994
1995 result.setHasMoreItems(convertBoolean(typeList.hasMoreItems(), false));
1996 result.setNumItems(typeList.getNumItems());
1997
1998
1999 convertExtension(typeList, result);
2000
2001 return result;
2002 }
2003
2004
2005
2006
2007 public static List<TypeDefinitionContainer> convertTypeContainerList(List<CmisTypeContainer> typeContainers) {
2008 if (typeContainers == null) {
2009 return null;
2010 }
2011
2012 List<TypeDefinitionContainer> result = new ArrayList<TypeDefinitionContainer>();
2013 for (CmisTypeContainer container : typeContainers) {
2014 TypeDefinitionContainerImpl newConatiner = new TypeDefinitionContainerImpl();
2015 newConatiner.setTypeDefinition(convert(container.getType()));
2016 newConatiner.setChildren(convertTypeContainerList(container.getChildren()));
2017 convertExtension(container, newConatiner);
2018
2019 result.add(newConatiner);
2020 }
2021
2022 return result;
2023 }
2024
2025
2026
2027
2028 public static void convertTypeContainerList(List<TypeDefinitionContainer> typeContainers,
2029 List<CmisTypeContainer> target) {
2030 if (typeContainers == null) {
2031 return;
2032 }
2033
2034 for (TypeDefinitionContainer container : typeContainers) {
2035 CmisTypeContainer newConatiner = new CmisTypeContainer();
2036 newConatiner.setType(convert(container.getTypeDefinition()));
2037 convertTypeContainerList(container.getChildren(), newConatiner.getChildren());
2038 convertExtension(container, newConatiner);
2039
2040 target.add(newConatiner);
2041 }
2042 }
2043
2044
2045
2046
2047 public static ObjectInFolderData convert(CmisObjectInFolderType objectInFolder) {
2048 if (objectInFolder == null) {
2049 return null;
2050 }
2051
2052 ObjectInFolderDataImpl result = new ObjectInFolderDataImpl();
2053
2054 result.setObject(convert(objectInFolder.getObject()));
2055 result.setPathSegment(objectInFolder.getPathSegment());
2056
2057
2058 convertExtension(objectInFolder, result);
2059
2060 return result;
2061 }
2062
2063
2064
2065
2066 public static CmisObjectInFolderType convert(ObjectInFolderData objectInFolder) {
2067 if (objectInFolder == null) {
2068 return null;
2069 }
2070
2071 CmisObjectInFolderType result = new CmisObjectInFolderType();
2072
2073 result.setObject(convert(objectInFolder.getObject()));
2074 result.setPathSegment(objectInFolder.getPathSegment());
2075
2076
2077 convertExtension(objectInFolder, result);
2078
2079 return result;
2080 }
2081
2082
2083
2084
2085 public static ObjectParentData convert(CmisObjectParentsType objectParent) {
2086 if (objectParent == null) {
2087 return null;
2088 }
2089
2090 ObjectParentDataImpl result = new ObjectParentDataImpl();
2091
2092 result.setObject(convert(objectParent.getObject()));
2093 result.setRelativePathSegment(objectParent.getRelativePathSegment());
2094
2095
2096 convertExtension(objectParent, result);
2097
2098 return result;
2099 }
2100
2101
2102
2103
2104 public static CmisObjectParentsType convert(ObjectParentData objectParent) {
2105 if (objectParent == null) {
2106 return null;
2107 }
2108
2109 CmisObjectParentsType result = new CmisObjectParentsType();
2110
2111 result.setObject(convert(objectParent.getObject()));
2112 result.setRelativePathSegment(objectParent.getRelativePathSegment());
2113
2114
2115 convertExtension(objectParent, result);
2116
2117 return result;
2118 }
2119
2120
2121
2122
2123 public static ObjectInFolderList convert(CmisObjectInFolderListType objectInFolderList) {
2124 if (objectInFolderList == null) {
2125 return null;
2126 }
2127
2128 ObjectInFolderListImpl result = new ObjectInFolderListImpl();
2129 List<ObjectInFolderData> objects = new ArrayList<ObjectInFolderData>();
2130 for (CmisObjectInFolderType object : objectInFolderList.getObjects()) {
2131 objects.add(convert(object));
2132 }
2133
2134 result.setObjects(objects);
2135
2136 result.setHasMoreItems(objectInFolderList.isHasMoreItems());
2137 result.setNumItems(objectInFolderList.getNumItems());
2138
2139
2140 convertExtension(objectInFolderList, result);
2141
2142 return result;
2143 }
2144
2145
2146
2147
2148 public static CmisObjectInFolderListType convert(ObjectInFolderList objectInFolderList) {
2149 if (objectInFolderList == null) {
2150 return null;
2151 }
2152
2153 CmisObjectInFolderListType result = new CmisObjectInFolderListType();
2154
2155 if (objectInFolderList.getObjects() != null) {
2156 for (ObjectInFolderData object : objectInFolderList.getObjects()) {
2157 result.getObjects().add(convert(object));
2158 }
2159 }
2160
2161 result.setHasMoreItems(objectInFolderList.hasMoreItems());
2162 result.setNumItems(objectInFolderList.getNumItems());
2163
2164
2165 convertExtension(objectInFolderList, result);
2166
2167 return result;
2168 }
2169
2170
2171
2172
2173 public static ObjectList convert(CmisObjectListType objectList) {
2174 if (objectList == null) {
2175 return null;
2176 }
2177
2178 ObjectListImpl result = new ObjectListImpl();
2179
2180 List<ObjectData> objects = new ArrayList<ObjectData>();
2181 for (CmisObjectType object : objectList.getObjects()) {
2182 objects.add(convert(object));
2183 }
2184
2185 result.setObjects(objects);
2186 result.setHasMoreItems(objectList.isHasMoreItems());
2187 result.setNumItems(objectList.getNumItems());
2188
2189
2190 convertExtension(objectList, result);
2191
2192 return result;
2193 }
2194
2195
2196
2197
2198 public static CmisObjectListType convert(ObjectList objectList) {
2199 if (objectList == null) {
2200 return null;
2201 }
2202
2203 CmisObjectListType result = new CmisObjectListType();
2204
2205 if (objectList.getObjects() != null) {
2206 for (ObjectData object : objectList.getObjects()) {
2207 result.getObjects().add(convert(object));
2208 }
2209 }
2210
2211 result.setHasMoreItems(objectList.hasMoreItems());
2212 result.setNumItems(objectList.getNumItems());
2213
2214
2215 convertExtension(objectList, result);
2216
2217 return result;
2218 }
2219
2220
2221
2222
2223 public static ObjectInFolderContainer convert(CmisObjectInFolderContainerType container) {
2224 if (container == null) {
2225 return null;
2226 }
2227
2228 ObjectInFolderContainerImpl result = new ObjectInFolderContainerImpl();
2229
2230 result.setObject(convert(container.getObjectInFolder()));
2231
2232 List<ObjectInFolderContainer> containerList = new ArrayList<ObjectInFolderContainer>();
2233 for (CmisObjectInFolderContainerType containerChild : container.getChildren()) {
2234 containerList.add(convert(containerChild));
2235 }
2236
2237 result.setChildren(containerList);
2238
2239
2240 convertExtension(container, result);
2241
2242 return result;
2243 }
2244
2245
2246
2247
2248 public static CmisObjectInFolderContainerType convert(ObjectInFolderContainer container) {
2249 if (container == null) {
2250 return null;
2251 }
2252
2253 CmisObjectInFolderContainerType result = new CmisObjectInFolderContainerType();
2254
2255 result.setObjectInFolder(convert(container.getObject()));
2256
2257 if (container.getChildren() != null) {
2258 for (ObjectInFolderContainer child : container.getChildren()) {
2259 result.getChildren().add(convert(child));
2260 }
2261 }
2262
2263
2264 convertExtension(container, result);
2265
2266 return result;
2267 }
2268
2269
2270
2271
2272 public static Acl convert(CmisACLType acl) {
2273 if (acl == null) {
2274 return null;
2275 }
2276
2277 Acl result = convert(acl.getACL(), acl.isExact());
2278
2279
2280 convertExtension(acl, result);
2281
2282 return result;
2283 }
2284
2285
2286
2287
2288 public static FailedToDeleteData convert(DeleteTreeResponse.FailedToDelete failedToDelete) {
2289 if (failedToDelete == null) {
2290 return null;
2291 }
2292
2293 FailedToDeleteDataImpl result = new FailedToDeleteDataImpl();
2294
2295 result.setIds(failedToDelete.getObjectIds());
2296
2297
2298 convertExtension(failedToDelete, result);
2299
2300 return result;
2301 }
2302
2303
2304
2305
2306 public static DeleteTreeResponse.FailedToDelete convert(FailedToDeleteData failedToDelete) {
2307 if (failedToDelete == null) {
2308 return null;
2309 }
2310
2311 DeleteTreeResponse.FailedToDelete result = new DeleteTreeResponse.FailedToDelete();
2312
2313 if (failedToDelete.getIds() != null) {
2314 for (String id : failedToDelete.getIds()) {
2315 result.getObjectIds().add(id);
2316 }
2317 }
2318
2319
2320 convertExtension(failedToDelete, result);
2321
2322 return result;
2323 }
2324
2325
2326
2327
2328
2329
2330
2331
2332 public static ContentStream convert(CmisContentStreamType contentStream) {
2333 if (contentStream == null) {
2334 return null;
2335 }
2336
2337 ContentStreamImpl result = new ContentStreamImpl();
2338
2339 result.setFileName(contentStream.getFilename());
2340 result.setLength(contentStream.getLength());
2341 result.setMimeType(contentStream.getMimeType());
2342 if (contentStream.getStream() != null) {
2343 try {
2344 try {
2345 if (contentStream.getStream() instanceof StreamingDataHandler) {
2346 result.setStream(((StreamingDataHandler) contentStream.getStream()).readOnce());
2347 } else {
2348 result.setStream(contentStream.getStream().getInputStream());
2349 }
2350 } catch (NoClassDefFoundError cnfe) {
2351
2352
2353 result.setStream(contentStream.getStream().getInputStream());
2354 }
2355 } catch (IOException e) {
2356 throw new CmisRuntimeException("Could not get the stream: " + e.getMessage(), e);
2357 }
2358 }
2359
2360
2361 convertExtension(contentStream, result);
2362
2363 return result;
2364 }
2365
2366
2367
2368
2369 public static CmisContentStreamType convert(final ContentStream contentStream) {
2370 if (contentStream == null) {
2371 return null;
2372 }
2373
2374 CmisContentStreamType result = new CmisContentStreamType();
2375
2376 result.setFilename(contentStream.getFileName());
2377 result.setLength(contentStream.getBigLength());
2378 result.setMimeType(contentStream.getMimeType());
2379
2380 result.setStream(new DataHandler(new DataSource() {
2381
2382 public OutputStream getOutputStream() throws IOException {
2383 return null;
2384 }
2385
2386 public String getName() {
2387 return contentStream.getFileName();
2388 }
2389
2390 public InputStream getInputStream() throws IOException {
2391 return contentStream.getStream();
2392 }
2393
2394 public String getContentType() {
2395 return contentStream.getMimeType();
2396 }
2397 }));
2398
2399 return result;
2400 }
2401
2402
2403
2404
2405
2406
2407
2408
2409 public static CmisExtensionType convert(ExtensionsData extension) {
2410 if (extension == null) {
2411 return null;
2412 }
2413
2414 CmisExtensionType result = new CmisExtensionType();
2415
2416 if (extension.getExtensions() != null) {
2417 for (CmisExtensionElement ext : extension.getExtensions()) {
2418 result.getAny().add(convertCmisExtensionElementToNode(ext));
2419 }
2420 }
2421
2422 return result;
2423 }
2424
2425
2426
2427
2428 public static javax.xml.ws.Holder<CmisExtensionType> convertExtensionHolder(ExtensionsData extension) {
2429 if (extension == null) {
2430 return null;
2431 }
2432
2433 javax.xml.ws.Holder<CmisExtensionType> result = new javax.xml.ws.Holder<CmisExtensionType>();
2434 result.value = convert(extension);
2435
2436 return result;
2437 }
2438
2439
2440
2441
2442 public static void setExtensionValues(javax.xml.ws.Holder<CmisExtensionType> source, ExtensionsData target) {
2443 if (target == null) {
2444 return;
2445 }
2446 target.setExtensions(null);
2447
2448 if ((source == null) || (source.value == null)) {
2449 return;
2450 }
2451
2452 List<CmisExtensionElement> list = new ArrayList<CmisExtensionElement>();
2453 target.setExtensions(list);
2454
2455 if (!source.value.getAny().isEmpty()) {
2456 for (Object obj : source.value.getAny()) {
2457 list.add(convertDomToCmisExtensionElement(obj));
2458 }
2459 }
2460 }
2461
2462
2463
2464
2465 public static ExtensionsData convertExtensionHolder(javax.xml.ws.Holder<CmisExtensionType> extension) {
2466 if (extension == null) {
2467 return null;
2468 }
2469
2470 return convert(extension.value);
2471 }
2472
2473
2474
2475
2476 public static void setExtensionValues(ExtensionsData source, javax.xml.ws.Holder<CmisExtensionType> target) {
2477 if ((target == null) || (target.value == null)) {
2478 return;
2479 }
2480 target.value.getAny().clear();
2481
2482 if ((source == null) || (source.getExtensions() == null)) {
2483 return;
2484 }
2485
2486 if (source.getExtensions() != null) {
2487 for (CmisExtensionElement ext : source.getExtensions()) {
2488 target.value.getAny().add(convertCmisExtensionElementToNode(ext));
2489 }
2490 }
2491 }
2492
2493
2494
2495
2496 public static <T> javax.xml.ws.Holder<T> convertHolder(Holder<T> orgHolder) {
2497 if (orgHolder == null) {
2498 return null;
2499 }
2500
2501 javax.xml.ws.Holder<T> result = new javax.xml.ws.Holder<T>();
2502 result.value = orgHolder.getValue();
2503
2504 return result;
2505 }
2506
2507
2508
2509
2510 public static <T> Holder<T> convertHolder(javax.xml.ws.Holder<T> orgHolder) {
2511 if (orgHolder == null) {
2512 return null;
2513 }
2514
2515 Holder<T> result = new Holder<T>();
2516 result.setValue(orgHolder.value);
2517
2518 return result;
2519 }
2520
2521
2522
2523
2524 public static <T> void setHolderValue(javax.xml.ws.Holder<T> source, Holder<T> target) {
2525 if ((source == null) || (target == null)) {
2526 return;
2527 }
2528
2529 target.setValue(source.value);
2530 }
2531
2532
2533
2534
2535 public static <T> void setHolderValue(Holder<T> source, javax.xml.ws.Holder<T> target) {
2536 if ((source == null) || (target == null)) {
2537 return;
2538 }
2539
2540 target.value = source.getValue();
2541 }
2542
2543 @SuppressWarnings("unchecked")
2544 public static void convertExtension(Object source, ExtensionsData target) {
2545 if (source == null) {
2546 return;
2547 }
2548
2549 try {
2550 Method m = source.getClass().getMethod("getAny", new Class<?>[0]);
2551 List<Object> list = (List<Object>) m.invoke(source, new Object[0]);
2552
2553 if (!list.isEmpty()) {
2554 List<CmisExtensionElement> extensions = new ArrayList<CmisExtensionElement>();
2555 for (Object obj : list) {
2556 extensions.add(convertDomToCmisExtensionElement(obj));
2557 }
2558
2559 target.setExtensions(extensions);
2560 } else {
2561 target.setExtensions(null);
2562 }
2563 } catch (NoSuchMethodException e) {
2564 } catch (Exception e) {
2565 throw new CmisRuntimeException("Exception: " + e.getMessage(), e);
2566 }
2567 }
2568
2569 @SuppressWarnings("unchecked")
2570 public static void convertExtension(ExtensionsData source, Object target) {
2571 if (source == null) {
2572 return;
2573 }
2574
2575 try {
2576 Method m = target.getClass().getMethod("getAny", new Class<?>[0]);
2577 List<Object> list = (List<Object>) m.invoke(target, new Object[0]);
2578
2579 list.clear();
2580 if (source.getExtensions() != null) {
2581 for (CmisExtensionElement ext : source.getExtensions()) {
2582 list.add(convertCmisExtensionElementToNode(ext));
2583 }
2584 }
2585 } catch (NoSuchMethodException e) {
2586 } catch (Exception e) {
2587 throw new CmisRuntimeException("Exception: " + e.getMessage(), e);
2588 }
2589 }
2590
2591
2592
2593
2594 public static ExtensionsData convert(CmisExtensionType extension) {
2595 if (extension == null) {
2596 return null;
2597 }
2598
2599 ExtensionDataImpl result = new ExtensionDataImpl();
2600 List<CmisExtensionElement> extensions = new ArrayList<CmisExtensionElement>();
2601 result.setExtensions(extensions);
2602
2603 for (Object obj : extension.getAny()) {
2604 extensions.add(convertDomToCmisExtensionElement(obj));
2605 }
2606
2607 return result;
2608 }
2609
2610
2611
2612
2613 private static CmisExtensionElement convertDomToCmisExtensionElement(Object source) {
2614
2615 if (!(source instanceof Node)) {
2616 return null;
2617 }
2618
2619 Node node = (Node) source;
2620 if (node.getNodeType() != Node.ELEMENT_NODE) {
2621 return null;
2622 }
2623
2624 String name = node.getLocalName();
2625 String namespace = node.getNamespaceURI();
2626
2627 CmisExtensionElement result = null;
2628 List<CmisExtensionElement> cmisChildren = new ArrayList<CmisExtensionElement>();
2629 StringBuilder value = new StringBuilder();
2630
2631 NodeList children = node.getChildNodes();
2632
2633 for (int i = 0; i < children.getLength(); i++) {
2634 Node child = children.item(i);
2635
2636 if (child.getNodeType() == Node.ELEMENT_NODE) {
2637 CmisExtensionElement cmisChild = convertDomToCmisExtensionElement(child);
2638 if (cmisChild != null) {
2639 cmisChildren.add(cmisChild);
2640 }
2641 } else if (child.getNodeType() == Node.TEXT_NODE) {
2642 value.append(child.getNodeValue());
2643 }
2644 }
2645
2646 Map<String, String> attributes = null;
2647 if (node.getAttributes() != null) {
2648 attributes = new HashMap<String, String>();
2649 for (int i = 0; i < node.getAttributes().getLength(); i++) {
2650 Node attrNode = node.getAttributes().item(i);
2651
2652 String attrNamespace = attrNode.getNamespaceURI();
2653
2654 if (attrNamespace == null || attrNamespace.equals(namespace)) {
2655 attributes.put(attrNode.getLocalName(), attrNode.getNodeValue());
2656 }
2657 }
2658 }
2659
2660 if (cmisChildren.isEmpty()) {
2661 result = new CmisExtensionElementImpl(namespace, name, attributes, value.toString());
2662 } else {
2663 result = new CmisExtensionElementImpl(namespace, name, attributes, cmisChildren);
2664 }
2665
2666 return result;
2667 }
2668
2669
2670
2671
2672 private static Node convertCmisExtensionElementToNode(CmisExtensionElement source) {
2673 if (source == null) {
2674 return null;
2675 }
2676
2677 Document doc = null;
2678
2679 try {
2680 DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance();
2681 DocumentBuilder docBuilder = dbfac.newDocumentBuilder();
2682 doc = docBuilder.newDocument();
2683 } catch (Exception e) {
2684 throw new CmisRuntimeException("Unable to convert extensions!", e);
2685 }
2686
2687 Element root = doc.createElementNS(
2688 (source.getNamespace() == null ? DEFAULT_EXTENSION_NS : source.getNamespace()), source.getName());
2689 doc.appendChild(root);
2690
2691 if (source.getValue() != null) {
2692 root.appendChild(doc.createTextNode(source.getValue()));
2693 } else {
2694 for (CmisExtensionElement child : source.getChildren()) {
2695 root.appendChild(convertCmisExtensionElementToNode(child, root, doc));
2696 }
2697 }
2698
2699
2700 if (source.getAttributes() != null) {
2701 for (Map.Entry<String, String> e : source.getAttributes().entrySet()) {
2702 root.setAttributeNS((source.getNamespace() == null ? DEFAULT_EXTENSION_NS : source.getNamespace()),
2703 e.getKey(), e.getValue());
2704 }
2705 }
2706
2707 return root;
2708 }
2709
2710
2711
2712
2713 private static Node convertCmisExtensionElementToNode(CmisExtensionElement source, Element parent, Document doc) {
2714 if (source == null) {
2715 return null;
2716 }
2717
2718 Element element = doc.createElementNS(
2719 (source.getNamespace() == null ? DEFAULT_EXTENSION_NS : source.getNamespace()), source.getName());
2720
2721 if (source.getValue() != null) {
2722 element.appendChild(doc.createTextNode(source.getValue()));
2723 } else {
2724 for (CmisExtensionElement child : source.getChildren()) {
2725 element.appendChild(convertCmisExtensionElementToNode(child, element, doc));
2726 }
2727 }
2728
2729
2730 if (source.getAttributes() != null) {
2731 for (Map.Entry<String, String> e : source.getAttributes().entrySet()) {
2732 element.setAttributeNS((source.getNamespace() == null ? DEFAULT_EXTENSION_NS : source.getNamespace()),
2733 e.getKey(), e.getValue());
2734 }
2735 }
2736
2737 return element;
2738 }
2739
2740 private static boolean convertBoolean(Boolean value, boolean def) {
2741 return (value == null ? def : value.booleanValue());
2742 }
2743
2744
2745
2746
2747
2748
2749
2750
2751 public static <T extends Enum<T>> T convert(Class<T> destClass, Enum<?> source) {
2752 if (source == null) {
2753 return null;
2754 }
2755
2756 return Enum.valueOf(destClass, source.name());
2757 }
2758 }