Search in sources :

Example 6 with PropertyData

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

the class IbisObjectService method updateProperties.

@Override
public void updateProperties(String repositoryId, Holder<String> objectId, Holder<String> changeToken, Properties properties, ExtensionsData extension) {
    if (!eventDispatcher.contains(CmisEvent.UPDATE_PROPERTIES)) {
        objectService.updateProperties(repositoryId, objectId, changeToken, properties, extension);
    } else {
        XmlBuilder cmisXml = new XmlBuilder("cmis");
        cmisXml.addSubElement(buildXml("repositoryId", repositoryId));
        if (objectId != null)
            cmisXml.addSubElement(buildXml("objectId", objectId.getValue()));
        if (changeToken != null)
            cmisXml.addSubElement(buildXml("changeToken", changeToken.getValue()));
        XmlBuilder propertiesXml = new XmlBuilder("properties");
        for (Iterator<PropertyData<?>> it = properties.getPropertyList().iterator(); it.hasNext(); ) {
            propertiesXml.addSubElement(CmisUtils.getPropertyXml(it.next()));
        }
        cmisXml.addSubElement(propertiesXml);
        eventDispatcher.trigger(CmisEvent.UPDATE_PROPERTIES, cmisXml.toXML(), callContext);
    }
}
Also used : PropertyData(org.apache.chemistry.opencmis.commons.data.PropertyData) XmlBuilder(nl.nn.adapterframework.util.XmlBuilder)

Example 7 with PropertyData

use of org.apache.chemistry.opencmis.commons.data.PropertyData in project alfresco-remote-api by Alfresco.

the class RepoService method getProperties.

/*
     * Get (CMIS) node properties
     */
private Properties getProperties(NodeRef nodeRef) {
    CMISNodeInfoImpl nodeInfo = cmisConnector.createNodeInfo(nodeRef);
    final Properties properties = cmisConnector.getNodeProperties(nodeInfo, null);
    // fake the title property, which CMIS doesn't give us
    String title = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_TITLE);
    final PropertyStringImpl titleProp = new PropertyStringImpl(ContentModel.PROP_TITLE.toString(), title);
    Properties wrapProperties = new Properties() {

        @Override
        public List<CmisExtensionElement> getExtensions() {
            return properties.getExtensions();
        }

        @Override
        public void setExtensions(List<CmisExtensionElement> extensions) {
            properties.setExtensions(extensions);
        }

        @Override
        public Map<String, PropertyData<?>> getProperties() {
            Map<String, PropertyData<?>> updatedProperties = new HashMap<String, PropertyData<?>>(properties.getProperties());
            updatedProperties.put(titleProp.getId(), titleProp);
            return updatedProperties;
        }

        @Override
        public List<PropertyData<?>> getPropertyList() {
            List<PropertyData<?>> propertyList = new ArrayList<PropertyData<?>>(properties.getPropertyList());
            propertyList.add(titleProp);
            return propertyList;
        }
    };
    return wrapProperties;
}
Also used : CmisExtensionElement(org.apache.chemistry.opencmis.commons.data.CmisExtensionElement) PropertyData(org.apache.chemistry.opencmis.commons.data.PropertyData) CMISNodeInfoImpl(org.alfresco.opencmis.CMISNodeInfoImpl) PropertyStringImpl(org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyStringImpl) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Properties(org.apache.chemistry.opencmis.commons.data.Properties)

Example 8 with PropertyData

use of org.apache.chemistry.opencmis.commons.data.PropertyData 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)

Example 9 with PropertyData

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

the class IbisObjectService method createDocument.

