/** * 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(); }
/** * 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(); }
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); } }
/** * 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; }
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 writeExtensionElement(XMLStreamWriter writer, CmisExtensionElement source, List<String> ns) throws XMLStreamException { if (source == null || source.getName() == null) { return; writer.writeStartElement(prefix, source.getName(), source.getNamespace()); writer.writeStartElement(source.getName());
if (!extension.getName().equals("properties"))
/** * 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()); } }
(source.getNamespace() == null ? DEFAULT_EXTENSION_NS : source.getNamespace()), source.getName()); doc.appendChild(root);
for (CmisExtensionElement extension : extensions) if ("properties".equals(extension.getName()))
private static void writeExtensionElement(XmlSerializer writer, CmisExtensionElement source, LinkedList<String> ns) throws IOException { if (source == null || source.getName() == null) { return; writer.startTag(source.getNamespace(), source.getName()); writer.startTag(null, source.getName()); writer.endTag(namespace, source.getName());
if (ASPECTS_TO_ADD.equals(extension.getName()) && (extension.getValue() != null)) else if (ASPECTS_TO_REMOVE.equals(extension.getName()) && (extension.getValue() != null)) else if (PROPERTIES.equals(extension.getName()) && (extension.getChildren() != null)) if (!property.getName().startsWith("property")) if (property.getName().equals("propertyBoolean")) else if (property.getName().equals("propertyInteger")) else if (property.getName().equals("propertyDateTime")) else if (property.getName().equals("propertyDecimal")) if ("value".equals(valueElement.getName()))
if (ASPECTS_TO_ADD.equals(extension.getName()) && (extension.getValue() != null)) else if (ASPECTS_TO_REMOVE.equals(extension.getName()) && (extension.getValue() != null)) else if (PROPERTIES.equals(extension.getName()) && (extension.getChildren() != null)) if (!property.getName().startsWith("property")) if (property.getName().equals("propertyBoolean")) else if (property.getName().equals("propertyInteger")) else if (property.getName().equals("propertyDateTime")) else if (property.getName().equals("propertyDecimal")) if ("value".equals(valueElement.getName()))
&& SET_ASPECTS.equals(extension.getName()))
&& SET_ASPECTS.equals(extension.getName()))