Package org.apache.chemistry.opencmis.commons.server

Examples of org.apache.chemistry.opencmis.commons.server.ObjectInfo


     * change this behavior, override this method.</li>
     * </ul>
     */
    public ObjectInfo getObjectInfo(String repositoryId, String objectId) {
        Map<String, ObjectInfo> oim = getObjectInfoMap();
        ObjectInfo info = oim.get(objectId);
        if (info == null) {
            // object info has not been found -> create one
            try {
                // switch off object info collection to avoid side effects
                addObjectInfos = false;
View Full Code Here


            String relativePathSegment, UrlBuilder baseUrl, boolean isRoot) throws XMLStreamException, JAXBException {
        if (object == null) {
            throw new CmisRuntimeException("Object not set!");
        }

        ObjectInfo info = service.getObjectInfo(repositoryId, object.getId());
        if (info == null) {
            throw new CmisRuntimeException("Object Info not found for: " + object.getId());
        }

        // start
        entry.startEntry(isRoot);

        // write object
        String contentSrc = null;

        if (info.hasContent()) {
            UrlBuilder contentSrcBuilder = compileUrlBuilder(baseUrl, RESOURCE_CONTENT, info.getId());
            if (info.getFileName() != null) {
                contentSrcBuilder.addPathSegment(info.getFileName());
            }

            contentSrc = contentSrcBuilder.toString();
        }

        entry.writeObject(object, info, contentSrc, info.getContentType(), pathSegment, relativePathSegment);

        // write links
        entry.writeServiceLink(baseUrl.toString(), repositoryId);

        entry.writeSelfLink(compileUrl(baseUrl, RESOURCE_ENTRY, info.getId()), info.getId());
        entry.writeEnclosureLink(compileUrl(baseUrl, RESOURCE_ENTRY, info.getId()));
        entry.writeEditLink(compileUrl(baseUrl, RESOURCE_ENTRY, info.getId()));
        entry.writeDescribedByLink(compileUrl(baseUrl, RESOURCE_TYPE, info.getTypeId()));
        entry.writeAllowableActionsLink(compileUrl(baseUrl, RESOURCE_ALLOWABLEACIONS, info.getId()));

        if (info.hasParent()) {
            entry.writeUpLink(compileUrl(baseUrl, RESOURCE_PARENTS, info.getId()), Constants.MEDIATYPE_FEED);
        }

        if (info.getBaseType() == BaseTypeId.CMIS_FOLDER) {
            entry.writeDownLink(compileUrl(baseUrl, RESOURCE_CHILDREN, info.getId()), Constants.MEDIATYPE_FEED);

            if (info.supportsDescendants()) {
                entry.writeDownLink(compileUrl(baseUrl, RESOURCE_DESCENDANTS, info.getId()),
                        Constants.MEDIATYPE_DESCENDANTS);
            }

            if (info.supportsFolderTree()) {
                entry.writeFolderTreeLink(compileUrl(baseUrl, RESOURCE_FOLDERTREE, info.getId()));
            }
        }

        if (info.getVersionSeriesId() != null) {
            UrlBuilder vsUrl = compileUrlBuilder(baseUrl, RESOURCE_VERSIONS, info.getId());
            vsUrl.addParameter(Constants.PARAM_VERSION_SERIES_ID, info.getVersionSeriesId());
            entry.writeVersionHistoryLink(vsUrl.toString());
        }

        if (!info.isCurrentVersion()) {
            UrlBuilder cvUrl = compileUrlBuilder(baseUrl, RESOURCE_ENTRY, info.getId());
            cvUrl.addParameter(Constants.PARAM_RETURN_VERSION, ReturnVersion.LATEST);
            entry.writeEditLink(cvUrl.toString());
        }

        if (info.getBaseType() == BaseTypeId.CMIS_DOCUMENT) {
            entry.writeEditMediaLink(compileUrl(baseUrl, RESOURCE_CONTENT, info.getId()), info.getContentType());
        }

        if (info.getWorkingCopyId() != null) {
            entry.writeWorkingCopyLink(compileUrl(baseUrl, RESOURCE_ENTRY, info.getWorkingCopyId()));
        }

        if (info.getWorkingCopyOriginalId() != null) {
            entry.writeViaLink(compileUrl(baseUrl, RESOURCE_ENTRY, info.getWorkingCopyOriginalId()));
        }

        if (info.getRenditionInfos() != null) {
            for (RenditionInfo ri : info.getRenditionInfos()) {
                UrlBuilder rurl = compileUrlBuilder(baseUrl, RESOURCE_CONTENT,
                        info.getId());
                rurl.addParameter(Constants.PARAM_STREAM_ID, ri.getId());
                entry.writeAlternateLink(rurl.toString(), ri.getContenType(),
                        ri.getKind(), ri.getTitle(), ri.getLength());
            }
        }

        if (info.hasAcl()) {
            entry.writeAclLink(compileUrl(baseUrl, RESOURCE_ACL, info.getId()));
        }

        if (info.supportsPolicies()) {
            entry.writePoliciesLink(compileUrl(baseUrl, RESOURCE_POLICIES, info.getId()));
        }

        if (info.supportsRelationships()) {
            entry.writeRelationshipsLink(compileUrl(baseUrl, RESOURCE_RELATIONSHIPS, info.getId()));
        }

        if (info.getRelationshipSourceIds() != null) {
            for (String id : info.getRelationshipSourceIds()) {
                entry.writeRelationshipSourceLink(compileUrl(baseUrl, RESOURCE_ENTRY, id));
            }
        }

        if (info.getRelationshipTargetIds() != null) {
            for (String id : info.getRelationshipTargetIds()) {
                entry.writeRelationshipTargetLink(compileUrl(baseUrl, RESOURCE_ENTRY, id));
            }
        }

        // write children
View Full Code Here

            String relativePathSegment, UrlBuilder baseUrl, boolean isRoot) throws XMLStreamException, JAXBException {
        if (object == null) {
            throw new CmisRuntimeException("Object not set!");
        }

        ObjectInfo info = null;
        try {
            info = service.getObjectInfo(repositoryId, object.getId());
        } catch (Exception e) {
            // ignore all exceptions
        }
View Full Code Here

        // execute
        Holder<String> checkOutId = new Holder<String>(parser.getId());
        service.checkOut(repositoryId, checkOutId, null, null);

        ObjectInfo objectInfo = service.getObjectInfo(repositoryId, checkOutId.getValue());
        if (objectInfo == null) {
            throw new CmisRuntimeException("Object Info is missing!");
        }

        ObjectData object = objectInfo.getObject();
        if (object == null) {
            throw new CmisRuntimeException("Object is null!");
        }

        if (object.getId() == null) {
View Full Code Here

        AtomFeed feed = new AtomFeed();
        feed.startDocument(response.getOutputStream());
        feed.startFeed(true);

        // write basic Atom feed elements
        ObjectInfo latestObjectInfo = service.getObjectInfo(repositoryId, versions.get(0).getId());
        ObjectInfo firstObjectInfo = service.getObjectInfo(repositoryId, versions.get(versions.size() - 1).getId());

        feed.writeFeedElements(versionSeriesId, firstObjectInfo.getCreatedBy(), latestObjectInfo.getName(),
                latestObjectInfo.getLastModificationDate(), null, null);

        // write links
        UrlBuilder baseUrl = compileBaseUrl(request, repositoryId);
View Full Code Here

                createProperties(cp, null, typeCache), folderId,
                createContentStream(request), versioningState,
                createPolicies(cp), createAddAcl(cp),
                createRemoveAcl(cp), null);

        ObjectInfo objectInfo = service.getObjectInfo(repositoryId, newObjectId);
        if (objectInfo == null) {
            throw new CmisRuntimeException("Object Info is missing!");
        }

        ObjectData object = objectInfo.getObject();
        if (object == null) {
            throw new CmisRuntimeException("Object is null!");
        }

        JSONObject jsonObject = JSONConverter.convert(object, typeCache);
View Full Code Here

        String newObjectId = service.createFolder(repositoryId,
                createProperties(cp, null, typeCache), folderId,
                createPolicies(cp), createAddAcl(cp),
                createRemoveAcl(cp), null);

        ObjectInfo objectInfo = service.getObjectInfo(repositoryId, newObjectId);
        if (objectInfo == null) {
            throw new CmisRuntimeException("Object Info is missing!");
        }

        ObjectData object = objectInfo.getObject();
        if (object == null) {
            throw new CmisRuntimeException("Object is null!");
        }

        JSONObject jsonObject = JSONConverter.convert(object, typeCache);
View Full Code Here

        return type;
    }

    public TypeDefinition getTypeDefinitionForObject(String objectId) {
        ObjectInfo info = service.getObjectInfo(repositoryId, objectId);
        if (info == null) {
            return null;
        }

        return getTypeDefinition(info.getTypeId());
    }
View Full Code Here

    return type;
  }

  public TypeDefinition getTypeDefinitionForObject(String objectId) {
    ObjectInfo info = service.getObjectInfo(repositoryId, objectId);
    if (info == null) {
      return null;
    }

    return getTypeDefinition(info.getTypeId());
  }
View Full Code Here

        if (policies == null) {
            throw new CmisRuntimeException("Policies are null!");
        }

        ObjectInfo objectInfo = service.getObjectInfo(repositoryId, objectId);
        if (objectInfo == null) {
            throw new CmisRuntimeException("Object Info is missing!");
        }

        // set headers
        response.setStatus(HttpServletResponse.SC_OK);
        response.setContentType(Constants.MEDIATYPE_FEED);

        // write XML
        AtomFeed feed = new AtomFeed();
        feed.startDocument(response.getOutputStream());
        feed.startFeed(true);

        // write basic Atom feed elements
        feed.writeFeedElements(objectInfo.getId(), objectInfo.getCreatedBy(), objectInfo.getName(),
                objectInfo.getLastModificationDate(), null, null);

        // write links
        UrlBuilder baseUrl = compileBaseUrl(request, repositoryId);

        feed.writeServiceLink(baseUrl.toString(), repositoryId);

        feed.writeSelfLink(compileUrl(baseUrl, RESOURCE_POLICIES, objectInfo.getId()), null);

        // write entries
        AtomEntry entry = new AtomEntry(feed.getWriter());
        for (ObjectData policy : policies) {
            if (policy == null) {
                continue;
            }
            writePolicyEntry(service, entry, objectInfo.getId(), policy, repositoryId, baseUrl);
        }

        // we are done
        feed.endFeed();
        feed.endDocument();
View Full Code Here

TOP

Related Classes of org.apache.chemistry.opencmis.commons.server.ObjectInfo

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.