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