Search in sources :

Example 1 with CmisVersion

use of org.apache.chemistry.opencmis.commons.enums.CmisVersion in project alfresco-repository by Alfresco.

the class CMISConnector method getRequestCmisVersion.

public CmisVersion getRequestCmisVersion() {
    CallContext callContext = AlfrescoCmisServiceCall.get();
    CmisVersion cmisVersion = (callContext != null ? callContext.getCmisVersion() : CmisVersion.CMIS_1_0);
    return cmisVersion;
}
Also used : CmisVersion(org.apache.chemistry.opencmis.commons.enums.CmisVersion) CallContext(org.apache.chemistry.opencmis.commons.server.CallContext)

Example 2 with CmisVersion

use of org.apache.chemistry.opencmis.commons.enums.CmisVersion in project alfresco-repository by Alfresco.

the class AlfrescoCmisServiceImpl method getRepositoryInfo.

@Override
public RepositoryInfo getRepositoryInfo(String repositoryId, ExtensionsData extension) {
    checkRepositoryId(repositoryId);
    CmisVersion cmisVersion = getContext().getCmisVersion();
    return connector.getRepositoryInfo(cmisVersion);
}
Also used : CmisVersion(org.apache.chemistry.opencmis.commons.enums.CmisVersion)

Example 3 with CmisVersion

use of org.apache.chemistry.opencmis.commons.enums.CmisVersion in project alfresco-repository by Alfresco.

the class CMISConnector method query.

@SuppressWarnings("unchecked")
public ObjectList query(String statement, Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter, BigInteger maxItems, BigInteger skipCount) /*, CmisVersion cmisVersion*/
{
    // prepare results
    ObjectListImpl result = new ObjectListImpl();
    result.setObjects(new ArrayList<ObjectData>());
    // prepare query
    CMISQueryOptions options = new CMISQueryOptions(statement, getRootStoreRef());
    CmisVersion cmisVersion = getRequestCmisVersion();
    options.setCmisVersion(cmisVersion);
    options.setQueryMode(CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS);
    int skip = 0;
    if ((skipCount != null) && (skipCount.intValue() >= 0)) {
        skip = skipCount.intValue();
        options.setSkipCount(skip);
    }
    if ((maxItems != null) && (maxItems.intValue() >= 0)) {
        options.setMaxItems(maxItems.intValue());
    }
    boolean fetchObject = includeAllowableActions || (includeRelationships != IncludeRelationships.NONE) || (!RENDITION_NONE.equals(renditionFilter));
    // query
    CMISResultSet rs = getOpenCMISQueryService().query(options);
    try {
        CMISResultSetColumn[] columns = rs.getMetaData().getColumns();
        for (CMISResultSetRow row : rs) {
            NodeRef nodeRef = row.getNodeRef();
            if (!nodeService.exists(nodeRef) || filter(nodeRef)) {
                continue;
            }
            TypeDefinitionWrapper type = getType(nodeRef);
            if (type == null) {
                continue;
            }
            ObjectDataImpl hit = new ObjectDataImpl();
            PropertiesImpl properties = new PropertiesImpl();
            hit.setProperties(properties);
            Map<String, Serializable> values = row.getValues();
            for (CMISResultSetColumn column : columns) {
                AbstractPropertyData<?> property = getProperty(column.getCMISDataType(), column.getCMISPropertyDefinition(), values.get(column.getName()));
                property.setQueryName(column.getName());
                properties.addProperty(property);
            }
            if (fetchObject) {
                // set allowable actions
                if (includeAllowableActions) {
                    CMISNodeInfoImpl nodeInfo = createNodeInfo(nodeRef);
                    if (!nodeInfo.getObjectVariant().equals(CMISObjectVariant.NOT_EXISTING)) {
                        hit.setAllowableActions(getAllowableActions(nodeInfo));
                    }
                }
                // set relationships
                if (includeRelationships != IncludeRelationships.NONE) {
                    hit.setRelationships(getRelationships(nodeRef, includeRelationships));
                }
                // set renditions
                if (!RENDITION_NONE.equals(renditionFilter)) {
                    List<RenditionData> renditions = getRenditions(nodeRef, renditionFilter, null, null);
                    if ((renditions != null) && (!renditions.isEmpty())) {
                        hit.setRenditions(renditions);
                    } else {
                        hit.setRenditions(Collections.EMPTY_LIST);
                    }
                }
            }
            result.getObjects().add(hit);
        }
        long numberFound = rs.getNumberFound();
        if (numberFound != -1) {
            result.setNumItems(BigInteger.valueOf(numberFound));
        }
        result.setHasMoreItems(rs.hasMore());
    } finally {
        rs.close();
    }
    return result;
}
Also used : CmisVersion(org.apache.chemistry.opencmis.commons.enums.CmisVersion) Serializable(java.io.Serializable) PropertiesImpl(org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertiesImpl) ItemTypeDefinitionWrapper(org.alfresco.opencmis.dictionary.ItemTypeDefinitionWrapper) TypeDefinitionWrapper(org.alfresco.opencmis.dictionary.TypeDefinitionWrapper) DocumentTypeDefinitionWrapper(org.alfresco.opencmis.dictionary.DocumentTypeDefinitionWrapper) ObjectData(org.apache.chemistry.opencmis.commons.data.ObjectData) ObjectListImpl(org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectListImpl) CMISQueryOptions(org.alfresco.opencmis.search.CMISQueryOptions) PropertyString(org.apache.chemistry.opencmis.commons.data.PropertyString) CMISResultSet(org.alfresco.opencmis.search.CMISResultSet) CMISResultSetRow(org.alfresco.opencmis.search.CMISResultSetRow) ObjectDataImpl(org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectDataImpl) CMISResultSetColumn(org.alfresco.opencmis.search.CMISResultSetColumn) NodeRef(org.alfresco.service.cmr.repository.NodeRef) RenditionData(org.apache.chemistry.opencmis.commons.data.RenditionData)

Aggregations

CmisVersion (org.apache.chemistry.opencmis.commons.enums.CmisVersion)3 Serializable (java.io.Serializable)1 DocumentTypeDefinitionWrapper (org.alfresco.opencmis.dictionary.DocumentTypeDefinitionWrapper)1 ItemTypeDefinitionWrapper (org.alfresco.opencmis.dictionary.ItemTypeDefinitionWrapper)1 TypeDefinitionWrapper (org.alfresco.opencmis.dictionary.TypeDefinitionWrapper)1 CMISQueryOptions (org.alfresco.opencmis.search.CMISQueryOptions)1 CMISResultSet (org.alfresco.opencmis.search.CMISResultSet)1 CMISResultSetColumn (org.alfresco.opencmis.search.CMISResultSetColumn)1 CMISResultSetRow (org.alfresco.opencmis.search.CMISResultSetRow)1 NodeRef (org.alfresco.service.cmr.repository.NodeRef)1 ObjectData (org.apache.chemistry.opencmis.commons.data.ObjectData)1 PropertyString (org.apache.chemistry.opencmis.commons.data.PropertyString)1 RenditionData (org.apache.chemistry.opencmis.commons.data.RenditionData)1 ObjectDataImpl (org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectDataImpl)1 ObjectListImpl (org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectListImpl)1 PropertiesImpl (org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertiesImpl)1 CallContext (org.apache.chemistry.opencmis.commons.server.CallContext)1