Search in sources :

Example 1 with DocumentTypeDefinitionImpl

use of org.apache.chemistry.opencmis.commons.impl.dataobjects.DocumentTypeDefinitionImpl in project copper-cms by PogeyanOSS.

the class CreateAndDeleteTypeTest method createDocumentTypeDefinition.

private DocumentTypeDefinitionImpl createDocumentTypeDefinition(Session session, String typeId, ObjectType parentType) {
    CmisTestResult failure = null;
    NewTypeSettableAttributes settableAttributes = session.getRepositoryInfo().getCapabilities().getNewTypeSettableAttributes();
    if (settableAttributes == null) {
        addResult(createResult(WARNING, "Capability NewTypeSettableAttributes is not set!"));
    }
    DocumentTypeDefinitionImpl result = new DocumentTypeDefinitionImpl();
    result.setBaseTypeId(parentType.getBaseTypeId());
    result.setParentTypeId(parentType.getId());
    if (settableAttributes == null || Boolean.TRUE.equals(settableAttributes.canSetId())) {
        result.setId(typeId);
    } else if (settableAttributes != null) {
        failure = createResult(WARNING, "Flag 'id' in capability NewTypeSettableAttributes is not set!");
        addResult(assertNotNull(settableAttributes.canSetId(), null, failure));
    }
    if (settableAttributes == null || Boolean.TRUE.equals(settableAttributes.canSetLocalName())) {
        result.setLocalName("tck:testlocal");
    } else if (settableAttributes != null) {
        failure = createResult(WARNING, "Flag 'localName' in capability NewTypeSettableAttributes is not set!");
        addResult(assertNotNull(settableAttributes.canSetLocalName(), null, failure));
    }
    if (settableAttributes == null || Boolean.TRUE.equals(settableAttributes.canSetLocalNamespace())) {
        result.setLocalNamespace("http://tck/testlocalnamespace");
    } else if (settableAttributes != null) {
        failure = createResult(WARNING, "Flag 'localNamespace' in capability NewTypeSettableAttributes is not set!");
        addResult(assertNotNull(settableAttributes.canSetLocalNamespace(), null, failure));
    }
    if (settableAttributes == null || Boolean.TRUE.equals(settableAttributes.canSetDisplayName())) {
        result.setDisplayName("TCK Document Type");
    } else if (settableAttributes != null) {
        failure = createResult(WARNING, "Flag 'displayName' in capability NewTypeSettableAttributes is not set!");
        addResult(assertNotNull(settableAttributes.canSetDisplayName(), null, failure));
    }
    if (settableAttributes == null || Boolean.TRUE.equals(settableAttributes.canSetDescription())) {
        result.setDescription("This is the TCK document type");
    } else if (settableAttributes != null) {
        failure = createResult(WARNING, "Flag 'description' in capability NewTypeSettableAttributes is not set!");
        addResult(assertNotNull(settableAttributes.canSetDescription(), null, failure));
    }
    if (settableAttributes == null || Boolean.TRUE.equals(settableAttributes.canSetQueryName())) {
        result.setQueryName("tck:testqueryname");
    } else if (settableAttributes != null) {
        failure = createResult(WARNING, "Flag 'queryName' in capability NewTypeSettableAttributes is not set!");
        addResult(assertNotNull(settableAttributes.canSetQueryName(), null, failure));
    }
    if (settableAttributes == null || Boolean.TRUE.equals(settableAttributes.canSetQueryable())) {
        result.setIsQueryable(false);
    } else if (settableAttributes != null) {
        failure = createResult(WARNING, "Flag 'queryable' in capability NewTypeSettableAttributes is not set!");
        addResult(assertNotNull(settableAttributes.canSetQueryable(), null, failure));
    }
    if (settableAttributes == null || Boolean.TRUE.equals(settableAttributes.canSetFulltextIndexed())) {
        result.setIsFulltextIndexed(false);
    } else if (settableAttributes != null) {
        failure = createResult(WARNING, "Flag 'fulltextIndexed' in capability NewTypeSettableAttributes is not set!");
        addResult(assertNotNull(settableAttributes.canSetFulltextIndexed(), null, failure));
    }
    if (settableAttributes == null || Boolean.TRUE.equals(settableAttributes.canSetIncludedInSupertypeQuery())) {
        result.setIsIncludedInSupertypeQuery(false);
    } else if (settableAttributes != null) {
        failure = createResult(WARNING, "Flag 'includedInSupertypeQuery' in capability NewTypeSettableAttributes is not set!");
        addResult(assertNotNull(settableAttributes.canSetIncludedInSupertypeQuery(), null, failure));
    }
    if (settableAttributes == null || Boolean.TRUE.equals(settableAttributes.canSetControllableAcl())) {
        result.setIsControllableAcl(false);
    } else if (settableAttributes != null) {
        failure = createResult(WARNING, "Flag 'controllableACL' in capability NewTypeSettableAttributes is not set!");
        addResult(assertNotNull(settableAttributes.canSetControllableAcl(), null, failure));
    }
    if (settableAttributes == null || Boolean.TRUE.equals(settableAttributes.canSetControllablePolicy())) {
        result.setIsControllablePolicy(false);
    } else if (settableAttributes != null) {
        failure = createResult(WARNING, "Flag 'controllablePolicy' in capability NewTypeSettableAttributes is not set!");
        addResult(assertNotNull(settableAttributes.canSetControllablePolicy(), null, failure));
    }
    if (settableAttributes == null || Boolean.TRUE.equals(settableAttributes.canSetCreatable())) {
        result.setIsCreatable(true);
    } else if (settableAttributes != null) {
        failure = createResult(WARNING, "Flag 'creatable' in capability NewTypeSettableAttributes is not set!");
        addResult(assertNotNull(settableAttributes.canSetCreatable(), null, failure));
    }
    if (settableAttributes == null || Boolean.TRUE.equals(settableAttributes.canSetFileable())) {
        result.setIsFileable(true);
    } else if (settableAttributes != null) {
        failure = createResult(WARNING, "Flag 'fileable' in capability NewTypeSettableAttributes is not set!");
        addResult(assertNotNull(settableAttributes.canSetFileable(), null, failure));
    }
    result.setIsVersionable(false);
    result.setContentStreamAllowed(ContentStreamAllowed.ALLOWED);
    return result;
}
Also used : NewTypeSettableAttributes(org.apache.chemistry.opencmis.commons.data.NewTypeSettableAttributes) CmisTestResult(org.apache.chemistry.opencmis.tck.CmisTestResult) DocumentTypeDefinitionImpl(org.apache.chemistry.opencmis.commons.impl.dataobjects.DocumentTypeDefinitionImpl)

