org.alfresco.opencmis.mapping.CMISMapping Java Examples

The following examples show how to use org.alfresco.opencmis.mapping.CMISMapping. 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: AlfrescoClientDataModelServicesFactory.java    From SearchServices with GNU Lesser General Public License v3.0 6 votes vote down vote up
protected static CMISStrictDictionaryService newInstance(CMISMapping cmisMapping, DictionaryService dictionaryService, DictionaryDAO dictionaryDAO)
{
    CMISStrictDictionaryService cmisDictionaryService = new CMISStrictDictionaryService();
    cmisDictionaryService.setCmisMapping(cmisMapping);
    cmisDictionaryService.setDictionaryService(dictionaryService);
    cmisDictionaryService.setDictionaryDAO(dictionaryDAO);
    cmisDictionaryService.setSingletonCache(new MemoryCache<String, CMISDictionaryRegistry>());

    RuntimePropertyLuceneBuilderMapping luceneBuilderMapping = new RuntimePropertyLuceneBuilderMapping();
    luceneBuilderMapping.setDictionaryService(dictionaryService);
    luceneBuilderMapping.setCmisDictionaryService(cmisDictionaryService);
    cmisDictionaryService.setPropertyLuceneBuilderMapping(luceneBuilderMapping);
    luceneBuilderMapping.afterPropertiesSet();
    cmisDictionaryService.init();
    return cmisDictionaryService;
}
 
Example #2
Source File: ShadowTypeDefinitionWrapper.java    From alfresco-data-model with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void resolveInheritance(CMISMapping cmisMapping,
        CMISDictionaryRegistry registry, DictionaryService dictionaryService)
{
    PropertyDefinition<?> propertyDefintion;

    if (parent != null)
    {
        for (PropertyDefinitionWrapper propDef : parent.getProperties(false))
        {
            if (propertiesById.containsKey(propDef.getPropertyId()))
            {
                continue;
            }

            org.alfresco.service.cmr.dictionary.PropertyDefinition alfrescoPropDef = dictionaryService.getProperty(
                    propDef.getOwningType().getAlfrescoName(), propDef.getAlfrescoName());

            propertyDefintion = createPropertyDefinition(cmisMapping, propDef.getPropertyId(),
                    alfrescoPropDef.getName(), dictionaryService, alfrescoPropDef, true);

            if (propertyDefintion != null)
            {
                registerProperty(new BasePropertyDefintionWrapper(propertyDefintion, alfrescoPropDef.getName(),
                        propDef.getOwningType(), propDef.getPropertyAccessor(), propDef.getPropertyLuceneBuilder()));
            }
        }
    }

    List<TypeDefinitionWrapper> children = registry.getChildren(typeDef.getId());
    for (TypeDefinitionWrapper child : children)
    {
        if (child instanceof AbstractTypeDefinitionWrapper)
        {
            ((AbstractTypeDefinitionWrapper) child).resolveInheritance(cmisMapping, registry,
                    dictionaryService);
        }
    }
}
 
Example #3
Source File: CMISDictionaryRegistryImpl.java    From alfresco-data-model with GNU Lesser General Public License v3.0 5 votes vote down vote up
public CMISDictionaryRegistryImpl(CMISAbstractDictionaryService cmisDictionaryService, String tenant, String parentTenant,
		CMISMapping cmisMapping, DictionaryService dictionaryService, DictionaryInitializer dictionaryInitializer)
{
	this.cmisDictionaryService = cmisDictionaryService;
	this.tenant = tenant;
	this.parentTenant = parentTenant;
	this.cmisMapping = cmisMapping;
	this.dictionaryService = dictionaryService;
	this.dictionaryInitializer = dictionaryInitializer;
}
 
Example #4
Source File: AlfrescoClientDataModelServicesFactory.java    From SearchServices with GNU Lesser General Public License v3.0 5 votes vote down vote up
private static CMISMapping newInstanceOfExcludedCMISMapping(CMISMapping cmisMapping, QNameFilter filter)
{
    CMISMapping cmisMappingWithExcl = new CMISMapping();
    cmisMappingWithExcl.setNamespaceService(cmisMapping.getNamespaceService());
    cmisMappingWithExcl.setDictionaryService(cmisMapping.getDictionaryService());
    cmisMappingWithExcl.setFilter(filter);
    cmisMappingWithExcl.setCmisVersion(cmisMapping.getCmisVersion());
    cmisMappingWithExcl.afterPropertiesSet();
    return cmisMappingWithExcl;
}
 
Example #5
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 #6
Source File: RelationshipTypeDefintionWrapper.java    From alfresco-data-model with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void resolveInheritance(CMISMapping cmisMapping, CMISDictionaryRegistry registry,
        DictionaryService dictionaryService)
{
    PropertyDefinition<?> propertyDefintion;

    if (parent != null)
    {
        for (PropertyDefinitionWrapper propDef : parent.getProperties(false))
        {
            org.alfresco.service.cmr.dictionary.PropertyDefinition alfrescoPropDef = dictionaryService.getProperty(
                    propDef.getOwningType().getAlfrescoName(), propDef.getAlfrescoName());

            propertyDefintion = createPropertyDefinition(cmisMapping, propDef.getPropertyId(),
                    alfrescoPropDef.getName(), dictionaryService, alfrescoPropDef, true);

            if (propertyDefintion != null)
            {
                registerProperty(new BasePropertyDefintionWrapper(propertyDefintion, alfrescoPropDef.getName(),
                        propDef.getOwningType(), propDef.getPropertyAccessor(), propDef.getPropertyLuceneBuilder()));
            }
        }
    }

    List<TypeDefinitionWrapper> children = registry.getChildren(typeDef.getId());
    for (TypeDefinitionWrapper child : children)
    {
        if (child instanceof AbstractTypeDefinitionWrapper)
        {
            ((AbstractTypeDefinitionWrapper) child).resolveInheritance(cmisMapping, registry, dictionaryService);
        }
    }
}
 
