Package org.apache.chemistry.opencmis.inmemory.storedobj.api

Examples of org.apache.chemistry.opencmis.inmemory.storedobj.api.Folder


                    "Cannot add object to folder, version specific filing is not supported.");
        StoredObject so = sos[0];
        StoredObject folder = sos[1];
        checkObjects(so, folder);

        Folder newParent = (Folder) folder;
        MultiFiling obj = (MultiFiling) so;
        obj.addParent(newParent);

        if (context.isObjectInfoRequired()) {
            ObjectInfoImpl objectInfo = new ObjectInfoImpl();
View Full Code Here


           
        ObjectStore objectStore = fStoreManager.getObjectStore(repositoryId);
        StoredObject folder = sos[1];

        checkObjects(so, folder);
        Folder parent = (Folder) folder;
        MultiFiling obj = (MultiFiling) so;
        obj.removeParent(parent);

        // To be able to provide all Atom links in the response we need
        // additional information:
View Full Code Here

        doc.setName(name);
        return doc;
    }

    public Folder createFolder(String name) {
        Folder folder = new FolderImpl(this, name, null);
        ;
        folder.setRepositoryId(fRepositoryId);
        return folder;
    }
View Full Code Here

    public String createFolder(CallContext context, String repositoryId, Properties properties, String folderId,
            List<String> policies, Acl addAces, Acl removeAces, ExtensionsData extension) {
        LOG.debug("start createFolder()");

        String user = context.getUsername();
        Folder folder = createFolderIntern(repositoryId, properties, folderId, policies, addAces, removeAces,
                extension, user);
        LOG.debug("stop createFolder()");
        return folder.getId();
    }
