Search in sources :

Example 1 with PermissionDefinition

use of org.apache.chemistry.opencmis.commons.definitions.PermissionDefinition in project structr by structr.

the class StructrRepositoryInfo method getPermissions.

@Override
public List<PermissionDefinition> getPermissions() {
    final List<PermissionDefinition> permissions = new LinkedList<>();
    permissions.add(new StructrPermissionDefinition(Permission.read, "Read access"));
    permissions.add(new StructrPermissionDefinition(Permission.write, "Write access"));
    permissions.add(new StructrPermissionDefinition(Permission.delete, "Write access"));
    permissions.add(new StructrPermissionDefinition(Permission.accessControl, "Access control"));
    return permissions;
}
Also used : StructrPermissionDefinition(org.structr.files.cmis.repository.StructrPermissionDefinition) StructrPermissionDefinition(org.structr.files.cmis.repository.StructrPermissionDefinition) PermissionDefinition(org.apache.chemistry.opencmis.commons.definitions.PermissionDefinition) LinkedList(java.util.LinkedList)

Example 2 with PermissionDefinition

use of org.apache.chemistry.opencmis.commons.definitions.PermissionDefinition in project iaf by ibissource.

the class CmisUtils method xml2permissionDefinitionList.

private static List<PermissionDefinition> xml2permissionDefinitionList(Element cmisResult) {
    List<PermissionDefinition> permissionsList = new ArrayList<PermissionDefinition>();
    Element permissionsXml = XmlUtils.getFirstChildTag(cmisResult, "permissions");
    for (Node node : XmlUtils.getChildTags(permissionsXml, "permission")) {
        Element element = (Element) node;
        PermissionDefinitionDataImpl permissionDefinition = new PermissionDefinitionDataImpl();
        permissionDefinition.setId(element.getAttribute("id"));
        permissionDefinition.setDescription(element.getAttribute("description"));
        permissionsList.add(permissionDefinition);
    }
    return permissionsList;
}
Also used : PermissionDefinition(org.apache.chemistry.opencmis.commons.definitions.PermissionDefinition) Element(org.w3c.dom.Element) Node(org.w3c.dom.Node) ArrayList(java.util.ArrayList) PermissionDefinitionDataImpl(org.apache.chemistry.opencmis.commons.impl.dataobjects.PermissionDefinitionDataImpl)

Example 3 with PermissionDefinition

use of org.apache.chemistry.opencmis.commons.definitions.PermissionDefinition 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 4 with PermissionDefinition

use of org.apache.chemistry.opencmis.commons.definitions.PermissionDefinition 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 5 with PermissionDefinition

use of org.apache.chemistry.opencmis.commons.definitions.PermissionDefinition in project copper-cms by PogeyanOSS.

the class RepositoryInfoTest method run.