Example #7
Source File: RelationshipTypeDefintionWrapper.java    From alfresco-data-model with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
    public List<TypeDefinitionWrapper> connectParentAndSubTypes(CMISMapping cmisMapping, CMISDictionaryRegistry registry,
            DictionaryService dictionaryService)
    {
    	String parentTypeId = typeDef.getParentTypeId();

        // find parent
        if (parentTypeId != null)
        {
            parent = registry.getTypeDefByTypeId(parentTypeId);
            if(registry.getTenant() != null && parent != null && registry.getTypeDefByTypeId(parentTypeId, false) == null)
            {
            	// this is a tenant registry and the parent is not defined locally so add this type as a child of it
            	registry.addChild(parent.getTypeId(), this);
            }
        }
        else
        {
            if (!isBaseType())
            {
                throw new AlfrescoRuntimeException("Type " + typeDef.getId() + " has no parent!");
            }

            parent = null;
        }

        // find children
        List<TypeDefinitionWrapper> children = new LinkedList<TypeDefinitionWrapper>();
        if (isBaseType())
        {
            for (TypeDefinitionWrapper child : registry.getAssocDefs())
            {
                children.add(child);
            }
        }

        return children;
//        registry.setChildren(typeDef.getId(), children);
    }
 
Example #8
Source File: SecondaryTypeDefinitionWrapper.java    From alfresco-data-model with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void resolveInheritance(CMISMapping cmisMapping,
        CMISDictionaryRegistry registry, DictionaryService dictionaryService)
{
    PropertyDefinition<?> propertyDefintion;

    if (parent != null)
    {
        for (PropertyDefinitionWrapper propDef : parent.getProperties(false))
        {
            if (propertiesById.containsKey(propDef.getPropertyId()))
            {
                continue;
            }

            org.alfresco.service.cmr.dictionary.PropertyDefinition alfrescoPropDef = dictionaryService.getProperty(
                    propDef.getOwningType().getAlfrescoName(), propDef.getAlfrescoName());

            propertyDefintion = createPropertyDefinition(cmisMapping, propDef.getPropertyId(),
                    alfrescoPropDef.getName(), dictionaryService, alfrescoPropDef, true);

            if (propertyDefintion != null)
            {
                registerProperty(new BasePropertyDefintionWrapper(propertyDefintion, alfrescoPropDef.getName(),
                        propDef.getOwningType(), propDef.getPropertyAccessor(), propDef.getPropertyLuceneBuilder()));
            }
        }
    }

    List<TypeDefinitionWrapper> children = registry.getChildren(typeDef.getId());
    for (TypeDefinitionWrapper child : children)
    {
        if (child instanceof AbstractTypeDefinitionWrapper)
        {
            ((AbstractTypeDefinitionWrapper) child).resolveInheritance(cmisMapping, registry,
                    dictionaryService);
        }
    }
}
 
Example #9
Source File: PolicyTypeDefintionWrapper.java    From alfresco-data-model with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void resolveInheritance(CMISMapping cmisMapping,
        CMISDictionaryRegistry registry, DictionaryService dictionaryService)
{
    PropertyDefinition<?> propertyDefintion;

    if (parent != null)
    {
        for (PropertyDefinitionWrapper propDef : parent.getProperties(false))
        {
            if (propertiesById.containsKey(propDef.getPropertyId()))
            {
                continue;
            }

            org.alfresco.service.cmr.dictionary.PropertyDefinition alfrescoPropDef = dictionaryService.getProperty(
                    propDef.getOwningType().getAlfrescoName(), propDef.getAlfrescoName());

            propertyDefintion = createPropertyDefinition(cmisMapping, propDef.getPropertyId(),
                    alfrescoPropDef.getName(), dictionaryService, alfrescoPropDef, true);

            if (propertyDefintion != null)
            {
                registerProperty(new BasePropertyDefintionWrapper(propertyDefintion, alfrescoPropDef.getName(),
                        propDef.getOwningType(), propDef.getPropertyAccessor(), propDef.getPropertyLuceneBuilder()));
            }
        }
    }

    List<TypeDefinitionWrapper> children = registry.getChildren(typeDef.getId());
    for (TypeDefinitionWrapper child : children)
    {
        if (child instanceof AbstractTypeDefinitionWrapper)
        {
            ((AbstractTypeDefinitionWrapper) child).resolveInheritance(cmisMapping, registry,
                    dictionaryService);
        }
    }
}
 
Example #10
Source File: AbstractTypeDefinitionWrapper.java    From alfresco-data-model with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Adds all property definitions owned by that type.
 */