Example 2 with DocumentTypeDefinitionImpl

use of org.apache.chemistry.opencmis.commons.impl.dataobjects.DocumentTypeDefinitionImpl in project copper-cms by PogeyanOSS.

the class CreateAndDeleteTypeTest method createTypeWithProperties.

private void createTypeWithProperties(Session session, ObjectType parentType) {
    CmisTestResult failure = null;
    CreatablePropertyTypes cpt = session.getRepositoryInfo().getCapabilities().getCreatablePropertyTypes();
    if (cpt == null || cpt.canCreate() == null || cpt.canCreate().isEmpty()) {
        addResult(createResult(FAILURE, "Repository Info does not indicate, which property types can be created!"));
        return;
    }
    // define the type
    DocumentTypeDefinitionImpl newTypeDef = createDocumentTypeDefinition(session, "tck:testid_with_properties", parentType);
    // add a property for each creatable property type
    for (PropertyType propType : PropertyType.values()) {
        if (!cpt.canCreate().contains(propType)) {
            continue;
        }
        newTypeDef.addPropertyDefinition(createPropertyDefinition(propType));
    }
    // create the type
    ObjectType newType = createType(session, newTypeDef);
    if (newType == null) {
        return;
    }
    // get the type
    ObjectType newType2 = null;
    try {
        newType2 = session.getTypeDefinition(newType.getId());
        // assert type definitions
        failure = createResult(FAILURE, "The type definition returned by createType() doesn't match the type definition returned by getTypeDefinition()!");
        addResult(assertEquals(newType, newType2, null, failure));
    } catch (CmisObjectNotFoundException e) {
        addResult(createResult(FAILURE, "Newly created type can not be fetched. Id: " + newType.getId(), e, false));
    }
    // check properties
    List<PropertyDefinition<?>> newPropDefs = new ArrayList<PropertyDefinition<?>>();
    for (Map.Entry<String, PropertyDefinition<?>> propDef : newType.getPropertyDefinitions().entrySet()) {
        if (Boolean.FALSE.equals(propDef.getValue().isInherited())) {
            newPropDefs.add(propDef.getValue());
        }
    }
    failure = createResult(FAILURE, "The number of defined properties and the number of non-inherited properties don't match!");
    addResult(assertEquals(newTypeDef.getPropertyDefinitions().size(), newPropDefs.size(), null, failure));
    // check the order of the properties, which must match the order of the
    // original type definition
    // (OpenCMIS keeps the order of the property definitions.)
    int i = 0;
    for (Map.Entry<String, PropertyDefinition<?>> propDef : newTypeDef.getPropertyDefinitions().entrySet()) {
        PropertyDefinition<?> newPropDef = newPropDefs.get(i);
        failure = createResult(FAILURE, "Property " + (i + 1) + " must be of type " + propDef.getValue().getPropertyType() + " but is of type " + newPropDef.getPropertyType() + "!");
        addResult(assertEquals(propDef.getValue().getPropertyType(), newPropDef.getPropertyType(), null, failure));
        addResult(createInfoResult("Repository assigned the property '" + propDef.getValue().getId() + "' the following property id: " + newPropDef.getId()));
        i++;
    }
    // delete the type
    deleteType(session, newType.getId());
}
Also used : CreatablePropertyTypes(org.apache.chemistry.opencmis.commons.data.CreatablePropertyTypes) ArrayList(java.util.ArrayList) PropertyType(org.apache.chemistry.opencmis.commons.enums.PropertyType) DocumentTypeDefinitionImpl(org.apache.chemistry.opencmis.commons.impl.dataobjects.DocumentTypeDefinitionImpl) PropertyDefinition(org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition) AbstractPropertyDefinition(org.apache.chemistry.opencmis.commons.impl.dataobjects.AbstractPropertyDefinition) ObjectType(org.apache.chemistry.opencmis.client.api.ObjectType) CmisObjectNotFoundException(org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException) CmisTestResult(org.apache.chemistry.opencmis.tck.CmisTestResult) Map(java.util.Map)

