Search in sources :

Example 1 with CMISInfo

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;
}
Also used : CMISInfo(org.structr.cmis.CMISInfo) BaseTypeId(org.apache.chemistry.opencmis.commons.enums.BaseTypeId)

Example 2 with CMISInfo

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;
}
Also used : App(org.structr.core.app.App) StructrApp(org.structr.core.app.StructrApp) SchemaNode(org.structr.core.entity.SchemaNode) Tx(org.structr.core.graph.Tx) FrameworkException(org.structr.common.error.FrameworkException) ConfigurationProvider(org.structr.schema.ConfigurationProvider) CMISInfo(org.structr.cmis.CMISInfo) Folder(org.structr.web.entity.Folder) File(org.structr.web.entity.File) 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 CMISInfo

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;
}
Also used : MutableTypeDefinition(org.apache.chemistry.opencmis.commons.definitions.MutableTypeDefinition) CMISInfo(org.structr.cmis.CMISInfo) BaseTypeId(org.apache.chemistry.opencmis.commons.enums.BaseTypeId) MutablePropertyDefinition(org.apache.chemistry.opencmis.commons.definitions.MutablePropertyDefinition) GraphObject(org.structr.core.GraphObject) PropertyKey(org.structr.core.property.PropertyKey)

Aggregations

CMISInfo (org.structr.cmis.CMISInfo)3 MutableTypeDefinition (org.apache.chemistry.opencmis.commons.definitions.MutableTypeDefinition)2 BaseTypeId (org.apache.chemistry.opencmis.commons.enums.BaseTypeId)2 LinkedList (java.util.LinkedList)1 MutableDocumentTypeDefinition (org.apache.chemistry.opencmis.commons.definitions.MutableDocumentTypeDefinition)1 MutableFolderTypeDefinition (org.apache.chemistry.opencmis.commons.definitions.MutableFolderTypeDefinition)1 MutableItemTypeDefinition (org.apache.chemistry.opencmis.commons.definitions.MutableItemTypeDefinition)1 MutablePolicyTypeDefinition (org.apache.chemistry.opencmis.commons.definitions.MutablePolicyTypeDefinition)1 MutablePropertyDefinition (org.apache.chemistry.opencmis.commons.definitions.MutablePropertyDefinition)1 MutableRelationshipTypeDefinition (org.apache.chemistry.opencmis.commons.definitions.MutableRelationshipTypeDefinition)1 MutableSecondaryTypeDefinition (org.apache.chemistry.opencmis.commons.definitions.MutableSecondaryTypeDefinition)1 TypeDefinition (org.apache.chemistry.opencmis.commons.definitions.TypeDefinition)1 FrameworkException (org.structr.common.error.FrameworkException)1 GraphObject (org.structr.core.GraphObject)1 App (org.structr.core.app.App)1 StructrApp (org.structr.core.app.StructrApp)1 SchemaNode (org.structr.core.entity.SchemaNode)1 Tx (org.structr.core.graph.Tx)1 PropertyKey (org.structr.core.property.PropertyKey)1 ConfigurationProvider (org.structr.schema.ConfigurationProvider)1