Package org.apache.chemistry.opencmis.commons.impl.dataobjects

Examples of org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectListImpl


    public ObjectList buildResultList(TypeManager tm, String user, Boolean includeAllowableActions,
            IncludeRelationships includeRelationships, String renditionFilter, BigInteger maxItems, BigInteger skipCount) {

        sortMatches();

        ObjectListImpl res = new ObjectListImpl();
        res.setNumItems(BigInteger.valueOf(matches.size()));
        int start = 0;
        if (skipCount != null) {
            start = (int) skipCount.longValue();
        }
        if (start < 0) {
            start = 0;
        }
        if (start > matches.size()) {
            start = matches.size();
        }
        int stop = 0;
        if (maxItems != null) {
            stop = start + (int) maxItems.longValue();
        }
        if (stop <= 0 || stop > matches.size()) {
            stop = matches.size();
        }
        res.setHasMoreItems(stop < matches.size());
        if (start > 0 || stop > 0) {
            matches = matches.subList(start, stop);
        }
        List<ObjectData> objDataList = new ArrayList<ObjectData>();
        Map<String, String> props = queryObj.getRequestedProperties();
        Map<String, String> funcs = queryObj.getRequestedFuncs();
        for (StoredObject so : matches) {
            TypeDefinition td = tm.getTypeById(so.getTypeId()).getTypeDefinition();
            ObjectData od = PropertyCreationHelper.getObjectDataQueryResult(td, so, user, props, funcs,
                    includeAllowableActions, includeRelationships, renditionFilter);

            objDataList.add(od);
        }
        res.setObjects(objDataList);
        return res;
    }
View Full Code Here


        // dummy implementation using hard coded values

        RepositoryInfo rep = fRepositoryService.getRepositoryInfo(context, repositoryId, null);
        String rootFolderId = rep.getRootFolderId();

        ObjectListImpl objList = new ObjectListImpl();
        List<ObjectInFolderContainer> tempRes = fNavigationService.getDescendants(context, repositoryId, rootFolderId,
                BigInteger.valueOf(3), filter, false, IncludeRelationships.NONE, null, false, extension, null);

        // convert ObjectInFolderContainerList to objectList
        List<ObjectData> lod = new ArrayList<ObjectData>();
        for (ObjectInFolderContainer obj : tempRes) {
            convertList(lod, obj);
        }
        objList.setObjects(lod);
        objList.setNumItems(BigInteger.valueOf(lod.size()));

        // To be able to provide all Atom links in the response we need
        // additional information:
        fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, null, objectInfos, objList);
        return objList;
