Search in sources :

Example 1 with PolicyIdList

use of org.apache.chemistry.opencmis.commons.data.PolicyIdList in project iaf by ibissource.

the class CmisUtils method objectData2Xml.

/**
 * @param object to translate to xml
 * @param cmisXml root XML element (defaults to creating a new 'objectData' element)
 * @return the root XML element
 */
public static XmlBuilder objectData2Xml(ObjectData object, XmlBuilder cmisXml) {
    if (object.getProperties() != null) {
        XmlBuilder propertiesXml = new XmlBuilder("properties");
        for (Iterator<PropertyData<?>> it = object.getProperties().getPropertyList().iterator(); it.hasNext(); ) {
            propertiesXml.addSubElement(CmisUtils.getPropertyXml(it.next()));
        }
        cmisXml.addSubElement(propertiesXml);
    }
    if (object.getAllowableActions() != null) {
        XmlBuilder allowableActionsXml = new XmlBuilder("allowableActions");
        Set<Action> actions = object.getAllowableActions().getAllowableActions();
        for (Action action : actions) {
            XmlBuilder actionXml = new XmlBuilder("action");
            actionXml.setValue(action.value());
            allowableActionsXml.addSubElement(actionXml);
        }
        cmisXml.addSubElement(allowableActionsXml);
    }
    if (object.getAcl() != null) {
        XmlBuilder isExactAclXml = new XmlBuilder("isExactAcl");
        isExactAclXml.setValue(object.getAcl().isExact().toString());
        cmisXml.addSubElement(isExactAclXml);
    }
    cmisXml.addAttribute("id", object.getId());
    if (object.getBaseTypeId() != null)
        cmisXml.addAttribute("baseTypeId", object.getBaseTypeId().name());
    PolicyIdList policies = object.getPolicyIds();
    if (policies != null) {
        XmlBuilder policiesXml = new XmlBuilder("policyIds");
        for (String objectId : policies.getPolicyIds()) {
            XmlBuilder policyXml = new XmlBuilder("policyId");
            policyXml.setValue(objectId);
            policiesXml.addSubElement(policyXml);
        }
        cmisXml.addSubElement(policiesXml);
    }
    XmlBuilder relationshipsXml = new XmlBuilder("relationships");
    List<ObjectData> relationships = object.getRelationships();
    if (relationships != null) {
        for (ObjectData relation : relationships) {
            relationshipsXml.addSubElement(objectData2Xml(relation, new XmlBuilder("relation")));
        }
    }
    cmisXml.addSubElement(relationshipsXml);
    return cmisXml;
}
Also used : Action(org.apache.chemistry.opencmis.commons.enums.Action) PropertyData(org.apache.chemistry.opencmis.commons.data.PropertyData) ObjectData(org.apache.chemistry.opencmis.commons.data.ObjectData) XmlBuilder(nl.nn.adapterframework.util.XmlBuilder) PropertyString(org.apache.chemistry.opencmis.commons.data.PropertyString) PolicyIdList(org.apache.chemistry.opencmis.commons.data.PolicyIdList)

Aggregations

XmlBuilder (nl.nn.adapterframework.util.XmlBuilder)1 ObjectData (org.apache.chemistry.opencmis.commons.data.ObjectData)1 PolicyIdList (org.apache.chemistry.opencmis.commons.data.PolicyIdList)1 PropertyData (org.apache.chemistry.opencmis.commons.data.PropertyData)1 PropertyString (org.apache.chemistry.opencmis.commons.data.PropertyString)1 Action (org.apache.chemistry.opencmis.commons.enums.Action)1