Example usage for org.dom4j Element addElement

List of usage examples for org.dom4j Element addElement

Introduction

In this page you can find the example usage for org.dom4j Element addElement.

Prototype

Element addElement(String qualifiedName, String namespaceURI);

Source Link

Document

Adds a new Element node with the given qualified name and namespace URI to this branch and returns a reference to the new node.

Usage

From source file:com.bluexml.side.Framework.alfresco.dataGenerator.serialization.mapping.XMLForACPMappingHelper.java

License:Open Source License

/**
 * create and fill the xml's elements corresponding to native Alfresco's aspects of given node 
 * under aspects element//w w w.ja  va  2 s .  c  o  m
 * @param aspects
 * @param node
 */
private void createNativeAspects(Element aspects, INode node) {
    Map<QNamePattern, Object> dataAspects = ((NativeAlfrescoNode) ((AlfrescoNode) node).getNativeNode())
            .getNativeDatasAspects();
    Set<QNamePattern> nativeAspects = dataAspects.keySet();
    for (QNamePattern nativeAspect : nativeAspects) {
        String tag = ((org.alfresco.service.namespace.QName) nativeAspect).toPrefixString();
        String data = dataAspects.get(nativeAspect).toString();
        String uri = ((org.alfresco.service.namespace.QName) nativeAspect).getNamespaceURI();
        aspects.addElement(tag, uri).addText(data);
    }

}

From source file:com.bluexml.side.Framework.alfresco.dataGenerator.serialization.mapping.XMLForACPMappingHelper.java

License:Open Source License

/**
 * create and fill xml's elements corresponding to SIDE properties
 * @param prop//from  www .  j a v  a  2s. c  om
 * @param propertiesData
 */
private void createAndFillSIDEProperties(Element prop, Map<PropertyDefinition, Object> propertiesData) {
    Set<PropertyDefinition> properties = propertiesData.keySet();
    for (PropertyDefinition property : properties) {
        String tag = property.getName().toPrefixString();
        String uri = property.getName().getNamespaceURI();
        String data = propertiesData.get(property).toString();
        prop.addElement(tag, uri).addText(data);
    }

}

From source file:com.bluexml.side.Framework.alfresco.dataGenerator.serialization.mapping.XMLForACPMappingHelper.java

License:Open Source License

/**
 * create and fill xml's elements corresponding to native properties of given generated node
 * @param properties//w  ww  .j  av  a 2  s. c o m
 * @param dataNativeProperties
 */
private void createAndFillNativeProperties(Element properties, Map<QNamePattern, Object> dataNativeProperties) {
    Set<QNamePattern> nativePorperties = dataNativeProperties.keySet();
    for (QNamePattern nativeProperty : nativePorperties) {
        String tag = ((org.alfresco.service.namespace.QName) nativeProperty).toPrefixString();
        String uri = ((org.alfresco.service.namespace.QName) nativeProperty).getNamespaceURI();
        String data = dataNativeProperties.get(nativeProperty).toString();
        if (((org.alfresco.service.namespace.QName) nativeProperty).equals(ContentModel.PROP_TITLE)) {
            data = services.getNodeName(dataNativeProperties);
        }
        properties.addElement(tag, uri).addText(data);
    }

}

From source file:com.bluexml.side.Framework.alfresco.dataGenerator.serialization.mapping.XMLForACPMappingHelper.java

License:Open Source License

/**
 * create and fill the xml's elements corresponding to generated arcs of given source node
 * @param root/*from  w  ww .  j a  v  a 2  s .  c  om*/
 * @param src
 * @return the associations root xml element
 */
public Element createAssociation(Element root, INode src) {
    String tag = services.createTag(NamespaceService.REPOSITORY_VIEW_PREFIX, Constants.REFERENCE);

    String attributeName = services.createTag(NamespaceService.REPOSITORY_VIEW_PREFIX, Constants.PATHREF);
    Map<QNamePattern, Object> nativeDataProperties = ((NativeAlfrescoNode) ((AlfrescoNode) src).getNativeNode())
            .getNativeDatasProperties();
    String attrValue = services.getNodeName(nativeDataProperties).replace(" ", Constants.BLANK_REPLACE);
    String attributeValue = services.createTag(NamespaceService.CONTENT_MODEL_PREFIX, attrValue);

    return root.addElement(tag, NamespaceService.REPOSITORY_VIEW_1_0_URI).addAttribute(attributeName,
            attributeValue);
}

