@SuppressWarnings("unchecked") public static void convertExtension(ExtensionsData source, Object target) { if (source == null) { return; } try { Method m = target.getClass().getMethod("getAny", new Class<?>[0]); List<Object> list = (List<Object>) m.invoke(target, new Object[0]); list.clear(); if (source.getExtensions() != null) { for (CmisExtensionElement ext : source.getExtensions()) { list.add(convertCmisExtensionElementToNode(ext)); } } } catch (NoSuchMethodException e) { // ignore } catch (Exception e) { throw new CmisRuntimeException("Exception: " + e.getMessage(), e); } }
/** * Converts a binding extension into a Web Services extension. */ public static CmisExtensionType convert(ExtensionsData extension) { if (extension == null) { return null; } CmisExtensionType result = new CmisExtensionType(); if (extension.getExtensions() != null) { for (CmisExtensionElement ext : extension.getExtensions()) { result.getAny().add(convertCmisExtensionElementToNode(ext)); } } return result; }
/** * Copies a holder value. */ public static void setExtensionValues(ExtensionsData source, javax.xml.ws.Holder<CmisExtensionType> target) { if ((target == null) || (target.value == null)) { return; } target.value.getAny().clear(); if ((source == null) || (source.getExtensions() == null)) { return; } if (source.getExtensions() != null) { for (CmisExtensionElement ext : source.getExtensions()) { target.value.getAny().add(convertCmisExtensionElementToNode(ext)); } } }
/** * 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; }
} else { for (CmisExtensionElement child : source.getChildren()) { root.appendChild(convertCmisExtensionElementToNode(child, root, doc));