Search in sources :

Example 6 with BaseTypeId

use of org.apache.chemistry.opencmis.commons.enums.BaseTypeId in project copper-cms by PogeyanOSS.

the class CopperCmsRepository method createRepositoryInfo.

@SuppressWarnings("serial")
private RepositoryInfo createRepositoryInfo(String repositoryId, CmisVersion cmisVersion) {
    String rootFolderId = ROOT_ID;
    // repository info
    RepositoryInfoImpl repoInfo = new RepositoryInfoImpl();
    repoInfo.setId(repositoryId == null ? "inMem" : repositoryId);
    repoInfo.setName("Pogeyan MongoDB CMIS Repository");
    repoInfo.setDescription("Pogeyan MongoDB CMIS  Repository (Version: " + OPENCMIS_VERSION + ")");
    repoInfo.setRootFolder(rootFolderId);
    repoInfo.setPrincipalAnonymous("");
    repoInfo.setPrincipalAnyone("");
    repoInfo.setThinClientUri("");
    repoInfo.setChangesIncomplete(Boolean.TRUE);
    repoInfo.setLatestChangeLogToken("token-24");
    repoInfo.setVendorName("Apache Chemistry");
    repoInfo.setProductName(OPENCMIS_SERVER);
    repoInfo.setProductVersion(OPENCMIS_VERSION);
    // set capabilities
    RepositoryCapabilitiesImpl caps = new RepositoryCapabilitiesImpl();
    caps.setAllVersionsSearchable(false);
    caps.setCapabilityAcl(CapabilityAcl.MANAGE);
    caps.setCapabilityChanges(CapabilityChanges.OBJECTIDSONLY);
    caps.setCapabilityContentStreamUpdates(CapabilityContentStreamUpdates.ANYTIME);
    caps.setCapabilityJoin(CapabilityJoin.NONE);
    caps.setCapabilityQuery(CapabilityQuery.BOTHCOMBINED);
    caps.setCapabilityRendition(CapabilityRenditions.READ);
    caps.setIsPwcSearchable(false);
    caps.setIsPwcUpdatable(true);
    caps.setSupportsGetDescendants(true);
    caps.setSupportsGetFolderTree(true);
    caps.setSupportsMultifiling(true);
    caps.setSupportsUnfiling(true);
    caps.setSupportsVersionSpecificFiling(false);
    caps.setCapabilityAcl(CapabilityAcl.MANAGE);
    AclCapabilitiesDataImpl aclCaps = new AclCapabilitiesDataImpl();
    aclCaps.setAclPropagation(AclPropagation.OBJECTONLY);
    aclCaps.setSupportedPermissions(SupportedPermissions.BASIC);
    // permissions
    List<PermissionDefinition> permissions = new ArrayList<PermissionDefinition>();
    permissions.add(createPermission(CMIS_READ, "Read"));
    permissions.add(createPermission(CMIS_WRITE, "Write"));
    permissions.add(createPermission(CMIS_ALL, "All"));
    if (cmisVersion == CmisVersion.CMIS_1_1) {
        NewTypeSettableAttributesImpl typeAttrs = new NewTypeSettableAttributesImpl();
        typeAttrs.setCanSetControllableAcl(false);
        typeAttrs.setCanSetControllablePolicy(false);
        typeAttrs.setCanSetCreatable(true);
        typeAttrs.setCanSetDescription(true);
        typeAttrs.setCanSetDisplayName(true);
        typeAttrs.setCanSetFileable(false);
        typeAttrs.setCanSetFulltextIndexed(false);
        typeAttrs.setCanSetId(true);
        typeAttrs.setCanSetIncludedInSupertypeQuery(false);
        typeAttrs.setCanSetLocalName(true);
        typeAttrs.setCanSetLocalNamespace(true);
        typeAttrs.setCanSetQueryable(false);
        typeAttrs.setCanSetQueryName(true);
        caps.setNewTypeSettableAttributes(typeAttrs);
    }
    aclCaps.setPermissionDefinitionData(permissions);
    // mapping
    List<PermissionMapping> list = new ArrayList<PermissionMapping>();
    list.add(createMapping(PermissionMapping.CAN_GET_DESCENDENTS_FOLDER, CMIS_READ));
    list.add(createMapping(PermissionMapping.CAN_GET_CHILDREN_FOLDER, CMIS_READ));
    list.add(createMapping(PermissionMapping.CAN_GET_PARENTS_FOLDER, CMIS_READ));
    list.add(createMapping(PermissionMapping.CAN_GET_FOLDER_PARENT_OBJECT, CMIS_READ));
    list.add(createMapping(PermissionMapping.CAN_CREATE_DOCUMENT_FOLDER, CMIS_WRITE));
    list.add(createMapping(PermissionMapping.CAN_CREATE_FOLDER_FOLDER, CMIS_WRITE));
    list.add(createMapping(PermissionMapping.CAN_CREATE_RELATIONSHIP_SOURCE, CMIS_READ));
    list.add(createMapping(PermissionMapping.CAN_CREATE_RELATIONSHIP_TARGET, CMIS_READ));
    list.add(createMapping(PermissionMapping.CAN_GET_PROPERTIES_OBJECT, CMIS_READ));
    list.add(createMapping(PermissionMapping.CAN_VIEW_CONTENT_OBJECT, CMIS_READ));
    list.add(createMapping(PermissionMapping.CAN_UPDATE_PROPERTIES_OBJECT, CMIS_WRITE));
    list.add(createMapping(PermissionMapping.CAN_MOVE_OBJECT, CMIS_WRITE));
    list.add(createMapping(PermissionMapping.CAN_MOVE_TARGET, CMIS_WRITE));
    list.add(createMapping(PermissionMapping.CAN_MOVE_SOURCE, CMIS_WRITE));
    list.add(createMapping(PermissionMapping.CAN_DELETE_OBJECT, CMIS_WRITE));
    list.add(createMapping(PermissionMapping.CAN_DELETE_TREE_FOLDER, CMIS_WRITE));
    list.add(createMapping(PermissionMapping.CAN_SET_CONTENT_DOCUMENT, CMIS_WRITE));
    list.add(createMapping(PermissionMapping.CAN_DELETE_CONTENT_DOCUMENT, CMIS_WRITE));
    list.add(createMapping(PermissionMapping.CAN_ADD_TO_FOLDER_OBJECT, CMIS_WRITE));
    list.add(createMapping(PermissionMapping.CAN_REMOVE_FROM_FOLDER_OBJECT, CMIS_WRITE));
    list.add(createMapping(PermissionMapping.CAN_CHECKOUT_DOCUMENT, CMIS_WRITE));
    list.add(createMapping(PermissionMapping.CAN_CANCEL_CHECKOUT_DOCUMENT, CMIS_WRITE));
    list.add(createMapping(PermissionMapping.CAN_CHECKIN_DOCUMENT, CMIS_WRITE));
    list.add(createMapping(PermissionMapping.CAN_GET_ALL_VERSIONS_VERSION_SERIES, CMIS_READ));
    list.add(createMapping(PermissionMapping.CAN_GET_OBJECT_RELATIONSHIPS_OBJECT, CMIS_READ));
    list.add(createMapping(PermissionMapping.CAN_ADD_POLICY_OBJECT, CMIS_WRITE));
    list.add(createMapping(PermissionMapping.CAN_REMOVE_POLICY_OBJECT, CMIS_WRITE));
    list.add(createMapping(PermissionMapping.CAN_GET_APPLIED_POLICIES_OBJECT, CMIS_READ));
    list.add(createMapping(PermissionMapping.CAN_GET_ACL_OBJECT, CMIS_READ));
    list.add(createMapping(PermissionMapping.CAN_APPLY_ACL_OBJECT, CMIS_ALL));
    Map<String, PermissionMapping> map = new LinkedHashMap<String, PermissionMapping>();
    for (PermissionMapping pm : list) {
        map.put(pm.getKey(), pm);
    }
    List<BaseTypeId> changesOnType;
    // CMIS 1.1 extensions
    if (cmisVersion == CmisVersion.CMIS_1_1) {
        repoInfo.setCmisVersionSupported(CmisVersion.CMIS_1_1.value());
        repoInfo.setCmisVersion(CmisVersion.CMIS_1_1);
        changesOnType = new ArrayList<BaseTypeId>() {

            {
                add(BaseTypeId.CMIS_DOCUMENT);
                add(BaseTypeId.CMIS_FOLDER);
                add(BaseTypeId.CMIS_ITEM);
            }
        };
        Set<PropertyType> propertyTypeSet = new HashSet<PropertyType>() {

            {
                add(PropertyType.BOOLEAN);
                add(PropertyType.DATETIME);
                add(PropertyType.DECIMAL);
                add(PropertyType.HTML);
                add(PropertyType.ID);
                add(PropertyType.INTEGER);
                add(PropertyType.STRING);
                add(PropertyType.URI);
            }
        };
        CreatablePropertyTypesImpl creatablePropertyTypes = new CreatablePropertyTypesImpl();
        creatablePropertyTypes.setCanCreate(propertyTypeSet);
        caps.setCreatablePropertyTypes(creatablePropertyTypes);
        caps.setCapabilityOrderBy(CapabilityOrderBy.COMMON);
    } else {
        repoInfo.setCmisVersionSupported(CmisVersion.CMIS_1_0.value());
        repoInfo.setCmisVersion(CmisVersion.CMIS_1_0);
        changesOnType = new ArrayList<BaseTypeId>() {

            {
                add(BaseTypeId.CMIS_DOCUMENT);
                add(BaseTypeId.CMIS_FOLDER);
            }
        };
    }
    repoInfo.setChangesOnType(changesOnType);
    aclCaps.setPermissionMappingData(map);
    repoInfo.setAclCapabilities(aclCaps);
    repoInfo.setCapabilities(caps);
    return repoInfo;
}
Also used : RepositoryInfoImpl(org.apache.chemistry.opencmis.commons.impl.dataobjects.RepositoryInfoImpl) PermissionMapping(org.apache.chemistry.opencmis.commons.data.PermissionMapping) RepositoryCapabilitiesImpl(org.apache.chemistry.opencmis.commons.impl.dataobjects.RepositoryCapabilitiesImpl) PermissionDefinition(org.apache.chemistry.opencmis.commons.definitions.PermissionDefinition) CreatablePropertyTypesImpl(org.apache.chemistry.opencmis.commons.impl.dataobjects.CreatablePropertyTypesImpl) ArrayList(java.util.ArrayList) BaseTypeId(org.apache.chemistry.opencmis.commons.enums.BaseTypeId) PropertyType(org.apache.chemistry.opencmis.commons.enums.PropertyType) LinkedHashMap(java.util.LinkedHashMap) NewTypeSettableAttributesImpl(org.apache.chemistry.opencmis.commons.impl.dataobjects.NewTypeSettableAttributesImpl) AclCapabilitiesDataImpl(org.apache.chemistry.opencmis.commons.impl.dataobjects.AclCapabilitiesDataImpl) HashSet(java.util.HashSet)

