Search in sources :

Example 11 with TypeDefinitionWrapper

use of org.alfresco.opencmis.dictionary.TypeDefinitionWrapper in project alfresco-repository by Alfresco.

the class AlfrescoCmisServiceImpl method createFolder.

@Override
public String createFolder(String repositoryId, final Properties properties, String folderId, final List<String> policies, final Acl addAces, final Acl removeAces, ExtensionsData extension) {
    checkRepositoryId(repositoryId);
    // get the parent folder node ref
    final CMISNodeInfo parentInfo = getOrCreateFolderInfo(folderId, "Folder");
    // get name and type
    final String name = connector.getNameProperty(properties, null);
    final String objectTypeId = connector.getObjectTypeIdProperty(properties);
    final TypeDefinitionWrapper type = connector.getTypeForCreate(objectTypeId, BaseTypeId.CMIS_FOLDER);
    connector.checkChildObjectType(parentInfo, type.getTypeId());
    // run transaction
    FileInfo fileInfo = connector.getFileFolderService().create(parentInfo.getNodeRef(), name, type.getAlfrescoClass());
    NodeRef nodeRef = fileInfo.getNodeRef();
    connector.setProperties(nodeRef, type, properties, new String[] { PropertyIds.NAME, PropertyIds.OBJECT_TYPE_ID });
    connector.applyPolicies(nodeRef, type, policies);
    connector.applyACL(nodeRef, type, addAces, removeAces);
    connector.getActivityPoster().postFileFolderAdded(nodeRef);
    String objectId = connector.createObjectId(nodeRef);
    return objectId;
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) FileInfo(org.alfresco.service.cmr.model.FileInfo) TypeDefinitionWrapper(org.alfresco.opencmis.dictionary.TypeDefinitionWrapper) CMISNodeInfo(org.alfresco.opencmis.dictionary.CMISNodeInfo)

Example 12 with TypeDefinitionWrapper

use of org.alfresco.opencmis.dictionary.TypeDefinitionWrapper in project alfresco-repository by Alfresco.

the class AlfrescoCmisServiceImpl method getTypeChildren.

@Override
public TypeDefinitionList getTypeChildren(String repositoryId, String typeId, Boolean includePropertyDefinitions, BigInteger maxItems, BigInteger skipCount, ExtensionsData extension) {
    checkRepositoryId(repositoryId);
    // convert BigIntegers to int
    int max = (maxItems == null ? Integer.MAX_VALUE : maxItems.intValue());
    int skip = (skipCount == null || skipCount.intValue() < 0 ? 0 : skipCount.intValue());
    // set up the result
    TypeDefinitionListImpl result = new TypeDefinitionListImpl();
    List<TypeDefinition> list = new ArrayList<TypeDefinition>();
    result.setList(list);
    // get the types from the dictionary
    List<TypeDefinitionWrapper> childrenList;
    if (typeId == null) {
        childrenList = connector.getOpenCMISDictionaryService().getBaseTypes(true);
    } else {
        TypeDefinitionWrapper tdw = connector.getOpenCMISDictionaryService().findType(typeId);
        if (tdw == null) {
            throw new CmisObjectNotFoundException("Type '" + typeId + "' is unknown!");
        }
        childrenList = connector.getOpenCMISDictionaryService().getChildren(typeId);
    // childrenList = tdw.getChildren();
    }
    // create result
    if (max > 0) {
        int lastIndex = (max + skip > childrenList.size() ? childrenList.size() : max + skip) - 1;
        for (int i = skip; i <= lastIndex; i++) {
            list.add(childrenList.get(i).getTypeDefinition(includePropertyDefinitions));
        }
    }
    result.setHasMoreItems(childrenList.size() - skip > result.getList().size());
    result.setNumItems(BigInteger.valueOf(childrenList.size()));
    return result;
}
Also used : CmisObjectNotFoundException(org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException) TypeDefinitionWrapper(org.alfresco.opencmis.dictionary.TypeDefinitionWrapper) ArrayList(java.util.ArrayList) TypeDefinitionListImpl(org.apache.chemistry.opencmis.commons.impl.dataobjects.TypeDefinitionListImpl) DocumentTypeDefinition(org.apache.chemistry.opencmis.commons.definitions.DocumentTypeDefinition) TypeDefinition(org.apache.chemistry.opencmis.commons.definitions.TypeDefinition)

Example 13 with TypeDefinitionWrapper

use of org.alfresco.opencmis.dictionary.TypeDefinitionWrapper in project alfresco-repository by Alfresco.

the class AlfrescoCmisServiceImpl method applyAcl.

// --- ACL service ---
@Override
public Acl applyAcl(String repositoryId, String objectId, final Acl addAces, final Acl removeAces, AclPropagation aclPropagation, ExtensionsData extension) {
    checkRepositoryId(repositoryId);
    // We are spec compliant if we just let it through and the tck will not fail
    CMISNodeInfo info = getOrCreateNodeInfo(objectId, "Object");
    // relationships don't have ACLs
    if (info.isVariant(CMISObjectVariant.ASSOC)) {
        throw new CmisConstraintException("Relationships are not ACL controllable!");
    }
    final NodeRef nodeRef = info.getCurrentNodeNodeRef();
    final TypeDefinitionWrapper type = info.getType();
    connector.applyACL(nodeRef, type, addAces, removeAces);
    return connector.getACL(nodeRef, false);
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) CmisConstraintException(org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException) TypeDefinitionWrapper(org.alfresco.opencmis.dictionary.TypeDefinitionWrapper) CMISNodeInfo(org.alfresco.opencmis.dictionary.CMISNodeInfo)