protected void createOwningPropertyDefinitions(CMISMapping cmisMapping,
        PropertyAccessorMapping propertyAccessorMapping, PropertyLuceneBuilderMapping luceneBuilderMapping,
        DictionaryService dictionaryService, ClassDefinition cmisClassDef)
{
    PropertyDefinition<?> propertyDefintion;

    for (org.alfresco.service.cmr.dictionary.PropertyDefinition alfrescoPropDef : cmisClassDef.getProperties()
            .values())
    {
        if (!isBaseType())
        {
            if (!alfrescoPropDef.getContainerClass().equals(cmisClassDef))
            {
                continue;
            }
        }

        // compile property id
        String propertyId = cmisMapping.buildPrefixEncodedString(alfrescoPropDef.getName());

        if(propertyId.equals("cmis:secondaryObjectTypeIds") && cmisMapping.getCmisVersion() == CmisVersion.CMIS_1_0)
        {
        	continue;
        }

        // create property definition
        propertyDefintion = createPropertyDefinition(cmisMapping, propertyId, alfrescoPropDef.getName(),
                dictionaryService, alfrescoPropDef, false);

        // if the datatype is not supported, the property defintion will be
        // null
        if (propertyDefintion != null)
        {
            CMISPropertyAccessor propertyAccessor = null;
            if (propertyAccessorMapping != null)
            {
                propertyAccessor = propertyAccessorMapping.getPropertyAccessor(propertyId);
                if (propertyAccessor == null)
                {
                    propertyAccessor = propertyAccessorMapping.createDirectPropertyAccessor(propertyId,
                            alfrescoPropDef.getName());
                }
            }

            CMISPropertyLuceneBuilder luceneBuilder = null;
            if (luceneBuilderMapping != null)
            {
                luceneBuilder = luceneBuilderMapping.getPropertyLuceneBuilder(propertyId);
                if (luceneBuilder == null)
                {
                    luceneBuilder = luceneBuilderMapping.createDirectPropertyLuceneBuilder(alfrescoPropDef
                            .getName());
                }
            }

            registerProperty(new BasePropertyDefintionWrapper(propertyDefintion, alfrescoPropDef.getName(), this,
                    propertyAccessor, luceneBuilder));
        }
    }
}
 
Example #11
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 #12
Source File: RelationshipTypeDefintionWrapper.java    From alfresco-data-model with GNU Lesser General Public License v3.0 4 votes vote down vote up
public RelationshipTypeDefintionWrapper(CMISMapping cmisMapping, PropertyAccessorMapping accessorMapping,
        PropertyLuceneBuilderMapping luceneBuilderMapping, String typeId, DictionaryService dictionaryService, AssociationDefinition cmisAssocDef)
{
    this.dictionaryService = dictionaryService;
    alfrescoName = cmisAssocDef.getName();
    alfrescoClass = cmisMapping.getAlfrescoClass(alfrescoName);

    typeDef = new RelationshipTypeDefinitionImpl();

    typeDef.setBaseTypeId(BaseTypeId.CMIS_RELATIONSHIP);
    typeDef.setId(typeId);
    typeDef.setLocalName(alfrescoName.getLocalName());
    typeDef.setLocalNamespace(alfrescoName.getNamespaceURI());

    typeDef.setQueryName(cmisMapping.buildPrefixEncodedString(alfrescoName));
    typeDef.setParentTypeId(BaseTypeId.CMIS_RELATIONSHIP.value());

    typeDef.setDisplayName(null);
    typeDef.setDescription(null);

    typeDef.setIsCreatable(true);
    typeDef.setIsQueryable(false);
    typeDef.setIsFulltextIndexed(false);
    typeDef.setIsControllablePolicy(false);
    typeDef.setIsControllableAcl(false);
    typeDef.setIsIncludedInSupertypeQuery(true);
    typeDef.setIsFileable(false);

    ArrayList<String> both = new ArrayList<String>(2);
    both.add(BaseTypeId.CMIS_DOCUMENT.value());
    both.add(BaseTypeId.CMIS_FOLDER.value());
    
    String sourceTypeId = cmisMapping.getCmisTypeId(cmisMapping
            .getCmisType(cmisAssocDef.getSourceClass().getName()));
    if (sourceTypeId != null)
    {
        typeDef.setAllowedSourceTypes(Collections.singletonList(sourceTypeId));
    }
    else
    {
        typeDef.setAllowedSourceTypes(both);
    }

    String targetTypeId = cmisMapping.getCmisTypeId(cmisMapping
            .getCmisType(cmisAssocDef.getTargetClass().getName()));
    if (targetTypeId != null)
    {
        typeDef.setAllowedTargetTypes(Collections.singletonList(targetTypeId));
    }
    else
    {
        typeDef.setAllowedTargetTypes(both);
    }

    typeDefInclProperties = CMISUtils.copy(typeDef);
    setTypeDefinition(typeDef, typeDefInclProperties);
    createActionEvaluators(accessorMapping, BaseTypeId.CMIS_RELATIONSHIP);
}
 
