Search in sources :

Example 1 with MBaseObjectDAO

use of com.pogeyan.cmis.api.data.services.MBaseObjectDAO 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)

Aggregations

MBaseObjectDAO (com.pogeyan.cmis.api.data.services.MBaseObjectDAO)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 LinkedHashMap (java.util.LinkedHashMap)1 PermissionMapping (org.apache.chemistry.opencmis.commons.data.PermissionMapping)1 PermissionDefinition (org.apache.chemistry.opencmis.commons.definitions.PermissionDefinition)1 BaseTypeId (org.apache.chemistry.opencmis.commons.enums.BaseTypeId)1 PropertyType (org.apache.chemistry.opencmis.commons.enums.PropertyType)1 AclCapabilitiesDataImpl (org.apache.chemistry.opencmis.commons.impl.dataobjects.AclCapabilitiesDataImpl)1 CreatablePropertyTypesImpl (org.apache.chemistry.opencmis.commons.impl.dataobjects.CreatablePropertyTypesImpl)1 NewTypeSettableAttributesImpl (org.apache.chemistry.opencmis.commons.impl.dataobjects.NewTypeSettableAttributesImpl)1 RepositoryCapabilitiesImpl (org.apache.chemistry.opencmis.commons.impl.dataobjects.RepositoryCapabilitiesImpl)1 RepositoryInfoImpl (org.apache.chemistry.opencmis.commons.impl.dataobjects.RepositoryInfoImpl)1