Example 7 with BaseTypeId

use of org.apache.chemistry.opencmis.commons.enums.BaseTypeId in project copper-cms by PogeyanOSS.

the class RepositoryActor method createRepositoryInfo.

@SuppressWarnings("serial")
private RepositoryInfo createRepositoryInfo(String repositoryId, String name, CmisVersion cmisVersion, String rootFolderId, String description) {
    LOG.info("createRepositoryInfo rootFolderId: {}", rootFolderId);
    MBaseObjectDAO baseMorphiaDAO = DatabaseServiceFactory.getInstance(repositoryId).getObjectService(repositoryId, MBaseObjectDAO.class);
    String latestToken = String.valueOf(baseMorphiaDAO.getLatestToken().getChangeToken() != null ? baseMorphiaDAO.getLatestToken().getChangeToken().getTime() : null);
    // repository info
    RepositoryInfoImpl repoInfo = new RepositoryInfoImpl();
    repoInfo.setId(repositoryId == null ? "repository" : repositoryId);
    repoInfo.setName(name);
    repoInfo.setDescription(description);
    repoInfo.setRootFolder(rootFolderId.toString());
    repoInfo.setPrincipalAnonymous("");
    repoInfo.setPrincipalAnyone("");
    repoInfo.setThinClientUri("");
    repoInfo.setChangesIncomplete(Boolean.FALSE);
    repoInfo.setLatestChangeLogToken(latestToken != null ? latestToken : "token-24");
    repoInfo.setVendorName("Pogeyan Technologies Pvt. Ltd.");
    repoInfo.setProductName(OPENCMIS_SERVER);
    repoInfo.setProductVersion(OPENCMIS_VERSION);
    // set capabilities
    RepositoryCapabilitiesImpl caps = new RepositoryCapabilitiesImpl();
    caps.setAllVersionsSearchable(true);
    caps.setCapabilityAcl(CapabilityAcl.MANAGE);
    caps.setCapabilityChanges(CapabilityChanges.OBJECTIDSONLY);
    caps.setCapabilityContentStreamUpdates(CapabilityContentStreamUpdates.ANYTIME);
    caps.setCapabilityJoin(CapabilityJoin.NONE);
    caps.setCapabilityQuery(CapabilityQuery.NONE);
    caps.setCapabilityRendition(CapabilityRenditions.READ);
    caps.setIsPwcSearchable(true);
    caps.setIsPwcUpdatable(true);
    caps.setSupportsGetDescendants(true);
    caps.setSupportsGetFolderTree(true);
    caps.setSupportsMultifiling(true);
    caps.setSupportsUnfiling(true);
    caps.setSupportsVersionSpecificFiling(true);
    AclCapabilitiesDataImpl aclCaps = new AclCapabilitiesDataImpl();
    aclCaps.setAclPropagation(AclPropagation.OBJECTONLY);
    aclCaps.setSupportedPermissions(SupportedPermissions.BOTH);
    // permissions
    List<PermissionDefinition> permissions = new ArrayList<PermissionDefinition>();
    permissions.add(createPermission(CMIS_READ, "Read"));
    permissions.add(createPermission(CMIS_WRITE, "Write"));
    permissions.add(createPermission(CMIS_ALL, "All"));
    if (cmisVersion == CmisVersion.CMIS_1_1) {
        NewTypeSettableAttributesImpl typeAttrs = new NewTypeSettableAttributesImpl();
        typeAttrs.setCanSetControllableAcl(true);
        typeAttrs.setCanSetControllablePolicy(true);
        typeAttrs.setCanSetCreatable(true);
        typeAttrs.setCanSetDescription(true);
        typeAttrs.setCanSetDisplayName(true);
        typeAttrs.setCanSetFileable(true);
        typeAttrs.setCanSetFulltextIndexed(true);
        typeAttrs.setCanSetId(true);
        typeAttrs.setCanSetIncludedInSupertypeQuery(false);
        typeAttrs.setCanSetLocalName(true);
        typeAttrs.setCanSetLocalNamespace(true);
        typeAttrs.setCanSetQueryable(true);
        typeAttrs.setCanSetQueryName(true);
        caps.setNewTypeSettableAttributes(typeAttrs);
    }
    aclCaps.setPermissionDefinitionData(permissions);
    // mapping
    List<PermissionMapping> list = new ArrayList<PermissionMapping>();
    list.add(createMapping(PermissionMapping.CAN_GET_DESCENDENTS_FOLDER, CMIS_READ));
    list.add(createMapping(PermissionMapping.CAN_GET_CHILDREN_FOLDER, CMIS_READ));
    list.add(createMapping(PermissionMapping.CAN_GET_PARENTS_FOLDER, CMIS_READ));
    list.add(createMapping(PermissionMapping.CAN_GET_FOLDER_PARENT_OBJECT, CMIS_READ));
    list.add(createMapping(PermissionMapping.CAN_CREATE_DOCUMENT_FOLDER, CMIS_WRITE));
    list.add(createMapping(PermissionMapping.CAN_CREATE_FOLDER_FOLDER, CMIS_WRITE));
    list.add(createMapping(PermissionMapping.CAN_CREATE_RELATIONSHIP_SOURCE, CMIS_READ));
    list.add(createMapping(PermissionMapping.CAN_CREATE_RELATIONSHIP_TARGET, CMIS_READ));
    list.add(createMapping(PermissionMapping.CAN_GET_PROPERTIES_OBJECT, CMIS_READ));
    list.add(createMapping(PermissionMapping.CAN_VIEW_CONTENT_OBJECT, CMIS_READ));
    list.add(createMapping(PermissionMapping.CAN_UPDATE_PROPERTIES_OBJECT, CMIS_WRITE));
    list.add(createMapping(PermissionMapping.CAN_MOVE_OBJECT, CMIS_WRITE));
    list.add(createMapping(PermissionMapping.CAN_MOVE_TARGET, CMIS_WRITE));
    list.add(createMapping(PermissionMapping.CAN_MOVE_SOURCE, CMIS_WRITE));
    list.add(createMapping(PermissionMapping.CAN_DELETE_OBJECT, CMIS_WRITE));
    list.add(createMapping(PermissionMapping.CAN_DELETE_TREE_FOLDER, CMIS_WRITE));
    list.add(createMapping(PermissionMapping.CAN_SET_CONTENT_DOCUMENT, CMIS_WRITE));
    list.add(createMapping(PermissionMapping.CAN_DELETE_CONTENT_DOCUMENT, CMIS_WRITE));
    list.add(createMapping(PermissionMapping.CAN_ADD_TO_FOLDER_OBJECT, CMIS_WRITE));
    list.add(createMapping(PermissionMapping.CAN_REMOVE_FROM_FOLDER_OBJECT, CMIS_WRITE));
    list.add(createMapping(PermissionMapping.CAN_CHECKOUT_DOCUMENT, CMIS_WRITE));
    list.add(createMapping(PermissionMapping.CAN_CANCEL_CHECKOUT_DOCUMENT, CMIS_WRITE));
    list.add(createMapping(PermissionMapping.CAN_CHECKIN_DOCUMENT, CMIS_WRITE));
    list.add(createMapping(PermissionMapping.CAN_GET_ALL_VERSIONS_VERSION_SERIES, CMIS_READ));
    list.add(createMapping(PermissionMapping.CAN_GET_OBJECT_RELATIONSHIPS_OBJECT, CMIS_READ));
    list.add(createMapping(PermissionMapping.CAN_ADD_POLICY_OBJECT, CMIS_WRITE));
    list.add(createMapping(PermissionMapping.CAN_REMOVE_POLICY_OBJECT, CMIS_WRITE));
    list.add(createMapping(PermissionMapping.CAN_GET_APPLIED_POLICIES_OBJECT, CMIS_READ));
    list.add(createMapping(PermissionMapping.CAN_GET_ACL_OBJECT, CMIS_READ));
    list.add(createMapping(PermissionMapping.CAN_APPLY_ACL_OBJECT, CMIS_ALL));
    Map<String, PermissionMapping> map = new LinkedHashMap<String, PermissionMapping>();
    for (PermissionMapping pm : list) {
        map.put(pm.getKey(), pm);
    }
    List<BaseTypeId> changesOnType;
    // CMIS 1.1 extensions
    if (cmisVersion == CmisVersion.CMIS_1_1) {
        repoInfo.setCmisVersionSupported(CmisVersion.CMIS_1_1.value());
        repoInfo.setCmisVersion(CmisVersion.CMIS_1_1);
        changesOnType = new ArrayList<BaseTypeId>() {

            {
                add(BaseTypeId.CMIS_DOCUMENT);
                add(BaseTypeId.CMIS_FOLDER);
                add(BaseTypeId.CMIS_ITEM);
            }
        };
        Set<PropertyType> propertyTypeSet = new HashSet<PropertyType>() {

            {
                add(PropertyType.BOOLEAN);
                add(PropertyType.DATETIME);
                add(PropertyType.DECIMAL);
                add(PropertyType.HTML);
                add(PropertyType.ID);
                add(PropertyType.INTEGER);
                add(PropertyType.STRING);
                add(PropertyType.URI);
            }
        };
        CreatablePropertyTypesImpl creatablePropertyTypes = new CreatablePropertyTypesImpl();
        creatablePropertyTypes.setCanCreate(propertyTypeSet);
        caps.setCreatablePropertyTypes(creatablePropertyTypes);
        caps.setCapabilityOrderBy(CapabilityOrderBy.COMMON);
    } else {
        repoInfo.setCmisVersionSupported(CmisVersion.CMIS_1_0.value());
        repoInfo.setCmisVersion(CmisVersion.CMIS_1_0);
        changesOnType = new ArrayList<BaseTypeId>() {

            {
                add(BaseTypeId.CMIS_DOCUMENT);
                add(BaseTypeId.CMIS_FOLDER);
            }
        };
    }
    repoInfo.setChangesOnType(changesOnType);
    aclCaps.setPermissionMappingData(map);
    repoInfo.setAclCapabilities(aclCaps);
    repoInfo.setCapabilities(caps);
    return repoInfo;
}
Also used : RepositoryInfoImpl(org.apache.chemistry.opencmis.commons.impl.dataobjects.RepositoryInfoImpl) PermissionMapping(org.apache.chemistry.opencmis.commons.data.PermissionMapping) RepositoryCapabilitiesImpl(org.apache.chemistry.opencmis.commons.impl.dataobjects.RepositoryCapabilitiesImpl) PermissionDefinition(org.apache.chemistry.opencmis.commons.definitions.PermissionDefinition) CreatablePropertyTypesImpl(org.apache.chemistry.opencmis.commons.impl.dataobjects.CreatablePropertyTypesImpl) ArrayList(java.util.ArrayList) BaseTypeId(org.apache.chemistry.opencmis.commons.enums.BaseTypeId) PropertyType(org.apache.chemistry.opencmis.commons.enums.PropertyType) LinkedHashMap(java.util.LinkedHashMap) NewTypeSettableAttributesImpl(org.apache.chemistry.opencmis.commons.impl.dataobjects.NewTypeSettableAttributesImpl) AclCapabilitiesDataImpl(org.apache.chemistry.opencmis.commons.impl.dataobjects.AclCapabilitiesDataImpl) MBaseObjectDAO(com.pogeyan.cmis.api.data.services.MBaseObjectDAO) HashSet(java.util.HashSet)

