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;
}
Aggregations