View Full Code Here

    public ObjectData moveObject(CallContext context, String repositoryId, Holder<String> objectId,
            String targetFolderId, String sourceFolderId, ExtensionsData extension, ObjectInfoHandler objectInfos) {

        LOG.debug("start moveObject()");
        StoredObject so = checkStandardParameters(repositoryId, objectId.getValue());
        Folder targetFolder = null;
        Folder sourceFolder = null;
        ObjectStore objectStore = fStoreManager.getObjectStore(repositoryId);
        Filing spo = null;

        if (null == so)
            throw new CmisObjectNotFoundException("Unknown object: " + objectId.getValue());
View Full Code Here

        // Validation stuff
        TypeValidator.validateRequiredSystemProperties(properties);
        TypeDefinition typeDef = getTypeDefinition(repositoryId, properties);

        Folder folder = null;
        if (null != folderId) {
            StoredObject so = objectStore.getObjectById(folderId);

            if (null == so)
                throw new CmisInvalidArgumentException(" Cannot create document, folderId: " + folderId + " is invalid");

            if (so instanceof Folder)
                folder = (Folder) so;
            else
                throw new CmisInvalidArgumentException("Can't creat document, folderId does not refer to a folder: "
                        + folderId);

            TypeValidator.validateAllowedChildObjectTypes(typeDef, folder.getAllowedChildObjectTypeIds());
        }

        // check if the given type is a document type
        if (!typeDef.getBaseTypeId().equals(BaseTypeId.CMIS_DOCUMENT))
            throw new CmisInvalidArgumentException("Cannot create a document, with a non-document type: " + typeDef.getId());

        // check name syntax
        if (!NameValidator.isValidId(name))
            throw new CmisInvalidArgumentException(NameValidator.ERROR_ILLEGAL_NAME);

        TypeValidator.validateVersionStateForCreate((DocumentTypeDefinition) typeDef, versioningState);

        // set properties that are not set but have a default:
        Map<String, PropertyData<?>> propMapNew = setDefaultProperties(typeDef, propMap);
        if (propMapNew != propMap) {
            properties = new PropertiesImpl(propMapNew.values());
            propMap = propMapNew;
        }

        TypeValidator.validateProperties(typeDef, properties, true);

        // set user, creation date, etc.
        if (user == null)
            user = "unknown";

        StoredObject so = null;

        // check if content stream parameters are set and if not set some defaults
        if (null != contentStream && (contentStream.getFileName() == null || contentStream.getFileName().length() == 0 ||
            contentStream.getMimeType() == null || contentStream.getMimeType().length() == 0)) {
            ContentStreamImpl cs = new ContentStreamImpl();
            cs.setStream(contentStream.getStream());
            if (contentStream.getFileName() == null || contentStream.getFileName().length() == 0)
                cs.setFileName(name);
            else
                cs.setFileName(contentStream.getFileName());
            cs.setLength(contentStream.getBigLength());
            if (contentStream.getMimeType() == null || contentStream.getMimeType().length() == 0)
                cs.setMimeType("application/octet-stream");
            else
                cs.setMimeType(contentStream.getMimeType());
            cs.setExtensions(contentStream.getExtensions());
            contentStream = cs;
        }

        // Now we are sure to have document type definition:
        if (((DocumentTypeDefinition) typeDef).isVersionable()) {
            VersionedDocument verDoc = fStoreManager.getObjectStore(repositoryId).createVersionedDocument(name);
            verDoc.createSystemBasePropertiesWhenCreated(properties.getProperties(), user);
            verDoc.setCustomProperties(properties.getProperties());
            DocumentVersion version = verDoc.addVersion(contentStream, versioningState, user);
            if (null != folder)
                folder.addChildDocument(verDoc); // add document to folder and
            // set parent in doc
            else
                verDoc.persist();
            version.createSystemBasePropertiesWhenCreated(propMap, user);
            version.setCustomProperties(propMap);
            version.persist();
            so = version; // return the version and not the version series to
            // caller
        } else {
            Document doc = fStoreManager.getObjectStore(repositoryId).createDocument(name);
            doc.setContent(contentStream, false);
            // add document to folder
            doc.createSystemBasePropertiesWhenCreated(propMap, user);
            doc.setCustomProperties(propMap);
            if (null != folder)
                folder.addChildDocument(doc); // add document to folder and set
            // parent in doc
            else
                doc.persist();
            so = doc;
        }
View Full Code Here

        // from everywhere
        checkStandardParameters(repositoryId, folderId);

        ObjectStore fs = fStoreManager.getObjectStore(repositoryId);
        StoredObject so = null;
        Folder parent = null;

        // get required properties
        PropertyData<?> pd = properties.getProperties().get(PropertyIds.NAME);
        String folderName = (String) pd.getFirstValue();
        if (null == folderName || folderName.length() == 0)
            throw new CmisInvalidArgumentException("Cannot create a folder without a name.");

        // check name syntax
        if (!NameValidator.isValidId(folderName))
            throw new CmisInvalidArgumentException(NameValidator.ERROR_ILLEGAL_NAME);

        TypeValidator.validateRequiredSystemProperties(properties);

        TypeDefinition typeDef = getTypeDefinition(repositoryId, properties);

        // check if the given type is a folder type
        if (!typeDef.getBaseTypeId().equals(BaseTypeId.CMIS_FOLDER))
            throw new CmisInvalidArgumentException("Cannot create a folder, with a non-folder type: " + typeDef.getId());

        Map<String, PropertyData<?>> propMap = properties.getProperties();
        Map<String, PropertyData<?>> propMapNew = setDefaultProperties(typeDef, propMap);
        if (propMapNew != propMap) {
            properties = new PropertiesImpl(propMapNew.values());
        }

        TypeValidator.validateProperties(typeDef, properties, true);

        // create folder
        try {
            LOG.debug("get folder for id: " + folderId);
            so = fs.getObjectById(folderId);
        } catch (Exception e) {
            throw new CmisObjectNotFoundException("Failed to retrieve folder.", e);
        }

        if (so instanceof Folder)
            parent = (Folder) so;
        else
            throw new CmisInvalidArgumentException("Can't create folder, folderId does not refer to a folder: "
                    + folderId);

        ObjectStore objStore = fStoreManager.getObjectStore(repositoryId);
        Folder newFolder = objStore.createFolder(folderName);
        // set default system attributes
        if (user == null)
            user = "unknown";
        newFolder.createSystemBasePropertiesWhenCreated(properties.getProperties(), user);
        newFolder.setCustomProperties(properties.getProperties());
        parent.addChildFolder(newFolder);
        LOG.debug("stop createFolder()");
        return newFolder;
    }
View Full Code Here

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

        StoredObject so = checkStandardParameters(repositoryId, folderId);

        Folder folder = null;
        if (so instanceof Folder)
            folder = (Folder) so;
        else
            throw new CmisInvalidArgumentException("Can't get folder parent, id does not refer to a folder: "
                    + folderId);
View Full Code Here

        ObjectInFolderListImpl result = new ObjectInFolderListImpl();
        List<ObjectInFolderData> folderList = new ArrayList<ObjectInFolderData>();
        ObjectStore fs = fStoreManager.getObjectStore(repositoryId);
        StoredObject so = fs.getObjectById(folderId);
        Folder folder = null;

        if (so == null)
            throw new CmisObjectNotFoundException("Unknown object id: " + folderId);

        if (so instanceof Folder)
            folder = (Folder) so;
        else
            return null; // it is a document and has no children

        List<? extends StoredObject> children = folderOnly ? folder.getFolderChildren(maxItems, skipCount) : folder
                .getChildren(maxItems, skipCount);

        List<String> requestedIds = FilterParser.getRequestedIdsFromFilter(filter);

        for (StoredObject spo : children) {
View Full Code Here

    private ObjectData getFolderParentIntern(String repositoryId, SingleFiling sop, String filter,
            ObjectInfoHandler objectInfos) {

        ObjectDataImpl parent = new ObjectDataImpl();

        Folder parentFolder = sop.getParent();

        if (null == parentFolder) {
            return null;
        }
View Full Code Here

TOP

Related Classes of org.apache.chemistry.opencmis.inmemory.storedobj.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.