Search in sources :

Example 1 with ObjectDataImpl

use of org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectDataImpl 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;
    }
}
Also used : Action(org.apache.chemistry.opencmis.commons.enums.Action) PolicyIdListImpl(org.apache.chemistry.opencmis.commons.impl.dataobjects.PolicyIdListImpl) Element(org.w3c.dom.Element) Node(org.w3c.dom.Node) ObjectData(org.apache.chemistry.opencmis.commons.data.ObjectData) ArrayList(java.util.ArrayList) AllowableActionsImpl(org.apache.chemistry.opencmis.commons.impl.dataobjects.AllowableActionsImpl) ObjectDataImpl(org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectDataImpl) ParseException(java.text.ParseException) SenderException(nl.nn.adapterframework.core.SenderException) XmlBuilder(nl.nn.adapterframework.util.XmlBuilder) IPipeLineSession(nl.nn.adapterframework.core.IPipeLineSession) PipeLineSessionBase(nl.nn.adapterframework.core.PipeLineSessionBase)

Aggregations

ParseException (java.text.ParseException)1 ArrayList (java.util.ArrayList)1 IPipeLineSession (nl.nn.adapterframework.core.IPipeLineSession)1 PipeLineSessionBase (nl.nn.adapterframework.core.PipeLineSessionBase)1 SenderException (nl.nn.adapterframework.core.SenderException)1 XmlBuilder (nl.nn.adapterframework.util.XmlBuilder)1 ObjectData (org.apache.chemistry.opencmis.commons.data.ObjectData)1 Action (org.apache.chemistry.opencmis.commons.enums.Action)1 AllowableActionsImpl (org.apache.chemistry.opencmis.commons.impl.dataobjects.AllowableActionsImpl)1 ObjectDataImpl (org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectDataImpl)1 PolicyIdListImpl (org.apache.chemistry.opencmis.commons.impl.dataobjects.PolicyIdListImpl)1 Element (org.w3c.dom.Element)1 Node (org.w3c.dom.Node)1