Example 8 with BaseTypeId

use of org.apache.chemistry.opencmis.commons.enums.BaseTypeId in project copper-cms by PogeyanOSS.

the class ServletHelpers method queryHttpToBaseMessage.

static BaseMessage queryHttpToBaseMessage(QueryStringHttpServletRequestWrapper request, String[] pathFragments, IUserObject userObject) {
    QueryGetRequest queryRequest = new QueryGetRequest();
    queryRequest.setParameterMap(request.getParameterMap());
    queryRequest.setBaseUrl((String) request.getAttribute(BrowserConstants.BASE_URL_ATTRIBUTE));
    queryRequest.setScheme(request.getScheme());
    queryRequest.setServerName(request.getServerName());
    queryRequest.setServerPort(request.getServerPort());
    queryRequest.setContextPath(request.getContextPath());
    queryRequest.setServletPath(request.getServletPath());
    queryRequest.setRange(request.getHeader("Range"));
    String objectId = HttpUtils.getStringParameter(request, BrowserConstants.PARAM_OBJECT_ID);
    queryRequest.setObjectId(objectId);
    if (userObject != null) {
        queryRequest.setUserName(userObject.getUserDN());
        queryRequest.setUserObject(userObject);
    }
    if (pathFragments.length > 0) {
        queryRequest.setRepositoryId(pathFragments[0]);
    }
    // selector is the actionName
    String selector = HttpUtils.getStringParameter(request, BrowserConstants.PARAM_SELECTOR);
    if (pathFragments.length > 1) {
        queryRequest.setPathFragments(pathFragments);
        // nested url
        String repositoryId = pathFragments[0];
        try {
            ObjectData object = null;
            // Example objectId format-typeID::primaryKey::primaryKeyValue
            if (objectId != null && objectId.contains("::")) {
                String[] inputs = objectId.split("::");
                // getObjectForRestAPI method is used to get the object.
                object = CmisObjectService.Impl.getObjectForRestAPI(repositoryId, inputs[0], inputs[1], inputs[2], "cmis:objectId,cmis:objectTypeId,cmis:baseTypeId", false, IncludeRelationships.NONE, "cmis:none", false, false, null, "");
            } else {
                object = ServletHelpers.getObjectDataFor(repositoryId, objectId, pathFragments);
            }
            // reset object id again here
            objectId = object.getId();
            queryRequest.setObjectId(objectId);
            String typeId = getStringPropertyValue(object, PropertyIds.OBJECT_TYPE_ID);
            queryRequest.setTypeId(typeId);
            BaseTypeId baseTypeId = BaseTypeId.fromValue(getStringPropertyValue(object, PropertyIds.BASE_TYPE_ID));
            queryRequest.setBaseTypeId(baseTypeId);
            if (selector == null) {
                switch(baseTypeId) {
                    case CMIS_DOCUMENT:
                        selector = BrowserConstants.SELECTOR_CONTENT;
                        break;
                    case CMIS_FOLDER:
                        selector = BrowserConstants.SELECTOR_CHILDREN;
                        break;
                    default:
                        selector = BrowserConstants.SELECTOR_OBJECT;
                        break;
                }
            }
        } catch (Exception e) {
            selector = BrowserConstants.SELECTOR_OBJECT;
        }
    }
    selector = selector == null ? "GetRepositories".toLowerCase() : selector;
    BaseMessage bm = BaseMessage.create("", selector, queryRequest);
    return bm;
}
Also used : BaseMessage(com.pogeyan.cmis.api.BaseMessage) ObjectData(org.apache.chemistry.opencmis.commons.data.ObjectData) BaseTypeId(org.apache.chemistry.opencmis.commons.enums.BaseTypeId) QueryGetRequest(com.pogeyan.cmis.api.messages.QueryGetRequest) CmisStreamNotSupportedException(org.apache.chemistry.opencmis.commons.exceptions.CmisStreamNotSupportedException) CmisContentAlreadyExistsException(org.apache.chemistry.opencmis.commons.exceptions.CmisContentAlreadyExistsException) CmisConstraintException(org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException) CmisPermissionDeniedException(org.apache.chemistry.opencmis.commons.exceptions.CmisPermissionDeniedException) CmisRuntimeException(org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException) CmisObjectNotFoundException(org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException) CmisServiceUnavailableException(org.apache.chemistry.opencmis.commons.exceptions.CmisServiceUnavailableException) CmisNameConstraintViolationException(org.apache.chemistry.opencmis.commons.exceptions.CmisNameConstraintViolationException) CmisFilterNotValidException(org.apache.chemistry.opencmis.commons.exceptions.CmisFilterNotValidException) CmisTooManyRequestsException(org.apache.chemistry.opencmis.commons.exceptions.CmisTooManyRequestsException) CmisBaseException(org.apache.chemistry.opencmis.commons.exceptions.CmisBaseException) CmisStorageException(org.apache.chemistry.opencmis.commons.exceptions.CmisStorageException) CmisNotSupportedException(org.apache.chemistry.opencmis.commons.exceptions.CmisNotSupportedException) IOException(java.io.IOException) CmisUpdateConflictException(org.apache.chemistry.opencmis.commons.exceptions.CmisUpdateConflictException) CmisVersioningException(org.apache.chemistry.opencmis.commons.exceptions.CmisVersioningException) CmisInvalidArgumentException(org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException)

