Search in sources :

Example 1 with TypeDefinitionContainer

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

the class RepositoryActor method getTypeDescendants.

private JSONArray getTypeDescendants(QueryGetRequest request) throws IllegalArgumentException, CmisInvalidArgumentException, CmisRuntimeException {
    String permission = request.getUserObject().getPermission();
    if (!Helpers.checkingUserPremission(permission, "get")) {
        throw new CmisRuntimeException(request.getUserName() + " is not authorized to applyAcl.");
    }
    String typeId = request.getParameter(QueryGetRequest.PARAM_TYPE_ID);
    DateTimeFormat dateTimeFormat = request.getDateTimeFormatParameter();
    BigInteger depth = request.getBigIntegerParameter(QueryGetRequest.PARAM_DEPTH);
    boolean includePropertyDefinitions = request.getBooleanParameter(QueryGetRequest.PARAM_PROPERTY_DEFINITIONS, false);
    List<TypeDefinitionContainer> typeTree = CmisTypeServices.Impl.getTypeDescendants(request.getRepositoryId(), typeId, depth, includePropertyDefinitions, null);
    if (typeTree == null) {
        throw new CmisRuntimeException("Type tree is null!");
    }
    JSONArray jsonTypeTree = new JSONArray();
    for (TypeDefinitionContainer container : typeTree) {
        jsonTypeTree.add(JSONConverter.convert(container, dateTimeFormat));
    }
    return jsonTypeTree;
}
Also used : CmisRuntimeException(org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException) JSONArray(org.apache.chemistry.opencmis.commons.impl.json.JSONArray) BigInteger(java.math.BigInteger) TypeDefinitionContainer(org.apache.chemistry.opencmis.commons.definitions.TypeDefinitionContainer) DateTimeFormat(org.apache.chemistry.opencmis.commons.enums.DateTimeFormat)

Example 2 with TypeDefinitionContainer

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

the class CMISRepositoryService method getTypeDescendants.

@Override
public List<TypeDefinitionContainer> getTypeDescendants(String repositoryId, String typeId, BigInteger depth, Boolean includePropertyDefinitions, ExtensionsData extension) {
    // important: descendants are ALL children and children of children, i.e. the whole tree
    /*
		Id typeId: The typeId of an object-type specified in the repository.
		 - If specified, then the repository MUST return all of descendant types of the specified type.
		 - If not specified, then the Repository MUST return all types and MUST ignore the value of the depth parameter.
		*/
    final List<TypeDefinitionContainer> results = new LinkedList<>();
    if (typeId != null) {
        final BaseTypeId baseTypeId = getBaseTypeId(typeId);
        if (baseTypeId != null) {
            final TypeDefinition typeDefinition = getTypeDefinition(repositoryId, typeId, extension);
            final TypeDefinitionContainer container = getTypeDefinitionContainer(typeDefinition, includePropertyDefinitions);
            results.add(container);
        } else {
            final Class type = StructrApp.getConfiguration().getNodeEntityClass(typeId);
            if (type != null) {
                final TypeDefinition typeDefinition = extendTypeDefinition(type, includePropertyDefinitions);
                if (typeDefinition != null) {
                    results.add(getTypeDefinitionContainer(typeDefinition, includePropertyDefinitions));
                } else {
                    throw new CmisObjectNotFoundException("Type with ID " + typeId + " does not exist");
                }
            } else {
                throw new CmisObjectNotFoundException("Type with ID " + typeId + " does not exist");
            }
        }
    } else {
        results.add(getTypeDefinitionContainer(getDocumentTypeDefinition(BaseTypeId.CMIS_DOCUMENT.value(), includePropertyDefinitions, true), includePropertyDefinitions));
        results.add(getTypeDefinitionContainer(getFolderTypeDefinition(BaseTypeId.CMIS_FOLDER.value(), includePropertyDefinitions, true), includePropertyDefinitions));
        results.add(getTypeDefinitionContainer(getItemTypeDefinition(BaseTypeId.CMIS_ITEM.value(), includePropertyDefinitions, true), includePropertyDefinitions));
        results.add(getTypeDefinitionContainer(getPolicyTypeDefinition(BaseTypeId.CMIS_POLICY.value(), includePropertyDefinitions, true), includePropertyDefinitions));
        results.add(getTypeDefinitionContainer(getRelationshipTypeDefinition(BaseTypeId.CMIS_RELATIONSHIP.value(), includePropertyDefinitions, true), includePropertyDefinitions));
        results.add(getTypeDefinitionContainer(getSecondaryTypeDefinition(BaseTypeId.CMIS_SECONDARY.value(), includePropertyDefinitions, true), includePropertyDefinitions));
    }
    return results;
}
Also used : CmisObjectNotFoundException(org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException) BaseTypeId(org.apache.chemistry.opencmis.commons.enums.BaseTypeId) TypeDefinitionContainer(org.apache.chemistry.opencmis.commons.definitions.TypeDefinitionContainer) LinkedList(java.util.LinkedList) MutableTypeDefinition(org.apache.chemistry.opencmis.commons.definitions.MutableTypeDefinition) MutablePolicyTypeDefinition(org.apache.chemistry.opencmis.commons.definitions.MutablePolicyTypeDefinition) MutableRelationshipTypeDefinition(org.apache.chemistry.opencmis.commons.definitions.MutableRelationshipTypeDefinition) MutableFolderTypeDefinition(org.apache.chemistry.opencmis.commons.definitions.MutableFolderTypeDefinition) TypeDefinition(org.apache.chemistry.opencmis.commons.definitions.TypeDefinition) MutableDocumentTypeDefinition(org.apache.chemistry.opencmis.commons.definitions.MutableDocumentTypeDefinition) MutableSecondaryTypeDefinition(org.apache.chemistry.opencmis.commons.definitions.MutableSecondaryTypeDefinition) MutableItemTypeDefinition(org.apache.chemistry.opencmis.commons.definitions.MutableItemTypeDefinition)