@Override
public String createDocument(String repositoryId, Properties properties, String folderId, ContentStream contentStream, VersioningState versioningState, List<String> policies, Acl addAces, Acl removeAces, ExtensionsData extension) {
    if (!eventDispatcher.contains(CmisEvent.CREATE_DOCUMENT)) {
        return objectService.createDocument(repositoryId, properties, folderId, contentStream, versioningState, policies, addAces, removeAces, extension);
    } else {
        XmlBuilder cmisXml = new XmlBuilder("cmis");
        cmisXml.addSubElement(buildXml("repositoryId", repositoryId));
        cmisXml.addSubElement(buildXml("folderId", folderId));
        cmisXml.addSubElement(buildXml("versioningState", versioningState));
        XmlBuilder contentStreamXml = new XmlBuilder("contentStream");
        contentStreamXml.addAttribute("filename", contentStream.getFileName());
        contentStreamXml.addAttribute("length", contentStream.getLength());
        contentStreamXml.addAttribute("mimeType", contentStream.getMimeType());
        cmisXml.addSubElement(contentStreamXml);
        XmlBuilder propertiesXml = new XmlBuilder("properties");
        for (Iterator<PropertyData<?>> it = properties.getPropertyList().iterator(); it.hasNext(); ) {
            propertiesXml.addSubElement(CmisUtils.getPropertyXml(it.next()));
        }
        cmisXml.addSubElement(propertiesXml);
        PipeLineSession context = new PipeLineSession();
        context.put("ContentStream", contentStream.getStream());
        context.put(CmisUtils.CMIS_CALLCONTEXT_KEY, callContext);
        Element result = eventDispatcher.trigger(CmisEvent.CREATE_DOCUMENT, cmisXml.toXML(), context);
        return XmlUtils.getChildTagAsString(result, "id");
    }
}
Also used : PropertyData(org.apache.chemistry.opencmis.commons.data.PropertyData) Element(org.w3c.dom.Element) XmlBuilder(nl.nn.adapterframework.util.XmlBuilder) PipeLineSession(nl.nn.adapterframework.core.PipeLineSession)

Example 10 with PropertyData

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

the class IbisObjectService method createItem.

@Override
public String createItem(String repositoryId, Properties properties, String folderId, List<String> policies, Acl addAces, Acl removeAces, ExtensionsData extension) {
    if (!eventDispatcher.contains(CmisEvent.CREATE_ITEM)) {
        return objectService.createItem(repositoryId, properties, folderId, policies, addAces, removeAces, extension);
    } else {
        XmlBuilder cmisXml = new XmlBuilder("cmis");
        cmisXml.addSubElement(buildXml("repositoryId", repositoryId));
        cmisXml.addSubElement(buildXml("folderId", folderId));
        cmisXml.addSubElement(buildXml("policies", policies));
        XmlBuilder propertiesXml = new XmlBuilder("properties");
        for (Iterator<PropertyData<?>> it = properties.getPropertyList().iterator(); it.hasNext(); ) {
            propertiesXml.addSubElement(CmisUtils.getPropertyXml(it.next()));
        }
        cmisXml.addSubElement(propertiesXml);
        Element result = eventDispatcher.trigger(CmisEvent.CREATE_ITEM, cmisXml.toXML(), callContext);
        return XmlUtils.getChildTagAsString(result, "id");
    }
}
Also used : PropertyData(org.apache.chemistry.opencmis.commons.data.PropertyData) Element(org.w3c.dom.Element) XmlBuilder(nl.nn.adapterframework.util.XmlBuilder)

Aggregations

PropertyData (org.apache.chemistry.opencmis.commons.data.PropertyData)18 ArrayList (java.util.ArrayList)9 List (java.util.List)7 VersionableAspectTest (org.alfresco.repo.version.VersionableAspectTest)6 ObjectData (org.apache.chemistry.opencmis.commons.data.ObjectData)6 ObjectList (org.apache.chemistry.opencmis.commons.data.ObjectList)6 CmisService (org.apache.chemistry.opencmis.commons.server.CmisService)6 Test (org.junit.Test)6 HashMap (java.util.HashMap)5 XmlBuilder (nl.nn.adapterframework.util.XmlBuilder)5 NodeRef (org.alfresco.service.cmr.repository.NodeRef)5 ObjectInFolderList (org.apache.chemistry.opencmis.commons.data.ObjectInFolderList)5 Properties (org.apache.chemistry.opencmis.commons.data.Properties)5 RepositoryInfo (org.apache.chemistry.opencmis.commons.data.RepositoryInfo)5 PropertiesImpl (org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertiesImpl)5 PropertyStringImpl (org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyStringImpl)5 FileInfo (org.alfresco.service.cmr.model.FileInfo)4 Serializable (java.io.Serializable)3 Map (java.util.Map)3 MimetypeMap (org.alfresco.repo.content.MimetypeMap)3