Search in sources :

Example 1 with FolderTypeDefintionWrapper

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

the class CMISConnector method createObjectId.

public String createObjectId(NodeRef nodeRef, boolean dropStoreRef) {
    QName typeQName = nodeService.getType(nodeRef);
    TypeDefinitionWrapper type = getOpenCMISDictionaryService().findNodeType(typeQName);
    if (type instanceof ItemTypeDefinitionWrapper) {
        return constructObjectId(nodeRef, null);
    }
    if (type instanceof FolderTypeDefintionWrapper) {
        return constructObjectId(nodeRef, null, dropStoreRef);
    }
    Serializable versionLabel = getNodeService().getProperty(nodeRef, ContentModel.PROP_VERSION_LABEL);
    if (versionLabel == null) {
        versionLabel = CMISConnector.UNVERSIONED_VERSION_LABEL;
    }
    return constructObjectId(nodeRef, (String) versionLabel, dropStoreRef);
}
Also used : Serializable(java.io.Serializable) QName(org.alfresco.service.namespace.QName) ItemTypeDefinitionWrapper(org.alfresco.opencmis.dictionary.ItemTypeDefinitionWrapper) TypeDefinitionWrapper(org.alfresco.opencmis.dictionary.TypeDefinitionWrapper) DocumentTypeDefinitionWrapper(org.alfresco.opencmis.dictionary.DocumentTypeDefinitionWrapper) FolderTypeDefintionWrapper(org.alfresco.opencmis.dictionary.FolderTypeDefintionWrapper) ItemTypeDefinitionWrapper(org.alfresco.opencmis.dictionary.ItemTypeDefinitionWrapper)

Example 2 with FolderTypeDefintionWrapper

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

the class AlfrescoCmisServiceImpl method getDescendantsTree.

private void getDescendantsTree(String repositoryId, NodeRef folderNodeRef, int depth, String filter, Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter, Boolean includePathSegment, boolean foldersOnly, List<ObjectInFolderContainer> list) {
    // get the children references
    List<ChildAssociationRef> childrenList = connector.getNodeService().getChildAssocs(folderNodeRef);
    for (ChildAssociationRef child : childrenList) {
        try {
            TypeDefinitionWrapper type = connector.getType(child.getChildRef());
            if (type == null) {
                continue;
            }
            boolean isFolder = (type instanceof FolderTypeDefintionWrapper);
            if (foldersOnly && !isFolder) {
                continue;
            }
            if (isFolder && type.getAlfrescoClass().equals(ContentModel.TYPE_SYSTEM_FOLDER)) {
                continue;
            }
            if (connector.isHidden(child.getChildRef())) {
                continue;
            }
            if (connector.filter(child.getChildRef())) {
                continue;
            }
            boolean isObjectInfoRequired = getContext().isObjectInfoRequired();
            // create a child CMIS object
            ObjectInFolderDataImpl object = new ObjectInFolderDataImpl();
            // note: checkExists=false (don't need to check again)
            CMISNodeInfo ni = createNodeInfo(child.getChildRef(), null, false);
            object.setObject(connector.createCMISObject(ni, filter, includeAllowableActions, includeRelationships, renditionFilter, false, false));
            if (isObjectInfoRequired) {
                getObjectInfo(repositoryId, ni.getObjectId(), includeRelationships);
            }
            if (includePathSegment) {
                object.setPathSegment(connector.getName(child.getChildRef()));
            }
            // create the container
            ObjectInFolderContainerImpl container = new ObjectInFolderContainerImpl();
            container.setObject(object);
            if ((depth != 1) && isFolder) {
                container.setChildren(new ArrayList<ObjectInFolderContainer>());
                getDescendantsTree(repositoryId, child.getChildRef(), depth - 1, filter, includeAllowableActions, includeRelationships, renditionFilter, includePathSegment, foldersOnly, container.getChildren());
            }
            // add it
            list.add(container);
        } catch (InvalidNodeRefException e) {
        // ignore invalid children
        } catch (CmisObjectNotFoundException e) {
        // ignore objects that have not been found (perhaps because their type is unknown to CMIS)
        }
    }
}
Also used : ObjectInFolderDataImpl(org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectInFolderDataImpl) CmisObjectNotFoundException(org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException) ObjectInFolderContainerImpl(org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectInFolderContainerImpl) TypeDefinitionWrapper(org.alfresco.opencmis.dictionary.TypeDefinitionWrapper) InvalidNodeRefException(org.alfresco.service.cmr.repository.InvalidNodeRefException) CMISNodeInfo(org.alfresco.opencmis.dictionary.CMISNodeInfo) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef) FolderTypeDefintionWrapper(org.alfresco.opencmis.dictionary.FolderTypeDefintionWrapper) ObjectInFolderContainer(org.apache.chemistry.opencmis.commons.data.ObjectInFolderContainer)

Example 3 with FolderTypeDefintionWrapper

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

the class CMISNodeInfoImpl method getParents.

@Override
public List<CMISNodeInfo> getParents() {
    if ((objecVariant == CMISObjectVariant.INVALID_ID) || (objecVariant == CMISObjectVariant.NOT_A_CMIS_OBJECT) || (objecVariant == CMISObjectVariant.NOT_EXISTING) || (objecVariant == CMISObjectVariant.PERMISSION_DENIED)) {
        return Collections.<CMISNodeInfo>emptyList();
    }
    if (parents == null) {
        parents = new ArrayList<CMISNodeInfo>();
        NodeRef nodeRefForParent = (isCurrentVersion() ? getCurrentNodeNodeRef() : nodeRef);
        List<ChildAssociationRef> nodeParents = connector.getNodeService().getParentAssocs(nodeRefForParent, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL);
        if (nodeParents != null) {
            for (ChildAssociationRef parent : nodeParents) {
                if (connector.getType(parent.getParentRef()) instanceof FolderTypeDefintionWrapper) {
                    parents.add(new CMISNodeInfoImpl(connector, parent.getParentRef()));
                }
            }
        }
    }
    return parents;
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) CMISNodeInfo(org.alfresco.opencmis.dictionary.CMISNodeInfo) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef) FolderTypeDefintionWrapper(org.alfresco.opencmis.dictionary.FolderTypeDefintionWrapper)

Aggregations

FolderTypeDefintionWrapper (org.alfresco.opencmis.dictionary.FolderTypeDefintionWrapper)3 CMISNodeInfo (org.alfresco.opencmis.dictionary.CMISNodeInfo)2 TypeDefinitionWrapper (org.alfresco.opencmis.dictionary.TypeDefinitionWrapper)2 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)2 Serializable (java.io.Serializable)1 DocumentTypeDefinitionWrapper (org.alfresco.opencmis.dictionary.DocumentTypeDefinitionWrapper)1 ItemTypeDefinitionWrapper (org.alfresco.opencmis.dictionary.ItemTypeDefinitionWrapper)1 InvalidNodeRefException (org.alfresco.service.cmr.repository.InvalidNodeRefException)1 NodeRef (org.alfresco.service.cmr.repository.NodeRef)1 QName (org.alfresco.service.namespace.QName)1 ObjectInFolderContainer (org.apache.chemistry.opencmis.commons.data.ObjectInFolderContainer)1 CmisObjectNotFoundException (org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException)1 ObjectInFolderContainerImpl (org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectInFolderContainerImpl)1 ObjectInFolderDataImpl (org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectInFolderDataImpl)1