Search in sources :

Example 1 with NewTypeSettableAttributes

use of org.apache.chemistry.opencmis.commons.data.NewTypeSettableAttributes 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 NewTypeSettableAttributes

use of org.apache.chemistry.opencmis.commons.data.NewTypeSettableAttributes in project copper-cms by PogeyanOSS.

the class AbstractSessionTest method createType.

// --- type helpers ---
/**
 * Creates a new type.
 */
protected ObjectType createType(Session session, TypeDefinition typeDef) {
    NewTypeSettableAttributes settableAttributes = session.getRepositoryInfo().getCapabilities().getNewTypeSettableAttributes();
    if (settableAttributes == null) {
        addResult(createResult(WARNING, "Repository Info does not indicate, which type attributes can be set!"));
    } else {
    }
    ObjectType newType = null;
    try {
        newType = session.createType(typeDef);
        addResult(createInfoResult("Created type '" + typeDef.getId() + "'. Repository assigned the following type ID: " + newType.getId()));
    } catch (CmisBaseException e) {
        addResult(createResult(FAILURE, "Creating type '" + typeDef.getId() + "' failed: " + e.getMessage(), e, false));
        return null;
    }
    addResult(checkTypeDefinition(session, newType, "Newly created type spec compliance."));
    if (newType.getTypeMutability() == null) {
        addResult(createResult(FAILURE, "Newly created type does not provide type mutability data! ID: " + newType.getId()));
    }
    return newType;
}
Also used : ObjectType(org.apache.chemistry.opencmis.client.api.ObjectType) NewTypeSettableAttributes(org.apache.chemistry.opencmis.commons.data.NewTypeSettableAttributes) CmisBaseException(org.apache.chemistry.opencmis.commons.exceptions.CmisBaseException)

Aggregations

NewTypeSettableAttributes (org.apache.chemistry.opencmis.commons.data.NewTypeSettableAttributes)2 ObjectType (org.apache.chemistry.opencmis.client.api.ObjectType)1 CmisBaseException (org.apache.chemistry.opencmis.commons.exceptions.CmisBaseException)1 DocumentTypeDefinitionImpl (org.apache.chemistry.opencmis.commons.impl.dataobjects.DocumentTypeDefinitionImpl)1 CmisTestResult (org.apache.chemistry.opencmis.tck.CmisTestResult)1