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

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


        CmisTestResult f;

        try {
            // create folders
            Folder testFolder = createTestFolder(session);
            Folder folder1 = createFolder(session, testFolder, "copyfolder1");
            Folder folder2 = createFolder(session, testFolder, "copyfolder2");

            // create document
            Document doc1 = createDocument(session, folder1, "copytestdoc.txt", "copy test");

            VersioningState versioningState = VersioningState.MAJOR;
View Full Code Here


    public void run(Session session) {
        CmisTestResult f;

        try {
            // create folders
            Folder testFolder = createTestFolder(session);

            // create document
            Document doc1 = createDocument(session, testFolder, NAME1, "rename me!");
            Document workDoc = doc1;
View Full Code Here

      if (baseTypeId.equals(CMIS_FOLDER_BASE_TYPE)) {

        // adding all the children for a folder

        Folder folder = (Folder) cmisObject;
        ItemIterable<CmisObject> children = folder.getChildren();
        for (CmisObject child : children) {
          activities.addDocumentReference(child.getId(), nodeId,
              RELATIONSHIP_CHILD);
        }
View Full Code Here

        producer.process(exchange);
    }

    @Test
    public void createDocumentAtSpecificPath() throws Exception {
        Folder folder1 = createFolderWithName("Folder1");
        createChildFolderWithName(folder1, "Folder2");
        String existingFolderStructure = "/Folder1/Folder2";

        Exchange exchange = createExchangeWithInBody("Some content to be stored");
        exchange.getIn().getHeaders().put(PropertyIds.CONTENT_STREAM_MIME_TYPE, "text/plain; charset=UTF-8");
View Full Code Here

        return session.getObject(nodeId);
    }

    protected void deleteAllContent() {
        Session session = createSession();
        Folder rootFolder = session.getRootFolder();
        ItemIterable<CmisObject> children = rootFolder.getChildren();
        for (CmisObject cmisObject : children) {
            if ("cmis:folder".equals(cmisObject.getPropertyValue(PropertyIds.OBJECT_TYPE_ID))) {
                List<String> notDeltedIdList = ((Folder)cmisObject)
                        .deleteTree(true, UnfileObject.DELETE, true);
                if (notDeltedIdList != null && notDeltedIdList.size() > 0) {
View Full Code Here

        in.close();
        return result.toString();
    }

    protected Folder createFolderWithName(String folderName) {
        Folder rootFolder = createSession().getRootFolder();
        return createChildFolderWithName(rootFolder, folderName);
    }
View Full Code Here

        InputStream content = (InputStream)documents.get(0).get("CamelCMISContent");
        assertEquals("This is the first Camel test content.", readFromStream(content));
    }

    private void populateServerWithContent() throws UnsupportedEncodingException {
        Folder newFolder = createFolderWithName("CamelCmisTestFolder");
        createTextDocument(newFolder, "This is the first Camel test content.", "test1.txt");
        createTextDocument(newFolder, "This is the second Camel test content.", "test2.txt");
    }
View Full Code Here

        return exchanges.get(index).getIn().getHeader("cmis:name", String.class);
    }

    private void populateRepositoryRootFolderWithTwoFoldersAndTwoDocuments()
        throws UnsupportedEncodingException {
        Folder folder1 = createFolderWithName("Folder1");
        Folder folder2 = createChildFolderWithName(folder1, "Folder2");
        createTextDocument(folder2, "Document2.1", "2.1.txt");
        createTextDocument(folder2, "Document2.2", "2.2.txt");
        //L0              ROOT
        //                |
        //L1            Folder1
View Full Code Here

    public void run(Session session) {
        CmisTestResult f;

        try {
            // create folder and document
            Folder testFolder = createTestFolder(session);

            DocumentTypeDefinition docType = (DocumentTypeDefinition) session
                    .getTypeDefinition(getDocumentTestTypeId());

            if (!docType.isVersionable()) {
                addResult(createResult(SKIPPED, "Test type is not versionable. Test skipped!"));
                return;
            }

            // major version
            Document docMajor = testFolder.createDocument(getProperties("major.txt"), getContentStream(),
                    VersioningState.MAJOR);
            addResult(checkObject(session, docMajor, getAllProperties(docMajor), "Major version compliance"));

            f = createResult(FAILURE, "Document should be major version.");
            addResult(assertIsTrue(docMajor.isMajorVersion(), null, f));

            List<Document> versions = docMajor.getAllVersions();

            f = createResult(FAILURE, "Version series should have one version but has " + versions.size() + ".");
            addResult(assertEquals(1, versions.size(), null, f));

            deleteObject(docMajor);

            // minor version
            try {
                Document docMinor = testFolder.createDocument(getProperties("minor.txt"), getContentStream(),
                        VersioningState.MINOR);
                addResult(checkObject(session, docMinor, getAllProperties(docMinor), "Minor version compliance"));

                f = createResult(FAILURE, "Document should be minor version.");
                addResult(assertIsFalse(docMinor.isMajorVersion(), null, f));

                versions = docMinor.getAllVersions();

                f = createResult(FAILURE, "Version series should have one version but has " + versions.size() + ".");
                addResult(assertEquals(1, versions.size(), null, f));

                deleteObject(docMinor);
            } catch (CmisConstraintException ce) {
                addResult(createResult(WARNING, "Creating a minor version failed! "
                        + "The repository might not support minor versions. Exception: " + ce, ce, false));
            } catch (CmisInvalidArgumentException iae) {
                addResult(createResult(WARNING, "Creating a minor version failed! "
                        + "The repository might not support minor versions.  Exception: " + iae, iae, false));
            }

            // checked out version
            try {
                Document docCheckedOut = testFolder.createDocument(getProperties("checkout.txt"), getContentStream(),
                        VersioningState.CHECKEDOUT);
                addResult(checkObject(session, docCheckedOut, getAllProperties(docCheckedOut),
                        "Checked out version compliance"));

                f = createResult(FAILURE, "Version series should be checked out.");
View Full Code Here

    protected Folder createFolder(Session session, Folder parent, String name, String objectTypeId) {
        Map<String, Object> properties = new HashMap<String, Object>();
        properties.put(PropertyIds.NAME, name);
        properties.put(PropertyIds.OBJECT_TYPE_ID, objectTypeId);

        Folder result = null;
        try {
            // create the folder
            result = parent.createFolder(properties, null, null, null, SELECT_ALL_NO_CACHE_OC);
        } catch (CmisBaseException e) {
            addResult(createResult(UNEXPECTED_EXCEPTION, "Folder could not be created! Exception: " + e.getMessage(),
                    e, true));
        }

        try {
            // check the new folder
            String[] propertiesToCheck = new String[result.getType().getPropertyDefinitions().size()];

            int i = 0;
            for (String propId : result.getType().getPropertyDefinitions().keySet()) {
                propertiesToCheck[i++] = propId;
            }

            addResult(checkObject(session, result, propertiesToCheck, "New folder object spec compliance"));

            // check object parents
            List<Folder> objectParents = result.getParents();

            CmisTestResult f = createResult(FAILURE, "Newly created folder has no or more than one parent! Id: "
                    + result.getId(), true);
            addResult(assertEquals(1, objectParents.size(), null, f));

            f = createResult(FAILURE, "First object parent of the newly created folder does not match parent! Id: "
                    + result.getId(), true);
            assertShallowEquals(parent, objectParents.get(0), null, f);

            // check folder parent
            Folder folderParent = result.getFolderParent();
            f = createResult(FAILURE, "Newly created folder has no folder parent! Id: " + result.getId(), true);
            addResult(assertNotNull(folderParent, null, f));

            f = createResult(FAILURE,
                    "Folder parent of the newly created folder does not match parent! Id: " + result.getId(), true);
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.