Example 9 with BaseTypeId

use of org.apache.chemistry.opencmis.commons.enums.BaseTypeId in project structr by structr.

the class CMISObjectService method createFolder.

@Override
public String createFolder(final String repositoryId, final Properties properties, final String folderId, final List<String> policies, final Acl addAces, final Acl removeAces, final ExtensionsData extension) {
    final App app = StructrApp.getInstance(securityContext);
    String uuid = null;
    try (final Tx tx = app.tx()) {
        final String objectTypeId = getStringValue(properties, PropertyIds.OBJECT_TYPE_ID);
        final Class type = typeFromObjectTypeId(objectTypeId, BaseTypeId.CMIS_FOLDER, Folder.class);
        // check if type exists
        if (type != null) {
            // check that base type is cmis:folder
            final BaseTypeId baseTypeId = getBaseTypeId(type);
            if (baseTypeId != null && BaseTypeId.CMIS_FOLDER.equals(baseTypeId)) {
                // create folder
                final AbstractFile newFolder = (AbstractFile) app.create(type, PropertyMap.cmisTypeToJavaType(securityContext, type, properties));
                // find and set parent if it exists
                if (!CMISInfo.ROOT_FOLDER_ID.equals(folderId)) {
                    final Folder parent = app.get(Folder.class, folderId);
                    if (parent != null) {
                        newFolder.setParent(parent);
                    } else {
                        throw new CmisObjectNotFoundException("Folder with ID " + folderId + " does not exist");
                    }
                }
                uuid = newFolder.getUuid();
            } else {
                throw new CmisConstraintException("Cannot create cmis:folder of type " + objectTypeId);
            }
        } else {
            throw new CmisObjectNotFoundException("Type with ID " + objectTypeId + " does not exist");
        }
        tx.success();
    } catch (Throwable t) {
        throw new CmisRuntimeException("New folder could not be created: " + t.getMessage());
    }
    return uuid;
}
Also used : App(org.structr.core.app.App) StructrApp(org.structr.core.app.StructrApp) AbstractFile(org.structr.web.entity.AbstractFile) Tx(org.structr.core.graph.Tx) CmisObjectNotFoundException(org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException) CmisRuntimeException(org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException) CmisConstraintException(org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException) BaseTypeId(org.apache.chemistry.opencmis.commons.enums.BaseTypeId) Folder(org.structr.web.entity.Folder)

