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

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


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

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


            String targetFolderId, String sourceFolderId, ExtensionsData extension, ObjectInfoHandler objectInfos) {

        LOG.debug("start moveObject()");
        StoredObject[] sos = validator.moveObject(context, repositoryId, objectId, targetFolderId, sourceFolderId, extension);
        StoredObject so = sos[0];
        Folder targetFolder = null;
        Folder sourceFolder = null;
        ObjectStore objectStore = fStoreManager.getObjectStore(repositoryId);
        Filing spo = null;
        String user = context.getUsername();

        if (null == so) {
View Full Code Here

        String name = (String) pd.getFirstValue();

        // Validation stuff
        TypeValidator.validateRequiredSystemProperties(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());
View Full Code Here

        String user = context.getUsername();
        validator.createFolder(context, repositoryId, folderId, extension);

        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);

        // validate ACL
        TypeValidator.validateAcl(typeDef, addACEs, removeACEs);
       
        // 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);
        }

        if (user == null) {
            user = "unknown";
        }

        ObjectStore objStore = fStoreManager.getObjectStore(repositoryId);
        Folder newFolder = objStore.createFolder(folderName, properties.getProperties(), user, parent,
    addACEs,  removeACEs);
        LOG.debug("stop createFolder()");
        newFolder.persist();
        return newFolder;
    }
View Full Code Here

        }
        return folder;
    }

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

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

        StoredObject so = validator.getFolderParent(context, repositoryId, folderId, extension);

        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, user) : folder
                .getChildren(maxItems, skipCount, user);

        for (StoredObject spo : children) {
            ObjectInFolderDataImpl oifd = new ObjectInFolderDataImpl();
            if (includePathSegments != null && includePathSegments) {
View Full Code Here

        Boolean includeAllowableActions, IncludeRelationships includeRelationships,
        String user, ObjectInfoHandler objectInfos) {

        ObjectDataImpl parent = new ObjectDataImpl();

        Folder parentFolder = sop.getParent();

        if (null == parentFolder) {
            return null;
        }

        copyFilteredProperties(repositoryId, parentFolder, filter, parent);
       
        parent.setRelationships(DataObjectCreator.getRelationships(includeRelationships, parentFolder, user));
       
        if (includeAllowableActions != null && includeAllowableActions) {
            //  AllowableActions allowableActions = DataObjectCreator.fillAllowableActions(spo, user);
            AllowableActions allowableActions = parentFolder.getAllowableActions(user);
            parent.setAllowableActions(allowableActions);
          }
       
        if (objectInfos != null) {
            ObjectInfoImpl objectInfo = new ObjectInfoImpl();
View Full Code Here

   
    public static Object getProperty(StoredObject so, String propertyId) {
        ContentStream content = null;
        DocumentVersion ver = null;
        VersionedDocument verDoc = null;
        Folder folder = null;
        Document doc = null;

        if (so instanceof Content)
            content = ((Content) so).getContent(0, 0);
        if (so instanceof DocumentVersion)
            ver = (DocumentVersion) so;
        if (so instanceof VersionedDocument)
            verDoc = (VersionedDocument) so;
        if (so instanceof Folder)
            folder = (Folder) so;
        if (so instanceof Document)
            doc = (Document) so;

        // generic properties:
        if (propertyId.equals(PropertyIds.NAME)) {
            return so.getName();
        }
        if (propertyId.equals(PropertyIds.OBJECT_ID)) {
            return so.getId();
        }
        if (propertyId.equals(PropertyIds.OBJECT_TYPE_ID)) {
            return so.getTypeId();
        }
        if (propertyId.equals(PropertyIds.BASE_TYPE_ID)) {
            return null; // TOODO: return so.getBaseTypeId());
        }
        if (propertyId.equals(PropertyIds.CREATED_BY)) {
            return so.getCreatedBy();
        }
        if (propertyId.equals(PropertyIds.CREATION_DATE)) {
            return so.getCreatedAt();
        }
        if (propertyId.equals(PropertyIds.LAST_MODIFIED_BY)) {
            return so.getModifiedBy();
        }
        if (propertyId.equals(PropertyIds.LAST_MODIFICATION_DATE)) {
            return so.getModifiedAt();
        }
        if (propertyId.equals(PropertyIds.CHANGE_TOKEN)) {
            return so.getChangeToken();
        }

        if (ver != null) {
            // get version related properties
            // not support on a version, only on a versioned document:
            // VERSION_SERIES_ID, IS_VERSION_SERIES_CHECKED_OUT,
            // VERSION_SERIES_CHECKED_OUT_BY,
            // VERSION_SERIES_CHECKED_OUT_ID, IS_LATEST_MAJOR_VERSION,
            // IS_LATEST_VERSION
            if (propertyId.equals(PropertyIds.IS_MAJOR_VERSION)) {
                return ver.isMajor();
            }

            if (propertyId.equals(PropertyIds.CHECKIN_COMMENT)) {
                return ver.getCheckinComment();
            }
            if (propertyId.equals(PropertyIds.VERSION_LABEL)) {
                return ver.getVersionLabel();
            }
            if (propertyId.equals(PropertyIds.VERSION_SERIES_CHECKED_OUT_ID)) {
                return ver.isPwc() ? ver.getId() : null;
            }
        }

        // get versioned document related properties
        if (verDoc != null) {
            if (propertyId.equals(PropertyIds.VERSION_SERIES_ID)) {
                return verDoc.getId();
            }
            if (propertyId.equals(PropertyIds.IS_VERSION_SERIES_CHECKED_OUT)) {
                return verDoc.isCheckedOut();
            }
            if (propertyId.equals(PropertyIds.VERSION_SERIES_CHECKED_OUT_BY)) {
                return verDoc.getCheckedOutBy();
            }
        }

        // Set the content related properties
        if (null != content) {
            // omit: PropertyIds.CMIS_CONTENT_STREAM_ID
            if (propertyId.equals(PropertyIds.CONTENT_STREAM_FILE_NAME)) {
                return content.getFileName();
            }

            if (propertyId.equals(PropertyIds.CONTENT_STREAM_LENGTH)) {
                return content.getBigLength();
            }
            if (propertyId.equals(PropertyIds.CONTENT_STREAM_MIME_TYPE)) {
                return content.getMimeType();
            }
        }

        if (folder != null) {
            // not supported: ALLOWED_CHILD_OBJECT_TYPE_IDS
            if (propertyId.equals(PropertyIds.PARENT_ID)) {
                return folder.getParent() == null ? null : folder.getParent().getId();
            }

            if (propertyId.equals(PropertyIds.PATH)) {
                return folder.getPath();
            }
        }

        if (doc != null) {
            if (propertyId.equals(PropertyIds.IS_IMMUTABLE)) {
View Full Code Here

    }

    @Test
    public void testCreatAndGetFolders() {
        try {
            Folder childFolder = createFolder("Folder 1");
            fRoot.addChildFolder(childFolder);
            fail("Should throw exception if folder already exists.");
        } catch (Exception e) {
        }
        assertEquals(f1.getName(), "Folder 1");
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.