Example 3 with TypeDefinitionContainer

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

the class CMISRepositoryService method getTypeDefinitionContainer.

private TypeDefinitionContainer getTypeDefinitionContainer(final TypeDefinition typeDefinition, final Boolean includePropertyDefinitions) {
    final TypeDefinitionContainerImpl result = new TypeDefinitionContainerImpl();
    final List<TypeDefinitionContainer> list = new LinkedList<>();
    result.setTypeDefinition(typeDefinition);
    result.setChildren(list);
    final String typeId = typeDefinition.getId();
    final BaseTypeId baseTypeId = getBaseTypeId(typeId);
    if (baseTypeId != null) {
        for (final TypeDefinition child : getBaseTypeChildren(baseTypeId, includePropertyDefinitions)) {
            list.add(getTypeDefinitionContainer(child, includePropertyDefinitions));
        }
    } else {
        for (final TypeDefinition child : getTypeChildren(typeDefinition.getId(), includePropertyDefinitions)) {
            list.add(getTypeDefinitionContainer(child, includePropertyDefinitions));
        }
    }
    return result;
}
Also used : TypeDefinitionContainerImpl(org.apache.chemistry.opencmis.commons.impl.dataobjects.TypeDefinitionContainerImpl) BaseTypeId(org.apache.chemistry.opencmis.commons.enums.BaseTypeId) TypeDefinitionContainer(org.apache.chemistry.opencmis.commons.definitions.TypeDefinitionContainer) LinkedList(java.util.LinkedList) MutableTypeDefinition(org.apache.chemistry.opencmis.commons.definitions.MutableTypeDefinition) MutablePolicyTypeDefinition(org.apache.chemistry.opencmis.commons.definitions.MutablePolicyTypeDefinition) MutableRelationshipTypeDefinition(org.apache.chemistry.opencmis.commons.definitions.MutableRelationshipTypeDefinition) MutableFolderTypeDefinition(org.apache.chemistry.opencmis.commons.definitions.MutableFolderTypeDefinition) TypeDefinition(org.apache.chemistry.opencmis.commons.definitions.TypeDefinition) MutableDocumentTypeDefinition(org.apache.chemistry.opencmis.commons.definitions.MutableDocumentTypeDefinition) MutableSecondaryTypeDefinition(org.apache.chemistry.opencmis.commons.definitions.MutableSecondaryTypeDefinition) MutableItemTypeDefinition(org.apache.chemistry.opencmis.commons.definitions.MutableItemTypeDefinition)

Aggregations

TypeDefinitionContainer (org.apache.chemistry.opencmis.commons.definitions.TypeDefinitionContainer)3 LinkedList (java.util.LinkedList)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 MutableTypeDefinition (org.apache.chemistry.opencmis.commons.definitions.MutableTypeDefinition)2 TypeDefinition (org.apache.chemistry.opencmis.commons.definitions.TypeDefinition)2 BaseTypeId (org.apache.chemistry.opencmis.commons.enums.BaseTypeId)2 BigInteger (java.math.BigInteger)1 DateTimeFormat (org.apache.chemistry.opencmis.commons.enums.DateTimeFormat)1 CmisObjectNotFoundException (org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException)1 CmisRuntimeException (org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException)1 TypeDefinitionContainerImpl (org.apache.chemistry.opencmis.commons.impl.dataobjects.TypeDefinitionContainerImpl)1 JSONArray (org.apache.chemistry.opencmis.commons.impl.json.JSONArray)1