@Override
public void run(Session session) {
    CmisTestResult success;
    CmisTestResult failure;
    RepositoryInfo ri = getRepositoryInfo(session);
    // ID
    success = createResult(OK, "Repository ID: " + ri.getId());
    failure = createResult(FAILURE, "Repository id is not set!", true);
    addResult(assertStringNotEmpty(ri.getId(), success, failure));
    // name
    failure = createResult(FAILURE, "Repository name is not set!");
    addResult(assertNotNull(ri.getName(), null, failure));
    success = createResult(OK, "Repository name: " + ri.getName());
    failure = createResult(WARNING, "Repository name is empty!");
    addResult(assertStringNotEmpty(ri.getName(), success, failure));
    // description
    failure = createResult(FAILURE, "Repository description is not set!");
    addResult(assertNotNull(ri.getDescription(), null, failure));
    success = createResult(OK, "Repository description: " + ri.getDescription());
    failure = createResult(WARNING, "Repository description is empty!");
    addResult(assertStringNotEmpty(ri.getDescription(), success, failure));
    // vendor
    failure = createResult(FAILURE, "Vendor name is not set!");
    addResult(assertStringNotEmpty(ri.getVendorName(), null, failure));
    success = createResult(OK, "Vendor name: " + ri.getVendorName());
    failure = createResult(WARNING, "Vendor name is empty!");
    addResult(assertStringNotEmpty(ri.getVendorName(), success, failure));
    // product name
    failure = createResult(FAILURE, "Product name is not set!");
    addResult(assertStringNotEmpty(ri.getProductName(), null, failure));
    success = createResult(OK, "Product name: " + ri.getProductName());
    failure = createResult(WARNING, "Product name is empty!");
    addResult(assertStringNotEmpty(ri.getProductName(), success, failure));
    // product version
    failure = createResult(FAILURE, "Product version is not set!");
    addResult(assertStringNotEmpty(ri.getProductVersion(), null, failure));
    success = createResult(OK, "Product version: " + ri.getProductVersion());
    failure = createResult(WARNING, "Product version is empty!");
    addResult(assertStringNotEmpty(ri.getProductVersion(), success, failure));
    // CMIS version supported
    success = createResult(OK, "CMIS Version Supported: " + ri.getCmisVersionSupported());
    failure = createResult(FAILURE, "CMIS Version Supported is not set!");
    addResult(assertStringNotEmpty(ri.getCmisVersionSupported(), success, failure));
    if (!"1.0".equals(ri.getCmisVersionSupported()) && !"1.1".equals(ri.getCmisVersionSupported())) {
        addResult(createResult(FAILURE, "CMIS Version Supported is neither '1.0' nor '1.1'!"));
    }
    // root folder
    success = createResult(OK, "Root folder ID: " + ri.getRootFolderId());
    failure = createResult(FAILURE, "Root folder ID is not set!");
    addResult(assertStringNotEmpty(ri.getRootFolderId(), success, failure));
    // thin client URI
    success = createResult(OK, "Thin client URI: " + ri.getThinClientUri());
    failure = createResult(WARNING, "Thin client URI is not set!");
    addResult(assertStringNotEmpty(ri.getThinClientUri(), success, failure));
    if (ri.getThinClientUri() != null && ri.getThinClientUri().length() > 0) {
        try {
            HttpURLConnection conn = (HttpURLConnection) (new URL(ri.getThinClientUri())).openConnection();
            conn.connect();
            int responseCode = conn.getResponseCode();
            failure = createResult(WARNING, "Unable to connect to thin client '" + ri.getThinClientUri() + "'. HTTP status code: " + responseCode);
            addResult(assertIsTrue(responseCode >= 200 && responseCode < 400, null, failure));
            conn.disconnect();
        } catch (Exception e) {
            addResult(createResult(WARNING, "Unable to connect to thin client '" + ri.getThinClientUri() + "': " + e.getMessage(), e, false));
        }
    }
    // principal ID anonymous
    success = createResult(OK, "Principal ID anonymous: " + ri.getPrincipalIdAnonymous());
    failure = createResult(WARNING, "Principal ID anonymous is not set!");
    addResult(assertStringNotEmpty(ri.getPrincipalIdAnonymous(), success, failure));
    // principal ID anyone
    success = createResult(OK, "Principal ID anyone: " + ri.getPrincipalIdAnyone());
    failure = createResult(WARNING, "Principal Id anyone is not set!");
    addResult(assertStringNotEmpty(ri.getPrincipalIdAnyone(), success, failure));
    // latest change log token
    success = createResult(OK, "Latest change log token: " + ri.getLatestChangeLogToken());
    failure = createResult(WARNING, "Latest change log token is not set!");
    addResult(assertStringNotEmpty(ri.getLatestChangeLogToken(), success, failure));
    // changes incomplete
    success = createResult(OK, "Changes Incomplete: " + ri.getChangesIncomplete());
    failure = createResult(WARNING, "Changes Incomplete is not set!");
    addResult(assertNotNull(ri.getChangesIncomplete(), success, failure));
    // changes on type
    success = createResult(OK, "Changes on type: " + ri.getChangesOnType());
    failure = createResult(WARNING, "Changes on type is not set!");
    addResult(assertNotNull(ri.getChangesOnType(), success, failure));
    if (ri.getChangesOnType() != null) {
        failure = createResult(WARNING, "Changes on type has more than 4 entries!");
        addResult(assertIsTrue(ri.getChangesOnType().size() < 5, null, failure));
    }
    // features
    if (ri.getCmisVersion() != CmisVersion.CMIS_1_0) {
        success = createResult(OK, "Repository features exposed.");
        failure = createResult(OK, "No repository features exposed.");
        addResult(assertNotNull(ri.getExtensionFeatures(), success, failure));
        if (ri.getExtensionFeatures() != null) {
            for (ExtensionFeature feature : ri.getExtensionFeatures()) {
                failure = createResult(FAILURE, "At least one repository features has no ID!");
                addResult(assertStringNotEmpty(feature.getId(), null, failure));
            }
        }
    }
    // capabilities
    if (ri.getCapabilities() == null) {
        addResult(createResult(FAILURE, "Capabilities are not set!"));
    } else {
        RepositoryCapabilities cap = ri.getCapabilities();
        // ACL capability
        success = createResult(OK, "ACL capability: " + cap.getAclCapability());
        failure = createResult(FAILURE, "ACL capability is not set!");
        addResult(assertNotNull(cap.getAclCapability(), success, failure));
        // changes capability
        success = createResult(OK, "Changes capability: " + cap.getChangesCapability());
        failure = createResult(WARNING, "Changes capability is not set!");
        addResult(assertNotNull(cap.getChangesCapability(), success, failure));
        // content stream updates capability
        success = createResult(OK, "Content stream updates capability: " + cap.getContentStreamUpdatesCapability());
        failure = createResult(FAILURE, "Content stream updates is not set!");
        addResult(assertNotNull(cap.getContentStreamUpdatesCapability(), success, failure));
        // get descendants capability
        success = createResult(OK, "Get descendants capability: " + cap.isGetDescendantsSupported());
        failure = createResult(FAILURE, "Get descendants capability is not set!");
        addResult(assertNotNull(cap.isGetDescendantsSupported(), success, failure));
        // get folder tree capability
        success = createResult(OK, "Get folder tree capability: " + cap.isGetFolderTreeSupported());
        failure = createResult(FAILURE, "Get folder tree capability is not set!");
        addResult(assertNotNull(cap.isGetFolderTreeSupported(), success, failure));
        // multifiling capability
        success = createResult(OK, "Multifiling capability: " + cap.isMultifilingSupported());
        failure = createResult(FAILURE, "Multifiling capability is not set!");
        addResult(assertNotNull(cap.isMultifilingSupported(), success, failure));
        // unfiling capability
        success = createResult(OK, "Unfiling capability: " + cap.isUnfilingSupported());
        failure = createResult(FAILURE, "Unfiling capability is not set!");
        addResult(assertNotNull(cap.isUnfilingSupported(), success, failure));
        // version specific filing capability
        success = createResult(OK, "Version specific filing capability: " + cap.isVersionSpecificFilingSupported());
        failure = createResult(FAILURE, "Version specific filing capability is not set!");
        addResult(assertNotNull(cap.isVersionSpecificFilingSupported(), success, failure));
        // query capability
        success = createResult(OK, "Query capability: " + cap.getQueryCapability());
        failure = createResult(FAILURE, "Query capability is not set!");
        addResult(assertNotNull(cap.getQueryCapability(), success, failure));
        // JOIN capability
        success = createResult(OK, "JOIN capability: " + cap.getJoinCapability());
        failure = createResult(FAILURE, "JOIN capability is not set!");
        addResult(assertNotNull(cap.getJoinCapability(), success, failure));
        // all versions searchable capability
        success = createResult(OK, "All versions searchable capability: " + cap.isAllVersionsSearchableSupported());
        failure = createResult(FAILURE, "All versions searchable capability is not set!");
        addResult(assertNotNull(cap.isAllVersionsSearchableSupported(), success, failure));
        // PWC searchable capability
        success = createResult(OK, "PWC searchable capability: " + cap.isPwcSearchableSupported());
        failure = createResult(FAILURE, "PWC searchable capability is not set!");
        addResult(assertNotNull(cap.isPwcSearchableSupported(), success, failure));
        // PWC updatable capability
        success = createResult(OK, "PWC updatable capability: " + cap.isPwcUpdatableSupported());
        failure = createResult(FAILURE, "PWC updatable capability is not set!");
        addResult(assertNotNull(cap.isPwcUpdatableSupported(), success, failure));
        // renditions capability
        success = createResult(OK, "Renditions capability: " + cap.getRenditionsCapability());
        failure = createResult(FAILURE, "Renditions capability is not set!");
        addResult(assertNotNull(cap.getRenditionsCapability(), success, failure));
        if (ri.getCmisVersion() != CmisVersion.CMIS_1_0) {
            // new type settable attributes
            success = createResult(OK, "'New type settable attributes' flags are set.");
            failure = createResult(WARNING, "'New type settable attributes' flags are not set!");
            addResult(assertNotNull(cap.getNewTypeSettableAttributes(), success, failure));
            // creatable property types
            success = createResult(OK, "'Creatable property types' flags are set.");
            failure = createResult(WARNING, "'Creatable property types' flags are not set!");
            addResult(assertNotNull(cap.getCreatablePropertyTypes(), success, failure));
        }
    }
    // ACL capabilities
    if (ri.getAclCapabilities() == null) {
        addResult(createResult(WARNING, "ACL capabilities are not set!"));
    } else {
        AclCapabilities aclCap = ri.getAclCapabilities();
        // supported permissions
        success = createResult(OK, "Supported permissions: " + aclCap.getSupportedPermissions());
        failure = createResult(WARNING, "Supported permissions are not set!");
        addResult(assertNotNull(aclCap.getSupportedPermissions(), success, failure));
        // ACL propagation
        success = createResult(OK, "ACL propagation: " + aclCap.getAclPropagation());
        failure = createResult(WARNING, "ACL propagation is not set!");
        addResult(assertNotNull(aclCap.getAclPropagation(), success, failure));
        // permissions
        success = createResult(OK, "Permissions: " + (aclCap.getPermissions() == null ? "?" : aclCap.getPermissions().size()));
        failure = createResult(FAILURE, "Permissions are not set!");
        addResult(assertNotNull(aclCap.getPermissions(), success, failure));
        if (aclCap.getPermissions() != null) {
            int i = 0;
            for (PermissionDefinition permDef : aclCap.getPermissions()) {
                failure = createResult(FAILURE, "Permission #" + i + " is not set!");
                addResult(assertNotNull(permDef, null, failure));
                if (permDef != null) {
                    failure = createResult(FAILURE, "ID of permission #" + i + " is not set!");
                    addResult(assertStringNotEmpty(permDef.getId(), null, failure));
                }
                i++;
            }
        }
        // permission mapping
        success = createResult(OK, "Permission mapping: " + (aclCap.getPermissionMapping() == null ? "?" : aclCap.getPermissionMapping().size()));
        failure = createResult(WARNING, "Permission mapping is not set!");
        addResult(assertNotNull(aclCap.getPermissionMapping(), success, failure));
    }
    if (ri.getExtensionFeatures() != null) {
        for (ExtensionFeature ef : ri.getExtensionFeatures()) {
            success = createResult(OK, "Extension Feature: " + ef.getId());
            failure = createResult(FAILURE, "Extension Feature without ID!");
            addResult(assertStringNotEmpty(ef.getId(), success, failure));
            failure = createResult(WARNING, "Extension Feature without common name: " + ef.getId());
            addResult(assertStringNotEmpty(ef.getCommonName(), null, failure));
            failure = createResult(WARNING, "Extension Feature without version label: " + ef.getId());
            addResult(assertStringNotEmpty(ef.getVersionLabel(), null, failure));
            failure = createResult(WARNING, "Extension Feature without URL: " + ef.getId());
            addResult(assertStringNotEmpty(ef.getUrl(), null, failure));
        }
    }
}
Also used : AclCapabilities(org.apache.chemistry.opencmis.commons.data.AclCapabilities) PermissionDefinition(org.apache.chemistry.opencmis.commons.definitions.PermissionDefinition) HttpURLConnection(java.net.HttpURLConnection) ExtensionFeature(org.apache.chemistry.opencmis.commons.data.ExtensionFeature) RepositoryInfo(org.apache.chemistry.opencmis.commons.data.RepositoryInfo) CmisTestResult(org.apache.chemistry.opencmis.tck.CmisTestResult) URL(java.net.URL) RepositoryCapabilities(org.apache.chemistry.opencmis.commons.data.RepositoryCapabilities)

