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;
}
Aggregations