View Full Code Here

    public static ObjectList convert(CmisObjectListType objectList) {
        if (objectList == null) {
            return null;
        }

        ObjectListImpl result = new ObjectListImpl();

        List<ObjectData> objects = new ArrayList<ObjectData>();
        for (CmisObjectType object : objectList.getObjects()) {
            objects.add(convert(object));
        }

        result.setObjects(objects);
        result.setHasMoreItems(objectList.isHasMoreItems());
        result.setNumItems(objectList.getNumItems());

        // handle extensions
        convertExtension(objectList, result);

        return result;
View Full Code Here

            String orderBy, Boolean includeAllowableActions, IncludeRelationships includeRelationships,
            String renditionFilter, BigInteger maxItems, BigInteger skipCount, ExtensionsData extension,
            ObjectInfoHandler objectInfos) {

        validator.getCheckedOutDocs(context, repositoryId, folderId, extension);
        ObjectListImpl res = new ObjectListImpl();
        List<ObjectData> odList = new ArrayList<ObjectData>();

        LOG.debug("start getCheckedOutDocs()");

        String user = context.getUsername();
        if (null == folderId) {
            List<StoredObject> checkedOuts = fStoreManager.getObjectStore(repositoryId).getCheckedOutDocuments(
                    orderBy);
            for (StoredObject checkedOut : checkedOuts) {
                TypeDefinition td = fStoreManager.getTypeById(repositoryId, checkedOut.getTypeId()).getTypeDefinition();
                ObjectData od = PropertyCreationHelper.getObjectData(td, checkedOut, filter, user,
                        includeAllowableActions, includeRelationships, renditionFilter, false, false, extension);
                if (context.isObjectInfoRequired()) {
                    ObjectInfoImpl objectInfo = new ObjectInfoImpl();
                    fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, checkedOut, objectInfo);
                    objectInfos.addObjectInfo(objectInfo);
                }
                odList.add(od);
            }
        } else {
            ObjectInFolderList children = getChildrenIntern(repositoryId, folderId, filter, orderBy,
                    includeAllowableActions, includeRelationships, renditionFilter, false, -1, -1, false, context
                            .isObjectInfoRequired() ? objectInfos : null, user);
            for (ObjectInFolderData child : children.getObjects()) {
                ObjectData obj = child.getObject();
                StoredObject so = fStoreManager.getObjectStore(repositoryId).getObjectById(obj.getId());
                LOG.info("Checked out: children:" + obj.getId());
                if (so instanceof DocumentVersion && ((DocumentVersion) so).getParentDocument().isCheckedOut()) {
                    odList.add(obj);
                    if (context.isObjectInfoRequired()) {
                        ObjectInfoImpl objectInfo = new ObjectInfoImpl();
                        fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, so, objectInfo);
                        objectInfos.addObjectInfo(objectInfo);
                    }
                }
            }
        }
        res.setObjects(odList);
        res.setNumItems(BigInteger.valueOf(odList.size()));

        LOG.debug("end getCheckedOutDocs()");
        return res;
    }
