Search in sources :

Example 1 with ObjectInFolderContainer

use of org.apache.chemistry.opencmis.commons.data.ObjectInFolderContainer in project copper-cms by PogeyanOSS.

the class NavigationActor method getFolderTree.

private JSONArray getFolderTree(QueryGetRequest request) throws CmisInvalidArgumentException, CmisRuntimeException {
    String permission = request.getUserObject().getPermission();
    if (!Helpers.checkingUserPremission(permission, "get")) {
        throw new CmisRuntimeException(request.getUserName() + " is not authorized to applyAcl.");
    }
    String folderId = request.getObjectId();
    String filter = request.getParameter(QueryGetRequest.PARAM_FILTER);
    BigInteger depth = request.getBigIntegerParameter(QueryGetRequest.PARAM_DEPTH);
    Boolean includeAllowableActions = request.getBooleanParameter(QueryGetRequest.PARAM_ALLOWABLE_ACTIONS);
    IncludeRelationships includeRelationships = request.getEnumParameter(QueryGetRequest.PARAM_RELATIONSHIPS, IncludeRelationships.class);
    String renditionFilter = request.getParameter(QueryGetRequest.PARAM_RENDITION_FILTER);
    Boolean includePathSegment = request.getBooleanParameter(QueryGetRequest.PARAM_PATH_SEGMENT);
    boolean succinct = request.getBooleanParameter(QueryGetRequest.PARAM_SUCCINCT, false);
    DateTimeFormat dateTimeFormat = request.getDateTimeFormatParameter();
    List<ObjectInFolderContainer> folderTree = CmisNavigationService.Impl.getFolderTree(request.getRepositoryId(), folderId, depth, filter, includeAllowableActions, includeRelationships, renditionFilter, includePathSegment, null, request.getUserObject());
    if (folderTree == null) {
        throw new CmisRuntimeException("Folder Tree are null!");
    }
    JSONArray jsonDescendants = new JSONArray();
    for (ObjectInFolderContainer descendant : folderTree) {
        jsonDescendants.add(JSONConverter.convert(descendant, CmisTypeCacheService.get(request.getRepositoryId()), succinct, dateTimeFormat));
    }
    return jsonDescendants;
}
Also used : CmisRuntimeException(org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException) JSONArray(org.apache.chemistry.opencmis.commons.impl.json.JSONArray) BigInteger(java.math.BigInteger) IncludeRelationships(org.apache.chemistry.opencmis.commons.enums.IncludeRelationships) ObjectInFolderContainer(org.apache.chemistry.opencmis.commons.data.ObjectInFolderContainer) DateTimeFormat(org.apache.chemistry.opencmis.commons.enums.DateTimeFormat)

Example 2 with ObjectInFolderContainer

use of org.apache.chemistry.opencmis.commons.data.ObjectInFolderContainer in project copper-cms by PogeyanOSS.

the class NavigationActor method getDescendants.