Aggregations

PermissionDefinition (org.apache.chemistry.opencmis.commons.definitions.PermissionDefinition)6 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)2 LinkedHashMap (java.util.LinkedHashMap)2 PermissionMapping (org.apache.chemistry.opencmis.commons.data.PermissionMapping)2 BaseTypeId (org.apache.chemistry.opencmis.commons.enums.BaseTypeId)2 PropertyType (org.apache.chemistry.opencmis.commons.enums.PropertyType)2 AclCapabilitiesDataImpl (org.apache.chemistry.opencmis.commons.impl.dataobjects.AclCapabilitiesDataImpl)2 CreatablePropertyTypesImpl (org.apache.chemistry.opencmis.commons.impl.dataobjects.CreatablePropertyTypesImpl)2 NewTypeSettableAttributesImpl (org.apache.chemistry.opencmis.commons.impl.dataobjects.NewTypeSettableAttributesImpl)2 RepositoryCapabilitiesImpl (org.apache.chemistry.opencmis.commons.impl.dataobjects.RepositoryCapabilitiesImpl)2 RepositoryInfoImpl (org.apache.chemistry.opencmis.commons.impl.dataobjects.RepositoryInfoImpl)2 MBaseObjectDAO (com.pogeyan.cmis.api.data.services.MBaseObjectDAO)1 HttpURLConnection (java.net.HttpURLConnection)1 URL (java.net.URL)1 LinkedList (java.util.LinkedList)1 XmlBuilder (nl.nn.adapterframework.util.XmlBuilder)1 AclCapabilities (org.apache.chemistry.opencmis.commons.data.AclCapabilities)1 ExtensionFeature (org.apache.chemistry.opencmis.commons.data.ExtensionFeature)1 RepositoryCapabilities (org.apache.chemistry.opencmis.commons.data.RepositoryCapabilities)1