Example 10 with BaseTypeId

use of org.apache.chemistry.opencmis.commons.enums.BaseTypeId in project structr by structr.

the class CMISRepositoryService method extendTypeDefinition.

private MutableTypeDefinition extendTypeDefinition(final Class<? extends GraphObject> type, final Boolean includePropertyDefinitions) {
    final String typeName = type.getSimpleName();
    MutableTypeDefinition result = null;
    try {
        // instantiate class to obtain runtime CMIS information
        final GraphObject obj = type.newInstance();
        if (obj != null) {
            final CMISInfo info = obj.getCMISInfo();
            if (info != null) {
                final BaseTypeId baseTypeId = info.getBaseTypeId();
                if (baseTypeId != null) {
                    switch(baseTypeId) {
                        case CMIS_DOCUMENT:
                            result = getDocumentTypeDefinition(typeName, includePropertyDefinitions, false);
                            break;
                        case CMIS_FOLDER:
                            result = getFolderTypeDefinition(typeName, includePropertyDefinitions, false);
                            break;
                        case CMIS_ITEM:
                            result = getItemTypeDefinition(typeName, includePropertyDefinitions, false);
                            break;
                        case CMIS_POLICY:
                            result = getPolicyTypeDefinition(typeName, includePropertyDefinitions, false);
                            break;
                        case CMIS_RELATIONSHIP:
                            result = getRelationshipTypeDefinition(typeName, includePropertyDefinitions, false);
                            break;
                        case CMIS_SECONDARY:
                            result = getSecondaryTypeDefinition(typeName, includePropertyDefinitions, false);
                            break;
                    }
                    if (result != null) {
                        // initialize..
                        for (final PropertyKey key : StructrApp.getConfiguration().getPropertySet(type, PropertyView.All)) {
                            final MutablePropertyDefinition property = createProperty(type, key);
                            if (property != null) {
                                result.addPropertyDefinition(property);
                            }
                        }
                    }
                }
            }
        }
    } catch (final IllegalAccessException | InstantiationException iex) {
        logger.warn("", iex);
    }
    return result;
}
Also used : MutableTypeDefinition(org.apache.chemistry.opencmis.commons.definitions.MutableTypeDefinition) CMISInfo(org.structr.cmis.CMISInfo) BaseTypeId(org.apache.chemistry.opencmis.commons.enums.BaseTypeId) MutablePropertyDefinition(org.apache.chemistry.opencmis.commons.definitions.MutablePropertyDefinition) GraphObject(org.structr.core.GraphObject) PropertyKey(org.structr.core.property.PropertyKey)

