/** * 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; }
/** * 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 (source.getAttributes() != null) { for (Map.Entry<String, String> e : source.getAttributes().entrySet()) { root.setAttributeNS((source.getNamespace() == null ? DEFAULT_EXTENSION_NS : source.getNamespace()), e.getKey(), e.getValue());
if (source.getAttributes() != null) { for (Map.Entry<String, String> attr : source.getAttributes().entrySet()) { writer.writeAttribute(attr.getKey(), attr.getValue());
String id = property.getAttributes().get("propertyDefinitionId");
if (source.getAttributes() != null) { for (Map.Entry<String, String> attr : source.getAttributes().entrySet()) { writer.attribute(null, attr.getKey(), attr.getValue());
String propertyId = (property.getAttributes() == null ? null : property.getAttributes().get( "propertyDefinitionId")); if ((propertyId == null) || (property.getChildren() == null))
String propertyId = (property.getAttributes() == null ? null : property.getAttributes().get( "propertyDefinitionId")); if ((propertyId == null) || (property.getChildren() == null))
for (CmisExtensionElement prop : propExtensions) Map<String, String> cmisAspectProperty = prop.getAttributes(); Set<String> cmisAspectPropertyNames = cmisAspectProperty.keySet(); assertTrue("propertyDefinitionId attribute should be present", cmisAspectPropertyNames.contains("propertyDefinitionId"));
for (CmisExtensionElement prop : propExtensions) Map<String, String> cmisAspectProperty = prop.getAttributes(); Set<String> cmisAspectPropertyNames = cmisAspectProperty.keySet(); assertTrue("propertyDefinitionId attribute should be present", cmisAspectPropertyNames.contains("propertyDefinitionId"));