Example 14 with TypeDefinitionWrapper

use of org.alfresco.opencmis.dictionary.TypeDefinitionWrapper in project alfresco-repository by Alfresco.

the class CMISChangeLogDataExtractor method isSupported.

/**
 * @return Returns <tt>true</tt> if items in the CMIS domain model
 * @see org.alfresco.repo.audit.extractor.DataExtractor#isSupported(java.io.Serializable)
 */
public boolean isSupported(Serializable data) {
    if (data != null) {
        NodeRef nodeRef = getNodeRef(data);
        if (nodeRef != null) {
            QName typeQName = nodeService.getType(nodeRef);
            TypeDefinitionWrapper type = cmisDictionaryService.findNodeType(typeQName);
            return (type != null) && (type.getBaseTypeId() == BaseTypeId.CMIS_DOCUMENT || type.getBaseTypeId() == BaseTypeId.CMIS_FOLDER);
        }
    }
    return false;
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) QName(org.alfresco.service.namespace.QName) TypeDefinitionWrapper(org.alfresco.opencmis.dictionary.TypeDefinitionWrapper)

Example 15 with TypeDefinitionWrapper

use of org.alfresco.opencmis.dictionary.TypeDefinitionWrapper in project alfresco-repository by Alfresco.

the class CMISTest method testACE3322.

/**
 * ACE-3322
 */
@Test
public void testACE3322() {
    final String[] types = { "cmis:document", "cmis:relationship", "cmis:folder", "cmis:item" };
    CmisServiceCallback<String> callback = new CmisServiceCallback<String>() {

        @Override
        public String execute(CmisService cmisService) {
            for (int i = 0; i < types.length; i++) {
                List<TypeDefinitionWrapper> baseTypes = cmisDictionaryService.getBaseTypes();
                assertNotNull(baseTypes);
                checkDefs(baseTypes);
                List<TypeDefinitionWrapper> children = cmisDictionaryService.getChildren(types[i]);
                assertNotNull(children);
                // Check that children were updated
                checkDefs(children);
            }
            return "";
        }

        private void checkDefs(List<TypeDefinitionWrapper> defs) {
            for (TypeDefinitionWrapper def : defs) {
                assertNotNull("Type definition was not updated. Please refer to ACE-3322", def.getTypeDefinition(false).getDisplayName());
                assertNotNull("Type definition was not updated. Please refer to ACE-3322", def.getTypeDefinition(false).getDescription());
                // Check that property's display name and description were updated
                for (PropertyDefinitionWrapper property : def.getProperties()) {
                    assertNotNull("Display name is null", property.getPropertyDefinition().getDisplayName());
                    assertNotNull("Description is null", property.getPropertyDefinition().getDescription());
                }
            }
        }
    };
    withCmisService(callback, CmisVersion.CMIS_1_1);
}
Also used : PropertyDefinitionWrapper(org.alfresco.opencmis.dictionary.PropertyDefinitionWrapper) CmisService(org.apache.chemistry.opencmis.commons.server.CmisService) TypeDefinitionWrapper(org.alfresco.opencmis.dictionary.TypeDefinitionWrapper) ObjectInFolderList(org.apache.chemistry.opencmis.commons.data.ObjectInFolderList) ArrayList(java.util.ArrayList) ObjectList(org.apache.chemistry.opencmis.commons.data.ObjectList) List(java.util.List) VersionableAspectTest(org.alfresco.repo.version.VersionableAspectTest) Test(org.junit.Test)

Aggregations

TypeDefinitionWrapper (org.alfresco.opencmis.dictionary.TypeDefinitionWrapper)33 CMISNodeInfo (org.alfresco.opencmis.dictionary.CMISNodeInfo)13 DocumentTypeDefinitionWrapper (org.alfresco.opencmis.dictionary.DocumentTypeDefinitionWrapper)13 ItemTypeDefinitionWrapper (org.alfresco.opencmis.dictionary.ItemTypeDefinitionWrapper)13 NodeRef (org.alfresco.service.cmr.repository.NodeRef)12 CmisObjectNotFoundException (org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException)11 ArrayList (java.util.ArrayList)10 PropertyString (org.apache.chemistry.opencmis.commons.data.PropertyString)9 CmisConstraintException (org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException)9 CmisInvalidArgumentException (org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException)9 Serializable (java.io.Serializable)8 QName (org.alfresco.service.namespace.QName)8 PropertyDefinitionWrapper (org.alfresco.opencmis.dictionary.PropertyDefinitionWrapper)7 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)5 InvalidNodeRefException (org.alfresco.service.cmr.repository.InvalidNodeRefException)5 HashMap (java.util.HashMap)4 HashSet (java.util.HashSet)4 List (java.util.List)4 FileInfo (org.alfresco.service.cmr.model.FileInfo)4 ObjectData (org.apache.chemistry.opencmis.commons.data.ObjectData)4