Search in sources :

Example 1 with PropertyData

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

the class IbisObjectService method createFolder.

@Override
public String createFolder(String repositoryId, Properties properties, String folderId, List<String> policies, Acl addAces, Acl removeAces, ExtensionsData extension) {
    if (!eventDispatcher.contains(CmisEvent.CREATE_FOLDER)) {
        return objectService.createFolder(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_FOLDER, 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)

Example 2 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 3 with PropertyData

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

the class FavouriteFolder method getFolder.

// public Folder(String id, String guid, Map<String, Serializable> properties)
// {
// super(id, guid, properties);
// }
public static FavouriteFolder getFolder(String id, String guid, Properties props) {
    FavouriteFolder folder = new FavouriteFolder(id, guid);
    Map<String, PropertyData<?>> properties = props.getProperties();
    folder.setName((String) properties.get(PropertyIds.NAME).getFirstValue());
    folder.setTitle((String) properties.get(ContentModel.PROP_TITLE.toString()).getFirstValue());
    folder.setCreatedBy((String) properties.get(PropertyIds.CREATED_BY).getFirstValue());
    folder.setModifiedBy((String) properties.get(PropertyIds.LAST_MODIFIED_BY).getFirstValue());
    GregorianCalendar modifiedAt = (GregorianCalendar) properties.get(PropertyIds.LAST_MODIFICATION_DATE).getFirstValue();
    folder.setModifiedAt(modifiedAt.getTime());
    GregorianCalendar createdAt = (GregorianCalendar) properties.get(PropertyIds.CREATION_DATE).getFirstValue();
    folder.setCreatedAt(createdAt.getTime());
    // document.setDescription((String)props.get(PropertyIds.DE).getFirstValue());
    return folder;
}
Also used : PropertyData(org.apache.chemistry.opencmis.commons.data.PropertyData) GregorianCalendar(java.util.GregorianCalendar)

Example 4 with PropertyData

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

the class FavouriteDocument method getDocument.

// public Document(String id, String guid, Map<String, Serializable> properties)
// {
// super(id, guid, properties);
// }
public static FavouriteDocument getDocument(String id, String guid, Properties props) {
    FavouriteDocument document = new FavouriteDocument(id, guid);
    Map<String, PropertyData<?>> properties = props.getProperties();
    document.setName((String) properties.get(PropertyIds.NAME).getFirstValue());
    document.setTitle((String) properties.get(ContentModel.PROP_TITLE.toString()).getFirstValue());
    document.setCreatedBy((String) properties.get(PropertyIds.CREATED_BY).getFirstValue());
    document.setModifiedBy((String) properties.get(PropertyIds.LAST_MODIFIED_BY).getFirstValue());
    GregorianCalendar modifiedAt = (GregorianCalendar) properties.get(PropertyIds.LAST_MODIFICATION_DATE).getFirstValue();
    document.setModifiedAt(modifiedAt.getTime());
    GregorianCalendar createdAt = (GregorianCalendar) properties.get(PropertyIds.CREATION_DATE).getFirstValue();
    document.setCreatedAt(createdAt.getTime());
    // document.setDescription((String)props.get(PropertyIds.DE).getFirstValue());
    document.setMimeType((String) properties.get(PropertyIds.CONTENT_STREAM_MIME_TYPE).getFirstValue());
    document.setSizeInBytes((BigInteger) properties.get(PropertyIds.CONTENT_STREAM_LENGTH).getFirstValue());
    document.setVersionLabel((String) properties.get(PropertyIds.VERSION_LABEL).getFirstValue());
    return document;
}
Also used : PropertyData(org.apache.chemistry.opencmis.commons.data.PropertyData) GregorianCalendar(java.util.GregorianCalendar)

Example 5 with PropertyData

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

the class CMISTest method mnt10548test.

@Category(RedundantTests.class)
@Test
public void mnt10548test() throws Exception {
    AuthenticationUtil.pushAuthentication();
    AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
    final Pair<FileInfo, FileInfo> folderAndDocument = transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Pair<FileInfo, FileInfo>>() {

        private static final String TEST_NAME = "mnt10548test-";

        @Override
        public Pair<FileInfo, FileInfo> execute() throws Throwable {
            NodeRef companyHomeNodeRef = repositoryHelper.getCompanyHome();
            /* Create folder within companyHome */
            String folderName = TEST_NAME + GUID.generate();
            FileInfo folderInfo = fileFolderService.create(companyHomeNodeRef, folderName, ContentModel.TYPE_FOLDER);
            nodeService.setProperty(folderInfo.getNodeRef(), ContentModel.PROP_NAME, folderName);
            assertNotNull(folderInfo);
            /* Create content */
            String docName = TEST_NAME + GUID.generate();
            FileInfo document = fileFolderService.create(folderInfo.getNodeRef(), docName, ContentModel.TYPE_CONTENT);
            assertNotNull(document);
            nodeService.setProperty(document.getNodeRef(), ContentModel.PROP_NAME, docName);
            /* Add some tags */
            NodeRef nodeRef = document.getNodeRef();
            taggingService.addTag(nodeRef, "tag1");
            taggingService.addTag(nodeRef, "tag2");
            taggingService.addTag(nodeRef, "tag3");
            return new Pair<FileInfo, FileInfo>(folderInfo, document);
        }
    });
    ObjectData objData = withCmisService(new CmisServiceCallback<ObjectData>() {

        private static final String FILE_FOLDER_SEPARATOR = "/";

        @Override
        public ObjectData execute(CmisService cmisService) {
            List<RepositoryInfo> repositories = cmisService.getRepositoryInfos(null);
            assertTrue(repositories.size() > 0);
            RepositoryInfo repo = repositories.get(0);
            String repositoryId = repo.getId();
            String path = FILE_FOLDER_SEPARATOR + folderAndDocument.getFirst().getName() + FILE_FOLDER_SEPARATOR + folderAndDocument.getSecond().getName();
            /* get CMIS object of document */
            ObjectData objData = cmisService.getObjectByPath(repositoryId, path, null, false, null, null, false, false, null);
            return objData;
        }
    }, CmisVersion.CMIS_1_1);
    Map<String, PropertyData<?>> cmisProps = objData.getProperties().getProperties();
    String taggable = ContentModel.ASPECT_TAGGABLE.getPrefixedQName(namespaceService).toPrefixString();
    PropertyData<?> propData = cmisProps.get(taggable);
    assertNotNull(propData);
    List<?> props = propData.getValues();
    assertTrue(props.size() == 3);
    /* MNT-10548 fix : CMIS should return List of String, not List of NodeRef */
    for (Object o : props) {
        assertTrue(o.getClass() + " found but String expected", o instanceof String);
    }
}
Also used : PropertyData(org.apache.chemistry.opencmis.commons.data.PropertyData) RepositoryInfo(org.apache.chemistry.opencmis.commons.data.RepositoryInfo) ObjectData(org.apache.chemistry.opencmis.commons.data.ObjectData) NodeRef(org.alfresco.service.cmr.repository.NodeRef) FileInfo(org.alfresco.service.cmr.model.FileInfo) CmisService(org.apache.chemistry.opencmis.commons.server.CmisService) ObjectInFolderList(org.apache.chemistry.opencmis.commons.data.ObjectInFolderList) ArrayList(java.util.ArrayList) ObjectList(org.apache.chemistry.opencmis.commons.data.ObjectList) List(java.util.List) UnfileObject(org.apache.chemistry.opencmis.commons.enums.UnfileObject) Pair(org.alfresco.util.Pair) Category(org.junit.experimental.categories.Category) VersionableAspectTest(org.alfresco.repo.version.VersionableAspectTest) Test(org.junit.Test)

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