private JSONArray getDescendants(QueryGetRequest request) throws CmisInvalidArgumentException, CmisRuntimeException {
    String permission = request.getUserObject().getPermission();
    if (!Helpers.checkingUserPremission(permission, "get")) {
        throw new CmisRuntimeException(request.getUserName() + " is not authorized to applyAcl.");
    }
    String folderId = request.getObjectId();
    String filter = request.getParameter(QueryGetRequest.PARAM_FILTER);
    BigInteger depth = request.getBigIntegerParameter(QueryGetRequest.PARAM_DEPTH);
    Boolean includeAllowableActions = request.getBooleanParameter(QueryGetRequest.PARAM_ALLOWABLE_ACTIONS);
    includeAllowableActions = includeAllowableActions == null ? false : includeAllowableActions;
    IncludeRelationships includeRelationships = request.getEnumParameter(QueryGetRequest.PARAM_RELATIONSHIPS, IncludeRelationships.class);
    String renditionFilter = request.getParameter(QueryGetRequest.PARAM_RENDITION_FILTER);
    Boolean includePathSegment = request.getBooleanParameter(QueryGetRequest.PARAM_PATH_SEGMENT);
    boolean succinct = request.getBooleanParameter(QueryGetRequest.PARAM_SUCCINCT, false);
    DateTimeFormat dateTimeFormat = request.getDateTimeFormatParameter();
    List<ObjectInFolderContainer> descendants = CmisNavigationService.Impl.getDescendants(request.getRepositoryId(), folderId, depth, filter, includeAllowableActions, includeRelationships, renditionFilter, includePathSegment, null, request.getUserObject());
    if (descendants == null) {
        throw new CmisRuntimeException("Descendants are null!");
    }
    JSONArray jsonDescendants = new JSONArray();
    for (ObjectInFolderContainer descendant : descendants) {
        jsonDescendants.add(JSONConverter.convert(descendant, CmisTypeCacheService.get(request.getRepositoryId()), succinct, dateTimeFormat));
    }
    return jsonDescendants;
}
Also used : CmisRuntimeException(org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException) JSONArray(org.apache.chemistry.opencmis.commons.impl.json.JSONArray) BigInteger(java.math.BigInteger) IncludeRelationships(org.apache.chemistry.opencmis.commons.enums.IncludeRelationships) ObjectInFolderContainer(org.apache.chemistry.opencmis.commons.data.ObjectInFolderContainer) DateTimeFormat(org.apache.chemistry.opencmis.commons.enums.DateTimeFormat)

Example 3 with ObjectInFolderContainer

use of org.apache.chemistry.opencmis.commons.data.ObjectInFolderContainer in project structr by structr.

the class CMISNavigationService method getDescendants.

@Override
public List<ObjectInFolderContainer> getDescendants(String repositoryId, String folderId, BigInteger depth, String filter, Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter, Boolean includePathSegment, ExtensionsData extension) {
    final List<ObjectInFolderContainer> result = new LinkedList<>();
    final App app = StructrApp.getInstance();
    try (final Tx tx = app.tx()) {
        int maxDepth = Integer.MAX_VALUE;
        if (depth != null && depth.intValue() >= 0) {
            maxDepth = depth.intValue();
        }
        for (final AbstractFile child : getChildrenQuery(app, folderId).getAsList()) {
            recursivelyCollectDescendants(result, child, maxDepth, 1, includeAllowableActions);
        }
        tx.success();
    } catch (final FrameworkException fex) {
        logger.warn("", fex);
    }
    return result;
}
Also used : StructrApp(org.structr.core.app.StructrApp) App(org.structr.core.app.App) AbstractFile(org.structr.web.entity.AbstractFile) Tx(org.structr.core.graph.Tx) FrameworkException(org.structr.common.error.FrameworkException) ObjectInFolderContainer(org.apache.chemistry.opencmis.commons.data.ObjectInFolderContainer) LinkedList(java.util.LinkedList)

Example 4 with ObjectInFolderContainer

use of org.apache.chemistry.opencmis.commons.data.ObjectInFolderContainer in project structr by structr.

the class CMISNavigationService method recursivelyCollectFolderTree.

// ----- private methods -----
private void recursivelyCollectFolderTree(final List<ObjectInFolderContainer> list, final Folder child, final int maxDepth, final int depth, final Boolean includeAllowableActions) throws FrameworkException {
    if (depth > maxDepth) {
        return;
    }
    final CMISObjectInFolderWrapper wrapper = new CMISObjectInFolderWrapper(includeAllowableActions);
    final ObjectInFolderContainerImpl impl = new ObjectInFolderContainerImpl();
    final List<ObjectInFolderContainer> childContainerList = new LinkedList<>();
    final String pathSegment = child.getName();
    impl.setObject(wrapper.wrapObjectData(wrapper.wrapGraphObject(child), pathSegment));
    impl.setChildren(childContainerList);
    // add wrapped object to current list
    list.add(impl);
    // fetch and sort children
    final List<Folder> children = Iterables.toList(child.getFolders());
    Collections.sort(children, new GraphObjectComparator(AbstractNode.name, false));
    // descend into children
    for (final Folder folderChild : children) {
        recursivelyCollectFolderTree(childContainerList, folderChild, maxDepth, depth + 1, includeAllowableActions);
    }
}
Also used : ObjectInFolderContainerImpl(org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectInFolderContainerImpl) CMISObjectInFolderWrapper(org.structr.files.cmis.wrapper.CMISObjectInFolderWrapper) GraphObjectComparator(org.structr.common.GraphObjectComparator) CMISRootFolder(org.structr.files.cmis.repository.CMISRootFolder) Folder(org.structr.web.entity.Folder) ObjectInFolderContainer(org.apache.chemistry.opencmis.commons.data.ObjectInFolderContainer) LinkedList(java.util.LinkedList)

