org.apache.chemistry.opencmis.commons.enums.CmisVersion Java Examples

The following examples show how to use org.apache.chemistry.opencmis.commons.enums.CmisVersion. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CmisUtils.java    From iaf with Apache License 2.0 6 votes vote down vote up
public static RepositoryInfo xml2repositoryInfo(Element cmisResult) {
	RepositoryInfoImpl repositoryInfo = new RepositoryInfoImpl();

	repositoryInfo.setCmisVersion(CmisVersion.fromValue(cmisResult.getAttribute("cmisVersion")));
	repositoryInfo.setCmisVersionSupported(cmisResult.getAttribute("cmisVersionSupported"));
	repositoryInfo.setDescription(cmisResult.getAttribute("description"));
	repositoryInfo.setId(cmisResult.getAttribute("id"));
	repositoryInfo.setLatestChangeLogToken(cmisResult.getAttribute("latestChangeLogToken"));
	repositoryInfo.setName(cmisResult.getAttribute("name"));
	repositoryInfo.setPrincipalAnonymous(cmisResult.getAttribute("principalIdAnonymous"));
	repositoryInfo.setPrincipalAnyone(cmisResult.getAttribute("principalIdAnyone"));
	repositoryInfo.setProductName(cmisResult.getAttribute("productName"));
	repositoryInfo.setProductVersion(cmisResult.getAttribute("productVersion"));
	repositoryInfo.setRootFolder(cmisResult.getAttribute("rootFolderId"));
	repositoryInfo.setThinClientUri(cmisResult.getAttribute("thinClientUri"));
	repositoryInfo.setVendorName(cmisResult.getAttribute("vendorName"));
	repositoryInfo.setChangesIncomplete(CmisUtils.parseBooleanAttr(cmisResult, "changesIncomplete"));
	repositoryInfo.setAclCapabilities(CmisUtils.xml2aclCapabilities(cmisResult));
	repositoryInfo.setCapabilities(CmisUtils.xml2capabilities(cmisResult));
	repositoryInfo.setChangesOnType(CmisUtils.xml2changesOnType(cmisResult));

	return repositoryInfo;
}
 
Example #2
Source File: CMISTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
private <T extends Object> T withCmisService(CmisServiceCallback<T> callback, CmisVersion cmisVersion)
{
    CmisService cmisService = null;

    try
    {
        CallContext context = new SimpleCallContext("admin", "admin", cmisVersion);
        cmisService = factory.getService(context);
        T ret = callback.execute(cmisService);
        return ret;
    }
    finally
    {
        if(cmisService != null)
        {
            cmisService.close();
        }
    }
}
 
Example #3
Source File: AlfrescoSolrDataModel.java    From SearchServices with GNU Lesser General Public License v3.0 6 votes vote down vote up
public Query getCMISQuery(CMISQueryMode mode, Pair<SearchParameters, Boolean> searchParametersAndFilter, SolrQueryRequest req, org.alfresco.repo.search.impl.querymodel.Query queryModelQuery, CmisVersion cmisVersion, String alternativeDictionary) throws ParseException
{
    SearchParameters searchParameters = searchParametersAndFilter.getFirst();
    Boolean isFilter = searchParametersAndFilter.getSecond();

    CmisFunctionEvaluationContext functionContext = getCMISFunctionEvaluationContext(mode, cmisVersion, alternativeDictionary);

    Set<String> selectorGroup = queryModelQuery.getSource().getSelectorGroups(functionContext).get(0);

    LuceneQueryBuilderContext<Query, Sort, ParseException> luceneContext = getLuceneQueryBuilderContext(searchParameters, req, alternativeDictionary, FTSQueryParser.RerankPhase.SINGLE_PASS);
    @SuppressWarnings("unchecked")
    LuceneQueryBuilder<Query, Sort, ParseException> builder = (LuceneQueryBuilder<Query, Sort, ParseException>) queryModelQuery;
    org.apache.lucene.search.Query luceneQuery = builder.buildQuery(selectorGroup, luceneContext, functionContext);

    return new ContextAwareQuery(luceneQuery, Boolean.TRUE.equals(isFilter) ? null : searchParameters);
}
 
Example #4
Source File: CMISServletDispatcher.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public String getInitParameter(String arg0)
{
	if(arg0.equals(CmisAtomPubServlet.PARAM_CALL_CONTEXT_HANDLER))
	{
		return PublicApiCallContextHandler.class.getName();
	}
	else if(arg0.equals(CmisAtomPubServlet.PARAM_CMIS_VERSION))
	{
		return (cmisVersion != null ? cmisVersion.value() : CmisVersion.CMIS_1_0.value());
	}
	return null;
}
 
Example #5
Source File: CMISTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void assertVersions(final NodeRef nodeRef, final String expectedVersionLabel, final VersionType expectedVersionType)
{
    transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<List<Void>>()
    {
        @Override
        public List<Void> execute() throws Throwable
        {
            assertTrue("Node should be versionable", nodeService.hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE));
            
            Version version = versionService.getCurrentVersion(nodeRef);
            
            assertNotNull(version);
            assertEquals(expectedVersionLabel, version.getVersionLabel());
            assertEquals(expectedVersionType, version.getVersionType());
            
            return null;
        }
    });
    
    withCmisService(new CmisServiceCallback<Void>()
    {
        @Override
        public Void execute(CmisService cmisService)
        {
            String repositoryId = cmisService.getRepositoryInfos(null).get(0).getId();
            
            ObjectData data = 
                cmisService.getObjectOfLatestVersion(repositoryId, nodeRef.toString(), null, Boolean.FALSE, null, null, null, null, null, null, null);
            
            assertNotNull(data);
            
            PropertyData<?> prop = data.getProperties().getProperties().get(PropertyIds.VERSION_LABEL);
            Object versionLabelCmisValue = prop.getValues().get(0);
            
            assertEquals(expectedVersionLabel, versionLabelCmisValue);
            
            return null;
        }
    }, CmisVersion.CMIS_1_1);
}
 
