/** * Returns the aspect types from the Alfresco extensions. */ public static Collection<ObjectType> getAspectTypes(Session session, List<CmisExtensionElement> alfrescoExtensions) { Collection<ObjectType> aspectTypes = new ArrayList<ObjectType>(); for (CmisExtensionElement extension : alfrescoExtensions) { if (extension.getName().equals(APPLIED_ASPECTS)) { ObjectType aspectType = session.getTypeDefinition(extension.getValue()); aspectTypes.add(aspectType); } } return aspectTypes; }
/** * Copy constructor. */ public CmisExtensionElementImpl(CmisExtensionElement element) { if (element == null) { throw new IllegalArgumentException("Element must set!"); } if (element.getName() == null) { throw new IllegalArgumentException("Name must set!"); } this.name = element.getName(); this.namespace = element.getNamespace(); this.value = element.getValue(); this.children = element.getChildren(); }
/** * Copy constructor. */ public CmisExtensionElementImpl(CmisExtensionElement element) { if (element == null) { throw new IllegalArgumentException("Element must set!"); } if (element.getName() == null) { throw new IllegalArgumentException("Name must set!"); } this.name = element.getName(); this.namespace = element.getNamespace(); this.value = element.getValue(); this.children = element.getChildren(); }
/** * Converts a CMIS extension element to a DOM node. */ private static Node convertCmisExtensionElementToNode(CmisExtensionElement source, Element parent, Document doc) { if (source == null) { return null; } Element element = doc.createElementNS( (source.getNamespace() == null ? DEFAULT_EXTENSION_NS : source.getNamespace()), source.getName()); if (source.getValue() != null) { element.appendChild(doc.createTextNode(source.getValue())); } else { for (CmisExtensionElement child : source.getChildren()) { element.appendChild(convertCmisExtensionElementToNode(child, element, doc)); } } // set attributes if (source.getAttributes() != null) { for (Map.Entry<String, String> e : source.getAttributes().entrySet()) { element.setAttributeNS((source.getNamespace() == null ? DEFAULT_EXTENSION_NS : source.getNamespace()), e.getKey(), e.getValue()); } } return element; }
values.add(Boolean.parseBoolean(propertyValues.getValue())); break; case DATETIME: values.add(df.newXMLGregorianCalendar(propertyValues.getValue()).toGregorianCalendar()); break; case DECIMAL: values.add(new BigDecimal(propertyValues.getValue())); break; case INTEGER: values.add(new BigInteger(propertyValues.getValue())); break; default: values.add(propertyValues.getValue());
/** * Makes a deep copy of an extension element. */ private CmisExtensionElement copy(CmisExtensionElement element) { if (element == null) { return null; } Map<String, String> attrs = (element.getAttributes() != null ? new HashMap<String, String>( element.getAttributes()) : null); List<CmisExtensionElement> children = element.getChildren(); if (isNotEmpty(children)) { List<CmisExtensionElement> copyChildren = new ArrayList<CmisExtensionElement>(children.size()); for (CmisExtensionElement child : children) { copyChildren.add(copy(child)); } return new CmisExtensionElementImpl(element.getNamespace(), element.getName(), attrs, copyChildren); } else { return new CmisExtensionElementImpl(element.getNamespace(), element.getName(), attrs, element.getValue()); } }
if (ASPECTS_TO_ADD.equals(extension.getName()) && (extension.getValue() != null)) aspectsToAdd.add(extension.getValue()); else if (ASPECTS_TO_REMOVE.equals(extension.getName()) && (extension.getValue() != null)) aspectsToRemove.add(extension.getValue()); try values.add(Boolean.parseBoolean(valueElement.getValue())); try values.add(df.newXMLGregorianCalendar(valueElement.getValue()) .toGregorianCalendar()); try value = new BigInteger(valueElement.getValue()); try values.add(new BigDecimal(valueElement.getValue())); values.add(valueElement.getValue());
if (ASPECTS_TO_ADD.equals(extension.getName()) && (extension.getValue() != null)) aspectsToAdd.add(extension.getValue()); else if (ASPECTS_TO_REMOVE.equals(extension.getName()) && (extension.getValue() != null)) aspectsToRemove.add(extension.getValue()); try values.add(Boolean.parseBoolean(valueElement.getValue())); try values.add(df.newXMLGregorianCalendar(valueElement.getValue()) .toGregorianCalendar()); try value = new BigInteger(valueElement.getValue()); try values.add(new BigDecimal(valueElement.getValue())); values.add(valueElement.getValue());
appliedAspects.add(extension.getValue());
private static void addExtensionToTarget(final CmisExtensionElement ext, final JSONObject target) { if (ext == null) { return; } Object value = null; if (isNotEmpty(ext.getChildren())) { value = convertExtensionList(ext.getChildren()); } else { value = ext.getValue(); } if (!target.containsKey(ext.getName())) { target.put(ext.getName(), value); } else { Object extValue = target.get(ext.getName()); JSONArray array; if (extValue instanceof JSONArray) { array = (JSONArray) extValue; } else { array = new JSONArray(); array.add(extValue); } array.add(value); target.put(ext.getName(), array); } }
private static void addExtensionToTarget(final CmisExtensionElement ext, final JSONObject target) { if (ext == null) { return; } Object value = null; if (isNotEmpty(ext.getChildren())) { value = convertExtensionList(ext.getChildren()); } else { value = ext.getValue(); } if (!target.containsKey(ext.getName())) { target.put(ext.getName(), value); } else { Object extValue = target.get(ext.getName()); JSONArray array; if (extValue instanceof JSONArray) { array = (JSONArray) extValue; } else { array = new JSONArray(); array.add(extValue); } array.add(value); target.put(ext.getName(), array); } }