Aggregations

BaseTypeId (org.apache.chemistry.opencmis.commons.enums.BaseTypeId)12 CmisObjectNotFoundException (org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException)5 MutableTypeDefinition (org.apache.chemistry.opencmis.commons.definitions.MutableTypeDefinition)3 CmisConstraintException (org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException)3 CmisRuntimeException (org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException)3 BaseMessage (com.pogeyan.cmis.api.BaseMessage)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 LinkedHashMap (java.util.LinkedHashMap)2 LinkedList (java.util.LinkedList)2 ObjectData (org.apache.chemistry.opencmis.commons.data.ObjectData)2 PermissionMapping (org.apache.chemistry.opencmis.commons.data.PermissionMapping)2 MutableDocumentTypeDefinition (org.apache.chemistry.opencmis.commons.definitions.MutableDocumentTypeDefinition)2 MutableFolderTypeDefinition (org.apache.chemistry.opencmis.commons.definitions.MutableFolderTypeDefinition)2 MutableItemTypeDefinition (org.apache.chemistry.opencmis.commons.definitions.MutableItemTypeDefinition)2 MutablePolicyTypeDefinition (org.apache.chemistry.opencmis.commons.definitions.MutablePolicyTypeDefinition)2 MutableRelationshipTypeDefinition (org.apache.chemistry.opencmis.commons.definitions.MutableRelationshipTypeDefinition)2 MutableSecondaryTypeDefinition (org.apache.chemistry.opencmis.commons.definitions.MutableSecondaryTypeDefinition)2 PermissionDefinition (org.apache.chemistry.opencmis.commons.definitions.PermissionDefinition)2 TypeDefinition (org.apache.chemistry.opencmis.commons.definitions.TypeDefinition)2