Example #13
Source File: RelationshipTypeDefintionWrapper.java    From alfresco-data-model with GNU Lesser General Public License v3.0 4 votes vote down vote up
public RelationshipTypeDefintionWrapper(CMISMapping cmisMapping, PropertyAccessorMapping accessorMapping,
        PropertyLuceneBuilderMapping luceneBuilderMapping, String typeId, DictionaryService dictionaryService, ClassDefinition cmisClassDef)
{
    this.dictionaryService = dictionaryService;
    alfrescoName = cmisClassDef.getName();
    alfrescoClass = cmisMapping.getAlfrescoClass(alfrescoName);

    typeDef = new RelationshipTypeDefinitionImpl();

    typeDef.setBaseTypeId(BaseTypeId.CMIS_RELATIONSHIP);
    typeDef.setId(typeId);
    typeDef.setLocalName(alfrescoName.getLocalName());
    typeDef.setLocalNamespace(alfrescoName.getNamespaceURI());

    if (BaseTypeId.CMIS_RELATIONSHIP.value().equals(typeId))
    {
        typeDef.setQueryName(ISO9075.encodeSQL(typeId));
        typeDef.setParentTypeId(null);
        typeDef.setIsCreatable(false);
    } else
    {
        typeDef.setQueryName(ISO9075.encodeSQL(cmisMapping.buildPrefixEncodedString(alfrescoName)));
        typeDef.setParentTypeId(BaseTypeId.CMIS_RELATIONSHIP.value());
        typeDef.setIsCreatable(true);
    }
    
    typeDef.setDisplayName(null);
    typeDef.setDescription(null);

    typeDef.setIsQueryable(false);
    typeDef.setIsFulltextIndexed(false);
    typeDef.setIsControllablePolicy(false);
    typeDef.setIsControllableAcl(false);
    typeDef.setIsIncludedInSupertypeQuery(true);
    typeDef.setIsFileable(false);

    typeDefInclProperties = CMISUtils.copy(typeDef);
    setTypeDefinition(typeDef, typeDefInclProperties);

    createOwningPropertyDefinitions(cmisMapping, accessorMapping, luceneBuilderMapping, dictionaryService, cmisClassDef);
    createActionEvaluators(accessorMapping, BaseTypeId.CMIS_RELATIONSHIP);
}
 
Example #14
Source File: PolicyTypeDefintionWrapper.java    From alfresco-data-model with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
    public List<TypeDefinitionWrapper> connectParentAndSubTypes(CMISMapping cmisMapping, CMISDictionaryRegistry registry,
            DictionaryService dictionaryService)
    {
    	String parentTypeId = typeDef.getParentTypeId();

        // find parent
        if (typeDef.getParentTypeId() != null)
        {
            parent = registry.getTypeDefByTypeId(parentTypeId);
//            if(registry.getTenant() != null && parent != null && registry.getTypeDefByTypeId(parentTypeId, false) == null)
//            {
//            	// this is a tenant registry and the parent is not defined locally so add this type as a child of it
//            	registry.addChild(parent.getTypeId(), this);
//            }
        }
        else
        {
            if (!isBaseType())
            {
                throw new AlfrescoRuntimeException("Type " + typeDef.getId() + " has no parent!");
            }

            parent = null;
        }

        // find children
        Collection<QName> childrenNames = null;

        if (isBaseType())
        {
            // add the "Aspects" type to the CMIS Policy type
            childrenNames = new ArrayList<QName>();
            childrenNames.add(CMISMapping.ASPECTS_QNAME);
        }
        else if (getAlfrescoName().equals(CMISMapping.ASPECTS_QNAME))
        {
            // add all root aspects to the "Aspects" type
            childrenNames = new ArrayList<QName>();

            String aspectsTypeId = cmisMapping.getCmisTypeId(CMISMapping.ASPECTS_QNAME);
            for (AbstractTypeDefinitionWrapper tdw : registry.getTypeDefs(false))
            {
//            	TypeDefinitionWrapper parent = tdw.getParent();
//            	if(tdw.getTenantId().equals(parent.getTenantId()))
//            	{
            		// type and parent in same tenant
//            	}
                String parentId = tdw.getTypeDefinition(false).getParentTypeId();
                if ((parentId != null) && parentId.equals(aspectsTypeId))
                {
                    childrenNames.add(tdw.getAlfrescoName());
                }
            }
        }
        else
        {
            // add all non-root aspects in this tenant to their parent
            childrenNames = dictionaryService.getSubAspects(cmisMapping.getAlfrescoClass(getAlfrescoName()), false);
        }

        List<TypeDefinitionWrapper> children = new LinkedList<TypeDefinitionWrapper>();
        for (QName childName : childrenNames)
        {
            if (cmisMapping.isValidCmisPolicy(childName))
            {
                TypeDefinitionWrapper child = registry.getTypeDefByQName(childName);

                if (child == null)
                {
                    throw new AlfrescoRuntimeException("Failed to retrieve sub type for type id " + childName
                            + " for parent type " + getAlfrescoName() + "!");
                }
                children.add(child);
            }
            else
            {
                logger.info("Not a policy: " + childName);
            }
        }

        return children;
//        registry.setChildren(typeDef.getId(), children);
    }
 
