mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged DEV/SWIFT to HEAD
26373: WIP: ALF-7339: RSOLR 009: Index track and build from SOLR - track content, track dates, basic sorting 26388: WIP: ALF-7339: RSOLR 009: Index track and build from SOLR - basic tracking of d:text and d:mltext (not dual tokenisation and identifier support) 26527: WIP ALF-7339: RSOLR 009: Index track and build from SOLR - track d:content, d:mltext, d:text - start of cross locale search and ordering support int the index (not at query time yet) - no dual tokenisation support yet - currently adding all fields for tokenized BOTH - .sort needs additional tokenisation support to use a different separator (\u0000 used to indicate locale and split stuff - better toe use {en}woof style with \u0000 split 26822: ALF-8166: RINF 10: treenode.get.js - tweak to use "childFileFolders" 26825: ALF-8133: RINF 10: ScriptNode - update "childByNamePath" to use optimised NodeService.getChildByName 26850: ALF-8133: RINF 10: ScriptNode - update "childByNamePath" to use optimised NodeService.getChildByName - follow-on to r26825 26862: ALF-8110: RINF 10: doclist.get.js - update "path" filter to use DB-based queries (by default) - milestone check-in for review and comparison (note: sorting will be pushed down as part of paging support in lower layers) 26872: Updated SOLR dev env 26915: ALF-8224: part 1: encapsulate cmis dictionary for SOLR usage 27017: Javadoc: removed uncommented param 27018: Added 'namePattern' property to NamedObjectRegistry to enforce naming conventions where required 27019: CannedQuery interface and related infrastructure - Provides basic support for query, sort, filter and page - CannedQueryFactory allows more complex implementations where required - Should be enough of a starter for tasks requiring miscellaneous queries - ALF-7167: Canned queries 27037: WCM QS Needs the Web-Client, so define the dependency to Eclipse 27041: Move WCM-QS test setup to a common base class 27044: Start to conver the WCM QS behaviour from JS to Java 27080: Added comment section for NodeLocator script declarations 27081: General cleanup: Removed non-javadocs, empty javadocs, unused code, etc 27104: Fixed ALF-7476: Typo in output from MMT 27114: ALF-7479: RSOLR 016: Query Handler ALF-7480: RSOLR 017: SOLR result set ALF-7481: RSOLR 018: Execute query against SOLR - First working stack git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@28286 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,658 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.opencmis.dictionary;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.opencmis.CMISActionEvaluator;
|
||||
import org.alfresco.opencmis.dictionary.CMISAbstractDictionaryService.DictionaryRegistry;
|
||||
import org.alfresco.opencmis.mapping.AbstractProperty;
|
||||
import org.alfresco.opencmis.mapping.CMISMapping;
|
||||
import org.alfresco.opencmis.mapping.DirectProperty;
|
||||
import org.alfresco.repo.dictionary.IndexTokenisationMode;
|
||||
import org.alfresco.repo.dictionary.constraint.ListOfValuesConstraint;
|
||||
import org.alfresco.repo.dictionary.constraint.NumericRangeConstraint;
|
||||
import org.alfresco.repo.dictionary.constraint.StringLengthConstraint;
|
||||
import org.alfresco.repo.search.impl.lucene.analysis.DateAnalyser;
|
||||
import org.alfresco.repo.search.impl.lucene.analysis.DateTimeAnalyser;
|
||||
import org.alfresco.repo.search.impl.lucene.analysis.DoubleAnalyser;
|
||||
import org.alfresco.repo.search.impl.lucene.analysis.FloatAnalyser;
|
||||
import org.alfresco.repo.search.impl.lucene.analysis.IntegerAnalyser;
|
||||
import org.alfresco.repo.search.impl.lucene.analysis.LongAnalyser;
|
||||
import org.alfresco.repo.search.impl.lucene.analysis.PathAnalyser;
|
||||
import org.alfresco.repo.search.impl.lucene.analysis.VerbatimAnalyser;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.dictionary.ClassDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.Constraint;
|
||||
import org.alfresco.service.cmr.dictionary.ConstraintDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.apache.chemistry.abdera.ext.utils.ISO8601DateFormat;
|
||||
import org.apache.chemistry.opencmis.commons.PropertyIds;
|
||||
import org.apache.chemistry.opencmis.commons.definitions.Choice;
|
||||
import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
|
||||
import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
|
||||
import org.apache.chemistry.opencmis.commons.enums.Action;
|
||||
import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
|
||||
import org.apache.chemistry.opencmis.commons.enums.Cardinality;
|
||||
import org.apache.chemistry.opencmis.commons.enums.PropertyType;
|
||||
import org.apache.chemistry.opencmis.commons.enums.Updatability;
|
||||
import org.apache.chemistry.opencmis.commons.impl.dataobjects.AbstractPropertyDefinition;
|
||||
import org.apache.chemistry.opencmis.commons.impl.dataobjects.AbstractTypeDefinition;
|
||||
import org.apache.chemistry.opencmis.commons.impl.dataobjects.ChoiceImpl;
|
||||
import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyBooleanDefinitionImpl;
|
||||
import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyDateTimeDefinitionImpl;
|
||||
import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyDecimalDefinitionImpl;
|
||||
import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyHtmlDefinitionImpl;
|
||||
import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyIdDefinitionImpl;
|
||||
import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyIntegerDefinitionImpl;
|
||||
import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyStringDefinitionImpl;
|
||||
import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyUriDefinitionImpl;
|
||||
|
||||
/**
|
||||
* Base class for type definition wrappers.
|
||||
*
|
||||
* @author florian.mueller
|
||||
*/
|
||||
public abstract class AbstractTypeDefinitionWrapper implements TypeDefinitionWrapper, Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
protected AbstractTypeDefinition typeDef;
|
||||
protected AbstractTypeDefinition typeDefInclProperties;
|
||||
|
||||
protected TypeDefinitionWrapper parent;
|
||||
protected List<TypeDefinitionWrapper> children;
|
||||
|
||||
protected QName alfrescoName = null;
|
||||
protected QName alfrescoClass = null;
|
||||
protected Map<Action, CMISActionEvaluator<? extends Object>> actionEvaluators;
|
||||
|
||||
protected Map<String, PropertyDefintionWrapper> propertiesById = new HashMap<String, PropertyDefintionWrapper>();
|
||||
protected Map<String, PropertyDefintionWrapper> propertiesByQueryName = new HashMap<String, PropertyDefintionWrapper>();
|
||||
protected Map<QName, PropertyDefintionWrapper> propertiesByQName = new HashMap<QName, PropertyDefintionWrapper>();
|
||||
|
||||
// interface
|
||||
|
||||
public TypeDefinition getTypeDefinition(boolean includePropertyDefinitions)
|
||||
{
|
||||
if (includePropertyDefinitions)
|
||||
{
|
||||
return typeDefInclProperties;
|
||||
} else
|
||||
{
|
||||
return typeDef;
|
||||
}
|
||||
}
|
||||
|
||||
protected void setTypeDefinition(AbstractTypeDefinition typeDef, AbstractTypeDefinition typeDefInclProperties)
|
||||
{
|
||||
this.typeDef = typeDef;
|
||||
this.typeDefInclProperties = typeDefInclProperties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeId()
|
||||
{
|
||||
return typeDef.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseTypeId getBaseTypeId()
|
||||
{
|
||||
return typeDef.getBaseTypeId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBaseType()
|
||||
{
|
||||
return typeDef.getId().equals(typeDef.getBaseTypeId().value());
|
||||
}
|
||||
|
||||
@Override
|
||||
public QName getAlfrescoName()
|
||||
{
|
||||
return alfrescoName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public QName getAlfrescoClass()
|
||||
{
|
||||
return alfrescoClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeDefinitionWrapper getParent()
|
||||
{
|
||||
return parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TypeDefinitionWrapper> getChildren()
|
||||
{
|
||||
return children;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Action, CMISActionEvaluator<? extends Object>> getActionEvaluators()
|
||||
{
|
||||
return actionEvaluators;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<PropertyDefintionWrapper> getProperties()
|
||||
{
|
||||
return propertiesById.values();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PropertyDefintionWrapper getPropertyById(String propertyId)
|
||||
{
|
||||
return propertiesById.get(propertyId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PropertyDefintionWrapper getPropertyByQueryName(String queryName)
|
||||
{
|
||||
return propertiesByQueryName.get(queryName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PropertyDefintionWrapper getPropertyByQName(QName name)
|
||||
{
|
||||
return propertiesByQName.get(name);
|
||||
}
|
||||
|
||||
// create
|
||||
|
||||
public abstract void connectParentAndSubTypes(CMISMapping cmisMapping, DictionaryRegistry registry,
|
||||
DictionaryService dictionaryService);
|
||||
|
||||
public abstract void resolveInheritance(CMISMapping cmisMapping, ServiceRegistry serviceRegistry,
|
||||
DictionaryRegistry registry, DictionaryService dictionaryService);
|
||||
|
||||
public void assertComplete()
|
||||
{
|
||||
if (typeDef == null)
|
||||
throw new IllegalStateException("typeDef is not set");
|
||||
if (typeDefInclProperties == null)
|
||||
throw new IllegalStateException("typeDefInclProperties is not set");
|
||||
if (alfrescoName == null)
|
||||
throw new IllegalStateException("alfrescoName is not set");
|
||||
if (alfrescoClass == null)
|
||||
throw new IllegalStateException("alfrescoClass is not set");
|
||||
if (propertiesById == null)
|
||||
throw new IllegalStateException("propertiesById is not set");
|
||||
if (propertiesByQueryName == null)
|
||||
throw new IllegalStateException("propertiesByQueryName is not set");
|
||||
if (propertiesByQName == null)
|
||||
throw new IllegalStateException("propertiesByQName is not set");
|
||||
if (propertiesById.size() == 0)
|
||||
throw new IllegalStateException("property map empty");
|
||||
if (propertiesById.size() != propertiesByQueryName.size())
|
||||
throw new IllegalStateException("property map mismatch");
|
||||
if (propertiesById.size() != propertiesByQName.size())
|
||||
throw new IllegalStateException("property map mismatch");
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds all property definitions owned by that type.
|
||||
*/
|
||||
protected void createOwningPropertyDefinitions(CMISMapping cmisMapping, ServiceRegistry serviceRegistry,
|
||||
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());
|
||||
|
||||
// create property definition
|
||||
propertyDefintion = createPropertyDefinition(cmisMapping, propertyId, alfrescoPropDef.getName(),
|
||||
alfrescoPropDef, false);
|
||||
|
||||
// if the datatype is not supported, the property defintion will be
|
||||
// null
|
||||
if (propertyDefintion != null)
|
||||
{
|
||||
AbstractProperty propertyAccessor = cmisMapping.getPropertyAccessor(propertyId);
|
||||
if (propertyAccessor == null)
|
||||
{
|
||||
propertyAccessor = new DirectProperty(serviceRegistry, propertyId, alfrescoPropDef.getName());
|
||||
}
|
||||
|
||||
registerProperty(new BasePropertyDefintionWrapper(propertyDefintion, alfrescoPropDef.getName(), this,
|
||||
propertyAccessor, propertyAccessor));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a property definition with this type
|
||||
*/
|
||||
protected void registerProperty(PropertyDefintionWrapper propDefWrapper)
|
||||
{
|
||||
if (propDefWrapper == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (propertiesById.containsKey(propDefWrapper.getPropertyId()))
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Property defintion " + propDefWrapper.getPropertyId()
|
||||
+ " already exists on type " + typeDef.getId());
|
||||
}
|
||||
|
||||
propertiesById.put(propDefWrapper.getPropertyId(), propDefWrapper);
|
||||
propertiesByQueryName.put(propDefWrapper.getPropertyDefinition().getQueryName(), propDefWrapper);
|
||||
propertiesByQName.put(propDefWrapper.getAlfrescoName(), propDefWrapper);
|
||||
typeDefInclProperties.addPropertyDefinition(propDefWrapper.getPropertyDefinition());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a property definition object.
|
||||
*/
|
||||
protected PropertyDefinition<?> createPropertyDefinition(CMISMapping cmisMapping, String id,
|
||||
QName alfrescoPropName, org.alfresco.service.cmr.dictionary.PropertyDefinition propDef, boolean inherited)
|
||||
{
|
||||
PropertyType datatype = cmisMapping.getDataType(propDef.getDataType());
|
||||
if (datatype == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
AbstractPropertyDefinition<?> result = null;
|
||||
|
||||
switch (datatype)
|
||||
{
|
||||
case BOOLEAN:
|
||||
result = new PropertyBooleanDefinitionImpl();
|
||||
break;
|
||||
case DATETIME:
|
||||
result = new PropertyDateTimeDefinitionImpl();
|
||||
break;
|
||||
case DECIMAL:
|
||||
result = new PropertyDecimalDefinitionImpl();
|
||||
break;
|
||||
case HTML:
|
||||
result = new PropertyHtmlDefinitionImpl();
|
||||
break;
|
||||
case ID:
|
||||
result = new PropertyIdDefinitionImpl();
|
||||
break;
|
||||
case INTEGER:
|
||||
result = new PropertyIntegerDefinitionImpl();
|
||||
break;
|
||||
case STRING:
|
||||
result = new PropertyStringDefinitionImpl();
|
||||
break;
|
||||
case URI:
|
||||
result = new PropertyUriDefinitionImpl();
|
||||
break;
|
||||
default:
|
||||
throw new RuntimeException("Unknown datatype! Spec change?");
|
||||
}
|
||||
|
||||
if (id.equals(PropertyIds.OBJECT_TYPE_ID) || id.equals(PropertyIds.SOURCE_ID)
|
||||
|| id.equals(PropertyIds.TARGET_ID))
|
||||
{
|
||||
// the CMIS spec requirement
|
||||
result.setUpdatability(Updatability.ONCREATE);
|
||||
} else
|
||||
{
|
||||
result.setUpdatability(propDef.isProtected() ? Updatability.READONLY : Updatability.READWRITE);
|
||||
}
|
||||
|
||||
result.setId(id);
|
||||
result.setLocalName(alfrescoPropName.getLocalName());
|
||||
result.setLocalNamespace(alfrescoPropName.getNamespaceURI());
|
||||
result.setDisplayName(propDef.getTitle() != null ? propDef.getTitle() : id);
|
||||
result.setDescription(propDef.getDescription() != null ? propDef.getDescription() : result.getDisplayName());
|
||||
result.setPropertyType(datatype);
|
||||
result.setCardinality(propDef.isMultiValued() ? Cardinality.MULTI : Cardinality.SINGLE);
|
||||
result.setIsInherited(inherited);
|
||||
result.setIsRequired(propDef.isMandatory());
|
||||
addDefaultValue(propDef.getDefaultValue(), result);
|
||||
|
||||
// query and order
|
||||
result.setQueryName(cmisMapping.buildPrefixEncodedString(alfrescoPropName));
|
||||
result.setIsQueryable(propDef.isIndexed());
|
||||
result.setIsOrderable(false);
|
||||
|
||||
if (result.isQueryable())
|
||||
{
|
||||
if (result.getCardinality() == Cardinality.SINGLE)
|
||||
{
|
||||
IndexTokenisationMode indexTokenisationMode = IndexTokenisationMode.TRUE;
|
||||
if (propDef.getIndexTokenisationMode() != null)
|
||||
{
|
||||
indexTokenisationMode = propDef.getIndexTokenisationMode();
|
||||
}
|
||||
|
||||
switch (indexTokenisationMode)
|
||||
{
|
||||
case BOTH:
|
||||
case FALSE:
|
||||
result.setIsOrderable(true);
|
||||
break;
|
||||
case TRUE:
|
||||
default:
|
||||
String analyserClassName = propDef.getDataType().getAnalyserClassName();
|
||||
if (propDef.getDataType().getName().equals(DataTypeDefinition.BOOLEAN))
|
||||
{
|
||||
result.setIsOrderable(true);
|
||||
} else if (analyserClassName.equals(DateTimeAnalyser.class.getCanonicalName())
|
||||
|| analyserClassName.equals(DateAnalyser.class.getCanonicalName())
|
||||
|| analyserClassName.equals(DoubleAnalyser.class.getCanonicalName())
|
||||
|| analyserClassName.equals(FloatAnalyser.class.getCanonicalName())
|
||||
|| analyserClassName.equals(IntegerAnalyser.class.getCanonicalName())
|
||||
|| analyserClassName.equals(LongAnalyser.class.getCanonicalName())
|
||||
|| analyserClassName.equals(PathAnalyser.class.getCanonicalName())
|
||||
|| analyserClassName.equals(VerbatimAnalyser.class.getCanonicalName()))
|
||||
{
|
||||
result.setIsOrderable(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// constraints and choices
|
||||
for (ConstraintDefinition constraintDef : propDef.getConstraints())
|
||||
{
|
||||
Constraint constraint = constraintDef.getConstraint();
|
||||
if (constraint instanceof ListOfValuesConstraint)
|
||||
{
|
||||
addChoiceList((ListOfValuesConstraint) constraint, result);
|
||||
}
|
||||
|
||||
if ((constraint instanceof StringLengthConstraint) && (result instanceof PropertyStringDefinitionImpl))
|
||||
{
|
||||
StringLengthConstraint slc = (StringLengthConstraint) constraint;
|
||||
((PropertyStringDefinitionImpl) result).setMaxLength(BigInteger.valueOf(slc.getMaxLength()));
|
||||
}
|
||||
|
||||
if (constraint instanceof NumericRangeConstraint)
|
||||
{
|
||||
NumericRangeConstraint nrc = (NumericRangeConstraint) constraint;
|
||||
if (result instanceof PropertyIntegerDefinitionImpl)
|
||||
{
|
||||
((PropertyIntegerDefinitionImpl) result)
|
||||
.setMinValue(BigInteger.valueOf(((Double) nrc.getMinValue()).longValue()));
|
||||
((PropertyIntegerDefinitionImpl) result)
|
||||
.setMaxValue(BigInteger.valueOf(((Double) nrc.getMaxValue()).longValue()));
|
||||
}
|
||||
if (result instanceof PropertyDecimalDefinitionImpl)
|
||||
{
|
||||
((PropertyDecimalDefinitionImpl) result).setMinValue(BigDecimal.valueOf(nrc.getMinValue()));
|
||||
((PropertyDecimalDefinitionImpl) result).setMaxValue(BigDecimal.valueOf(nrc.getMaxValue()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private <T> T convertValueFromString(String value, PropertyType datatype)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
switch (datatype)
|
||||
{
|
||||
case BOOLEAN:
|
||||
return (T) Boolean.valueOf(value);
|
||||
case DATETIME:
|
||||
GregorianCalendar cal = new GregorianCalendar();
|
||||
cal.setTime(ISO8601DateFormat.parse(value));
|
||||
return (T) cal;
|
||||
case DECIMAL:
|
||||
return (T) new BigDecimal(value);
|
||||
case HTML:
|
||||
return (T) value;
|
||||
case ID:
|
||||
return (T) value;
|
||||
case INTEGER:
|
||||
return (T) new BigInteger(value);
|
||||
case STRING:
|
||||
return (T) value;
|
||||
case URI:
|
||||
return (T) value;
|
||||
default:
|
||||
throw new RuntimeException("Unknown datatype! Spec change?");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the default value to a property definition.
|
||||
*/
|
||||
private void addDefaultValue(String value, PropertyDefinition<?> propDef)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (propDef instanceof PropertyBooleanDefinitionImpl)
|
||||
{
|
||||
PropertyBooleanDefinitionImpl propDefImpl = (PropertyBooleanDefinitionImpl) propDef;
|
||||
propDefImpl.setDefaultValue(Collections.singletonList((Boolean) convertValueFromString(value,
|
||||
PropertyType.BOOLEAN)));
|
||||
} else if (propDef instanceof PropertyDateTimeDefinitionImpl)
|
||||
{
|
||||
PropertyDateTimeDefinitionImpl propDefImpl = (PropertyDateTimeDefinitionImpl) propDef;
|
||||
propDefImpl.setDefaultValue(Collections.singletonList((GregorianCalendar) convertValueFromString(value,
|
||||
PropertyType.DATETIME)));
|
||||
} else if (propDef instanceof PropertyDecimalDefinitionImpl)
|
||||
{
|
||||
PropertyDecimalDefinitionImpl propDefImpl = (PropertyDecimalDefinitionImpl) propDef;
|
||||
propDefImpl.setDefaultValue(Collections.singletonList((BigDecimal) convertValueFromString(value,
|
||||
PropertyType.DECIMAL)));
|
||||
} else if (propDef instanceof PropertyHtmlDefinitionImpl)
|
||||
{
|
||||
PropertyHtmlDefinitionImpl propDefImpl = (PropertyHtmlDefinitionImpl) propDef;
|
||||
propDefImpl.setDefaultValue(Collections.singletonList((String) convertValueFromString(value,
|
||||
PropertyType.HTML)));
|
||||
} else if (propDef instanceof PropertyIdDefinitionImpl)
|
||||
{
|
||||
PropertyIdDefinitionImpl propDefImpl = (PropertyIdDefinitionImpl) propDef;
|
||||
propDefImpl.setDefaultValue(Collections.singletonList((String) convertValueFromString(value,
|
||||
PropertyType.ID)));
|
||||
} else if (propDef instanceof PropertyIntegerDefinitionImpl)
|
||||
{
|
||||
PropertyIntegerDefinitionImpl propDefImpl = (PropertyIntegerDefinitionImpl) propDef;
|
||||
propDefImpl.setDefaultValue(Collections.singletonList((BigInteger) convertValueFromString(value,
|
||||
PropertyType.INTEGER)));
|
||||
} else if (propDef instanceof PropertyStringDefinitionImpl)
|
||||
{
|
||||
PropertyStringDefinitionImpl propDefImpl = (PropertyStringDefinitionImpl) propDef;
|
||||
propDefImpl.setDefaultValue(Collections.singletonList((String) convertValueFromString(value,
|
||||
PropertyType.STRING)));
|
||||
} else if (propDef instanceof PropertyUriDefinitionImpl)
|
||||
{
|
||||
PropertyUriDefinitionImpl propDefImpl = (PropertyUriDefinitionImpl) propDef;
|
||||
propDefImpl.setDefaultValue(Collections.singletonList((String) convertValueFromString(value,
|
||||
PropertyType.URI)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds choices to the property defintion.
|
||||
*/
|
||||
private void addChoiceList(ListOfValuesConstraint lovc, PropertyDefinition<?> propDef)
|
||||
{
|
||||
if (propDef instanceof PropertyBooleanDefinitionImpl)
|
||||
{
|
||||
PropertyBooleanDefinitionImpl propDefImpl = (PropertyBooleanDefinitionImpl) propDef;
|
||||
propDefImpl.setIsOpenChoice(false);
|
||||
|
||||
List<Choice<Boolean>> choiceList = new ArrayList<Choice<Boolean>>();
|
||||
for (String allowed : lovc.getAllowedValues())
|
||||
{
|
||||
ChoiceImpl<Boolean> choice = new ChoiceImpl<Boolean>();
|
||||
choice.setDisplayName(allowed);
|
||||
choice.setValue(Collections.singletonList((Boolean) convertValueFromString(allowed,
|
||||
PropertyType.BOOLEAN)));
|
||||
|
||||
choiceList.add(choice);
|
||||
}
|
||||
|
||||
propDefImpl.setChoices(choiceList);
|
||||
} else if (propDef instanceof PropertyDateTimeDefinitionImpl)
|
||||
{
|
||||
PropertyDateTimeDefinitionImpl propDefImpl = (PropertyDateTimeDefinitionImpl) propDef;
|
||||
propDefImpl.setIsOpenChoice(false);
|
||||
|
||||
List<Choice<GregorianCalendar>> choiceList = new ArrayList<Choice<GregorianCalendar>>();
|
||||
for (String allowed : lovc.getAllowedValues())
|
||||
{
|
||||
ChoiceImpl<GregorianCalendar> choice = new ChoiceImpl<GregorianCalendar>();
|
||||
choice.setDisplayName(allowed);
|
||||
choice.setValue(Collections.singletonList((GregorianCalendar) convertValueFromString(allowed,
|
||||
PropertyType.DATETIME)));
|
||||
|
||||
choiceList.add(choice);
|
||||
}
|
||||
|
||||
propDefImpl.setChoices(choiceList);
|
||||
} else if (propDef instanceof PropertyDecimalDefinitionImpl)
|
||||
{
|
||||
PropertyDecimalDefinitionImpl propDefImpl = (PropertyDecimalDefinitionImpl) propDef;
|
||||
propDefImpl.setIsOpenChoice(false);
|
||||
|
||||
List<Choice<BigDecimal>> choiceList = new ArrayList<Choice<BigDecimal>>();
|
||||
for (String allowed : lovc.getAllowedValues())
|
||||
{
|
||||
ChoiceImpl<BigDecimal> choice = new ChoiceImpl<BigDecimal>();
|
||||
choice.setDisplayName(allowed);
|
||||
choice.setValue(Collections.singletonList((BigDecimal) convertValueFromString(allowed,
|
||||
PropertyType.DECIMAL)));
|
||||
|
||||
choiceList.add(choice);
|
||||
}
|
||||
|
||||
propDefImpl.setChoices(choiceList);
|
||||
} else if (propDef instanceof PropertyHtmlDefinitionImpl)
|
||||
{
|
||||
PropertyHtmlDefinitionImpl propDefImpl = (PropertyHtmlDefinitionImpl) propDef;
|
||||
propDefImpl.setIsOpenChoice(false);
|
||||
|
||||
List<Choice<String>> choiceList = new ArrayList<Choice<String>>();
|
||||
for (String allowed : lovc.getAllowedValues())
|
||||
{
|
||||
ChoiceImpl<String> choice = new ChoiceImpl<String>();
|
||||
choice.setDisplayName(allowed);
|
||||
choice.setValue(Collections.singletonList((String) convertValueFromString(allowed, PropertyType.HTML)));
|
||||
|
||||
choiceList.add(choice);
|
||||
}
|
||||
|
||||
propDefImpl.setChoices(choiceList);
|
||||
} else if (propDef instanceof PropertyIdDefinitionImpl)
|
||||
{
|
||||
PropertyIdDefinitionImpl propDefImpl = (PropertyIdDefinitionImpl) propDef;
|
||||
propDefImpl.setIsOpenChoice(false);
|
||||
|
||||
List<Choice<String>> choiceList = new ArrayList<Choice<String>>();
|
||||
for (String allowed : lovc.getAllowedValues())
|
||||
{
|
||||
ChoiceImpl<String> choice = new ChoiceImpl<String>();
|
||||
choice.setDisplayName(allowed);
|
||||
choice.setValue(Collections.singletonList((String) convertValueFromString(allowed, PropertyType.ID)));
|
||||
|
||||
choiceList.add(choice);
|
||||
}
|
||||
|
||||
propDefImpl.setChoices(choiceList);
|
||||
} else if (propDef instanceof PropertyIntegerDefinitionImpl)
|
||||
{
|
||||
PropertyIntegerDefinitionImpl propDefImpl = (PropertyIntegerDefinitionImpl) propDef;
|
||||
propDefImpl.setIsOpenChoice(false);
|
||||
|
||||
List<Choice<BigInteger>> choiceList = new ArrayList<Choice<BigInteger>>();
|
||||
for (String allowed : lovc.getAllowedValues())
|
||||
{
|
||||
ChoiceImpl<BigInteger> choice = new ChoiceImpl<BigInteger>();
|
||||
choice.setDisplayName(allowed);
|
||||
choice.setValue(Collections.singletonList((BigInteger) convertValueFromString(allowed,
|
||||
PropertyType.INTEGER)));
|
||||
|
||||
choiceList.add(choice);
|
||||
}
|
||||
|
||||
propDefImpl.setChoices(choiceList);
|
||||
} else if (propDef instanceof PropertyStringDefinitionImpl)
|
||||
{
|
||||
PropertyStringDefinitionImpl propDefImpl = (PropertyStringDefinitionImpl) propDef;
|
||||
propDefImpl.setIsOpenChoice(false);
|
||||
|
||||
List<Choice<String>> choiceList = new ArrayList<Choice<String>>();
|
||||
for (String allowed : lovc.getAllowedValues())
|
||||
{
|
||||
ChoiceImpl<String> choice = new ChoiceImpl<String>();
|
||||
choice.setDisplayName(allowed);
|
||||
choice.setValue(Collections
|
||||
.singletonList((String) convertValueFromString(allowed, PropertyType.STRING)));
|
||||
|
||||
choiceList.add(choice);
|
||||
}
|
||||
|
||||
propDefImpl.setChoices(choiceList);
|
||||
} else if (propDef instanceof PropertyUriDefinitionImpl)
|
||||
{
|
||||
PropertyUriDefinitionImpl propDefImpl = (PropertyUriDefinitionImpl) propDef;
|
||||
propDefImpl.setIsOpenChoice(false);
|
||||
|
||||
List<Choice<String>> choiceList = new ArrayList<Choice<String>>();
|
||||
for (String allowed : lovc.getAllowedValues())
|
||||
{
|
||||
ChoiceImpl<String> choice = new ChoiceImpl<String>();
|
||||
choice.setDisplayName(allowed);
|
||||
choice.setValue(Collections.singletonList((String) convertValueFromString(allowed, PropertyType.URI)));
|
||||
|
||||
choiceList.add(choice);
|
||||
}
|
||||
|
||||
propDefImpl.setChoices(choiceList);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,84 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.opencmis.dictionary;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.alfresco.cmis.CMISPropertyAccessor;
|
||||
import org.alfresco.cmis.CMISPropertyLuceneBuilder;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
|
||||
|
||||
public class BasePropertyDefintionWrapper implements PropertyDefintionWrapper, Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private PropertyDefinition<?> propDef;
|
||||
private QName alfrescoName;
|
||||
private TypeDefinitionWrapper owningType;
|
||||
private CMISPropertyAccessor accessor;
|
||||
private CMISPropertyLuceneBuilder luceneBuilder;
|
||||
|
||||
public BasePropertyDefintionWrapper(PropertyDefinition<?> propDef, QName alfrescoName,
|
||||
TypeDefinitionWrapper owningType, CMISPropertyAccessor accessor, CMISPropertyLuceneBuilder luceneBuilder)
|
||||
{
|
||||
this.propDef = propDef;
|
||||
this.alfrescoName = alfrescoName;
|
||||
this.owningType = owningType;
|
||||
this.accessor = accessor;
|
||||
this.luceneBuilder = luceneBuilder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PropertyDefinition<?> getPropertyDefinition()
|
||||
{
|
||||
return propDef;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPropertyId()
|
||||
{
|
||||
return propDef.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public QName getAlfrescoName()
|
||||
{
|
||||
return alfrescoName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeDefinitionWrapper getOwningType()
|
||||
{
|
||||
return owningType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CMISPropertyAccessor getPropertyAccessor()
|
||||
{
|
||||
return accessor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CMISPropertyLuceneBuilder getPropertyLuceneBuilder()
|
||||
{
|
||||
return luceneBuilder;
|
||||
}
|
||||
|
||||
}
|
@@ -1,428 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.opencmis.dictionary;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.opencmis.mapping.CMISMapping;
|
||||
import org.alfresco.repo.dictionary.DictionaryDAO;
|
||||
import org.alfresco.repo.dictionary.DictionaryListener;
|
||||
import org.alfresco.repo.tenant.TenantService;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
|
||||
import org.apache.chemistry.opencmis.commons.enums.PropertyType;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
import org.springframework.extensions.surf.util.AbstractLifecycleBean;
|
||||
|
||||
/**
|
||||
* Common CMIS Dictionary Support including registry of Types.
|
||||
*
|
||||
* @author davidc
|
||||
* @author florian.mueller
|
||||
*/
|
||||
public abstract class CMISAbstractDictionaryService extends AbstractLifecycleBean implements CMISDictionaryService,
|
||||
DictionaryListener
|
||||
{
|
||||
// Logger
|
||||
protected static final Log logger = LogFactory.getLog(CMISAbstractDictionaryService.class);
|
||||
|
||||
// service dependencies
|
||||
private DictionaryDAO dictionaryDAO;
|
||||
protected CMISMapping cmisMapping;
|
||||
protected DictionaryService dictionaryService;
|
||||
protected TenantService tenantService;
|
||||
protected ServiceRegistry serviceRegistry;
|
||||
|
||||
/**
|
||||
* Set the mapping service
|
||||
*
|
||||
* @param cmisMapping
|
||||
*/
|
||||
public void setOpenCMISMapping(CMISMapping cmisMapping)
|
||||
{
|
||||
this.cmisMapping = cmisMapping;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the dictionary Service
|
||||
*
|
||||
* @param dictionaryService
|
||||
*/
|
||||
public void setDictionaryService(DictionaryService dictionaryService)
|
||||
{
|
||||
this.dictionaryService = dictionaryService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the dictionary DAO
|
||||
*
|
||||
* @param dictionaryDAO
|
||||
*/
|
||||
public void setDictionaryDAO(DictionaryDAO dictionaryDAO)
|
||||
{
|
||||
this.dictionaryDAO = dictionaryDAO;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the tenant Service
|
||||
*
|
||||
* @param tenantService
|
||||
*/
|
||||
public void setTenantService(TenantService tenantService)
|
||||
{
|
||||
this.tenantService = tenantService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the service registry
|
||||
*
|
||||
* @param serviceRegistry
|
||||
*/
|
||||
public void setServiceRegistry(ServiceRegistry serviceRegistry)
|
||||
{
|
||||
this.serviceRegistry = serviceRegistry;
|
||||
}
|
||||
|
||||
/** CMIS Dictionary Registry (tenant-aware) */
|
||||
private Map<String, DictionaryRegistry> registryMap = new ConcurrentHashMap<String, DictionaryRegistry>(4);
|
||||
|
||||
/**
|
||||
* CMIS Dictionary registry
|
||||
*
|
||||
* Index of CMIS Type Definitions
|
||||
*/
|
||||
/* package */class DictionaryRegistry
|
||||
{
|
||||
// Type Definitions Index
|
||||
Map<QName, TypeDefinitionWrapper> typeDefsByQName = new HashMap<QName, TypeDefinitionWrapper>();
|
||||
Map<QName, TypeDefinitionWrapper> assocDefsByQName = new HashMap<QName, TypeDefinitionWrapper>();
|
||||
|
||||
Map<String, AbstractTypeDefinitionWrapper> typeDefsByTypeId = new HashMap<String, AbstractTypeDefinitionWrapper>();
|
||||
Map<String, TypeDefinitionWrapper> typeDefsByQueryName = new HashMap<String, TypeDefinitionWrapper>();
|
||||
List<TypeDefinitionWrapper> baseTypes = new ArrayList<TypeDefinitionWrapper>();
|
||||
|
||||
Map<String, PropertyDefintionWrapper> propDefbyPropId = new HashMap<String, PropertyDefintionWrapper>();
|
||||
Map<String, PropertyDefintionWrapper> propDefbyQueryName = new HashMap<String, PropertyDefintionWrapper>();
|
||||
|
||||
/**
|
||||
* Register type definition.
|
||||
*
|
||||
* @param typeDef
|
||||
*/
|
||||
public void registerTypeDefinition(AbstractTypeDefinitionWrapper typeDef)
|
||||
{
|
||||
AbstractTypeDefinitionWrapper existingTypeDef = typeDefsByTypeId.get(typeDef.getTypeId());
|
||||
if (existingTypeDef != null)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Type " + typeDef.getTypeId() + " already registered");
|
||||
}
|
||||
|
||||
typeDefsByTypeId.put(typeDef.getTypeId(), typeDef);
|
||||
QName typeQName = typeDef.getAlfrescoName();
|
||||
if (typeQName != null)
|
||||
{
|
||||
if ((typeDef instanceof RelationshipTypeDefintionWrapper) && !typeDef.isBaseType())
|
||||
{
|
||||
assocDefsByQName.put(typeQName, typeDef);
|
||||
} else
|
||||
{
|
||||
typeDefsByQName.put(typeQName, typeDef);
|
||||
}
|
||||
}
|
||||
|
||||
typeDefsByQueryName.put(typeDef.getTypeDefinition(false).getQueryName(), typeDef);
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Registered type " + typeDef.getTypeId() + " (scope=" + typeDef.getBaseTypeId() + ")");
|
||||
logger.debug(" QName: " + typeDef.getAlfrescoName());
|
||||
logger.debug(" Table: " + typeDef.getTypeDefinition(false).getQueryName());
|
||||
logger.debug(" Action Evaluators: " + typeDef.getActionEvaluators().size());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register property definitions.
|
||||
*
|
||||
* @param typeDef
|
||||
*/
|
||||
public void registerPropertyDefinitions(AbstractTypeDefinitionWrapper typeDef)
|
||||
{
|
||||
for (PropertyDefintionWrapper propDef : typeDef.getProperties())
|
||||
{
|
||||
if (propDef.getPropertyDefinition().isInherited())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
propDefbyPropId.put(propDef.getPropertyId(), propDef);
|
||||
propDefbyQueryName.put(propDef.getPropertyDefinition().getQueryName(), propDef);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("DictionaryRegistry[");
|
||||
builder.append("Types=").append(typeDefsByTypeId.size()).append(", ");
|
||||
builder.append("Base Types=").append(baseTypes.size()).append(", ");
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
|
||||
private DictionaryRegistry getRegistry()
|
||||
{
|
||||
String tenantDomain = tenantService.getCurrentUserDomain();
|
||||
DictionaryRegistry registry = registryMap.get(tenantDomain);
|
||||
if (registry == null)
|
||||
{
|
||||
init();
|
||||
registry = registryMap.get(tenantDomain);
|
||||
}
|
||||
return registry;
|
||||
}
|
||||
|
||||
public TypeDefinitionWrapper findType(String typeId)
|
||||
{
|
||||
return getRegistry().typeDefsByTypeId.get(typeId);
|
||||
}
|
||||
|
||||
public TypeDefinitionWrapper findTypeForClass(QName clazz, BaseTypeId... matchingScopes)
|
||||
{
|
||||
// searching for relationship
|
||||
boolean scopeByRelationship = false;
|
||||
for (BaseTypeId scope : matchingScopes)
|
||||
{
|
||||
if (scope == BaseTypeId.CMIS_RELATIONSHIP)
|
||||
{
|
||||
scopeByRelationship = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// locate type in registry
|
||||
clazz = cmisMapping.getCmisType(clazz);
|
||||
TypeDefinitionWrapper typeDef = null;
|
||||
if (scopeByRelationship)
|
||||
{
|
||||
typeDef = getRegistry().assocDefsByQName.get(clazz);
|
||||
} else
|
||||
{
|
||||
typeDef = getRegistry().typeDefsByQName.get(clazz);
|
||||
if (typeDef == null)
|
||||
{
|
||||
typeDef = getRegistry().assocDefsByQName.get(clazz);
|
||||
}
|
||||
}
|
||||
|
||||
// ensure matches one of provided matching scopes
|
||||
TypeDefinitionWrapper matchingTypeDef = (matchingScopes.length == 0) ? typeDef : null;
|
||||
if (typeDef != null)
|
||||
{
|
||||
for (BaseTypeId scope : matchingScopes)
|
||||
{
|
||||
if (typeDef.getBaseTypeId() == scope)
|
||||
{
|
||||
matchingTypeDef = typeDef;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return matchingTypeDef;
|
||||
}
|
||||
|
||||
public TypeDefinitionWrapper findNodeType(QName clazz)
|
||||
{
|
||||
return getRegistry().typeDefsByQName.get(cmisMapping.getCmisType(clazz));
|
||||
}
|
||||
|
||||
public TypeDefinitionWrapper findAssocType(QName clazz)
|
||||
{
|
||||
return getRegistry().assocDefsByQName.get(cmisMapping.getCmisType(clazz));
|
||||
}
|
||||
|
||||
public TypeDefinitionWrapper findTypeByQueryName(String queryName)
|
||||
{
|
||||
return getRegistry().typeDefsByQueryName.get(queryName);
|
||||
}
|
||||
|
||||
public QName getAlfrescoClass(QName name)
|
||||
{
|
||||
return cmisMapping.getAlfrescoClass(name);
|
||||
}
|
||||
|
||||
public PropertyDefintionWrapper findProperty(String propId)
|
||||
{
|
||||
return getRegistry().propDefbyPropId.get(propId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PropertyDefintionWrapper findPropertyByQueryName(String queryName)
|
||||
{
|
||||
return getRegistry().propDefbyQueryName.get(queryName);
|
||||
}
|
||||
|
||||
public List<TypeDefinitionWrapper> getBaseTypes()
|
||||
{
|
||||
return Collections.unmodifiableList(getRegistry().baseTypes);
|
||||
}
|
||||
|
||||
public List<TypeDefinitionWrapper> getAllTypes()
|
||||
{
|
||||
return Collections.unmodifiableList(new ArrayList<TypeDefinitionWrapper>(getRegistry().typeDefsByTypeId
|
||||
.values()));
|
||||
}
|
||||
|
||||
public PropertyType findDataType(QName dataType)
|
||||
{
|
||||
return cmisMapping.getDataType(dataType);
|
||||
}
|
||||
|
||||
public QName findAlfrescoDataType(PropertyType propertyType)
|
||||
{
|
||||
return cmisMapping.getAlfrescoDataType(propertyType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Factory for creating CMIS Definitions
|
||||
*
|
||||
* @param registry
|
||||
*/
|
||||
abstract protected void createDefinitions(DictionaryRegistry registry);
|
||||
|
||||
/**
|
||||
* Dictionary Initialization - creates a new registry
|
||||
*/
|
||||
private void init()
|
||||
{
|
||||
DictionaryRegistry registry = new DictionaryRegistry();
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Creating type definitions...");
|
||||
|
||||
// phase 1: construct type definitions and link them together
|
||||
createDefinitions(registry);
|
||||
for (AbstractTypeDefinitionWrapper objectTypeDef : registry.typeDefsByTypeId.values())
|
||||
{
|
||||
objectTypeDef.connectParentAndSubTypes(cmisMapping, registry, dictionaryService);
|
||||
}
|
||||
|
||||
// phase 2: register base types and inherit property definitions
|
||||
for (AbstractTypeDefinitionWrapper typeDef : registry.typeDefsByTypeId.values())
|
||||
{
|
||||
if (typeDef.getTypeDefinition(false).getParentTypeId() == null)
|
||||
{
|
||||
registry.baseTypes.add(typeDef);
|
||||
typeDef.resolveInheritance(cmisMapping, serviceRegistry, registry, dictionaryService);
|
||||
}
|
||||
}
|
||||
|
||||
// phase 3: register properties
|
||||
for (AbstractTypeDefinitionWrapper typeDef : registry.typeDefsByTypeId.values())
|
||||
{
|
||||
registry.registerPropertyDefinitions(typeDef);
|
||||
}
|
||||
|
||||
// phase 4: assert valid
|
||||
for (AbstractTypeDefinitionWrapper typeDef : registry.typeDefsByTypeId.values())
|
||||
{
|
||||
typeDef.assertComplete();
|
||||
}
|
||||
|
||||
// publish new registry
|
||||
registryMap.put(tenantService.getCurrentUserDomain(), registry);
|
||||
|
||||
if (logger.isInfoEnabled())
|
||||
logger.info("Initialized CMIS Dictionary. Types:" + registry.typeDefsByTypeId.size() + ", Base Types:"
|
||||
+ registry.baseTypes.size());
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.repo.dictionary.DictionaryListener#onInit()
|
||||
*/
|
||||
public void onDictionaryInit()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.repo.dictionary.DictionaryListener#afterInit()
|
||||
*/
|
||||
public void afterDictionaryInit()
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.alfresco.repo.dictionary.DictionaryListener#afterDictionaryDestroy()
|
||||
*/
|
||||
public void afterDictionaryDestroy()
|
||||
{
|
||||
registryMap.remove(tenantService.getCurrentUserDomain());
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.springframework.extensions.surf.util.AbstractLifecycleBean#onBootstrap
|
||||
* (org.springframework.context.ApplicationEvent)
|
||||
*/
|
||||
protected void onBootstrap(ApplicationEvent event)
|
||||
{
|
||||
afterDictionaryInit();
|
||||
dictionaryDAO.register(this);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.springframework.extensions.surf.util.AbstractLifecycleBean#onShutdown
|
||||
* (org.springframework.context.ApplicationEvent)
|
||||
*/
|
||||
protected void onShutdown(ApplicationEvent event)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
@@ -1,89 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.opencmis.dictionary;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
|
||||
import org.apache.chemistry.opencmis.commons.enums.PropertyType;
|
||||
|
||||
/**
|
||||
* Service to query the CMIS meta model
|
||||
*
|
||||
* @author davidc
|
||||
*/
|
||||
public interface CMISDictionaryService
|
||||
{
|
||||
/**
|
||||
* Find type for type id
|
||||
*
|
||||
* @param typeId
|
||||
* @return
|
||||
*/
|
||||
TypeDefinitionWrapper findType(String typeId);
|
||||
|
||||
/**
|
||||
* Find type for Alfresco class name. Optionally, constrain match to one of
|
||||
* specified CMIS scopes
|
||||
*
|
||||
* @param clazz
|
||||
* @param matchingScopes
|
||||
* @return
|
||||
*/
|
||||
TypeDefinitionWrapper findTypeForClass(QName clazz, BaseTypeId... matchingScopes);
|
||||
|
||||
TypeDefinitionWrapper findNodeType(QName clazz);
|
||||
|
||||
TypeDefinitionWrapper findAssocType(QName clazz);
|
||||
|
||||
PropertyDefintionWrapper findProperty(String propId);
|
||||
|
||||
PropertyDefintionWrapper findPropertyByQueryName(String queryName);
|
||||
|
||||
/**
|
||||
* Find a type by its query name
|
||||
*
|
||||
* @param queryName
|
||||
* @return
|
||||
*/
|
||||
TypeDefinitionWrapper findTypeByQueryName(String queryName);
|
||||
|
||||
/**
|
||||
* Get Base Types
|
||||
*/
|
||||
List<TypeDefinitionWrapper> getBaseTypes();
|
||||
|
||||
/**
|
||||
* Get all Types
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<TypeDefinitionWrapper> getAllTypes();
|
||||
|
||||
/**
|
||||
* Find data type
|
||||
*
|
||||
* @param dataType
|
||||
* @return
|
||||
*/
|
||||
PropertyType findDataType(QName dataType);
|
||||
|
||||
QName findAlfrescoDataType(PropertyType propertyType);
|
||||
}
|
@@ -1,117 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.opencmis.dictionary;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.alfresco.cmis.mapping.CMISMapping;
|
||||
import org.alfresco.service.cmr.dictionary.AssociationDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.ClassDefinition;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
|
||||
|
||||
/**
|
||||
* CMIS Dictionary which provides Types that strictly conform to the CMIS
|
||||
* specification.
|
||||
*
|
||||
* That is, only maps types to one of root Document, Folder, Relationship &
|
||||
* Policy.
|
||||
*
|
||||
* @author davidc
|
||||
*/
|
||||
public class CMISStrictDictionaryService extends CMISAbstractDictionaryService
|
||||
{
|
||||
|
||||
@Override
|
||||
protected void createDefinitions(DictionaryRegistry registry)
|
||||
{
|
||||
createTypeDefs(registry, dictionaryService.getAllTypes());
|
||||
createAssocDefs(registry, dictionaryService.getAllAssociations());
|
||||
createTypeDefs(registry, dictionaryService.getAllAspects());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Type Definitions
|
||||
*
|
||||
* @param registry
|
||||
* @param classQNames
|
||||
*/
|
||||
private void createTypeDefs(DictionaryRegistry registry, Collection<QName> classQNames)
|
||||
{
|
||||
for (QName classQName : classQNames)
|
||||
{
|
||||
// skip items that are remapped to CMIS model
|
||||
if (cmisMapping.isRemappedType(classQName))
|
||||
continue;
|
||||
|
||||
// create appropriate kind of type definition
|
||||
ClassDefinition classDef = dictionaryService.getClass(classQName);
|
||||
String typeId = null;
|
||||
AbstractTypeDefinitionWrapper objectTypeDef = null;
|
||||
if (cmisMapping.isValidCmisDocument(classQName))
|
||||
{
|
||||
typeId = cmisMapping.getCmisTypeId(BaseTypeId.CMIS_DOCUMENT, classQName);
|
||||
objectTypeDef = new DocumentTypeDefinitionWrapper(cmisMapping, serviceRegistry, typeId, classDef);
|
||||
} else if (cmisMapping.isValidCmisFolder(classQName))
|
||||
{
|
||||
typeId = cmisMapping.getCmisTypeId(BaseTypeId.CMIS_FOLDER, classQName);
|
||||
objectTypeDef = new FolderTypeDefintionWrapper(cmisMapping, serviceRegistry, typeId, classDef);
|
||||
} else if (cmisMapping.isValidCmisPolicy(classQName))
|
||||
{
|
||||
typeId = cmisMapping.getCmisTypeId(BaseTypeId.CMIS_POLICY, classQName);
|
||||
objectTypeDef = new PolicyTypeDefintionWrapper(cmisMapping, serviceRegistry, typeId, classDef);
|
||||
}
|
||||
|
||||
if (objectTypeDef != null)
|
||||
{
|
||||
registry.registerTypeDefinition(objectTypeDef);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Relationship Definitions
|
||||
*
|
||||
* @param registry
|
||||
* @param classQNames
|
||||
*/
|
||||
private void createAssocDefs(DictionaryRegistry registry, Collection<QName> classQNames)
|
||||
{
|
||||
// register base type
|
||||
String typeId = cmisMapping.getCmisTypeId(BaseTypeId.CMIS_RELATIONSHIP, CMISMapping.RELATIONSHIP_QNAME);
|
||||
RelationshipTypeDefintionWrapper objectTypeDef = new RelationshipTypeDefintionWrapper(cmisMapping,
|
||||
serviceRegistry, typeId, dictionaryService.getClass(CMISMapping.RELATIONSHIP_QNAME));
|
||||
|
||||
registry.registerTypeDefinition(objectTypeDef);
|
||||
|
||||
// register all other relationships
|
||||
for (QName classQName : classQNames)
|
||||
{
|
||||
if (!cmisMapping.isValidCmisRelationship(classQName))
|
||||
continue;
|
||||
|
||||
// create appropriate kind of type definition
|
||||
AssociationDefinition assocDef = dictionaryService.getAssociation(classQName);
|
||||
typeId = cmisMapping.getCmisTypeId(BaseTypeId.CMIS_RELATIONSHIP, classQName);
|
||||
objectTypeDef = new RelationshipTypeDefintionWrapper(cmisMapping, typeId, assocDef);
|
||||
|
||||
registry.registerTypeDefinition(objectTypeDef);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,85 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.opencmis.dictionary;
|
||||
|
||||
import org.alfresco.opencmis.CMISUtils;
|
||||
import org.alfresco.opencmis.mapping.CMISMapping;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.dictionary.ClassDefinition;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
|
||||
import org.apache.chemistry.opencmis.commons.enums.ContentStreamAllowed;
|
||||
import org.apache.chemistry.opencmis.commons.impl.dataobjects.DocumentTypeDefinitionImpl;
|
||||
|
||||
public class DocumentTypeDefinitionWrapper extends ShadowTypeDefinitionWrapper
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private DocumentTypeDefinitionImpl typeDef;
|
||||
private DocumentTypeDefinitionImpl typeDefInclProperties;
|
||||
|
||||
public DocumentTypeDefinitionWrapper(CMISMapping cmisMapping, ServiceRegistry serviceRegistry, String typeId,
|
||||
ClassDefinition cmisClassDef)
|
||||
{
|
||||
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(typeId);
|
||||
typeDef.setParentTypeId(null);
|
||||
} else
|
||||
{
|
||||
typeDef.setQueryName(cmisMapping.buildPrefixEncodedString(alfrescoName));
|
||||
QName parentQName = cmisMapping.getCmisType(cmisClassDef.getParentName());
|
||||
if (cmisMapping.isValidCmisDocument(parentQName))
|
||||
{
|
||||
typeDef.setParentTypeId(cmisMapping.getCmisTypeId(BaseTypeId.CMIS_DOCUMENT, parentQName));
|
||||
}
|
||||
}
|
||||
|
||||
typeDef.setDisplayName((cmisClassDef.getTitle() != null) ? cmisClassDef.getTitle() : typeId);
|
||||
typeDef.setDescription(cmisClassDef.getDescription() != null ? cmisClassDef.getDescription() : typeDef
|
||||
.getDisplayName());
|
||||
|
||||
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, serviceRegistry, cmisClassDef);
|
||||
|
||||
actionEvaluators = cmisMapping.getActionEvaluators(BaseTypeId.CMIS_DOCUMENT);
|
||||
}
|
||||
}
|
@@ -1,90 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.opencmis.dictionary;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.opencmis.CMISUtils;
|
||||
import org.alfresco.opencmis.mapping.CMISMapping;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.dictionary.ClassDefinition;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
|
||||
import org.apache.chemistry.opencmis.commons.impl.dataobjects.FolderTypeDefinitionImpl;
|
||||
|
||||
public class FolderTypeDefintionWrapper extends ShadowTypeDefinitionWrapper
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private FolderTypeDefinitionImpl typeDef;
|
||||
private FolderTypeDefinitionImpl typeDefInclProperties;
|
||||
|
||||
public FolderTypeDefintionWrapper(CMISMapping cmisMapping, ServiceRegistry serviceRegistry, String typeId,
|
||||
ClassDefinition cmisClassDef)
|
||||
{
|
||||
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(typeId);
|
||||
typeDef.setParentTypeId(null);
|
||||
} else
|
||||
{
|
||||
typeDef.setQueryName(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)
|
||||
|| serviceRegistry.getDictionaryService().isSubClass(alfrescoName, ContentModel.TYPE_SYSTEM_FOLDER))
|
||||
{
|
||||
isSystemFolder = true;
|
||||
}
|
||||
}
|
||||
|
||||
typeDef.setDisplayName((cmisClassDef.getTitle() != null) ? cmisClassDef.getTitle() : typeId);
|
||||
typeDef.setDescription(cmisClassDef.getDescription() != null ? cmisClassDef.getDescription() : typeDef
|
||||
.getDisplayName());
|
||||
|
||||
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, serviceRegistry, cmisClassDef);
|
||||
|
||||
actionEvaluators = cmisMapping.getActionEvaluators(BaseTypeId.CMIS_FOLDER);
|
||||
}
|
||||
}
|
@@ -1,195 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.opencmis.dictionary;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.opencmis.CMISUtils;
|
||||
import org.alfresco.opencmis.dictionary.CMISAbstractDictionaryService.DictionaryRegistry;
|
||||
import org.alfresco.opencmis.mapping.CMISMapping;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.dictionary.ClassDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
|
||||
import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
|
||||
import org.apache.chemistry.opencmis.commons.impl.dataobjects.PolicyTypeDefinitionImpl;
|
||||
|
||||
public class PolicyTypeDefintionWrapper extends AbstractTypeDefinitionWrapper
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private PolicyTypeDefinitionImpl typeDef;
|
||||
private PolicyTypeDefinitionImpl typeDefInclProperties;
|
||||
|
||||
public PolicyTypeDefintionWrapper(CMISMapping cmisMapping, ServiceRegistry serviceRegistry, String typeId,
|
||||
ClassDefinition cmisClassDef)
|
||||
{
|
||||
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(typeId);
|
||||
typeDef.setParentTypeId(null);
|
||||
} else
|
||||
{
|
||||
typeDef.setQueryName(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));
|
||||
}
|
||||
}
|
||||
|
||||
typeDef.setDisplayName((cmisClassDef.getTitle() != null) ? cmisClassDef.getTitle() : typeId);
|
||||
typeDef.setDescription(cmisClassDef.getDescription() != null ? cmisClassDef.getDescription() : typeDef
|
||||
.getDisplayName());
|
||||
|
||||
typeDef.setIsCreatable(false);
|
||||
typeDef.setIsQueryable(true);
|
||||
typeDef.setIsFulltextIndexed(true);
|
||||
typeDef.setIsControllablePolicy(false);
|
||||
typeDef.setIsControllableAcl(false);
|
||||
typeDef.setIsIncludedInSupertypeQuery(cmisClassDef.getIncludedInSuperTypeQuery());
|
||||
typeDef.setIsFileable(true);
|
||||
|
||||
typeDefInclProperties = CMISUtils.copy(typeDef);
|
||||
setTypeDefinition(typeDef, typeDefInclProperties);
|
||||
|
||||
createOwningPropertyDefinitions(cmisMapping, serviceRegistry, cmisClassDef);
|
||||
|
||||
actionEvaluators = cmisMapping.getActionEvaluators(BaseTypeId.CMIS_POLICY);
|
||||
}
|
||||
|
||||
public void connectParentAndSubTypes(CMISMapping cmisMapping, DictionaryRegistry registry,
|
||||
DictionaryService dictionaryService)
|
||||
{
|
||||
// find parent
|
||||
if (typeDef.getParentTypeId() != null)
|
||||
{
|
||||
parent = registry.typeDefsByTypeId.get(typeDef.getParentTypeId());
|
||||
} 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 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.typeDefsByTypeId.values())
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
for (QName childName : childrenNames)
|
||||
{
|
||||
if (cmisMapping.isValidCmisPolicy(childName))
|
||||
{
|
||||
TypeDefinitionWrapper child = registry.typeDefsByQName.get(childName);
|
||||
|
||||
if (child == null)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Failed to retrieve sub type for type id " + childName
|
||||
+ " for parent type " + getAlfrescoName() + "!");
|
||||
}
|
||||
children.add(child);
|
||||
} else
|
||||
{
|
||||
System.out.println("Not a policy: " + childName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void resolveInheritance(CMISMapping cmisMapping, ServiceRegistry serviceRegistry,
|
||||
DictionaryRegistry registry, DictionaryService dictionaryService)
|
||||
{
|
||||
PropertyDefinition<?> propertyDefintion;
|
||||
|
||||
if (parent != null)
|
||||
{
|
||||
for (PropertyDefintionWrapper propDef : parent.getProperties())
|
||||
{
|
||||
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(), alfrescoPropDef, true);
|
||||
|
||||
if (propertyDefintion != null)
|
||||
{
|
||||
registerProperty(new BasePropertyDefintionWrapper(propertyDefintion, alfrescoPropDef.getName(),
|
||||
propDef.getOwningType(), propDef.getPropertyAccessor(), propDef.getPropertyLuceneBuilder()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (TypeDefinitionWrapper child : children)
|
||||
{
|
||||
if (child instanceof AbstractTypeDefinitionWrapper)
|
||||
{
|
||||
((AbstractTypeDefinitionWrapper) child).resolveInheritance(cmisMapping, serviceRegistry, registry,
|
||||
dictionaryService);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.opencmis.dictionary;
|
||||
|
||||
import org.alfresco.cmis.CMISPropertyAccessor;
|
||||
import org.alfresco.cmis.CMISPropertyLuceneBuilder;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
|
||||
|
||||
public interface PropertyDefintionWrapper
|
||||
{
|
||||
PropertyDefinition<?> getPropertyDefinition();
|
||||
|
||||
String getPropertyId();
|
||||
|
||||
QName getAlfrescoName();
|
||||
|
||||
TypeDefinitionWrapper getOwningType();
|
||||
|
||||
CMISPropertyAccessor getPropertyAccessor();
|
||||
|
||||
CMISPropertyLuceneBuilder getPropertyLuceneBuilder();
|
||||
}
|
@@ -1,193 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.opencmis.dictionary;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.opencmis.CMISUtils;
|
||||
import org.alfresco.opencmis.dictionary.CMISAbstractDictionaryService.DictionaryRegistry;
|
||||
import org.alfresco.opencmis.mapping.CMISMapping;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.dictionary.AssociationDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.ClassDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
|
||||
import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
|
||||
import org.apache.chemistry.opencmis.commons.impl.dataobjects.RelationshipTypeDefinitionImpl;
|
||||
|
||||
public class RelationshipTypeDefintionWrapper extends AbstractTypeDefinitionWrapper
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private RelationshipTypeDefinitionImpl typeDef;
|
||||
private RelationshipTypeDefinitionImpl typeDefInclProperties;
|
||||
|
||||
public RelationshipTypeDefintionWrapper(CMISMapping cmisMapping, ServiceRegistry serviceRegistry, String typeId,
|
||||
ClassDefinition cmisClassDef)
|
||||
{
|
||||
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(typeId);
|
||||
typeDef.setParentTypeId(null);
|
||||
} else
|
||||
{
|
||||
typeDef.setQueryName(cmisMapping.buildPrefixEncodedString(alfrescoName));
|
||||
typeDef.setParentTypeId(BaseTypeId.CMIS_RELATIONSHIP.value());
|
||||
}
|
||||
|
||||
typeDef.setDisplayName(cmisClassDef.getTitle() != null ? cmisClassDef.getTitle() : typeId);
|
||||
typeDef.setDescription(cmisClassDef.getDescription() != null ? cmisClassDef.getDescription() : typeDef
|
||||
.getDisplayName());
|
||||
|
||||
typeDef.setIsCreatable(true);
|
||||
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, serviceRegistry, cmisClassDef);
|
||||
|
||||
actionEvaluators = cmisMapping.getActionEvaluators(BaseTypeId.CMIS_RELATIONSHIP);
|
||||
}
|
||||
|
||||
public RelationshipTypeDefintionWrapper(CMISMapping cmisMapping, String typeId, AssociationDefinition cmisAssocDef)
|
||||
{
|
||||
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(cmisAssocDef.getTitle() != null ? cmisAssocDef.getTitle() : typeId);
|
||||
typeDef.setDescription(cmisAssocDef.getDescription() != null ? cmisAssocDef.getDescription() : typeDef
|
||||
.getDisplayName());
|
||||
|
||||
typeDef.setIsCreatable(true);
|
||||
typeDef.setIsQueryable(false);
|
||||
typeDef.setIsFulltextIndexed(false);
|
||||
typeDef.setIsControllablePolicy(false);
|
||||
typeDef.setIsControllableAcl(false);
|
||||
typeDef.setIsIncludedInSupertypeQuery(true);
|
||||
typeDef.setIsFileable(false);
|
||||
|
||||
String sourceTypeId = cmisMapping.getCmisTypeId(cmisMapping
|
||||
.getCmisType(cmisAssocDef.getSourceClass().getName()));
|
||||
if (sourceTypeId != null)
|
||||
{
|
||||
typeDef.setAllowedSourceTypes(Collections.singletonList(sourceTypeId));
|
||||
}
|
||||
|
||||
String targetTypeId = cmisMapping.getCmisTypeId(cmisMapping
|
||||
.getCmisType(cmisAssocDef.getTargetClass().getName()));
|
||||
if (targetTypeId != null)
|
||||
{
|
||||
typeDef.setAllowedTargetTypes(Collections.singletonList(targetTypeId));
|
||||
}
|
||||
|
||||
typeDefInclProperties = CMISUtils.copy(typeDef);
|
||||
setTypeDefinition(typeDef, typeDefInclProperties);
|
||||
|
||||
actionEvaluators = cmisMapping.getActionEvaluators(BaseTypeId.CMIS_RELATIONSHIP);
|
||||
}
|
||||
|
||||
public void connectParentAndSubTypes(CMISMapping cmisMapping, DictionaryRegistry registry,
|
||||
DictionaryService dictionaryService)
|
||||
{
|
||||
// find parent
|
||||
if (typeDef.getParentTypeId() != null)
|
||||
{
|
||||
parent = registry.typeDefsByTypeId.get(typeDef.getParentTypeId());
|
||||
} else
|
||||
{
|
||||
if (!isBaseType())
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Type " + typeDef.getId() + " has no parent!");
|
||||
}
|
||||
|
||||
parent = null;
|
||||
}
|
||||
|
||||
// find children
|
||||
children = new ArrayList<TypeDefinitionWrapper>();
|
||||
if (isBaseType())
|
||||
{
|
||||
for (TypeDefinitionWrapper child : registry.assocDefsByQName.values())
|
||||
{
|
||||
children.add(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void resolveInheritance(CMISMapping cmisMapping, ServiceRegistry serviceRegistry,
|
||||
DictionaryRegistry registry, DictionaryService dictionaryService)
|
||||
{
|
||||
PropertyDefinition<?> propertyDefintion;
|
||||
|
||||
if (parent != null)
|
||||
{
|
||||
for (PropertyDefintionWrapper propDef : parent.getProperties())
|
||||
{
|
||||
org.alfresco.service.cmr.dictionary.PropertyDefinition alfrescoPropDef = dictionaryService.getProperty(
|
||||
propDef.getOwningType().getAlfrescoName(), propDef.getAlfrescoName());
|
||||
|
||||
propertyDefintion = createPropertyDefinition(cmisMapping, propDef.getPropertyId(),
|
||||
alfrescoPropDef.getName(), alfrescoPropDef, true);
|
||||
|
||||
if (propertyDefintion != null)
|
||||
{
|
||||
registerProperty(new BasePropertyDefintionWrapper(propertyDefintion, alfrescoPropDef.getName(),
|
||||
propDef.getOwningType(), propDef.getPropertyAccessor(), propDef.getPropertyLuceneBuilder()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (TypeDefinitionWrapper child : children)
|
||||
{
|
||||
if (child instanceof AbstractTypeDefinitionWrapper)
|
||||
{
|
||||
((AbstractTypeDefinitionWrapper) child).resolveInheritance(cmisMapping, serviceRegistry, registry,
|
||||
dictionaryService);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,111 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.opencmis.dictionary;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.opencmis.dictionary.CMISAbstractDictionaryService.DictionaryRegistry;
|
||||
import org.alfresco.opencmis.mapping.CMISMapping;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
|
||||
|
||||
public abstract class ShadowTypeDefinitionWrapper extends AbstractTypeDefinitionWrapper
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public void connectParentAndSubTypes(CMISMapping cmisMapping, DictionaryRegistry registry,
|
||||
DictionaryService dictionaryService)
|
||||
{
|
||||
// find parent
|
||||
if (typeDef.getParentTypeId() != null)
|
||||
{
|
||||
parent = registry.typeDefsByTypeId.get(typeDef.getParentTypeId());
|
||||
} else
|
||||
{
|
||||
if (!isBaseType())
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Type " + typeDef.getId() + " has no parent!");
|
||||
}
|
||||
|
||||
parent = null;
|
||||
}
|
||||
|
||||
// find children
|
||||
children = new ArrayList<TypeDefinitionWrapper>();
|
||||
Collection<QName> childrenNames = dictionaryService.getSubTypes(cmisMapping.getAlfrescoClass(getAlfrescoName()),
|
||||
false);
|
||||
for (QName childName : childrenNames)
|
||||
{
|
||||
if (cmisMapping.isValidCmisObject(getBaseTypeId(), childName))
|
||||
{
|
||||
TypeDefinitionWrapper child = registry.typeDefsByQName.get(childName);
|
||||
|
||||
if (child == null)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Failed to retrieve sub type for type id " + childName
|
||||
+ " for parent type " + getAlfrescoName() + "!");
|
||||
}
|
||||
children.add(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void resolveInheritance(CMISMapping cmisMapping, ServiceRegistry serviceRegistry,
|
||||
DictionaryRegistry registry, DictionaryService dictionaryService)
|
||||
{
|
||||
PropertyDefinition<?> propertyDefintion;
|
||||
|
||||
if (parent != null)
|
||||
{
|
||||
for (PropertyDefintionWrapper propDef : parent.getProperties())
|
||||
{
|
||||
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(), alfrescoPropDef, true);
|
||||
|
||||
if (propertyDefintion != null)
|
||||
{
|
||||
registerProperty(new BasePropertyDefintionWrapper(propertyDefintion, alfrescoPropDef.getName(),
|
||||
propDef.getOwningType(), propDef.getPropertyAccessor(), propDef.getPropertyLuceneBuilder()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (TypeDefinitionWrapper child : children)
|
||||
{
|
||||
if (child instanceof AbstractTypeDefinitionWrapper)
|
||||
{
|
||||
((AbstractTypeDefinitionWrapper) child).resolveInheritance(cmisMapping, serviceRegistry, registry,
|
||||
dictionaryService);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.opencmis.dictionary;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.opencmis.CMISActionEvaluator;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
|
||||
import org.apache.chemistry.opencmis.commons.enums.Action;
|
||||
import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
|
||||
|
||||
public interface TypeDefinitionWrapper
|
||||
{
|
||||
TypeDefinition getTypeDefinition(boolean includePropertyDefinitions);
|
||||
|
||||
String getTypeId();
|
||||
|
||||
BaseTypeId getBaseTypeId();
|
||||
|
||||
boolean isBaseType();
|
||||
|
||||
QName getAlfrescoName();
|
||||
|
||||
QName getAlfrescoClass();
|
||||
|
||||
TypeDefinitionWrapper getParent();
|
||||
|
||||
List<TypeDefinitionWrapper> getChildren();
|
||||
|
||||
Collection<PropertyDefintionWrapper> getProperties();
|
||||
|
||||
PropertyDefintionWrapper getPropertyById(String propertyId);
|
||||
|
||||
PropertyDefintionWrapper getPropertyByQueryName(String queryName);
|
||||
|
||||
PropertyDefintionWrapper getPropertyByQName(QName name);
|
||||
|
||||
Map<Action, CMISActionEvaluator<? extends Object>> getActionEvaluators();
|
||||
}
|
Reference in New Issue
Block a user