Example #6
Source File: CMISMapping.java    From alfresco-data-model with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Is this a valid CMIS policy type?
 * 
 * @param typeQName QName
 * @return boolean
 */
public boolean isValidCmisPolicy(QName typeQName)
{        if (typeQName == null)
    {
        return false;
    }
    if (typeQName.equals(POLICY_QNAME))
    {
        return true;
    }
    
    if(cmisVersion.equals(CmisVersion.CMIS_1_0))
    {
    	if (typeQName.equals(ASPECTS_QNAME))
    	{
    		return true;
    	}

    	AspectDefinition aspectDef = dictionaryService.getAspect(typeQName);
    	if (aspectDef == null)
    	{
    		return false;
    	}

    	// Anything derived from the aspects here would at some point have to linked up with an invalid parent so exclude these aspects 
    	// AND any that are derived from them.
    	if (       dictionaryService.isSubClass(aspectDef.getName(), ContentModel.ASPECT_VERSIONABLE)
    			|| dictionaryService.isSubClass(aspectDef.getName(), ContentModel.ASPECT_AUDITABLE)
    			|| dictionaryService.isSubClass(aspectDef.getName(), ContentModel.ASPECT_REFERENCEABLE))
    	{
    		return false;
    	}
    	return true;
    }
    else
    {
    	return false;
    }
}
 
Example #7
Source File: CMISStrictDictionaryService.java    From alfresco-data-model with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Create Type Definitions
 * 
 * @param classQName QName
 */
private AbstractTypeDefinitionWrapper createTypeDef(QName classQName)
{
	AbstractTypeDefinitionWrapper objectTypeDef = null;

    // skip items that are remapped to CMIS model
    if(!cmisMapping.isRemappedType(classQName))
    {
     // create appropriate kind of type definition
     ClassDefinition classDef = dictionaryService.getClass(classQName);
     String typeId = null;
     if (cmisMapping.isValidCmisDocument(classQName))
     {
         typeId = cmisMapping.getCmisTypeId(BaseTypeId.CMIS_DOCUMENT, classQName);
         objectTypeDef = new DocumentTypeDefinitionWrapper(cmisMapping, accessorMapping, luceneBuilderMapping, typeId, dictionaryService, classDef);
     }
     else if (cmisMapping.isValidCmisFolder(classQName))
     {
         typeId = cmisMapping.getCmisTypeId(BaseTypeId.CMIS_FOLDER, classQName);
         objectTypeDef = new FolderTypeDefintionWrapper(cmisMapping, accessorMapping, luceneBuilderMapping, typeId, dictionaryService, classDef);
     }
     else if (cmisMapping.getCmisVersion().equals(CmisVersion.CMIS_1_1) && cmisMapping.isValidCmisSecondaryType(classQName))
     {
         typeId = cmisMapping.getCmisTypeId(BaseTypeId.CMIS_SECONDARY, classQName);
         objectTypeDef = new SecondaryTypeDefinitionWrapper(cmisMapping, accessorMapping, luceneBuilderMapping, typeId, dictionaryService, classDef);
     }
     else if (cmisMapping.isValidCmisPolicy(classQName))
     {
         typeId = cmisMapping.getCmisTypeId(BaseTypeId.CMIS_POLICY, classQName);
         objectTypeDef = new PolicyTypeDefintionWrapper(cmisMapping, accessorMapping, luceneBuilderMapping, typeId, dictionaryService, classDef);
     }
     else if (cmisMapping.isValidCmisItem(classQName))
     {
         typeId = cmisMapping.getCmisTypeId(BaseTypeId.CMIS_ITEM, classQName);
         objectTypeDef = new ItemTypeDefinitionWrapper(cmisMapping, accessorMapping, luceneBuilderMapping, typeId, dictionaryService, classDef);
     }
    }

    return objectTypeDef;
}
 
Example #8
Source File: AlfrescoClientDataModelServicesFactory.java    From SearchServices with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Constructs a dictionary by default.
 * 
 * @param qnameFilter QNameFilter
 * @param namespaceDAO NamespaceDAO
 * @param dictionaryService DictionaryComponent
 * @param dictionaryDAO DictionaryDAO
 * @return Map
 */
