Search in sources :

Example 1 with TypeDefinitionListImpl

use of org.apache.chemistry.opencmis.commons.impl.dataobjects.TypeDefinitionListImpl in project alfresco-repository by Alfresco.

the class AlfrescoCmisServiceImpl method getTypeChildren.

@Override
public TypeDefinitionList getTypeChildren(String repositoryId, String typeId, Boolean includePropertyDefinitions, BigInteger maxItems, BigInteger skipCount, ExtensionsData extension) {
    checkRepositoryId(repositoryId);
    // convert BigIntegers to int
    int max = (maxItems == null ? Integer.MAX_VALUE : maxItems.intValue());
    int skip = (skipCount == null || skipCount.intValue() < 0 ? 0 : skipCount.intValue());
    // set up the result
    TypeDefinitionListImpl result = new TypeDefinitionListImpl();
    List<TypeDefinition> list = new ArrayList<TypeDefinition>();
    result.setList(list);
    // get the types from the dictionary
    List<TypeDefinitionWrapper> childrenList;
    if (typeId == null) {
        childrenList = connector.getOpenCMISDictionaryService().getBaseTypes(true);
    } else {
        TypeDefinitionWrapper tdw = connector.getOpenCMISDictionaryService().findType(typeId);
        if (tdw == null) {
            throw new CmisObjectNotFoundException("Type '" + typeId + "' is unknown!");
        }
        childrenList = connector.getOpenCMISDictionaryService().getChildren(typeId);
    // childrenList = tdw.getChildren();
    }
    // create result
    if (max > 0) {
        int lastIndex = (max + skip > childrenList.size() ? childrenList.size() : max + skip) - 1;
        for (int i = skip; i <= lastIndex; i++) {
            list.add(childrenList.get(i).getTypeDefinition(includePropertyDefinitions));
        }
    }
    result.setHasMoreItems(childrenList.size() - skip > result.getList().size());
    result.setNumItems(BigInteger.valueOf(childrenList.size()));
    return result;
}
Also used : CmisObjectNotFoundException(org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException) TypeDefinitionWrapper(org.alfresco.opencmis.dictionary.TypeDefinitionWrapper) ArrayList(java.util.ArrayList) TypeDefinitionListImpl(org.apache.chemistry.opencmis.commons.impl.dataobjects.TypeDefinitionListImpl) DocumentTypeDefinition(org.apache.chemistry.opencmis.commons.definitions.DocumentTypeDefinition) TypeDefinition(org.apache.chemistry.opencmis.commons.definitions.TypeDefinition)

Aggregations

ArrayList (java.util.ArrayList)1 TypeDefinitionWrapper (org.alfresco.opencmis.dictionary.TypeDefinitionWrapper)1 DocumentTypeDefinition (org.apache.chemistry.opencmis.commons.definitions.DocumentTypeDefinition)1 TypeDefinition (org.apache.chemistry.opencmis.commons.definitions.TypeDefinition)1 CmisObjectNotFoundException (org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException)1 TypeDefinitionListImpl (org.apache.chemistry.opencmis.commons.impl.dataobjects.TypeDefinitionListImpl)1