View Full Code Here

            QueryManager queryManager = session.getWorkspace().getQueryManager();
            Query query = queryManager.createQuery(xPath, Query.XPATH);
            QueryResult queryResult = query.execute();

            // prepare results
            ObjectListImpl result = new ObjectListImpl();
            result.setObjects(new ArrayList<ObjectData>());
            result.setHasMoreItems(false);

            // iterate through children
            Set<String> splitFilter = splitFilter(filter);
            int count = 0;
            NodeIterator nodes = queryResult.getNodes();
            while (nodes.hasNext()) {
                Node node = nodes.nextNode();
                JcrNode jcrNode = nodeFactory.create(node);
                if (!jcrNode.isVersionable()) {
                    continue;
                }

                count++;

                if (skip > 0) {
                    skip--;
                    continue;
                }

                if (result.getObjects().size() >= max) {
                    result.setHasMoreItems(true);
                    continue;
                }
               
                // build and add child object
                JcrPrivateWorkingCopy jcrVersion = jcrNode.asVersion().getPwc();
                ObjectData objectData = jcrVersion.compileObjectType(splitFilter, includeAllowableActions, null, false);
                result.getObjects().add(objectData);
            }

            result.setNumItems(BigInteger.valueOf(count));
            return result;
        }
        catch (RepositoryException e) {
            log.debug(e.getMessage(), e);
            throw new CmisRuntimeException(e.getMessage(), e);
View Full Code Here

            }

            QueryResult queryResult = query.execute();

            // prepare results
            ObjectListImpl result = new ObjectListImpl();
            result.setObjects(new ArrayList<ObjectData>());
            result.setHasMoreItems(false);

            // iterate through children
            int count = 0;
            NodeIterator nodes = queryResult.getNodes();
            while (nodes.hasNext() && result.getObjects().size() < max) {
                Node node = nodes.nextNode();
                JcrNode jcrNode = nodeFactory.create(node);
                count++;

                // Get pwc if this node is versionable and checked out
                if (jcrNode.isVersionable() && jcrNode.asVersion().isCheckedOut()) {
                    jcrNode = jcrNode.asVersion().getPwc();
                }

                // build and add child object
                ObjectData objectData = jcrNode.compileObjectType(null, includeAllowableActions, null, false);
                result.getObjects().add(objectData);
            }

            result.setHasMoreItems(nodes.hasNext());
            result.setNumItems(BigInteger.valueOf(count));
            return result;
        }
        catch (RepositoryException e) {
            log.debug(e.getMessage(), e);
            throw new CmisRuntimeException(e.getMessage(), e);
View Full Code Here

    @Override
    public ObjectList getCheckedOutDocs(String repositoryId, String folderId, String filter, String orderBy,
            Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter,
            BigInteger maxItems, BigInteger skipCount, ExtensionsData extension) {
        ObjectListImpl result = new ObjectListImpl();
        result.setHasMoreItems(false);
        result.setNumItems(BigInteger.ZERO);
        List<ObjectData> emptyList = Collections.emptyList();
        result.setObjects(emptyList);

        return result;
    }
View Full Code Here

        setSession(session);
    }

    public ObjectList getContentChanges(String repositoryId, Holder<String> changeLogToken, Boolean includeProperties,
            String filter, Boolean includePolicyIds, Boolean includeACL, BigInteger maxItems, ExtensionsData extension) {
        ObjectListImpl result = new ObjectListImpl();

        // find the link
        String link = loadRepositoryLink(repositoryId, Constants.REP_REL_CHANGES);

        if (link == null) {
            throw new CmisObjectNotFoundException("Unknown repository or content changes not supported!");
        }

        UrlBuilder url = new UrlBuilder(link);
        url.addParameter(Constants.PARAM_CHANGE_LOG_TOKEN, (changeLogToken == null ? null : changeLogToken.getValue()));
        url.addParameter(Constants.PARAM_PROPERTIES, includeProperties);
        url.addParameter(Constants.PARAM_FILTER, filter);
        url.addParameter(Constants.PARAM_POLICY_IDS, includePolicyIds);
        url.addParameter(Constants.PARAM_ACL, includeACL);
        url.addParameter(Constants.PARAM_MAX_ITEMS, maxItems);

        // read and parse
        HttpUtils.Response resp = read(url);
        AtomFeed feed = parse(resp.getStream(), AtomFeed.class);

        // handle top level
        for (AtomElement element : feed.getElements()) {
            if (element.getObject() instanceof AtomLink) {
                if (isNextLink(element)) {
                    result.setHasMoreItems(Boolean.TRUE);
                }
            } else if (isInt(NAME_NUM_ITEMS, element)) {
                result.setNumItems((BigInteger) element.getObject());
            }
        }

        // get the changes
        if (!feed.getEntries().isEmpty()) {
            result.setObjects(new ArrayList<ObjectData>(feed.getEntries().size()));

            for (AtomEntry entry : feed.getEntries()) {
                ObjectData hit = null;

                // walk through the entry
                for (AtomElement element : entry.getElements()) {
                    if (element.getObject() instanceof CmisObjectType) {
                        hit = convert((CmisObjectType) element.getObject());
                    }
                }

                if (hit != null) {
                    result.getObjects().add(hit);
                }
            }
        }

        return result;
View Full Code Here

    }

    public ObjectList query(String repositoryId, String statement, Boolean searchAllVersions,
            Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter,
            BigInteger maxItems, BigInteger skipCount, ExtensionsData extension) {
        ObjectListImpl result = new ObjectListImpl();

        // find the link
        String link = loadCollection(repositoryId, Constants.COLLECTION_QUERY);

        if (link == null) {
            throw new CmisObjectNotFoundException("Unknown repository or query not supported!");
        }

        UrlBuilder url = new UrlBuilder(link);

        // compile query request
        final CmisQueryType query = new CmisQueryType();
        query.setStatement(statement);
        query.setSearchAllVersions(searchAllVersions);
        query.setIncludeAllowableActions(includeAllowableActions);
        query.setIncludeRelationships(convert(EnumIncludeRelationships.class, includeRelationships));
        query.setRenditionFilter(renditionFilter);
        query.setMaxItems(maxItems);
        query.setSkipCount(skipCount);

        // post the query and parse results
        HttpUtils.Response resp = post(url, Constants.MEDIATYPE_QUERY, new HttpUtils.Output() {
            public void write(OutputStream out) throws Exception {
                JaxBHelper.marshal(JaxBHelper.CMIS_OBJECT_FACTORY.createQuery(query), out, false);
            }
        });
        AtomFeed feed = parse(resp.getStream(), AtomFeed.class);

        // handle top level
        for (AtomElement element : feed.getElements()) {
            if (element.getObject() instanceof AtomLink) {
                if (isNextLink(element)) {
                    result.setHasMoreItems(Boolean.TRUE);
                }
            } else if (isInt(NAME_NUM_ITEMS, element)) {
                result.setNumItems((BigInteger) element.getObject());
            }
        }

        // get the result set
        if (!feed.getEntries().isEmpty()) {
            result.setObjects(new ArrayList<ObjectData>(feed.getEntries().size()));

            for (AtomEntry entry : feed.getEntries()) {
                ObjectData hit = null;

                // walk through the entry
                for (AtomElement element : entry.getElements()) {
                    if (element.getObject() instanceof CmisObjectType) {
                        hit = convert((CmisObjectType) element.getObject());
                    }
                }

                if (hit != null) {
                    result.getObjects().add(hit);
                }
            }
        }

        return result;
View Full Code Here

    }

    public ObjectList getObjectRelationships(String repositoryId, String objectId, Boolean includeSubRelationshipTypes,
            RelationshipDirection relationshipDirection, String typeId, String filter, Boolean includeAllowableActions,
            BigInteger maxItems, BigInteger skipCount, ExtensionsData extension) {
        ObjectListImpl result = new ObjectListImpl();

        // find the link
        String link = loadLink(repositoryId, objectId, Constants.REL_RELATIONSHIPS, Constants.MEDIATYPE_FEED);

        if (link == null) {
            throwLinkException(repositoryId, objectId, Constants.REL_RELATIONSHIPS, Constants.MEDIATYPE_FEED);
        }

        UrlBuilder url = new UrlBuilder(link);
        url.addParameter(Constants.PARAM_SUB_RELATIONSHIP_TYPES, includeSubRelationshipTypes);
        url.addParameter(Constants.PARAM_RELATIONSHIP_DIRECTION, relationshipDirection);
        url.addParameter(Constants.PARAM_TYPE_ID, typeId);
        url.addParameter(Constants.PARAM_FILTER, filter);
        url.addParameter(Constants.PARAM_ALLOWABLE_ACTIONS, includeAllowableActions);
        url.addParameter(Constants.PARAM_MAX_ITEMS, maxItems);
        url.addParameter(Constants.PARAM_SKIP_COUNT, skipCount);

        // read and parse
        HttpUtils.Response resp = read(url);
        AtomFeed feed = parse(resp.getStream(), AtomFeed.class);

        // handle top level
        for (AtomElement element : feed.getElements()) {
            if (element.getObject() instanceof AtomLink) {
                if (isNextLink(element)) {
                    result.setHasMoreItems(Boolean.TRUE);
                }
            } else if (isInt(NAME_NUM_ITEMS, element)) {
                result.setNumItems((BigInteger) element.getObject());
            }
        }

        // get the children
        if (!feed.getEntries().isEmpty()) {
            result.setObjects(new ArrayList<ObjectData>(feed.getEntries().size()));

            for (AtomEntry entry : feed.getEntries()) {
                ObjectData relationship = null;

                lockLinks();
                try {
                    // clean up cache
                    removeLinks(repositoryId, entry.getId());

                    // walk through the entry
                    for (AtomElement element : entry.getElements()) {
                        if (element.getObject() instanceof AtomLink) {
                            addLink(repositoryId, entry.getId(), (AtomLink) element.getObject());
                        } else if (element.getObject() instanceof CmisObjectType) {
                            relationship = convert((CmisObjectType) element.getObject());
                        }
                    }
                } finally {
                    unlockLinks();
                }

                if (relationship != null) {
                    result.getObjects().add(relationship);
                }
            }

        }
View Full Code Here

TOP

Related Classes of org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectListImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.