Example #15
Source File: PolicyTypeDefintionWrapper.java    From alfresco-data-model with GNU Lesser General Public License v3.0 4 votes vote down vote up
public PolicyTypeDefintionWrapper(CMISMapping cmisMapping, PropertyAccessorMapping propertyAccessorMapping, 
        PropertyLuceneBuilderMapping luceneBuilderMapping, String typeId, DictionaryService dictionaryService, ClassDefinition cmisClassDef)
{
    this.dictionaryService = dictionaryService;
    alfrescoName = cmisClassDef.getName();
    alfrescoClass = cmisMapping.getAlfrescoClass(alfrescoName);

    typeDef = new PolicyTypeDefinitionImpl();

    typeDef.setBaseTypeId(BaseTypeId.CMIS_POLICY);
    typeDef.setId(typeId);
    typeDef.setLocalName(alfrescoName.getLocalName());
    typeDef.setLocalNamespace(alfrescoName.getNamespaceURI());

    if (BaseTypeId.CMIS_POLICY.value().equals(typeId))
    {
        typeDef.setQueryName(ISO9075.encodeSQL(typeId));
        typeDef.setParentTypeId(null);
    } else
    {
        typeDef.setQueryName(ISO9075.encodeSQL(cmisMapping.buildPrefixEncodedString(alfrescoName)));
        QName parentQName = cmisMapping.getCmisType(cmisClassDef.getParentName());
        if (parentQName == null)
        {
            typeDef.setParentTypeId(cmisMapping.getCmisTypeId(CMISMapping.ASPECTS_QNAME));
        } else if (cmisMapping.isValidCmisPolicy(parentQName))
        {
            typeDef.setParentTypeId(cmisMapping.getCmisTypeId(BaseTypeId.CMIS_POLICY, parentQName));
        } else
        {
            throw new IllegalStateException("The CMIS type model should ignore aspects that inherit from excluded aspects");
        }
    }

    typeDef.setDisplayName(null);
    typeDef.setDescription(null);

    typeDef.setIsCreatable(false);
    typeDef.setIsQueryable(true);
    typeDef.setIsFulltextIndexed(true);
    typeDef.setIsControllablePolicy(false);
    typeDef.setIsControllableAcl(false);
    typeDef.setIsIncludedInSupertypeQuery(cmisClassDef.getIncludedInSuperTypeQuery());
    typeDef.setIsFileable(false);

    typeDefInclProperties = CMISUtils.copy(typeDef);
    setTypeDefinition(typeDef, typeDefInclProperties);

    createOwningPropertyDefinitions(cmisMapping, propertyAccessorMapping, luceneBuilderMapping, dictionaryService, cmisClassDef);
    createActionEvaluators(propertyAccessorMapping, BaseTypeId.CMIS_POLICY);
}
 
Example #16
Source File: ItemTypeDefinitionWrapper.java    From alfresco-data-model with GNU Lesser General Public License v3.0 4 votes vote down vote up
public ItemTypeDefinitionWrapper(CMISMapping cmisMapping, PropertyAccessorMapping accessorMapping, 
        PropertyLuceneBuilderMapping luceneBuilderMapping, String typeId, DictionaryService dictionaryService, ClassDefinition cmisClassDef)
{
    this.dictionaryService = dictionaryService;
    alfrescoName = cmisClassDef.getName();
    alfrescoClass = cmisMapping.getAlfrescoClass(alfrescoName);

    typeDef = new ItemTypeDefinitionImpl();

    typeDef.setBaseTypeId(BaseTypeId.CMIS_ITEM);
    typeDef.setId(typeId);
    typeDef.setLocalName(alfrescoName.getLocalName());
    typeDef.setLocalNamespace(alfrescoName.getNamespaceURI());

    if (BaseTypeId.CMIS_ITEM.value().equals(typeId) )
    {
        typeDef.setQueryName(ISO9075.encodeSQL(typeId));
        typeDef.setParentTypeId(null);
    }  
    else
    {
        typeDef.setQueryName(ISO9075.encodeSQL(cmisMapping.buildPrefixEncodedString(alfrescoName)));
        QName parentQName = cmisMapping.getCmisType(cmisClassDef.getParentName());
        if(parentQName != null)
        {         
            typeDef.setParentTypeId(cmisMapping.getCmisTypeId(BaseTypeId.CMIS_ITEM, parentQName));
        }
    }

    typeDef.setDisplayName(null);
    typeDef.setDescription(null);

    if (BaseTypeId.CMIS_ITEM.value().equals(typeId) )
    {
    	typeDef.setIsCreatable(false);   // cmis:item is abstract
    	 // TEMP work around for select * from cmis:item which lists folders and files
    	typeDef.setIsQueryable(false);
    }
    else
    {
    	typeDef.setIsCreatable(true);
    	typeDef.setIsQueryable(true);
    }
  
    typeDef.setIsFulltextIndexed(true);
    typeDef.setIsControllablePolicy(true);
    typeDef.setIsControllableAcl(true);
    typeDef.setIsIncludedInSupertypeQuery(cmisClassDef.getIncludedInSuperTypeQuery());
    typeDef.setIsFileable(false);

    typeDefInclProperties = CMISUtils.copy(typeDef);
    setTypeDefinition(typeDef, typeDefInclProperties);

    createOwningPropertyDefinitions(cmisMapping, accessorMapping, luceneBuilderMapping, dictionaryService, cmisClassDef);
    createActionEvaluators(accessorMapping, BaseTypeId.CMIS_ITEM);
}
 