Example 5 with ObjectInFolderContainer

use of org.apache.chemistry.opencmis.commons.data.ObjectInFolderContainer in project structr by structr.

the class CMISNavigationService method recursivelyCollectDescendants.

private void recursivelyCollectDescendants(final List<ObjectInFolderContainer> list, final AbstractFile child, final int maxDepth, final int depth, final Boolean includeAllowableActions) throws FrameworkException {
    if (depth > maxDepth) {
        return;
    }
    final PropertyKey<Folder> parent = StructrApp.key(AbstractFile.class, "parent");
    final PropertyKey<Boolean> hasParent = StructrApp.key(AbstractFile.class, "hasParent");
    final PropertyKey<Boolean> isThumbnail = StructrApp.key(Image.class, "isThumbnail");
    final CMISObjectInFolderWrapper wrapper = new CMISObjectInFolderWrapper(includeAllowableActions);
    final ObjectInFolderContainerImpl impl = new ObjectInFolderContainerImpl();
    final List<ObjectInFolderContainer> childContainerList = new LinkedList<>();
    final String pathSegment = child.getName();
    impl.setObject(wrapper.wrapObjectData(wrapper.wrapGraphObject(child), pathSegment));
    impl.setChildren(childContainerList);
    // add wrapped object to current list
    list.add(impl);
    if (child.getProperty(AbstractNode.type).equals("Folder")) {
        final App app = StructrApp.getInstance();
        // descend into children
        for (final AbstractFile folderChild : app.nodeQuery(AbstractFile.class).sort(AbstractNode.name).and(parent, (Folder) child).and(isThumbnail, false).getAsList()) {
            recursivelyCollectDescendants(childContainerList, folderChild, maxDepth, depth + 1, includeAllowableActions);
        }
    }
}
Also used : StructrApp(org.structr.core.app.StructrApp) App(org.structr.core.app.App) AbstractFile(org.structr.web.entity.AbstractFile) ObjectInFolderContainerImpl(org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectInFolderContainerImpl) CMISObjectInFolderWrapper(org.structr.files.cmis.wrapper.CMISObjectInFolderWrapper) CMISRootFolder(org.structr.files.cmis.repository.CMISRootFolder) Folder(org.structr.web.entity.Folder) ObjectInFolderContainer(org.apache.chemistry.opencmis.commons.data.ObjectInFolderContainer) LinkedList(java.util.LinkedList)

Aggregations

ObjectInFolderContainer (org.apache.chemistry.opencmis.commons.data.ObjectInFolderContainer)6 LinkedList (java.util.LinkedList)4 App (org.structr.core.app.App)3 StructrApp (org.structr.core.app.StructrApp)3 CMISRootFolder (org.structr.files.cmis.repository.CMISRootFolder)3 Folder (org.structr.web.entity.Folder)3 BigInteger (java.math.BigInteger)2 DateTimeFormat (org.apache.chemistry.opencmis.commons.enums.DateTimeFormat)2 IncludeRelationships (org.apache.chemistry.opencmis.commons.enums.IncludeRelationships)2 CmisRuntimeException (org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException)2 ObjectInFolderContainerImpl (org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectInFolderContainerImpl)2 JSONArray (org.apache.chemistry.opencmis.commons.impl.json.JSONArray)2 GraphObjectComparator (org.structr.common.GraphObjectComparator)2 FrameworkException (org.structr.common.error.FrameworkException)2 Tx (org.structr.core.graph.Tx)2 CMISObjectInFolderWrapper (org.structr.files.cmis.wrapper.CMISObjectInFolderWrapper)2 AbstractFile (org.structr.web.entity.AbstractFile)2 CmisObjectNotFoundException (org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException)1