public static Map<DictionaryKey,CMISAbstractDictionaryService> constructDictionaries(QNameFilter qnameFilter, NamespaceDAO namespaceDAO,
		DictionaryComponent dictionaryService, DictionaryDAO dictionaryDAO) 
{
    DictionaryNamespaceComponent namespaceService = new DictionaryNamespaceComponent();
    namespaceService.setNamespaceDAO(namespaceDAO);

    CMISMapping cmisMapping = new CMISMapping();
    cmisMapping.setCmisVersion(CmisVersion.CMIS_1_0);
    cmisMapping.setFilter(qnameFilter);
    cmisMapping.setNamespaceService(namespaceService);
    cmisMapping.setDictionaryService(dictionaryService);
    cmisMapping.afterPropertiesSet();

    CMISMapping cmisMapping11 = new CMISMapping();
    cmisMapping11.setCmisVersion(CmisVersion.CMIS_1_1);
    cmisMapping11.setFilter(qnameFilter);
    cmisMapping11.setNamespaceService(namespaceService);
    cmisMapping11.setDictionaryService(dictionaryService);
    cmisMapping11.afterPropertiesSet();

    Map<DictionaryKey,CMISAbstractDictionaryService> dictionaries = new HashMap<DictionaryKey,CMISAbstractDictionaryService>();

    DictionaryKey key = new DictionaryKey(CmisVersion.CMIS_1_0, CMISStrictDictionaryService.DEFAULT);
    dictionaries.put(key, newInstance(cmisMapping, dictionaryService, dictionaryDAO));
    CMISMapping mappingWithExclusions = newInstanceOfExcludedCMISMapping(cmisMapping, qnameFilter);
    key = new DictionaryKey(CmisVersion.CMIS_1_0, DICTIONARY_FILTERED_WITH_EXCLUSIONS);
    dictionaries.put(key, newInstance(mappingWithExclusions, dictionaryService, dictionaryDAO));
    
    key = new DictionaryKey(CmisVersion.CMIS_1_1, CMISStrictDictionaryService.DEFAULT);
    dictionaries.put(key, newInstance(cmisMapping11, dictionaryService, dictionaryDAO));
    CMISMapping mappingWithExclusions11 = newInstanceOfExcludedCMISMapping(cmisMapping11, qnameFilter);
    key = new DictionaryKey(CmisVersion.CMIS_1_1, DICTIONARY_FILTERED_WITH_EXCLUSIONS);
    dictionaries.put(key, newInstance(mappingWithExclusions11, dictionaryService, dictionaryDAO));

    return dictionaries;
}
 
