Package org.apache.chemistry.opencmis.client.api

Examples of org.apache.chemistry.opencmis.client.api.Folder


            VersioningState versioningState, Session session) {
        if (type == null) {
            type = BaseTypeId.CMIS_DOCUMENT.value(); // "cmis:document";
        }

        Folder parentFolder = getFolder(parentIdOrPath, session);

        Map<String, Object> properties = new HashMap<String, Object>();
        properties.put(PropertyIds.OBJECT_TYPE_ID, type);
        properties.put(PropertyIds.NAME, name);

        ByteArrayInputStream bais = new ByteArrayInputStream(content == null ? new byte[0] : content.getBytes());
        ContentStream contentStream = new ContentStreamImpl(name, BigInteger.valueOf(content.getBytes().length),
                "text/plain", bais);

        return parentFolder.createDocument(properties, contentStream, versioningState);
    }
View Full Code Here


     *            the session
     * @return the newly created folder
     * @throws CmisBaseException
     */
    public static Folder createFolder(String parentIdOrPath, String name, String type, Session session) {
        Folder parentFolder = getFolder(parentIdOrPath, session);

        if (type == null) {
            type = BaseTypeId.CMIS_FOLDER.value();
        }

        Map<String, Object> properties = new HashMap<String, Object>();
        properties.put(PropertyIds.OBJECT_TYPE_ID, type);
        properties.put(PropertyIds.NAME, name);

        return parentFolder.createFolder(properties);
    }
View Full Code Here

    public void storeRDFinRepository(Object session, MGraph annotatedGraph) {
        List<NonLiteral> rootObjects = RDFBridgeHelper.getRootObjectsOfGraph(annotatedGraph);
        for (NonLiteral root : rootObjects) {
            String documentName = getObjectName(root, annotatedGraph);
            String documentPath = getObjectPath(root, documentName, annotatedGraph);
            Folder rootFolder = checkCreateParentFolders(documentPath, (Session) session);
            if (rootFolder != null) {
                createObject(rootFolder, root, null, documentName, annotatedGraph, (Session) session);
            } else {
                log.warn("Failed to get Folder for path: {}", documentPath);
            }
View Full Code Here

                              NonLiteral parentURI,
                              String documentName,
                              MGraph graph,
                              Session session) {

        Folder containerFolder = createStructureForDocument(documentName, documentURI, parentURI, parent,
            session, graph);

        Iterator<Triple> it = graph.filter(null, CMSAdapterVocabulary.CMS_OBJECT_PARENT_REF, documentURI);
        while (it.hasNext()) {
            NonLiteral childSubject = it.next().getSubject();
View Full Code Here

                    createFolder = false;
                }
            }
        }

        Folder createdFolder = null;
        CmisObject createdObject;
        if (createFolder) {
            createdFolder = createFolderByPath(parentFolder, objectName, objectPath, session);
            createdObject = createdFolder;
        } else {
View Full Code Here

     * @param session
     *            session to access repository
     * @return {@link Folder} one level up from the document
     */
    private Folder checkCreateParentFolders(String documentPath, Session session) {
        Folder f = session.getRootFolder();
        String[] pathSections = documentPath.split("/");
        String currentPath = "/";
        for (int i = 1; i < pathSections.length - 1; i++) {
            String folderName = pathSections[i];
            currentPath += folderName;
View Full Code Here

        }
        return f;
    }

    private Folder createFolderByPath(Folder root, String name, String path, Session session) {
        Folder f;
        try {
            CmisObject o = session.getObjectByPath(path);
            if (hasType(o, BaseTypeId.CMIS_FOLDER)) {
                f = (Folder) o;
            } else {
View Full Code Here

        if (parentURI != null) {
            graph.add(new TripleImpl(subject, CMSAdapterVocabulary.CMS_OBJECT_PARENT_REF, parentURI));
        }

        if (hasType(o, BaseTypeId.CMIS_FOLDER)) {
            Folder f = (Folder) o;
            putObjectPropertiesIntoGraph(f, subject, metadata, graph);

            // process children
            Iterator<CmisObject> childIt = f.getChildren().iterator();
            while (childIt.hasNext()) {
                CmisObject child = childIt.next();
                graph.addAll(getGraphForObject(baseURI, child, f, subject));
            }
        } else if (hasType(o, BaseTypeId.CMIS_DOCUMENT)) {
View Full Code Here

    public List<CMSObject> getChildren(CMSObject node, Object session) throws RepositoryAccessException {
        try {
            checkSession(session);
            CmisObject cmisObject = getByCMISObject(node, (Session) session);
            if (cmisObject instanceof Folder) {
                Folder cmisFolder = (Folder) cmisObject;
                // FIXME Is this code handles pagination
                Iterator<CmisObject> childIter = cmisFolder.getChildren().iterator();
                return convertResult(childIter);
            } else {
                return Arrays.asList(new CMSObject[] {});
            }
        } catch (CmisBaseException e) {
View Full Code Here

            if (instance.getParentRef() != null) {
                return CMISModelMapper.getCMSObject(cmisSession.getObject(CMISObjectId.getObjectId(instance
                        .getParentRef())));
            }
            if (cmisObject instanceof Folder) {
                Folder folder = (Folder) cmisObject;
                for (Folder parent : folder.getParents()) {
                    // TODO handle multiple parents
                    return CMISModelMapper.getCMSObject(parent);
                }
            }
        } catch (CmisBaseException e) {
View Full Code Here

TOP

Related Classes of org.apache.chemistry.opencmis.client.api.Folder

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.