mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Refactor CMIS Dictionary part 2
- further simplification of CMISDictionaryService and fixup fallout - added logging - consolidate & fix property definition handling (only one definition per property) - include support for aspect properties - fix property.isInherited - open up the door for types outside of CMIS doc, folder, rel & policy Dictionary Service - add isOverride() to PropertyDefinition Invite Workflows - ensure they create their own namespace for new types/props - NOTE: the previous way uses a hole in the DictinaryService which has been there unnoticed for over 4 years, till now. At some point, the hole will be filled in. Tests pass for CMIS REST / Web Services and Query. Tests pass for Invitation Service. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@13786 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -33,6 +33,7 @@ import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import org.alfresco.cmis.CMISDataTypeEnum;
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.repo.dictionary.DictionaryDAO;
|
||||
import org.alfresco.repo.dictionary.DictionaryListener;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
@@ -48,10 +49,10 @@ import org.springframework.context.ApplicationEvent;
|
||||
*
|
||||
* @author davidc
|
||||
*/
|
||||
public abstract class AbstractCMISDictionaryService extends AbstractLifecycleBean implements CMISDictionaryService, DictionaryListener
|
||||
public abstract class CMISAbstractDictionaryService extends AbstractLifecycleBean implements CMISDictionaryService, DictionaryListener
|
||||
{
|
||||
// Logger
|
||||
protected static final Log logger = LogFactory.getLog(AbstractCMISDictionaryService.class);
|
||||
protected static final Log logger = LogFactory.getLog(CMISAbstractDictionaryService.class);
|
||||
|
||||
// service dependencies
|
||||
private DictionaryDAO dictionaryDAO;
|
||||
@@ -102,9 +103,9 @@ public abstract class AbstractCMISDictionaryService extends AbstractLifecycleBea
|
||||
/*package*/ class DictionaryRegistry
|
||||
{
|
||||
// Type Definitions Index
|
||||
Map<QName, CMISObjectTypeDefinition> typeDefsByQName = new HashMap<QName, CMISObjectTypeDefinition>();
|
||||
Map<QName, CMISObjectTypeDefinition> assocDefsByQName = new HashMap<QName, CMISObjectTypeDefinition>();
|
||||
Map<CMISTypeId, CMISObjectTypeDefinition> objectDefsByTypeId = new HashMap<CMISTypeId, CMISObjectTypeDefinition>();
|
||||
Map<QName, CMISAbstractTypeDefinition> typeDefsByQName = new HashMap<QName, CMISAbstractTypeDefinition>();
|
||||
Map<QName, CMISAbstractTypeDefinition> assocDefsByQName = new HashMap<QName, CMISAbstractTypeDefinition>();
|
||||
Map<CMISTypeId, CMISAbstractTypeDefinition> objectDefsByTypeId = new HashMap<CMISTypeId, CMISAbstractTypeDefinition>();
|
||||
Map<CMISTypeId, CMISTypeDefinition> typeDefsByTypeId = new HashMap<CMISTypeId, CMISTypeDefinition>();
|
||||
Map<String, CMISTypeDefinition> typeDefsByTable = new HashMap<String, CMISTypeDefinition>();
|
||||
|
||||
@@ -116,25 +117,41 @@ public abstract class AbstractCMISDictionaryService extends AbstractLifecycleBea
|
||||
/**
|
||||
* Register Type Definition
|
||||
*
|
||||
* @param typeDefinition
|
||||
* @param typeDef
|
||||
*/
|
||||
public void registerTypeDefinition(CMISObjectTypeDefinition typeDefinition)
|
||||
public void registerTypeDefinition(CMISAbstractTypeDefinition typeDef)
|
||||
{
|
||||
QName typeQName = typeDefinition.getTypeId().getQName();
|
||||
if (typeQName != null)
|
||||
CMISTypeDefinition existingTypeDef = objectDefsByTypeId.get(typeDef.getTypeId());
|
||||
if (existingTypeDef != null)
|
||||
{
|
||||
if (typeDefinition instanceof CMISRelationshipTypeDefinition)
|
||||
{
|
||||
assocDefsByQName.put(typeQName, typeDefinition);
|
||||
}
|
||||
else
|
||||
{
|
||||
typeDefsByQName.put(typeQName, typeDefinition);
|
||||
}
|
||||
throw new AlfrescoRuntimeException("Type " + typeDef.getTypeId() + " already registered");
|
||||
}
|
||||
|
||||
objectDefsByTypeId.put(typeDef.getTypeId(), typeDef);
|
||||
if (typeDef.isPublic())
|
||||
{
|
||||
QName typeQName = typeDef.getTypeId().getQName();
|
||||
if (typeQName != null)
|
||||
{
|
||||
if (typeDef instanceof CMISRelationshipTypeDefinition)
|
||||
{
|
||||
assocDefsByQName.put(typeQName, typeDef);
|
||||
}
|
||||
else
|
||||
{
|
||||
typeDefsByQName.put(typeQName, typeDef);
|
||||
}
|
||||
}
|
||||
typeDefsByTypeId.put(typeDef.getTypeId(), typeDef);
|
||||
typeDefsByTable.put(typeDef.getQueryName().toLowerCase(), typeDef);
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Registered type " + typeDef.getTypeId() + " (scope=" + typeDef.getTypeId().getScope() + ", public=" + typeDef.isPublic() + ")");
|
||||
logger.debug(" QName: " + typeDef.getTypeId().getQName());
|
||||
logger.debug(" Table: " + typeDef.getQueryName());
|
||||
}
|
||||
objectDefsByTypeId.put(typeDefinition.getTypeId(), typeDefinition);
|
||||
typeDefsByTypeId.put(typeDefinition.getTypeId(), typeDefinition);
|
||||
typeDefsByTable.put(typeDefinition.getQueryName().toLowerCase(), typeDefinition);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -144,11 +161,25 @@ public abstract class AbstractCMISDictionaryService extends AbstractLifecycleBea
|
||||
*/
|
||||
public void registerPropertyDefinition(CMISPropertyDefinition propDef)
|
||||
{
|
||||
CMISPropertyDefinition existingPropDef = propDefsByPropId.get(propDef.getPropertyId());
|
||||
if (existingPropDef != null)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Property " + propDef.getPropertyId() + " of " + propDef.getOwningType().getTypeId() + " already registered by type " + existingPropDef.getOwningType().getTypeId());
|
||||
}
|
||||
|
||||
propDefsByPropId.put(propDef.getPropertyId(), propDef);
|
||||
propDefsByQName.put(propDef.getPropertyId().getQName(), propDef);
|
||||
propDefsByName.put(propDef.getPropertyId().getName().toLowerCase(), propDef);
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Registered property " + propDef.getPropertyId().getId());
|
||||
logger.debug(" QName: " + propDef.getPropertyId().getQName());
|
||||
logger.debug(" Name: " + propDef.getPropertyId().getName());
|
||||
logger.debug(" Owning Type: " + propDef.getOwningType().getTypeId());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
@@ -165,24 +196,45 @@ public abstract class AbstractCMISDictionaryService extends AbstractLifecycleBea
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.CMISDictionaryService#getTypeId(java.lang.String)
|
||||
* @see org.alfresco.cmis.dictionary.CMISDictionaryService#findType(org.alfresco.cmis.dictionary.CMISTypeId)
|
||||
*/
|
||||
public CMISTypeId getTypeId(String typeId)
|
||||
public CMISTypeDefinition findType(CMISTypeId typeId)
|
||||
{
|
||||
return cmisMapping.getCmisTypeId(typeId);
|
||||
return registry.objectDefsByTypeId.get(typeId);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.CMISDictionaryService#getTypeId(org.alfresco.service.namespace.QName, org.alfresco.cmis.dictionary.CMISScope)
|
||||
* @see org.alfresco.cmis.dictionary.CMISDictionaryService#findType(java.lang.String)
|
||||
*/
|
||||
public CMISTypeId getTypeId(QName clazz, CMISScope matchingScope)
|
||||
public CMISTypeDefinition findType(String typeId)
|
||||
{
|
||||
CMISTypeId cmisTypeId = cmisMapping.getCmisTypeId(typeId);
|
||||
return findType(cmisTypeId);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.CMISDictionaryService#findTypeForClass(org.alfresco.service.namespace.QName, org.alfresco.cmis.dictionary.CMISScope[])
|
||||
*/
|
||||
public CMISTypeDefinition findTypeForClass(QName clazz, CMISScope... matchingScopes)
|
||||
{
|
||||
// searching for relationship
|
||||
boolean scopeByRelationship = false;
|
||||
for (CMISScope scope : matchingScopes)
|
||||
{
|
||||
if (scope == CMISScope.RELATIONSHIP)
|
||||
{
|
||||
scopeByRelationship = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// locate type in registry
|
||||
CMISTypeDefinition typeDef = null;
|
||||
if (matchingScope != null && matchingScope == CMISScope.RELATIONSHIP)
|
||||
if (scopeByRelationship)
|
||||
{
|
||||
typeDef = registry.assocDefsByQName.get(clazz);
|
||||
}
|
||||
@@ -191,40 +243,33 @@ public abstract class AbstractCMISDictionaryService extends AbstractLifecycleBea
|
||||
typeDef = registry.typeDefsByQName.get(clazz);
|
||||
}
|
||||
|
||||
CMISTypeDefinition matchingTypeDef = null;
|
||||
if (matchingScope == null)
|
||||
// ensure matches one of provided matching scopes
|
||||
CMISTypeDefinition matchingTypeDef = (matchingScopes.length == 0) ? typeDef : null;
|
||||
if (typeDef != null)
|
||||
{
|
||||
matchingTypeDef = typeDef;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (typeDef != null && typeDef.getTypeId().getScope() == matchingScope)
|
||||
for (CMISScope scope : matchingScopes)
|
||||
{
|
||||
matchingTypeDef = typeDef;
|
||||
if (typeDef.getTypeId().getScope() == scope)
|
||||
{
|
||||
matchingTypeDef = typeDef;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return matchingTypeDef == null ? null : matchingTypeDef.getTypeId();
|
||||
|
||||
return matchingTypeDef;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.CMISDictionaryService#getTypeIdFromTable(java.lang.String)
|
||||
* @see org.alfresco.cmis.dictionary.CMISDictionaryService#findTypeForTable(java.lang.String)
|
||||
*/
|
||||
public CMISTypeId getTypeIdFromTable(String table)
|
||||
public CMISTypeDefinition findTypeForTable(String tableName)
|
||||
{
|
||||
CMISTypeDefinition typeDef = registry.typeDefsByTable.get(table.toLowerCase());
|
||||
return (typeDef == null) ? null : typeDef.getTypeId();
|
||||
CMISTypeDefinition typeDef = registry.typeDefsByTable.get(tableName.toLowerCase());
|
||||
return typeDef;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.CMISDictionaryService#getType(org.alfresco.cmis.dictionary.CMISTypeId)
|
||||
*/
|
||||
public CMISTypeDefinition getType(CMISTypeId typeId)
|
||||
{
|
||||
return registry.objectDefsByTypeId.get(typeId);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.CMISDictionaryService#getAllTypes()
|
||||
@@ -233,46 +278,58 @@ public abstract class AbstractCMISDictionaryService extends AbstractLifecycleBea
|
||||
{
|
||||
return Collections.unmodifiableCollection(registry.typeDefsByTypeId.values());
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.CMISDictionaryService#getProperty(org.alfresco.cmis.dictionary.CMISPropertyId)
|
||||
* @see org.alfresco.cmis.dictionary.CMISDictionaryService#getProperty(org.alfresco.service.namespace.QName, org.alfresco.cmis.dictionary.CMISTypeDefinition)
|
||||
*/
|
||||
public CMISPropertyDefinition getProperty(CMISPropertyId propertyId)
|
||||
{
|
||||
return registry.propDefsByPropId.get(propertyId);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.CMISDictionaryService#getPropertyId(java.lang.String)
|
||||
*/
|
||||
public CMISPropertyId getPropertyId(String property)
|
||||
{
|
||||
CMISPropertyDefinition propDef = registry.propDefsByName.get(property.toLowerCase());
|
||||
return (propDef == null) ? null : propDef.getPropertyId();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.CMISDictionaryService#getPropertyId(org.alfresco.service.namespace.QName)
|
||||
*/
|
||||
public CMISPropertyId getPropertyId(QName property)
|
||||
public CMISPropertyDefinition findProperty(QName property, CMISTypeDefinition matchingType)
|
||||
{
|
||||
CMISPropertyDefinition propDef = registry.propDefsByQName.get(property);
|
||||
return (propDef == null) ? null : propDef.getPropertyId();
|
||||
return getProperty(propDef, matchingType);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.CMISDictionaryService#getProperty(java.lang.String, org.alfresco.cmis.dictionary.CMISTypeDefinition)
|
||||
*/
|
||||
public CMISPropertyDefinition findProperty(String property, CMISTypeDefinition matchingType)
|
||||
{
|
||||
CMISPropertyDefinition propDef = registry.propDefsByName.get(property.toLowerCase());
|
||||
return getProperty(propDef, matchingType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return property definition if part of specified type definition
|
||||
*
|
||||
* @param property
|
||||
* @param matchingType
|
||||
* @return property definition (if matches), or null (if not matches)
|
||||
*/
|
||||
private CMISPropertyDefinition getProperty(CMISPropertyDefinition property, CMISTypeDefinition matchingType)
|
||||
{
|
||||
boolean isMatchingType = (matchingType == null);
|
||||
if (property != null && matchingType != null)
|
||||
{
|
||||
Map<CMISPropertyId, CMISPropertyDefinition> props = matchingType.getPropertyDefinitions();
|
||||
if (props.containsKey(property.getPropertyId()))
|
||||
{
|
||||
isMatchingType = true;
|
||||
}
|
||||
}
|
||||
return isMatchingType ? property : null;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.CMISDictionaryService#getDataType(org.alfresco.service.namespace.QName)
|
||||
*/
|
||||
public CMISDataTypeEnum getDataType(QName dataType)
|
||||
public CMISDataTypeEnum findDataType(QName dataType)
|
||||
{
|
||||
return cmisMapping.getDataType(dataType);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Factory for creating CMIS Definitions
|
||||
*
|
||||
@@ -288,9 +345,12 @@ public abstract class AbstractCMISDictionaryService extends AbstractLifecycleBea
|
||||
{
|
||||
DictionaryRegistry registry = new DictionaryRegistry();
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Creating type definitions...");
|
||||
|
||||
// phase 1: construct type definitions
|
||||
createDefinitions(registry);
|
||||
for (CMISObjectTypeDefinition objectTypeDef : registry.objectDefsByTypeId.values())
|
||||
for (CMISAbstractTypeDefinition objectTypeDef : registry.objectDefsByTypeId.values())
|
||||
{
|
||||
Map<CMISPropertyId, CMISPropertyDefinition> propDefs = objectTypeDef.createProperties(cmisMapping, dictionaryService);
|
||||
for (CMISPropertyDefinition propDef : propDefs.values())
|
||||
@@ -300,37 +360,43 @@ public abstract class AbstractCMISDictionaryService extends AbstractLifecycleBea
|
||||
objectTypeDef.createSubTypes(cmisMapping, dictionaryService);
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Linking type definitions...");
|
||||
|
||||
// phase 2: link together
|
||||
for (CMISObjectTypeDefinition objectTypeDef : registry.objectDefsByTypeId.values())
|
||||
for (CMISAbstractTypeDefinition objectTypeDef : registry.objectDefsByTypeId.values())
|
||||
{
|
||||
objectTypeDef.resolveDependencies(registry);
|
||||
}
|
||||
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Resolving type inheritance...");
|
||||
|
||||
// phase 3: resolve inheritance
|
||||
Map<Integer,List<CMISObjectTypeDefinition>> order = new TreeMap<Integer, List<CMISObjectTypeDefinition>>();
|
||||
for (CMISObjectTypeDefinition typeDef : registry.objectDefsByTypeId.values())
|
||||
Map<Integer,List<CMISAbstractTypeDefinition>> order = new TreeMap<Integer, List<CMISAbstractTypeDefinition>>();
|
||||
for (CMISAbstractTypeDefinition typeDef : registry.objectDefsByTypeId.values())
|
||||
{
|
||||
// calculate class depth in hierarchy
|
||||
int depth = 0;
|
||||
CMISTypeDefinition parent = typeDef.getParentType();
|
||||
CMISAbstractTypeDefinition parent = typeDef.getInternalParentType();
|
||||
while (parent != null)
|
||||
{
|
||||
depth = depth +1;
|
||||
parent = parent.getParentType();
|
||||
parent = parent.getInternalParentType();
|
||||
}
|
||||
|
||||
// map class to depth
|
||||
List<CMISObjectTypeDefinition> classes = order.get(depth);
|
||||
List<CMISAbstractTypeDefinition> classes = order.get(depth);
|
||||
if (classes == null)
|
||||
{
|
||||
classes = new ArrayList<CMISObjectTypeDefinition>();
|
||||
classes = new ArrayList<CMISAbstractTypeDefinition>();
|
||||
order.put(depth, classes);
|
||||
}
|
||||
classes.add(typeDef);
|
||||
}
|
||||
for (int depth = 0; depth < order.size(); depth++)
|
||||
{
|
||||
for (CMISObjectTypeDefinition typeDef : order.get(depth))
|
||||
for (CMISAbstractTypeDefinition typeDef : order.get(depth))
|
||||
{
|
||||
typeDef.resolveInheritance(registry);
|
||||
}
|
||||
@@ -339,8 +405,8 @@ public abstract class AbstractCMISDictionaryService extends AbstractLifecycleBea
|
||||
// publish new registry
|
||||
this.registry = registry;
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Initialized CMIS Dictionary. Types:" + registry.typeDefsByTypeId.size() + ", Properties:" + registry.propDefsByPropId.size());
|
||||
if (logger.isInfoEnabled())
|
||||
logger.info("Initialized CMIS Dictionary. Types:" + registry.typeDefsByTypeId.size() + ", Properties:" + registry.propDefsByPropId.size());
|
||||
}
|
||||
|
||||
/*
|
@@ -33,13 +33,15 @@ import java.util.LinkedList;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.cmis.CMISContentStreamAllowedEnum;
|
||||
import org.alfresco.cmis.dictionary.AbstractCMISDictionaryService.DictionaryRegistry;
|
||||
import org.alfresco.cmis.dictionary.CMISAbstractDictionaryService.DictionaryRegistry;
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.service.cmr.dictionary.AspectDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.ClassDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
|
||||
/**
|
||||
@@ -47,17 +49,22 @@ import org.alfresco.service.namespace.QName;
|
||||
*
|
||||
* @author davidc
|
||||
*/
|
||||
public class CMISObjectTypeDefinition implements CMISTypeDefinition, Serializable
|
||||
public class CMISAbstractTypeDefinition implements CMISTypeDefinition, Serializable
|
||||
{
|
||||
// Logger
|
||||
protected static final Log logger = LogFactory.getLog(CMISAbstractTypeDefinition.class);
|
||||
|
||||
private static final long serialVersionUID = -3131505923356013430L;
|
||||
|
||||
// Object type properties
|
||||
protected boolean isPublic;
|
||||
protected ClassDefinition cmisClassDef;
|
||||
protected CMISTypeId objectTypeId;
|
||||
protected String objectTypeQueryName;
|
||||
protected String displayName;
|
||||
protected CMISTypeId parentTypeId;
|
||||
protected CMISTypeDefinition parentType;
|
||||
protected CMISAbstractTypeDefinition internalParentType;
|
||||
protected CMISTypeDefinition rootType;
|
||||
protected String description;
|
||||
protected boolean creatable;
|
||||
@@ -68,6 +75,8 @@ public class CMISObjectTypeDefinition implements CMISTypeDefinition, Serializabl
|
||||
protected Collection<CMISTypeDefinition> subTypes = new ArrayList<CMISTypeDefinition>();
|
||||
protected Map<CMISPropertyId, CMISPropertyDefinition> properties = new HashMap<CMISPropertyId, CMISPropertyDefinition>();
|
||||
protected Map<CMISPropertyId, CMISPropertyDefinition> inheritedProperties = new HashMap<CMISPropertyId, CMISPropertyDefinition>();
|
||||
protected Map<CMISPropertyId, CMISPropertyDefinition> ownedProperties = new HashMap<CMISPropertyId, CMISPropertyDefinition>();
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@@ -82,20 +91,7 @@ public class CMISObjectTypeDefinition implements CMISTypeDefinition, Serializabl
|
||||
// map properties directly defined on this type
|
||||
for (PropertyDefinition propDef : cmisClassDef.getProperties().values())
|
||||
{
|
||||
if (propDef.getContainerClass().equals(cmisClassDef))
|
||||
{
|
||||
if (cmisMapping.getDataType(propDef.getDataType()) != null)
|
||||
{
|
||||
CMISPropertyDefinition cmisPropDef = createProperty(cmisMapping, propDef);
|
||||
properties.put(cmisPropDef.getPropertyId(), cmisPropDef);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// map properties directly defined on default aspects
|
||||
for (AspectDefinition aspectDef : cmisClassDef.getDefaultAspects(false))
|
||||
{
|
||||
for (PropertyDefinition propDef : aspectDef.getProperties().values())
|
||||
if (propDef.getContainerClass().equals(cmisClassDef) && !propDef.isOverride())
|
||||
{
|
||||
if (cmisMapping.getDataType(propDef.getDataType()) != null)
|
||||
{
|
||||
@@ -155,29 +151,48 @@ public class CMISObjectTypeDefinition implements CMISTypeDefinition, Serializabl
|
||||
{
|
||||
if (parentTypeId != null)
|
||||
{
|
||||
parentType = registry.typeDefsByTypeId.get(parentTypeId);
|
||||
if (parentType == null)
|
||||
internalParentType = registry.objectDefsByTypeId.get(parentTypeId);
|
||||
if (internalParentType == null)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Failed to retrieve parent type for type id " + parentTypeId);
|
||||
}
|
||||
if (internalParentType.isPublic() == isPublic)
|
||||
{
|
||||
parentType = internalParentType;
|
||||
}
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Type " + objectTypeId + ": parent=" + (parentType == null ? "<none>" : parentType.getTypeId()) +
|
||||
", internal parent=" + (internalParentType == null ? "<none>" : internalParentType.getTypeId()));
|
||||
|
||||
CMISTypeId rootTypeId = objectTypeId.getRootTypeId();
|
||||
if (rootTypeId != null)
|
||||
{
|
||||
rootType = registry.typeDefsByTypeId.get(rootTypeId);
|
||||
rootType = registry.objectDefsByTypeId.get(rootTypeId);
|
||||
if (rootType == null)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Failed to retrieve root type for type id " + rootTypeId);
|
||||
}
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Type " + objectTypeId + ": root=" + rootType.getTypeId());
|
||||
|
||||
for (CMISTypeId subTypeId : subTypeIds)
|
||||
{
|
||||
CMISTypeDefinition subType = registry.typeDefsByTypeId.get(subTypeId);
|
||||
CMISTypeDefinition subType = registry.objectDefsByTypeId.get(subTypeId);
|
||||
if (subType == null)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Failed to retrieve sub type for type id " + subTypeId + " for parent type " + objectTypeId);
|
||||
}
|
||||
subTypes.add(subType);
|
||||
if (subType.isPublic() == isPublic)
|
||||
{
|
||||
subTypes.add(subType);
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Type " + objectTypeId + ": subtype=" + subType.getTypeId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,70 +204,92 @@ public class CMISObjectTypeDefinition implements CMISTypeDefinition, Serializabl
|
||||
/*package*/ void resolveInheritance(DictionaryRegistry registry)
|
||||
{
|
||||
inheritedProperties.putAll(properties);
|
||||
if (parentType != null)
|
||||
ownedProperties.putAll(properties);
|
||||
if (internalParentType != null)
|
||||
{
|
||||
inheritedProperties.putAll(parentType.getPropertyDefinitions());
|
||||
}
|
||||
}
|
||||
|
||||
inheritedProperties.putAll(internalParentType.getPropertyDefinitions());
|
||||
|
||||
// collapse all internal inherited properties into owned properties
|
||||
if (internalParentType.isPublic != isPublic)
|
||||
{
|
||||
ownedProperties.putAll(internalParentType.getPropertyDefinitions());
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Type " + objectTypeId + " inheriting properties: " + internalParentType.getPropertyDefinitions().size() + " from " + internalParentType.getTypeId());
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Type " + objectTypeId + " properties: " + inheritedProperties.size() + ", owned: " + ownedProperties.size());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the unique identifier for the type
|
||||
* Get internal parent type
|
||||
*
|
||||
* @return - the type id
|
||||
* @return
|
||||
*/
|
||||
public CMISAbstractTypeDefinition getInternalParentType()
|
||||
{
|
||||
return internalParentType;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.CMISTypeDefinition#isPublic()
|
||||
*/
|
||||
public boolean isPublic()
|
||||
{
|
||||
return isPublic;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.CMISTypeDefinition#getTypeId()
|
||||
*/
|
||||
public CMISTypeId getTypeId()
|
||||
{
|
||||
return objectTypeId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the table name used for queries against the type. This is also a unique identifier for the type. The string
|
||||
* conforms to SQL table naming conventions. TODO: Should we impose a maximum length and if so how do we avoid
|
||||
* collisions from truncations?
|
||||
*
|
||||
* @return the sql table name
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.CMISTypeDefinition#getQueryName()
|
||||
*/
|
||||
public String getQueryName()
|
||||
{
|
||||
return objectTypeQueryName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the display name for the type.
|
||||
*
|
||||
* @return - the display name
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.CMISTypeDefinition#getDisplayName()
|
||||
*/
|
||||
public String getDisplayName()
|
||||
{
|
||||
return displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get parent type
|
||||
*
|
||||
* @return
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.CMISTypeDefinition#getParentType()
|
||||
*/
|
||||
public CMISTypeDefinition getParentType()
|
||||
{
|
||||
return parentType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the root type
|
||||
*
|
||||
* @return
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.CMISTypeDefinition#getRootType()
|
||||
*/
|
||||
public CMISTypeDefinition getRootType()
|
||||
{
|
||||
return rootType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get sub types
|
||||
*
|
||||
* @return
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.CMISTypeDefinition#getSubTypes(boolean)
|
||||
*/
|
||||
public Collection<CMISTypeDefinition> getSubTypes(boolean includeDescendants)
|
||||
{
|
||||
@@ -281,121 +318,117 @@ public class CMISObjectTypeDefinition implements CMISTypeDefinition, Serializabl
|
||||
}
|
||||
return descendants;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the description for the type
|
||||
*
|
||||
* @return - the description
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.CMISTypeDefinition#getDescription()
|
||||
*/
|
||||
public String getDescription()
|
||||
{
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can objects of this type be created?
|
||||
*
|
||||
* @return
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.CMISTypeDefinition#isCreatable()
|
||||
*/
|
||||
public boolean isCreatable()
|
||||
{
|
||||
return creatable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this type queryable? If not, the type may not appear in the FROM clause of a query. This property of the type
|
||||
* is not inherited in the type hierarchy. It is set on each type.
|
||||
*
|
||||
* @return true if queryable
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.CMISTypeDefinition#isQueryable()
|
||||
*/
|
||||
public boolean isQueryable()
|
||||
{
|
||||
return queryable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Are objects of this type controllable.
|
||||
*
|
||||
* @return
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.CMISTypeDefinition#isControllable()
|
||||
*/
|
||||
public boolean isControllable()
|
||||
{
|
||||
return controllable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Are objects of this type included in super type queries
|
||||
*
|
||||
* @return
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.CMISTypeDefinition#isIncludeInSuperTypeQuery()
|
||||
*/
|
||||
public boolean isIncludeInSuperTypeQuery()
|
||||
{
|
||||
return includeInSuperTypeQuery;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the property definitions for this type
|
||||
*
|
||||
* @return property definitions
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.CMISTypeDefinition#getPropertyDefinitions()
|
||||
*/
|
||||
public Map<CMISPropertyId, CMISPropertyDefinition> getPropertyDefinitions()
|
||||
{
|
||||
return inheritedProperties;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.CMISTypeDefinition#getOwnedPropertyDefinitions()
|
||||
*/
|
||||
public Map<CMISPropertyId, CMISPropertyDefinition> getOwnedPropertyDefinitions()
|
||||
{
|
||||
return ownedProperties;
|
||||
}
|
||||
|
||||
//
|
||||
// Document Type specific
|
||||
//
|
||||
|
||||
/**
|
||||
* Is Fileable?
|
||||
*
|
||||
* @return
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.CMISTypeDefinition#isFileable()
|
||||
*/
|
||||
public boolean isFileable()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is Versionable?
|
||||
*
|
||||
* @return
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.CMISTypeDefinition#isVersionable()
|
||||
*/
|
||||
public boolean isVersionable()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is Content Stream Allowed?
|
||||
*
|
||||
* @return
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.CMISTypeDefinition#getContentStreamAllowed()
|
||||
*/
|
||||
public CMISContentStreamAllowedEnum getContentStreamAllowed()
|
||||
{
|
||||
return CMISContentStreamAllowedEnum.NOT_ALLOWED;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Relationship Type specific
|
||||
//
|
||||
|
||||
/**
|
||||
* Get allowed source types
|
||||
*
|
||||
* @return
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.CMISTypeDefinition#getAllowedSourceTypes()
|
||||
*/
|
||||
public Collection<CMISTypeDefinition> getAllowedSourceTypes()
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get allowed target types
|
||||
*
|
||||
* @return
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.CMISTypeDefinition#getAllowedTargetTypes()
|
||||
*/
|
||||
public Collection<CMISTypeDefinition> getAllowedTargetTypes()
|
||||
{
|
@@ -37,85 +37,68 @@ import org.alfresco.service.namespace.QName;
|
||||
public interface CMISDictionaryService
|
||||
{
|
||||
/**
|
||||
* Get Type Id
|
||||
* Find type for type id
|
||||
* @param typeId
|
||||
* @return
|
||||
*/
|
||||
public CMISTypeDefinition findType(CMISTypeId typeId);
|
||||
|
||||
/**
|
||||
* Find type for type id
|
||||
*
|
||||
* @param typeId
|
||||
* @return
|
||||
*/
|
||||
public CMISTypeId getTypeId(String typeId);
|
||||
public CMISTypeDefinition findType(String typeId);
|
||||
|
||||
/**
|
||||
* Get Type Id from Table Name
|
||||
*
|
||||
* @param table
|
||||
* @return
|
||||
*/
|
||||
public CMISTypeId getTypeIdFromTable(String table);
|
||||
|
||||
/**
|
||||
* Get Type Id from Alfresco Class Name
|
||||
* Find type for Alfresco class name. Optionally, constrain match to one of specified CMIS scopes
|
||||
*
|
||||
* @param clazz
|
||||
* @param matchingScope if provided, only return type id matching scope
|
||||
* @param matchingScopes
|
||||
* @return
|
||||
*/
|
||||
public CMISTypeId getTypeId(QName clazz, CMISScope matchingScope);
|
||||
|
||||
/**
|
||||
* Get Type Definition
|
||||
*
|
||||
* @param typeId
|
||||
* @return
|
||||
*/
|
||||
public CMISTypeDefinition getType(CMISTypeId typeId);
|
||||
public CMISTypeDefinition findTypeForClass(QName clazz, CMISScope... matchingScopes);
|
||||
|
||||
/**
|
||||
* Get All Type Definitions
|
||||
* Find type for table
|
||||
*
|
||||
* @param tableName
|
||||
* @return
|
||||
*/
|
||||
public CMISTypeDefinition findTypeForTable(String tableName);
|
||||
|
||||
/**
|
||||
* Get all Types
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Collection<CMISTypeDefinition> getAllTypes();
|
||||
|
||||
|
||||
/**
|
||||
* Get Property Id for Alfresco property name
|
||||
* Find property. Optionally constrain match to specified type.
|
||||
*
|
||||
* @param property
|
||||
* @param matchingType
|
||||
* @return
|
||||
*/
|
||||
public CMISPropertyId getPropertyId(QName property);
|
||||
public CMISPropertyDefinition findProperty(QName property, CMISTypeDefinition matchingType);
|
||||
|
||||
/**
|
||||
* Get Property Id
|
||||
* Find property. Optionally constrain match to specified type.
|
||||
*
|
||||
* @param propertyId
|
||||
* @param property
|
||||
* @param matchingType
|
||||
* @return
|
||||
*/
|
||||
public CMISPropertyId getPropertyId(String propertyId);
|
||||
|
||||
public CMISPropertyDefinition findProperty(String property, CMISTypeDefinition matchingType);
|
||||
|
||||
/**
|
||||
* Get Property
|
||||
*
|
||||
* @param propertyId
|
||||
* @return
|
||||
*/
|
||||
public CMISPropertyDefinition getProperty(CMISPropertyId propertyId);
|
||||
|
||||
/**
|
||||
* Get Data Type
|
||||
* Find data type
|
||||
*
|
||||
* @param dataType
|
||||
* @return
|
||||
*/
|
||||
public CMISDataTypeEnum getDataType(QName dataType);
|
||||
|
||||
|
||||
// public CMISTypeDef findType(CMISTypeId typeId)
|
||||
// public CMISTypeDef findType(String typeId)
|
||||
// public CMISTypeDef findTypeForClass(QName clazz, CMISScope matchingScope, ...)
|
||||
// public CMISTypeDef findTypeForTable(String tableName)
|
||||
// public CMISTypeDef getAllTypes();
|
||||
// public CMISPropertyDefinition getProperty(QName property)
|
||||
// public CMISPropertyDefinition getProperty(CMISTypeDef typeDef, String property)
|
||||
// public CMISDataTypeEnum getDataType(QName dataType)
|
||||
public CMISDataTypeEnum findDataType(QName dataType);
|
||||
|
||||
}
|
||||
|
@@ -55,8 +55,7 @@ public class CMISDictionaryTest extends BaseCMISTest
|
||||
{
|
||||
for (CMISTypeDefinition typeDef : cmisDictionaryService.getAllTypes())
|
||||
{
|
||||
CMISTypeId typeId = typeDef.getTypeId();
|
||||
CMISTypeDefinition typeDefLookup = cmisDictionaryService.getType(typeId);
|
||||
CMISTypeDefinition typeDefLookup = cmisDictionaryService.findType(typeDef.getTypeId());
|
||||
assertNotNull(typeDefLookup);
|
||||
assertEquals(typeDef, typeDefLookup);
|
||||
}
|
||||
|
@@ -38,7 +38,7 @@ import org.alfresco.service.namespace.QName;
|
||||
*
|
||||
* @author davidc
|
||||
*/
|
||||
public class CMISDocumentTypeDefinition extends CMISObjectTypeDefinition
|
||||
public class CMISDocumentTypeDefinition extends CMISAbstractTypeDefinition
|
||||
{
|
||||
private static final long serialVersionUID = -7209732754962781522L;
|
||||
|
||||
@@ -57,17 +57,32 @@ public class CMISDocumentTypeDefinition extends CMISObjectTypeDefinition
|
||||
*/
|
||||
public CMISDocumentTypeDefinition(CMISMapping cmisMapping, CMISTypeId typeId, ClassDefinition cmisClassDef)
|
||||
{
|
||||
isPublic = true;
|
||||
|
||||
// Object type properties
|
||||
this.cmisClassDef = cmisClassDef;
|
||||
objectTypeId = typeId;
|
||||
objectTypeQueryName = (typeId == CMISDictionaryModel.DOCUMENT_TYPE_ID) ? typeId.getId() : cmisMapping.buildPrefixEncodedString(typeId.getQName(), false);
|
||||
displayName = (cmisClassDef.getTitle() != null) ? cmisClassDef.getTitle() : typeId.getId();
|
||||
QName parentQName = cmisMapping.getCmisType(cmisClassDef.getParentName());
|
||||
if (cmisMapping.isValidCmisDocument(parentQName))
|
||||
{
|
||||
parentTypeId = cmisMapping.getCmisTypeId(CMISScope.DOCUMENT, parentQName);
|
||||
}
|
||||
description = cmisClassDef.getDescription();
|
||||
|
||||
QName parentQName = cmisMapping.getCmisType(cmisClassDef.getParentName());
|
||||
if (typeId == CMISDictionaryModel.DOCUMENT_TYPE_ID)
|
||||
{
|
||||
objectTypeQueryName = typeId.getId();
|
||||
if (parentQName != null)
|
||||
{
|
||||
parentTypeId = cmisMapping.getCmisTypeId(CMISScope.OBJECT, parentQName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
objectTypeQueryName = cmisMapping.buildPrefixEncodedString(typeId.getQName(), false);
|
||||
if (cmisMapping.isValidCmisDocument(parentQName))
|
||||
{
|
||||
parentTypeId = cmisMapping.getCmisTypeId(CMISScope.DOCUMENT, parentQName);
|
||||
}
|
||||
}
|
||||
|
||||
creatable = true;
|
||||
queryable = true;
|
||||
controllable = false;
|
||||
|
@@ -33,7 +33,7 @@ import org.alfresco.service.namespace.QName;
|
||||
*
|
||||
* @author davidc
|
||||
*/
|
||||
public class CMISFolderTypeDefinition extends CMISObjectTypeDefinition
|
||||
public class CMISFolderTypeDefinition extends CMISAbstractTypeDefinition
|
||||
{
|
||||
private static final long serialVersionUID = 7526155195125799106L;
|
||||
|
||||
@@ -45,17 +45,32 @@ public class CMISFolderTypeDefinition extends CMISObjectTypeDefinition
|
||||
*/
|
||||
public CMISFolderTypeDefinition(CMISMapping cmisMapping, CMISTypeId typeId, ClassDefinition cmisClassDef)
|
||||
{
|
||||
isPublic = true;
|
||||
|
||||
// Object type properties
|
||||
this.cmisClassDef = cmisClassDef;
|
||||
objectTypeId = typeId;
|
||||
objectTypeQueryName = (typeId == CMISDictionaryModel.FOLDER_TYPE_ID) ? typeId.getId() : cmisMapping.buildPrefixEncodedString(typeId.getQName(), false);
|
||||
displayName = (cmisClassDef.getTitle() != null) ? cmisClassDef.getTitle() : typeId.getId();
|
||||
QName parentQName = cmisMapping.getCmisType(cmisClassDef.getParentName());
|
||||
if (cmisMapping.isValidCmisFolder(parentQName))
|
||||
{
|
||||
parentTypeId = cmisMapping.getCmisTypeId(CMISScope.FOLDER, parentQName);
|
||||
}
|
||||
description = cmisClassDef.getDescription();
|
||||
|
||||
QName parentQName = cmisMapping.getCmisType(cmisClassDef.getParentName());
|
||||
if (typeId == CMISDictionaryModel.FOLDER_TYPE_ID)
|
||||
{
|
||||
objectTypeQueryName = typeId.getId();
|
||||
if (parentQName != null)
|
||||
{
|
||||
parentTypeId = cmisMapping.getCmisTypeId(CMISScope.OBJECT, parentQName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
objectTypeQueryName = cmisMapping.buildPrefixEncodedString(typeId.getQName(), false);
|
||||
if (cmisMapping.isValidCmisFolder(parentQName))
|
||||
{
|
||||
parentTypeId = cmisMapping.getCmisTypeId(CMISScope.FOLDER, parentQName);
|
||||
}
|
||||
}
|
||||
|
||||
creatable = true;
|
||||
queryable = true;
|
||||
controllable = false;
|
||||
|
@@ -59,7 +59,10 @@ public class CMISMapping
|
||||
* The QName for the Alfresco CMIS Model.
|
||||
*/
|
||||
public static QName CMIS_MODEL_QNAME = QName.createQName(CMIS_MODEL_URI, CMIS_MODEL_NAME);
|
||||
|
||||
|
||||
// CMIS Internal Types
|
||||
public static String OBJECT_OBJECT_TYPE = "Object";
|
||||
public static String FILESYSTEM_OBJECT_TYPE ="FileSystemObject";
|
||||
|
||||
// CMIS Data Types
|
||||
public static QName CMIS_DATATYPE_ID = QName.createQName(CMIS_MODEL_URI, "id");
|
||||
@@ -68,11 +71,17 @@ public class CMISMapping
|
||||
public static QName CMIS_DATATYPE_HTML = QName.createQName(CMIS_MODEL_URI, "html");
|
||||
|
||||
// CMIS Types
|
||||
public static QName OBJECT_QNAME = QName.createQName(CMIS_MODEL_URI, OBJECT_OBJECT_TYPE);
|
||||
public static QName FILESYSTEM_OBJECT_QNAME = QName.createQName(CMIS_MODEL_URI, FILESYSTEM_OBJECT_TYPE);
|
||||
public static QName DOCUMENT_QNAME = QName.createQName(CMIS_MODEL_URI, CMISDictionaryModel.DOCUMENT_OBJECT_TYPE);
|
||||
public static QName FOLDER_QNAME = QName.createQName(CMIS_MODEL_URI, CMISDictionaryModel.FOLDER_OBJECT_TYPE);
|
||||
public static QName RELATIONSHIP_QNAME = QName.createQName(CMIS_MODEL_URI, CMISDictionaryModel.RELATIONSHIP_OBJECT_TYPE);
|
||||
public static QName POLICY_QNAME = QName.createQName(CMIS_MODEL_URI, CMISDictionaryModel.POLICY_OBJECT_TYPE);
|
||||
|
||||
// CMIS Internal Type Ids
|
||||
public static CMISTypeId OBJECT_TYPE_ID = new CMISTypeId(CMISScope.OBJECT, OBJECT_OBJECT_TYPE.toLowerCase(), OBJECT_QNAME);
|
||||
public static CMISTypeId FILESYSTEM_OBJECT_TYPE_ID = new CMISTypeId(CMISScope.OBJECT, FILESYSTEM_OBJECT_TYPE.toLowerCase(), FILESYSTEM_OBJECT_QNAME);
|
||||
|
||||
// Properties
|
||||
public static QName PROP_OBJECT_ID_QNAME = QName.createQName(CMIS_MODEL_URI, CMISDictionaryModel.PROP_OBJECT_ID);
|
||||
|
||||
@@ -90,6 +99,8 @@ public class CMISMapping
|
||||
*/
|
||||
static
|
||||
{
|
||||
qNameToCmisTypeId.put(OBJECT_QNAME, OBJECT_TYPE_ID);
|
||||
qNameToCmisTypeId.put(FILESYSTEM_OBJECT_QNAME, FILESYSTEM_OBJECT_TYPE_ID);
|
||||
qNameToCmisTypeId.put(DOCUMENT_QNAME, CMISDictionaryModel.DOCUMENT_TYPE_ID);
|
||||
qNameToCmisTypeId.put(FOLDER_QNAME, CMISDictionaryModel.FOLDER_TYPE_ID);
|
||||
qNameToCmisTypeId.put(RELATIONSHIP_QNAME, CMISDictionaryModel.RELATIONSHIP_TYPE_ID);
|
||||
@@ -195,6 +206,14 @@ public class CMISMapping
|
||||
{
|
||||
return CMISDictionaryModel.POLICY_TYPE_ID;
|
||||
}
|
||||
else if (typeId.equalsIgnoreCase(OBJECT_TYPE_ID.getId()))
|
||||
{
|
||||
return OBJECT_TYPE_ID;
|
||||
}
|
||||
else if (typeId.equalsIgnoreCase(FILESYSTEM_OBJECT_TYPE_ID.getId()))
|
||||
{
|
||||
return FILESYSTEM_OBJECT_TYPE_ID;
|
||||
}
|
||||
|
||||
// Is it an Alfresco type id?
|
||||
if (typeId.length() < 4 || typeId.charAt(1) != '/')
|
||||
@@ -255,6 +274,14 @@ public class CMISMapping
|
||||
{
|
||||
return getCmisTypeId(CMISScope.POLICY, classQName);
|
||||
}
|
||||
if (classQName.equals(CMISMapping.OBJECT_QNAME))
|
||||
{
|
||||
return getCmisTypeId(CMISScope.OBJECT, classQName);
|
||||
}
|
||||
if (classQName.equals(CMISMapping.FILESYSTEM_OBJECT_QNAME))
|
||||
{
|
||||
return getCmisTypeId(CMISScope.OBJECT, classQName);
|
||||
}
|
||||
if (isValidCmisDocument(classQName))
|
||||
{
|
||||
return getCmisTypeId(CMISScope.DOCUMENT, classQName);
|
||||
@@ -398,7 +425,8 @@ public class CMISMapping
|
||||
}
|
||||
|
||||
if (aspectDef.getName().equals(ContentModel.ASPECT_VERSIONABLE) ||
|
||||
aspectDef.getName().equals(ContentModel.ASPECT_AUDITABLE))
|
||||
aspectDef.getName().equals(ContentModel.ASPECT_AUDITABLE) ||
|
||||
aspectDef.getName().equals(ContentModel.ASPECT_REFERENCEABLE))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@@ -26,7 +26,7 @@ package org.alfresco.cmis.dictionary;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.alfresco.cmis.dictionary.AbstractCMISDictionaryService.DictionaryRegistry;
|
||||
import org.alfresco.cmis.dictionary.CMISAbstractDictionaryService.DictionaryRegistry;
|
||||
import org.alfresco.service.cmr.dictionary.ClassDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
@@ -37,7 +37,7 @@ import org.alfresco.service.namespace.QName;
|
||||
*
|
||||
* @author davidc
|
||||
*/
|
||||
public class CMISPolicyTypeDefinition extends CMISObjectTypeDefinition
|
||||
public class CMISPolicyTypeDefinition extends CMISAbstractTypeDefinition
|
||||
{
|
||||
private static final long serialVersionUID = 1621538303752395828L;
|
||||
|
||||
@@ -50,12 +50,20 @@ public class CMISPolicyTypeDefinition extends CMISObjectTypeDefinition
|
||||
*/
|
||||
public CMISPolicyTypeDefinition(CMISMapping cmisMapping, CMISTypeId typeId, ClassDefinition cmisClassDef)
|
||||
{
|
||||
isPublic = true;
|
||||
|
||||
// Object Type definitions
|
||||
this.cmisClassDef = cmisClassDef;
|
||||
objectTypeId = typeId;
|
||||
displayName = (cmisClassDef.getTitle() != null) ? cmisClassDef.getTitle() : typeId.getId();
|
||||
if (typeId == CMISDictionaryModel.POLICY_TYPE_ID)
|
||||
{
|
||||
objectTypeQueryName = typeId.getId();
|
||||
QName parentQName = cmisMapping.getCmisType(cmisClassDef.getParentName());
|
||||
if (parentQName != null)
|
||||
{
|
||||
parentTypeId = cmisMapping.getCmisTypeId(CMISScope.OBJECT, parentQName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -98,6 +106,10 @@ public class CMISPolicyTypeDefinition extends CMISObjectTypeDefinition
|
||||
{
|
||||
// NOTE: Force no inheritance of base Policy type
|
||||
inheritedProperties.putAll(properties);
|
||||
ownedProperties.putAll(properties);
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Type " + objectTypeId + " properties: " + inheritedProperties.size() + ", owned: " + ownedProperties.size());
|
||||
}
|
||||
|
||||
/*
|
||||
|
@@ -29,7 +29,7 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.cmis.dictionary.AbstractCMISDictionaryService.DictionaryRegistry;
|
||||
import org.alfresco.cmis.dictionary.CMISAbstractDictionaryService.DictionaryRegistry;
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.service.cmr.dictionary.AssociationDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.ClassDefinition;
|
||||
@@ -42,7 +42,7 @@ import org.alfresco.service.namespace.QName;
|
||||
*
|
||||
* @author davidc
|
||||
*/
|
||||
public class CMISRelationshipTypeDefinition extends CMISObjectTypeDefinition
|
||||
public class CMISRelationshipTypeDefinition extends CMISAbstractTypeDefinition
|
||||
{
|
||||
private static final long serialVersionUID = 5291428171784061346L;
|
||||
|
||||
@@ -65,6 +65,7 @@ public class CMISRelationshipTypeDefinition extends CMISObjectTypeDefinition
|
||||
*/
|
||||
public CMISRelationshipTypeDefinition(CMISMapping cmisMapping, CMISTypeId typeId, ClassDefinition cmisClassDef, AssociationDefinition assocDef)
|
||||
{
|
||||
isPublic = true;
|
||||
this.cmisClassDef = cmisClassDef;
|
||||
objectTypeId = typeId;
|
||||
creatable = false;
|
||||
@@ -76,7 +77,11 @@ public class CMISRelationshipTypeDefinition extends CMISObjectTypeDefinition
|
||||
// TODO: Add CMIS Association mapping??
|
||||
displayName = (cmisClassDef.getTitle() != null) ? cmisClassDef.getTitle() : typeId.getId();
|
||||
objectTypeQueryName = typeId.getId();
|
||||
parentTypeId = null;
|
||||
QName parentQName = cmisMapping.getCmisType(cmisClassDef.getParentName());
|
||||
if (parentQName != null)
|
||||
{
|
||||
parentTypeId = cmisMapping.getCmisTypeId(CMISScope.OBJECT, parentQName);
|
||||
}
|
||||
description = cmisClassDef.getDescription();
|
||||
}
|
||||
else
|
||||
@@ -87,13 +92,13 @@ public class CMISRelationshipTypeDefinition extends CMISObjectTypeDefinition
|
||||
description = assocDef.getDescription();
|
||||
|
||||
CMISTypeId sourceTypeId = cmisMapping.getCmisTypeId(cmisMapping.getCmisType(assocDef.getSourceClass().getName()));
|
||||
if (sourceTypeId != null && (sourceTypeId.getScope() == CMISScope.DOCUMENT || sourceTypeId.getScope() == CMISScope.FOLDER))
|
||||
if (sourceTypeId != null)
|
||||
{
|
||||
allowedSourceTypeIds.add(sourceTypeId);
|
||||
}
|
||||
|
||||
CMISTypeId targetTypeId = cmisMapping.getCmisTypeId(cmisMapping.getCmisType(assocDef.getTargetClass().getName()));
|
||||
if (targetTypeId != null && (targetTypeId.getScope() == CMISScope.DOCUMENT || targetTypeId.getScope() == CMISScope.FOLDER))
|
||||
if (targetTypeId != null)
|
||||
{
|
||||
allowedTargetTypeIds.add(targetTypeId);
|
||||
}
|
||||
@@ -145,21 +150,27 @@ public class CMISRelationshipTypeDefinition extends CMISObjectTypeDefinition
|
||||
super.resolveDependencies(registry);
|
||||
for (CMISTypeId sourceTypeId : allowedSourceTypeIds)
|
||||
{
|
||||
CMISTypeDefinition type = registry.typeDefsByTypeId.get(sourceTypeId);
|
||||
CMISTypeDefinition type = registry.objectDefsByTypeId.get(sourceTypeId);
|
||||
if (type == null)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Failed to retrieve allowed source type for type id " + sourceTypeId);
|
||||
}
|
||||
allowedSourceTypes.add(type);
|
||||
if (type.isPublic() == isPublic)
|
||||
{
|
||||
allowedSourceTypes.add(type);
|
||||
}
|
||||
}
|
||||
for (CMISTypeId targetTypeId : allowedTargetTypeIds)
|
||||
{
|
||||
CMISTypeDefinition type = registry.typeDefsByTypeId.get(targetTypeId);
|
||||
CMISTypeDefinition type = registry.objectDefsByTypeId.get(targetTypeId);
|
||||
if (type == null)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Failed to retrieve allowed target type for type id " + targetTypeId);
|
||||
}
|
||||
allowedTargetTypes.add(registry.typeDefsByTypeId.get(targetTypeId));
|
||||
if (type.isPublic() == isPublic)
|
||||
{
|
||||
allowedTargetTypes.add(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,10 +184,10 @@ public class CMISRelationshipTypeDefinition extends CMISObjectTypeDefinition
|
||||
super.resolveInheritance(registry);
|
||||
inheritedAllowedSourceTypes.addAll(allowedSourceTypes);
|
||||
inheritedAllowedTargetTypes.addAll(allowedTargetTypes);
|
||||
if (parentType != null)
|
||||
if (internalParentType != null)
|
||||
{
|
||||
inheritedAllowedSourceTypes.addAll(parentType.getAllowedSourceTypes());
|
||||
inheritedAllowedTargetTypes.addAll(parentType.getAllowedTargetTypes());
|
||||
inheritedAllowedSourceTypes.addAll(internalParentType.getAllowedSourceTypes());
|
||||
inheritedAllowedTargetTypes.addAll(internalParentType.getAllowedTargetTypes());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -38,7 +38,7 @@ import org.alfresco.service.namespace.QName;
|
||||
*
|
||||
* @author davidc
|
||||
*/
|
||||
public class CMISStrictDictionaryService extends AbstractCMISDictionaryService
|
||||
public class CMISStrictDictionaryService extends CMISAbstractDictionaryService
|
||||
{
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
@@ -73,7 +73,7 @@ public class CMISStrictDictionaryService extends AbstractCMISDictionaryService
|
||||
|
||||
// create appropriate kind of type definition
|
||||
ClassDefinition classDef = dictionaryService.getClass(cmisMapping.getCmisType(typeId.getQName()));
|
||||
CMISObjectTypeDefinition objectTypeDef = null;
|
||||
CMISAbstractTypeDefinition objectTypeDef = null;
|
||||
if (typeId.getScope() == CMISScope.DOCUMENT)
|
||||
{
|
||||
objectTypeDef = new CMISDocumentTypeDefinition(cmisMapping, typeId, classDef);
|
||||
@@ -91,6 +91,10 @@ public class CMISStrictDictionaryService extends AbstractCMISDictionaryService
|
||||
{
|
||||
objectTypeDef = new CMISPolicyTypeDefinition(cmisMapping, typeId, classDef);
|
||||
}
|
||||
else if (typeId.getScope() == CMISScope.OBJECT)
|
||||
{
|
||||
objectTypeDef = new CMISObjectTypeDefinition(cmisMapping, typeId, classDef, false);
|
||||
}
|
||||
|
||||
registry.registerTypeDefinition(objectTypeDef);
|
||||
}
|
||||
@@ -112,7 +116,7 @@ public class CMISStrictDictionaryService extends AbstractCMISDictionaryService
|
||||
// create appropriate kind of type definition
|
||||
CMISTypeId typeId = cmisMapping.getCmisTypeId(CMISScope.RELATIONSHIP, classQName);
|
||||
AssociationDefinition assocDef = dictionaryService.getAssociation(classQName);
|
||||
CMISObjectTypeDefinition objectTypeDef = new CMISRelationshipTypeDefinition(cmisMapping, typeId, null, assocDef);
|
||||
CMISAbstractTypeDefinition objectTypeDef = new CMISRelationshipTypeDefinition(cmisMapping, typeId, null, assocDef);
|
||||
|
||||
registry.registerTypeDefinition(objectTypeDef);
|
||||
}
|
||||
|
@@ -36,6 +36,11 @@ import org.alfresco.cmis.CMISContentStreamAllowedEnum;
|
||||
*/
|
||||
public interface CMISTypeDefinition
|
||||
{
|
||||
/**
|
||||
* @return true => type definition is for public consumption
|
||||
*/
|
||||
public boolean isPublic();
|
||||
|
||||
/**
|
||||
* Get the unique identifier for the type
|
||||
*
|
||||
@@ -60,17 +65,24 @@ public interface CMISTypeDefinition
|
||||
public String getDisplayName();
|
||||
|
||||
/**
|
||||
* Get the type id for the parent
|
||||
* Get the type for the parent
|
||||
*
|
||||
* @return - the parent type id
|
||||
*/
|
||||
public CMISTypeDefinition getParentType();
|
||||
|
||||
/**
|
||||
* Get the sub-types
|
||||
*
|
||||
* @param descendants
|
||||
* @return
|
||||
*/
|
||||
public Collection<CMISTypeDefinition> getSubTypes(boolean descendants);
|
||||
|
||||
/**
|
||||
* Get the root type id
|
||||
* @return - the root type id
|
||||
* Get the root type
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public CMISTypeDefinition getRootType();
|
||||
|
||||
@@ -146,10 +158,17 @@ public interface CMISTypeDefinition
|
||||
public Collection<CMISTypeDefinition> getAllowedTargetTypes();
|
||||
|
||||
/**
|
||||
* Gets the property definitions for this type
|
||||
* Gets the property definitions for this type (owned and inherited)
|
||||
*
|
||||
* @return property definitions
|
||||
*/
|
||||
public Map<CMISPropertyId, CMISPropertyDefinition> getPropertyDefinitions();
|
||||
|
||||
/**
|
||||
* Gets the property definitions owned by this type
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<CMISPropertyId, CMISPropertyDefinition> getOwnedPropertyDefinitions();
|
||||
|
||||
}
|
||||
|
@@ -100,6 +100,8 @@ public class CMISTypeId implements Serializable
|
||||
return CMISDictionaryModel.RELATIONSHIP_TYPE_ID;
|
||||
case POLICY:
|
||||
return CMISDictionaryModel.POLICY_TYPE_ID;
|
||||
case OBJECT:
|
||||
return CMISMapping.OBJECT_TYPE_ID;
|
||||
case UNKNOWN:
|
||||
default:
|
||||
return null;
|
||||
|
Reference in New Issue
Block a user