From 384f4abdf943e5a93fc441dc713d6516dfdad846 Mon Sep 17 00:00:00 2001 From: David Caruana Date: Sun, 22 Mar 2009 15:23:53 +0000 Subject: [PATCH] MOB-378 (AtomPub binding) Support for sub-types (and properties) - 1st pass at creation of document / folder sub-types - 1st pass at setting / updating custom properties - Existing AtomPub CMIS Tests passing git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@13707 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../AbstractGenericPropertyAccessor.java | 7 + .../AbstractNamedPropertyAccessor.java | 18 +- .../property/AbstractPropertyAccessor.java | 14 +- .../cmis/property/CMISPropertyService.java | 11 +- .../property/CMISPropertyServiceImpl.java | 152 +++++++---------- .../CheckinCommentPropertyAccessor.java | 20 ++- .../ContentStreamLengthPropertyAccessor.java | 18 +- ...ContentStreamMimetypePropertyAccessor.java | 19 +-- .../ContentStreamUriPropertyAccessor.java | 17 +- .../property/FixedValuePropertyAccessor.java | 15 +- .../property/GenericPropertyAccessor.java | 9 + .../property/IsImmutablePropertyAccessor.java | 18 +- .../IsLatestMajorVersionPropertyAccessor.java | 159 +++++++++++++++++- .../IsLatestVersionPropertyAccessor.java | 17 +- .../IsMajorVersionPropertyAccessor.java | 18 +- ...rsionSeriesCheckedOutPropertyAccessor.java | 17 +- .../property/MappingPropertyAccessor.java | 18 +- .../cmis/property/NamedPropertyAccessor.java | 8 + .../property/ObjectIdPropertyAccessor.java | 18 +- .../ObjectTypeIdPropertyAccessor.java | 17 +- .../cmis/property/ParentPropertyAccessor.java | 24 +-- .../cmis/property/SimplePropertyAccessor.java | 19 ++- ...ionSeriesCheckedOutByPropertyAccessor.java | 19 +-- ...ionSeriesCheckedOutIdPropertyAccessor.java | 20 +-- .../VersionSeriesIdPropertyAccessor.java | 17 +- 25 files changed, 417 insertions(+), 272 deletions(-) diff --git a/source/java/org/alfresco/cmis/property/AbstractGenericPropertyAccessor.java b/source/java/org/alfresco/cmis/property/AbstractGenericPropertyAccessor.java index d27b23d524..a05df337e5 100644 --- a/source/java/org/alfresco/cmis/property/AbstractGenericPropertyAccessor.java +++ b/source/java/org/alfresco/cmis/property/AbstractGenericPropertyAccessor.java @@ -24,6 +24,9 @@ */ package org.alfresco.cmis.property; +import org.alfresco.cmis.dictionary.CMISMapping; +import org.alfresco.service.ServiceRegistry; + /** * Base class for generic property accessors @@ -34,5 +37,9 @@ package org.alfresco.cmis.property; public abstract class AbstractGenericPropertyAccessor extends AbstractPropertyAccessor implements GenericPropertyAccessor { + protected AbstractGenericPropertyAccessor(CMISMapping cmisMapping, ServiceRegistry serviceRegistry) + { + super(cmisMapping, serviceRegistry); + } } diff --git a/source/java/org/alfresco/cmis/property/AbstractNamedPropertyAccessor.java b/source/java/org/alfresco/cmis/property/AbstractNamedPropertyAccessor.java index 1a8f5b6686..5da8caf7ff 100644 --- a/source/java/org/alfresco/cmis/property/AbstractNamedPropertyAccessor.java +++ b/source/java/org/alfresco/cmis/property/AbstractNamedPropertyAccessor.java @@ -24,7 +24,9 @@ */ 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 @@ -35,26 +37,24 @@ import org.alfresco.cmis.dictionary.CMISScope; public abstract class AbstractNamedPropertyAccessor extends AbstractPropertyAccessor implements NamedPropertyAccessor { private String propertyName; - private CMISScope scope; - public String getPropertyName() - { - return propertyName; - } - - public void setPropertyName(String propertyName) + 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 void setScope(CMISScope scope) + public String getPropertyName() { - this.scope = scope; + return propertyName; } + } diff --git a/source/java/org/alfresco/cmis/property/AbstractPropertyAccessor.java b/source/java/org/alfresco/cmis/property/AbstractPropertyAccessor.java index 04d9d16ac9..5624e1c3d4 100644 --- a/source/java/org/alfresco/cmis/property/AbstractPropertyAccessor.java +++ b/source/java/org/alfresco/cmis/property/AbstractPropertyAccessor.java @@ -38,25 +38,19 @@ public abstract class AbstractPropertyAccessor private CMISMapping cmisMapping; private ServiceRegistry serviceRegistry; - /** - * @param cmisMapping - */ - public void setCMISMapping(CMISMapping cmisMapping) + + protected AbstractPropertyAccessor(CMISMapping cmisMapping, ServiceRegistry serviceRegistry) { this.cmisMapping = cmisMapping; - } - - public void setServiceRegistry(ServiceRegistry serviceRegistry) - { this.serviceRegistry = serviceRegistry; } - public ServiceRegistry getServiceRegistry() + protected ServiceRegistry getServiceRegistry() { return serviceRegistry; } - public CMISMapping getCMISMapping() + protected CMISMapping getCMISMapping() { return cmisMapping; } diff --git a/source/java/org/alfresco/cmis/property/CMISPropertyService.java b/source/java/org/alfresco/cmis/property/CMISPropertyService.java index 5f2e8092e7..b89cb20648 100644 --- a/source/java/org/alfresco/cmis/property/CMISPropertyService.java +++ b/source/java/org/alfresco/cmis/property/CMISPropertyService.java @@ -28,6 +28,7 @@ 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 @@ -38,6 +39,14 @@ import org.alfresco.service.cmr.repository.NodeRef; */ 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 @@ -66,7 +75,7 @@ public interface CMISPropertyService * @param nodeRef * @return */ - public Map getProperties(NodeRef nodeRef); + 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 index 3b30165726..2fc8d55f7e 100644 --- a/source/java/org/alfresco/cmis/property/CMISPropertyServiceImpl.java +++ b/source/java/org/alfresco/cmis/property/CMISPropertyServiceImpl.java @@ -30,10 +30,11 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; -import org.alfresco.cmis.CMISService; import org.alfresco.cmis.CMISContentStreamAllowedEnum; +import org.alfresco.cmis.CMISService; 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; @@ -105,6 +106,17 @@ public class CMISPropertyServiceImpl implements CMISPropertyService, Initializin 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 @@ -153,7 +165,6 @@ public class CMISPropertyServiceImpl implements CMISPropertyService, Initializin public Serializable getProperty(NodeRef nodeRef, String propertyName) { - QName typeQName = cmisMapping.getCmisType(serviceRegistry.getNodeService().getType(nodeRef)); CMISScope scope; if (cmisMapping.isValidCmisDocument(typeQName)) @@ -197,7 +208,6 @@ public class CMISPropertyServiceImpl implements CMISPropertyService, Initializin return genericPropertyAccessor.getProperty(nodeRef, propertyName); } } - } public void setProperties(NodeRef nodeRef, Map values) @@ -207,15 +217,43 @@ public class CMISPropertyServiceImpl implements CMISPropertyService, Initializin public void setProperty(NodeRef nodeRef, String propertyName, Serializable value) { - throw new UnsupportedOperationException(); + 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(); - genericPropertyAccessor.setServiceRegistry(serviceRegistry); - genericPropertyAccessor.setCMISMapping(cmisMapping); + genericPropertyAccessor = new MappingPropertyAccessor(cmisMapping, serviceRegistry); // CMIS Object addNamedPropertyAccessor(getObjectIdPropertyAccessor()); @@ -254,160 +292,94 @@ public class CMISPropertyServiceImpl implements CMISPropertyService, Initializin public void addNamedPropertyAccessor(NamedPropertyAccessor namedPropertyAccessor) { - namedPropertyAccessors.put(namedPropertyAccessor.getPropertyName(), namedPropertyAccessor); } public NamedPropertyAccessor getSimplePropertyAccessor(String propertyName, QName to, CMISScope scope) { - SimplePropertyAccessor accessor = new SimplePropertyAccessor(); - accessor.setServiceRegistry(serviceRegistry); - accessor.setCMISMapping(cmisMapping); - accessor.setPropertyName(propertyName); - accessor.setMapping(to.toString()); - accessor.setScope(scope); - try - { - accessor.afterPropertiesSet(); - } - catch (Exception e) - { - // TODO Auto-generated catch block - e.printStackTrace(); - } - return accessor; + return new SimplePropertyAccessor(cmisMapping, serviceRegistry, scope, propertyName, to); } public NamedPropertyAccessor getObjectIdPropertyAccessor() { - ObjectIdPropertyAccessor accessor = new ObjectIdPropertyAccessor(); - accessor.setServiceRegistry(serviceRegistry); - accessor.setCMISMapping(cmisMapping); - return accessor; + return new ObjectIdPropertyAccessor(cmisMapping, serviceRegistry); } public NamedPropertyAccessor getFixedValuePropertyAccessor(String propertyName, Serializable fixedValue, CMISScope scope) { - FixedValuePropertyAccessor accessor = new FixedValuePropertyAccessor(); - accessor.setServiceRegistry(serviceRegistry); - accessor.setCMISMapping(cmisMapping); - accessor.setPropertyName(propertyName); + FixedValuePropertyAccessor accessor = new FixedValuePropertyAccessor(cmisMapping, serviceRegistry, scope, propertyName); accessor.setFixedValue(fixedValue); - accessor.setScope(scope); return accessor; } public NamedPropertyAccessor getObjectTypeIdPropertyAccessor() { - ObjectTypeIdPropertyAccessor accessor = new ObjectTypeIdPropertyAccessor(); - accessor.setServiceRegistry(serviceRegistry); - accessor.setCMISMapping(cmisMapping); - return accessor; + return new ObjectTypeIdPropertyAccessor(cmisMapping, serviceRegistry); } public NamedPropertyAccessor getIsImmutablePropertyAccessor() { - IsImmutablePropertyAccessor accessor = new IsImmutablePropertyAccessor(); - accessor.setServiceRegistry(serviceRegistry); - accessor.setCMISMapping(cmisMapping); - return accessor; + return new IsImmutablePropertyAccessor(cmisMapping, serviceRegistry); } public NamedPropertyAccessor getIsLatestVersionPropertyAccessor() { - IsLatestVersionPropertyAccessor accessor = new IsLatestVersionPropertyAccessor(); - accessor.setServiceRegistry(serviceRegistry); - accessor.setCMISMapping(cmisMapping); - return accessor; + return new IsLatestVersionPropertyAccessor(cmisMapping, serviceRegistry); } public NamedPropertyAccessor getIsMajorVersionPropertyAccessor() { - IsMajorVersionPropertyAccessor accessor = new IsMajorVersionPropertyAccessor(); - accessor.setServiceRegistry(serviceRegistry); - accessor.setCMISMapping(cmisMapping); - return accessor; + return new IsMajorVersionPropertyAccessor(cmisMapping, serviceRegistry); } public NamedPropertyAccessor getIsLatestMajorVersionPropertyAccessor() { - IsLatestMajorVersionPropertyAccessor accessor = new IsLatestMajorVersionPropertyAccessor(); - accessor.setServiceRegistry(serviceRegistry); - accessor.setCMISMapping(cmisMapping); - return accessor; + return new IsLatestMajorVersionPropertyAccessor(cmisMapping, serviceRegistry); } public NamedPropertyAccessor getVersionSeriesIdPropertyAccessor() { - VersionSeriesIdPropertyAccessor accessor = new VersionSeriesIdPropertyAccessor(); - accessor.setServiceRegistry(serviceRegistry); - accessor.setCMISMapping(cmisMapping); - return accessor; + return new VersionSeriesIdPropertyAccessor(cmisMapping, serviceRegistry); } public NamedPropertyAccessor getVersionSeriesIsCheckedOutPropertyAccessor() { - IsVersionSeriesCheckedOutPropertyAccessor accessor = new IsVersionSeriesCheckedOutPropertyAccessor(); - accessor.setServiceRegistry(serviceRegistry); - accessor.setCMISMapping(cmisMapping); - return accessor; + return new IsVersionSeriesCheckedOutPropertyAccessor(cmisMapping, serviceRegistry); } public NamedPropertyAccessor getVersionSeriesCheckedOutByPropertyAccessor() { - VersionSeriesCheckedOutByPropertyAccessor accessor = new VersionSeriesCheckedOutByPropertyAccessor(); - accessor.setServiceRegistry(serviceRegistry); - accessor.setCMISMapping(cmisMapping); - return accessor; + return new VersionSeriesCheckedOutByPropertyAccessor(cmisMapping, serviceRegistry); } public NamedPropertyAccessor getVersionSeriesCheckedOutIdPropertyAccessor() { - VersionSeriesCheckedOutIdPropertyAccessor accessor = new VersionSeriesCheckedOutIdPropertyAccessor(); - accessor.setServiceRegistry(serviceRegistry); - accessor.setCMISMapping(cmisMapping); - return accessor; + return new VersionSeriesCheckedOutIdPropertyAccessor(cmisMapping, serviceRegistry); } public NamedPropertyAccessor getCheckinCommentPropertyAccessor() { - CheckinCommentPropertyAccessor accessor = new CheckinCommentPropertyAccessor(); - accessor.setServiceRegistry(serviceRegistry); - accessor.setCMISMapping(cmisMapping); - return accessor; + return new CheckinCommentPropertyAccessor(cmisMapping, serviceRegistry); } public NamedPropertyAccessor getContentStreamLengthPropertyAccessor() { - ContentStreamLengthPropertyAccessor accessor = new ContentStreamLengthPropertyAccessor(); - accessor.setServiceRegistry(serviceRegistry); - accessor.setCMISMapping(cmisMapping); - return accessor; + return new ContentStreamLengthPropertyAccessor(cmisMapping, serviceRegistry); } public NamedPropertyAccessor getContentStreamMimetypePropertyAccessor() { - ContentStreamMimetypePropertyAccessor accessor = new ContentStreamMimetypePropertyAccessor(); - accessor.setServiceRegistry(serviceRegistry); - accessor.setCMISMapping(cmisMapping); - return accessor; + return new ContentStreamMimetypePropertyAccessor(cmisMapping, serviceRegistry); } public NamedPropertyAccessor getContentStreamUriPropertyAccessor() { - ContentStreamUriPropertyAccessor accessor = new ContentStreamUriPropertyAccessor(); - accessor.setServiceRegistry(serviceRegistry); - accessor.setCMISMapping(cmisMapping); - return accessor; + return new ContentStreamUriPropertyAccessor(cmisMapping, serviceRegistry); } public NamedPropertyAccessor getParentPropertyAccessor() { - ParentPropertyAccessor accessor = new ParentPropertyAccessor(); - accessor.setServiceRegistry(serviceRegistry); - accessor.setCMISMapping(cmisMapping); - accessor.setCMISService(cmisService); - return accessor; + return new ParentPropertyAccessor(cmisMapping, serviceRegistry, cmisService); } /** diff --git a/source/java/org/alfresco/cmis/property/CheckinCommentPropertyAccessor.java b/source/java/org/alfresco/cmis/property/CheckinCommentPropertyAccessor.java index e3d6b4fe95..2fd1c3c648 100644 --- a/source/java/org/alfresco/cmis/property/CheckinCommentPropertyAccessor.java +++ b/source/java/org/alfresco/cmis/property/CheckinCommentPropertyAccessor.java @@ -31,6 +31,7 @@ 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; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.version.Version; import org.apache.lucene.search.Query; @@ -42,6 +43,11 @@ import org.apache.lucene.search.Query; */ public class CheckinCommentPropertyAccessor extends AbstractNamedPropertyAccessor { + protected CheckinCommentPropertyAccessor(CMISMapping cmisMapping, ServiceRegistry serviceRegistry) + { + super(cmisMapping, serviceRegistry, CMISScope.DOCUMENT, CMISMapping.PROP_CHECKIN_COMMENT); + } + public Serializable getProperty(NodeRef nodeRef) { @@ -56,18 +62,13 @@ public class CheckinCommentPropertyAccessor extends AbstractNamedPropertyAccesso } } - @Override - public String getPropertyName() + public void setProperty(NodeRef nodeRef, Serializable value) { - return CMISMapping.PROP_CHECKIN_COMMENT; - } - - @Override - public CMISScope getScope() - { - return CMISScope.DOCUMENT; + throw new UnsupportedOperationException(); } + + /* * (non-Javadoc) * @@ -176,4 +177,5 @@ public class CheckinCommentPropertyAccessor extends AbstractNamedPropertyAccesso throw new UnsupportedOperationException(); } + } diff --git a/source/java/org/alfresco/cmis/property/ContentStreamLengthPropertyAccessor.java b/source/java/org/alfresco/cmis/property/ContentStreamLengthPropertyAccessor.java index c0a4876ac8..6b40951f5f 100644 --- a/source/java/org/alfresco/cmis/property/ContentStreamLengthPropertyAccessor.java +++ b/source/java/org/alfresco/cmis/property/ContentStreamLengthPropertyAccessor.java @@ -32,6 +32,7 @@ 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.dictionary.DataTypeDefinition; import org.alfresco.service.cmr.repository.ContentData; import org.alfresco.service.cmr.repository.NodeRef; @@ -52,6 +53,11 @@ import org.apache.lucene.search.BooleanClause.Occur; public class ContentStreamLengthPropertyAccessor extends AbstractNamedPropertyAccessor { + protected ContentStreamLengthPropertyAccessor(CMISMapping cmisMapping, ServiceRegistry serviceRegistry) + { + super(cmisMapping, serviceRegistry, CMISScope.DOCUMENT, CMISMapping.PROP_CONTENT_STREAM_LENGTH); + } + public Serializable getProperty(NodeRef nodeRef) { Serializable value = getServiceRegistry().getNodeService().getProperty(nodeRef, ContentModel.PROP_CONTENT); @@ -67,16 +73,9 @@ public class ContentStreamLengthPropertyAccessor extends AbstractNamedPropertyAc } - @Override - public String getPropertyName() + public void setProperty(NodeRef nodeRef, Serializable value) { - return CMISMapping.PROP_CONTENT_STREAM_LENGTH; - } - - @Override - public CMISScope getScope() - { - return CMISScope.DOCUMENT; + throw new UnsupportedOperationException(); } private String getLuceneFieldName() @@ -271,4 +270,5 @@ public class ContentStreamLengthPropertyAccessor extends AbstractNamedPropertyAc { return getLuceneFieldName(); } + } diff --git a/source/java/org/alfresco/cmis/property/ContentStreamMimetypePropertyAccessor.java b/source/java/org/alfresco/cmis/property/ContentStreamMimetypePropertyAccessor.java index 1098daf454..ebc3abaa6c 100644 --- a/source/java/org/alfresco/cmis/property/ContentStreamMimetypePropertyAccessor.java +++ b/source/java/org/alfresco/cmis/property/ContentStreamMimetypePropertyAccessor.java @@ -32,6 +32,7 @@ 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.dictionary.DataTypeDefinition; import org.alfresco.service.cmr.repository.ContentData; import org.alfresco.service.cmr.repository.NodeRef; @@ -52,6 +53,11 @@ import org.apache.lucene.search.BooleanClause.Occur; public class ContentStreamMimetypePropertyAccessor extends AbstractNamedPropertyAccessor { + protected ContentStreamMimetypePropertyAccessor(CMISMapping cmisMapping, ServiceRegistry serviceRegistry) + { + super(cmisMapping, serviceRegistry, CMISScope.DOCUMENT, CMISMapping.PROP_CONTENT_STREAM_MIME_TYPE); + } + public Serializable getProperty(NodeRef nodeRef) { Serializable value = getServiceRegistry().getNodeService().getProperty(nodeRef, ContentModel.PROP_CONTENT); @@ -64,19 +70,11 @@ public class ContentStreamMimetypePropertyAccessor extends AbstractNamedProperty { return ""; } - } - @Override - public String getPropertyName() + public void setProperty(NodeRef nodeRef, Serializable value) { - return CMISMapping.PROP_CONTENT_STREAM_MIME_TYPE; - } - - @Override - public CMISScope getScope() - { - return CMISScope.DOCUMENT; + throw new UnsupportedOperationException(); } private String getLuceneFieldName() @@ -271,4 +269,5 @@ public class ContentStreamMimetypePropertyAccessor extends AbstractNamedProperty { return getLuceneFieldName(); } + } diff --git a/source/java/org/alfresco/cmis/property/ContentStreamUriPropertyAccessor.java b/source/java/org/alfresco/cmis/property/ContentStreamUriPropertyAccessor.java index c2e6814353..99be25f6c7 100644 --- a/source/java/org/alfresco/cmis/property/ContentStreamUriPropertyAccessor.java +++ b/source/java/org/alfresco/cmis/property/ContentStreamUriPropertyAccessor.java @@ -32,6 +32,7 @@ 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; @@ -44,6 +45,11 @@ import org.apache.lucene.search.Query; public class ContentStreamUriPropertyAccessor extends AbstractNamedPropertyAccessor { + protected ContentStreamUriPropertyAccessor(CMISMapping cmisMapping, ServiceRegistry serviceRegistry) + { + super(cmisMapping, serviceRegistry, CMISScope.DOCUMENT, CMISMapping.PROP_CONTENT_STREAM_URI); + } + public Serializable getProperty(NodeRef nodeRef) { StringBuilder sb = new StringBuilder(); @@ -58,16 +64,9 @@ public class ContentStreamUriPropertyAccessor extends AbstractNamedPropertyAcces return sb.toString(); } - @Override - public String getPropertyName() + public void setProperty(NodeRef nodeRef, Serializable value) { - return CMISMapping.PROP_CONTENT_STREAM_URI; - } - - @Override - public CMISScope getScope() - { - return CMISScope.DOCUMENT; + throw new UnsupportedOperationException(); } /* diff --git a/source/java/org/alfresco/cmis/property/FixedValuePropertyAccessor.java b/source/java/org/alfresco/cmis/property/FixedValuePropertyAccessor.java index 2611545595..7aac6c58a6 100644 --- a/source/java/org/alfresco/cmis/property/FixedValuePropertyAccessor.java +++ b/source/java/org/alfresco/cmis/property/FixedValuePropertyAccessor.java @@ -29,9 +29,11 @@ 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.cmr.dictionary.DataTypeDefinition; +import org.alfresco.service.ServiceRegistry; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter; import org.alfresco.util.EqualsHelper; @@ -49,6 +51,12 @@ import org.apache.lucene.search.TermQuery; */ public class FixedValuePropertyAccessor extends AbstractNamedPropertyAccessor { + + protected FixedValuePropertyAccessor(CMISMapping cmisMapping, ServiceRegistry serviceRegistry, CMISScope scope, String propertyName) + { + super(cmisMapping, serviceRegistry, scope, propertyName); + } + Serializable fixedValue; public Serializable getFixedValue() @@ -66,6 +74,11 @@ public class FixedValuePropertyAccessor extends AbstractNamedPropertyAccessor return fixedValue; } + public void setProperty(NodeRef nodeRef, Serializable value) + { + throw new UnsupportedOperationException(); + } + /* * (non-Javadoc) * diff --git a/source/java/org/alfresco/cmis/property/GenericPropertyAccessor.java b/source/java/org/alfresco/cmis/property/GenericPropertyAccessor.java index bf0b73338d..20cb660712 100644 --- a/source/java/org/alfresco/cmis/property/GenericPropertyAccessor.java +++ b/source/java/org/alfresco/cmis/property/GenericPropertyAccessor.java @@ -48,6 +48,15 @@ public interface GenericPropertyAccessor * @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; diff --git a/source/java/org/alfresco/cmis/property/IsImmutablePropertyAccessor.java b/source/java/org/alfresco/cmis/property/IsImmutablePropertyAccessor.java index 5f9ee39005..06960e450c 100644 --- a/source/java/org/alfresco/cmis/property/IsImmutablePropertyAccessor.java +++ b/source/java/org/alfresco/cmis/property/IsImmutablePropertyAccessor.java @@ -32,6 +32,7 @@ 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.alfresco.service.cmr.repository.datatype.DefaultTypeConverter; @@ -46,6 +47,11 @@ import org.apache.lucene.search.Query; public class IsImmutablePropertyAccessor extends AbstractNamedPropertyAccessor { + protected IsImmutablePropertyAccessor(CMISMapping cmisMapping, ServiceRegistry serviceRegistry) + { + super(cmisMapping, serviceRegistry, CMISScope.DOCUMENT, CMISMapping.PROP_IS_IMMUTABLE); + } + public Serializable getProperty(NodeRef nodeRef) { LockType type = getServiceRegistry().getLockService().getLockType(nodeRef); @@ -63,19 +69,11 @@ public class IsImmutablePropertyAccessor extends AbstractNamedPropertyAccessor } } return Boolean.valueOf(false); - } - @Override - public String getPropertyName() + public void setProperty(NodeRef nodeRef, Serializable value) { - return CMISMapping.PROP_IS_IMMUTABLE; - } - - @Override - public CMISScope getScope() - { - return CMISScope.DOCUMENT; + throw new UnsupportedOperationException(); } /* diff --git a/source/java/org/alfresco/cmis/property/IsLatestMajorVersionPropertyAccessor.java b/source/java/org/alfresco/cmis/property/IsLatestMajorVersionPropertyAccessor.java index a7eb870516..4e2fede877 100644 --- a/source/java/org/alfresco/cmis/property/IsLatestMajorVersionPropertyAccessor.java +++ b/source/java/org/alfresco/cmis/property/IsLatestMajorVersionPropertyAccessor.java @@ -24,19 +24,166 @@ */ 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.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.cmr.version.Version; +import org.alfresco.service.cmr.version.VersionType; +import org.apache.lucene.queryParser.ParseException; +import org.apache.lucene.search.Query; /** - * Property accessor for CMIS is latest major version + * Accessor for CMIS is latest major version property * * @author andyh - * */ -public class IsLatestMajorVersionPropertyAccessor extends IsMajorVersionPropertyAccessor +public class IsLatestMajorVersionPropertyAccessor extends AbstractNamedPropertyAccessor { - @Override - public String getPropertyName() + + protected IsLatestMajorVersionPropertyAccessor(CMISMapping cmisMapping, ServiceRegistry serviceRegistry) { - return CMISMapping.PROP_IS_LATEST_MAJOR_VERSION; + super(cmisMapping, serviceRegistry, CMISScope.DOCUMENT, CMISMapping.PROP_IS_LATEST_MAJOR_VERSION); } + + public Serializable getProperty(NodeRef nodeRef) + { + if (getServiceRegistry().getNodeService().hasAspect(nodeRef, ContentModel.ASPECT_WORKING_COPY)) + { + return false; + } + else + { + Version version = getServiceRegistry().getVersionService().getCurrentVersion(nodeRef); + if (version != null) + { + return (version.getVersionType() == VersionType.MAJOR); + } + else + { + return false; + } + } + } + + public void setProperty(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) + */ + public Query buildLuceneEquality(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + { + 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 + { + 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) + */ + public Query buildLuceneGreaterThan(LuceneQueryParser lqp, String propertyName, 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) + */ + public Query buildLuceneGreaterThanOrEquals(LuceneQueryParser lqp, String propertyName, 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) + */ + public Query buildLuceneIn(LuceneQueryParser lqp, String propertyName, Collection values, Boolean not, PredicateMode mode) throws ParseException + { + 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) + */ + public Query buildLuceneInequality(LuceneQueryParser lqp, String propertyName, Serializable value, PredicateMode mode) throws ParseException + { + 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) + */ + public Query buildLuceneLessThan(LuceneQueryParser lqp, String propertyName, 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) + */ + public Query buildLuceneLessThanOrEquals(LuceneQueryParser lqp, String propertyName, 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) + */ + public Query buildLuceneLike(LuceneQueryParser lqp, String propertyName, Serializable value, Boolean not) throws ParseException + { + return null; + } + + /* (non-Javadoc) + * @see org.alfresco.cmis.property.NamedPropertyAccessor#getLuceneSortField(java.lang.String) + */ + public String getLuceneSortField(String propertyName) + { + throw new UnsupportedOperationException(); + } + } diff --git a/source/java/org/alfresco/cmis/property/IsLatestVersionPropertyAccessor.java b/source/java/org/alfresco/cmis/property/IsLatestVersionPropertyAccessor.java index 39e0e55c15..b20f1f529a 100644 --- a/source/java/org/alfresco/cmis/property/IsLatestVersionPropertyAccessor.java +++ b/source/java/org/alfresco/cmis/property/IsLatestVersionPropertyAccessor.java @@ -32,6 +32,7 @@ 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; @@ -44,21 +45,19 @@ import org.apache.lucene.search.Query; public class IsLatestVersionPropertyAccessor extends AbstractNamedPropertyAccessor { + protected IsLatestVersionPropertyAccessor(CMISMapping cmisMapping, ServiceRegistry serviceRegistry) + { + super(cmisMapping, serviceRegistry, CMISScope.DOCUMENT, CMISMapping.PROP_IS_LATEST_VERSION); + } + public Serializable getProperty(NodeRef nodeRef) { return !getServiceRegistry().getNodeService().hasAspect(nodeRef, ContentModel.ASPECT_WORKING_COPY); } - @Override - public String getPropertyName() + public void setProperty(NodeRef nodeRef, Serializable value) { - return CMISMapping.PROP_IS_LATEST_VERSION; - } - - @Override - public CMISScope getScope() - { - return CMISScope.DOCUMENT; + throw new UnsupportedOperationException(); } /* diff --git a/source/java/org/alfresco/cmis/property/IsMajorVersionPropertyAccessor.java b/source/java/org/alfresco/cmis/property/IsMajorVersionPropertyAccessor.java index 9baa6a0487..1725e1eb3f 100644 --- a/source/java/org/alfresco/cmis/property/IsMajorVersionPropertyAccessor.java +++ b/source/java/org/alfresco/cmis/property/IsMajorVersionPropertyAccessor.java @@ -32,6 +32,7 @@ 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.alfresco.service.cmr.version.Version; import org.alfresco.service.cmr.version.VersionType; @@ -46,6 +47,11 @@ import org.apache.lucene.search.Query; public class IsMajorVersionPropertyAccessor extends AbstractNamedPropertyAccessor { + protected IsMajorVersionPropertyAccessor(CMISMapping cmisMapping, ServiceRegistry serviceRegistry) + { + super(cmisMapping, serviceRegistry, CMISScope.DOCUMENT, CMISMapping.PROP_IS_MAJOR_VERSION); + } + public Serializable getProperty(NodeRef nodeRef) { if (getServiceRegistry().getNodeService().hasAspect(nodeRef, ContentModel.ASPECT_WORKING_COPY)) @@ -66,18 +72,12 @@ public class IsMajorVersionPropertyAccessor extends AbstractNamedPropertyAccesso } } - @Override - public String getPropertyName() + public void setProperty(NodeRef nodeRef, Serializable value) { - return CMISMapping.PROP_IS_MAJOR_VERSION; - } - - @Override - public CMISScope getScope() - { - return CMISScope.DOCUMENT; + throw new UnsupportedOperationException(); } + /* * (non-Javadoc) * diff --git a/source/java/org/alfresco/cmis/property/IsVersionSeriesCheckedOutPropertyAccessor.java b/source/java/org/alfresco/cmis/property/IsVersionSeriesCheckedOutPropertyAccessor.java index c9ee6ee726..4d1aab8f33 100644 --- a/source/java/org/alfresco/cmis/property/IsVersionSeriesCheckedOutPropertyAccessor.java +++ b/source/java/org/alfresco/cmis/property/IsVersionSeriesCheckedOutPropertyAccessor.java @@ -32,6 +32,7 @@ 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; @@ -45,6 +46,11 @@ import org.apache.lucene.search.Query; public class IsVersionSeriesCheckedOutPropertyAccessor extends AbstractNamedPropertyAccessor { + protected IsVersionSeriesCheckedOutPropertyAccessor(CMISMapping cmisMapping, ServiceRegistry serviceRegistry) + { + super(cmisMapping, serviceRegistry, CMISScope.DOCUMENT, CMISMapping.PROP_IS_VERSION_SERIES_CHECKED_OUT); + } + public Serializable getProperty(NodeRef nodeRef) { if (getServiceRegistry().getNodeService().hasAspect(nodeRef, ContentModel.ASPECT_WORKING_COPY)) @@ -66,16 +72,9 @@ public class IsVersionSeriesCheckedOutPropertyAccessor extends AbstractNamedProp } } - @Override - public String getPropertyName() + public void setProperty(NodeRef nodeRef, Serializable value) { - return CMISMapping.PROP_IS_VERSION_SERIES_CHECKED_OUT; - } - - @Override - public CMISScope getScope() - { - return CMISScope.DOCUMENT; + throw new UnsupportedOperationException(); } /* diff --git a/source/java/org/alfresco/cmis/property/MappingPropertyAccessor.java b/source/java/org/alfresco/cmis/property/MappingPropertyAccessor.java index 23107c2a1a..3a64f1b03b 100644 --- a/source/java/org/alfresco/cmis/property/MappingPropertyAccessor.java +++ b/source/java/org/alfresco/cmis/property/MappingPropertyAccessor.java @@ -27,8 +27,10 @@ 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; @@ -48,13 +50,23 @@ import org.apache.lucene.search.BooleanClause.Occur; */ 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) @@ -277,6 +289,6 @@ public class MappingPropertyAccessor extends AbstractGenericPropertyAccessor QName propertyQname = getCMISMapping().getPropertyQName(propertyName); return getLuceneFieldName(propertyQname); } - - + + } diff --git a/source/java/org/alfresco/cmis/property/NamedPropertyAccessor.java b/source/java/org/alfresco/cmis/property/NamedPropertyAccessor.java index 73e6722519..1a825c3f7e 100644 --- a/source/java/org/alfresco/cmis/property/NamedPropertyAccessor.java +++ b/source/java/org/alfresco/cmis/property/NamedPropertyAccessor.java @@ -55,6 +55,14 @@ public interface NamedPropertyAccessor * @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? diff --git a/source/java/org/alfresco/cmis/property/ObjectIdPropertyAccessor.java b/source/java/org/alfresco/cmis/property/ObjectIdPropertyAccessor.java index 85373644bb..9d3d8798f6 100644 --- a/source/java/org/alfresco/cmis/property/ObjectIdPropertyAccessor.java +++ b/source/java/org/alfresco/cmis/property/ObjectIdPropertyAccessor.java @@ -33,6 +33,7 @@ import org.alfresco.cmis.search.CMISQueryException; 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.dictionary.DataTypeDefinition; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter; @@ -52,6 +53,11 @@ import org.apache.lucene.search.BooleanClause.Occur; public class ObjectIdPropertyAccessor extends AbstractNamedPropertyAccessor { + protected ObjectIdPropertyAccessor(CMISMapping cmisMapping, ServiceRegistry serviceRegistry) + { + super(cmisMapping, serviceRegistry, CMISScope.OBJECT, CMISMapping.PROP_OBJECT_ID); + } + public Serializable getProperty(NodeRef nodeRef) { if (getServiceRegistry().getNodeService().hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE)) @@ -73,18 +79,10 @@ public class ObjectIdPropertyAccessor extends AbstractNamedPropertyAccessor } - @Override - public String getPropertyName() + public void setProperty(NodeRef nodeRef, Serializable value) { - return CMISMapping.PROP_OBJECT_ID; + throw new UnsupportedOperationException(); } - - @Override - public CMISScope getScope() - { - return CMISScope.OBJECT; - } - private String getLuceneFieldName() { diff --git a/source/java/org/alfresco/cmis/property/ObjectTypeIdPropertyAccessor.java b/source/java/org/alfresco/cmis/property/ObjectTypeIdPropertyAccessor.java index de54a2ef96..09e242197d 100644 --- a/source/java/org/alfresco/cmis/property/ObjectTypeIdPropertyAccessor.java +++ b/source/java/org/alfresco/cmis/property/ObjectTypeIdPropertyAccessor.java @@ -34,7 +34,7 @@ import org.alfresco.cmis.dictionary.CMISTypeId; import org.alfresco.cmis.search.CMISQueryException; import org.alfresco.repo.search.impl.lucene.LuceneQueryParser; import org.alfresco.repo.search.impl.querymodel.PredicateMode; -import org.alfresco.service.cmr.dictionary.DataTypeDefinition; +import org.alfresco.service.ServiceRegistry; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter; import org.alfresco.service.namespace.QName; @@ -53,6 +53,10 @@ import org.apache.lucene.search.BooleanClause.Occur; */ public class ObjectTypeIdPropertyAccessor extends AbstractNamedPropertyAccessor { + protected ObjectTypeIdPropertyAccessor(CMISMapping cmisMapping, ServiceRegistry serviceRegistry) + { + super(cmisMapping, serviceRegistry, CMISScope.OBJECT, CMISMapping.PROP_OBJECT_TYPE_ID); + } public Serializable getProperty(NodeRef nodeRef) { @@ -73,16 +77,9 @@ public class ObjectTypeIdPropertyAccessor extends AbstractNamedPropertyAccessor return getCMISMapping().getCmisTypeId(scope, typeQName).getTypeId(); } - @Override - public String getPropertyName() + public void setProperty(NodeRef nodeRef, Serializable value) { - return CMISMapping.PROP_OBJECT_TYPE_ID; - } - - @Override - public CMISScope getScope() - { - return CMISScope.OBJECT; + throw new UnsupportedOperationException(); } private String getLuceneFieldName() diff --git a/source/java/org/alfresco/cmis/property/ParentPropertyAccessor.java b/source/java/org/alfresco/cmis/property/ParentPropertyAccessor.java index 9344d1ccb7..72ddaaca29 100644 --- a/source/java/org/alfresco/cmis/property/ParentPropertyAccessor.java +++ b/source/java/org/alfresco/cmis/property/ParentPropertyAccessor.java @@ -32,6 +32,7 @@ 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; import org.alfresco.service.cmr.dictionary.DataTypeDefinition; import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.NodeRef; @@ -53,17 +54,13 @@ import org.apache.lucene.search.BooleanClause.Occur; public class ParentPropertyAccessor extends AbstractNamedPropertyAccessor { private CMISService cmisService; - - - /** - * @param cmisService - */ - public void setCMISService(CMISService cmisService) + + protected ParentPropertyAccessor(CMISMapping cmisMapping, ServiceRegistry serviceRegistry, CMISService cmisService) { + super(cmisMapping, serviceRegistry, CMISScope.FOLDER, CMISMapping.PROP_PARENT_ID); this.cmisService = cmisService; } - public Serializable getProperty(NodeRef nodeRef) { if (nodeRef.equals(cmisService.getDefaultRootNodeRef())) @@ -82,20 +79,11 @@ public class ParentPropertyAccessor extends AbstractNamedPropertyAccessor } } - - @Override - public String getPropertyName() + public void setProperty(NodeRef nodeRef, Serializable value) { - return CMISMapping.PROP_PARENT_ID; + throw new UnsupportedOperationException(); } - - @Override - public CMISScope getScope() - { - return CMISScope.FOLDER; - } - private String getLuceneFieldName() { return "PARENT"; diff --git a/source/java/org/alfresco/cmis/property/SimplePropertyAccessor.java b/source/java/org/alfresco/cmis/property/SimplePropertyAccessor.java index 462465f604..dec09dc016 100644 --- a/source/java/org/alfresco/cmis/property/SimplePropertyAccessor.java +++ b/source/java/org/alfresco/cmis/property/SimplePropertyAccessor.java @@ -27,8 +27,11 @@ 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; import org.alfresco.service.cmr.dictionary.PropertyDefinition; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter; @@ -40,22 +43,20 @@ 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; -import org.springframework.beans.factory.InitializingBean; /** * A simple 1-1 property mapping from a CMIS property name to an alfresco property * * @author andyh */ -public class SimplePropertyAccessor extends AbstractNamedPropertyAccessor implements InitializingBean +public class SimplePropertyAccessor extends AbstractNamedPropertyAccessor { private QName propertyQname; - private String mapping; - - public void setMapping(String mapping) + protected SimplePropertyAccessor(CMISMapping cmisMapping, ServiceRegistry serviceRegistry, CMISScope scope, String propertyName, QName mapping) { - this.mapping = mapping; + super(cmisMapping, serviceRegistry, scope, propertyName); + propertyQname = mapping; } public Serializable getProperty(NodeRef nodeRef) @@ -63,11 +64,11 @@ public class SimplePropertyAccessor extends AbstractNamedPropertyAccessor implem return getServiceRegistry().getNodeService().getProperty(nodeRef, propertyQname); } - public void afterPropertiesSet() throws Exception + public void setProperty(NodeRef nodeRef, Serializable value) { - propertyQname = QName.resolveToQName(getServiceRegistry().getNamespaceService(), mapping); + throw new UnsupportedOperationException(); } - + private String getLuceneFieldName() { StringBuilder field = new StringBuilder(64); diff --git a/source/java/org/alfresco/cmis/property/VersionSeriesCheckedOutByPropertyAccessor.java b/source/java/org/alfresco/cmis/property/VersionSeriesCheckedOutByPropertyAccessor.java index 41e48ccd2c..9cb918cf10 100644 --- a/source/java/org/alfresco/cmis/property/VersionSeriesCheckedOutByPropertyAccessor.java +++ b/source/java/org/alfresco/cmis/property/VersionSeriesCheckedOutByPropertyAccessor.java @@ -32,6 +32,7 @@ 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; @@ -45,6 +46,11 @@ import org.apache.lucene.search.Query; public class VersionSeriesCheckedOutByPropertyAccessor extends AbstractNamedPropertyAccessor { + protected VersionSeriesCheckedOutByPropertyAccessor(CMISMapping cmisMapping, ServiceRegistry serviceRegistry) + { + super(cmisMapping, serviceRegistry, CMISScope.DOCUMENT, CMISMapping.PROP_VERSION_SERIES_CHECKED_OUT_BY); + } + public Serializable getProperty(NodeRef nodeRef) { if (getServiceRegistry().getNodeService().hasAspect(nodeRef, ContentModel.ASPECT_WORKING_COPY)) @@ -72,17 +78,10 @@ public class VersionSeriesCheckedOutByPropertyAccessor extends AbstractNamedProp } } } - - @Override - public String getPropertyName() + + public void setProperty(NodeRef nodeRef, Serializable value) { - return CMISMapping.PROP_VERSION_SERIES_CHECKED_OUT_BY; - } - - @Override - public CMISScope getScope() - { - return CMISScope.DOCUMENT; + throw new UnsupportedOperationException(); } /* diff --git a/source/java/org/alfresco/cmis/property/VersionSeriesCheckedOutIdPropertyAccessor.java b/source/java/org/alfresco/cmis/property/VersionSeriesCheckedOutIdPropertyAccessor.java index d24e8af3d9..89f448912e 100644 --- a/source/java/org/alfresco/cmis/property/VersionSeriesCheckedOutIdPropertyAccessor.java +++ b/source/java/org/alfresco/cmis/property/VersionSeriesCheckedOutIdPropertyAccessor.java @@ -32,6 +32,7 @@ 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; @@ -44,6 +45,10 @@ import org.apache.lucene.search.Query; */ public class VersionSeriesCheckedOutIdPropertyAccessor extends AbstractNamedPropertyAccessor { + protected VersionSeriesCheckedOutIdPropertyAccessor(CMISMapping cmisMapping, ServiceRegistry serviceRegistry) + { + super(cmisMapping, serviceRegistry, CMISScope.DOCUMENT, CMISMapping.PROP_VERSION_SERIES_CHECKED_OUT_ID); + } public Serializable getProperty(NodeRef nodeRef) { @@ -64,21 +69,14 @@ public class VersionSeriesCheckedOutIdPropertyAccessor extends AbstractNamedProp return null; } } - } - @Override - public String getPropertyName() + public void setProperty(NodeRef nodeRef, Serializable value) { - return CMISMapping.PROP_VERSION_SERIES_CHECKED_OUT_ID; + throw new UnsupportedOperationException(); } - - @Override - public CMISScope getScope() - { - return CMISScope.DOCUMENT; - } - + + /* * (non-Javadoc) * diff --git a/source/java/org/alfresco/cmis/property/VersionSeriesIdPropertyAccessor.java b/source/java/org/alfresco/cmis/property/VersionSeriesIdPropertyAccessor.java index e2e85a3245..911cb37cc2 100644 --- a/source/java/org/alfresco/cmis/property/VersionSeriesIdPropertyAccessor.java +++ b/source/java/org/alfresco/cmis/property/VersionSeriesIdPropertyAccessor.java @@ -32,6 +32,7 @@ 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; @@ -41,6 +42,10 @@ import org.apache.lucene.search.Query; */ public class VersionSeriesIdPropertyAccessor extends AbstractNamedPropertyAccessor { + protected VersionSeriesIdPropertyAccessor(CMISMapping cmisMapping, ServiceRegistry serviceRegistry) + { + super(cmisMapping, serviceRegistry, CMISScope.DOCUMENT, CMISMapping.PROP_VERSION_SERIES_ID); + } /* * (non-Javadoc) @@ -57,16 +62,9 @@ public class VersionSeriesIdPropertyAccessor extends AbstractNamedPropertyAccess return nodeRef.toString(); } - @Override - public String getPropertyName() + public void setProperty(NodeRef nodeRef, Serializable value) { - return CMISMapping.PROP_VERSION_SERIES_ID; - } - - @Override - public CMISScope getScope() - { - return CMISScope.DOCUMENT; + throw new UnsupportedOperationException(); } /* @@ -176,5 +174,4 @@ public class VersionSeriesIdPropertyAccessor extends AbstractNamedPropertyAccess { throw new UnsupportedOperationException(); } - }