Example 3 with DocumentTypeDefinitionImpl

use of org.apache.chemistry.opencmis.commons.impl.dataobjects.DocumentTypeDefinitionImpl in project copper-cms by PogeyanOSS.

the class CreateAndDeleteTypeTest method createTypeWithoutProperties.

private void createTypeWithoutProperties(Session session, ObjectType parentType) {
    CmisTestResult failure = null;
    // define the type
    DocumentTypeDefinitionImpl newTypeDef = createDocumentTypeDefinition(session, "tck:testid_without_properties", parentType);
    // create the type
    ObjectType newType = createType(session, newTypeDef);
    if (newType == null) {
        return;
    }
    // get the type
    ObjectType newType2 = null;
    try {
        newType2 = session.getTypeDefinition(newType.getId());
        // assert type definitions
        failure = createResult(FAILURE, "The type definition returned by createType() doesn't match the type definition returned by getTypeDefinition()!");
        addResult(assertEquals(newType, newType2, null, failure));
    } catch (CmisObjectNotFoundException e) {
        addResult(createResult(FAILURE, "Newly created type can not be fetched. Id: " + newType.getId(), e, false));
    }
    // delete the type
    deleteType(session, newType.getId());
}
Also used : ObjectType(org.apache.chemistry.opencmis.client.api.ObjectType) CmisObjectNotFoundException(org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException) CmisTestResult(org.apache.chemistry.opencmis.tck.CmisTestResult) DocumentTypeDefinitionImpl(org.apache.chemistry.opencmis.commons.impl.dataobjects.DocumentTypeDefinitionImpl)

Aggregations

DocumentTypeDefinitionImpl (org.apache.chemistry.opencmis.commons.impl.dataobjects.DocumentTypeDefinitionImpl)3 CmisTestResult (org.apache.chemistry.opencmis.tck.CmisTestResult)3 ObjectType (org.apache.chemistry.opencmis.client.api.ObjectType)2 CmisObjectNotFoundException (org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException)2 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 CreatablePropertyTypes (org.apache.chemistry.opencmis.commons.data.CreatablePropertyTypes)1 NewTypeSettableAttributes (org.apache.chemistry.opencmis.commons.data.NewTypeSettableAttributes)1 PropertyDefinition (org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition)1 PropertyType (org.apache.chemistry.opencmis.commons.enums.PropertyType)1 AbstractPropertyDefinition (org.apache.chemistry.opencmis.commons.impl.dataobjects.AbstractPropertyDefinition)1