use of org.structr.cmis.CMISInfo in project structr by structr.
the class CMISObjectWrapper method wrap.
// ----- public static methods -----
public static CMISObjectWrapper wrap(final GraphObject source, final String propertyFilter, final Boolean includeAllowableActions) throws FrameworkException {
CMISObjectWrapper wrapper = null;
if (source != null) {
final CMISInfo cmisInfo = source.getCMISInfo();
if (cmisInfo != null) {
final BaseTypeId baseTypeId = cmisInfo.getBaseTypeId();
if (baseTypeId != null) {
switch(baseTypeId) {
case CMIS_DOCUMENT:
wrapper = new CMISDocumentWrapper(propertyFilter, includeAllowableActions);
wrapper.initializeFrom(cmisInfo.getDocumentInfo());
break;
case CMIS_FOLDER:
wrapper = new CMISFolderWrapper(propertyFilter, includeAllowableActions);
wrapper.initializeFrom(cmisInfo.getFolderInfo());
break;
case CMIS_ITEM:
wrapper = new CMISItemWrapper(propertyFilter, includeAllowableActions);
wrapper.initializeFrom(cmisInfo.getItemInfo());
break;
case CMIS_POLICY:
wrapper = new CMISPolicyWrapper(propertyFilter, includeAllowableActions);
wrapper.initializeFrom(cmisInfo.getPolicyInfo());
break;
case CMIS_RELATIONSHIP:
wrapper = new CMISRelationshipWrapper(propertyFilter, includeAllowableActions);
wrapper.initializeFrom(cmisInfo.getRelationshipInfo());
break;
case CMIS_SECONDARY:
wrapper = new CMISSecondaryWrapper(propertyFilter, includeAllowableActions);
wrapper.initializeFrom(cmisInfo.getSecondaryInfo());
break;
}
}
}
}
return wrapper;
}
use of org.structr.cmis.CMISInfo in project structr by structr.
the class CMISRepositoryService method getBaseTypeChildren.
private List<TypeDefinition> getBaseTypeChildren(final BaseTypeId baseTypeId, final Boolean includePropertyDefinitions) {
final ConfigurationProvider config = StructrApp.getConfiguration();
final List<TypeDefinition> result = new LinkedList<>();
final App app = StructrApp.getInstance();
// static definition of base type children, add new types here!
switch(baseTypeId) {
case CMIS_DOCUMENT:
result.add(extendTypeDefinition(File.class, includePropertyDefinitions));
break;
case CMIS_FOLDER:
result.add(extendTypeDefinition(Folder.class, includePropertyDefinitions));
break;
case CMIS_ITEM:
try (final Tx tx = app.tx()) {
for (final SchemaNode schemaNode : app.nodeQuery(SchemaNode.class).sort(AbstractNode.name).getAsList()) {
final Class type = config.getNodeEntityClass(schemaNode.getClassName());
if (type != null) {
final CMISInfo info = getCMISInfo(type);
if (info != null && baseTypeId.equals(info.getBaseTypeId())) {
final TypeDefinition extendedTypeDefinition = extendTypeDefinition(type, includePropertyDefinitions);
if (extendedTypeDefinition != null) {
result.add(extendedTypeDefinition);
}
}
}
}
tx.success();
} catch (final FrameworkException fex) {
logger.warn("", fex);
}
break;
}
return result;
}
use of org.structr.cmis.CMISInfo in project structr by structr.
the class CMISRepositoryService method extendTypeDefinition.
private MutableTypeDefinition extendTypeDefinition(final Class<? extends GraphObject> type, final Boolean includePropertyDefinitions) {
final String typeName = type.getSimpleName();
MutableTypeDefinition result = null;
try {
// instantiate class to obtain runtime CMIS information
final GraphObject obj = type.newInstance();
if (obj != null) {
final CMISInfo info = obj.getCMISInfo();
if (info != null) {
final BaseTypeId baseTypeId = info.getBaseTypeId();
if (baseTypeId != null) {
switch(baseTypeId) {
case CMIS_DOCUMENT:
result = getDocumentTypeDefinition(typeName, includePropertyDefinitions, false);
break;
case CMIS_FOLDER:
result = getFolderTypeDefinition(typeName, includePropertyDefinitions, false);
break;
case CMIS_ITEM:
result = getItemTypeDefinition(typeName, includePropertyDefinitions, false);
break;
case CMIS_POLICY:
result = getPolicyTypeDefinition(typeName, includePropertyDefinitions, false);
break;
case CMIS_RELATIONSHIP:
result = getRelationshipTypeDefinition(typeName, includePropertyDefinitions, false);
break;
case CMIS_SECONDARY:
result = getSecondaryTypeDefinition(typeName, includePropertyDefinitions, false);
break;
}
if (result != null) {
// initialize..
for (final PropertyKey key : StructrApp.getConfiguration().getPropertySet(type, PropertyView.All)) {
final MutablePropertyDefinition property = createProperty(type, key);
if (property != null) {
result.addPropertyDefinition(property);
}
}
}
}
}
}
} catch (final IllegalAccessException | InstantiationException iex) {
logger.warn("", iex);
}
return result;
}
Aggregations