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

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


            testFolderParentPath = TestParameters.DEFAULT_TEST_FOLDER_PARENT_VALUE;
        }

        String name = "cmistck" + System.currentTimeMillis() + session.getRepositoryInfo().hashCode();

        Folder parent = null;
        try {
            CmisObject parentObject = session.getObjectByPath(testFolderParentPath, SELECT_ALL_NO_CACHE_OC);
            if (!(parentObject instanceof Folder)) {
                addResult(createResult(FAILURE, "Parent folder of the test folder is actually not a folder! Path: "
                        + testFolderParentPath, true));
View Full Code Here


                    f = createResult(FAILURE, "Non-Document object has CAN_GET_ALL_VERSIONS allowable action!");
                    addResult(results, assertNotAllowableAction(object, Action.CAN_GET_ALL_VERSIONS, null, f));
                }

                if (object instanceof Folder) {
                    Folder folder = (Folder) object;
                    if (folder.isRootFolder()) {
                        f = createResult(FAILURE, "Root folder has CAN_DELETE_OBJECT allowable action!");
                        addResult(results, assertNotAllowableAction(object, Action.CAN_DELETE_OBJECT, null, f));

                        f = createResult(FAILURE, "Root folder has CAN_GET_FOLDER_PARENT allowable action!");
                        addResult(results, assertNotAllowableAction(object, Action.CAN_GET_FOLDER_PARENT, null, f));
View Full Code Here

   
    private String copyFileToRepository(String fileName, String folderId) {
        LOG.debug("uploading file " + fileName);
        FileInputStream is = null;
        Map<String, Object> properties = new HashMap<String, Object>();
        Folder parentFolder;
        String id = null;
       
        if (null == folderId)
            parentFolder = session.getRootFolder();
        else
            parentFolder = (Folder) session.getObject(folderId);
       
        try {
            File f = new File(fileName);
            Tika tika = new Tika();    
            String mimeType = tika.detect(f);
            LOG.info("Detected MIME type: "+ mimeType);
           
            // extract metadata: first get a parser
            MetadataParser parser = CFG.getParser(mimeType);
            if (null == parser) {
                properties.put(PropertyIds.NAME, f.getName());
                properties.put(PropertyIds.OBJECT_TYPE_ID, CFG.getDefaultDocumentType());
            } else {
                parser.reset();
                PropertyMapper mapper = CFG.getPropertyMapper(mimeType);
                if (null == mapper)
                    throw new MapperException("Unknown mime type (no configuration): " + mimeType);
                String typeId = mapper.getMappedTypeId();
                if (null == typeId)
                    throw new MapperException("No CMIS type configured for mime type" + mimeType);
                TypeDefinition td = session.getTypeDefinition(typeId);
                if (null == td)
                    throw new MapperException("CMIS type " + typeId + " does not exist on server.");

                LOG.info("Detected MIME type: "+ mimeType + " is mapped to CMIS type id: " + td.getId());
                parser.extractMetadata(f, td);
                properties = parser.getCmisProperties();
            }
                       
            // check if there is an overridden content type configured
            int posLastDot = f.getName().indexOf('.');
            String ext = posLastDot < 0 ? null : f.getName().substring(posLastDot+1, f.getName().length());
            String overridden = null;
            if (null != ext && (overridden = CFG.getContentType(ext)) != null)
                mimeType = overridden;
            long length = f.length();
           
            is = new FileInputStream(fileName);

            ContentStream contentStream = session.getObjectFactory().createContentStream(fileName,
                    length, mimeType, is);
            if (!properties.containsKey(PropertyIds.NAME))
                properties.put(PropertyIds.NAME, f.getName());
            Document doc = parentFolder.createDocument(properties, contentStream, VersioningState.NONE);
            id = doc.getId();
            LOG.info("New document created with id: " + id + ", name: " +  properties.get(PropertyIds.NAME) + " in folder: " + parentFolder.getId());
        } catch (Exception e) {
            LOG.error("Failed to create CMIS document.", e);
        } finally {
            if (null != is) {
                try {
View Full Code Here

        }
        return id;
    }
   
    private  String createFolderInRepository(String fileName, String parentFolderId) {
        Folder parentFolder;
        String id = null;
        if (null == parentFolderId)
            parentFolder = session.getRootFolder();
        else
            parentFolder = (Folder) session.getObject(parentFolderId);
        Map<String, Object> properties = new HashMap<String, Object>();
        File f = new File(fileName);
        properties.put(PropertyIds.NAME, f.getName());
        properties.put(PropertyIds.OBJECT_TYPE_ID, CFG.getDefaultFolderType());
        try {
            Folder folder = parentFolder.createFolder(properties);
            id = folder.getId();
            LOG.debug("New folder created with id: " + folder.getId() + ", path: " + folder.getPaths().get(0));
        } catch (Exception e) {
            LOG.error("Failed to create CMIS document.", e);
        } finally {
        }
        LOG.info("New folder created with id: " + id + ", name: " +  properties.get(PropertyIds.NAME) + " in parent folder: " + parentFolder.getId());
View Full Code Here

            testFolderParentPath = TestParameters.DEFAULT_TEST_FOLDER_PARENT_VALUE;
        }

        String name = "cmistck" + System.currentTimeMillis() + session.getRepositoryInfo().hashCode();

        Folder parent = null;
        try {
            CmisObject parentObject = session.getObjectByPath(testFolderParentPath, SELECT_ALL_NO_CACHE_OC);
            if (!(parentObject instanceof Folder)) {
                addResult(createResult(FAILURE, "Parent folder of the test folder is actually not a folder! Path: "
                        + testFolderParentPath, true));
View Full Code Here

                    f = createResult(FAILURE, "Non-Document object has CAN_GET_ALL_VERSIONS allowable action!");
                    addResult(results, assertNotAllowableAction(object, Action.CAN_GET_ALL_VERSIONS, null, f));
                }

                if (object instanceof Folder) {
                    Folder folder = (Folder) object;
                    if (folder.isRootFolder()) {
                        f = createResult(FAILURE, "Root folder has CAN_DELETE_OBJECT allowable action!");
                        addResult(results, assertNotAllowableAction(object, Action.CAN_DELETE_OBJECT, null, f));

                        f = createResult(FAILURE, "Root folder has CAN_GET_FOLDER_PARENT allowable action!");
                        addResult(results, assertNotAllowableAction(object, Action.CAN_GET_FOLDER_PARENT, null, f));
View Full Code Here

        CmisTestResult f;

        Document pwc = null;
        try {
            // create folder and a checked-out document
            Folder testFolder = createTestFolder(session);
            Document doc = createDocument(session, testFolder, "checkedouttest.txt", "checked out");
            DocumentTypeDefinition docType = (DocumentTypeDefinition) doc.getType();

            if (!docType.isVersionable()) {
                addResult(createResult(WARNING, "Test type is not versionable. Check out skipped!"));
            } else {
                ObjectId pwcId = doc.checkOut();
                pwc = (Document) session.getObject(pwcId, SELECT_ALL_NO_CACHE_OC);
            }

            // test all checked-out documents
            int sessionCheckedOut = checkPWCs(session, session.getCheckedOutDocs(SELECT_ALL_NO_CACHE_OC_ORDER_BY_NAME));
            addResult(createInfoResult(sessionCheckedOut + " checked out document(s) overall."));

            if (pwc != null) {
                f = createResult(FAILURE, "There should be at least one checked out document in the repository!");
                addResult(assertIsTrue(sessionCheckedOut >= 1, null, f));
            }

            // test checked-out documents in the test folder
            int testFolderCheckedOut = checkPWCs(session,
                    testFolder.getCheckedOutDocs(SELECT_ALL_NO_CACHE_OC_ORDER_BY_NAME));
            addResult(createInfoResult(testFolderCheckedOut + " checked out document(s) in the test folder."));

            if (pwc != null) {
                f = createResult(FAILURE, "There should be at least one checked out document in the test folder!");
                addResult(assertIsTrue(testFolderCheckedOut >= 1, null, f));
View Full Code Here

    public void run(Session session) {
        CmisTestResult f;

        try {
            // create folder and document
            Folder testFolder = createTestFolder(session);
            Document doc = createDocument(session, testFolder, "versioningtest.txt", "versioning");
            DocumentTypeDefinition docType = (DocumentTypeDefinition) doc.getType();

            if (!docType.isVersionable()) {
                addResult(createResult(SKIPPED, "Test type is not versionable. Test skipped!"));
View Full Code Here

    @Override
    public void run(Session session) {
        try {
            // create folder and document
            Folder testFolder = createTestFolder(session);
            Document doc = createDocument(session, testFolder, "versiondeletetest.txt", "v1");
            DocumentTypeDefinition docType = (DocumentTypeDefinition) doc.getType();

            if (!docType.isVersionable()) {
                addResult(createResult(SKIPPED, "Test type is not versionable. Test skipped!"));
View Full Code Here

        CmisTestResult f;

        if (supportsACLs(session)) {
            try {
                // create folder and document
                Folder testFolder = createTestFolder(session);
                Document doc = createDocument(session, testFolder, "acltest.txt", "ACL test");

                // check if there is an ACL
                Acl acl = doc.getAcl();
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.