Example #9
Source File: AlfrescoSolrDataModel.java    From SearchServices with GNU Lesser General Public License v3.0 5 votes vote down vote up
public org.alfresco.repo.search.impl.querymodel.Query parseCMISQueryToAlfrescoAbstractQuery(CMISQueryMode mode, SearchParameters searchParameters,
                                                                                            SolrQueryRequest req, String alternativeDictionary, CmisVersion cmisVersion)
{
    // convert search parameters to cmis query options
    // TODO: how to handle store ref
    CMISQueryOptions options = new CMISQueryOptions(searchParameters.getQuery(), StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
    options.setQueryMode(CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS);
    options.setDefaultFieldName(searchParameters.getDefaultFieldName());
    // TODO: options.setDefaultFTSConnective()
    // TODO: options.setDefaultFTSFieldConnective()
    options.setIncludeInTransactionData(!searchParameters.excludeDataInTheCurrentTransaction());
    options.setLocales(searchParameters.getLocales());
    options.setMlAnalaysisMode(searchParameters.getMlAnalaysisMode());
    options.setQueryParameterDefinitions(searchParameters.getQueryParameterDefinitions());
    for(String name : searchParameters.getQueryTemplates().keySet())
    {
        String template = searchParameters.getQueryTemplates().get(name);
        options.addQueryTemplate(name, template);
    }

    // parse cmis syntax
    CapabilityJoin joinSupport = (mode == CMISQueryMode.CMS_STRICT) ? CapabilityJoin.NONE : CapabilityJoin.INNERANDOUTER;
    CmisFunctionEvaluationContext functionContext = getCMISFunctionEvaluationContext(mode, cmisVersion, alternativeDictionary);

    CMISDictionaryService cmisDictionary = getCMISDictionary(alternativeDictionary, cmisVersion);

    CMISQueryParser parser = new CMISQueryParser(options, cmisDictionary, joinSupport);
    org.alfresco.repo.search.impl.querymodel.Query queryModelQuery = parser.parse(new LuceneQueryModelFactory<Query, Sort, SyntaxError>(), functionContext);

    if (queryModelQuery.getSource() != null)
    {
        List<Set<String>> selectorGroups = queryModelQuery.getSource().getSelectorGroups(functionContext);
        if (selectorGroups.size() == 0)
        {
            throw new UnsupportedOperationException("No selectors");
        }
    }
    return queryModelQuery;
}
 
Example #10
Source File: AlfrescoSolrDataModel.java    From SearchServices with GNU Lesser General Public License v3.0 5 votes vote down vote up
public CmisFunctionEvaluationContext getCMISFunctionEvaluationContext(CMISQueryMode mode, CmisVersion cmisVersion, String alternativeDictionary)
{
    BaseTypeId[] validScopes = (mode == CMISQueryMode.CMS_STRICT) ? CmisFunctionEvaluationContext.STRICT_SCOPES : CmisFunctionEvaluationContext.ALFRESCO_SCOPES;
    CmisFunctionEvaluationContext functionContext = new CmisFunctionEvaluationContext();
    functionContext.setCmisDictionaryService(getCMISDictionary(alternativeDictionary, cmisVersion));
    functionContext.setValidScopes(validScopes);
    return functionContext;
}
 
Example #11
Source File: CMISConnector.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public CMISQueryService getOpenCMISQueryService()
{
    CmisVersion cmisVersion = getRequestCmisVersion();
    if(cmisVersion.equals(CmisVersion.CMIS_1_0))
    {
        return cmisQueryService;
    }
    else
    {
        return cmisQueryService11;
    }
}
 
Example #12
Source File: CmisTypeDefinitionFactoryBean.java    From spring-content with Apache License 2.0 5 votes vote down vote up
@Override
public TypeDefinition getObject() throws Exception {
	CmisDocument cmisDocumentMetadata = entityClass.getAnnotation(CmisDocument.class);
	CmisFolder cmisFolderMetadata = entityClass.getAnnotation(CmisFolder.class);
	if (cmisDocumentMetadata != null) {
		return createDocumentTypeDefinition(entityClass, repoClass, storeClass, cmisDocumentMetadata, CmisVersion.CMIS_1_1, null);
	} else if (cmisFolderMetadata != null) {
		return createFolderTypeDefinition(entityClass, repoClass, cmisFolderMetadata, CmisVersion.CMIS_1_1, null);
	}
	throw new IllegalStateException(format("Unknown type definition: %s", entityClass));
}
 
Example #13
Source File: CmisTypeDefinitionFactoryBean.java    From spring-content with Apache License 2.0 5 votes vote down vote up
public MutableDocumentTypeDefinition createDocumentTypeDefinition(Class<?> entityClass, Class<?> repoClass, Class<?> storeClass, CmisDocument metadata, CmisVersion cmisVersion, String parentId) {
	MutableDocumentTypeDefinition documentType = new DocumentTypeDefinitionImpl();
	documentType.setBaseTypeId(BaseTypeId.CMIS_DOCUMENT);
	documentType.setParentTypeId(parentId);
	documentType.setIsControllableAcl(false);
	documentType.setIsControllablePolicy(false);
	documentType.setIsCreatable(repoClass != null);
	documentType.setDescription("Document");
	documentType.setDisplayName("Document");
	documentType.setIsFileable(isFileable(repoClass));
	documentType.setIsFulltextIndexed(isFulltextIndexed(repoClass));
	documentType.setIsIncludedInSupertypeQuery(true);
	documentType.setLocalName("Document");
	documentType.setLocalNamespace("");
	documentType.setIsQueryable(false);
	documentType.setQueryName("cmis:document");
	documentType.setId(BaseTypeId.CMIS_DOCUMENT.value());
	if (cmisVersion != CmisVersion.CMIS_1_0) {
		TypeMutabilityImpl typeMutability = new TypeMutabilityImpl();
		typeMutability.setCanCreate(false);
		typeMutability.setCanUpdate(false);
		typeMutability.setCanDelete(false);
		documentType.setTypeMutability(typeMutability);
	}

	documentType.setIsVersionable(isVersionable(repoClass));
	documentType.setContentStreamAllowed((storeClass != null) ? ContentStreamAllowed.ALLOWED : ContentStreamAllowed.NOTALLOWED);

	this.addBasePropertyDefinitions(documentType, entityClass, cmisVersion, parentId != null);
	this.addDocumentPropertyDefinitions(documentType, repoClass, storeClass, cmisVersion, parentId != null);
	return documentType;
}
 
Example #14
Source File: CmisTypeDefinitionFactoryBean.java    From spring-content with Apache License 2.0 5 votes vote down vote up
protected void addDocumentPropertyDefinitions(MutableDocumentTypeDefinition type, Class<?> repoClazz, Class<?> storeClazz, CmisVersion cmisVersion, boolean inherited) {

		if (storeClass != null) {
			type.addPropertyDefinition(this
					.createPropertyDefinition("cmis:contentStreamLength", "Content Stream Length", "Content Stream Length", PropertyType.INTEGER, Cardinality.SINGLE, Updatability.READONLY, inherited, false, false, false));
			type.addPropertyDefinition(this
					.createPropertyDefinition("cmis:contentStreamMimeType", "MIME Type", "MIME Type", PropertyType.STRING, Cardinality.SINGLE, Updatability.READONLY, inherited, false, false, false));
			type.addPropertyDefinition(this
					.createPropertyDefinition("cmis:contentStreamFileName", "Filename", "Filename", PropertyType.STRING, Cardinality.SINGLE, Updatability.READONLY, inherited, false, false, false));
			type.addPropertyDefinition(this
					.createPropertyDefinition("cmis:contentStreamId", "Content Stream Id", "Content Stream Id", PropertyType.ID, Cardinality.SINGLE, Updatability.READONLY, inherited, false, false, false));
		}

		if (isVersionable(repoClass)) {
			type.addPropertyDefinition(this
					.createPropertyDefinition("cmis:isImmutable", "Is Immutable", "Is Immutable", PropertyType.BOOLEAN, Cardinality.SINGLE, Updatability.READONLY, inherited, false, false, false));
			type.addPropertyDefinition(this
					.createPropertyDefinition("cmis:isLatestVersion", "Is Latest Version", "Is Latest Version", PropertyType.BOOLEAN, Cardinality.SINGLE, Updatability.READONLY, inherited, false, false, false));
			type.addPropertyDefinition(this
					.createPropertyDefinition("cmis:isMajorVersion", "Is Major Version", "Is Major Version", PropertyType.BOOLEAN, Cardinality.SINGLE, Updatability.READONLY, inherited, false, false, false));
			type.addPropertyDefinition(this
					.createPropertyDefinition("cmis:isLatestMajorVersion", "Is Latest Major Version", "Is Latest Major Version", PropertyType.BOOLEAN, Cardinality.SINGLE, Updatability.READONLY, inherited, false, false, false));
			if (cmisVersion != CmisVersion.CMIS_1_0) {
				type.addPropertyDefinition(this
						.createPropertyDefinition("cmis:isPrivateWorkingCopy", "Is Private Working Copy", "Is Private Working Copy", PropertyType.BOOLEAN, Cardinality.SINGLE, Updatability.READONLY, inherited, false, true, false));
			}
			type.addPropertyDefinition(this
					.createPropertyDefinition("cmis:versionLabel", "Version Label", "Version Label", PropertyType.STRING, Cardinality.SINGLE, Updatability.READONLY, inherited, false, true, false));
			type.addPropertyDefinition(this
					.createPropertyDefinition("cmis:versionSeriesId", "Version Series Id", "Version Series Id", PropertyType.ID, Cardinality.SINGLE, Updatability.READONLY, inherited, false, true, false));
			type.addPropertyDefinition(this
					.createPropertyDefinition("cmis:isVersionSeriesCheckedOut", "Is Version Series Checked Out", "Is Verison Series Checked Out", PropertyType.BOOLEAN, Cardinality.SINGLE, Updatability.READONLY, inherited, false, true, false));
			type.addPropertyDefinition(this
					.createPropertyDefinition("cmis:versionSeriesCheckedOutBy", "Version Series Checked Out By", "Version Series Checked Out By", PropertyType.STRING, Cardinality.SINGLE, Updatability.READONLY, inherited, false, false, false));
			type.addPropertyDefinition(this
					.createPropertyDefinition("cmis:versionSeriesCheckedOutId", "Version Series Checked Out Id", "Version Series Checked Out Id", PropertyType.ID, Cardinality.SINGLE, Updatability.READONLY, inherited, false, false, false));
			type.addPropertyDefinition(this
					.createPropertyDefinition("cmis:checkinComment", "Checkin Comment", "Checkin Comment", PropertyType.STRING, Cardinality.SINGLE, Updatability.READONLY, inherited, false, false, false));
		}
	}
 
Example #15
Source File: CmisTypeDefinitionFactoryBean.java    From spring-content with Apache License 2.0 5 votes vote down vote up
public MutableFolderTypeDefinition createFolderTypeDefinition(Class<?> entityClass, Class<?> repoClass, CmisFolder metadata, CmisVersion cmisVersion, String parentId) {
	MutableFolderTypeDefinition folderType = new FolderTypeDefinitionImpl();
	folderType.setBaseTypeId(BaseTypeId.CMIS_FOLDER);
	folderType.setParentTypeId(parentId);
	folderType.setIsControllableAcl(false);
	folderType.setIsControllablePolicy(false);
	folderType.setIsCreatable(repoClass != null);
	folderType.setDescription("Folder");
	folderType.setDisplayName("Folder");
	folderType.setIsFileable(isFileable(repoClass));
	folderType.setIsFulltextIndexed(false);
	folderType.setIsIncludedInSupertypeQuery(true);
	folderType.setLocalName("Folder");
	folderType.setLocalNamespace("");
	folderType.setIsQueryable(false);
	folderType.setQueryName("cmis:folder");
	folderType.setId(BaseTypeId.CMIS_FOLDER.value());
	if (cmisVersion != CmisVersion.CMIS_1_0) {
		TypeMutabilityImpl typeMutability = new TypeMutabilityImpl();
		typeMutability.setCanCreate(false);
		typeMutability.setCanUpdate(false);
		typeMutability.setCanDelete(false);
		folderType.setTypeMutability(typeMutability);
	}

	this.addBasePropertyDefinitions(folderType, entityClass, cmisVersion, parentId != null);
	this.addFolderPropertyDefinitions(folderType, cmisVersion, parentId != null);
	return folderType;
}
 
Example #16
Source File: CmisTypeDefinitionFactoryBean.java    From spring-content with Apache License 2.0 5 votes vote down vote up
protected void addFolderPropertyDefinitions(MutableFolderTypeDefinition type, CmisVersion cmisVersion, boolean inherited) {

		if (true /* is fileable */) {
			type.addPropertyDefinition(this
					.createPropertyDefinition("cmis:parentId", "Parent Id", "Parent Id", PropertyType.ID, Cardinality.SINGLE, Updatability.READONLY, inherited, false, false, false));
			type.addPropertyDefinition(this
					.createPropertyDefinition("cmis:path", "Path", "Path", PropertyType.STRING, Cardinality.SINGLE, Updatability.READONLY, inherited, false, false, false));
			type.addPropertyDefinition(this
					.createPropertyDefinition("cmis:allowedChildObjectTypeIds", "Allowed Child Object Type Ids", "Allowed Child Object Type Ids", PropertyType.ID, Cardinality.MULTI, Updatability.READONLY, inherited, false, false, false));
		}
	}
 
Example #17
Source File: CmisUtils.java    From iaf with Apache License 2.0 5 votes vote down vote up
public static List<TypeDefinitionContainer> xml2TypeDescendants(Element typeDefinitionsXml, CmisVersion cmisVersion) {
	List<TypeDefinitionContainer> typeDefinitionList = new ArrayList<TypeDefinitionContainer>();
	Collection<Node> typeDescendantList = XmlUtils.getChildTags(typeDefinitionsXml, "typeDescendant");
	for (Node node : typeDescendantList) {
		Element typeDefinition = XmlUtils.getFirstChildTag((Element) node, "typeDefinition");
		TypeDefinition typeDef = CmisUtils.xml2TypeDefinition(typeDefinition, cmisVersion);
		TypeDefinitionContainerImpl typeDefinitionContainer = new TypeDefinitionContainerImpl(typeDef);

		Element children = XmlUtils.getFirstChildTag((Element) node, "children");
		typeDefinitionContainer.setChildren(xml2TypeDescendants(children, cmisVersion));

		typeDefinitionList.add(typeDefinitionContainer);
	}
	return typeDefinitionList;
}
 
Example #18
Source File: CMISConnector.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public CMISDictionaryService getOpenCMISDictionaryService()
{
    CmisVersion cmisVersion = getRequestCmisVersion();
    if(cmisVersion.equals(CmisVersion.CMIS_1_0))
    {
        return cmisDictionaryService;
    }
    else
    {
        return cmisDictionaryService11;
    }
}
 
Example #19
Source File: CMISConnector.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void addAspectProperties(CMISNodeInfo info, String filter, PropertiesImpl result)
{
    if (getRequestCmisVersion().equals(CmisVersion.CMIS_1_1))
    {
        Set<String> propertyIds = new HashSet<>();
        Set<String> filterSet = splitFilter(filter);

        Set<QName> aspects = info.getNodeAspects();
        for (QName aspect : aspects)
        {
            TypeDefinitionWrapper aspectType = getOpenCMISDictionaryService().findNodeType(aspect);
            if (aspectType == null)
            {
                continue;
            }

            for (PropertyDefinitionWrapper propDef : aspectType.getProperties())
            {
                if (propertyIds.contains(propDef.getPropertyId()))
                {
                    // skip properties that have already been added
                    continue;
                }

                if ((filterSet != null) && (!filterSet.contains(propDef.getPropertyDefinition().getQueryName())))
                {
                    // skip properties that are not in the filter
                    continue;
                }

                Serializable value = propDef.getPropertyAccessor().getValue(info);
                result.addProperty(getProperty(propDef.getPropertyDefinition().getPropertyType(), propDef, value));

                // mark property as 'added'
                propertyIds.add(propDef.getPropertyId());
            }
        }
    }
}
 
Example #20
Source File: CMISTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * ACE-33
 * 
 * Cmis Item support
 */
@Test
public void testItems()
{

    withCmisService(new CmisServiceCallback<String>() {
        @Override
        public String execute(CmisService cmisService) {
            List<RepositoryInfo> repositories = cmisService.getRepositoryInfos(null);
            assertTrue(repositories.size() > 0);
            RepositoryInfo repo = repositories.get(0);
            String repositoryId = repo.getId();
            
        	TypeDefinition def = cmisService.getTypeDefinition(repositoryId, "cmis:item", null);
        	assertNotNull("the cmis:item type is not defined", def); 
            
        	@SuppressWarnings("unused")
            TypeDefinition p = cmisService.getTypeDefinition(repositoryId, "I:cm:person", null);
        	assertNotNull("the I:cm:person type is not defined", def); 
        	
        	ObjectList result = cmisService.query(repositoryId, "select * from cm:person", Boolean.FALSE, Boolean.TRUE, IncludeRelationships.NONE, "", BigInteger.TEN, BigInteger.ZERO, null);
        	assertTrue("", result.getNumItems().intValue() > 0);
        	return "";
    
        };
    }, CmisVersion.CMIS_1_1);
	
}
 
Example #21
Source File: AlfrescoCmisServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public RepositoryInfo getRepositoryInfo(String repositoryId, ExtensionsData extension)
{
    checkRepositoryId(repositoryId);

	CmisVersion cmisVersion = getContext().getCmisVersion();
    return connector.getRepositoryInfo(cmisVersion);
}
 
Example #22
Source File: SOLRAPIClientTest.java    From SearchServices with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void setUp() throws Exception
{
    if(client == null)
    {
        TenantService tenantService = new SingleTServiceImpl();

        dictionaryDAO = new DictionaryDAOImpl();
        NamespaceDAO namespaceDAO = dictionaryDAO;
        dictionaryDAO.setTenantService(tenantService);
        
        CompiledModelsCache compiledModelsCache = new CompiledModelsCache();
        compiledModelsCache.setDictionaryDAO(dictionaryDAO);
        compiledModelsCache.setTenantService(tenantService);
        compiledModelsCache.setRegistry(new DefaultAsynchronouslyRefreshedCacheRegistry());
        TraceableThreadFactory threadFactory = new TraceableThreadFactory();
        threadFactory.setThreadDaemon(true);
        threadFactory.setThreadPriority(Thread.NORM_PRIORITY);
        
        ThreadPoolExecutor threadPoolExecutor = new DynamicallySizedThreadPoolExecutor(20, 20, 90, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(), threadFactory,
                new ThreadPoolExecutor.CallerRunsPolicy());
        compiledModelsCache.setThreadPoolExecutor(threadPoolExecutor);
        dictionaryDAO.setDictionaryRegistryCache(compiledModelsCache);
        // TODO: use config ....
        dictionaryDAO.setDefaultAnalyserResourceBundleName("alfresco/model/dataTypeAnalyzers");
        dictionaryDAO.setResourceClassLoader(getResourceClassLoader());
        dictionaryDAO.init();

        DictionaryComponent dictionaryComponent = new DictionaryComponent();
        dictionaryComponent.setDictionaryDAO(dictionaryDAO);
        dictionaryComponent.setMessageLookup(new StaticMessageLookup());

        // cmis dictionary
        CMISMapping cmisMapping = new CMISMapping();
        cmisMapping.setCmisVersion(CmisVersion.CMIS_1_0);
        DictionaryNamespaceComponent namespaceService = new DictionaryNamespaceComponent();
        namespaceService.setNamespaceDAO(namespaceDAO);
        cmisMapping.setNamespaceService(namespaceService);
        cmisMapping.setDictionaryService(dictionaryComponent);
        cmisMapping.afterPropertiesSet();

        cmisDictionaryService = new CMISStrictDictionaryService();
        cmisDictionaryService.setCmisMapping(cmisMapping);
        cmisDictionaryService.setDictionaryService(dictionaryComponent);
        cmisDictionaryService.setDictionaryDAO(dictionaryDAO);
        cmisDictionaryService.setSingletonCache(new MemoryCache<String, CMISDictionaryRegistry>());
        cmisDictionaryService.setTenantService(tenantService);
        cmisDictionaryService.init();

        RuntimePropertyLuceneBuilderMapping luceneBuilderMapping = new RuntimePropertyLuceneBuilderMapping();
        luceneBuilderMapping.setDictionaryService(dictionaryComponent);
        luceneBuilderMapping.setCmisDictionaryService(cmisDictionaryService);
        cmisDictionaryService.setPropertyLuceneBuilderMapping(luceneBuilderMapping);

        luceneBuilderMapping.afterPropertiesSet();

        // Load the key store from the classpath
        ClasspathKeyResourceLoader keyResourceLoader = new ClasspathKeyResourceLoader();
        client = new SOLRAPIClient(getRepoClient(keyResourceLoader), dictionaryComponent, dictionaryDAO);
        trackModels();
    }
}
 
Example #23
Source File: AlfrescoClientDataModelServicesFactory.java    From SearchServices with GNU Lesser General Public License v3.0 4 votes vote down vote up
public DictionaryKey(CmisVersion cmisVersion, String key) {
	super();
	this.cmisVersion = cmisVersion;
	this.key = key;
}
 
Example #24
Source File: CMISTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
private <T extends Object> T withCmisService(CmisServiceCallback<T> callback)
{
    return withCmisService(callback, CmisVersion.CMIS_1_0);
}
 
Example #25
Source File: CMISTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public CmisVersion getCmisVersion()
{
    return cmisVersion;
}
 
Example #26
Source File: CMISTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
public SimpleCallContext(String user, String password, CmisVersion cmisVersion)
{
	contextMap.put(USERNAME, user);
	contextMap.put(PASSWORD, password);
	this.cmisVersion = cmisVersion;
}
 
Example #27
Source File: CMISServletDispatcher.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void setCmisVersion(String cmisVersion)
{
    this.cmisVersion = CmisVersion.fromValue(cmisVersion);
}
 
Example #28
Source File: AlfrescoCmisServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public List<RepositoryInfo> getRepositoryInfos(ExtensionsData extension)
{
	CmisVersion cmisVersion = getContext().getCmisVersion();
    return Collections.singletonList(connector.getRepositoryInfo(cmisVersion));
}
 
Example #29
Source File: CMISConnector.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Creates the repository info object.
 */
private RepositoryInfo createRepositoryInfo(CmisVersion cmisVersion)
{
    Descriptor currentDescriptor = descriptorService.getCurrentRepositoryDescriptor();

    // get change token
    boolean auditEnabled = auditService.isAuditEnabled(CMIS_CHANGELOG_AUDIT_APPLICATION, "/"
            + CMIS_CHANGELOG_AUDIT_APPLICATION);
    String latestChangeLogToken = null;

    if (auditEnabled)
    {
        EntryIdCallback auditQueryCallback = new EntryIdCallback(false);
        AuditQueryParameters params = new AuditQueryParameters();
        params.setApplicationName(CMIS_CHANGELOG_AUDIT_APPLICATION);
        params.setForward(false);
        auditService.auditQuery(auditQueryCallback, params, 1);
        String entryId = auditQueryCallback.getEntryId();
        // MNT-13529
        // add initial change log token
        latestChangeLogToken = entryId == null ? "0" : entryId;
    }

    // compile repository info
    RepositoryInfoImpl ri = new RepositoryInfoImpl();

    ri.setId(currentDescriptor.getId());
    ri.setName(currentDescriptor.getName());
    ri.setDescription(currentDescriptor.getName());
    ri.setVendorName("Alfresco");
    ri.setProductName("Alfresco " + descriptorService.getServerDescriptor().getEdition());
    ri.setProductVersion(currentDescriptor.getVersion());
    NodeRef rootNodeRef = getRootNodeRef();
    ri.setRootFolder(constructObjectId(rootNodeRef, null));
    ri.setCmisVersion(cmisVersion);

    ri.setChangesIncomplete(true);
    ri.setChangesOnType(Arrays.asList(new BaseTypeId[] { BaseTypeId.CMIS_DOCUMENT, BaseTypeId.CMIS_FOLDER }));
    ri.setLatestChangeLogToken(latestChangeLogToken);
    ri.setPrincipalAnonymous(AuthenticationUtil.getGuestUserName());
    ri.setPrincipalAnyone(PermissionService.ALL_AUTHORITIES);

    RepositoryCapabilitiesImpl repCap = new RepositoryCapabilitiesImpl();
    ri.setCapabilities(repCap);

    repCap.setAllVersionsSearchable(false);
    repCap.setCapabilityAcl(CapabilityAcl.MANAGE);
    repCap.setCapabilityChanges(auditEnabled ? CapabilityChanges.OBJECTIDSONLY : CapabilityChanges.NONE);
    repCap.setCapabilityContentStreamUpdates(CapabilityContentStreamUpdates.ANYTIME);
    repCap.setCapabilityJoin(CapabilityJoin.NONE);
    repCap.setCapabilityQuery(CapabilityQuery.BOTHCOMBINED);
    repCap.setCapabilityRendition(CapabilityRenditions.READ);
    repCap.setIsPwcSearchable(false);
    repCap.setIsPwcUpdatable(true);
    repCap.setSupportsGetDescendants(true);
    repCap.setSupportsGetFolderTree(true);
    repCap.setSupportsMultifiling(true);
    repCap.setSupportsUnfiling(false);
    repCap.setSupportsVersionSpecificFiling(false);

    AclCapabilitiesDataImpl aclCap = new AclCapabilitiesDataImpl();
    ri.setAclCapabilities(aclCap);

    aclCap.setAclPropagation(AclPropagation.PROPAGATE);
    aclCap.setSupportedPermissions(SupportedPermissions.BOTH);
    aclCap.setPermissionDefinitionData(repositoryPermissions);
    aclCap.setPermissionMappingData(permissionMappings);

    return ri;
}
 
Example #30
Source File: CmisTypeDefinitionFactoryBean.java    From spring-content with Apache License 2.0 4 votes vote down vote up
protected void addBasePropertyDefinitions(MutableTypeDefinition type, Class<?> entityClazz, CmisVersion cmisVersion, boolean inherited) {
	Field cmisNameField = BeanUtils.findFieldWithAnnotation(entityClazz, CmisName.class);
	if (cmisNameField != null) {
		type.addPropertyDefinition(this.createPropertyDefinition("cmis:name", "Name", "Name", propertyType(cmisNameField), cardinality(cmisNameField), updatability(entityClazz, cmisNameField), inherited, true, false, false));
	}
	if (cmisVersion != CmisVersion.CMIS_1_0) {
		Field cmisDescField = BeanUtils.findFieldWithAnnotation(entityClazz, CmisDescription.class);
		if (cmisDescField != null) {
			type.addPropertyDefinition(this.createPropertyDefinition("cmis:description", "Description", "Description", propertyType(cmisDescField), cardinality(cmisDescField), updatability(entityClazz, cmisDescField), inherited, false, false, false));
		}
	}

	Field idField = BeanUtils.findFieldWithAnnotation(entityClazz, Id.class);
	if (idField == null) {
		idField = BeanUtils.findFieldWithAnnotation(entityClazz, org.springframework.data.annotation.Id.class);
	}
	if (idField != null) {
		type.addPropertyDefinition(this.createPropertyDefinition("cmis:objectId", "Object Id", "Object Id", PropertyType.ID, cardinality(idField), Updatability.READONLY, inherited, false, false, false));
	}

	type.addPropertyDefinition(this.createPropertyDefinition("cmis:baseTypeId", "Base Type Id", "Base Type Id", PropertyType.ID, Cardinality.SINGLE, Updatability.READONLY, inherited, false, false, false));
	type.addPropertyDefinition(this.createPropertyDefinition("cmis:objectTypeId", "Object Type Id", "Object Type Id", PropertyType.ID, Cardinality.SINGLE, Updatability.ONCREATE, inherited, true, false, false));
	if (cmisVersion != CmisVersion.CMIS_1_0) {
		type.addPropertyDefinition(this.createPropertyDefinition("cmis:secondaryObjectTypeIds", "Secondary Type Ids", "Secondary Type Ids", PropertyType.ID, Cardinality.MULTI, Updatability.READONLY, inherited, false, false, false));
	}

	Field field = BeanUtils.findFieldWithAnnotation(entityClazz, CreatedBy.class);
	if (field != null) {
		type.addPropertyDefinition(this.createPropertyDefinition("cmis:createdBy", "Created By", "Created By", propertyType(field), cardinality(field), Updatability.READONLY, inherited, false, false, false));
	}
	field = BeanUtils.findFieldWithAnnotation(entityClazz, CreatedDate.class);
	if (field != null) {
		type.addPropertyDefinition(this.createPropertyDefinition("cmis:creationDate", "Creation Date", "Creation Date", propertyType(field), cardinality(field), Updatability.READONLY, inherited, false, false, false));
	}
	field = BeanUtils.findFieldWithAnnotation(entityClazz, LastModifiedBy.class);
	if (field != null) {
		type.addPropertyDefinition(this.createPropertyDefinition("cmis:lastModifiedBy", "Last Modified By", "Last Modified By", propertyType(field), cardinality(field), Updatability.READONLY, inherited, false, false, false));
	}
	field = BeanUtils.findFieldWithAnnotation(entityClazz, LastModifiedDate.class);
	if (field != null) {
		type.addPropertyDefinition(this.createPropertyDefinition("cmis:lastModificationDate", "Last Modification Date", "Last Modification Date", propertyType(field), cardinality(field), Updatability.READONLY, inherited, false, false, false));
	}
	field = BeanUtils.findFieldWithAnnotation(entityClazz, Version.class);
	if (field != null) {
		type.addPropertyDefinition(this.createPropertyDefinition("cmis:changeToken", "Change Token", "Change Token", PropertyType.STRING, Cardinality.SINGLE, Updatability.READONLY, inherited, false, false, false));
	}
}