diff --git a/config/alfresco/cmis-api-context.xml b/config/alfresco/cmis-api-context.xml index 0c98ddb3b6..8317901cee 100644 --- a/config/alfresco/cmis-api-context.xml +++ b/config/alfresco/cmis-api-context.xml @@ -3,12 +3,9 @@ - - - - - - + + + @@ -32,22 +29,11 @@ - - - - - - - - - - - - 0.5 workspace/SpacesStore/Company Home + @@ -56,13 +42,10 @@ - + - - - - + diff --git a/source/java/org/alfresco/cmis/CMISService.java b/source/java/org/alfresco/cmis/CMISService.java index 03332ed24f..d13867ba08 100644 --- a/source/java/org/alfresco/cmis/CMISService.java +++ b/source/java/org/alfresco/cmis/CMISService.java @@ -24,10 +24,15 @@ */ package org.alfresco.cmis; +import java.io.Serializable; import java.util.HashMap; import java.util.List; import java.util.Map; +import org.alfresco.cmis.dictionary.CMISDictionaryService; +import org.alfresco.cmis.dictionary.CMISPropertyDefinition; +import org.alfresco.cmis.dictionary.CMISPropertyId; +import org.alfresco.cmis.dictionary.CMISTypeDefinition; import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.model.ContentModel; import org.alfresco.repo.model.Repository; @@ -93,6 +98,7 @@ public class CMISService implements ApplicationContextAware, ApplicationListener private Repository repository; private RetryingTransactionHelper retryingTransactionHelper; private DictionaryService dictionaryService; + private CMISDictionaryService cmisDictionaryService; private SearchService searchService; private NodeService nodeService; private TenantAdminService tenantAdminService; @@ -156,6 +162,14 @@ public class CMISService implements ApplicationContextAware, ApplicationListener this.dictionaryService = dictionaryService; } + /** + * @param cmisDictionaryService + */ + public void setCMISDictionaryService(CMISDictionaryService cmisDictionaryService) + { + this.cmisDictionaryService = cmisDictionaryService; + } + /** * @param searchService */ @@ -446,4 +460,72 @@ public class CMISService implements ApplicationContextAware, ApplicationListener } } + /** + * Get a single property + * + * @param nodeRef + * @param propertyName + * @return value + */ + public Serializable getProperty(NodeRef nodeRef, String propertyName) + { + QName typeQName = nodeService.getType(nodeRef); + CMISTypeDefinition typeDef = cmisDictionaryService.findTypeForClass(typeQName); + if (typeDef == null) + { + throw new AlfrescoRuntimeException("Type " + typeQName + " not found in CMIS Dictionary"); + } + CMISPropertyDefinition propDef = cmisDictionaryService.findProperty(propertyName, typeDef); + if (propDef == null) + { + throw new AlfrescoRuntimeException("Property " + propertyName + " not found for type " + typeDef.getTypeId() + " in CMIS Dictionary"); + } + return propDef.getPropertyAccessor().getValue(nodeRef); + } + + /** + * Get all properties + * + * @param nodeRef + * @return + */ + public Map getProperties(NodeRef nodeRef) + { + QName typeQName = nodeService.getType(nodeRef); + CMISTypeDefinition typeDef = cmisDictionaryService.findTypeForClass(typeQName); + if (typeDef == null) + { + throw new AlfrescoRuntimeException("Type " + typeQName + " not found in CMIS Dictionary"); + } + Map propDefs = typeDef.getPropertyDefinitions(); + Map values = new HashMap(propDefs.size()); + for (CMISPropertyDefinition propDef : propDefs.values()) + { + values.put(propDef.getPropertyId().getName(), propDef.getPropertyAccessor().getValue(nodeRef)); + } + return values; + } + + /** + * Set a single property + * + * @param nodeRef + * @param propertyName + * @param value + */ + public void setProperty(NodeRef nodeRef, String propertyName, Serializable value) + { + QName typeQName = nodeService.getType(nodeRef); + CMISTypeDefinition typeDef = cmisDictionaryService.findTypeForClass(typeQName); + if (typeDef == null) + { + throw new AlfrescoRuntimeException("Type " + typeQName + " not found in CMIS Dictionary"); + } + CMISPropertyDefinition propDef = cmisDictionaryService.findProperty(propertyName, typeDef); + if (propDef == null) + { + throw new AlfrescoRuntimeException("Property " + propertyName + " not found for type " + typeDef.getTypeId() + " in CMIS Dictionary"); + } + propDef.getPropertyAccessor().setValue(nodeRef, value); + } } diff --git a/source/java/org/alfresco/cmis/TypesFilter.java b/source/java/org/alfresco/cmis/TypesFilter.java deleted file mode 100644 index 791f719d1e..0000000000 --- a/source/java/org/alfresco/cmis/TypesFilter.java +++ /dev/null @@ -1,69 +0,0 @@ -package org.alfresco.cmis; - -/** - * Types Filter - * - * @author davidc - */ -public enum TypesFilter -{ - Documents, - Folders, - Policies, - Any; - - /** - * Gets the default Types filter - * - * @return default types filter - */ - public static TypesFilter getDefault() - { - return Any; - } - - /** - * Is specified Types filter valid? - * - * @param typesFilter types filter - * @return true => valid - */ - public static boolean isValid(String typesFilter) - { - try - { - TypesFilter.valueOf(typesFilter); - return true; - } - catch(IllegalArgumentException e) - { - return false; - } - catch(NullPointerException e) - { - return false; - } - } - - /** - * Resolve to a Types Filter - * - * NOTE: If specified types filter is not specified or invalid, the default types - * filter is returned - * - * @param typesFilter types filter - * @return resolved types filter - */ - public static TypesFilter toTypesFilter(String typesFilter) - { - if (isValid(typesFilter)) - { - return TypesFilter.valueOf(typesFilter); - } - else - { - return getDefault(); - } - } - -} \ No newline at end of file diff --git a/source/java/org/alfresco/cmis/dictionary/BaseCMISTest.java b/source/java/org/alfresco/cmis/dictionary/BaseCMISTest.java index 70e016705c..3ca2b44ecb 100644 --- a/source/java/org/alfresco/cmis/dictionary/BaseCMISTest.java +++ b/source/java/org/alfresco/cmis/dictionary/BaseCMISTest.java @@ -32,7 +32,7 @@ import javax.transaction.UserTransaction; import junit.framework.TestCase; import org.alfresco.cmis.CMISService; -import org.alfresco.cmis.property.CMISPropertyService; +import org.alfresco.cmis.mapping.CMISMapping; import org.alfresco.cmis.search.CMISQueryService; import org.alfresco.repo.security.authentication.AuthenticationComponent; import org.alfresco.repo.security.authentication.AuthenticationUtil; @@ -64,6 +64,8 @@ public abstract class BaseCMISTest extends TestCase protected CMISMapping cmisMapping; + protected CMISService cmisService; + protected CMISDictionaryService cmisDictionaryService; protected DictionaryService dictionaryService; @@ -74,8 +76,6 @@ public abstract class BaseCMISTest extends TestCase protected UserTransaction testTX; - protected CMISPropertyService cmisPropertyService; - protected NodeService nodeService; protected NodeRef rootNodeRef; @@ -92,8 +92,6 @@ public abstract class BaseCMISTest extends TestCase private MutableAuthenticationDao authenticationDAO; - protected CMISService cmisService; - protected SearchService searchService; protected ContentService contentService; @@ -104,7 +102,6 @@ public abstract class BaseCMISTest extends TestCase cmisDictionaryService = (CMISDictionaryService) ctx.getBean("CMISDictionaryService"); cmisMapping = (CMISMapping) ctx.getBean("CMISMapping"); - cmisPropertyService = (CMISPropertyService) ctx.getBean("CMISPropertyService"); cmisQueryService = (CMISQueryService) ctx.getBean("CMISQueryService"); cmisService = (CMISService) ctx.getBean("CMISService"); dictionaryService = (DictionaryService) ctx.getBean("dictionaryService"); diff --git a/source/java/org/alfresco/cmis/dictionary/CMISAbstractDictionaryService.java b/source/java/org/alfresco/cmis/dictionary/CMISAbstractDictionaryService.java index 90a72fb995..8f9f1f02f8 100644 --- a/source/java/org/alfresco/cmis/dictionary/CMISAbstractDictionaryService.java +++ b/source/java/org/alfresco/cmis/dictionary/CMISAbstractDictionaryService.java @@ -33,6 +33,7 @@ import java.util.Map; import java.util.TreeMap; import org.alfresco.cmis.CMISDataTypeEnum; +import org.alfresco.cmis.mapping.CMISMapping; import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.repo.dictionary.DictionaryDAO; import org.alfresco.repo.dictionary.DictionaryListener; @@ -177,6 +178,8 @@ public abstract class CMISAbstractDictionaryService extends AbstractLifecycleBea logger.debug(" QName: " + propDef.getPropertyId().getQName()); logger.debug(" Name: " + propDef.getPropertyId().getName()); logger.debug(" Owning Type: " + propDef.getOwningType().getTypeId()); + logger.debug(" Property Accessor: " + propDef.getPropertyAccessor() + " , mappedProperty=" + propDef.getPropertyAccessor().getMappedProperty()); + logger.debug(" Property Lucene Builder: " + propDef.getPropertyLuceneBuilder()); } } diff --git a/source/java/org/alfresco/cmis/dictionary/CMISAbstractTypeDefinition.java b/source/java/org/alfresco/cmis/dictionary/CMISAbstractTypeDefinition.java index d16287fc17..eecce192aa 100644 --- a/source/java/org/alfresco/cmis/dictionary/CMISAbstractTypeDefinition.java +++ b/source/java/org/alfresco/cmis/dictionary/CMISAbstractTypeDefinition.java @@ -34,8 +34,8 @@ import java.util.Map; import org.alfresco.cmis.CMISContentStreamAllowedEnum; import org.alfresco.cmis.dictionary.CMISAbstractDictionaryService.DictionaryRegistry; +import org.alfresco.cmis.mapping.CMISMapping; 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; diff --git a/source/java/org/alfresco/cmis/dictionary/CMISDictionaryModel.java b/source/java/org/alfresco/cmis/dictionary/CMISDictionaryModel.java index 8d539de0b0..8f827e44ca 100644 --- a/source/java/org/alfresco/cmis/dictionary/CMISDictionaryModel.java +++ b/source/java/org/alfresco/cmis/dictionary/CMISDictionaryModel.java @@ -24,6 +24,7 @@ */ package org.alfresco.cmis.dictionary; +import org.alfresco.cmis.mapping.CMISMapping; import org.alfresco.model.ContentModel; /** diff --git a/source/java/org/alfresco/cmis/dictionary/CMISDocumentTypeDefinition.java b/source/java/org/alfresco/cmis/dictionary/CMISDocumentTypeDefinition.java index af9f672994..d716edb634 100644 --- a/source/java/org/alfresco/cmis/dictionary/CMISDocumentTypeDefinition.java +++ b/source/java/org/alfresco/cmis/dictionary/CMISDocumentTypeDefinition.java @@ -27,6 +27,7 @@ package org.alfresco.cmis.dictionary; import java.util.List; import org.alfresco.cmis.CMISContentStreamAllowedEnum; +import org.alfresco.cmis.mapping.CMISMapping; import org.alfresco.model.ContentModel; import org.alfresco.service.cmr.dictionary.AspectDefinition; import org.alfresco.service.cmr.dictionary.ClassDefinition; diff --git a/source/java/org/alfresco/cmis/dictionary/CMISFolderTypeDefinition.java b/source/java/org/alfresco/cmis/dictionary/CMISFolderTypeDefinition.java index 52db375402..dc774cdf22 100644 --- a/source/java/org/alfresco/cmis/dictionary/CMISFolderTypeDefinition.java +++ b/source/java/org/alfresco/cmis/dictionary/CMISFolderTypeDefinition.java @@ -24,6 +24,7 @@ */ package org.alfresco.cmis.dictionary; +import org.alfresco.cmis.mapping.CMISMapping; import org.alfresco.service.cmr.dictionary.ClassDefinition; import org.alfresco.service.namespace.QName; diff --git a/source/java/org/alfresco/cmis/dictionary/CMISObjectTypeDefinition.java b/source/java/org/alfresco/cmis/dictionary/CMISObjectTypeDefinition.java index 2fc10a233e..9c9fe57aff 100644 --- a/source/java/org/alfresco/cmis/dictionary/CMISObjectTypeDefinition.java +++ b/source/java/org/alfresco/cmis/dictionary/CMISObjectTypeDefinition.java @@ -26,6 +26,7 @@ package org.alfresco.cmis.dictionary; import java.util.Collection; +import org.alfresco.cmis.mapping.CMISMapping; import org.alfresco.service.cmr.dictionary.ClassDefinition; import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.namespace.QName; diff --git a/source/java/org/alfresco/cmis/dictionary/CMISPolicyTypeDefinition.java b/source/java/org/alfresco/cmis/dictionary/CMISPolicyTypeDefinition.java index 52d9228d44..050c211968 100644 --- a/source/java/org/alfresco/cmis/dictionary/CMISPolicyTypeDefinition.java +++ b/source/java/org/alfresco/cmis/dictionary/CMISPolicyTypeDefinition.java @@ -27,6 +27,7 @@ package org.alfresco.cmis.dictionary; import java.util.Collection; import org.alfresco.cmis.dictionary.CMISAbstractDictionaryService.DictionaryRegistry; +import org.alfresco.cmis.mapping.CMISMapping; import org.alfresco.service.cmr.dictionary.ClassDefinition; import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.namespace.QName; diff --git a/source/java/org/alfresco/cmis/dictionary/CMISPropertyDefinition.java b/source/java/org/alfresco/cmis/dictionary/CMISPropertyDefinition.java index 4b343ec61b..a119e9960c 100644 --- a/source/java/org/alfresco/cmis/dictionary/CMISPropertyDefinition.java +++ b/source/java/org/alfresco/cmis/dictionary/CMISPropertyDefinition.java @@ -31,6 +31,10 @@ import java.util.HashSet; import org.alfresco.cmis.CMISCardinalityEnum; import org.alfresco.cmis.CMISDataTypeEnum; import org.alfresco.cmis.CMISUpdatabilityEnum; +import org.alfresco.cmis.mapping.CMISMapping; +import org.alfresco.cmis.property.AbstractPropertyAccessor; +import org.alfresco.cmis.property.PropertyAccessor; +import org.alfresco.cmis.property.PropertyLuceneBuilder; import org.alfresco.repo.dictionary.IndexTokenisationMode; import org.alfresco.repo.dictionary.constraint.ListOfValuesConstraint; import org.alfresco.repo.dictionary.constraint.StringLengthConstraint; @@ -71,6 +75,7 @@ public class CMISPropertyDefinition implements Serializable private CMISUpdatabilityEnum updatability; private boolean queryable; private boolean orderable; + private AbstractPropertyAccessor propertyAccessor; /** @@ -145,6 +150,7 @@ public class CMISPropertyDefinition implements Serializable { orderable = false; } + propertyAccessor = cmisMapping.getPropertyAccessor(propertyId); } /** @@ -307,6 +313,27 @@ public class CMISPropertyDefinition implements Serializable return orderable; } + /** + * Gets the property accessor (for reading / writing values) + * + * @return + */ + public PropertyAccessor getPropertyAccessor() + { + return propertyAccessor; + } + + /** + * Gets the property Lucene builder + * + * @return + */ + public PropertyLuceneBuilder getPropertyLuceneBuilder() + { + return propertyAccessor; + } + + /* * (non-Javadoc) * @see java.lang.Object#toString() @@ -319,6 +346,7 @@ public class CMISPropertyDefinition implements Serializable builder.append("OwningTypeId=").append(getOwningType().getTypeId()).append(", "); builder.append("PropertyName=").append(getPropertyId().getName()).append(", "); builder.append("PropertyId=").append(getPropertyId().getId()).append(", "); + builder.append("PropertyQName=").append(getPropertyId().getQName()).append(", "); builder.append("DisplayName=").append(getDisplayName()).append(", "); builder.append("Description=").append(getDescription()).append(", "); builder.append("PropertyType=").append(getDataType()).append(", "); diff --git a/source/java/org/alfresco/cmis/dictionary/CMISRelationshipTypeDefinition.java b/source/java/org/alfresco/cmis/dictionary/CMISRelationshipTypeDefinition.java index 62f678f390..7fb87c99d6 100644 --- a/source/java/org/alfresco/cmis/dictionary/CMISRelationshipTypeDefinition.java +++ b/source/java/org/alfresco/cmis/dictionary/CMISRelationshipTypeDefinition.java @@ -30,6 +30,7 @@ import java.util.List; import java.util.Map; import org.alfresco.cmis.dictionary.CMISAbstractDictionaryService.DictionaryRegistry; +import org.alfresco.cmis.mapping.CMISMapping; import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.service.cmr.dictionary.AssociationDefinition; import org.alfresco.service.cmr.dictionary.ClassDefinition; diff --git a/source/java/org/alfresco/cmis/dictionary/CMISTypeId.java b/source/java/org/alfresco/cmis/dictionary/CMISTypeId.java index a77bc08ba5..cb330a585e 100644 --- a/source/java/org/alfresco/cmis/dictionary/CMISTypeId.java +++ b/source/java/org/alfresco/cmis/dictionary/CMISTypeId.java @@ -26,6 +26,7 @@ package org.alfresco.cmis.dictionary; import java.io.Serializable; +import org.alfresco.cmis.mapping.CMISMapping; import org.alfresco.service.namespace.QName; /** diff --git a/source/java/org/alfresco/cmis/dictionary/CMISMapping.java b/source/java/org/alfresco/cmis/mapping/CMISMapping.java similarity index 57% rename from source/java/org/alfresco/cmis/dictionary/CMISMapping.java rename to source/java/org/alfresco/cmis/mapping/CMISMapping.java index 5059fda64a..ab8533cfd6 100644 --- a/source/java/org/alfresco/cmis/dictionary/CMISMapping.java +++ b/source/java/org/alfresco/cmis/mapping/CMISMapping.java @@ -22,28 +22,54 @@ * the FLOSS exception, and it is also available here: * http://www.alfresco.com/legal/licensing" */ -package org.alfresco.cmis.dictionary; +package org.alfresco.cmis.mapping; import java.util.Collection; import java.util.HashMap; +import java.util.Map; +import org.alfresco.cmis.CMISContentStreamAllowedEnum; import org.alfresco.cmis.CMISDataTypeEnum; +import org.alfresco.cmis.dictionary.CMISDictionaryModel; +import org.alfresco.cmis.dictionary.CMISPropertyId; +import org.alfresco.cmis.dictionary.CMISScope; +import org.alfresco.cmis.dictionary.CMISTypeId; +import org.alfresco.cmis.property.AbstractPropertyAccessor; +import org.alfresco.cmis.property.CheckinCommentPropertyAccessor; +import org.alfresco.cmis.property.ContentStreamLengthPropertyAccessor; +import org.alfresco.cmis.property.ContentStreamMimetypePropertyAccessor; +import org.alfresco.cmis.property.ContentStreamUriPropertyAccessor; +import org.alfresco.cmis.property.DirectPropertyAccessor; +import org.alfresco.cmis.property.FixedValuePropertyAccessor; +import org.alfresco.cmis.property.IsImmutablePropertyAccessor; +import org.alfresco.cmis.property.IsLatestMajorVersionPropertyAccessor; +import org.alfresco.cmis.property.IsLatestVersionPropertyAccessor; +import org.alfresco.cmis.property.IsMajorVersionPropertyAccessor; +import org.alfresco.cmis.property.IsVersionSeriesCheckedOutPropertyAccessor; +import org.alfresco.cmis.property.ObjectIdPropertyAccessor; +import org.alfresco.cmis.property.ObjectTypeIdPropertyAccessor; +import org.alfresco.cmis.property.ParentPropertyAccessor; +import org.alfresco.cmis.property.VersionSeriesCheckedOutByPropertyAccessor; +import org.alfresco.cmis.property.VersionSeriesCheckedOutIdPropertyAccessor; +import org.alfresco.cmis.property.VersionSeriesIdPropertyAccessor; import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.model.ContentModel; +import org.alfresco.service.ServiceRegistry; import org.alfresco.service.cmr.dictionary.AspectDefinition; import org.alfresco.service.cmr.dictionary.AssociationDefinition; import org.alfresco.service.cmr.dictionary.DataTypeDefinition; -import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.namespace.NamespaceException; import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; +import org.springframework.beans.factory.InitializingBean; + /** * CMIS <-> Alfresco mappings * * @author andyh */ -public class CMISMapping +public class CMISMapping implements InitializingBean { /** * The Alfresco CMIS model URI. @@ -85,100 +111,104 @@ public class CMISMapping // Properties public static QName PROP_OBJECT_ID_QNAME = QName.createQName(CMIS_MODEL_URI, CMISDictionaryModel.PROP_OBJECT_ID); + // Service Dependencies + private ServiceRegistry serviceRegistry; + // Mappings - // - no entry means no mapping and pass through as is - - private static HashMap qNameToCmisTypeId = new HashMap(); - private static HashMap cmisToAlfrecsoTypes = new HashMap(); - private static HashMap alfrescoToCmisTypes = new HashMap(); - private static HashMap alfrescoPropertyTypesToCmisPropertyTypes = new HashMap(); - + private Map mapAlfrescoQNameToTypeId = new HashMap(); + private Map mapCmisQNameToAlfrescoQName = new HashMap(); + private Map mapAlfrescoQNameToCmisQName = new HashMap(); + private Map mapAlfrescoToCmisDataType = new HashMap(); + private Map propertyAccessors = new HashMap(); - /** - * Set up mappings + + /* + * (non-Javadoc) + * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet() */ - static + public void afterPropertiesSet() throws Exception { - 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); - qNameToCmisTypeId.put(POLICY_QNAME, CMISDictionaryModel.POLICY_TYPE_ID); + mapAlfrescoQNameToTypeId.put(OBJECT_QNAME, OBJECT_TYPE_ID); + mapAlfrescoQNameToTypeId.put(FILESYSTEM_OBJECT_QNAME, FILESYSTEM_OBJECT_TYPE_ID); + mapAlfrescoQNameToTypeId.put(DOCUMENT_QNAME, CMISDictionaryModel.DOCUMENT_TYPE_ID); + mapAlfrescoQNameToTypeId.put(FOLDER_QNAME, CMISDictionaryModel.FOLDER_TYPE_ID); + mapAlfrescoQNameToTypeId.put(RELATIONSHIP_QNAME, CMISDictionaryModel.RELATIONSHIP_TYPE_ID); + mapAlfrescoQNameToTypeId.put(POLICY_QNAME, CMISDictionaryModel.POLICY_TYPE_ID); - cmisToAlfrecsoTypes.put(DOCUMENT_QNAME, ContentModel.TYPE_CONTENT); - cmisToAlfrecsoTypes.put(FOLDER_QNAME, ContentModel.TYPE_FOLDER); - cmisToAlfrecsoTypes.put(RELATIONSHIP_QNAME, null); - cmisToAlfrecsoTypes.put(POLICY_QNAME, null); + mapAlfrescoQNameToCmisQName.put(ContentModel.TYPE_CONTENT, DOCUMENT_QNAME); + mapAlfrescoQNameToCmisQName.put(ContentModel.TYPE_FOLDER, FOLDER_QNAME); - alfrescoToCmisTypes.put(ContentModel.TYPE_CONTENT, DOCUMENT_QNAME); - alfrescoToCmisTypes.put(ContentModel.TYPE_FOLDER, FOLDER_QNAME); + mapCmisQNameToAlfrescoQName.put(DOCUMENT_QNAME, ContentModel.TYPE_CONTENT); + mapCmisQNameToAlfrescoQName.put(FOLDER_QNAME, ContentModel.TYPE_FOLDER); + mapCmisQNameToAlfrescoQName.put(RELATIONSHIP_QNAME, null); + mapCmisQNameToAlfrescoQName.put(POLICY_QNAME, null); - alfrescoPropertyTypesToCmisPropertyTypes.put(DataTypeDefinition.ANY, null); - alfrescoPropertyTypesToCmisPropertyTypes.put(DataTypeDefinition.ASSOC_REF, null); - alfrescoPropertyTypesToCmisPropertyTypes.put(DataTypeDefinition.BOOLEAN, CMISDataTypeEnum.BOOLEAN); - alfrescoPropertyTypesToCmisPropertyTypes.put(DataTypeDefinition.CATEGORY, CMISDataTypeEnum.ID); - alfrescoPropertyTypesToCmisPropertyTypes.put(DataTypeDefinition.CHILD_ASSOC_REF, null); - alfrescoPropertyTypesToCmisPropertyTypes.put(DataTypeDefinition.CONTENT, null); - alfrescoPropertyTypesToCmisPropertyTypes.put(DataTypeDefinition.DATE, CMISDataTypeEnum.DATETIME); - alfrescoPropertyTypesToCmisPropertyTypes.put(DataTypeDefinition.DATETIME, CMISDataTypeEnum.DATETIME); - alfrescoPropertyTypesToCmisPropertyTypes.put(DataTypeDefinition.DOUBLE, CMISDataTypeEnum.DECIMAL); - alfrescoPropertyTypesToCmisPropertyTypes.put(DataTypeDefinition.FLOAT, CMISDataTypeEnum.DECIMAL); - alfrescoPropertyTypesToCmisPropertyTypes.put(DataTypeDefinition.INT, CMISDataTypeEnum.INTEGER); - alfrescoPropertyTypesToCmisPropertyTypes.put(DataTypeDefinition.LOCALE, null); - alfrescoPropertyTypesToCmisPropertyTypes.put(DataTypeDefinition.LONG, CMISDataTypeEnum.INTEGER); - alfrescoPropertyTypesToCmisPropertyTypes.put(DataTypeDefinition.MLTEXT, CMISDataTypeEnum.STRING); - alfrescoPropertyTypesToCmisPropertyTypes.put(DataTypeDefinition.NODE_REF, CMISDataTypeEnum.ID); - alfrescoPropertyTypesToCmisPropertyTypes.put(DataTypeDefinition.PATH, null); - alfrescoPropertyTypesToCmisPropertyTypes.put(DataTypeDefinition.QNAME, null); - alfrescoPropertyTypesToCmisPropertyTypes.put(DataTypeDefinition.TEXT, CMISDataTypeEnum.STRING); - alfrescoPropertyTypesToCmisPropertyTypes.put(CMIS_DATATYPE_ID, CMISDataTypeEnum.ID); - alfrescoPropertyTypesToCmisPropertyTypes.put(CMIS_DATATYPE_URI, CMISDataTypeEnum.URI); - alfrescoPropertyTypesToCmisPropertyTypes.put(CMIS_DATATYPE_XML, CMISDataTypeEnum.XML); - alfrescoPropertyTypesToCmisPropertyTypes.put(CMIS_DATATYPE_HTML, CMISDataTypeEnum.HTML); + mapAlfrescoToCmisDataType.put(DataTypeDefinition.ANY, null); + mapAlfrescoToCmisDataType.put(DataTypeDefinition.ASSOC_REF, null); + mapAlfrescoToCmisDataType.put(DataTypeDefinition.BOOLEAN, CMISDataTypeEnum.BOOLEAN); + mapAlfrescoToCmisDataType.put(DataTypeDefinition.CATEGORY, CMISDataTypeEnum.ID); + mapAlfrescoToCmisDataType.put(DataTypeDefinition.CHILD_ASSOC_REF, null); + mapAlfrescoToCmisDataType.put(DataTypeDefinition.CONTENT, null); + mapAlfrescoToCmisDataType.put(DataTypeDefinition.DATE, CMISDataTypeEnum.DATETIME); + mapAlfrescoToCmisDataType.put(DataTypeDefinition.DATETIME, CMISDataTypeEnum.DATETIME); + mapAlfrescoToCmisDataType.put(DataTypeDefinition.DOUBLE, CMISDataTypeEnum.DECIMAL); + mapAlfrescoToCmisDataType.put(DataTypeDefinition.FLOAT, CMISDataTypeEnum.DECIMAL); + mapAlfrescoToCmisDataType.put(DataTypeDefinition.INT, CMISDataTypeEnum.INTEGER); + mapAlfrescoToCmisDataType.put(DataTypeDefinition.LOCALE, null); + mapAlfrescoToCmisDataType.put(DataTypeDefinition.LONG, CMISDataTypeEnum.INTEGER); + mapAlfrescoToCmisDataType.put(DataTypeDefinition.MLTEXT, CMISDataTypeEnum.STRING); + mapAlfrescoToCmisDataType.put(DataTypeDefinition.NODE_REF, CMISDataTypeEnum.ID); + mapAlfrescoToCmisDataType.put(DataTypeDefinition.PATH, null); + mapAlfrescoToCmisDataType.put(DataTypeDefinition.QNAME, null); + mapAlfrescoToCmisDataType.put(DataTypeDefinition.TEXT, CMISDataTypeEnum.STRING); + mapAlfrescoToCmisDataType.put(CMIS_DATATYPE_ID, CMISDataTypeEnum.ID); + mapAlfrescoToCmisDataType.put(CMIS_DATATYPE_URI, CMISDataTypeEnum.URI); + mapAlfrescoToCmisDataType.put(CMIS_DATATYPE_XML, CMISDataTypeEnum.XML); + mapAlfrescoToCmisDataType.put(CMIS_DATATYPE_HTML, CMISDataTypeEnum.HTML); + + registerPropertyAccessor(new ObjectIdPropertyAccessor(serviceRegistry)); + registerPropertyAccessor(new FixedValuePropertyAccessor(serviceRegistry, CMISDictionaryModel.PROP_URI, null)); + registerPropertyAccessor(new ObjectTypeIdPropertyAccessor(serviceRegistry)); + registerPropertyAccessor(new DirectPropertyAccessor(serviceRegistry, CMISDictionaryModel.PROP_CREATED_BY, ContentModel.PROP_CREATOR)); + registerPropertyAccessor(new DirectPropertyAccessor(serviceRegistry, CMISDictionaryModel.PROP_CREATION_DATE, ContentModel.PROP_CREATED)); + registerPropertyAccessor(new DirectPropertyAccessor(serviceRegistry, CMISDictionaryModel.PROP_LAST_MODIFIED_BY, ContentModel.PROP_MODIFIER)); + registerPropertyAccessor(new DirectPropertyAccessor(serviceRegistry, CMISDictionaryModel.PROP_LAST_MODIFICATION_DATE, ContentModel.PROP_MODIFIED)); + registerPropertyAccessor(new FixedValuePropertyAccessor(serviceRegistry, CMISDictionaryModel.PROP_CHANGE_TOKEN, null)); + registerPropertyAccessor(new DirectPropertyAccessor(serviceRegistry, CMISDictionaryModel.PROP_NAME, ContentModel.PROP_NAME)); + registerPropertyAccessor(new IsImmutablePropertyAccessor(serviceRegistry)); + registerPropertyAccessor(new IsLatestVersionPropertyAccessor(serviceRegistry)); + registerPropertyAccessor(new IsMajorVersionPropertyAccessor(serviceRegistry)); + registerPropertyAccessor(new IsLatestMajorVersionPropertyAccessor(serviceRegistry)); + registerPropertyAccessor(new DirectPropertyAccessor(serviceRegistry, CMISDictionaryModel.PROP_VERSION_LABEL, ContentModel.PROP_VERSION_LABEL)); + registerPropertyAccessor(new VersionSeriesIdPropertyAccessor(serviceRegistry)); + registerPropertyAccessor(new IsVersionSeriesCheckedOutPropertyAccessor(serviceRegistry)); + registerPropertyAccessor(new VersionSeriesCheckedOutByPropertyAccessor(serviceRegistry)); + registerPropertyAccessor(new VersionSeriesCheckedOutIdPropertyAccessor(serviceRegistry)); + registerPropertyAccessor(new CheckinCommentPropertyAccessor(serviceRegistry)); + registerPropertyAccessor(new FixedValuePropertyAccessor(serviceRegistry, CMISDictionaryModel.PROP_CONTENT_STREAM_ALLOWED, CMISContentStreamAllowedEnum.ALLOWED.toString())); + registerPropertyAccessor(new ContentStreamLengthPropertyAccessor(serviceRegistry)); + registerPropertyAccessor(new ContentStreamMimetypePropertyAccessor(serviceRegistry)); + registerPropertyAccessor(new DirectPropertyAccessor(serviceRegistry, CMISDictionaryModel.PROP_CONTENT_STREAM_FILENAME, ContentModel.PROP_NAME)); + registerPropertyAccessor(new ContentStreamUriPropertyAccessor(serviceRegistry)); + registerPropertyAccessor(new ParentPropertyAccessor(serviceRegistry)); + registerPropertyAccessor(new FixedValuePropertyAccessor(serviceRegistry, CMISDictionaryModel.PROP_ALLOWED_CHILD_OBJECT_TYPE_IDS, null)); } - private DictionaryService dictionaryService; - private NamespaceService namespaceService; /** - * Set the dictionary Service - * - * @param dictionaryService + * @param serviceRegistry */ - public void setDictionaryService(DictionaryService dictionaryService) + public void setServiceRegistry(ServiceRegistry serviceRegistry) { - this.dictionaryService = dictionaryService; + this.serviceRegistry = serviceRegistry; } /** - * Gets the dictionary service - * - * @return dictionaryService - */ - /* package */DictionaryService getDictionaryService() - { - return this.dictionaryService; - } - - /** - * Set the namespace service - * - * @param namespaceService - */ - public void setNamespaceService(NamespaceService namespaceService) - { - this.namespaceService = namespaceService; - } - - /** - * Gets the namespace service - * * @return namespaceService */ /*package*/ NamespaceService getNamespaceService() { - return this.namespaceService; + return serviceRegistry.getNamespaceService(); } /** @@ -227,7 +257,7 @@ public class CMISMapping { throw new AlfrescoRuntimeException("Malformed type id '" + typeId + "'; discriminator " + typeId.charAt(0) + " unknown"); } - QName typeQName = QName.resolveToQName(namespaceService, typeId.substring(2).replace('_', ':')); + QName typeQName = QName.resolveToQName(serviceRegistry.getNamespaceService(), typeId.substring(2).replace('_', ':')); // Construct CMIS Type Id return new CMISTypeId(scope, typeId, typeQName); @@ -241,7 +271,7 @@ public class CMISMapping */ public CMISTypeId getCmisTypeId(CMISScope scope, QName typeQName) { - CMISTypeId typeId = qNameToCmisTypeId.get(typeQName); + CMISTypeId typeId = mapAlfrescoQNameToTypeId.get(typeQName); if (typeId == null) { StringBuilder builder = new StringBuilder(128); @@ -302,13 +332,13 @@ public class CMISMapping return null; } - /*package*/ String buildPrefixEncodedString(QName qname, boolean upperCase) + public String buildPrefixEncodedString(QName qname, boolean upperCase) { StringBuilder builder = new StringBuilder(128); if (!qname.getNamespaceURI().equals(CMIS_MODEL_URI)) { - Collection prefixes = namespaceService.getPrefixes(qname.getNamespaceURI()); + Collection prefixes = serviceRegistry.getNamespaceService().getPrefixes(qname.getNamespaceURI()); if (prefixes.size() == 0) { throw new NamespaceException("A namespace prefix is not registered for uri " + qname.getNamespaceURI()); @@ -353,7 +383,7 @@ public class CMISMapping return true; } - if (dictionaryService.isSubClass(typeQName, ContentModel.TYPE_FOLDER)) + if (serviceRegistry.getDictionaryService().isSubClass(typeQName, ContentModel.TYPE_FOLDER)) { if (typeQName.equals(ContentModel.TYPE_FOLDER)) { @@ -386,7 +416,7 @@ public class CMISMapping return true; } - if (dictionaryService.isSubClass(typeQName, ContentModel.TYPE_CONTENT)) + if (serviceRegistry.getDictionaryService().isSubClass(typeQName, ContentModel.TYPE_CONTENT)) { if (typeQName.equals(ContentModel.TYPE_CONTENT)) { @@ -418,7 +448,7 @@ public class CMISMapping return true; } - AspectDefinition aspectDef = dictionaryService.getAspect(typeQName); + AspectDefinition aspectDef = serviceRegistry.getDictionaryService().getAspect(typeQName); if (aspectDef == null) { return false; @@ -451,7 +481,7 @@ public class CMISMapping { return true; } - AssociationDefinition associationDefinition = dictionaryService.getAssociation(associationQName); + AssociationDefinition associationDefinition = serviceRegistry.getDictionaryService().getAssociation(associationQName); if (associationDefinition == null) { return false; @@ -480,7 +510,7 @@ public class CMISMapping */ public QName getCmisType(QName typeQName) { - QName mapped = alfrescoToCmisTypes.get(typeQName); + QName mapped = mapAlfrescoQNameToCmisQName.get(typeQName); if (mapped != null) { return mapped; @@ -496,7 +526,7 @@ public class CMISMapping */ public boolean isRemappedType(QName typeQName) { - return alfrescoToCmisTypes.containsKey(typeQName); + return mapAlfrescoQNameToCmisQName.containsKey(typeQName); } /** @@ -507,7 +537,7 @@ public class CMISMapping */ public QName getAlfrescoType(QName cmisTypeQName) { - QName mapped = cmisToAlfrecsoTypes.get(cmisTypeQName); + QName mapped = mapCmisQNameToAlfrescoQName.get(cmisTypeQName); if (mapped != null) { return mapped; @@ -541,7 +571,7 @@ public class CMISMapping public CMISDataTypeEnum getDataType(QName dataType) { - return alfrescoPropertyTypesToCmisPropertyTypes.get(dataType); + return mapAlfrescoToCmisDataType.get(dataType); } /** @@ -556,7 +586,7 @@ public class CMISMapping { // Try the cmis model first - it it matches we are done QName cmisPropertyQName = QName.createQName(CMIS_MODEL_URI, cmisPropertyName); - if (dictionaryService.getProperty(cmisPropertyQName) != null) + if (serviceRegistry.getDictionaryService().getProperty(cmisPropertyQName) != null) { return cmisPropertyQName; } @@ -568,7 +598,7 @@ public class CMISMapping // CMIS case insensitive hunt - no prefix if (split == -1) { - for (QName qname : dictionaryService.getAllProperties(null)) + for (QName qname : serviceRegistry.getDictionaryService().getAllProperties(null)) { if (qname.getNamespaceURI().equals(CMIS_MODEL_URI)) { @@ -586,15 +616,15 @@ public class CMISMapping // Try lower case version first. - QName propertyQName = QName.createQName(prefix.toLowerCase(), localName.toLowerCase(), namespaceService); - if (dictionaryService.getProperty(propertyQName) != null) + QName propertyQName = QName.createQName(prefix.toLowerCase(), localName.toLowerCase(), serviceRegistry.getNamespaceService()); + if (serviceRegistry.getDictionaryService().getProperty(propertyQName) != null) { return propertyQName; } // Full case insensitive hunt - for (String test : namespaceService.getPrefixes()) + for (String test : serviceRegistry.getNamespaceService().getPrefixes()) { if (test.equalsIgnoreCase(prefix)) { @@ -602,9 +632,9 @@ public class CMISMapping break; } } - String uri = namespaceService.getNamespaceURI(prefix); + String uri = serviceRegistry.getNamespaceService().getNamespaceURI(prefix); - for (QName qname : dictionaryService.getAllProperties(null)) + for (QName qname : serviceRegistry.getDictionaryService().getAllProperties(null)) { if (qname.getNamespaceURI().equals(uri)) { @@ -634,4 +664,36 @@ public class CMISMapping return propertyQName.toString(); } } + + /** + * Get a Property Accessor + * + * @param propertyId + * @return + */ + public AbstractPropertyAccessor getPropertyAccessor(CMISPropertyId propertyId) + { + AbstractPropertyAccessor propertyAccessor = propertyAccessors.get(propertyId.getName()); + if (propertyAccessor == null) + { + QName propertyQName = propertyId.getQName(); + if (propertyQName == null) + { + throw new AlfrescoRuntimeException("Can't get property accessor for property id " + propertyId.getName() + " due to unknown property QName"); + } + propertyAccessor = new DirectPropertyAccessor(serviceRegistry, propertyId.getName(), propertyQName); + } + return propertyAccessor; + } + + /** + * Register pre-defined Property Accessor + * + * @param propertyAccessor + */ + private void registerPropertyAccessor(AbstractPropertyAccessor propertyAccessor) + { + propertyAccessors.put(propertyAccessor.getName(), propertyAccessor); + } + } diff --git a/source/java/org/alfresco/cmis/property/AbstractNamedPropertyAccessor.java b/source/java/org/alfresco/cmis/property/AbstractNamedPropertyAccessor.java deleted file mode 100644 index 5da8caf7ff..0000000000 --- a/source/java/org/alfresco/cmis/property/AbstractNamedPropertyAccessor.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2005-2007 Alfresco Software Limited. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program 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 General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - * As a special exception to the terms and conditions of version 2.0 of - * the GPL, you may redistribute this Program in connection with Free/Libre - * and Open Source Software ("FLOSS") applications as described in Alfresco's - * FLOSS exception. You should have recieved a copy of the text describing - * the FLOSS exception, and it is also available here: - * http://www.alfresco.com/legal/licensing" - */ -package org.alfresco.cmis.property; - -import org.alfresco.cmis.dictionary.CMISMapping; -import org.alfresco.cmis.dictionary.CMISScope; -import org.alfresco.service.ServiceRegistry; - -/** - * Base class for named property accessors - * - * @author andyh - * - */ -public abstract class AbstractNamedPropertyAccessor extends AbstractPropertyAccessor implements NamedPropertyAccessor -{ - private String propertyName; - private CMISScope scope; - - protected AbstractNamedPropertyAccessor(CMISMapping cmisMapping, ServiceRegistry serviceRegistry, CMISScope scope, String propertyName) - { - super(cmisMapping, serviceRegistry); - this.scope = scope; - this.propertyName = propertyName; - } - - - public CMISScope getScope() - { - return scope; - } - - public String getPropertyName() - { - return propertyName; - } - -} diff --git a/source/java/org/alfresco/cmis/property/AbstractPropertyAccessor.java b/source/java/org/alfresco/cmis/property/AbstractPropertyAccessor.java index 5624e1c3d4..2de07f5ee6 100644 --- a/source/java/org/alfresco/cmis/property/AbstractPropertyAccessor.java +++ b/source/java/org/alfresco/cmis/property/AbstractPropertyAccessor.java @@ -24,35 +24,55 @@ */ package org.alfresco.cmis.property; -import org.alfresco.cmis.dictionary.CMISMapping; import org.alfresco.service.ServiceRegistry; +import org.alfresco.service.namespace.QName; /** - * Base class for all property accessors - provides the service registry + * Base class for all property accessors * * @author andyh * */ -public abstract class AbstractPropertyAccessor +public abstract class AbstractPropertyAccessor implements PropertyAccessor, PropertyLuceneBuilder { - private CMISMapping cmisMapping; private ServiceRegistry serviceRegistry; + private String propertyName; - - protected AbstractPropertyAccessor(CMISMapping cmisMapping, ServiceRegistry serviceRegistry) + /** + * Construct + * + * @param serviceRegistry + * @param propertyName + */ + protected AbstractPropertyAccessor(ServiceRegistry serviceRegistry, String propertyName) { - this.cmisMapping = cmisMapping; this.serviceRegistry = serviceRegistry; + this.propertyName = propertyName; } + /** + * @return service registry + */ protected ServiceRegistry getServiceRegistry() { return serviceRegistry; } - protected CMISMapping getCMISMapping() + /* + * (non-Javadoc) + * @see org.alfresco.cmis.property.PropertyAccessor#getName() + */ + public String getName() { - return cmisMapping; + return propertyName; } + /* + * (non-Javadoc) + * @see org.alfresco.cmis.property.PropertyAccessor#getMappedProperty() + */ + public QName getMappedProperty() + { + return null; + } } diff --git a/source/java/org/alfresco/cmis/property/CMISPropertyService.java b/source/java/org/alfresco/cmis/property/CMISPropertyService.java deleted file mode 100644 index b89cb20648..0000000000 --- a/source/java/org/alfresco/cmis/property/CMISPropertyService.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (C) 2005-2007 Alfresco Software Limited. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program 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 General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - * As a special exception to the terms and conditions of version 2.0 of - * the GPL, you may redistribute this Program in connection with Free/Libre - * and Open Source Software ("FLOSS") applications as described in Alfresco's - * FLOSS exception. You should have recieved a copy of the text describing - * the FLOSS exception, and it is also available here: - * http://www.alfresco.com/legal/licensing" - */ -package org.alfresco.cmis.property; - -import java.io.Serializable; -import java.util.Map; - -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; - -/** - * Public API to get and set CMIS properties - * - * - * @author andyh - * - */ -public interface CMISPropertyService -{ - /** - * Map CMIS Property name to Alfresco property name (only for direct 1 to 1 mappings) - * - * @param propertyName CMIS property name - * @return Alfresco property name (or null, if there's no mapping) - */ - public QName mapPropertyName(String propertyName); - - /** - * Set a single property - * @param nodeRef - * @param propertyName - * @param value - */ - public void setProperty(NodeRef nodeRef, String propertyName, Serializable value); - - /** - * Set all properties - * @param nodeRef - * @param values - */ - public void setProperties(NodeRef nodeRef, Map values); - - /** - * Get a property value - * @param nodeRef - * @param propertyName - * @return - */ - public Serializable getProperty(NodeRef nodeRef, String propertyName); - - /** - * Get all property values for a node - * @param nodeRef - * @return - */ - public Map getProperties(NodeRef nodeRef); - - -} diff --git a/source/java/org/alfresco/cmis/property/CMISPropertyServiceImpl.java b/source/java/org/alfresco/cmis/property/CMISPropertyServiceImpl.java deleted file mode 100644 index 23a6078ae0..0000000000 --- a/source/java/org/alfresco/cmis/property/CMISPropertyServiceImpl.java +++ /dev/null @@ -1,591 +0,0 @@ -/* - * Copyright (C) 2005-2007 Alfresco Software Limited. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program 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 General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - * As a special exception to the terms and conditions of version 2.0 of - * the GPL, you may redistribute this Program in connection with Free/Libre - * and Open Source Software ("FLOSS") applications as described in Alfresco's - * FLOSS exception. You should have recieved a copy of the text describing - * the FLOSS exception, and it is also available here: - * http://www.alfresco.com/legal/licensing" - */ -package org.alfresco.cmis.property; - -import java.io.Serializable; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.cmis.CMISContentStreamAllowedEnum; -import org.alfresco.cmis.CMISService; -import org.alfresco.cmis.dictionary.CMISDictionaryModel; -import org.alfresco.cmis.dictionary.CMISMapping; -import org.alfresco.cmis.dictionary.CMISScope; -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.model.ContentModel; -import org.alfresco.repo.search.impl.lucene.LuceneQueryParser; -import org.alfresco.repo.search.impl.querymodel.PredicateMode; -import org.alfresco.service.ServiceRegistry; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; -import org.apache.lucene.queryParser.ParseException; -import org.apache.lucene.search.Query; -import org.springframework.beans.factory.InitializingBean; - -/** - * Mapping between Alfresco and CMIS property types - * - * @author andyh - */ -public class CMISPropertyServiceImpl implements CMISPropertyService, InitializingBean -{ - private HashMap namedPropertyAccessors = new HashMap(); - - private AbstractGenericPropertyAccessor genericPropertyAccessor; - - private CMISService cmisService; - - private CMISMapping cmisMapping; - - private ServiceRegistry serviceRegistry; - - private boolean strict = false; - - /** - * @param cmisService - */ - public void setCMISService(CMISService cmisService) - { - this.cmisService = cmisService; - } - - /** - * @param cmisMapping - */ - public void setCMISMapping(CMISMapping cmisMapping) - { - this.cmisMapping = cmisMapping; - } - - /** - * @return cmis mapping service - */ - public CMISMapping getCMISMapping() - { - return cmisMapping; - } - - /** - * @param serviceRegistry - */ - public void setServiceRegistry(ServiceRegistry serviceRegistry) - { - this.serviceRegistry = serviceRegistry; - } - - public boolean isStrict() - { - return strict; - } - - public void setStrict(boolean strict) - { - this.strict = strict; - } - - public QName mapPropertyName(String propertyName) - { - NamedPropertyAccessor accessor = namedPropertyAccessors.get(propertyName); - if (accessor != null && !(accessor instanceof SimplePropertyAccessor)) - { - return null; - } - - return cmisMapping.getPropertyQName(propertyName); - } - - public Map getProperties(NodeRef nodeRef) - { - // Map - QName typeQName = cmisMapping.getCmisType(serviceRegistry.getNodeService().getType(nodeRef)); - CMISScope scope; - if (cmisMapping.isValidCmisDocument(typeQName)) - { - scope = CMISScope.DOCUMENT; - } - else if (cmisMapping.isValidCmisFolder(typeQName)) - { - scope = CMISScope.FOLDER; - } - else - { - scope = null; - } - - if (scope == null) - { - return Collections. emptyMap(); - } - - HashMap mapped = new HashMap(); - if (!strict) - { - Map unmapped = serviceRegistry.getNodeService().getProperties(nodeRef); - for (QName propertyQName : unmapped.keySet()) - { - String cmisPropertyName = cmisMapping.getCmisPropertyName(propertyQName); - mapped.put(cmisPropertyName, unmapped.get(propertyQName)); - } - } - // Add core - for (String cmisPropertyName : namedPropertyAccessors.keySet()) - { - NamedPropertyAccessor accessor = namedPropertyAccessors.get(cmisPropertyName); - if ((accessor.getScope() == CMISScope.OBJECT) || accessor.getScope().equals(scope)) - { - mapped.put(cmisPropertyName, accessor.getProperty(nodeRef)); - // Could hide properties here .... - } - } - return mapped; - } - - public Serializable getProperty(NodeRef nodeRef, String propertyName) - { - QName typeQName = cmisMapping.getCmisType(serviceRegistry.getNodeService().getType(nodeRef)); - CMISScope scope; - if (cmisMapping.isValidCmisDocument(typeQName)) - { - scope = CMISScope.DOCUMENT; - } - else if (cmisMapping.isValidCmisFolder(typeQName)) - { - scope = CMISScope.FOLDER; - } - else - { - scope = null; - } - - if (scope == null) - { - return null; - } - - NamedPropertyAccessor accessor = namedPropertyAccessors.get(propertyName); - if (accessor != null) - { - if ((accessor.getScope() == CMISScope.OBJECT) || accessor.getScope().equals(scope)) - { - return accessor.getProperty(nodeRef); - } - else - { - return null; - } - } - else - { - if (strict) - { - return null; - } - else - { - return genericPropertyAccessor.getProperty(nodeRef, propertyName); - } - } - } - - public void setProperties(NodeRef nodeRef, Map values) - { - throw new UnsupportedOperationException(); - } - - public void setProperty(NodeRef nodeRef, String propertyName, Serializable value) - { - QName typeQName = cmisMapping.getCmisType(serviceRegistry.getNodeService().getType(nodeRef)); - CMISScope scope; - if (cmisMapping.isValidCmisDocument(typeQName)) - { - scope = CMISScope.DOCUMENT; - } - else if (cmisMapping.isValidCmisFolder(typeQName)) - { - scope = CMISScope.FOLDER; - } - else - { - throw new AlfrescoRuntimeException("Node type " + typeQName + " is not a valid CMIS document or folder"); - } - - NamedPropertyAccessor accessor = namedPropertyAccessors.get(propertyName); - if (accessor != null) - { - if ((accessor.getScope() == CMISScope.OBJECT) || accessor.getScope().equals(scope)) - { - accessor.setProperty(nodeRef, value); - } - else - { - throw new AlfrescoRuntimeException("Property " + propertyName + " is not applicable for type " + typeQName); - } - } - else - { - genericPropertyAccessor.setProperty(nodeRef, propertyName, value); - } - } - - public void afterPropertiesSet() throws Exception - { - // Generic Alfresco mappings - genericPropertyAccessor = new MappingPropertyAccessor(cmisMapping, serviceRegistry); - - // CMIS Object - addNamedPropertyAccessor(getObjectIdPropertyAccessor()); - addNamedPropertyAccessor(getFixedValuePropertyAccessor(CMISDictionaryModel.PROP_URI, null, CMISScope.OBJECT)); - addNamedPropertyAccessor(getObjectTypeIdPropertyAccessor()); - addNamedPropertyAccessor(getSimplePropertyAccessor(CMISDictionaryModel.PROP_CREATED_BY, ContentModel.PROP_CREATOR, CMISScope.OBJECT)); - addNamedPropertyAccessor(getSimplePropertyAccessor(CMISDictionaryModel.PROP_CREATION_DATE, ContentModel.PROP_CREATED, CMISScope.OBJECT)); - addNamedPropertyAccessor(getSimplePropertyAccessor(CMISDictionaryModel.PROP_LAST_MODIFIED_BY, ContentModel.PROP_MODIFIER, CMISScope.OBJECT)); - addNamedPropertyAccessor(getSimplePropertyAccessor(CMISDictionaryModel.PROP_LAST_MODIFICATION_DATE, ContentModel.PROP_MODIFIED, CMISScope.OBJECT)); - addNamedPropertyAccessor(getFixedValuePropertyAccessor(CMISDictionaryModel.PROP_CHANGE_TOKEN, null, CMISScope.OBJECT)); - - // CMIS Document and Folder - addNamedPropertyAccessor(getSimplePropertyAccessor(CMISDictionaryModel.PROP_NAME, ContentModel.PROP_NAME, CMISScope.OBJECT)); - - // CMIS Document - addNamedPropertyAccessor(getIsImmutablePropertyAccessor()); - addNamedPropertyAccessor(getIsLatestVersionPropertyAccessor()); - addNamedPropertyAccessor(getIsMajorVersionPropertyAccessor()); - addNamedPropertyAccessor(getIsLatestMajorVersionPropertyAccessor()); - addNamedPropertyAccessor(getSimplePropertyAccessor(CMISDictionaryModel.PROP_VERSION_LABEL, ContentModel.PROP_VERSION_LABEL, CMISScope.DOCUMENT)); - addNamedPropertyAccessor(getVersionSeriesIdPropertyAccessor()); - addNamedPropertyAccessor(getVersionSeriesIsCheckedOutPropertyAccessor()); - addNamedPropertyAccessor(getVersionSeriesCheckedOutByPropertyAccessor()); - addNamedPropertyAccessor(getVersionSeriesCheckedOutIdPropertyAccessor()); - addNamedPropertyAccessor(getCheckinCommentPropertyAccessor()); - addNamedPropertyAccessor(getFixedValuePropertyAccessor(CMISDictionaryModel.PROP_CONTENT_STREAM_ALLOWED, CMISContentStreamAllowedEnum.ALLOWED.toString(), CMISScope.DOCUMENT)); - addNamedPropertyAccessor(getContentStreamLengthPropertyAccessor()); - addNamedPropertyAccessor(getContentStreamMimetypePropertyAccessor()); - addNamedPropertyAccessor(getSimplePropertyAccessor(CMISDictionaryModel.PROP_CONTENT_STREAM_FILENAME, ContentModel.PROP_NAME, CMISScope.DOCUMENT)); - addNamedPropertyAccessor(getContentStreamUriPropertyAccessor()); - - // CMIS Folder - addNamedPropertyAccessor(getParentPropertyAccessor()); - addNamedPropertyAccessor(getFixedValuePropertyAccessor(CMISDictionaryModel.PROP_ALLOWED_CHILD_OBJECT_TYPE_IDS, null, CMISScope.FOLDER)); - } - - public void addNamedPropertyAccessor(NamedPropertyAccessor namedPropertyAccessor) - { - namedPropertyAccessors.put(namedPropertyAccessor.getPropertyName(), namedPropertyAccessor); - } - - public NamedPropertyAccessor getSimplePropertyAccessor(String propertyName, QName to, CMISScope scope) - { - return new SimplePropertyAccessor(cmisMapping, serviceRegistry, scope, propertyName, to); - } - - public NamedPropertyAccessor getObjectIdPropertyAccessor() - { - return new ObjectIdPropertyAccessor(cmisMapping, serviceRegistry); - } - - public NamedPropertyAccessor getFixedValuePropertyAccessor(String propertyName, Serializable fixedValue, CMISScope scope) - { - FixedValuePropertyAccessor accessor = new FixedValuePropertyAccessor(cmisMapping, serviceRegistry, scope, propertyName); - accessor.setFixedValue(fixedValue); - return accessor; - } - - public NamedPropertyAccessor getObjectTypeIdPropertyAccessor() - { - return new ObjectTypeIdPropertyAccessor(cmisMapping, serviceRegistry); - } - - public NamedPropertyAccessor getIsImmutablePropertyAccessor() - { - return new IsImmutablePropertyAccessor(cmisMapping, serviceRegistry); - } - - public NamedPropertyAccessor getIsLatestVersionPropertyAccessor() - { - return new IsLatestVersionPropertyAccessor(cmisMapping, serviceRegistry); - } - - public NamedPropertyAccessor getIsMajorVersionPropertyAccessor() - { - return new IsMajorVersionPropertyAccessor(cmisMapping, serviceRegistry); - } - - public NamedPropertyAccessor getIsLatestMajorVersionPropertyAccessor() - { - return new IsLatestMajorVersionPropertyAccessor(cmisMapping, serviceRegistry); - } - - public NamedPropertyAccessor getVersionSeriesIdPropertyAccessor() - { - return new VersionSeriesIdPropertyAccessor(cmisMapping, serviceRegistry); - } - - public NamedPropertyAccessor getVersionSeriesIsCheckedOutPropertyAccessor() - { - return new IsVersionSeriesCheckedOutPropertyAccessor(cmisMapping, serviceRegistry); - } - - public NamedPropertyAccessor getVersionSeriesCheckedOutByPropertyAccessor() - { - return new VersionSeriesCheckedOutByPropertyAccessor(cmisMapping, serviceRegistry); - } - - public NamedPropertyAccessor getVersionSeriesCheckedOutIdPropertyAccessor() - { - return new VersionSeriesCheckedOutIdPropertyAccessor(cmisMapping, serviceRegistry); - } - - public NamedPropertyAccessor getCheckinCommentPropertyAccessor() - { - return new CheckinCommentPropertyAccessor(cmisMapping, serviceRegistry); - } - - public NamedPropertyAccessor getContentStreamLengthPropertyAccessor() - { - return new ContentStreamLengthPropertyAccessor(cmisMapping, serviceRegistry); - } - - public NamedPropertyAccessor getContentStreamMimetypePropertyAccessor() - { - return new ContentStreamMimetypePropertyAccessor(cmisMapping, serviceRegistry); - } - - public NamedPropertyAccessor getContentStreamUriPropertyAccessor() - { - return new ContentStreamUriPropertyAccessor(cmisMapping, serviceRegistry); - } - - public NamedPropertyAccessor getParentPropertyAccessor() - { - return new ParentPropertyAccessor(cmisMapping, serviceRegistry, cmisService); - } - - /** - * @param lqp - * @param propertyName - * @param value - * @param mode - * @return - * @throws ParseException - */ - public Query buildLuceneEquality(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException - { - NamedPropertyAccessor accessor = namedPropertyAccessors.get(propertyName); - if (accessor != null) - { - return accessor.buildLuceneEquality(lqp, propertyName, value, mode); - } - else - { - return genericPropertyAccessor.buildLuceneEquality(lqp, propertyName, value, mode); - } - } - - /** - * @param lqp - * @param propertyName - * @param not - * @return - */ - public Query buildLuceneExists(LuceneQueryParser lqp, String propertyName, Boolean not) throws ParseException - { - NamedPropertyAccessor accessor = namedPropertyAccessors.get(propertyName); - if (accessor != null) - { - return accessor.buildLuceneExists(lqp, propertyName, not); - } - else - { - return genericPropertyAccessor.buildLuceneExists(lqp, propertyName, not); - } - } - - /** - * @param lqp - * @param propertyName - * @param value - * @param mode - * @return - * @throws ParseException - */ - public Query buildLuceneGreaterThan(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException - { - NamedPropertyAccessor accessor = namedPropertyAccessors.get(propertyName); - if (accessor != null) - { - return accessor.buildLuceneGreaterThan(lqp, propertyName, value, mode); - } - else - { - return genericPropertyAccessor.buildLuceneGreaterThan(lqp, propertyName, value, mode); - } - } - - /** - * @param lqp - * @param propertyName - * @param value - * @param mode - * @return - * @throws ParseException - */ - public Query buildLuceneGreaterThanOrEquals(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException - { - NamedPropertyAccessor accessor = namedPropertyAccessors.get(propertyName); - if (accessor != null) - { - return accessor.buildLuceneGreaterThanOrEquals(lqp, propertyName, value, mode); - } - else - { - return genericPropertyAccessor.buildLuceneGreaterThanOrEquals(lqp, propertyName, value, mode); - } - } - - /** - * @param lqp - * @param propertyName - * @param values - * @param not - * @param mode - * @return - * @throws ParseException - */ - public Query buildLuceneIn(LuceneQueryParser lqp, String propertyName, Collection values, Boolean not, PredicateMode mode) throws ParseException - { - NamedPropertyAccessor accessor = namedPropertyAccessors.get(propertyName); - if (accessor != null) - { - return accessor.buildLuceneIn(lqp, propertyName, values, not, mode); - } - else - { - return genericPropertyAccessor.buildLuceneIn(lqp, propertyName, values, not, mode); - } - } - - /** - * @param lqp - * @param propertyName - * @param value - * @param mode - * @return - * @throws ParseException - */ - public Query buildLuceneInequality(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException - { - NamedPropertyAccessor accessor = namedPropertyAccessors.get(propertyName); - if (accessor != null) - { - return accessor.buildLuceneInequality(lqp, propertyName, value, mode); - } - else - { - return genericPropertyAccessor.buildLuceneInequality(lqp, propertyName, value, mode); - } - } - - /** - * @param lqp - * @param propertyName - * @param value - * @param mode - * @return - * @throws ParseException - */ - public Query buildLuceneLessThan(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException - { - NamedPropertyAccessor accessor = namedPropertyAccessors.get(propertyName); - if (accessor != null) - { - return accessor.buildLuceneLessThan(lqp, propertyName, value, mode); - } - else - { - return genericPropertyAccessor.buildLuceneLessThan(lqp, propertyName, value, mode); - } - } - - /** - * @param lqp - * @param propertyName - * @param value - * @param mode - * @return - * @throws ParseException - */ - public Query buildLuceneLessThanOrEquals(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException - { - NamedPropertyAccessor accessor = namedPropertyAccessors.get(propertyName); - if (accessor != null) - { - return accessor.buildLuceneLessThanOrEquals(lqp, propertyName, value, mode); - } - else - { - return genericPropertyAccessor.buildLuceneLessThanOrEquals(lqp, propertyName, value, mode); - } - } - - /** - * @param lqp - * @param propertyName - * @param value - * @param not - * @return - * @throws ParseException - */ - public Query buildLuceneLike(LuceneQueryParser lqp, String propertyName, Serializable value, Boolean not) throws ParseException - { - NamedPropertyAccessor accessor = namedPropertyAccessors.get(propertyName); - if (accessor != null) - { - return accessor.buildLuceneLike(lqp, propertyName, value, not); - } - else - { - return genericPropertyAccessor.buildLuceneLike(lqp, propertyName, value, not); - } - } - - /** - * @param propertyName - * @return - */ - public String getLuceneSortField(String propertyName) - { - NamedPropertyAccessor accessor = namedPropertyAccessors.get(propertyName); - if (accessor != null) - { - return accessor.getLuceneSortField(propertyName); - } - else - { - return genericPropertyAccessor.getLuceneSortField(propertyName); - } - } - -} diff --git a/source/java/org/alfresco/cmis/property/CMISPropertyServiceTest.java b/source/java/org/alfresco/cmis/property/CMISPropertyServiceTest.java index 6b6f7d80eb..0e7291e9b5 100644 --- a/source/java/org/alfresco/cmis/property/CMISPropertyServiceTest.java +++ b/source/java/org/alfresco/cmis/property/CMISPropertyServiceTest.java @@ -32,6 +32,7 @@ import java.util.Map; import org.alfresco.cmis.CMISContentStreamAllowedEnum; import org.alfresco.cmis.dictionary.BaseCMISTest; import org.alfresco.cmis.dictionary.CMISDictionaryModel; +import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.model.ContentModel; import org.alfresco.repo.version.VersionModel; import org.alfresco.service.cmr.lock.LockType; @@ -46,7 +47,7 @@ public class CMISPropertyServiceTest extends BaseCMISTest public void testBasicFolder() { NodeRef folder = fileFolderService.create(rootNodeRef, "BaseFolder", ContentModel.TYPE_FOLDER).getNodeRef(); - Map properties = cmisPropertyService.getProperties(folder); + Map properties = cmisService.getProperties(folder); assertEquals(folder.toString(), properties.get(CMISDictionaryModel.PROP_OBJECT_ID)); assertNull(properties.get(CMISDictionaryModel.PROP_URI)); assertEquals(CMISDictionaryModel.FOLDER_TYPE_ID.getId(), properties.get(CMISDictionaryModel.PROP_OBJECT_TYPE_ID)); @@ -89,7 +90,7 @@ public class CMISPropertyServiceTest extends BaseCMISTest { NodeRef content = fileFolderService.create(rootNodeRef, "BaseContent", ContentModel.TYPE_CONTENT).getNodeRef(); - Map properties = cmisPropertyService.getProperties(content); + Map properties = cmisService.getProperties(content); assertEquals(properties.get(CMISDictionaryModel.PROP_OBJECT_ID), content.toString()); assertNull(properties.get(CMISDictionaryModel.PROP_URI)); assertEquals(properties.get(CMISDictionaryModel.PROP_OBJECT_TYPE_ID), CMISDictionaryModel.DOCUMENT_TYPE_ID.getId()); @@ -124,7 +125,7 @@ public class CMISPropertyServiceTest extends BaseCMISTest { NodeRef content = fileFolderService.create(rootNodeRef, "BaseContent", ContentModel.TYPE_CONTENT).getNodeRef(); - Map properties = cmisPropertyService.getProperties(content); + Map properties = cmisService.getProperties(content); assertEquals(properties.get(CMISDictionaryModel.PROP_OBJECT_ID), content.toString()); assertNull(properties.get(CMISDictionaryModel.PROP_URI)); assertEquals(properties.get(CMISDictionaryModel.PROP_OBJECT_TYPE_ID), CMISDictionaryModel.DOCUMENT_TYPE_ID.getId()); @@ -166,7 +167,7 @@ public class CMISPropertyServiceTest extends BaseCMISTest + " and random charcters \u00E0\u00EA\u00EE\u00F0\u00F1\u00F6\u00FB\u00FF"); long size = writer.getSize(); - properties = cmisPropertyService.getProperties(content); + properties = cmisService.getProperties(content); assertEquals(properties.get(CMISDictionaryModel.PROP_CONTENT_STREAM_ALLOWED), CMISContentStreamAllowedEnum.ALLOWED.toString()); assertEquals(properties.get(CMISDictionaryModel.PROP_CONTENT_STREAM_LENGTH), size); assertEquals(properties.get(CMISDictionaryModel.PROP_CONTENT_STREAM_MIME_TYPE), "text/plain"); @@ -178,7 +179,7 @@ public class CMISPropertyServiceTest extends BaseCMISTest { NodeRef content = fileFolderService.create(rootNodeRef, "BaseContent", ContentModel.TYPE_CONTENT).getNodeRef(); - Map properties = cmisPropertyService.getProperties(content); + Map properties = cmisService.getProperties(content); assertEquals(properties.get(CMISDictionaryModel.PROP_OBJECT_ID), content.toString()); assertNull(properties.get(CMISDictionaryModel.PROP_URI)); assertEquals(properties.get(CMISDictionaryModel.PROP_OBJECT_TYPE_ID), CMISDictionaryModel.DOCUMENT_TYPE_ID.getId()); @@ -211,7 +212,7 @@ public class CMISPropertyServiceTest extends BaseCMISTest serviceRegistry.getLockService().lock(content, LockType.READ_ONLY_LOCK); - properties = cmisPropertyService.getProperties(content); + properties = cmisService.getProperties(content); assertEquals(properties.get(CMISDictionaryModel.PROP_IS_IMMUTABLE), true); assertEquals(properties.get(CMISDictionaryModel.PROP_IS_LATEST_VERSION), true); assertEquals(properties.get(CMISDictionaryModel.PROP_IS_MAJOR_VERSION), false); @@ -224,7 +225,7 @@ public class CMISPropertyServiceTest extends BaseCMISTest assertEquals(properties.get(CMISDictionaryModel.PROP_CHECKIN_COMMENT), null); serviceRegistry.getLockService().unlock(content); - properties = cmisPropertyService.getProperties(content); + properties = cmisService.getProperties(content); assertEquals(properties.get(CMISDictionaryModel.PROP_OBJECT_ID), content.toString()); assertNull(properties.get(CMISDictionaryModel.PROP_URI)); @@ -262,7 +263,7 @@ public class CMISPropertyServiceTest extends BaseCMISTest { NodeRef content = fileFolderService.create(rootNodeRef, "BaseContent", ContentModel.TYPE_CONTENT).getNodeRef(); - Map properties = cmisPropertyService.getProperties(content); + Map properties = cmisService.getProperties(content); assertEquals(properties.get(CMISDictionaryModel.PROP_OBJECT_ID), content.toString()); assertNull(properties.get(CMISDictionaryModel.PROP_URI)); assertEquals(properties.get(CMISDictionaryModel.PROP_OBJECT_TYPE_ID), CMISDictionaryModel.DOCUMENT_TYPE_ID.getId()); @@ -295,7 +296,7 @@ public class CMISPropertyServiceTest extends BaseCMISTest NodeRef pwc = serviceRegistry.getCheckOutCheckInService().checkout(content); - properties = cmisPropertyService.getProperties(content); + properties = cmisService.getProperties(content); assertEquals(properties.get(CMISDictionaryModel.PROP_IS_IMMUTABLE), true); assertEquals(properties.get(CMISDictionaryModel.PROP_IS_LATEST_VERSION), true); assertEquals(properties.get(CMISDictionaryModel.PROP_IS_MAJOR_VERSION), false); @@ -307,7 +308,7 @@ public class CMISPropertyServiceTest extends BaseCMISTest assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_ID), pwc.toString()); assertEquals(properties.get(CMISDictionaryModel.PROP_CHECKIN_COMMENT), null); - properties = cmisPropertyService.getProperties(pwc); + properties = cmisService.getProperties(pwc); assertEquals(properties.get(CMISDictionaryModel.PROP_OBJECT_ID), pwc.toString()); assertNull(properties.get(CMISDictionaryModel.PROP_URI)); @@ -341,7 +342,7 @@ public class CMISPropertyServiceTest extends BaseCMISTest serviceRegistry.getCheckOutCheckInService().cancelCheckout(pwc); - properties = cmisPropertyService.getProperties(content); + properties = cmisService.getProperties(content); assertEquals(properties.get(CMISDictionaryModel.PROP_OBJECT_ID), content.toString()); assertNull(properties.get(CMISDictionaryModel.PROP_URI)); assertEquals(properties.get(CMISDictionaryModel.PROP_OBJECT_TYPE_ID), CMISDictionaryModel.DOCUMENT_TYPE_ID.getId()); @@ -374,7 +375,7 @@ public class CMISPropertyServiceTest extends BaseCMISTest pwc = serviceRegistry.getCheckOutCheckInService().checkout(content); - properties = cmisPropertyService.getProperties(content); + properties = cmisService.getProperties(content); assertEquals(properties.get(CMISDictionaryModel.PROP_IS_IMMUTABLE), true); assertEquals(properties.get(CMISDictionaryModel.PROP_IS_LATEST_VERSION), true); assertEquals(properties.get(CMISDictionaryModel.PROP_IS_MAJOR_VERSION), false); @@ -386,7 +387,7 @@ public class CMISPropertyServiceTest extends BaseCMISTest assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_ID), pwc.toString()); assertEquals(properties.get(CMISDictionaryModel.PROP_CHECKIN_COMMENT), null); - properties = cmisPropertyService.getProperties(pwc); + properties = cmisService.getProperties(pwc); assertEquals(properties.get(CMISDictionaryModel.PROP_OBJECT_ID), pwc.toString()); assertNull(properties.get(CMISDictionaryModel.PROP_URI)); @@ -420,7 +421,7 @@ public class CMISPropertyServiceTest extends BaseCMISTest serviceRegistry.getCheckOutCheckInService().checkin(pwc, null); - properties = cmisPropertyService.getProperties(content); + properties = cmisService.getProperties(content); assertEquals(properties.get(CMISDictionaryModel.PROP_OBJECT_ID), content.toString()); assertNull(properties.get(CMISDictionaryModel.PROP_URI)); assertEquals(properties.get(CMISDictionaryModel.PROP_OBJECT_TYPE_ID), CMISDictionaryModel.DOCUMENT_TYPE_ID.getId()); @@ -457,7 +458,7 @@ public class CMISPropertyServiceTest extends BaseCMISTest { NodeRef content = fileFolderService.create(rootNodeRef, "BaseContent", ContentModel.TYPE_CONTENT).getNodeRef(); - Map properties = cmisPropertyService.getProperties(content); + Map properties = cmisService.getProperties(content); assertEquals(properties.get(CMISDictionaryModel.PROP_OBJECT_ID), content.toString()); assertNull(properties.get(CMISDictionaryModel.PROP_URI)); assertEquals(properties.get(CMISDictionaryModel.PROP_OBJECT_TYPE_ID), CMISDictionaryModel.DOCUMENT_TYPE_ID.getId()); @@ -490,7 +491,7 @@ public class CMISPropertyServiceTest extends BaseCMISTest nodeService.addAspect(content, ContentModel.ASPECT_VERSIONABLE, null); - properties = cmisPropertyService.getProperties(content); + properties = cmisService.getProperties(content); assertEquals(properties.get(CMISDictionaryModel.PROP_OBJECT_ID), content.toString()); assertNull(properties.get(CMISDictionaryModel.PROP_URI)); assertEquals(properties.get(CMISDictionaryModel.PROP_OBJECT_TYPE_ID), CMISDictionaryModel.DOCUMENT_TYPE_ID.getId()); @@ -523,7 +524,7 @@ public class CMISPropertyServiceTest extends BaseCMISTest NodeRef pwc = serviceRegistry.getCheckOutCheckInService().checkout(content); - properties = cmisPropertyService.getProperties(content); + properties = cmisService.getProperties(content); assertEquals(properties.get(CMISDictionaryModel.PROP_IS_IMMUTABLE), true); assertEquals(properties.get(CMISDictionaryModel.PROP_IS_LATEST_VERSION), true); assertEquals(properties.get(CMISDictionaryModel.PROP_IS_MAJOR_VERSION), false); @@ -535,7 +536,7 @@ public class CMISPropertyServiceTest extends BaseCMISTest assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_ID), pwc.toString()); assertEquals(properties.get(CMISDictionaryModel.PROP_CHECKIN_COMMENT), null); - properties = cmisPropertyService.getProperties(pwc); + properties = cmisService.getProperties(pwc); assertEquals(properties.get(CMISDictionaryModel.PROP_OBJECT_ID), pwc.toString()); assertNull(properties.get(CMISDictionaryModel.PROP_URI)); @@ -569,7 +570,7 @@ public class CMISPropertyServiceTest extends BaseCMISTest serviceRegistry.getCheckOutCheckInService().cancelCheckout(pwc); - properties = cmisPropertyService.getProperties(content); + properties = cmisService.getProperties(content); assertEquals(properties.get(CMISDictionaryModel.PROP_OBJECT_ID), content.toString()); assertNull(properties.get(CMISDictionaryModel.PROP_URI)); assertEquals(properties.get(CMISDictionaryModel.PROP_OBJECT_TYPE_ID), CMISDictionaryModel.DOCUMENT_TYPE_ID.getId()); @@ -602,7 +603,7 @@ public class CMISPropertyServiceTest extends BaseCMISTest pwc = serviceRegistry.getCheckOutCheckInService().checkout(content); - properties = cmisPropertyService.getProperties(content); + properties = cmisService.getProperties(content); assertEquals(properties.get(CMISDictionaryModel.PROP_IS_IMMUTABLE), true); assertEquals(properties.get(CMISDictionaryModel.PROP_IS_LATEST_VERSION), true); assertEquals(properties.get(CMISDictionaryModel.PROP_IS_MAJOR_VERSION), false); @@ -614,7 +615,7 @@ public class CMISPropertyServiceTest extends BaseCMISTest assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_ID), pwc.toString()); assertEquals(properties.get(CMISDictionaryModel.PROP_CHECKIN_COMMENT), null); - properties = cmisPropertyService.getProperties(pwc); + properties = cmisService.getProperties(pwc); assertEquals(properties.get(CMISDictionaryModel.PROP_OBJECT_ID), pwc.toString()); assertNull(properties.get(CMISDictionaryModel.PROP_URI)); @@ -651,7 +652,7 @@ public class CMISPropertyServiceTest extends BaseCMISTest versionProperties.put(VersionModel.PROP_VERSION_TYPE, VersionType.MAJOR); serviceRegistry.getCheckOutCheckInService().checkin(pwc, versionProperties); - properties = cmisPropertyService.getProperties(content); + properties = cmisService.getProperties(content); assertEquals(properties.get(CMISDictionaryModel.PROP_OBJECT_ID), content.toString()+"/1.0"); assertNull(properties.get(CMISDictionaryModel.PROP_URI)); assertEquals(properties.get(CMISDictionaryModel.PROP_OBJECT_TYPE_ID), CMISDictionaryModel.DOCUMENT_TYPE_ID.getId()); @@ -684,7 +685,7 @@ public class CMISPropertyServiceTest extends BaseCMISTest pwc = serviceRegistry.getCheckOutCheckInService().checkout(content); - properties = cmisPropertyService.getProperties(content); + properties = cmisService.getProperties(content); assertEquals(properties.get(CMISDictionaryModel.PROP_IS_IMMUTABLE), true); assertEquals(properties.get(CMISDictionaryModel.PROP_IS_LATEST_VERSION), true); assertEquals(properties.get(CMISDictionaryModel.PROP_IS_MAJOR_VERSION), true); @@ -696,7 +697,7 @@ public class CMISPropertyServiceTest extends BaseCMISTest assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_ID), pwc.toString()); assertEquals(properties.get(CMISDictionaryModel.PROP_CHECKIN_COMMENT), "Meep"); - properties = cmisPropertyService.getProperties(pwc); + properties = cmisService.getProperties(pwc); assertEquals(properties.get(CMISDictionaryModel.PROP_OBJECT_ID), pwc.toString()); assertNull(properties.get(CMISDictionaryModel.PROP_URI)); @@ -733,7 +734,7 @@ public class CMISPropertyServiceTest extends BaseCMISTest versionProperties.put(VersionModel.PROP_VERSION_TYPE, VersionType.MINOR); serviceRegistry.getCheckOutCheckInService().checkin(pwc, versionProperties); - properties = cmisPropertyService.getProperties(content); + properties = cmisService.getProperties(content); assertEquals(properties.get(CMISDictionaryModel.PROP_OBJECT_ID), content.toString()+"/1.1"); assertNull(properties.get(CMISDictionaryModel.PROP_URI)); assertEquals(properties.get(CMISDictionaryModel.PROP_OBJECT_TYPE_ID), CMISDictionaryModel.DOCUMENT_TYPE_ID.getId()); @@ -768,37 +769,45 @@ public class CMISPropertyServiceTest extends BaseCMISTest public void testSinglePropertyFolderAccess() { NodeRef folder = fileFolderService.create(rootNodeRef, "BaseFolder", ContentModel.TYPE_FOLDER).getNodeRef(); - assertEquals(cmisPropertyService.getProperty(folder, CMISDictionaryModel.PROP_OBJECT_ID), folder.toString()); - assertNull(cmisPropertyService.getProperty(folder, CMISDictionaryModel.PROP_URI)); - assertEquals(cmisPropertyService.getProperty(folder, CMISDictionaryModel.PROP_OBJECT_TYPE_ID), CMISDictionaryModel.FOLDER_TYPE_ID.getId()); - assertEquals(cmisPropertyService.getProperty(folder, CMISDictionaryModel.PROP_CREATED_BY), authenticationComponent.getCurrentUserName()); - assertNotNull(cmisPropertyService.getProperty(folder, CMISDictionaryModel.PROP_CREATION_DATE)); - assertEquals(cmisPropertyService.getProperty(folder, CMISDictionaryModel.PROP_LAST_MODIFIED_BY), authenticationComponent.getCurrentUserName()); - assertNotNull(cmisPropertyService.getProperty(folder, CMISDictionaryModel.PROP_LAST_MODIFICATION_DATE)); - assertNull(cmisPropertyService.getProperty(folder, CMISDictionaryModel.PROP_CHANGE_TOKEN)); + assertEquals(cmisService.getProperty(folder, CMISDictionaryModel.PROP_OBJECT_ID), folder.toString()); + assertNull(cmisService.getProperty(folder, CMISDictionaryModel.PROP_URI)); + assertEquals(cmisService.getProperty(folder, CMISDictionaryModel.PROP_OBJECT_TYPE_ID), CMISDictionaryModel.FOLDER_TYPE_ID.getId()); + assertEquals(cmisService.getProperty(folder, CMISDictionaryModel.PROP_CREATED_BY), authenticationComponent.getCurrentUserName()); + assertNotNull(cmisService.getProperty(folder, CMISDictionaryModel.PROP_CREATION_DATE)); + assertEquals(cmisService.getProperty(folder, CMISDictionaryModel.PROP_LAST_MODIFIED_BY), authenticationComponent.getCurrentUserName()); + assertNotNull(cmisService.getProperty(folder, CMISDictionaryModel.PROP_LAST_MODIFICATION_DATE)); + assertNull(cmisService.getProperty(folder, CMISDictionaryModel.PROP_CHANGE_TOKEN)); - assertEquals(cmisPropertyService.getProperty(folder, CMISDictionaryModel.PROP_NAME), "BaseFolder"); + assertEquals(cmisService.getProperty(folder, CMISDictionaryModel.PROP_NAME), "BaseFolder"); - assertNull(cmisPropertyService.getProperty(folder, CMISDictionaryModel.PROP_IS_IMMUTABLE)); - assertNull(cmisPropertyService.getProperty(folder, CMISDictionaryModel.PROP_IS_LATEST_VERSION)); - assertNull(cmisPropertyService.getProperty(folder, CMISDictionaryModel.PROP_IS_MAJOR_VERSION)); - assertNull(cmisPropertyService.getProperty(folder, CMISDictionaryModel.PROP_IS_LATEST_MAJOR_VERSION)); - assertNull(cmisPropertyService.getProperty(folder, CMISDictionaryModel.PROP_VERSION_LABEL)); - assertNull(cmisPropertyService.getProperty(folder, CMISDictionaryModel.PROP_VERSION_SERIES_ID)); - assertNull(cmisPropertyService.getProperty(folder, CMISDictionaryModel.PROP_IS_VERSION_SERIES_CHECKED_OUT)); - assertNull(cmisPropertyService.getProperty(folder, CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_BY)); - assertNull(cmisPropertyService.getProperty(folder, CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_ID)); - assertNull(cmisPropertyService.getProperty(folder, CMISDictionaryModel.PROP_CHECKIN_COMMENT)); - assertNull(cmisPropertyService.getProperty(folder, CMISDictionaryModel.PROP_CONTENT_STREAM_ALLOWED)); - assertNull(cmisPropertyService.getProperty(folder, CMISDictionaryModel.PROP_CONTENT_STREAM_LENGTH)); - assertNull(cmisPropertyService.getProperty(folder, CMISDictionaryModel.PROP_CONTENT_STREAM_MIME_TYPE)); - assertNull(cmisPropertyService.getProperty(folder, CMISDictionaryModel.PROP_CONTENT_STREAM_FILENAME)); - assertNull(cmisPropertyService.getProperty(folder, CMISDictionaryModel.PROP_CONTENT_STREAM_URI)); + try + { + cmisService.getProperty(folder, CMISDictionaryModel.PROP_IS_IMMUTABLE); + cmisService.getProperty(folder, CMISDictionaryModel.PROP_IS_LATEST_VERSION); + cmisService.getProperty(folder, CMISDictionaryModel.PROP_IS_MAJOR_VERSION); + cmisService.getProperty(folder, CMISDictionaryModel.PROP_IS_LATEST_MAJOR_VERSION); + cmisService.getProperty(folder, CMISDictionaryModel.PROP_VERSION_LABEL); + cmisService.getProperty(folder, CMISDictionaryModel.PROP_VERSION_SERIES_ID); + cmisService.getProperty(folder, CMISDictionaryModel.PROP_IS_VERSION_SERIES_CHECKED_OUT); + cmisService.getProperty(folder, CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_BY); + cmisService.getProperty(folder, CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_ID); + cmisService.getProperty(folder, CMISDictionaryModel.PROP_CHECKIN_COMMENT); + cmisService.getProperty(folder, CMISDictionaryModel.PROP_CONTENT_STREAM_ALLOWED); + cmisService.getProperty(folder, CMISDictionaryModel.PROP_CONTENT_STREAM_LENGTH); + cmisService.getProperty(folder, CMISDictionaryModel.PROP_CONTENT_STREAM_MIME_TYPE); + cmisService.getProperty(folder, CMISDictionaryModel.PROP_CONTENT_STREAM_FILENAME); + cmisService.getProperty(folder, CMISDictionaryModel.PROP_CONTENT_STREAM_URI); + fail("Failed to catch invalid property on type folder"); + } + catch(AlfrescoRuntimeException e) + { + // NOTE: Invalid property + } - assertEquals(cmisPropertyService.getProperty(folder, CMISDictionaryModel.PROP_PARENT_ID), rootNodeRef.toString()); - assertNull(cmisPropertyService.getProperty(folder, CMISDictionaryModel.PROP_ALLOWED_CHILD_OBJECT_TYPE_IDS)); + assertEquals(cmisService.getProperty(folder, CMISDictionaryModel.PROP_PARENT_ID), rootNodeRef.toString()); + assertNull(cmisService.getProperty(folder, CMISDictionaryModel.PROP_ALLOWED_CHILD_OBJECT_TYPE_IDS)); - assertEquals(cmisPropertyService.getProperty(folder, "CM_NAME"), "BaseFolder"); - assertEquals(cmisPropertyService.getProperty(folder, "cm_name"), "BaseFolder"); + assertEquals(cmisService.getProperty(folder, "NAME"), "BaseFolder"); + assertEquals(cmisService.getProperty(folder, "name"), "BaseFolder"); } } diff --git a/source/java/org/alfresco/cmis/property/CheckinCommentPropertyAccessor.java b/source/java/org/alfresco/cmis/property/CheckinCommentPropertyAccessor.java index fa90857fbd..6a448eb402 100644 --- a/source/java/org/alfresco/cmis/property/CheckinCommentPropertyAccessor.java +++ b/source/java/org/alfresco/cmis/property/CheckinCommentPropertyAccessor.java @@ -28,8 +28,6 @@ import java.io.Serializable; import java.util.Collection; import org.alfresco.cmis.dictionary.CMISDictionaryModel; -import org.alfresco.cmis.dictionary.CMISMapping; -import org.alfresco.cmis.dictionary.CMISScope; import org.alfresco.repo.search.impl.lucene.LuceneQueryParser; import org.alfresco.repo.search.impl.querymodel.PredicateMode; import org.alfresco.service.ServiceRegistry; @@ -42,15 +40,23 @@ import org.apache.lucene.search.Query; * * @author andyh */ -public class CheckinCommentPropertyAccessor extends AbstractNamedPropertyAccessor +public class CheckinCommentPropertyAccessor extends AbstractPropertyAccessor { - protected CheckinCommentPropertyAccessor(CMISMapping cmisMapping, ServiceRegistry serviceRegistry) + /** + * Construct + * + * @param serviceRegistry + */ + public CheckinCommentPropertyAccessor(ServiceRegistry serviceRegistry) { - super(cmisMapping, serviceRegistry, CMISScope.DOCUMENT, CMISDictionaryModel.PROP_CHECKIN_COMMENT); + super(serviceRegistry, CMISDictionaryModel.PROP_CHECKIN_COMMENT); } - - public Serializable getProperty(NodeRef nodeRef) + /* + * (non-Javadoc) + * @see org.alfresco.cmis.property.PropertyAccessor#getValue(org.alfresco.service.cmr.repository.NodeRef) + */ + public Serializable getValue(NodeRef nodeRef) { Version version = getServiceRegistry().getVersionService().getCurrentVersion(nodeRef); if (version != null) @@ -63,120 +69,103 @@ public class CheckinCommentPropertyAccessor extends AbstractNamedPropertyAccesso } } - public void setProperty(NodeRef nodeRef, Serializable value) + /* + * (non-Javadoc) + * @see org.alfresco.cmis.property.PropertyAccessor#setValue(org.alfresco.service.cmr.repository.NodeRef, java.io.Serializable) + */ + public void setValue(NodeRef nodeRef, Serializable value) { throw new UnsupportedOperationException(); } - - /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneEquality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneEquality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneEquality(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) + public Query buildLuceneEquality(LuceneQueryParser lqp, Serializable value, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneExists(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.lang.Boolean) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneExists(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.lang.Boolean) */ - public Query buildLuceneExists(LuceneQueryParser lqp, String propertyName, Boolean not) + public Query buildLuceneExists(LuceneQueryParser lqp, Boolean not) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneGreaterThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneGreaterThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneGreaterThan(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) + public Query buildLuceneGreaterThan(LuceneQueryParser lqp, Serializable value, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneGreaterThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneGreaterThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneGreaterThanOrEquals(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) + public Query buildLuceneGreaterThanOrEquals(LuceneQueryParser lqp, Serializable value, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneIn(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.util.Collection, java.lang.Boolean, - * org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneIn(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.util.Collection, java.lang.Boolean, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneIn(LuceneQueryParser lqp, String propertyName, Collection values, Boolean not, PredicateMode mode) + public Query buildLuceneIn(LuceneQueryParser lqp, Collection values, Boolean not, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneInequality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneInequality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneInequality(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) + public Query buildLuceneInequality(LuceneQueryParser lqp, Serializable value, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneLessThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLessThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneLessThan(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) + public Query buildLuceneLessThan(LuceneQueryParser lqp, Serializable value, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneLessThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLessThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneLessThanOrEquals(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) + public Query buildLuceneLessThanOrEquals(LuceneQueryParser lqp, Serializable value, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneLike(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, java.lang.Boolean) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLike(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, java.lang.Boolean) */ - public Query buildLuceneLike(LuceneQueryParser lqp, String propertyName, Serializable value, Boolean not) + public Query buildLuceneLike(LuceneQueryParser lqp, Serializable value, Boolean not) { return null; } - /* (non-Javadoc) - * @see org.alfresco.cmis.property.NamedPropertyAccessor#getLuceneSortField(java.lang.String) + /* + * (non-Javadoc) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#getLuceneSortField() */ - public String getLuceneSortField(String propertyName) + public String getLuceneSortField() { throw new UnsupportedOperationException(); } - } diff --git a/source/java/org/alfresco/cmis/property/ContentStreamLengthPropertyAccessor.java b/source/java/org/alfresco/cmis/property/ContentStreamLengthPropertyAccessor.java index 9ba8b3d57a..e86d7e746a 100644 --- a/source/java/org/alfresco/cmis/property/ContentStreamLengthPropertyAccessor.java +++ b/source/java/org/alfresco/cmis/property/ContentStreamLengthPropertyAccessor.java @@ -28,8 +28,6 @@ import java.io.Serializable; import java.util.Collection; import org.alfresco.cmis.dictionary.CMISDictionaryModel; -import org.alfresco.cmis.dictionary.CMISMapping; -import org.alfresco.cmis.dictionary.CMISScope; import org.alfresco.model.ContentModel; import org.alfresco.repo.search.impl.lucene.LuceneQueryParser; import org.alfresco.repo.search.impl.querymodel.PredicateMode; @@ -51,15 +49,23 @@ import org.apache.lucene.search.BooleanClause.Occur; * * @author andyh */ -public class ContentStreamLengthPropertyAccessor extends AbstractNamedPropertyAccessor +public class ContentStreamLengthPropertyAccessor extends AbstractPropertyAccessor { - - protected ContentStreamLengthPropertyAccessor(CMISMapping cmisMapping, ServiceRegistry serviceRegistry) + /** + * Construct + * + * @param serviceRegistry + */ + public ContentStreamLengthPropertyAccessor(ServiceRegistry serviceRegistry) { - super(cmisMapping, serviceRegistry, CMISScope.DOCUMENT, CMISDictionaryModel.PROP_CONTENT_STREAM_LENGTH); + super(serviceRegistry, CMISDictionaryModel.PROP_CONTENT_STREAM_LENGTH); } - public Serializable getProperty(NodeRef nodeRef) + /* + * (non-Javadoc) + * @see org.alfresco.cmis.property.PropertyAccessor#getValue(org.alfresco.service.cmr.repository.NodeRef) + */ + public Serializable getValue(NodeRef nodeRef) { Serializable value = getServiceRegistry().getNodeService().getProperty(nodeRef, ContentModel.PROP_CONTENT); if (value != null) @@ -71,14 +77,18 @@ public class ContentStreamLengthPropertyAccessor extends AbstractNamedPropertyAc { return 0L; } - } - public void setProperty(NodeRef nodeRef, Serializable value) + /* + * (non-Javadoc) + * @see org.alfresco.cmis.property.PropertyAccessor#setValue(org.alfresco.service.cmr.repository.NodeRef, java.io.Serializable) + */ + public void setValue(NodeRef nodeRef, Serializable value) { throw new UnsupportedOperationException(); } + private String getLuceneFieldName() { StringBuilder field = new StringBuilder(128); @@ -97,22 +107,18 @@ public class ContentStreamLengthPropertyAccessor extends AbstractNamedPropertyAc /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneEquality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneEquality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneEquality(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneEquality(LuceneQueryParser lqp, Serializable value, PredicateMode mode) throws ParseException { return lqp.getFieldQuery(getLuceneFieldName(), getValueAsString(value)); } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneExists(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.lang.Boolean) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneExists(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.lang.Boolean) */ - public Query buildLuceneExists(LuceneQueryParser lqp, String propertyName, Boolean not) throws ParseException + public Query buildLuceneExists(LuceneQueryParser lqp, Boolean not) throws ParseException { if (not) { @@ -122,39 +128,31 @@ public class ContentStreamLengthPropertyAccessor extends AbstractNamedPropertyAc { return lqp.getFieldQuery("ISNOTNULL", ContentModel.PROP_CONTENT.toString()); } - } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneGreaterThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneGreaterThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneGreaterThan(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneGreaterThan(LuceneQueryParser lqp, Serializable value, PredicateMode mode) throws ParseException { return lqp.getRangeQuery(getLuceneFieldName(), getValueAsString(value), "MAX", false, true); } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneGreaterThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneGreaterThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneGreaterThanOrEquals(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneGreaterThanOrEquals(LuceneQueryParser lqp, Serializable value, PredicateMode mode) throws ParseException { return lqp.getRangeQuery(getLuceneFieldName(), getValueAsString(value), "MAX", true, true); } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneIn(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.util.Collection, java.lang.Boolean, - * org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneIn(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.util.Collection, java.lang.Boolean, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneIn(LuceneQueryParser lqp, String propertyName, Collection values, Boolean not, PredicateMode mode) throws ParseException + public Query buildLuceneIn(LuceneQueryParser lqp, Collection values, Boolean not, PredicateMode mode) throws ParseException { String field = getLuceneFieldName(); @@ -212,44 +210,36 @@ public class ContentStreamLengthPropertyAccessor extends AbstractNamedPropertyAc /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneInequality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneInequality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneInequality(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneInequality(LuceneQueryParser lqp, Serializable value, PredicateMode mode) throws ParseException { return lqp.getDoesNotMatchFieldQuery(getLuceneFieldName(), getValueAsString(value)); } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneLessThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLessThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneLessThan(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneLessThan(LuceneQueryParser lqp, Serializable value, PredicateMode mode) throws ParseException { return lqp.getRangeQuery(getLuceneFieldName(), "MIN", getValueAsString(value), true, false); } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneLessThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLessThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneLessThanOrEquals(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneLessThanOrEquals(LuceneQueryParser lqp, Serializable value, PredicateMode mode) throws ParseException { return lqp.getRangeQuery(getLuceneFieldName(), "MIN", getValueAsString(value), true, true); } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneLike(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, java.lang.Boolean) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLike(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, java.lang.Boolean) */ - public Query buildLuceneLike(LuceneQueryParser lqp, String propertyName, Serializable value, Boolean not) throws ParseException + public Query buildLuceneLike(LuceneQueryParser lqp, Serializable value, Boolean not) throws ParseException { if (not) { @@ -264,10 +254,11 @@ public class ContentStreamLengthPropertyAccessor extends AbstractNamedPropertyAc } } - /* (non-Javadoc) - * @see org.alfresco.cmis.property.NamedPropertyAccessor#getLuceneSortField(java.lang.String) + /* + * (non-Javadoc) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#getLuceneSortField() */ - public String getLuceneSortField(String propertyName) + public String getLuceneSortField() { return getLuceneFieldName(); } diff --git a/source/java/org/alfresco/cmis/property/ContentStreamMimetypePropertyAccessor.java b/source/java/org/alfresco/cmis/property/ContentStreamMimetypePropertyAccessor.java index 00d71463cc..866f8ea002 100644 --- a/source/java/org/alfresco/cmis/property/ContentStreamMimetypePropertyAccessor.java +++ b/source/java/org/alfresco/cmis/property/ContentStreamMimetypePropertyAccessor.java @@ -28,8 +28,6 @@ import java.io.Serializable; import java.util.Collection; import org.alfresco.cmis.dictionary.CMISDictionaryModel; -import org.alfresco.cmis.dictionary.CMISMapping; -import org.alfresco.cmis.dictionary.CMISScope; import org.alfresco.model.ContentModel; import org.alfresco.repo.search.impl.lucene.LuceneQueryParser; import org.alfresco.repo.search.impl.querymodel.PredicateMode; @@ -51,15 +49,23 @@ import org.apache.lucene.search.BooleanClause.Occur; * * @author andyh */ -public class ContentStreamMimetypePropertyAccessor extends AbstractNamedPropertyAccessor +public class ContentStreamMimetypePropertyAccessor extends AbstractPropertyAccessor { - - protected ContentStreamMimetypePropertyAccessor(CMISMapping cmisMapping, ServiceRegistry serviceRegistry) + /** + * Construct + * + * @param serviceRegistry + */ + public ContentStreamMimetypePropertyAccessor(ServiceRegistry serviceRegistry) { - super(cmisMapping, serviceRegistry, CMISScope.DOCUMENT, CMISDictionaryModel.PROP_CONTENT_STREAM_MIME_TYPE); + super(serviceRegistry, CMISDictionaryModel.PROP_CONTENT_STREAM_MIME_TYPE); } - public Serializable getProperty(NodeRef nodeRef) + /* + * (non-Javadoc) + * @see org.alfresco.cmis.property.PropertyAccessor#getValue(org.alfresco.service.cmr.repository.NodeRef) + */ + public Serializable getValue(NodeRef nodeRef) { Serializable value = getServiceRegistry().getNodeService().getProperty(nodeRef, ContentModel.PROP_CONTENT); if (value != null) @@ -73,7 +79,11 @@ public class ContentStreamMimetypePropertyAccessor extends AbstractNamedProperty } } - public void setProperty(NodeRef nodeRef, Serializable value) + /* + * (non-Javadoc) + * @see org.alfresco.cmis.property.PropertyAccessor#setValue(org.alfresco.service.cmr.repository.NodeRef, java.io.Serializable) + */ + public void setValue(NodeRef nodeRef, Serializable value) { throw new UnsupportedOperationException(); } @@ -96,22 +106,18 @@ public class ContentStreamMimetypePropertyAccessor extends AbstractNamedProperty /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneEquality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneEquality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneEquality(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneEquality(LuceneQueryParser lqp, Serializable value, PredicateMode mode) throws ParseException { return lqp.getFieldQuery(getLuceneFieldName(), getValueAsString(value)); } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneExists(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.lang.Boolean) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneExists(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.lang.Boolean) */ - public Query buildLuceneExists(LuceneQueryParser lqp, String propertyName, Boolean not) throws ParseException + public Query buildLuceneExists(LuceneQueryParser lqp, Boolean not) throws ParseException { if (not) { @@ -126,34 +132,27 @@ public class ContentStreamMimetypePropertyAccessor extends AbstractNamedProperty /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneGreaterThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneGreaterThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneGreaterThan(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneGreaterThan(LuceneQueryParser lqp, Serializable value, PredicateMode mode) throws ParseException { return lqp.getRangeQuery(getLuceneFieldName(), getValueAsString(value), "\uFFFF", false, true); } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneGreaterThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneGreaterThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneGreaterThanOrEquals(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneGreaterThanOrEquals(LuceneQueryParser lqp, Serializable value, PredicateMode mode) throws ParseException { return lqp.getRangeQuery(getLuceneFieldName(), getValueAsString(value), "\uFFFF", true, true); } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneIn(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.util.Collection, java.lang.Boolean, - * org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneIn(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.util.Collection, java.lang.Boolean, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneIn(LuceneQueryParser lqp, String propertyName, Collection values, Boolean not, PredicateMode mode) throws ParseException + public Query buildLuceneIn(LuceneQueryParser lqp, Collection values, Boolean not, PredicateMode mode) throws ParseException { String field = getLuceneFieldName(); @@ -211,44 +210,36 @@ public class ContentStreamMimetypePropertyAccessor extends AbstractNamedProperty /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneInequality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneInequality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneInequality(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneInequality(LuceneQueryParser lqp, Serializable value, PredicateMode mode) throws ParseException { return lqp.getDoesNotMatchFieldQuery(getLuceneFieldName(), getValueAsString(value)); } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneLessThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLessThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneLessThan(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneLessThan(LuceneQueryParser lqp, Serializable value, PredicateMode mode) throws ParseException { return lqp.getRangeQuery(getLuceneFieldName(), "\u0000", getValueAsString(value), true, false); } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneLessThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLessThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneLessThanOrEquals(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneLessThanOrEquals(LuceneQueryParser lqp, Serializable value, PredicateMode mode) throws ParseException { return lqp.getRangeQuery(getLuceneFieldName(), "\u0000", getValueAsString(value), true, true); } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneLike(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, java.lang.Boolean) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLike(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, java.lang.Boolean) */ - public Query buildLuceneLike(LuceneQueryParser lqp, String propertyName, Serializable value, Boolean not) throws ParseException + public Query buildLuceneLike(LuceneQueryParser lqp, Serializable value, Boolean not) throws ParseException { if (not) { @@ -263,10 +254,11 @@ public class ContentStreamMimetypePropertyAccessor extends AbstractNamedProperty } } - /* (non-Javadoc) - * @see org.alfresco.cmis.property.NamedPropertyAccessor#getLuceneSortField(java.lang.String) + /* + * (non-Javadoc) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#getLuceneSortField() */ - public String getLuceneSortField(String propertyName) + public String getLuceneSortField() { return getLuceneFieldName(); } diff --git a/source/java/org/alfresco/cmis/property/ContentStreamUriPropertyAccessor.java b/source/java/org/alfresco/cmis/property/ContentStreamUriPropertyAccessor.java index ec76040754..7176f3301e 100644 --- a/source/java/org/alfresco/cmis/property/ContentStreamUriPropertyAccessor.java +++ b/source/java/org/alfresco/cmis/property/ContentStreamUriPropertyAccessor.java @@ -28,8 +28,6 @@ import java.io.Serializable; import java.util.Collection; import org.alfresco.cmis.dictionary.CMISDictionaryModel; -import org.alfresco.cmis.dictionary.CMISMapping; -import org.alfresco.cmis.dictionary.CMISScope; import org.alfresco.model.ContentModel; import org.alfresco.repo.search.impl.lucene.LuceneQueryParser; import org.alfresco.repo.search.impl.querymodel.PredicateMode; @@ -43,15 +41,23 @@ import org.apache.lucene.search.Query; * * @author andyh */ -public class ContentStreamUriPropertyAccessor extends AbstractNamedPropertyAccessor +public class ContentStreamUriPropertyAccessor extends AbstractPropertyAccessor { - - protected ContentStreamUriPropertyAccessor(CMISMapping cmisMapping, ServiceRegistry serviceRegistry) + /** + * Construct + * + * @param serviceRegistry + */ + public ContentStreamUriPropertyAccessor(ServiceRegistry serviceRegistry) { - super(cmisMapping, serviceRegistry, CMISScope.DOCUMENT, CMISDictionaryModel.PROP_CONTENT_STREAM_URI); + super(serviceRegistry, CMISDictionaryModel.PROP_CONTENT_STREAM_URI); } - public Serializable getProperty(NodeRef nodeRef) + /* + * (non-Javadoc) + * @see org.alfresco.cmis.property.PropertyAccessor#getValue(org.alfresco.service.cmr.repository.NodeRef) + */ + public Serializable getValue(NodeRef nodeRef) { StringBuilder sb = new StringBuilder(); sb.append("/api/node/"); @@ -65,116 +71,102 @@ public class ContentStreamUriPropertyAccessor extends AbstractNamedPropertyAcces return sb.toString(); } - public void setProperty(NodeRef nodeRef, Serializable value) + /* + * (non-Javadoc) + * @see org.alfresco.cmis.property.PropertyAccessor#setValue(org.alfresco.service.cmr.repository.NodeRef, java.io.Serializable) + */ + public void setValue(NodeRef nodeRef, Serializable value) { throw new UnsupportedOperationException(); } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneEquality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneEquality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneEquality(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneEquality(LuceneQueryParser lqp, Serializable value, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneExists(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.lang.Boolean) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneExists(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.lang.Boolean) */ - public Query buildLuceneExists(LuceneQueryParser lqp, String propertyName, Boolean not) throws ParseException + public Query buildLuceneExists(LuceneQueryParser lqp, Boolean not) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneGreaterThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneGreaterThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneGreaterThan(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneGreaterThan(LuceneQueryParser lqp, Serializable value, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneGreaterThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneGreaterThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneGreaterThanOrEquals(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneGreaterThanOrEquals(LuceneQueryParser lqp, Serializable value, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneIn(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.util.Collection, java.lang.Boolean, - * org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneIn(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.util.Collection, java.lang.Boolean, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneIn(LuceneQueryParser lqp, String propertyName, Collection values, Boolean not, PredicateMode mode) throws ParseException + public Query buildLuceneIn(LuceneQueryParser lqp, Collection values, Boolean not, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneInequality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneInequality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneInequality(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneInequality(LuceneQueryParser lqp, Serializable value, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneLessThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLessThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneLessThan(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneLessThan(LuceneQueryParser lqp, Serializable value, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneLessThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLessThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneLessThanOrEquals(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneLessThanOrEquals(LuceneQueryParser lqp, Serializable value, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneLike(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, java.lang.Boolean) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLike(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, java.lang.Boolean) */ - public Query buildLuceneLike(LuceneQueryParser lqp, String propertyName, Serializable value, Boolean not) throws ParseException + public Query buildLuceneLike(LuceneQueryParser lqp, Serializable value, Boolean not) { return null; } - - /* (non-Javadoc) - * @see org.alfresco.cmis.property.NamedPropertyAccessor#getLuceneSortField(java.lang.String) + + /* + * (non-Javadoc) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#getLuceneSortField() */ - public String getLuceneSortField(String propertyName) + public String getLuceneSortField() { - return null; + throw new UnsupportedOperationException(); } } diff --git a/source/java/org/alfresco/cmis/property/SimplePropertyAccessor.java b/source/java/org/alfresco/cmis/property/DirectPropertyAccessor.java similarity index 63% rename from source/java/org/alfresco/cmis/property/SimplePropertyAccessor.java rename to source/java/org/alfresco/cmis/property/DirectPropertyAccessor.java index dec09dc016..23d6b0e0ee 100644 --- a/source/java/org/alfresco/cmis/property/SimplePropertyAccessor.java +++ b/source/java/org/alfresco/cmis/property/DirectPropertyAccessor.java @@ -27,8 +27,6 @@ package org.alfresco.cmis.property; import java.io.Serializable; import java.util.Collection; -import org.alfresco.cmis.dictionary.CMISMapping; -import org.alfresco.cmis.dictionary.CMISScope; import org.alfresco.repo.search.impl.lucene.LuceneQueryParser; import org.alfresco.repo.search.impl.querymodel.PredicateMode; import org.alfresco.service.ServiceRegistry; @@ -49,22 +47,46 @@ import org.apache.lucene.search.BooleanClause.Occur; * * @author andyh */ -public class SimplePropertyAccessor extends AbstractNamedPropertyAccessor +public class DirectPropertyAccessor extends AbstractPropertyAccessor { - private QName propertyQname; + private QName alfrescoName; - protected SimplePropertyAccessor(CMISMapping cmisMapping, ServiceRegistry serviceRegistry, CMISScope scope, String propertyName, QName mapping) + /** + * Construct + * + * @param serviceRegistry + * @param propertyName + * @param alfrescoName + */ + public DirectPropertyAccessor(ServiceRegistry serviceRegistry, String propertyName, QName alfrescoName) { - super(cmisMapping, serviceRegistry, scope, propertyName); - propertyQname = mapping; + super(serviceRegistry, propertyName); + this.alfrescoName = alfrescoName; } - public Serializable getProperty(NodeRef nodeRef) + /* + * (non-Javadoc) + * @see org.alfresco.cmis.property.AbstractPropertyAccessor#getMappedProperty() + */ + public QName getMappedProperty() { - return getServiceRegistry().getNodeService().getProperty(nodeRef, propertyQname); + return alfrescoName; + } + + /* + * (non-Javadoc) + * @see org.alfresco.cmis.property.PropertyAccessor#getValue(org.alfresco.service.cmr.repository.NodeRef) + */ + public Serializable getValue(NodeRef nodeRef) + { + return getServiceRegistry().getNodeService().getProperty(nodeRef, alfrescoName); } - public void setProperty(NodeRef nodeRef, Serializable value) + /* + * (non-Javadoc) + * @see org.alfresco.cmis.property.PropertyAccessor#setValue(org.alfresco.service.cmr.repository.NodeRef, java.io.Serializable) + */ + public void setValue(NodeRef nodeRef, Serializable value) { throw new UnsupportedOperationException(); } @@ -73,13 +95,13 @@ public class SimplePropertyAccessor extends AbstractNamedPropertyAccessor { StringBuilder field = new StringBuilder(64); field.append("@"); - field.append(propertyQname); + field.append(alfrescoName); return field.toString(); } private String getValueAsString(Serializable value) { - PropertyDefinition pd = getServiceRegistry().getDictionaryService().getProperty(propertyQname); + PropertyDefinition pd = getServiceRegistry().getDictionaryService().getProperty(alfrescoName); Object converted = DefaultTypeConverter.INSTANCE.convert(pd.getDataType(), value); String asString = DefaultTypeConverter.INSTANCE.convert(String.class, converted); return asString; @@ -87,42 +109,34 @@ public class SimplePropertyAccessor extends AbstractNamedPropertyAccessor /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneEquality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneEquality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneEquality(LuceneQueryParser lqp, String xxxx, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneEquality(LuceneQueryParser lqp, Serializable value, PredicateMode mode) throws ParseException { - String field = getLuceneFieldName(); - String stringValue = getValueAsString(value); - return lqp.getFieldQuery(field, stringValue); + return lqp.getFieldQuery(getLuceneFieldName(), getValueAsString(value)); } - + /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneExists(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.lang.Boolean) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneExists(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.lang.Boolean) */ - public Query buildLuceneExists(LuceneQueryParser lqp, String xxxx, Boolean not) throws ParseException + public Query buildLuceneExists(LuceneQueryParser lqp, Boolean not) throws ParseException { if (not) { - return lqp.getFieldQuery("ISNULL", propertyQname.toString()); + return lqp.getFieldQuery("ISNULL", alfrescoName.toString()); } else { - return lqp.getFieldQuery("ISNOTNULL", propertyQname.toString()); + return lqp.getFieldQuery("ISNOTNULL", alfrescoName.toString()); } } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneGreaterThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneGreaterThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneGreaterThan(LuceneQueryParser lqp, String xxxx, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneGreaterThan(LuceneQueryParser lqp, Serializable value, PredicateMode mode) throws ParseException { String field = getLuceneFieldName(); String stringValue = getValueAsString(value); @@ -131,11 +145,9 @@ public class SimplePropertyAccessor extends AbstractNamedPropertyAccessor /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneGreaterThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneGreaterThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneGreaterThanOrEquals(LuceneQueryParser lqp, String xxxx, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneGreaterThanOrEquals(LuceneQueryParser lqp, Serializable value, PredicateMode mode) throws ParseException { String field = getLuceneFieldName(); String stringValue = getValueAsString(value); @@ -144,15 +156,12 @@ public class SimplePropertyAccessor extends AbstractNamedPropertyAccessor /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneIn(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.util.Collection, java.lang.Boolean, - * org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneIn(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.util.Collection, java.lang.Boolean, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneIn(LuceneQueryParser lqp, String xxxx, Collection values, Boolean not, PredicateMode mode) throws ParseException + public Query buildLuceneIn(LuceneQueryParser lqp, Collection values, Boolean not, PredicateMode mode) throws ParseException { String field = getLuceneFieldName(); - PropertyDefinition pd = getServiceRegistry().getDictionaryService().getProperty(propertyQname); + PropertyDefinition pd = getServiceRegistry().getDictionaryService().getProperty(alfrescoName); // Check type conversion @@ -208,11 +217,9 @@ public class SimplePropertyAccessor extends AbstractNamedPropertyAccessor /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneInequality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneInequality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneInequality(LuceneQueryParser lqp, String xxxx, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneInequality(LuceneQueryParser lqp, Serializable value, PredicateMode mode) throws ParseException { String field = getLuceneFieldName(); String stringValue = getValueAsString(value); @@ -221,11 +228,9 @@ public class SimplePropertyAccessor extends AbstractNamedPropertyAccessor /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneLessThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLessThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneLessThan(LuceneQueryParser lqp, String xxxx, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneLessThan(LuceneQueryParser lqp, Serializable value, PredicateMode mode) throws ParseException { String field = getLuceneFieldName(); String stringValue = getValueAsString(value); @@ -234,11 +239,9 @@ public class SimplePropertyAccessor extends AbstractNamedPropertyAccessor /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneLessThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLessThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneLessThanOrEquals(LuceneQueryParser lqp, String xxx, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneLessThanOrEquals(LuceneQueryParser lqp, Serializable value, PredicateMode mode) throws ParseException { String field = getLuceneFieldName(); String stringValue = getValueAsString(value); @@ -247,11 +250,9 @@ public class SimplePropertyAccessor extends AbstractNamedPropertyAccessor /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneLike(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, java.lang.Boolean) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLike(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, java.lang.Boolean) */ - public Query buildLuceneLike(LuceneQueryParser lqp, String xxxx, Serializable value, Boolean not) throws ParseException + public Query buildLuceneLike(LuceneQueryParser lqp, Serializable value, Boolean not) throws ParseException { String field = getLuceneFieldName(); String stringValue = getValueAsString(value); @@ -269,10 +270,11 @@ public class SimplePropertyAccessor extends AbstractNamedPropertyAccessor } } - /* (non-Javadoc) - * @see org.alfresco.cmis.property.NamedPropertyAccessor#getLuceneSortField(java.lang.String) + /* + * (non-Javadoc) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#getLuceneSortField() */ - public String getLuceneSortField(String propertyName) + public String getLuceneSortField() { return getLuceneFieldName(); } diff --git a/source/java/org/alfresco/cmis/property/FixedValuePropertyAccessor.java b/source/java/org/alfresco/cmis/property/FixedValuePropertyAccessor.java index 7aac6c58a6..779fc68e88 100644 --- a/source/java/org/alfresco/cmis/property/FixedValuePropertyAccessor.java +++ b/source/java/org/alfresco/cmis/property/FixedValuePropertyAccessor.java @@ -29,8 +29,6 @@ import java.util.Collection; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.alfresco.cmis.dictionary.CMISMapping; -import org.alfresco.cmis.dictionary.CMISScope; import org.alfresco.repo.search.impl.lucene.LuceneQueryParser; import org.alfresco.repo.search.impl.querymodel.PredicateMode; import org.alfresco.service.ServiceRegistry; @@ -49,45 +47,48 @@ import org.apache.lucene.search.TermQuery; * * @author andyh */ -public class FixedValuePropertyAccessor extends AbstractNamedPropertyAccessor +public class FixedValuePropertyAccessor extends AbstractPropertyAccessor { + private Serializable value; - protected FixedValuePropertyAccessor(CMISMapping cmisMapping, ServiceRegistry serviceRegistry, CMISScope scope, String propertyName) + /** + * Construct + * + * @param serviceRegistry + * @param propertyName + * @param value + */ + public FixedValuePropertyAccessor(ServiceRegistry serviceRegistry, String propertyName, Serializable value) { - super(cmisMapping, serviceRegistry, scope, propertyName); + super(serviceRegistry, propertyName); + this.value = value; } - Serializable fixedValue; - - public Serializable getFixedValue() + /* + * (non-Javadoc) + * @see org.alfresco.cmis.property.PropertyAccessor#getValue(org.alfresco.service.cmr.repository.NodeRef) + */ + public Serializable getValue(NodeRef nodeRef) { - return fixedValue; + return value; } - public void setFixedValue(Serializable fixedValue) - { - this.fixedValue = fixedValue; - } - - public Serializable getProperty(NodeRef nodeRef) - { - return fixedValue; - } - - public void setProperty(NodeRef nodeRef, Serializable value) + /* + * (non-Javadoc) + * @see org.alfresco.cmis.property.PropertyAccessor#setValue(org.alfresco.service.cmr.repository.NodeRef, java.io.Serializable) + */ + public void setValue(NodeRef nodeRef, Serializable value) { throw new UnsupportedOperationException(); } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneEquality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneEquality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneEquality(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneEquality(LuceneQueryParser lqp, Serializable value, PredicateMode mode) throws ParseException { - if (EqualsHelper.nullSafeEquals(fixedValue, value)) + if (EqualsHelper.nullSafeEquals(value, value)) { return new MatchAllDocsQuery(); } @@ -99,15 +100,13 @@ public class FixedValuePropertyAccessor extends AbstractNamedPropertyAccessor /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneExists(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.lang.Boolean) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneExists(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.lang.Boolean) */ - public Query buildLuceneExists(LuceneQueryParser lqp, String propertyName, Boolean not) throws ParseException + public Query buildLuceneExists(LuceneQueryParser lqp, Boolean not) throws ParseException { if (not) { - if (fixedValue == null) + if (value == null) { return new MatchAllDocsQuery(); } @@ -118,7 +117,7 @@ public class FixedValuePropertyAccessor extends AbstractNamedPropertyAccessor } else { - if (fixedValue == null) + if (value == null) { return new TermQuery(new Term("NO_TOKENS", "__")); } @@ -132,16 +131,14 @@ public class FixedValuePropertyAccessor extends AbstractNamedPropertyAccessor /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneGreaterThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneGreaterThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ @SuppressWarnings("unchecked") - public Query buildLuceneGreaterThan(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneGreaterThan(LuceneQueryParser lqp, Serializable value, PredicateMode mode) throws ParseException { - if (fixedValue instanceof Comparable) + if (value instanceof Comparable) { - Comparable comparable = (Comparable) fixedValue; + Comparable comparable = (Comparable) value; if (comparable.compareTo(value) > 0) { return new MatchAllDocsQuery(); @@ -159,16 +156,14 @@ public class FixedValuePropertyAccessor extends AbstractNamedPropertyAccessor /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneGreaterThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneGreaterThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ @SuppressWarnings("unchecked") - public Query buildLuceneGreaterThanOrEquals(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneGreaterThanOrEquals(LuceneQueryParser lqp, Serializable value, PredicateMode mode) throws ParseException { - if (fixedValue instanceof Comparable) + if (value instanceof Comparable) { - Comparable comparable = (Comparable) fixedValue; + Comparable comparable = (Comparable) value; if (comparable.compareTo(value) >= 0) { return new MatchAllDocsQuery(); @@ -186,17 +181,14 @@ public class FixedValuePropertyAccessor extends AbstractNamedPropertyAccessor /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneIn(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.util.Collection, java.lang.Boolean, - * org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneIn(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.util.Collection, java.lang.Boolean, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneIn(LuceneQueryParser lqp, String propertyName, Collection values, Boolean not, PredicateMode mode) throws ParseException + public Query buildLuceneIn(LuceneQueryParser lqp, Collection values, Boolean not, PredicateMode mode) throws ParseException { boolean in = false; for (Serializable value : values) { - if (EqualsHelper.nullSafeEquals(fixedValue, value)) + if (EqualsHelper.nullSafeEquals(value, value)) { in = true; break; @@ -211,18 +203,15 @@ public class FixedValuePropertyAccessor extends AbstractNamedPropertyAccessor { return new TermQuery(new Term("NO_TOKENS", "__")); } - } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneInequality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneInequality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneInequality(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneInequality(LuceneQueryParser lqp, Serializable value, PredicateMode mode) throws ParseException { - if (!EqualsHelper.nullSafeEquals(fixedValue, value)) + if (!EqualsHelper.nullSafeEquals(value, value)) { return new MatchAllDocsQuery(); } @@ -234,16 +223,14 @@ public class FixedValuePropertyAccessor extends AbstractNamedPropertyAccessor /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneLessThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLessThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ @SuppressWarnings("unchecked") - public Query buildLuceneLessThan(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneLessThan(LuceneQueryParser lqp, Serializable value, PredicateMode mode) throws ParseException { - if (fixedValue instanceof Comparable) + if (value instanceof Comparable) { - Comparable comparable = (Comparable) fixedValue; + Comparable comparable = (Comparable) value; if (comparable.compareTo(value) < 0) { return new MatchAllDocsQuery(); @@ -261,16 +248,14 @@ public class FixedValuePropertyAccessor extends AbstractNamedPropertyAccessor /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneLessThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLessThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ @SuppressWarnings("unchecked") - public Query buildLuceneLessThanOrEquals(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneLessThanOrEquals(LuceneQueryParser lqp, Serializable value, PredicateMode mode) throws ParseException { - if (fixedValue instanceof Comparable) + if (value instanceof Comparable) { - Comparable comparable = (Comparable) fixedValue; + Comparable comparable = (Comparable) value; if (comparable.compareTo(value) <= 0) { return new MatchAllDocsQuery(); @@ -288,22 +273,19 @@ public class FixedValuePropertyAccessor extends AbstractNamedPropertyAccessor /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneLike(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, java.lang.Boolean) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLike(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, java.lang.Boolean) */ - public Query buildLuceneLike(LuceneQueryParser lqp, String propertyName, Serializable value, Boolean not) throws ParseException + public Query buildLuceneLike(LuceneQueryParser lqp, Serializable value, Boolean not) throws ParseException { - - if (fixedValue != null) + if (value != null) { boolean matches = false; - Object converted = DefaultTypeConverter.INSTANCE.convert(fixedValue.getClass(), value); + Object converted = DefaultTypeConverter.INSTANCE.convert(value.getClass(), value); String asString = DefaultTypeConverter.INSTANCE.convert(String.class, converted); String regExpression = SearchLanguageConversion.convertSQLLikeToRegex(asString); Pattern pattern = Pattern.compile(regExpression); - String target = DefaultTypeConverter.INSTANCE.convert(String.class, fixedValue); + String target = DefaultTypeConverter.INSTANCE.convert(String.class, value); Matcher matcher = pattern.matcher(target); if (matcher.matches()) { @@ -323,13 +305,13 @@ public class FixedValuePropertyAccessor extends AbstractNamedPropertyAccessor { return new TermQuery(new Term("NO_TOKENS", "__")); } - } - - /* (non-Javadoc) - * @see org.alfresco.cmis.property.NamedPropertyAccessor#getLuceneSortField(java.lang.String) + + /* + * (non-Javadoc) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#getLuceneSortField() */ - public String getLuceneSortField(String propertyName) + public String getLuceneSortField() { throw new UnsupportedOperationException(); } diff --git a/source/java/org/alfresco/cmis/property/GenericPropertyAccessor.java b/source/java/org/alfresco/cmis/property/GenericPropertyAccessor.java deleted file mode 100644 index 20cb660712..0000000000 --- a/source/java/org/alfresco/cmis/property/GenericPropertyAccessor.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (C) 2005-2007 Alfresco Software Limited. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program 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 General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - * As a special exception to the terms and conditions of version 2.0 of - * the GPL, you may redistribute this Program in connection with Free/Libre - * and Open Source Software ("FLOSS") applications as described in Alfresco's - * FLOSS exception. You should have recieved a copy of the text describing - * the FLOSS exception, and it is also available here: - * http://www.alfresco.com/legal/licensing" - */ -package org.alfresco.cmis.property; - -import java.io.Serializable; -import java.util.Collection; - -import org.alfresco.repo.search.impl.lucene.LuceneQueryParser; -import org.alfresco.repo.search.impl.querymodel.PredicateMode; -import org.alfresco.service.cmr.repository.NodeRef; -import org.apache.lucene.queryParser.ParseException; -import org.apache.lucene.search.Query; - -/** - * The API to access a property. - * - * @author andyh - */ -public interface GenericPropertyAccessor -{ - /** - * Get the property value - * - * @param nodeRef - * @param propertyName - * @return - */ - public Serializable getProperty(NodeRef nodeRef, String propertyName); - - /** - * Set the property value - * - * @param nodeRef - * @param propertyName - * @Param value - */ - public void setProperty(NodeRef nodeRef, String propertyName, Serializable value); - - public Query buildLuceneEquality(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException; - - public Query buildLuceneExists(LuceneQueryParser lqp, String propertyName, Boolean not) throws ParseException; - - public Query buildLuceneGreaterThan(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException; - - public Query buildLuceneGreaterThanOrEquals(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException; - - public Query buildLuceneIn(LuceneQueryParser lqp, String propertyName, Collection values, Boolean not, PredicateMode mode) throws ParseException; - - public Query buildLuceneInequality(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException; - - public Query buildLuceneLessThan(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException; - - public Query buildLuceneLessThanOrEquals(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException; - - public Query buildLuceneLike(LuceneQueryParser lqp, String propertyName, Serializable value, Boolean not) throws ParseException; - - public String getLuceneSortField(String propertyName); - - -} diff --git a/source/java/org/alfresco/cmis/property/IsImmutablePropertyAccessor.java b/source/java/org/alfresco/cmis/property/IsImmutablePropertyAccessor.java index 5b143a09fd..1b909e38b4 100644 --- a/source/java/org/alfresco/cmis/property/IsImmutablePropertyAccessor.java +++ b/source/java/org/alfresco/cmis/property/IsImmutablePropertyAccessor.java @@ -28,8 +28,6 @@ import java.io.Serializable; import java.util.Collection; import org.alfresco.cmis.dictionary.CMISDictionaryModel; -import org.alfresco.cmis.dictionary.CMISMapping; -import org.alfresco.cmis.dictionary.CMISScope; import org.alfresco.model.ContentModel; import org.alfresco.repo.search.impl.lucene.LuceneQueryParser; import org.alfresco.repo.search.impl.querymodel.PredicateMode; @@ -37,7 +35,6 @@ import org.alfresco.service.ServiceRegistry; import org.alfresco.service.cmr.lock.LockType; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter; -import org.apache.lucene.queryParser.ParseException; import org.apache.lucene.search.Query; /** @@ -45,15 +42,23 @@ import org.apache.lucene.search.Query; * * @author andyh */ -public class IsImmutablePropertyAccessor extends AbstractNamedPropertyAccessor +public class IsImmutablePropertyAccessor extends AbstractPropertyAccessor { - - protected IsImmutablePropertyAccessor(CMISMapping cmisMapping, ServiceRegistry serviceRegistry) + /** + * Construct + * + * @param serviceRegistry + */ + public IsImmutablePropertyAccessor(ServiceRegistry serviceRegistry) { - super(cmisMapping, serviceRegistry, CMISScope.DOCUMENT, CMISDictionaryModel.PROP_IS_IMMUTABLE); + super(serviceRegistry, CMISDictionaryModel.PROP_IS_IMMUTABLE); } - public Serializable getProperty(NodeRef nodeRef) + /* + * (non-Javadoc) + * @see org.alfresco.cmis.property.PropertyAccessor#getValue(org.alfresco.service.cmr.repository.NodeRef) + */ + public Serializable getValue(NodeRef nodeRef) { LockType type = getServiceRegistry().getLockService().getLockType(nodeRef); if (type == LockType.READ_ONLY_LOCK) @@ -72,118 +77,102 @@ public class IsImmutablePropertyAccessor extends AbstractNamedPropertyAccessor return Boolean.valueOf(false); } - public void setProperty(NodeRef nodeRef, Serializable value) + /* + * (non-Javadoc) + * @see org.alfresco.cmis.property.PropertyAccessor#setValue(org.alfresco.service.cmr.repository.NodeRef, java.io.Serializable) + */ + public void setValue(NodeRef nodeRef, Serializable value) { throw new UnsupportedOperationException(); } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneEquality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneEquality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneEquality(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException - { - // TODO Auto-generated method stub - return null; - } - - /* - * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneExists(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.lang.Boolean) - */ - public Query buildLuceneExists(LuceneQueryParser lqp, String propertyName, Boolean not) throws ParseException + public Query buildLuceneEquality(LuceneQueryParser lqp, Serializable value, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneGreaterThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneExists(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.lang.Boolean) */ - public Query buildLuceneGreaterThan(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneExists(LuceneQueryParser lqp, Boolean not) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneGreaterThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneGreaterThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneGreaterThanOrEquals(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneGreaterThan(LuceneQueryParser lqp, Serializable value, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneIn(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.util.Collection, java.lang.Boolean, - * org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneGreaterThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneIn(LuceneQueryParser lqp, String propertyName, Collection values, Boolean not, PredicateMode mode) throws ParseException + public Query buildLuceneGreaterThanOrEquals(LuceneQueryParser lqp, Serializable value, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneInequality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneIn(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.util.Collection, java.lang.Boolean, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneInequality(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneIn(LuceneQueryParser lqp, Collection values, Boolean not, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneLessThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneInequality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneLessThan(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneInequality(LuceneQueryParser lqp, Serializable value, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneLessThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLessThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneLessThanOrEquals(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneLessThan(LuceneQueryParser lqp, Serializable value, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneLike(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, java.lang.Boolean) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLessThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneLike(LuceneQueryParser lqp, String propertyName, Serializable value, Boolean not) throws ParseException + public Query buildLuceneLessThanOrEquals(LuceneQueryParser lqp, Serializable value, PredicateMode mode) { return null; } - - /* (non-Javadoc) - * @see org.alfresco.cmis.property.NamedPropertyAccessor#getLuceneSortField(java.lang.String) + + /* + * (non-Javadoc) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLike(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, java.lang.Boolean) */ - public String getLuceneSortField(String propertyName) + public Query buildLuceneLike(LuceneQueryParser lqp, Serializable value, Boolean not) + { + return null; + } + + /* + * (non-Javadoc) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#getLuceneSortField() + */ + public String getLuceneSortField() { throw new UnsupportedOperationException(); } - } diff --git a/source/java/org/alfresco/cmis/property/IsLatestMajorVersionPropertyAccessor.java b/source/java/org/alfresco/cmis/property/IsLatestMajorVersionPropertyAccessor.java index d89fc4336c..c3fbbc0ecc 100644 --- a/source/java/org/alfresco/cmis/property/IsLatestMajorVersionPropertyAccessor.java +++ b/source/java/org/alfresco/cmis/property/IsLatestMajorVersionPropertyAccessor.java @@ -28,8 +28,6 @@ import java.io.Serializable; import java.util.Collection; import org.alfresco.cmis.dictionary.CMISDictionaryModel; -import org.alfresco.cmis.dictionary.CMISMapping; -import org.alfresco.cmis.dictionary.CMISScope; import org.alfresco.model.ContentModel; import org.alfresco.repo.search.impl.lucene.LuceneQueryParser; import org.alfresco.repo.search.impl.querymodel.PredicateMode; @@ -37,7 +35,6 @@ import org.alfresco.service.ServiceRegistry; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.version.Version; import org.alfresco.service.cmr.version.VersionType; -import org.apache.lucene.queryParser.ParseException; import org.apache.lucene.search.Query; /** @@ -45,15 +42,23 @@ import org.apache.lucene.search.Query; * * @author andyh */ -public class IsLatestMajorVersionPropertyAccessor extends AbstractNamedPropertyAccessor +public class IsLatestMajorVersionPropertyAccessor extends AbstractPropertyAccessor { - - protected IsLatestMajorVersionPropertyAccessor(CMISMapping cmisMapping, ServiceRegistry serviceRegistry) + /** + * Construct + * + * @param serviceRegistry + */ + public IsLatestMajorVersionPropertyAccessor(ServiceRegistry serviceRegistry) { - super(cmisMapping, serviceRegistry, CMISScope.DOCUMENT, CMISDictionaryModel.PROP_IS_LATEST_MAJOR_VERSION); + super(serviceRegistry, CMISDictionaryModel.PROP_IS_LATEST_MAJOR_VERSION); } - public Serializable getProperty(NodeRef nodeRef) + /* + * (non-Javadoc) + * @see org.alfresco.cmis.property.PropertyAccessor#getValue(org.alfresco.service.cmr.repository.NodeRef) + */ + public Serializable getValue(NodeRef nodeRef) { if (getServiceRegistry().getNodeService().hasAspect(nodeRef, ContentModel.ASPECT_WORKING_COPY)) { @@ -73,7 +78,11 @@ public class IsLatestMajorVersionPropertyAccessor extends AbstractNamedPropertyA } } - public void setProperty(NodeRef nodeRef, Serializable value) + /* + * (non-Javadoc) + * @see org.alfresco.cmis.property.PropertyAccessor#setValue(org.alfresco.service.cmr.repository.NodeRef, java.io.Serializable) + */ + public void setValue(NodeRef nodeRef, Serializable value) { throw new UnsupportedOperationException(); } @@ -81,110 +90,91 @@ public class IsLatestMajorVersionPropertyAccessor extends AbstractNamedPropertyA /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneEquality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneEquality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneEquality(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneEquality(LuceneQueryParser lqp, Serializable value, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneExists(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.lang.Boolean) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneExists(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.lang.Boolean) */ - public Query buildLuceneExists(LuceneQueryParser lqp, String propertyName, Boolean not) throws ParseException + public Query buildLuceneExists(LuceneQueryParser lqp, Boolean not) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneGreaterThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneGreaterThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneGreaterThan(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneGreaterThan(LuceneQueryParser lqp, Serializable value, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneGreaterThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneGreaterThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneGreaterThanOrEquals(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneGreaterThanOrEquals(LuceneQueryParser lqp, Serializable value, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneIn(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.util.Collection, java.lang.Boolean, - * org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneIn(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.util.Collection, java.lang.Boolean, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneIn(LuceneQueryParser lqp, String propertyName, Collection values, Boolean not, PredicateMode mode) throws ParseException + public Query buildLuceneIn(LuceneQueryParser lqp, Collection values, Boolean not, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneInequality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneInequality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneInequality(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneInequality(LuceneQueryParser lqp, Serializable value, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneLessThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLessThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneLessThan(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneLessThan(LuceneQueryParser lqp, Serializable value, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneLessThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLessThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneLessThanOrEquals(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneLessThanOrEquals(LuceneQueryParser lqp, Serializable value, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneLike(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, java.lang.Boolean) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLike(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, java.lang.Boolean) */ - public Query buildLuceneLike(LuceneQueryParser lqp, String propertyName, Serializable value, Boolean not) throws ParseException + public Query buildLuceneLike(LuceneQueryParser lqp, Serializable value, Boolean not) { return null; } - - /* (non-Javadoc) - * @see org.alfresco.cmis.property.NamedPropertyAccessor#getLuceneSortField(java.lang.String) + + /* + * (non-Javadoc) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#getLuceneSortField() */ - public String getLuceneSortField(String propertyName) + public String getLuceneSortField() { throw new UnsupportedOperationException(); } - } diff --git a/source/java/org/alfresco/cmis/property/IsLatestVersionPropertyAccessor.java b/source/java/org/alfresco/cmis/property/IsLatestVersionPropertyAccessor.java index f19c97483e..024b8c72b5 100644 --- a/source/java/org/alfresco/cmis/property/IsLatestVersionPropertyAccessor.java +++ b/source/java/org/alfresco/cmis/property/IsLatestVersionPropertyAccessor.java @@ -28,14 +28,11 @@ import java.io.Serializable; import java.util.Collection; import org.alfresco.cmis.dictionary.CMISDictionaryModel; -import org.alfresco.cmis.dictionary.CMISMapping; -import org.alfresco.cmis.dictionary.CMISScope; import org.alfresco.model.ContentModel; import org.alfresco.repo.search.impl.lucene.LuceneQueryParser; import org.alfresco.repo.search.impl.querymodel.PredicateMode; import org.alfresco.service.ServiceRegistry; import org.alfresco.service.cmr.repository.NodeRef; -import org.apache.lucene.queryParser.ParseException; import org.apache.lucene.search.Query; /** @@ -43,130 +40,123 @@ import org.apache.lucene.search.Query; * * @author andyh */ -public class IsLatestVersionPropertyAccessor extends AbstractNamedPropertyAccessor +public class IsLatestVersionPropertyAccessor extends AbstractPropertyAccessor { - - protected IsLatestVersionPropertyAccessor(CMISMapping cmisMapping, ServiceRegistry serviceRegistry) + /** + * Construct + * + * @param serviceRegistry + */ + public IsLatestVersionPropertyAccessor(ServiceRegistry serviceRegistry) { - super(cmisMapping, serviceRegistry, CMISScope.DOCUMENT, CMISDictionaryModel.PROP_IS_LATEST_VERSION); + super(serviceRegistry, CMISDictionaryModel.PROP_IS_LATEST_VERSION); } - public Serializable getProperty(NodeRef nodeRef) + /* + * (non-Javadoc) + * @see org.alfresco.cmis.property.PropertyAccessor#getValue(org.alfresco.service.cmr.repository.NodeRef) + */ + public Serializable getValue(NodeRef nodeRef) { return !getServiceRegistry().getNodeService().hasAspect(nodeRef, ContentModel.ASPECT_WORKING_COPY); } - public void setProperty(NodeRef nodeRef, Serializable value) + /* + * (non-Javadoc) + * @see org.alfresco.cmis.property.PropertyAccessor#setValue(org.alfresco.service.cmr.repository.NodeRef, java.io.Serializable) + */ + public void setValue(NodeRef nodeRef, Serializable value) { throw new UnsupportedOperationException(); } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneEquality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneEquality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneEquality(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneEquality(LuceneQueryParser lqp, Serializable value, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneExists(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.lang.Boolean) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneExists(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.lang.Boolean) */ - public Query buildLuceneExists(LuceneQueryParser lqp, String propertyName, Boolean not) throws ParseException + public Query buildLuceneExists(LuceneQueryParser lqp, Boolean not) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneGreaterThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneGreaterThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneGreaterThan(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneGreaterThan(LuceneQueryParser lqp, Serializable value, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneGreaterThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneGreaterThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneGreaterThanOrEquals(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneGreaterThanOrEquals(LuceneQueryParser lqp, Serializable value, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneIn(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.util.Collection, java.lang.Boolean, - * org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneIn(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.util.Collection, java.lang.Boolean, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneIn(LuceneQueryParser lqp, String propertyName, Collection values, Boolean not, PredicateMode mode) throws ParseException + public Query buildLuceneIn(LuceneQueryParser lqp, Collection values, Boolean not, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneInequality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneInequality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneInequality(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneInequality(LuceneQueryParser lqp, Serializable value, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneLessThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLessThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneLessThan(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneLessThan(LuceneQueryParser lqp, Serializable value, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneLessThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLessThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneLessThanOrEquals(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneLessThanOrEquals(LuceneQueryParser lqp, Serializable value, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneLike(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, java.lang.Boolean) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLike(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, java.lang.Boolean) */ - public Query buildLuceneLike(LuceneQueryParser lqp, String propertyName, Serializable value, Boolean not) throws ParseException + public Query buildLuceneLike(LuceneQueryParser lqp, Serializable value, Boolean not) { return null; } - - /* (non-Javadoc) - * @see org.alfresco.cmis.property.NamedPropertyAccessor#getLuceneSortField(java.lang.String) + + /* + * (non-Javadoc) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#getLuceneSortField() */ - public String getLuceneSortField(String propertyName) + public String getLuceneSortField() { throw new UnsupportedOperationException(); } - } diff --git a/source/java/org/alfresco/cmis/property/IsMajorVersionPropertyAccessor.java b/source/java/org/alfresco/cmis/property/IsMajorVersionPropertyAccessor.java index 48362f1c09..41e552f265 100644 --- a/source/java/org/alfresco/cmis/property/IsMajorVersionPropertyAccessor.java +++ b/source/java/org/alfresco/cmis/property/IsMajorVersionPropertyAccessor.java @@ -28,8 +28,6 @@ import java.io.Serializable; import java.util.Collection; import org.alfresco.cmis.dictionary.CMISDictionaryModel; -import org.alfresco.cmis.dictionary.CMISMapping; -import org.alfresco.cmis.dictionary.CMISScope; import org.alfresco.model.ContentModel; import org.alfresco.repo.search.impl.lucene.LuceneQueryParser; import org.alfresco.repo.search.impl.querymodel.PredicateMode; @@ -37,7 +35,6 @@ import org.alfresco.service.ServiceRegistry; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.version.Version; import org.alfresco.service.cmr.version.VersionType; -import org.apache.lucene.queryParser.ParseException; import org.apache.lucene.search.Query; /** @@ -45,15 +42,23 @@ import org.apache.lucene.search.Query; * * @author andyh */ -public class IsMajorVersionPropertyAccessor extends AbstractNamedPropertyAccessor +public class IsMajorVersionPropertyAccessor extends AbstractPropertyAccessor { - - protected IsMajorVersionPropertyAccessor(CMISMapping cmisMapping, ServiceRegistry serviceRegistry) + /** + * Construct + * + * @param serviceRegistry + */ + public IsMajorVersionPropertyAccessor(ServiceRegistry serviceRegistry) { - super(cmisMapping, serviceRegistry, CMISScope.DOCUMENT, CMISDictionaryModel.PROP_IS_MAJOR_VERSION); + super(serviceRegistry, CMISDictionaryModel.PROP_IS_MAJOR_VERSION); } - public Serializable getProperty(NodeRef nodeRef) + /* + * (non-Javadoc) + * @see org.alfresco.cmis.property.PropertyAccessor#getValue(org.alfresco.service.cmr.repository.NodeRef) + */ + public Serializable getValue(NodeRef nodeRef) { if (getServiceRegistry().getNodeService().hasAspect(nodeRef, ContentModel.ASPECT_WORKING_COPY)) { @@ -73,7 +78,11 @@ public class IsMajorVersionPropertyAccessor extends AbstractNamedPropertyAccesso } } - public void setProperty(NodeRef nodeRef, Serializable value) + /* + * (non-Javadoc) + * @see org.alfresco.cmis.property.PropertyAccessor#setValue(org.alfresco.service.cmr.repository.NodeRef, java.io.Serializable) + */ + public void setValue(NodeRef nodeRef, Serializable value) { throw new UnsupportedOperationException(); } @@ -81,110 +90,91 @@ public class IsMajorVersionPropertyAccessor extends AbstractNamedPropertyAccesso /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneEquality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneEquality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneEquality(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneEquality(LuceneQueryParser lqp, Serializable value, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneExists(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.lang.Boolean) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneExists(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.lang.Boolean) */ - public Query buildLuceneExists(LuceneQueryParser lqp, String propertyName, Boolean not) throws ParseException + public Query buildLuceneExists(LuceneQueryParser lqp, Boolean not) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneGreaterThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneGreaterThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneGreaterThan(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneGreaterThan(LuceneQueryParser lqp, Serializable value, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneGreaterThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneGreaterThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneGreaterThanOrEquals(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneGreaterThanOrEquals(LuceneQueryParser lqp, Serializable value, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneIn(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.util.Collection, java.lang.Boolean, - * org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneIn(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.util.Collection, java.lang.Boolean, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneIn(LuceneQueryParser lqp, String propertyName, Collection values, Boolean not, PredicateMode mode) throws ParseException + public Query buildLuceneIn(LuceneQueryParser lqp, Collection values, Boolean not, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneInequality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneInequality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneInequality(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneInequality(LuceneQueryParser lqp, Serializable value, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneLessThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLessThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneLessThan(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneLessThan(LuceneQueryParser lqp, Serializable value, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneLessThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLessThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneLessThanOrEquals(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneLessThanOrEquals(LuceneQueryParser lqp, Serializable value, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneLike(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, java.lang.Boolean) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLike(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, java.lang.Boolean) */ - public Query buildLuceneLike(LuceneQueryParser lqp, String propertyName, Serializable value, Boolean not) throws ParseException + public Query buildLuceneLike(LuceneQueryParser lqp, Serializable value, Boolean not) { return null; } - - /* (non-Javadoc) - * @see org.alfresco.cmis.property.NamedPropertyAccessor#getLuceneSortField(java.lang.String) + + /* + * (non-Javadoc) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#getLuceneSortField() */ - public String getLuceneSortField(String propertyName) + public String getLuceneSortField() { throw new UnsupportedOperationException(); } - } diff --git a/source/java/org/alfresco/cmis/property/IsVersionSeriesCheckedOutPropertyAccessor.java b/source/java/org/alfresco/cmis/property/IsVersionSeriesCheckedOutPropertyAccessor.java index 4e455376f2..a548e5bcb9 100644 --- a/source/java/org/alfresco/cmis/property/IsVersionSeriesCheckedOutPropertyAccessor.java +++ b/source/java/org/alfresco/cmis/property/IsVersionSeriesCheckedOutPropertyAccessor.java @@ -28,15 +28,12 @@ import java.io.Serializable; import java.util.Collection; import org.alfresco.cmis.dictionary.CMISDictionaryModel; -import org.alfresco.cmis.dictionary.CMISMapping; -import org.alfresco.cmis.dictionary.CMISScope; import org.alfresco.model.ContentModel; import org.alfresco.repo.search.impl.lucene.LuceneQueryParser; import org.alfresco.repo.search.impl.querymodel.PredicateMode; import org.alfresco.service.ServiceRegistry; import org.alfresco.service.cmr.lock.LockType; import org.alfresco.service.cmr.repository.NodeRef; -import org.apache.lucene.queryParser.ParseException; import org.apache.lucene.search.Query; /** @@ -44,15 +41,23 @@ import org.apache.lucene.search.Query; * * @author andyh */ -public class IsVersionSeriesCheckedOutPropertyAccessor extends AbstractNamedPropertyAccessor +public class IsVersionSeriesCheckedOutPropertyAccessor extends AbstractPropertyAccessor { - - protected IsVersionSeriesCheckedOutPropertyAccessor(CMISMapping cmisMapping, ServiceRegistry serviceRegistry) + /** + * Construct + * + * @param serviceRegistry + */ + public IsVersionSeriesCheckedOutPropertyAccessor(ServiceRegistry serviceRegistry) { - super(cmisMapping, serviceRegistry, CMISScope.DOCUMENT, CMISDictionaryModel.PROP_IS_VERSION_SERIES_CHECKED_OUT); + super(serviceRegistry, CMISDictionaryModel.PROP_IS_VERSION_SERIES_CHECKED_OUT); } - public Serializable getProperty(NodeRef nodeRef) + /* + * (non-Javadoc) + * @see org.alfresco.cmis.property.PropertyAccessor#getValue(org.alfresco.service.cmr.repository.NodeRef) + */ + public Serializable getValue(NodeRef nodeRef) { if (getServiceRegistry().getNodeService().hasAspect(nodeRef, ContentModel.ASPECT_WORKING_COPY)) { @@ -73,117 +78,102 @@ public class IsVersionSeriesCheckedOutPropertyAccessor extends AbstractNamedProp } } - public void setProperty(NodeRef nodeRef, Serializable value) + /* + * (non-Javadoc) + * @see org.alfresco.cmis.property.PropertyAccessor#setValue(org.alfresco.service.cmr.repository.NodeRef, java.io.Serializable) + */ + public void setValue(NodeRef nodeRef, Serializable value) { throw new UnsupportedOperationException(); } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneEquality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneEquality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneEquality(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneEquality(LuceneQueryParser lqp, Serializable value, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneExists(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.lang.Boolean) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneExists(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.lang.Boolean) */ - public Query buildLuceneExists(LuceneQueryParser lqp, String propertyName, Boolean not) throws ParseException + public Query buildLuceneExists(LuceneQueryParser lqp, Boolean not) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneGreaterThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneGreaterThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneGreaterThan(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneGreaterThan(LuceneQueryParser lqp, Serializable value, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneGreaterThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneGreaterThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneGreaterThanOrEquals(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneGreaterThanOrEquals(LuceneQueryParser lqp, Serializable value, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneIn(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.util.Collection, java.lang.Boolean, - * org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneIn(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.util.Collection, java.lang.Boolean, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneIn(LuceneQueryParser lqp, String propertyName, Collection values, Boolean not, PredicateMode mode) throws ParseException + public Query buildLuceneIn(LuceneQueryParser lqp, Collection values, Boolean not, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneInequality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneInequality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneInequality(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneInequality(LuceneQueryParser lqp, Serializable value, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneLessThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLessThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneLessThan(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneLessThan(LuceneQueryParser lqp, Serializable value, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneLessThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLessThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneLessThanOrEquals(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneLessThanOrEquals(LuceneQueryParser lqp, Serializable value, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneLike(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, java.lang.Boolean) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLike(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, java.lang.Boolean) */ - public Query buildLuceneLike(LuceneQueryParser lqp, String propertyName, Serializable value, Boolean not) throws ParseException + public Query buildLuceneLike(LuceneQueryParser lqp, Serializable value, Boolean not) { return null; } - - /* (non-Javadoc) - * @see org.alfresco.cmis.property.NamedPropertyAccessor#getLuceneSortField(java.lang.String) + + /* + * (non-Javadoc) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#getLuceneSortField() */ - public String getLuceneSortField(String propertyName) + public String getLuceneSortField() { throw new UnsupportedOperationException(); } - } diff --git a/source/java/org/alfresco/cmis/property/MappingPropertyAccessor.java b/source/java/org/alfresco/cmis/property/MappingPropertyAccessor.java deleted file mode 100644 index 3a64f1b03b..0000000000 --- a/source/java/org/alfresco/cmis/property/MappingPropertyAccessor.java +++ /dev/null @@ -1,294 +0,0 @@ -/* - * Copyright (C) 2005-2007 Alfresco Software Limited. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program 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 General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - * As a special exception to the terms and conditions of version 2.0 of - * the GPL, you may redistribute this Program in connection with Free/Libre - * and Open Source Software ("FLOSS") applications as described in Alfresco's - * FLOSS exception. You should have recieved a copy of the text describing - * the FLOSS exception, and it is also available here: - * http://www.alfresco.com/legal/licensing" - */ -package org.alfresco.cmis.property; - -import java.io.Serializable; -import java.util.Collection; - -import org.alfresco.cmis.dictionary.CMISMapping; -import org.alfresco.repo.search.impl.lucene.LuceneQueryParser; -import org.alfresco.repo.search.impl.querymodel.PredicateMode; -import org.alfresco.service.ServiceRegistry; -import org.alfresco.service.cmr.dictionary.PropertyDefinition; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter; -import org.alfresco.service.namespace.QName; -import org.apache.lucene.index.Term; -import org.apache.lucene.queryParser.ParseException; -import org.apache.lucene.search.BooleanQuery; -import org.apache.lucene.search.MatchAllDocsQuery; -import org.apache.lucene.search.Query; -import org.apache.lucene.search.TermQuery; -import org.apache.lucene.search.BooleanClause.Occur; - -/** - * Generic mapping of CMIS style property names to Alfresco properties (for non CMIS properties) - * @author andyh - * - */ -public class MappingPropertyAccessor extends AbstractGenericPropertyAccessor -{ - - protected MappingPropertyAccessor(CMISMapping cmisMapping, ServiceRegistry serviceRegistry) - { - super(cmisMapping, serviceRegistry); - } - - public Serializable getProperty(NodeRef nodeRef, String propertyName) - { - QName propertyQname = getCMISMapping().getPropertyQName(propertyName); - return getServiceRegistry().getNodeService().getProperty(nodeRef, propertyQname); - } - - public void setProperty(NodeRef nodeRef, String propertyName, Serializable value) - { - QName propertyQname = getCMISMapping().getPropertyQName(propertyName); - getServiceRegistry().getNodeService().setProperty(nodeRef, propertyQname, value); - } - - - private String getLuceneFieldName(QName propertyQname) - { - StringBuilder field = new StringBuilder(64); - field.append("@"); - field.append(propertyQname); - return field.toString(); - } - - private String getValueAsString(QName propertyQname, Serializable value) - { - PropertyDefinition pd = getServiceRegistry().getDictionaryService().getProperty(propertyQname); - Object converted = DefaultTypeConverter.INSTANCE.convert(pd.getDataType(), value); - String asString = DefaultTypeConverter.INSTANCE.convert(String.class, converted); - return asString; - } - - /* - * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneEquality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) - */ - public Query buildLuceneEquality(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException - { - QName propertyQname = getCMISMapping().getPropertyQName(propertyName); - String field = getLuceneFieldName(propertyQname); - String stringValue = getValueAsString(propertyQname, value); - return lqp.getFieldQuery(field, stringValue); - } - - /* - * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneExists(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.lang.Boolean) - */ - public Query buildLuceneExists(LuceneQueryParser lqp, String propertyName, Boolean not) throws ParseException - { - QName propertyQname = getCMISMapping().getPropertyQName(propertyName); - if(not) - { - return lqp.getFieldQuery("ISNULL", propertyQname.toString()); - } - else - { - return lqp.getFieldQuery("ISNOTNULL", propertyQname.toString()); - } - } - - /* - * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneGreaterThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) - */ - public Query buildLuceneGreaterThan(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException - { - QName propertyQname = getCMISMapping().getPropertyQName(propertyName); - String field = getLuceneFieldName(propertyQname); - String stringValue = getValueAsString(propertyQname, value); - return lqp.getRangeQuery(field, stringValue, "\uFFFF", false, true); - } - - /* - * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneGreaterThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) - */ - public Query buildLuceneGreaterThanOrEquals(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException - { - QName propertyQname = getCMISMapping().getPropertyQName(propertyName); - String field = getLuceneFieldName(propertyQname); - String stringValue = getValueAsString(propertyQname, value); - return lqp.getRangeQuery(field, stringValue, "\uFFFF", true, true); - } - - /* - * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneIn(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.util.Collection, java.lang.Boolean, - * org.alfresco.repo.search.impl.querymodel.PredicateMode) - */ - public Query buildLuceneIn(LuceneQueryParser lqp, String propertyName, Collection values, Boolean not, PredicateMode mode) throws ParseException - { - QName propertyQname = getCMISMapping().getPropertyQName(propertyName); - String field = getLuceneFieldName(propertyQname); - PropertyDefinition pd = getServiceRegistry().getDictionaryService().getProperty(propertyQname); - - // Check type conversion - - @SuppressWarnings("unused") - Object converted = DefaultTypeConverter.INSTANCE.convert(pd.getDataType(), values); - Collection asStrings = DefaultTypeConverter.INSTANCE.convert(String.class, values); - - if (asStrings.size() == 0) - { - if (not) - { - return new MatchAllDocsQuery(); - } - else - { - return new TermQuery(new Term("NO_TOKENS", "__")); - } - } - else if (asStrings.size() == 1) - { - String value = asStrings.iterator().next(); - if (not) - { - return lqp.getDoesNotMatchFieldQuery(field, value); - } - else - { - return lqp.getFieldQuery(field, value); - } - } - else - { - BooleanQuery booleanQuery = new BooleanQuery(); - if (not) - { - booleanQuery.add(new MatchAllDocsQuery(), Occur.MUST); - } - for (String value : asStrings) - { - Query any = lqp.getFieldQuery(field, value); - if (not) - { - booleanQuery.add(any, Occur.MUST_NOT); - } - else - { - booleanQuery.add(any, Occur.SHOULD); - } - } - return booleanQuery; - } - } - - /* - * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneInequality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) - */ - public Query buildLuceneInequality(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException - { - QName propertyQname = getCMISMapping().getPropertyQName(propertyName); - String field = getLuceneFieldName(propertyQname); - String stringValue = getValueAsString(propertyQname, value); - return lqp.getDoesNotMatchFieldQuery(field, stringValue); - } - - /* - * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneLessThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) - */ - public Query buildLuceneLessThan(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException - { - QName propertyQname = getCMISMapping().getPropertyQName(propertyName); - String field = getLuceneFieldName(propertyQname); - String stringValue = getValueAsString(propertyQname, value); - return lqp.getRangeQuery(field, "\u0000", stringValue, true, false); - } - - /* - * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneLessThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) - */ - public Query buildLuceneLessThanOrEquals(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException - { - QName propertyQname = getCMISMapping().getPropertyQName(propertyName); - String field = getLuceneFieldName(propertyQname); - String stringValue = getValueAsString(propertyQname, value); - return lqp.getRangeQuery(field, "\u0000", stringValue, true, true); - } - - /* - * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneLike(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, java.lang.Boolean) - */ - public Query buildLuceneLike(LuceneQueryParser lqp, String propertyName, Serializable value, Boolean not) throws ParseException - { - QName propertyQname = getCMISMapping().getPropertyQName(propertyName); - String field = getLuceneFieldName(propertyQname); - String stringValue = getValueAsString(propertyQname, value); - - if (not) - { - BooleanQuery booleanQuery = new BooleanQuery(); - booleanQuery.add(new MatchAllDocsQuery(), Occur.MUST); - booleanQuery.add(lqp.getLikeQuery(field, stringValue), Occur.MUST_NOT); - return booleanQuery; - } - else - { - return lqp.getLikeQuery(field, stringValue); - } - } - - - - - /* (non-Javadoc) - * @see org.alfresco.cmis.property.GenericPropertyAccessor#getLuceneSortField(java.lang.String) - */ - public String getLuceneSortField(String propertyName) - { - QName propertyQname = getCMISMapping().getPropertyQName(propertyName); - return getLuceneFieldName(propertyQname); - } - - -} diff --git a/source/java/org/alfresco/cmis/property/ObjectIdPropertyAccessor.java b/source/java/org/alfresco/cmis/property/ObjectIdPropertyAccessor.java index ef4dd02c09..b87e6a806a 100644 --- a/source/java/org/alfresco/cmis/property/ObjectIdPropertyAccessor.java +++ b/source/java/org/alfresco/cmis/property/ObjectIdPropertyAccessor.java @@ -28,8 +28,6 @@ import java.io.Serializable; import java.util.Collection; import org.alfresco.cmis.dictionary.CMISDictionaryModel; -import org.alfresco.cmis.dictionary.CMISMapping; -import org.alfresco.cmis.dictionary.CMISScope; import org.alfresco.cmis.search.CMISQueryException; import org.alfresco.model.ContentModel; import org.alfresco.repo.search.impl.lucene.LuceneQueryParser; @@ -51,15 +49,23 @@ import org.apache.lucene.search.BooleanClause.Occur; * * @author andyh */ -public class ObjectIdPropertyAccessor extends AbstractNamedPropertyAccessor +public class ObjectIdPropertyAccessor extends AbstractPropertyAccessor { - - protected ObjectIdPropertyAccessor(CMISMapping cmisMapping, ServiceRegistry serviceRegistry) + /** + * Construct + * + * @param serviceRegistry + */ + public ObjectIdPropertyAccessor(ServiceRegistry serviceRegistry) { - super(cmisMapping, serviceRegistry, CMISScope.OBJECT, CMISDictionaryModel.PROP_OBJECT_ID); + super(serviceRegistry, CMISDictionaryModel.PROP_OBJECT_ID); } - public Serializable getProperty(NodeRef nodeRef) + /* + * (non-Javadoc) + * @see org.alfresco.cmis.property.PropertyAccessor#getValue(org.alfresco.service.cmr.repository.NodeRef) + */ + public Serializable getValue(NodeRef nodeRef) { if (getServiceRegistry().getNodeService().hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE)) { @@ -73,14 +79,16 @@ public class ObjectIdPropertyAccessor extends AbstractNamedPropertyAccessor builder.append(versionLabel); return builder.toString(); } - } return nodeRef.toString(); - } - public void setProperty(NodeRef nodeRef, Serializable value) + /* + * (non-Javadoc) + * @see org.alfresco.cmis.property.PropertyAccessor#setValue(org.alfresco.service.cmr.repository.NodeRef, java.io.Serializable) + */ + public void setValue(NodeRef nodeRef, Serializable value) { throw new UnsupportedOperationException(); } @@ -99,11 +107,9 @@ public class ObjectIdPropertyAccessor extends AbstractNamedPropertyAccessor /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneEquality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneEquality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneEquality(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneEquality(LuceneQueryParser lqp, Serializable value, PredicateMode mode) throws ParseException { String field = getLuceneFieldName(); String stringValue = getValueAsString(value); @@ -112,11 +118,9 @@ public class ObjectIdPropertyAccessor extends AbstractNamedPropertyAccessor /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneExists(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.lang.Boolean) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneExists(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.lang.Boolean) */ - public Query buildLuceneExists(LuceneQueryParser lqp, String propertyName, Boolean not) throws ParseException + public Query buildLuceneExists(LuceneQueryParser lqp, Boolean not) throws ParseException { if (not) { @@ -130,34 +134,27 @@ public class ObjectIdPropertyAccessor extends AbstractNamedPropertyAccessor /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneGreaterThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneGreaterThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneGreaterThan(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneGreaterThan(LuceneQueryParser lqp, Serializable value, PredicateMode mode) throws ParseException { - throw new CMISQueryException("Property "+getPropertyName() +" can not be used in a 'greater than' comparison"); + throw new CMISQueryException("Property " + getName() +" can not be used in a 'greater than' comparison"); } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneGreaterThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneGreaterThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneGreaterThanOrEquals(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneGreaterThanOrEquals(LuceneQueryParser lqp, Serializable value, PredicateMode mode) throws ParseException { - throw new CMISQueryException("Property "+getPropertyName() +" can not be used in a 'greater than or equals' comparison"); + throw new CMISQueryException("Property " + getName() + " can not be used in a 'greater than or equals' comparison"); } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneIn(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.util.Collection, java.lang.Boolean, - * org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneIn(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.util.Collection, java.lang.Boolean, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneIn(LuceneQueryParser lqp, String propertyName, Collection values, Boolean not, PredicateMode mode) throws ParseException + public Query buildLuceneIn(LuceneQueryParser lqp, Collection values, Boolean not, PredicateMode mode) throws ParseException { String field = getLuceneFieldName(); @@ -215,11 +212,9 @@ public class ObjectIdPropertyAccessor extends AbstractNamedPropertyAccessor /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneInequality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneInequality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneInequality(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneInequality(LuceneQueryParser lqp, Serializable value, PredicateMode mode) throws ParseException { String field = getLuceneFieldName(); String stringValue = getValueAsString(value); @@ -228,24 +223,20 @@ public class ObjectIdPropertyAccessor extends AbstractNamedPropertyAccessor /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneLessThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLessThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneLessThan(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneLessThan(LuceneQueryParser lqp, Serializable value, PredicateMode mode) throws ParseException { - throw new CMISQueryException("Property "+getPropertyName() +" can not be used in a 'less than' comparison"); + throw new CMISQueryException("Property " + getName() + " can not be used in a 'less than' comparison"); } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneLessThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLessThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneLessThanOrEquals(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneLessThanOrEquals(LuceneQueryParser lqp, Serializable value, PredicateMode mode) throws ParseException { - throw new CMISQueryException("Property "+getPropertyName() +" can not be used in a 'less than or equals' comparison"); + throw new CMISQueryException("Property " + getName() + " can not be used in a 'less than or equals' comparison"); } /* @@ -254,7 +245,7 @@ public class ObjectIdPropertyAccessor extends AbstractNamedPropertyAccessor * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneLike(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, * java.lang.String, java.io.Serializable, java.lang.Boolean) */ - public Query buildLuceneLike(LuceneQueryParser lqp, String propertyName, Serializable value, Boolean not) throws ParseException + public Query buildLuceneLike(LuceneQueryParser lqp, Serializable value, Boolean not) throws ParseException { String field = getLuceneFieldName(); String stringValue = getValueAsString(value); @@ -275,7 +266,7 @@ public class ObjectIdPropertyAccessor extends AbstractNamedPropertyAccessor /* (non-Javadoc) * @see org.alfresco.cmis.property.NamedPropertyAccessor#getLuceneSortField(java.lang.String) */ - public String getLuceneSortField(String propertyName) + public String getLuceneSortField() { return getLuceneFieldName(); } diff --git a/source/java/org/alfresco/cmis/property/ObjectTypeIdPropertyAccessor.java b/source/java/org/alfresco/cmis/property/ObjectTypeIdPropertyAccessor.java index 2f2bd8a6d1..d626361f7c 100644 --- a/source/java/org/alfresco/cmis/property/ObjectTypeIdPropertyAccessor.java +++ b/source/java/org/alfresco/cmis/property/ObjectTypeIdPropertyAccessor.java @@ -29,9 +29,7 @@ import java.util.ArrayList; import java.util.Collection; import org.alfresco.cmis.dictionary.CMISDictionaryModel; -import org.alfresco.cmis.dictionary.CMISMapping; -import org.alfresco.cmis.dictionary.CMISScope; -import org.alfresco.cmis.dictionary.CMISTypeId; +import org.alfresco.cmis.dictionary.CMISTypeDefinition; import org.alfresco.cmis.search.CMISQueryException; import org.alfresco.repo.search.impl.lucene.LuceneQueryParser; import org.alfresco.repo.search.impl.querymodel.PredicateMode; @@ -52,33 +50,33 @@ import org.apache.lucene.search.BooleanClause.Occur; * * @author andyh */ -public class ObjectTypeIdPropertyAccessor extends AbstractNamedPropertyAccessor +public class ObjectTypeIdPropertyAccessor extends AbstractPropertyAccessor { - protected ObjectTypeIdPropertyAccessor(CMISMapping cmisMapping, ServiceRegistry serviceRegistry) + /** + * Construct + * + * @param serviceRegistry + */ + public ObjectTypeIdPropertyAccessor(ServiceRegistry serviceRegistry) { - super(cmisMapping, serviceRegistry, CMISScope.OBJECT, CMISDictionaryModel.PROP_OBJECT_TYPE_ID); + super(serviceRegistry, CMISDictionaryModel.PROP_OBJECT_TYPE_ID); } - public Serializable getProperty(NodeRef nodeRef) + /* + * (non-Javadoc) + * @see org.alfresco.cmis.property.PropertyAccessor#getValue(org.alfresco.service.cmr.repository.NodeRef) + */ + public Serializable getValue(NodeRef nodeRef) { - QName typeQName = getCMISMapping().getCmisType(getServiceRegistry().getNodeService().getType(nodeRef)); - CMISScope scope; - if (getCMISMapping().isValidCmisDocument(typeQName)) - { - scope = CMISScope.DOCUMENT; - } - else if (getCMISMapping().isValidCmisFolder(typeQName)) - { - scope = CMISScope.FOLDER; - } - else - { - scope = CMISScope.UNKNOWN; - } - return getCMISMapping().getCmisTypeId(scope, typeQName).getId(); + QName type = getServiceRegistry().getNodeService().getType(nodeRef); + return getServiceRegistry().getCMISDictionaryService().findTypeForClass(type).getTypeId().getId(); } - public void setProperty(NodeRef nodeRef, Serializable value) + /* + * (non-Javadoc) + * @see org.alfresco.cmis.property.PropertyAccessor#setValue(org.alfresco.service.cmr.repository.NodeRef, java.io.Serializable) + */ + public void setValue(NodeRef nodeRef, Serializable value) { throw new UnsupportedOperationException(); } @@ -99,26 +97,21 @@ public class ObjectTypeIdPropertyAccessor extends AbstractNamedPropertyAccessor /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneEquality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneEquality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneEquality(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneEquality(LuceneQueryParser lqp, Serializable value, PredicateMode mode) throws ParseException { String field = getLuceneFieldName(); String stringValue = getValueAsString(value); - CMISTypeId cmisTypeId = getCMISMapping().getCmisTypeId(stringValue); - QName alfrescoType = getCMISMapping().getAlfrescoType(cmisTypeId.getQName()); - return lqp.getFieldQuery(field, alfrescoType.toString()); + CMISTypeDefinition type = getServiceRegistry().getCMISDictionaryService().findType(stringValue); + return lqp.getFieldQuery(field, type.getTypeId().getQName().toString()); } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneExists(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.lang.Boolean) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneExists(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.lang.Boolean) */ - public Query buildLuceneExists(LuceneQueryParser lqp, String propertyName, Boolean not) throws ParseException + public Query buildLuceneExists(LuceneQueryParser lqp, Boolean not) throws ParseException { if (not) { @@ -132,34 +125,27 @@ public class ObjectTypeIdPropertyAccessor extends AbstractNamedPropertyAccessor /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneGreaterThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneGreaterThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneGreaterThan(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneGreaterThan(LuceneQueryParser lqp, Serializable value, PredicateMode mode) throws ParseException { - throw new CMISQueryException("Property "+getPropertyName() +" can not be used in a 'greater than' comparison"); + throw new CMISQueryException("Property " + getName() + " can not be used in a 'greater than' comparison"); } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneGreaterThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneGreaterThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneGreaterThanOrEquals(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneGreaterThanOrEquals(LuceneQueryParser lqp, Serializable value, PredicateMode mode) throws ParseException { - throw new CMISQueryException("Property "+getPropertyName() +" can not be used in a 'greater than or equals' comparison"); + throw new CMISQueryException("Property " + getName() + " can not be used in a 'greater than or equals' comparison"); } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneIn(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.util.Collection, java.lang.Boolean, - * org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneIn(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.util.Collection, java.lang.Boolean, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneIn(LuceneQueryParser lqp, String propertyName, Collection values, Boolean not, PredicateMode mode) throws ParseException + public Query buildLuceneIn(LuceneQueryParser lqp, Collection values, Boolean not, PredicateMode mode) throws ParseException { String field = getLuceneFieldName(); @@ -167,9 +153,8 @@ public class ObjectTypeIdPropertyAccessor extends AbstractNamedPropertyAccessor for (Serializable value : values) { String stringValue = getValueAsString(value); - CMISTypeId cmisTypeId = getCMISMapping().getCmisTypeId(stringValue); - QName alfrescoType = getCMISMapping().getAlfrescoType(cmisTypeId.getQName()); - asStrings.add(alfrescoType.toString()); + CMISTypeDefinition type = getServiceRegistry().getCMISDictionaryService().findType(stringValue); + asStrings.add(type.getTypeId().getQName().toString()); } if (asStrings.size() == 0) @@ -220,73 +205,63 @@ public class ObjectTypeIdPropertyAccessor extends AbstractNamedPropertyAccessor /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneInequality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneInequality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneInequality(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneInequality(LuceneQueryParser lqp, Serializable value, PredicateMode mode) throws ParseException { String field = getLuceneFieldName(); String stringValue = getValueAsString(value); - CMISTypeId cmisTypeId = getCMISMapping().getCmisTypeId(stringValue); - QName alfrescoType = getCMISMapping().getAlfrescoType(cmisTypeId.getQName()); - return lqp.getDoesNotMatchFieldQuery(field, alfrescoType.toString()); + CMISTypeDefinition type = getServiceRegistry().getCMISDictionaryService().findType(stringValue); + return lqp.getDoesNotMatchFieldQuery(field, type.getTypeId().getQName().toString()); } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneLessThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLessThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneLessThan(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneLessThan(LuceneQueryParser lqp, Serializable value, PredicateMode mode) throws ParseException { - throw new CMISQueryException("Property "+getPropertyName() +" can not be used in a 'less than' comparison"); + throw new CMISQueryException("Property " + getName() + " can not be used in a 'less than' comparison"); } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneLessThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLessThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneLessThanOrEquals(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneLessThanOrEquals(LuceneQueryParser lqp, Serializable value, PredicateMode mode) throws ParseException { - throw new CMISQueryException("Property "+getPropertyName() +" can not be used in a 'less than or equals' comparison"); + throw new CMISQueryException("Property " + getName() + " can not be used in a 'less than or equals' comparison"); } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneLike(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, java.lang.Boolean) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLike(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, java.lang.Boolean) */ - public Query buildLuceneLike(LuceneQueryParser lqp, String propertyName, Serializable value, Boolean not) throws ParseException + public Query buildLuceneLike(LuceneQueryParser lqp, Serializable value, Boolean not) throws ParseException { String field = getLuceneFieldName(); String stringValue = getValueAsString(value); - CMISTypeId cmisTypeId = getCMISMapping().getCmisTypeId(stringValue); - QName alfrescoType = getCMISMapping().getAlfrescoType(cmisTypeId.getQName()); + CMISTypeDefinition type = getServiceRegistry().getCMISDictionaryService().findType(stringValue); + String typeQName = type.getTypeId().getQName().toString(); if (not) { BooleanQuery booleanQuery = new BooleanQuery(); booleanQuery.add(new MatchAllDocsQuery(), Occur.MUST); - booleanQuery.add(lqp.getLikeQuery(field, alfrescoType.toString()), Occur.MUST_NOT); + booleanQuery.add(lqp.getLikeQuery(field, typeQName), Occur.MUST_NOT); return booleanQuery; } else { - return lqp.getLikeQuery(field, alfrescoType.toString()); + return lqp.getLikeQuery(field, typeQName); } } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#getLuceneSortField(java.lang.String) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#getLuceneSortField() */ - public String getLuceneSortField(String propertyName) + public String getLuceneSortField() { return getLuceneFieldName(); } diff --git a/source/java/org/alfresco/cmis/property/ParentPropertyAccessor.java b/source/java/org/alfresco/cmis/property/ParentPropertyAccessor.java index 67f9bfe9b6..3a6c027549 100644 --- a/source/java/org/alfresco/cmis/property/ParentPropertyAccessor.java +++ b/source/java/org/alfresco/cmis/property/ParentPropertyAccessor.java @@ -27,10 +27,7 @@ package org.alfresco.cmis.property; import java.io.Serializable; import java.util.Collection; -import org.alfresco.cmis.CMISService; import org.alfresco.cmis.dictionary.CMISDictionaryModel; -import org.alfresco.cmis.dictionary.CMISMapping; -import org.alfresco.cmis.dictionary.CMISScope; import org.alfresco.repo.search.impl.lucene.LuceneQueryParser; import org.alfresco.repo.search.impl.querymodel.PredicateMode; import org.alfresco.service.ServiceRegistry; @@ -52,19 +49,25 @@ import org.apache.lucene.search.BooleanClause.Occur; * @author andyh * */ -public class ParentPropertyAccessor extends AbstractNamedPropertyAccessor +public class ParentPropertyAccessor extends AbstractPropertyAccessor { - private CMISService cmisService; - - protected ParentPropertyAccessor(CMISMapping cmisMapping, ServiceRegistry serviceRegistry, CMISService cmisService) + /** + * Construct + * + * @param serviceRegistry + */ + public ParentPropertyAccessor(ServiceRegistry serviceRegistry) { - super(cmisMapping, serviceRegistry, CMISScope.FOLDER, CMISDictionaryModel.PROP_PARENT_ID); - this.cmisService = cmisService; + super(serviceRegistry, CMISDictionaryModel.PROP_PARENT_ID); } - public Serializable getProperty(NodeRef nodeRef) + /* + * (non-Javadoc) + * @see org.alfresco.cmis.property.PropertyAccessor#getValue(org.alfresco.service.cmr.repository.NodeRef) + */ + public Serializable getValue(NodeRef nodeRef) { - if (nodeRef.equals(cmisService.getDefaultRootNodeRef())) + if (nodeRef.equals(getServiceRegistry().getCMISService().getDefaultRootNodeRef())) { return null; } @@ -79,8 +82,12 @@ public class ParentPropertyAccessor extends AbstractNamedPropertyAccessor return null; } } - - public void setProperty(NodeRef nodeRef, Serializable value) + + /* + * (non-Javadoc) + * @see org.alfresco.cmis.property.PropertyAccessor#setValue(org.alfresco.service.cmr.repository.NodeRef, java.io.Serializable) + */ + public void setValue(NodeRef nodeRef, Serializable value) { throw new UnsupportedOperationException(); } @@ -97,14 +104,11 @@ public class ParentPropertyAccessor extends AbstractNamedPropertyAccessor return asString; } - /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneEquality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneEquality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneEquality(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneEquality(LuceneQueryParser lqp, Serializable value, PredicateMode mode) throws ParseException { String field = getLuceneFieldName(); String stringValue = getValueAsString(value); @@ -113,11 +117,9 @@ public class ParentPropertyAccessor extends AbstractNamedPropertyAccessor /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneExists(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.lang.Boolean) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneExists(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.lang.Boolean) */ - public Query buildLuceneExists(LuceneQueryParser lqp, String propertyName, Boolean not) throws ParseException + public Query buildLuceneExists(LuceneQueryParser lqp, Boolean not) throws ParseException { if (not) { @@ -131,34 +133,27 @@ public class ParentPropertyAccessor extends AbstractNamedPropertyAccessor /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneGreaterThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneGreaterThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneGreaterThan(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneGreaterThan(LuceneQueryParser lqp, Serializable value, PredicateMode mode) throws ParseException { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneGreaterThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneGreaterThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneGreaterThanOrEquals(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneGreaterThanOrEquals(LuceneQueryParser lqp, Serializable value, PredicateMode mode) throws ParseException { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneIn(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.util.Collection, java.lang.Boolean, - * org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneIn(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.util.Collection, java.lang.Boolean, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneIn(LuceneQueryParser lqp, String propertyName, Collection values, Boolean not, PredicateMode mode) throws ParseException + public Query buildLuceneIn(LuceneQueryParser lqp, Collection values, Boolean not, PredicateMode mode) throws ParseException { String field = getLuceneFieldName(); @@ -216,11 +211,9 @@ public class ParentPropertyAccessor extends AbstractNamedPropertyAccessor /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneInequality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneInequality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneInequality(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneInequality(LuceneQueryParser lqp, Serializable value, PredicateMode mode) throws ParseException { String field = getLuceneFieldName(); String stringValue = getValueAsString(value); @@ -229,33 +222,27 @@ public class ParentPropertyAccessor extends AbstractNamedPropertyAccessor /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneLessThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLessThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneLessThan(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneLessThan(LuceneQueryParser lqp, Serializable value, PredicateMode mode) throws ParseException { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneLessThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLessThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneLessThanOrEquals(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneLessThanOrEquals(LuceneQueryParser lqp, Serializable value, PredicateMode mode) throws ParseException { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneLike(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, java.lang.Boolean) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLike(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, java.lang.Boolean) */ - public Query buildLuceneLike(LuceneQueryParser lqp, String propertyName, Serializable value, Boolean not) throws ParseException + public Query buildLuceneLike(LuceneQueryParser lqp, Serializable value, Boolean not) throws ParseException { String field = getLuceneFieldName(); String stringValue = getValueAsString(value); @@ -273,11 +260,11 @@ public class ParentPropertyAccessor extends AbstractNamedPropertyAccessor } } - - /* (non-Javadoc) - * @see org.alfresco.cmis.property.NamedPropertyAccessor#getLuceneSortField(java.lang.String) + /* + * (non-Javadoc) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#getLuceneSortField() */ - public String getLuceneSortField(String propertyName) + public String getLuceneSortField() { return getLuceneFieldName(); } diff --git a/source/java/org/alfresco/cmis/property/AbstractGenericPropertyAccessor.java b/source/java/org/alfresco/cmis/property/PropertyAccessor.java similarity index 58% rename from source/java/org/alfresco/cmis/property/AbstractGenericPropertyAccessor.java rename to source/java/org/alfresco/cmis/property/PropertyAccessor.java index a05df337e5..9cf18dee54 100644 --- a/source/java/org/alfresco/cmis/property/AbstractGenericPropertyAccessor.java +++ b/source/java/org/alfresco/cmis/property/PropertyAccessor.java @@ -1,45 +1,68 @@ -/* - * Copyright (C) 2005-2007 Alfresco Software Limited. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program 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 General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - * As a special exception to the terms and conditions of version 2.0 of - * the GPL, you may redistribute this Program in connection with Free/Libre - * and Open Source Software ("FLOSS") applications as described in Alfresco's - * FLOSS exception. You should have recieved a copy of the text describing - * the FLOSS exception, and it is also available here: - * http://www.alfresco.com/legal/licensing" - */ -package org.alfresco.cmis.property; - -import org.alfresco.cmis.dictionary.CMISMapping; -import org.alfresco.service.ServiceRegistry; - - -/** - * Base class for generic property accessors - * - * @author andyh - * - */ -public abstract class AbstractGenericPropertyAccessor extends AbstractPropertyAccessor implements GenericPropertyAccessor -{ - - protected AbstractGenericPropertyAccessor(CMISMapping cmisMapping, ServiceRegistry serviceRegistry) - { - super(cmisMapping, serviceRegistry); - } - -} +/* + * Copyright (C) 2005-2009 Alfresco Software Limited. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program 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 General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + * As a special exception to the terms and conditions of version 2.0 of + * the GPL, you may redistribute this Program in connection with Free/Libre + * and Open Source Software ("FLOSS") applications as described in Alfresco's + * FLOSS exception. You should have recieved a copy of the text describing + * the FLOSS exception, and it is also available here: + * http://www.alfresco.com/legal/licensing" + */ +package org.alfresco.cmis.property; + +import java.io.Serializable; + +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; + +/** + * CMIS Property Accessor + * + * @author davidc + */ +public interface PropertyAccessor +{ + /** + * Get the CMIS Property Name + * + * @return + */ + public String getName(); + + /** + * Get the (directly) mapped Alfresco property (if a direct mapping exists) + * + * @return + */ + public QName getMappedProperty(); + + /** + * Get the property value + * + * @param nodeRef + * @return + */ + public Serializable getValue(NodeRef nodeRef); + + /** + * Set the property value + * + * @param nodeRef + * @Param value + */ + public void setValue(NodeRef nodeRef, Serializable value); +} diff --git a/source/java/org/alfresco/cmis/property/NamedPropertyAccessor.java b/source/java/org/alfresco/cmis/property/PropertyLuceneBuilder.java similarity index 51% rename from source/java/org/alfresco/cmis/property/NamedPropertyAccessor.java rename to source/java/org/alfresco/cmis/property/PropertyLuceneBuilder.java index 1a825c3f7e..e403c5c3e5 100644 --- a/source/java/org/alfresco/cmis/property/NamedPropertyAccessor.java +++ b/source/java/org/alfresco/cmis/property/PropertyLuceneBuilder.java @@ -1,154 +1,120 @@ -/* - * Copyright (C) 2005-2007 Alfresco Software Limited. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program 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 General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - * As a special exception to the terms and conditions of version 2.0 of - * the GPL, you may redistribute this Program in connection with Free/Libre - * and Open Source Software ("FLOSS") applications as described in Alfresco's - * FLOSS exception. You should have recieved a copy of the text describing - * the FLOSS exception, and it is also available here: - * http://www.alfresco.com/legal/licensing" - */ -package org.alfresco.cmis.property; - -import java.io.Serializable; -import java.util.Collection; - -import org.alfresco.cmis.dictionary.CMISScope; -import org.alfresco.repo.search.impl.lucene.LuceneQueryParser; -import org.alfresco.repo.search.impl.querymodel.PredicateMode; -import org.alfresco.service.cmr.repository.NodeRef; -import org.apache.lucene.queryParser.ParseException; -import org.apache.lucene.search.Query; - -/** - * Named property accessor - * - * @author andyh - */ -public interface NamedPropertyAccessor -{ - /** - * Get the name of the CMIS property this accessor fetches - * - * @return - */ - public String getPropertyName(); - - /** - * Get the property value - * - * @param nodeRef - * @return - */ - public Serializable getProperty(NodeRef nodeRef); - - /** - * Set the property value - * - * @param nodeRef - * @Param value - */ - public void setProperty(NodeRef nodeRef, Serializable value); - - /** - * To what types of objects does this property apply? - * - * @return - */ - public CMISScope getScope(); - - public Query buildLuceneEquality(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException; - - /** - * @param lqp - * @param propertyName - * @param not - * @return - * @throws ParseException - */ - public Query buildLuceneExists(LuceneQueryParser lqp, String propertyName, Boolean not) throws ParseException; - - /** - * @param lqp - * @param propertyName - * @param value - * @param mode - * @return - */ - public Query buildLuceneGreaterThan(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException; - - /** - * @param lqp - * @param propertyName - * @param value - * @param mode - * @return - */ - public Query buildLuceneGreaterThanOrEquals(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException; - - /** - * @param lqp - * @param propertyName - * @param values - * @param not - * @param mode - * @return - */ - public Query buildLuceneIn(LuceneQueryParser lqp, String propertyName, Collection values, Boolean not, PredicateMode mode) throws ParseException; - - /** - * @param lqp - * @param propertyName - * @param value - * @param mode - * @return - */ - public Query buildLuceneInequality(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException; - - /** - * @param lqp - * @param propertyName - * @param value - * @param mode - * @return - */ - public Query buildLuceneLessThan(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException; - - /** - * @param lqp - * @param propertyName - * @param value - * @param mode - * @return - */ - public Query buildLuceneLessThanOrEquals(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException; - - /** - * @param lqp - * @param propertyName - * @param value - * @param not - * @return - */ - public Query buildLuceneLike(LuceneQueryParser lqp, String propertyName, Serializable value, Boolean not) throws ParseException; - - /** - * @param propertyName - * @return - */ - public String getLuceneSortField(String propertyName); -} +/* + * Copyright (C) 2005-2009 Alfresco Software Limited. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program 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 General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + * As a special exception to the terms and conditions of version 2.0 of + * the GPL, you may redistribute this Program in connection with Free/Libre + * and Open Source Software ("FLOSS") applications as described in Alfresco's + * FLOSS exception. You should have recieved a copy of the text describing + * the FLOSS exception, and it is also available here: + * http://www.alfresco.com/legal/licensing" + */ +package org.alfresco.cmis.property; + +import java.io.Serializable; +import java.util.Collection; + +import org.alfresco.repo.search.impl.lucene.LuceneQueryParser; +import org.alfresco.repo.search.impl.querymodel.PredicateMode; +import org.apache.lucene.queryParser.ParseException; +import org.apache.lucene.search.Query; + +/** + * CMIS Property Lucene Builder + * + * @author andyh + */ +public interface PropertyLuceneBuilder +{ + /** + * @param lqp + * @param value + * @param mode + * @return + * @throws ParseException + */ + public Query buildLuceneEquality(LuceneQueryParser lqp, Serializable value, PredicateMode mode) throws ParseException; + + /** + * @param lqp + * @param not + * @return + * @throws ParseException + */ + public Query buildLuceneExists(LuceneQueryParser lqp, Boolean not) throws ParseException; + + /** + * @param lqp + * @param value + * @param mode + * @return + */ + public Query buildLuceneGreaterThan(LuceneQueryParser lqp, Serializable value, PredicateMode mode) throws ParseException; + + /** + * @param lqp + * @param value + * @param mode + * @return + */ + public Query buildLuceneGreaterThanOrEquals(LuceneQueryParser lqp, Serializable value, PredicateMode mode) throws ParseException; + + /** + * @param lqp + * @param values + * @param not + * @param mode + * @return + */ + public Query buildLuceneIn(LuceneQueryParser lqp, Collection values, Boolean not, PredicateMode mode) throws ParseException; + + /** + * @param lqp + * @param value + * @param mode + * @return + */ + public Query buildLuceneInequality(LuceneQueryParser lqp, Serializable value, PredicateMode mode) throws ParseException; + + /** + * @param lqp + * @param value + * @param mode + * @return + */ + public Query buildLuceneLessThan(LuceneQueryParser lqp, Serializable value, PredicateMode mode) throws ParseException; + + /** + * @param lqp + * @param value + * @param mode + * @return + */ + public Query buildLuceneLessThanOrEquals(LuceneQueryParser lqp, Serializable value, PredicateMode mode) throws ParseException; + + /** + * @param lqp + * @param value + * @param not + * @return + */ + public Query buildLuceneLike(LuceneQueryParser lqp, Serializable value, Boolean not) throws ParseException; + + /** + * @return + */ + public String getLuceneSortField(); +} diff --git a/source/java/org/alfresco/cmis/property/VersionSeriesCheckedOutByPropertyAccessor.java b/source/java/org/alfresco/cmis/property/VersionSeriesCheckedOutByPropertyAccessor.java index 6383c2e56c..73d05cb800 100644 --- a/source/java/org/alfresco/cmis/property/VersionSeriesCheckedOutByPropertyAccessor.java +++ b/source/java/org/alfresco/cmis/property/VersionSeriesCheckedOutByPropertyAccessor.java @@ -28,15 +28,12 @@ import java.io.Serializable; import java.util.Collection; import org.alfresco.cmis.dictionary.CMISDictionaryModel; -import org.alfresco.cmis.dictionary.CMISMapping; -import org.alfresco.cmis.dictionary.CMISScope; import org.alfresco.model.ContentModel; import org.alfresco.repo.search.impl.lucene.LuceneQueryParser; import org.alfresco.repo.search.impl.querymodel.PredicateMode; import org.alfresco.service.ServiceRegistry; import org.alfresco.service.cmr.lock.LockType; import org.alfresco.service.cmr.repository.NodeRef; -import org.apache.lucene.queryParser.ParseException; import org.apache.lucene.search.Query; /** @@ -44,15 +41,23 @@ import org.apache.lucene.search.Query; * * @author andyh */ -public class VersionSeriesCheckedOutByPropertyAccessor extends AbstractNamedPropertyAccessor +public class VersionSeriesCheckedOutByPropertyAccessor extends AbstractPropertyAccessor { - - protected VersionSeriesCheckedOutByPropertyAccessor(CMISMapping cmisMapping, ServiceRegistry serviceRegistry) + /** + * Construct + * + * @param serviceRegistry + */ + public VersionSeriesCheckedOutByPropertyAccessor(ServiceRegistry serviceRegistry) { - super(cmisMapping, serviceRegistry, CMISScope.DOCUMENT, CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_BY); + super(serviceRegistry, CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_BY); } - public Serializable getProperty(NodeRef nodeRef) + /* + * (non-Javadoc) + * @see org.alfresco.cmis.property.PropertyAccessor#getValue(org.alfresco.service.cmr.repository.NodeRef) + */ + public Serializable getValue(NodeRef nodeRef) { if (getServiceRegistry().getNodeService().hasAspect(nodeRef, ContentModel.ASPECT_WORKING_COPY)) { @@ -80,119 +85,102 @@ public class VersionSeriesCheckedOutByPropertyAccessor extends AbstractNamedProp } } - public void setProperty(NodeRef nodeRef, Serializable value) + /* + * (non-Javadoc) + * @see org.alfresco.cmis.property.PropertyAccessor#setValue(org.alfresco.service.cmr.repository.NodeRef, java.io.Serializable) + */ + public void setValue(NodeRef nodeRef, Serializable value) { throw new UnsupportedOperationException(); } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneEquality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneEquality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneEquality(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneEquality(LuceneQueryParser lqp, Serializable value, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneExists(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.lang.Boolean) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneExists(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.lang.Boolean) */ - public Query buildLuceneExists(LuceneQueryParser lqp, String propertyName, Boolean not) throws ParseException + public Query buildLuceneExists(LuceneQueryParser lqp, Boolean not) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneGreaterThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneGreaterThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneGreaterThan(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneGreaterThan(LuceneQueryParser lqp, Serializable value, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneGreaterThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneGreaterThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneGreaterThanOrEquals(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneGreaterThanOrEquals(LuceneQueryParser lqp, Serializable value, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneIn(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.util.Collection, java.lang.Boolean, - * org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneIn(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.util.Collection, java.lang.Boolean, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneIn(LuceneQueryParser lqp, String propertyName, Collection values, Boolean not, PredicateMode mode) throws ParseException + public Query buildLuceneIn(LuceneQueryParser lqp, Collection values, Boolean not, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneInequality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneInequality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneInequality(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneInequality(LuceneQueryParser lqp, Serializable value, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneLessThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLessThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneLessThan(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneLessThan(LuceneQueryParser lqp, Serializable value, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneLessThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLessThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneLessThanOrEquals(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneLessThanOrEquals(LuceneQueryParser lqp, Serializable value, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneLike(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, java.lang.Boolean) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLike(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, java.lang.Boolean) */ - public Query buildLuceneLike(LuceneQueryParser lqp, String propertyName, Serializable value, Boolean not) throws ParseException + public Query buildLuceneLike(LuceneQueryParser lqp, Serializable value, Boolean not) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#getLuceneSortField(java.lang.String) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#getLuceneSortField() */ - public String getLuceneSortField(String propertyName) + public String getLuceneSortField() { throw new UnsupportedOperationException(); } - } diff --git a/source/java/org/alfresco/cmis/property/VersionSeriesCheckedOutIdPropertyAccessor.java b/source/java/org/alfresco/cmis/property/VersionSeriesCheckedOutIdPropertyAccessor.java index e4f46c28f9..d0dc80c8ef 100644 --- a/source/java/org/alfresco/cmis/property/VersionSeriesCheckedOutIdPropertyAccessor.java +++ b/source/java/org/alfresco/cmis/property/VersionSeriesCheckedOutIdPropertyAccessor.java @@ -28,15 +28,12 @@ import java.io.Serializable; import java.util.Collection; import org.alfresco.cmis.dictionary.CMISDictionaryModel; -import org.alfresco.cmis.dictionary.CMISMapping; -import org.alfresco.cmis.dictionary.CMISScope; import org.alfresco.model.ContentModel; import org.alfresco.repo.search.impl.lucene.LuceneQueryParser; import org.alfresco.repo.search.impl.querymodel.PredicateMode; import org.alfresco.service.ServiceRegistry; import org.alfresco.service.cmr.lock.LockType; import org.alfresco.service.cmr.repository.NodeRef; -import org.apache.lucene.queryParser.ParseException; import org.apache.lucene.search.Query; /** @@ -44,14 +41,23 @@ import org.apache.lucene.search.Query; * * @author andyh */ -public class VersionSeriesCheckedOutIdPropertyAccessor extends AbstractNamedPropertyAccessor +public class VersionSeriesCheckedOutIdPropertyAccessor extends AbstractPropertyAccessor { - protected VersionSeriesCheckedOutIdPropertyAccessor(CMISMapping cmisMapping, ServiceRegistry serviceRegistry) + /** + * Construct + * + * @param serviceRegistry + */ + public VersionSeriesCheckedOutIdPropertyAccessor(ServiceRegistry serviceRegistry) { - super(cmisMapping, serviceRegistry, CMISScope.DOCUMENT, CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_ID); + super(serviceRegistry, CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_ID); } - public Serializable getProperty(NodeRef nodeRef) + /* + * (non-Javadoc) + * @see org.alfresco.cmis.property.PropertyAccessor#getValue(org.alfresco.service.cmr.repository.NodeRef) + */ + public Serializable getValue(NodeRef nodeRef) { if (getServiceRegistry().getNodeService().hasAspect(nodeRef, ContentModel.ASPECT_WORKING_COPY)) { @@ -72,7 +78,11 @@ public class VersionSeriesCheckedOutIdPropertyAccessor extends AbstractNamedProp } } - public void setProperty(NodeRef nodeRef, Serializable value) + /* + * (non-Javadoc) + * @see org.alfresco.cmis.property.PropertyAccessor#setValue(org.alfresco.service.cmr.repository.NodeRef, java.io.Serializable) + */ + public void setValue(NodeRef nodeRef, Serializable value) { throw new UnsupportedOperationException(); } @@ -80,108 +90,90 @@ public class VersionSeriesCheckedOutIdPropertyAccessor extends AbstractNamedProp /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneEquality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneEquality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneEquality(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneEquality(LuceneQueryParser lqp, Serializable value, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneExists(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.lang.Boolean) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneExists(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.lang.Boolean) */ - public Query buildLuceneExists(LuceneQueryParser lqp, String propertyName, Boolean not) throws ParseException + public Query buildLuceneExists(LuceneQueryParser lqp, Boolean not) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneGreaterThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneGreaterThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneGreaterThan(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneGreaterThan(LuceneQueryParser lqp, Serializable value, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneGreaterThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneGreaterThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneGreaterThanOrEquals(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneGreaterThanOrEquals(LuceneQueryParser lqp, Serializable value, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneIn(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.util.Collection, java.lang.Boolean, - * org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneIn(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.util.Collection, java.lang.Boolean, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneIn(LuceneQueryParser lqp, String propertyName, Collection values, Boolean not, PredicateMode mode) throws ParseException + public Query buildLuceneIn(LuceneQueryParser lqp, Collection values, Boolean not, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneInequality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneInequality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneInequality(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneInequality(LuceneQueryParser lqp, Serializable value, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneLessThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLessThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneLessThan(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneLessThan(LuceneQueryParser lqp, Serializable value, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneLessThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLessThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneLessThanOrEquals(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneLessThanOrEquals(LuceneQueryParser lqp, Serializable value, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneLike(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, java.lang.Boolean) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLike(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, java.lang.Boolean) */ - public Query buildLuceneLike(LuceneQueryParser lqp, String propertyName, Serializable value, Boolean not) throws ParseException + public Query buildLuceneLike(LuceneQueryParser lqp, Serializable value, Boolean not) { return null; } - /* (non-Javadoc) - * @see org.alfresco.cmis.property.NamedPropertyAccessor#getLuceneSortField(java.lang.String) + /* + * (non-Javadoc) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#getLuceneSortField() */ - public String getLuceneSortField(String propertyName) + public String getLuceneSortField() { throw new UnsupportedOperationException(); } diff --git a/source/java/org/alfresco/cmis/property/VersionSeriesIdPropertyAccessor.java b/source/java/org/alfresco/cmis/property/VersionSeriesIdPropertyAccessor.java index 2ad9939486..4e1558ccb4 100644 --- a/source/java/org/alfresco/cmis/property/VersionSeriesIdPropertyAccessor.java +++ b/source/java/org/alfresco/cmis/property/VersionSeriesIdPropertyAccessor.java @@ -28,32 +28,33 @@ import java.io.Serializable; import java.util.Collection; import org.alfresco.cmis.dictionary.CMISDictionaryModel; -import org.alfresco.cmis.dictionary.CMISMapping; -import org.alfresco.cmis.dictionary.CMISScope; import org.alfresco.model.ContentModel; import org.alfresco.repo.search.impl.lucene.LuceneQueryParser; import org.alfresco.repo.search.impl.querymodel.PredicateMode; import org.alfresco.service.ServiceRegistry; import org.alfresco.service.cmr.repository.NodeRef; -import org.apache.lucene.queryParser.ParseException; import org.apache.lucene.search.Query; /** * @author andyh */ -public class VersionSeriesIdPropertyAccessor extends AbstractNamedPropertyAccessor +public class VersionSeriesIdPropertyAccessor extends AbstractPropertyAccessor { - protected VersionSeriesIdPropertyAccessor(CMISMapping cmisMapping, ServiceRegistry serviceRegistry) + /** + * Construct + * + * @param serviceRegistry + */ + public VersionSeriesIdPropertyAccessor(ServiceRegistry serviceRegistry) { - super(cmisMapping, serviceRegistry, CMISScope.DOCUMENT, CMISDictionaryModel.PROP_VERSION_SERIES_ID); + super(serviceRegistry, CMISDictionaryModel.PROP_VERSION_SERIES_ID); } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#getProperty(org.alfresco.service.cmr.repository.NodeRef) + * @see org.alfresco.cmis.property.PropertyAccessor#getValue(org.alfresco.service.cmr.repository.NodeRef) */ - public Serializable getProperty(NodeRef nodeRef) + public Serializable getValue(NodeRef nodeRef) { if (getServiceRegistry().getNodeService().hasAspect(nodeRef, ContentModel.ASPECT_WORKING_COPY)) { @@ -63,115 +64,101 @@ public class VersionSeriesIdPropertyAccessor extends AbstractNamedPropertyAccess return nodeRef.toString(); } - public void setProperty(NodeRef nodeRef, Serializable value) + /* + * (non-Javadoc) + * @see org.alfresco.cmis.property.PropertyAccessor#setValue(org.alfresco.service.cmr.repository.NodeRef, java.io.Serializable) + */ + public void setValue(NodeRef nodeRef, Serializable value) { throw new UnsupportedOperationException(); } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneEquality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneEquality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneEquality(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneEquality(LuceneQueryParser lqp, Serializable value, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneExists(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.lang.Boolean) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneExists(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.lang.Boolean) */ - public Query buildLuceneExists(LuceneQueryParser lqp, String propertyName, Boolean not) throws ParseException + public Query buildLuceneExists(LuceneQueryParser lqp, Boolean not) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneGreaterThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneGreaterThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneGreaterThan(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneGreaterThan(LuceneQueryParser lqp, Serializable value, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneGreaterThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneGreaterThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneGreaterThanOrEquals(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneGreaterThanOrEquals(LuceneQueryParser lqp, Serializable value, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneIn(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.util.Collection, java.lang.Boolean, - * org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneIn(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.util.Collection, java.lang.Boolean, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneIn(LuceneQueryParser lqp, String propertyName, Collection values, Boolean not, PredicateMode mode) throws ParseException + public Query buildLuceneIn(LuceneQueryParser lqp, Collection values, Boolean not, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneInequality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneInequality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneInequality(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneInequality(LuceneQueryParser lqp, Serializable value, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneLessThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLessThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneLessThan(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneLessThan(LuceneQueryParser lqp, Serializable value, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneLessThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLessThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode) */ - public Query buildLuceneLessThanOrEquals(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + public Query buildLuceneLessThanOrEquals(LuceneQueryParser lqp, Serializable value, PredicateMode mode) { return null; } /* * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneLike(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, java.lang.Boolean) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLike(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, java.lang.Boolean) */ - public Query buildLuceneLike(LuceneQueryParser lqp, String propertyName, Serializable value, Boolean not) throws ParseException + public Query buildLuceneLike(LuceneQueryParser lqp, Serializable value, Boolean not) { return null; } - - /* (non-Javadoc) - * @see org.alfresco.cmis.property.NamedPropertyAccessor#getLuceneSortField(java.lang.String) + + /* + * (non-Javadoc) + * @see org.alfresco.cmis.property.PropertyLuceneBuilder#getLuceneSortField() */ - public String getLuceneSortField(String propertyName) + public String getLuceneSortField() { throw new UnsupportedOperationException(); } diff --git a/source/java/org/alfresco/cmis/search/CMISResultSetImpl.java b/source/java/org/alfresco/cmis/search/CMISResultSetImpl.java index 1b5de6bfb1..4ad4e90dd6 100644 --- a/source/java/org/alfresco/cmis/search/CMISResultSetImpl.java +++ b/source/java/org/alfresco/cmis/search/CMISResultSetImpl.java @@ -32,13 +32,11 @@ import java.util.Map; import java.util.Set; import org.alfresco.cmis.dictionary.CMISDictionaryService; -import org.alfresco.cmis.property.CMISPropertyService; import org.alfresco.repo.search.impl.querymodel.Query; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.search.LimitBy; import org.alfresco.service.cmr.search.ResultSet; -import org.springframework.web.servlet.tags.form.OptionTag; /** * @author andyh @@ -57,17 +55,14 @@ public class CMISResultSetImpl implements CMISResultSet, Serializable CMISDictionaryService cmisDictionaryService; - CMISPropertyService cmisPropertyService; - public CMISResultSetImpl(Map wrapped, CMISQueryOptions options, NodeService nodeService, Query query, CMISDictionaryService cmisDictionaryService, - CMISPropertyService cmisPropertyService) + public CMISResultSetImpl(Map wrapped, CMISQueryOptions options, NodeService nodeService, Query query, CMISDictionaryService cmisDictionaryService) { this.wrapped = wrapped; this.options = options; this.nodeService = nodeService; this.query = query; this.cmisDictionaryService = cmisDictionaryService; - this.cmisPropertyService = cmisPropertyService; } /* @@ -106,7 +101,7 @@ public class CMISResultSetImpl implements CMISResultSet, Serializable */ public CMISResultSetRow getRow(int i) { - return new CMISResultSetRowImpl(this, i, getScores(i), nodeService, getNodeRefs(i), query, cmisPropertyService, cmisDictionaryService); + return new CMISResultSetRowImpl(this, i, getScores(i), nodeService, getNodeRefs(i), query, cmisDictionaryService); } /* diff --git a/source/java/org/alfresco/cmis/search/CMISResultSetRowImpl.java b/source/java/org/alfresco/cmis/search/CMISResultSetRowImpl.java index d1d0b54741..160d6b6271 100644 --- a/source/java/org/alfresco/cmis/search/CMISResultSetRowImpl.java +++ b/source/java/org/alfresco/cmis/search/CMISResultSetRowImpl.java @@ -29,7 +29,6 @@ import java.util.LinkedHashMap; import java.util.Map; import org.alfresco.cmis.dictionary.CMISDictionaryService; -import org.alfresco.cmis.property.CMISPropertyService; import org.alfresco.repo.search.impl.querymodel.Column; import org.alfresco.repo.search.impl.querymodel.Query; import org.alfresco.service.cmr.repository.NodeRef; @@ -58,11 +57,9 @@ public class CMISResultSetRowImpl implements CMISResultSetRow private Query query; - private CMISPropertyService cmisPropertyService; - private CMISDictionaryService cmisDictionaryService; - public CMISResultSetRowImpl(CMISResultSet resultSet, int index, Map scores, NodeService nodeService, Map nodeRefs, Query query, CMISPropertyService cmisPropertyService, CMISDictionaryService cmisDictionaryService ) + public CMISResultSetRowImpl(CMISResultSet resultSet, int index, Map scores, NodeService nodeService, Map nodeRefs, Query query, CMISDictionaryService cmisDictionaryService) { this.resultSet = resultSet; this.index = index; @@ -70,7 +67,6 @@ public class CMISResultSetRowImpl implements CMISResultSetRow this.nodeService = nodeService; this.nodeRefs = nodeRefs; this.query = query; - this.cmisPropertyService = cmisPropertyService; this.cmisDictionaryService = cmisDictionaryService; } @@ -163,7 +159,6 @@ public class CMISResultSetRowImpl implements CMISResultSetRow { CmisFunctionEvaluationContext context = new CmisFunctionEvaluationContext(); context.setCmisDictionaryService(cmisDictionaryService); - context.setCmisPropertyService(cmisPropertyService); context.setNodeRefs(nodeRefs); context.setNodeService(nodeService); context.setScores(scores); diff --git a/source/java/org/alfresco/cmis/search/CmisFunctionEvaluationContext.java b/source/java/org/alfresco/cmis/search/CmisFunctionEvaluationContext.java index 1797626aeb..87c25101bf 100644 --- a/source/java/org/alfresco/cmis/search/CmisFunctionEvaluationContext.java +++ b/source/java/org/alfresco/cmis/search/CmisFunctionEvaluationContext.java @@ -30,8 +30,6 @@ import java.util.Map; import org.alfresco.cmis.dictionary.CMISDictionaryService; import org.alfresco.cmis.dictionary.CMISPropertyDefinition; -import org.alfresco.cmis.property.CMISPropertyService; -import org.alfresco.cmis.property.CMISPropertyServiceImpl; import org.alfresco.repo.search.impl.lucene.LuceneQueryParser; import org.alfresco.repo.search.impl.querymodel.FunctionEvaluationContext; import org.alfresco.repo.search.impl.querymodel.PredicateMode; @@ -52,8 +50,6 @@ public class CmisFunctionEvaluationContext implements FunctionEvaluationContext private NodeService nodeService; - private CMISPropertyService cmisPropertyService; - private CMISDictionaryService cmisDictionaryService; private Float score; @@ -85,15 +81,6 @@ public class CmisFunctionEvaluationContext implements FunctionEvaluationContext this.nodeService = nodeService; } - /** - * @param cmisPropertyService - * the cmisPropertyService to set - */ - public void setCmisPropertyService(CMISPropertyService cmisPropertyService) - { - this.cmisPropertyService = cmisPropertyService; - } - /** * @param cmisDictionaryService * the cmisDictionaryService to set @@ -132,7 +119,7 @@ public class CmisFunctionEvaluationContext implements FunctionEvaluationContext public Serializable getProperty(NodeRef nodeRef, QName propertyQName) { CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyQName, null); - return cmisPropertyService.getProperty(nodeRef, propertyDef.getPropertyId().getName()); + return propertyDef.getPropertyAccessor().getValue(nodeRef); } /* @@ -164,16 +151,8 @@ public class CmisFunctionEvaluationContext implements FunctionEvaluationContext public Query buildLuceneEquality(LuceneQueryParser lqp, QName propertyQName, Serializable value, PredicateMode mode) throws ParseException { - if (cmisPropertyService instanceof CMISPropertyServiceImpl) - { - CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyQName, null); - CMISPropertyServiceImpl impl = (CMISPropertyServiceImpl) cmisPropertyService; - return impl.buildLuceneEquality(lqp, propertyDef.getPropertyId().getName(), value, mode); - } - else - { - return null; - } + CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyQName, null); + return propertyDef.getPropertyLuceneBuilder().buildLuceneEquality(lqp, value, mode); } /* @@ -184,16 +163,8 @@ public class CmisFunctionEvaluationContext implements FunctionEvaluationContext */ public Query buildLuceneExists(LuceneQueryParser lqp, QName propertyQName, Boolean not) throws ParseException { - if (cmisPropertyService instanceof CMISPropertyServiceImpl) - { - CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyQName, null); - CMISPropertyServiceImpl impl = (CMISPropertyServiceImpl) cmisPropertyService; - return impl.buildLuceneExists(lqp, propertyDef.getPropertyId().getName(), not); - } - else - { - return null; - } + CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyQName, null); + return propertyDef.getPropertyLuceneBuilder().buildLuceneExists(lqp, not); } /* @@ -205,16 +176,8 @@ public class CmisFunctionEvaluationContext implements FunctionEvaluationContext */ public Query buildLuceneGreaterThan(LuceneQueryParser lqp, QName propertyQName, Serializable value, PredicateMode mode) throws ParseException { - if (cmisPropertyService instanceof CMISPropertyServiceImpl) - { - CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyQName, null); - CMISPropertyServiceImpl impl = (CMISPropertyServiceImpl) cmisPropertyService; - return impl.buildLuceneGreaterThan(lqp, propertyDef.getPropertyId().getName(), value, mode); - } - else - { - return null; - } + CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyQName, null); + return propertyDef.getPropertyLuceneBuilder().buildLuceneGreaterThan(lqp, value, mode); } /* @@ -226,16 +189,8 @@ public class CmisFunctionEvaluationContext implements FunctionEvaluationContext */ public Query buildLuceneGreaterThanOrEquals(LuceneQueryParser lqp, QName propertyQName, Serializable value, PredicateMode mode) throws ParseException { - if (cmisPropertyService instanceof CMISPropertyServiceImpl) - { - CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyQName, null); - CMISPropertyServiceImpl impl = (CMISPropertyServiceImpl) cmisPropertyService; - return impl.buildLuceneGreaterThanOrEquals(lqp, propertyDef.getPropertyId().getName(), value, mode); - } - else - { - return null; - } + CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyQName, null); + return propertyDef.getPropertyLuceneBuilder().buildLuceneGreaterThanOrEquals(lqp, value, mode); } /* @@ -247,16 +202,8 @@ public class CmisFunctionEvaluationContext implements FunctionEvaluationContext */ public Query buildLuceneIn(LuceneQueryParser lqp, QName propertyQName, Collection values, Boolean not, PredicateMode mode) throws ParseException { - if (cmisPropertyService instanceof CMISPropertyServiceImpl) - { - CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyQName, null); - CMISPropertyServiceImpl impl = (CMISPropertyServiceImpl) cmisPropertyService; - return impl.buildLuceneIn(lqp, propertyDef.getPropertyId().getName(), values, not, mode); - } - else - { - return null; - } + CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyQName, null); + return propertyDef.getPropertyLuceneBuilder().buildLuceneIn(lqp, values, not, mode); } /* @@ -268,16 +215,8 @@ public class CmisFunctionEvaluationContext implements FunctionEvaluationContext */ public Query buildLuceneInequality(LuceneQueryParser lqp, QName propertyQName, Serializable value, PredicateMode mode) throws ParseException { - if (cmisPropertyService instanceof CMISPropertyServiceImpl) - { - CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyQName, null); - CMISPropertyServiceImpl impl = (CMISPropertyServiceImpl) cmisPropertyService; - return impl.buildLuceneInequality(lqp, propertyDef.getPropertyId().getName(), value, mode); - } - else - { - return null; - } + CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyQName, null); + return propertyDef.getPropertyLuceneBuilder().buildLuceneInequality(lqp, value, mode); } /* @@ -289,16 +228,8 @@ public class CmisFunctionEvaluationContext implements FunctionEvaluationContext */ public Query buildLuceneLessThan(LuceneQueryParser lqp, QName propertyQName, Serializable value, PredicateMode mode) throws ParseException { - if (cmisPropertyService instanceof CMISPropertyServiceImpl) - { - CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyQName, null); - CMISPropertyServiceImpl impl = (CMISPropertyServiceImpl) cmisPropertyService; - return impl.buildLuceneLessThan(lqp, propertyDef.getPropertyId().getName(), value, mode); - } - else - { - return null; - } + CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyQName, null); + return propertyDef.getPropertyLuceneBuilder().buildLuceneLessThan(lqp, value, mode); } /* @@ -310,16 +241,8 @@ public class CmisFunctionEvaluationContext implements FunctionEvaluationContext */ public Query buildLuceneLessThanOrEquals(LuceneQueryParser lqp, QName propertyQName, Serializable value, PredicateMode mode) throws ParseException { - if (cmisPropertyService instanceof CMISPropertyServiceImpl) - { - CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyQName, null); - CMISPropertyServiceImpl impl = (CMISPropertyServiceImpl) cmisPropertyService; - return impl.buildLuceneLessThanOrEquals(lqp, propertyDef.getPropertyId().getName(), value, mode); - } - else - { - return null; - } + CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyQName, null); + return propertyDef.getPropertyLuceneBuilder().buildLuceneLessThanOrEquals(lqp, value, mode); } /* @@ -330,16 +253,8 @@ public class CmisFunctionEvaluationContext implements FunctionEvaluationContext */ public Query buildLuceneLike(LuceneQueryParser lqp, QName propertyQName, Serializable value, Boolean not) throws ParseException { - if (cmisPropertyService instanceof CMISPropertyServiceImpl) - { - CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyQName, null); - CMISPropertyServiceImpl impl = (CMISPropertyServiceImpl) cmisPropertyService; - return impl.buildLuceneLike(lqp, propertyDef.getPropertyId().getName(), value, not); - } - else - { - return null; - } + CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyQName, null); + return propertyDef.getPropertyLuceneBuilder().buildLuceneLike(lqp, value, not); } /* (non-Javadoc) @@ -347,16 +262,8 @@ public class CmisFunctionEvaluationContext implements FunctionEvaluationContext */ public String getLuceneSortField(QName propertyQName) { - if (cmisPropertyService instanceof CMISPropertyServiceImpl) - { - CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyQName, null); - CMISPropertyServiceImpl impl = (CMISPropertyServiceImpl) cmisPropertyService; - return impl.getLuceneSortField(propertyDef.getPropertyId().getName()); - } - else - { - return null; - } + CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyQName, null); + return propertyDef.getPropertyLuceneBuilder().getLuceneSortField(); } } diff --git a/source/java/org/alfresco/cmis/search/QueryTest.java b/source/java/org/alfresco/cmis/search/QueryTest.java index 9bc4513b01..45c2e6e452 100644 --- a/source/java/org/alfresco/cmis/search/QueryTest.java +++ b/source/java/org/alfresco/cmis/search/QueryTest.java @@ -305,7 +305,7 @@ public class QueryTest extends BaseCMISTest returnValue = (T) DefaultTypeConverter.INSTANCE.convert(returnType.getClass(), sValue); if (dump) { - System.out.println(cmisPropertyService.getProperties(row.getNodeRef(rs.getMetaData().getSelectorNames()[0]))); + System.out.println(cmisService.getProperties(row.getNodeRef(rs.getMetaData().getSelectorNames()[0]))); } } if (dump) @@ -1346,7 +1346,7 @@ public class QueryTest extends BaseCMISTest { String companyHomeId = testQuery("SELECT ObjectId FROM Folder WHERE Name = '\"Folder 0\"'", 1, false, "ObjectId", new String(), false); - Serializable ser = cmisPropertyService.getProperty(f0, CMISDictionaryModel.PROP_OBJECT_ID); + Serializable ser = cmisService.getProperty(f0, CMISDictionaryModel.PROP_OBJECT_ID); String id = DefaultTypeConverter.INSTANCE.convert(String.class, ser); assertEquals(companyHomeId, id); @@ -1490,7 +1490,7 @@ public class QueryTest extends BaseCMISTest public void testFolderEquals() { - Serializable ser = cmisPropertyService.getProperty(f0, CMISDictionaryModel.PROP_NAME); + Serializable ser = cmisService.getProperty(f0, CMISDictionaryModel.PROP_NAME); String Name = DefaultTypeConverter.INSTANCE.convert(String.class, ser); testQuery("SELECT * FROM Folder WHERE Name = '" + Name + "'", 1, false, "ObjectId", new String(), false); @@ -1501,7 +1501,7 @@ public class QueryTest extends BaseCMISTest public void test_IN_TREE() { - Serializable ser = cmisPropertyService.getProperty(f0, CMISDictionaryModel.PROP_OBJECT_ID); + Serializable ser = cmisService.getProperty(f0, CMISDictionaryModel.PROP_OBJECT_ID); String id = DefaultTypeConverter.INSTANCE.convert(String.class, ser); testQuery("SELECT * FROM Folder WHERE IN_TREE('" + id + "')", 6, false, "ObjectId", new String(), false); @@ -1509,7 +1509,7 @@ public class QueryTest extends BaseCMISTest public void test_IN_FOLDER() { - Serializable ser = cmisPropertyService.getProperty(f0, CMISDictionaryModel.PROP_OBJECT_ID); + Serializable ser = cmisService.getProperty(f0, CMISDictionaryModel.PROP_OBJECT_ID); String id = DefaultTypeConverter.INSTANCE.convert(String.class, ser); testQuery("SELECT * FROM Folder WHERE IN_FOLDER('" + id + "')", 2, false, "ObjectId", new String(), false); diff --git a/source/java/org/alfresco/cmis/search/impl/CMISQueryServiceImpl.java b/source/java/org/alfresco/cmis/search/impl/CMISQueryServiceImpl.java index 1d1296c7c5..e6f02f26b5 100644 --- a/source/java/org/alfresco/cmis/search/impl/CMISQueryServiceImpl.java +++ b/source/java/org/alfresco/cmis/search/impl/CMISQueryServiceImpl.java @@ -33,8 +33,6 @@ import org.alfresco.cmis.CMISJoinEnum; import org.alfresco.cmis.CMISQueryEnum; import org.alfresco.cmis.CMISService; import org.alfresco.cmis.dictionary.CMISDictionaryService; -import org.alfresco.cmis.dictionary.CMISMapping; -import org.alfresco.cmis.property.CMISPropertyService; import org.alfresco.cmis.search.CMISQueryOptions; import org.alfresco.cmis.search.CMISQueryService; import org.alfresco.cmis.search.CMISResultSet; @@ -55,8 +53,6 @@ public class CMISQueryServiceImpl implements CMISQueryService private CMISDictionaryService cmisDictionaryService; - private CMISPropertyService cmisPropertyService; - private QueryEngine queryEngine; private NodeService nodeService; @@ -65,7 +61,7 @@ public class CMISQueryServiceImpl implements CMISQueryService * @param service * the service to set */ - public void setCmisService(CMISService cmisService) + public void setCMISService(CMISService cmisService) { this.cmisService = cmisService; } @@ -74,7 +70,7 @@ public class CMISQueryServiceImpl implements CMISQueryService * @param cmisDictionaryService * the cmisDictionaryService to set */ - public void setCmisDictionaryService(CMISDictionaryService cmisDictionaryService) + public void setCMISDictionaryService(CMISDictionaryService cmisDictionaryService) { this.cmisDictionaryService = cmisDictionaryService; } @@ -97,15 +93,6 @@ public class CMISQueryServiceImpl implements CMISQueryService this.nodeService = nodeService; } - /** - * @param cmisPropertyService - * the cmisPropertyService to set - */ - public void setCmisPropertyService(CMISPropertyService cmisPropertyService) - { - this.cmisPropertyService = cmisPropertyService; - } - /* * (non-Javadoc) * @@ -123,7 +110,6 @@ public class CMISQueryServiceImpl implements CMISQueryService CmisFunctionEvaluationContext functionContext = new CmisFunctionEvaluationContext(); functionContext.setCmisDictionaryService(cmisDictionaryService); - functionContext.setCmisPropertyService(cmisPropertyService); functionContext.setNodeService(nodeService); QueryEngineResults results = queryEngine.executeQuery(query, options, functionContext); @@ -137,7 +123,7 @@ public class CMISQueryServiceImpl implements CMISQueryService wrapped.put(selector, current); } } - CMISResultSet cmis = new CMISResultSetImpl(wrapped, options, nodeService, query, cmisDictionaryService, cmisPropertyService); + CMISResultSet cmis = new CMISResultSetImpl(wrapped, options, nodeService, query, cmisDictionaryService); return cmis; } diff --git a/source/java/org/alfresco/repo/search/impl/querymodel/impl/BaseJoin.java b/source/java/org/alfresco/repo/search/impl/querymodel/impl/BaseJoin.java index bd1cb3941d..5d835956bf 100644 --- a/source/java/org/alfresco/repo/search/impl/querymodel/impl/BaseJoin.java +++ b/source/java/org/alfresco/repo/search/impl/querymodel/impl/BaseJoin.java @@ -30,7 +30,7 @@ import java.util.List; import java.util.Map; import java.util.Set; -import org.alfresco.cmis.dictionary.CMISMapping; +import org.alfresco.cmis.mapping.CMISMapping; import org.alfresco.model.ContentModel; import org.alfresco.repo.search.impl.querymodel.Argument; import org.alfresco.repo.search.impl.querymodel.Constraint; diff --git a/source/java/org/alfresco/repo/service/ServiceDescriptorRegistry.java b/source/java/org/alfresco/repo/service/ServiceDescriptorRegistry.java index f7e4e46c4c..9f6a54465d 100644 --- a/source/java/org/alfresco/repo/service/ServiceDescriptorRegistry.java +++ b/source/java/org/alfresco/repo/service/ServiceDescriptorRegistry.java @@ -26,6 +26,9 @@ package org.alfresco.repo.service; import java.util.Collection; +import org.alfresco.cmis.CMISService; +import org.alfresco.cmis.dictionary.CMISDictionaryService; +import org.alfresco.cmis.search.CMISQueryService; import org.alfresco.mbeans.VirtServerRegistry; import org.alfresco.repo.forms.FormService; import org.alfresco.repo.transaction.RetryingTransactionHelper; @@ -504,6 +507,32 @@ public class ServiceDescriptorRegistry public InvitationService getInvitationService() { return (InvitationService)getService(INVITATION_SERVICE); - } + + /* + * (non-Javadoc) + * @see org.alfresco.service.ServiceRegistry#getCMISService() + */ + public CMISService getCMISService() + { + return (CMISService)getService(CMIS_SERVICE); + } + + /* + * (non-Javadoc) + * @see org.alfresco.service.ServiceRegistry#getCMISDictionaryService() + */ + public CMISDictionaryService getCMISDictionaryService() + { + return (CMISDictionaryService)getService(CMIS_DICTIONARY_SERVICE); + } + + /* + * (non-Javadoc) + * @see org.alfresco.service.ServiceRegistry#getCMISQueryService() + */ + public CMISQueryService getCMISQueryService() + { + return (CMISQueryService)getService(CMIS_QUERY_SERVICE); + } } diff --git a/source/java/org/alfresco/service/ServiceRegistry.java b/source/java/org/alfresco/service/ServiceRegistry.java index 051449a777..671c8e4a6c 100644 --- a/source/java/org/alfresco/service/ServiceRegistry.java +++ b/source/java/org/alfresco/service/ServiceRegistry.java @@ -26,6 +26,9 @@ package org.alfresco.service; import java.util.Collection; +import org.alfresco.cmis.CMISService; +import org.alfresco.cmis.dictionary.CMISDictionaryService; +import org.alfresco.cmis.search.CMISQueryService; import org.alfresco.mbeans.VirtServerRegistry; import org.alfresco.repo.forms.FormService; import org.alfresco.repo.transaction.RetryingTransactionHelper; @@ -137,6 +140,10 @@ public interface ServiceRegistry static final QName ASSET_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "AssetService"); static final QName FORM_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "FormService"); static final QName INVITATION_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "InvitationService"); + static final QName CMIS_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "CMISService"); + static final QName CMIS_DICTIONARY_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "CMISDictionaryService"); + static final QName CMIS_QUERY_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "CMISQueryService"); + /** * Get the list of services provided by the Repository @@ -465,4 +472,25 @@ public interface ServiceRegistry */ @NotAuditable InvitationService getInvitationService(); + + /** + * Get the CMIS service (or null if one is not provided) + * @return the CMIS service + */ + @NotAuditable + CMISService getCMISService(); + + /** + * Get the CMIS Dictionary service (or null if one is not provided) + * @return the CMIS Dictionary service + */ + @NotAuditable + CMISDictionaryService getCMISDictionaryService(); + + /** + * Get the CMIS Query service (or null if one is not provided) + * @return the CMIS Query service + */ + @NotAuditable + CMISQueryService getCMISQueryService(); }