Example #17
Source File: BaseCMISTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void setUp() throws Exception
{
    ctx = ApplicationContextHelper.getApplicationContext();
    serviceRegistry = (ServiceRegistry) ctx.getBean("ServiceRegistry");
    
    cmisDictionaryService = (CMISDictionaryService) ctx.getBean("OpenCMISDictionaryService");
    cmisMapping = (CMISMapping) ctx.getBean("OpenCMISMapping");
    cmisQueryService = (CMISQueryService) ctx.getBean("OpenCMISQueryService");
    cmisConnector = (CMISConnector) ctx.getBean("CMISConnector");
    dictionaryService = (DictionaryService) ctx.getBean("dictionaryService");
    nodeService = (NodeService) ctx.getBean("nodeService");
    fileFolderService = (FileFolderService) ctx.getBean("fileFolderService");
    namespaceService = (NamespaceService) ctx.getBean("namespaceService");
    
    transactionService = (TransactionService) ctx.getBean("transactionComponent");
    authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent");
    
    searchService = (SearchService) ctx.getBean("searchService");
    
    contentService = (ContentService) ctx.getBean("contentService");
    
    permissionService = (PermissionService) ctx.getBean("permissionService");
    
    versionService = (VersionService) ctx.getBean("versionService");
    
    authenticationService = (MutableAuthenticationService) ctx.getBean("authenticationService");
    authenticationDAO = (MutableAuthenticationDao) ctx.getBean("authenticationDao");
    
    thumbnailService = (ThumbnailService) ctx.getBean("thumbnailService");
    
    permissionModelDao = (ModelDAO) ctx.getBean("permissionsModelDAO");
    
    dictionaryDAO = (DictionaryDAO) ctx.getBean("dictionaryDAO");
    namespaceDao = (NamespaceDAO) ctx.getBean("namespaceDAO");

    testTX = transactionService.getUserTransaction();
    testTX.begin();
    // Authenticate as the admin user
    AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
    
    String storeName = "CMISTest-" + getStoreName() + "-" + (new Date().getTime());
    this.storeRef = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, storeName);
    rootNodeRef = nodeService.getRootNode(storeRef);
    
    if(authenticationDAO.userExists("cmis"))
    {
        authenticationService.deleteAuthentication("cmis");
    }
    authenticationService.createAuthentication("cmis", "cmis".toCharArray());        
}
 
Example #18
Source File: AbstractTypeDefinitionWrapper.java    From alfresco-data-model with GNU Lesser General Public License v3.0 4 votes vote down vote up
public abstract void resolveInheritance(CMISMapping cmisMapping, CMISDictionaryRegistry registry,
DictionaryService dictionaryService);
 
Example #19
Source File: AbstractTypeDefinitionWrapper.java    From alfresco-data-model with GNU Lesser General Public License v3.0 4 votes vote down vote up
public abstract List<TypeDefinitionWrapper> connectParentAndSubTypes(CMISMapping cmisMapping, CMISDictionaryRegistry registry,
DictionaryService dictionaryService);
 
Example #20
Source File: FolderTypeDefintionWrapper.java    From alfresco-data-model with GNU Lesser General Public License v3.0 4 votes vote down vote up
public FolderTypeDefintionWrapper(CMISMapping cmisMapping, PropertyAccessorMapping accessorMapping, 
        PropertyLuceneBuilderMapping luceneBuilderMapping, String typeId, DictionaryService dictionaryService, ClassDefinition cmisClassDef)
{
    this.dictionaryService = dictionaryService;
    alfrescoName = cmisClassDef.getName();
    alfrescoClass = cmisMapping.getAlfrescoClass(alfrescoName);

    typeDef = new FolderTypeDefinitionImpl();

    typeDef.setBaseTypeId(BaseTypeId.CMIS_FOLDER);
    typeDef.setId(typeId);
    typeDef.setLocalName(alfrescoName.getLocalName());
    typeDef.setLocalNamespace(alfrescoName.getNamespaceURI());

    boolean isSystemFolder = false;
    if (BaseTypeId.CMIS_FOLDER.value().equals(typeId))
    {
        typeDef.setQueryName(ISO9075.encodeSQL(typeId));
        typeDef.setParentTypeId(null);
    } else
    {
        typeDef.setQueryName(ISO9075.encodeSQL(cmisMapping.buildPrefixEncodedString(alfrescoName)));
        QName parentQName = cmisMapping.getCmisType(cmisClassDef.getParentName());
        if (cmisMapping.isValidCmisFolder(parentQName))
        {
            typeDef.setParentTypeId(cmisMapping.getCmisTypeId(BaseTypeId.CMIS_FOLDER, parentQName));
        }

        if (alfrescoName.equals(ContentModel.TYPE_SYSTEM_FOLDER)
                || cmisMapping.getDictionaryService().isSubClass(alfrescoName, ContentModel.TYPE_SYSTEM_FOLDER))
        {
            isSystemFolder = true;
        }
    }

    typeDef.setDisplayName(null);
    typeDef.setDescription(null);

    typeDef.setIsCreatable(!isSystemFolder);
    typeDef.setIsQueryable(true);
    typeDef.setIsFulltextIndexed(true);
    typeDef.setIsControllablePolicy(false);
    typeDef.setIsControllableAcl(true);
    typeDef.setIsIncludedInSupertypeQuery(cmisClassDef.getIncludedInSuperTypeQuery());
    typeDef.setIsFileable(true);

    typeDefInclProperties = CMISUtils.copy(typeDef);
    setTypeDefinition(typeDef, typeDefInclProperties);

    createOwningPropertyDefinitions(cmisMapping, accessorMapping, luceneBuilderMapping, dictionaryService, cmisClassDef);
    createActionEvaluators(accessorMapping, BaseTypeId.CMIS_FOLDER);
}
 
