use of org.apache.chemistry.opencmis.commons.impl.dataobjects.AllowableActionsImpl in project iaf by ibissource.
the class ObjectServiceImpl method getObject.
@Override
public ObjectData getObject(String repositoryId, String objectId, String filter, Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter, Boolean includePolicyIds, Boolean includeAcl, ExtensionsData extensions) {
boolean bypass = AppConstants.getInstance().getBoolean("cmis.proxy.bypass.getObject", false);
if (!bypass) {
ObjectData objectData = objectService.getObject(repositoryId, objectId, filter, includeAllowableActions, includeRelationships, renditionFilter, includePolicyIds, includeAcl, extensions);
return objectData;
} else {
XmlBuilder cmisXml = new XmlBuilder("cmis");
cmisXml.addSubElement(buildXml("repositoryId", repositoryId));
cmisXml.addSubElement(buildXml("objectId", objectId));
cmisXml.addSubElement(buildXml("filter", filter));
cmisXml.addSubElement(buildXml("includeAllowableActions", includeAllowableActions));
cmisXml.addSubElement(buildXml("includePolicies", includePolicyIds));
cmisXml.addSubElement(buildXml("includeAcl", includeAcl));
ObjectDataImpl impl = new ObjectDataImpl();
try {
IPipeLineSession messageContext = new PipeLineSessionBase();
String result = CmisServletDispatcher.getInstance().getCmisListener().processRequest(null, cmisXml.toXML(), messageContext);
Element cmisElement;
if (XmlUtils.isWellFormed(result, "cmis")) {
cmisElement = XmlUtils.buildElement(result);
} else {
cmisElement = XmlUtils.buildElement("<cmis/>");
}
// Handle allowable actions
Element allowableActionsElem = XmlUtils.getFirstChildTag(cmisElement, "allowableActions");
if (allowableActionsElem != null) {
AllowableActionsImpl allowableActions = new AllowableActionsImpl();
Set<Action> actions = EnumSet.noneOf(Action.class);
Iterator<Node> actionIterator = XmlUtils.getChildTags(allowableActionsElem, "action").iterator();
while (actionIterator.hasNext()) {
String property = XmlUtils.getStringValue((Element) actionIterator.next());
actions.add(Action.fromValue(property));
}
allowableActions.setAllowableActions(actions);
impl.setAllowableActions(allowableActions);
}
// Handle isExactAcl
impl.setIsExactAcl(XmlUtils.getChildTagAsBoolean(cmisElement, "isExactAcl"));
// Handle policyIds
Element policyIdsElem = XmlUtils.getFirstChildTag(cmisElement, "policyIds");
if (policyIdsElem != null) {
PolicyIdListImpl policyIdList = new PolicyIdListImpl();
List<String> policies = new ArrayList<String>();
Iterator<Node> policyIterator = XmlUtils.getChildTags(allowableActionsElem, "policyId").iterator();
while (policyIterator.hasNext()) {
String policyId = XmlUtils.getStringValue((Element) policyIterator.next());
policies.add(policyId);
}
policyIdList.setPolicyIds(policies);
impl.setPolicyIds(policyIdList);
}
// Handle properties
impl.setProperties(processProperties(cmisElement));
} catch (Exception e) {
log.error("error creating CMIS objectData: " + e.getMessage(), e.getCause());
}
impl.setRenditions(null);
impl.setExtensions(null);
impl.setChangeEventInfo(null);
impl.setRelationships(null);
return impl;
}
}
Aggregations