From source file:com.bluexml.side.Framework.alfresco.dataGenerator.serialization.mapping.XMLForACPMappingHelper.java

License:Open Source License

/**
 * create and fill the xml's elements corresponding to target of given generated arc
 * @param assoc//ww w  .  ja  v a2 s.  c o m
 * @param arc
 */
public void createTargetAssociation(Element assoc, IArc arc) {
    org.alfresco.service.namespace.QName arcQName = ((AlfrescoArc) arc).getTypeAssociation().getName();
    Element definedAssoc = assoc.addElement(arcQName.toPrefixString(), arcQName.getNamespaceURI());

    createAssociation(definedAssoc, ((AlfrescoArc) arc).getTarget());
}

From source file:com.buddycloud.channeldirectory.search.rsm.RSMUtils.java

License:Apache License

/**
 * Appends RSM info to query response./*from ww w . ja  v a 2 s.  c o m*/
 * @param queryElement
 * @param rsm
 */
public static void appendRSMElement(Element queryElement, RSM rsm) {
    Element setElement = queryElement.addElement("set", RSM.NAMESPACE);

    if (rsm.getFirst() != null) {
        Element firstElement = setElement.addElement("first");
        firstElement.addAttribute("index", rsm.getIndex().toString());
        firstElement.setText(rsm.getFirst());
    }

    if (rsm.getLast() != null) {
        Element lastElement = setElement.addElement("last");
        lastElement.setText(rsm.getLast());
    }

    setElement.addElement("count").setText(String.valueOf(rsm.getCount()));
}

From source file:com.buddycloud.channeldirectory.search.utils.FeatureUtils.java

License:Apache License

/**
 * Adds an element to the parent element and set its namespace
 * if the corresponding feature is contained in the options map
 * or this map is empty.//  w w w . ja  v a  2 s .c om
 * 
 * @param options
 * @param parentElement
 * @param key
 * @param namespace
 * @return
 */
public static Element addNamespaceElement(Set<String> options, Element parentElement, String key,
        String namespace) {
    if (options.contains(key) || options.isEmpty()) {
        return parentElement.addElement(key, namespace);
    }
    return null;
}

From source file:com.buddycloud.mediaserver.xmpp.MediaServerComponent.java

License:Apache License

protected IQ handleDiscoInfo(IQ iq) {
    IQ disco = super.handleDiscoInfo(iq);
    String endPoint = configuration.getProperty(MediaServerConfiguration.HTTP_ENDPOINT);
    if (endPoint != null) {
        Element queryEl = disco.getElement().element("query");
        Element xEl = queryEl.addElement("x", "jabber:x:data");
        xEl.addAttribute("type", "result");

        addField(xEl, "FORM_TYPE", "hidden", MediaServerConfiguration.BUDDYCLOUD_NS_API);
        addField(xEl, MediaServerConfiguration.API_ENDPOINT_FIELD_VAR, "text-single", endPoint);
    }/*ww  w . ja v a2  s  . c  o  m*/
    return disco;
}

From source file:com.buddycloud.mediaserver.xmpp.util.HTTPAuthMessageBuilder.java

License:Apache License

public Message createPacket() {
    Message m = new Message();
    m.setType(Type.normal);/*  www.  j a  va2s  . c  o  m*/
    m.setThread(thread);
    m.setBody("Confirmation message for transaction " + id);

    Element rootEl = m.getElement();
    rootEl.addAttribute("xmlns:stream", "http://etherx.jabber.org/streams");

    Element authEl = rootEl.addElement(ELEMENT_NAME, NAMESPACE);
    authEl.addAttribute("id", id);
    authEl.addAttribute("url", url);
    authEl.addAttribute("method", "GET");

    return m;
}

From source file:com.collabnet.ccf.core.ga.GenericArtifactHelper.java

License:Open Source License

/**
 * Adds a sub-element to parent-element/*from   www  . j  av a2s . c o  m*/
 * 
 * @param parentElement
 *            parent element that should get a new sub-element
 * @param subElementName
 *            name of the new created sub-element
 * @param subElementNamespace
 *            namespace of the new sub-element
 * @return newly created sub-element
 */
private static Element addElement(Element parentElement, String subElementName, String subElementNamespace) {
    return parentElement.addElement(subElementName, subElementNamespace);
}