Example #21
Source File: SecondaryTypeDefinitionWrapper.java    From alfresco-data-model with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
    public List<TypeDefinitionWrapper> connectParentAndSubTypes(CMISMapping cmisMapping, CMISDictionaryRegistry registry,
            DictionaryService dictionaryService)
    {
    	String parentTypeId = typeDef.getParentTypeId();

        // find parent
        if (parentTypeId != null)
        {
            parent = registry.getTypeDefByTypeId(parentTypeId);
            if(registry.getTenant() != null && parent != null && registry.getTypeDefByTypeId(parentTypeId, false) == null)
            {
            	// this is a tenant registry and the parent is not defined locally so add this type as a child of it
            	registry.addChild(parent.getTypeId(), this);
            }
        }
        else
        {
            if (!isBaseType())
            {
                throw new AlfrescoRuntimeException("Type " + typeDef.getId() + " has no parent!");
            }

            parent = null;
        }

        // find children
//        children = new ArrayList<TypeDefinitionWrapper>();
        Collection<QName> childrenNames = null;

        if (isBaseType())
        {
//            // add the "Aspects" type to the CMIS secondary type
//            childrenNames = new ArrayList<QName>();
//            childrenNames.add(CMISMapping.SECONDARY_TYPES_QNAME);
//        } else if (getAlfrescoName().equals(CMISMapping.SECONDARY_TYPES_QNAME))
//        {
            // add all root aspects to the "Aspects" type
            childrenNames = new ArrayList<QName>();

            String aspectsTypeId = cmisMapping.getCmisTypeId(CMISMapping.SECONDARY_TYPES_QNAME);
            for (AbstractTypeDefinitionWrapper tdw : registry.getTypeDefs())
            {
                String parentId = tdw.getTypeDefinition(false).getParentTypeId();
                if ((parentId != null) && parentId.equals(aspectsTypeId))
                {
                    childrenNames.add(tdw.getAlfrescoName());
                }
            }
        } else
        {
            // add all non-root aspects to their parent
            childrenNames = dictionaryService.getSubAspects(cmisMapping.getAlfrescoClass(getAlfrescoName()), false);
        }

        List<TypeDefinitionWrapper> children = new LinkedList<TypeDefinitionWrapper>();
        for (QName childName : childrenNames)
        {
            if (cmisMapping.isValidCmisSecondaryType(childName))
            {
                TypeDefinitionWrapper child = registry.getTypeDefByQName(childName);

                if (child == null)
                {
                    throw new AlfrescoRuntimeException("Failed to retrieve sub type for type id " + childName
                            + " for parent type " + getAlfrescoName() + "!");
                }
                children.add(child);
            }
            else
            {
                logger.info("Not a secondary type: " + childName);
            }
        }

        return children;
//        registry.setChildren(typeDef.getId(), children);
    }
 
Example #22
Source File: SecondaryTypeDefinitionWrapper.java    From alfresco-data-model with GNU Lesser General Public License v3.0 4 votes vote down vote up
public SecondaryTypeDefinitionWrapper(CMISMapping cmisMapping, PropertyAccessorMapping propertyAccessorMapping, 
        PropertyLuceneBuilderMapping luceneBuilderMapping, String typeId, DictionaryService dictionaryService, ClassDefinition cmisClassDef)
{
    this.dictionaryService = dictionaryService;
    alfrescoName = cmisClassDef.getName();
    alfrescoClass = cmisMapping.getAlfrescoClass(alfrescoName);

    typeDef = new SecondaryTypeDefinitionImpl();

    typeDef.setBaseTypeId(BaseTypeId.CMIS_SECONDARY);
    typeDef.setId(typeId);
    typeDef.setLocalName(alfrescoName.getLocalName());
    typeDef.setLocalNamespace(alfrescoName.getNamespaceURI());

    if (BaseTypeId.CMIS_SECONDARY.value().equals(typeId))
    {
        typeDef.setQueryName(ISO9075.encodeSQL(typeId));
        typeDef.setParentTypeId(null);
    }
    else
    {
        typeDef.setQueryName(ISO9075.encodeSQL(cmisMapping.buildPrefixEncodedString(alfrescoName)));
        QName parentQName = cmisMapping.getCmisType(cmisClassDef.getParentName());
        if (parentQName == null)
        {
            typeDef.setParentTypeId(cmisMapping.getCmisTypeId(CMISMapping.SECONDARY_TYPES_QNAME));
        } else if (cmisMapping.isValidCmisSecondaryType(parentQName))
        {
            typeDef.setParentTypeId(cmisMapping.getCmisTypeId(BaseTypeId.CMIS_SECONDARY, parentQName));
        } else
        {
            throw new IllegalStateException("The CMIS type model should ignore aspects that inherit from excluded aspects");
        }
    }

    typeDef.setDisplayName(null);
    typeDef.setDescription(null);

    typeDef.setIsCreatable(false);
    typeDef.setIsQueryable(true);
    typeDef.setIsFulltextIndexed(true);
    typeDef.setIsControllablePolicy(false);
    typeDef.setIsControllableAcl(false);
    typeDef.setIsIncludedInSupertypeQuery(cmisClassDef.getIncludedInSuperTypeQuery());
    typeDef.setIsFileable(false);

    typeDefInclProperties = CMISUtils.copy(typeDef);
    setTypeDefinition(typeDef, typeDefInclProperties);

    createOwningPropertyDefinitions(cmisMapping, propertyAccessorMapping, luceneBuilderMapping, dictionaryService, cmisClassDef);
    createActionEvaluators(propertyAccessorMapping, BaseTypeId.CMIS_SECONDARY);
}
 
Example #23
Source File: DocumentTypeDefinitionWrapper.java    From alfresco-data-model with GNU Lesser General Public License v3.0 4 votes vote down vote up
public DocumentTypeDefinitionWrapper(CMISMapping cmisMapping, PropertyAccessorMapping accessorMapping, 
        PropertyLuceneBuilderMapping luceneBuilderMapping, String typeId, DictionaryService dictionaryService, ClassDefinition cmisClassDef)
{
    this.dictionaryService = dictionaryService;
    alfrescoName = cmisClassDef.getName();
    alfrescoClass = cmisMapping.getAlfrescoClass(alfrescoName);

    typeDef = new DocumentTypeDefinitionImpl();

    typeDef.setBaseTypeId(BaseTypeId.CMIS_DOCUMENT);
    typeDef.setId(typeId);
    typeDef.setLocalName(alfrescoName.getLocalName());
    typeDef.setLocalNamespace(alfrescoName.getNamespaceURI());

    if (BaseTypeId.CMIS_DOCUMENT.value().equals(typeId))
    {
        typeDef.setQueryName(ISO9075.encodeSQL(typeId));
        typeDef.setParentTypeId(null);
    } else
    {
        typeDef.setQueryName(ISO9075.encodeSQL(cmisMapping.buildPrefixEncodedString(alfrescoName)));
        QName parentQName = cmisMapping.getCmisType(cmisClassDef.getParentName());
        if (cmisMapping.isValidCmisDocument(parentQName))
        {
            typeDef.setParentTypeId(cmisMapping.getCmisTypeId(BaseTypeId.CMIS_DOCUMENT, parentQName));
        }
    }

    typeDef.setDisplayName(null);
    typeDef.setDescription(null);

    typeDef.setIsCreatable(true);
    typeDef.setIsQueryable(true);
    typeDef.setIsFulltextIndexed(true);
    typeDef.setIsControllablePolicy(false);
    typeDef.setIsControllableAcl(true);
    typeDef.setIsIncludedInSupertypeQuery(cmisClassDef.getIncludedInSuperTypeQuery());
    typeDef.setIsFileable(true);
    typeDef.setContentStreamAllowed(ContentStreamAllowed.ALLOWED);
    typeDef.setIsVersionable(true);

    typeDefInclProperties = CMISUtils.copy(typeDef);
    setTypeDefinition(typeDef, typeDefInclProperties);

    createOwningPropertyDefinitions(cmisMapping, accessorMapping, luceneBuilderMapping, dictionaryService, cmisClassDef);
    createActionEvaluators(accessorMapping, BaseTypeId.CMIS_DOCUMENT);
}
 
Example #24
Source File: CMISDictionaryRegistryImpl.java    From alfresco-data-model with GNU Lesser General Public License v3.0 4 votes vote down vote up
public CMISDictionaryRegistryImpl(CMISAbstractDictionaryService cmisDictionaryService, CMISMapping cmisMapping,
		DictionaryService dictionaryService, DictionaryInitializer dictionaryInitializer)
{
	this(cmisDictionaryService, "", null, cmisMapping, dictionaryService, dictionaryInitializer);
}
 
Example #25
Source File: ShadowTypeDefinitionWrapper.java    From alfresco-data-model with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
    public List<TypeDefinitionWrapper> connectParentAndSubTypes(CMISMapping cmisMapping, CMISDictionaryRegistry registry,
            DictionaryService dictionaryService)
    {
    	String parentTypeId = typeDef.getParentTypeId();

        // find parent
        if (parentTypeId != null)
        {
            parent = registry.getTypeDefByTypeId(parentTypeId);
            if(registry.getTenant() != null && parent != null && registry.getTypeDefByTypeId(parentTypeId, false) == null)
            {
            	// this is a tenant registry and the parent is not defined locally so add this type as a child of it
            	registry.addChild(parent.getTypeId(), this);
            }
        }
        else
        {
            if (!isBaseType())
            {
                throw new AlfrescoRuntimeException("Type " + typeDef.getId() + " has no parent!");
            }

            parent = null;
        }

//        if(parent != null)
//        {
//            List<TypeDefinitionWrapper> children = new LinkedList<TypeDefinitionWrapper>();
//            children.add(this);
//            registry.setChildren(parent.getTypeId(), children);
//        }

        // find children
//        children = new ArrayList<TypeDefinitionWrapper>();
        List<TypeDefinitionWrapper> children = new LinkedList<TypeDefinitionWrapper>();
        Collection<QName> childrenNames = dictionaryService.getSubTypes(cmisMapping.getAlfrescoClass(getAlfrescoName()),
                false);
        for (QName childName : childrenNames)
        {
            if (cmisMapping.isValidCmisObject(getBaseTypeId(), childName))
            {
                TypeDefinitionWrapper child = registry.getTypeDefByQName(childName);

                if (child == null)
                {
                    throw new AlfrescoRuntimeException("Failed to retrieve sub type for type id " + childName
                            + " for parent type " + getAlfrescoName() + "!");
                }
                children.add(child);
            }
        }
        return children;
//        registry.setChildren(typeDef.getId(), children);
    }
 
Example #26
Source File: CMISAbstractDictionaryService.java    From alfresco-data-model with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * Set the mapping service
 * 
 * @param cmisMapping
 *            CMISMapping
 */
public void setCmisMapping(CMISMapping cmisMapping)
{
    this.cmisMapping = cmisMapping;
}