You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by je...@apache.org on 2013/08/16 10:47:51 UTC
svn commit: r1514619 [1/4] - in
/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory:
./ query/ server/ storedobj/api/ storedobj/impl/ types/
Author: jens
Date: Fri Aug 16 08:47:50 2013
New Revision: 1514619
URL: http://svn.apache.org/r1514619
Log:
InMemory: more cleanup
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/DummyCallContext.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/FilterParser.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/TypeManagerImpl.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/TypeValidator.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/query/InMemoryQueryProcessor.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/query/PropertyQueryUtil.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/BaseServiceValidatorImpl.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/ExtensionSample.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryAclService.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryMultiFilingServiceImpl.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryNavigationServiceImpl.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryObjectServiceImpl.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryServiceContext.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryServiceFactoryImpl.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryVersioningServiceImpl.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/Children.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/Filing.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/ObjectStore.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/ObjectStoreFiling.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/StoredObject.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/ContentStreamDataImpl.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/DocumentImpl.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/DocumentVersionImpl.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/FilingImpl.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/FolderImpl.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/ImageThumbnailGenerator.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/InMemoryAcl.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/InMemoryServiceValidatorImpl.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/ObjectStoreImpl.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/PolicyImpl.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/RelationshipImpl.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/StoreManagerImpl.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/StoredObjectImpl.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/VersionedDocumentImpl.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/DefaultTypeSystemCreator.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/PropertyCreationHelper.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/TypeUtil.java
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/DummyCallContext.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/DummyCallContext.java?rev=1514619&r1=1514618&r2=1514619&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/DummyCallContext.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/DummyCallContext.java Fri Aug 16 08:47:50 2013
@@ -29,6 +29,8 @@ import org.apache.chemistry.opencmis.com
import org.apache.chemistry.opencmis.commons.server.CallContext;
public class DummyCallContext implements CallContext {
+ private static final int FOUR_M = 4;
+ private static final int SIZE_KB = 1024;
private final Map<String, Object> fParameter = new HashMap<String, Object>();
public DummyCallContext() {
@@ -44,52 +46,52 @@ public class DummyCallContext implements
}
@Override
- public boolean isObjectInfoRequired() {
+ public boolean isObjectInfoRequired() {
return false;
}
@Override
- public Object get(String key) {
+ public Object get(String key) {
return fParameter.get(key);
}
@Override
- public String getBinding() {
+ public String getBinding() {
return BINDING_ATOMPUB;
}
-
+
@Override
- public CmisVersion getCmisVersion() {
+ public CmisVersion getCmisVersion() {
return CmisVersion.CMIS_1_1;
}
@Override
- public String getRepositoryId() {
+ public String getRepositoryId() {
return (String) get(REPOSITORY_ID);
}
@Override
- public String getLocale() {
+ public String getLocale() {
return (String) get(LOCALE);
}
@Override
- public BigInteger getOffset() {
+ public BigInteger getOffset() {
return (BigInteger) get(OFFSET);
}
@Override
- public BigInteger getLength() {
+ public BigInteger getLength() {
return (BigInteger) get(LENGTH);
}
@Override
- public String getPassword() {
+ public String getPassword() {
return (String) get(PASSWORD);
}
@Override
- public String getUsername() {
+ public String getUsername() {
return (String) get(USERNAME);
}
@@ -98,22 +100,22 @@ public class DummyCallContext implements
}
@Override
- public File getTempDirectory() {
+ public File getTempDirectory() {
return null;
}
@Override
- public boolean encryptTempFiles() {
+ public boolean encryptTempFiles() {
return false;
}
@Override
- public int getMemoryThreshold() {
- return 4 * 1024 * 1024;
+ public int getMemoryThreshold() {
+ return FOUR_M * SIZE_KB * SIZE_KB;
}
@Override
- public long getMaxContentSize() {
- return 4 * 1024 * 1024 * 1024;
+ public long getMaxContentSize() {
+ return FOUR_M * SIZE_KB * SIZE_KB * SIZE_KB;
}
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/FilterParser.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/FilterParser.java?rev=1514619&r1=1514618&r2=1514619&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/FilterParser.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/FilterParser.java Fri Aug 16 08:47:50 2013
@@ -29,7 +29,7 @@ import org.apache.chemistry.opencmis.com
/**
* @author Jens
*/
-public class FilterParser {
+public final class FilterParser {
// Utility class
private FilterParser() {
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/TypeManagerImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/TypeManagerImpl.java?rev=1514619&r1=1514618&r2=1514619&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/TypeManagerImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/TypeManagerImpl.java Fri Aug 16 08:47:50 2013
@@ -41,9 +41,9 @@ import org.slf4j.LoggerFactory;
/**
* Class that manages a type system for a repository types can be added, the
* inheritance can be managed and type can be retrieved for a given type id.
- *
+ *
* @author Jens
- *
+ *
*/
public class TypeManagerImpl implements TypeManagerCreatable {
@@ -53,19 +53,27 @@ public class TypeManagerImpl implements
*/
private final Map<String, TypeDefinitionContainer> fTypesMap = new HashMap<String, TypeDefinitionContainer>();
- /* (non-Javadoc)
- * @see org.apache.chemistry.opencmis.inmemory.TypeManager#getTypeById(java.lang.String)
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.apache.chemistry.opencmis.inmemory.TypeManager#getTypeById(java.lang
+ * .String)
*/
@Override
- public TypeDefinitionContainer getTypeById(String typeId) {
+ public TypeDefinitionContainer getTypeById(String typeId) {
return fTypesMap.get(typeId);
}
- /* (non-Javadoc)
- * @see org.apache.chemistry.opencmis.inmemory.TypeManager#getTypeByQueryName(java.lang.String)
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.apache.chemistry.opencmis.inmemory.TypeManager#getTypeByQueryName
+ * (java.lang.String)
*/
@Override
- public TypeDefinition getTypeByQueryName(String typeQueryName) {
+ public TypeDefinition getTypeByQueryName(String typeQueryName) {
for (Entry<String, TypeDefinitionContainer> entry : fTypesMap.entrySet()) {
if (entry.getValue().getTypeDefinition().getQueryName().equals(typeQueryName)) {
return entry.getValue().getTypeDefinition();
@@ -74,19 +82,25 @@ public class TypeManagerImpl implements
return null;
}
- /* (non-Javadoc)
- * @see org.apache.chemistry.opencmis.inmemory.TypeManager#getTypeDefinitionList()
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.apache.chemistry.opencmis.inmemory.TypeManager#getTypeDefinitionList
+ * ()
*/
@Override
- public Collection<TypeDefinitionContainer> getTypeDefinitionList() {
+ public Collection<TypeDefinitionContainer> getTypeDefinitionList() {
return Collections.unmodifiableCollection(fTypesMap.values());
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.apache.chemistry.opencmis.inmemory.TypeManager#getRootTypes()
*/
@Override
- public List<TypeDefinitionContainer> getRootTypes() {
+ public List<TypeDefinitionContainer> getRootTypes() {
// just take first repository
List<TypeDefinitionContainer> rootTypes = new ArrayList<TypeDefinitionContainer>();
@@ -103,10 +117,10 @@ public class TypeManagerImpl implements
* Initialize the type system with the given types. This list must not
* contain the CMIS default types. The default type are always contained by
* default.
- *
+ *
* @param typesList
* list of types to add to the repository
- *
+ *
*/
public void initTypeSystem(List<TypeDefinition> typesList, boolean createCmisDefaultTypes) {
@@ -127,17 +141,17 @@ public class TypeManagerImpl implements
/**
* Add a type to the type system. Add all properties from inherited types,
* add type to children of parent types.
- *
+ *
* @param repositoryId
* repository to which the type is added
* @param cmisType
* new type to add
*/
@Override
- public void addTypeDefinition(TypeDefinition cmisType, boolean addInheritedProperties) {
-
- LOG.info("Adding type definition with name " + cmisType.getLocalName() + " and id "
- + cmisType.getId() + " to repository.");
+ public void addTypeDefinition(TypeDefinition cmisType, boolean addInheritedProperties) {
+
+ LOG.info("Adding type definition with name " + cmisType.getLocalName() + " and id " + cmisType.getId()
+ + " to repository.");
TypeDefinitionContainerImpl typeContainer = new TypeDefinitionContainerImpl(cmisType);
if (null != cmisType.getParentTypeId()) {
@@ -146,39 +160,40 @@ public class TypeManagerImpl implements
parentTypeContainer.getChildren().add(typeContainer);
if (addInheritedProperties) {
- // recursively add inherited properties
- Map<String, PropertyDefinition<?>> propDefs = typeContainer.getTypeDefinition().getPropertyDefinitions();
+ // recursively add inherited properties
+ Map<String, PropertyDefinition<?>> propDefs = typeContainer.getTypeDefinition()
+ .getPropertyDefinitions();
addInheritedProperties(propDefs, parentTypeContainer.getTypeDefinition());
}
}
// add type to type map
fTypesMap.put(cmisType.getId(), typeContainer);
}
-
+
@Override
- public void updateTypeDefinition(TypeDefinition typeDefinition) {
+ public void updateTypeDefinition(TypeDefinition typeDefinition) {
throw new CmisNotSupportedException("updating a type definition is not supported.");
}
/**
* Remove a type from a type system
+ *
* @param typeId
*/
@Override
- public void deleteTypeDefinition(String typeId) {
- TypeDefinitionContainer typeDef = fTypesMap.remove(typeId);
+ public void deleteTypeDefinition(String typeId) {
+ TypeDefinitionContainer typeDef = fTypesMap.remove(typeId);
// remove type from children of parent types
TypeDefinitionContainer parentTypeContainer = fTypesMap.get(typeDef.getTypeDefinition().getParentTypeId());
parentTypeContainer.getChildren().remove(typeDef);
- fTypesMap.remove(typeId);
+ fTypesMap.remove(typeId);
}
-
/**
* Remove all types from the type system. After this call only the default
* CMIS types are present in the type system. Use this method with care, its
* mainly intended for unit tests
- *
+ *
* @param repositoryId
*/
public void clearTypeSystem() {
@@ -186,11 +201,16 @@ public class TypeManagerImpl implements
createCmisDefaultTypes();
}
- /* (non-Javadoc)
- * @see org.apache.chemistry.opencmis.inmemory.TypeManager#getPropertyIdForQueryName(org.apache.chemistry.opencmis.commons.definitions.TypeDefinition, java.lang.String)
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.apache.chemistry.opencmis.inmemory.TypeManager#getPropertyIdForQueryName
+ * (org.apache.chemistry.opencmis.commons.definitions.TypeDefinition,
+ * java.lang.String)
*/
@Override
- public String getPropertyIdForQueryName(TypeDefinition typeDefinition, String propQueryName) {
+ public String getPropertyIdForQueryName(TypeDefinition typeDefinition, String propQueryName) {
for (PropertyDefinition<?> pd : typeDefinition.getPropertyDefinitions().values()) {
if (pd.getQueryName().equals(propQueryName)) {
return pd.getId();
@@ -205,8 +225,7 @@ public class TypeManagerImpl implements
return;
}
- if (null != typeDefinition.getPropertyDefinitions())
- {
+ if (null != typeDefinition.getPropertyDefinitions()) {
addInheritedPropertyDefinitions(propDefs, typeDefinition.getPropertyDefinitions());
}
@@ -242,5 +261,5 @@ public class TypeManagerImpl implements
PropertyDefinition<?> clone = TypeUtil.clonePropertyDefinition(src);
return clone;
}
-
+
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/TypeValidator.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/TypeValidator.java?rev=1514619&r1=1514618&r2=1514619&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/TypeValidator.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/TypeValidator.java Fri Aug 16 08:47:50 2013
@@ -57,24 +57,25 @@ import org.apache.chemistry.opencmis.inm
import org.apache.chemistry.opencmis.server.support.TypeManager;
/**
- * A helper class doing some consistency checks when new type definitions are added to the system
+ * A helper class doing some consistency checks when new type definitions are
+ * added to the system
*
* @author Jens
- *
+ *
*/
-public class TypeValidator {
-
+public final class TypeValidator {
+
private static final Object CMIS_USER = "cmis:user";
- private TypeValidator() {
- }
-
+ private TypeValidator() {
+ }
+
public static void checkType(TypeManager tm, TypeDefinition td) {
- if(null == td) {
- throw new CmisInvalidArgumentException("Cannot add type, because the type defintion is null.");
- }
-
+ if (null == td) {
+ throw new CmisInvalidArgumentException("Cannot add type, because the type defintion is null.");
+ }
+
if (null == tm.getTypeById(td.getParentTypeId())) {
throw new CmisInvalidArgumentException("Cannot add type, because parent with id " + td.getParentTypeId()
+ " does not exist.");
@@ -89,19 +90,19 @@ public class TypeValidator {
checkTypeQueryName(tm, td.getQueryName());
checkTypeLocalName(tm, td.getLocalName());
checkBaseAndParentType(td);
-
+
if (null != td.getPropertyDefinitions()) {
TypeValidator.checkProperties(tm, td.getPropertyDefinitions().values());
- }
+ }
}
-
+
public static AbstractTypeDefinition completeType(TypeDefinition type) {
if (type instanceof DocumentTypeDefinition) {
return completeTypeDoc((DocumentTypeDefinition) type);
} else if (type instanceof FolderTypeDefinition) {
return completeTypeFolder((FolderTypeDefinition) type);
} else if (type instanceof PolicyTypeDefinition) {
- return completeTypePolicy((PolicyTypeDefinition)type);
+ return completeTypePolicy((PolicyTypeDefinition) type);
} else if (type instanceof ItemTypeDefinition) {
return completeTypeItem((ItemTypeDefinition) type);
} else if (type instanceof RelationshipTypeDefinition) {
@@ -110,7 +111,7 @@ public class TypeValidator {
return completeTypeSecondary((SecondaryTypeDefinition) type);
} else {
return null;
- }
+ }
}
public static void adjustTypeNamesAndId(AbstractTypeDefinition typeDef) {
@@ -156,7 +157,7 @@ public class TypeValidator {
tm.setCanUpdate(true);
td.setTypeMutability(tm);
td.setExtensions(td.getExtensions());
-
+
Map<String, PropertyDefinition<?>> propDefsNew = new LinkedHashMap<String, PropertyDefinition<?>>();
if (null != td.getPropertyDefinitions()) {
Map<String, PropertyDefinition<?>> propDefs = td.getPropertyDefinitions();
@@ -180,7 +181,7 @@ public class TypeValidator {
if (!NameValidator.isValidId(pd2.getId())) {
throw new CmisInvalidArgumentException(NameValidator.ERROR_ILLEGAL_NAME);
}
-
+
// check query name syntax
if (null == pd2.getQueryName()) {
throw new CmisInvalidArgumentException("property query name cannot be null.");
@@ -188,7 +189,7 @@ public class TypeValidator {
if (!NameValidator.isValidQueryName(pd2.getQueryName())) {
throw new CmisInvalidArgumentException(NameValidator.ERROR_ILLEGAL_NAME);
}
-
+
// check local name syntax
if (null == pd2.getLocalName()) {
throw new CmisInvalidArgumentException("property local name cannot be null.");
@@ -196,7 +197,7 @@ public class TypeValidator {
if (!NameValidator.isValidLocalName(pd2.getLocalName())) {
throw new CmisInvalidArgumentException(NameValidator.ERROR_ILLEGAL_NAME);
}
-
+
for (TypeDefinitionContainer tdc : tdl) {
TypeDefinition td = tdc.getTypeDefinition();
if (null != td.getPropertyDefinitions()) {
@@ -208,20 +209,20 @@ public class TypeValidator {
}
// check if query name is used
if (pd1.getQueryName().equals(pd2.getQueryName())) {
- throw new CmisConstraintException("Property query name " + pd2.getQueryName() + " already in use in type "
- + td.getQueryName());
+ throw new CmisConstraintException("Property query name " + pd2.getQueryName()
+ + " already in use in type " + td.getQueryName());
}
// check if local name is used
if (pd1.getLocalName().equals(pd2.getLocalName())) {
- throw new CmisConstraintException("Property local name " + pd2.getLocalName() + " already in use in type "
- + td.getId());
+ throw new CmisConstraintException("Property local name " + pd2.getLocalName()
+ + " already in use in type " + td.getId());
}
}
}
}
- }
+ }
}
-
+
private static void adjustPropertyNamesAndId(AbstractPropertyDefinition<?> propDef) {
if (null == propDef.getId()) {
propDef.setId(UUID.randomUUID().toString());
@@ -242,8 +243,8 @@ public class TypeValidator {
private static String replaceInvalidCharacters(String id) {
// if there are illegal characters adjust them
StringBuffer sb = new StringBuffer();
- for (int i = 0; i<id.length(); i++) {
- if (NameValidator.isValidId(id.substring(i, i+1))) {
+ for (int i = 0; i < id.length(); i++) {
+ if (NameValidator.isValidId(id.substring(i, i + 1))) {
sb.append(id.charAt(i));
} else {
sb.append('_');
@@ -284,13 +285,13 @@ public class TypeValidator {
ItemTypeDefinitionImpl td = TypeUtil.cloneTypeItem(type);
td.initialize(type);
completeAbstractTypeDefinition(td);
- return td;
+ return td;
}
private static SecondaryTypeDefinitionImpl completeTypeSecondary(SecondaryTypeDefinition type) {
SecondaryTypeDefinitionImpl td = TypeUtil.cloneTypeSecondary(type);
completeAbstractTypeDefinition(td);
- return td;
+ return td;
}
private static PolicyTypeDefinitionImpl completeTypePolicy(PolicyTypeDefinition type) {
@@ -299,11 +300,12 @@ public class TypeValidator {
return null;
}
- // When creating types PropertyDefinitions may only be partially filled, fill all fields
+ // When creating types PropertyDefinitions may only be partially filled,
+ // fill all fields
// to make a complete definition
private static AbstractPropertyDefinition<?> completePropertyDef(PropertyDefinition<?> pdSrc) {
AbstractPropertyDefinition<?> newPropDef = TypeUtil.clonePropertyDefinition(pdSrc);
-
+
if (null == newPropDef.getPropertyType()) {
throw new CmisInvalidArgumentException("Property " + pdSrc.getId() + "has no property type.");
}
@@ -337,41 +339,41 @@ public class TypeValidator {
}
public static Acl expandAclMakros(String user, Acl acl) {
- boolean mustCopy = false;
-
- if (user == null || acl == null || acl.getAces() == null) {
+ boolean mustCopy = false;
+
+ if (user == null || acl == null || acl.getAces() == null) {
return acl;
}
-
- for (Ace ace: acl.getAces()) {
- String principal = ace.getPrincipalId();
- if (principal != null && principal.equals(CMIS_USER)) {
- mustCopy = true;
- }
- }
-
- if (mustCopy) {
- AccessControlListImpl result = new AccessControlListImpl();
- List<Ace> list = new ArrayList<Ace>(acl.getAces().size());
- for (Ace ace: acl.getAces()) {
- String principal = ace.getPrincipalId();
- if (principal != null && principal.equals(CMIS_USER)) {
- AccessControlEntryImpl ace2 = new AccessControlEntryImpl();
- ace2.setPermissions(ace.getPermissions());
- ace2.setExtensions(ace.getExtensions());
- ace2.setPrincipal(new AccessControlPrincipalDataImpl(user));
- list.add(ace2);
- } else {
+
+ for (Ace ace : acl.getAces()) {
+ String principal = ace.getPrincipalId();
+ if (principal != null && principal.equals(CMIS_USER)) {
+ mustCopy = true;
+ }
+ }
+
+ if (mustCopy) {
+ AccessControlListImpl result = new AccessControlListImpl();
+ List<Ace> list = new ArrayList<Ace>(acl.getAces().size());
+ for (Ace ace : acl.getAces()) {
+ String principal = ace.getPrincipalId();
+ if (principal != null && principal.equals(CMIS_USER)) {
+ AccessControlEntryImpl ace2 = new AccessControlEntryImpl();
+ ace2.setPermissions(ace.getPermissions());
+ ace2.setExtensions(ace.getExtensions());
+ ace2.setPrincipal(new AccessControlPrincipalDataImpl(user));
+ list.add(ace2);
+ } else {
list.add(ace);
- }
- }
- result.setAces(list);
- return result;
- } else {
+ }
+ }
+ result.setAces(list);
+ return result;
+ } else {
return acl;
}
}
-
+
private static void checkTypeId(TypeManager tm, String typeId) {
if (null == typeId) {
@@ -385,10 +387,10 @@ public class TypeValidator {
if (null != tm.getTypeById(typeId)) {
throw new CmisInvalidArgumentException("You cannot add type with id " + typeId
- + " because it already exists.");
+ + " because it already exists.");
}
}
-
+
private static void checkTypeQueryName(TypeManager tm, String queryName) {
if (null == queryName) {
@@ -398,16 +400,16 @@ public class TypeValidator {
if (!NameValidator.isValidQueryName(queryName)) {
throw new CmisInvalidArgumentException(NameValidator.ERROR_ILLEGAL_NAME);
}
-
+
// check set query name is unique in the type system
if (null != tm.getTypeByQueryName(queryName)) {
throw new CmisInvalidArgumentException("You cannot add type with query name " + queryName
- + " because it already exists.");
+ + " because it already exists.");
}
}
-
+
private static void checkTypeLocalName(TypeManager tm, String localName) {
-
+
if (null == localName) {
throw new CmisInvalidArgumentException("Local name cannot be null.");
}
@@ -415,12 +417,12 @@ public class TypeValidator {
if (!NameValidator.isValidLocalName(localName)) {
throw new CmisInvalidArgumentException(NameValidator.ERROR_ILLEGAL_NAME);
}
-
+
for (TypeDefinitionContainer tdc : tm.getTypeDefinitionList()) {
if (tdc.getTypeDefinition().getLocalName().equals(localName)) {
throw new CmisConstraintException("You cannot add type with local name " + localName
+ " because it already exists.");
- }
+ }
}
}
@@ -431,7 +433,7 @@ public class TypeValidator {
if (null == td.getParentTypeId()) {
throw new CmisInvalidArgumentException("You cannot create a type without a parent type id: " + td.getId());
}
-
+
}
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/query/InMemoryQueryProcessor.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/query/InMemoryQueryProcessor.java?rev=1514619&r1=1514618&r2=1514619&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/query/InMemoryQueryProcessor.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/query/InMemoryQueryProcessor.java Fri Aug 16 08:47:50 2013
@@ -22,6 +22,7 @@
*/
package org.apache.chemistry.opencmis.inmemory.query;
+import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
@@ -42,6 +43,7 @@ import org.apache.chemistry.opencmis.com
import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
import org.apache.chemistry.opencmis.commons.enums.PropertyType;
import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectListImpl;
import org.apache.chemistry.opencmis.inmemory.storedobj.api.Content;
import org.apache.chemistry.opencmis.inmemory.storedobj.api.DocumentVersion;
@@ -82,7 +84,7 @@ public class InMemoryQueryProcessor {
private Tree whereTree;
private ObjectStoreImpl objStore;
private List<TypeDefinition> secondaryTypeIds;
-
+
public InMemoryQueryProcessor(ObjectStoreImpl objStore) {
this.objStore = objStore;
}
@@ -94,7 +96,7 @@ public class InMemoryQueryProcessor {
String statement, Boolean searchAllVersions, Boolean includeAllowableActions,
IncludeRelationships includeRelationships, String renditionFilter, BigInteger maxItems, BigInteger skipCount) {
- processQueryAndCatchExc(statement, tm ); // calls query processor
+ processQueryAndCatchExc(statement, tm); // calls query processor
// iterate over all the objects and check for each if the query matches
for (String objectId : ((ObjectStoreImpl) objectStore).getIds()) {
@@ -146,12 +148,11 @@ public class InMemoryQueryProcessor {
if (start > 0 || stop > 0) {
matches = matches.subList(start, stop);
}
-
-
+
List<ObjectData> objDataList = new ArrayList<ObjectData>();
Map<String, String> props = queryObj.getRequestedPropertiesByAlias();
Map<String, String> funcs = queryObj.getRequestedFuncsByAlias();
-
+
for (StoredObject so : matches) {
String queryName = queryObj.getTypes().values().iterator().next();
TypeDefinition td = queryObj.getTypeDefinitionFromQueryName(queryName);
@@ -172,10 +173,10 @@ public class InMemoryQueryProcessor {
}
// check secondary types
List<String> secTypeIds = so.getSecondaryTypeIds();
- for (String secTypeId: secTypeIds) {
+ for (String secTypeId : secTypeIds) {
if (secTypeId.equals(td.getId())) {
return true;
- }
+ }
}
// check parent type
TypeDefinition parentTD = queryObj.getParentType(typeId);
@@ -192,7 +193,7 @@ public class InMemoryQueryProcessor {
class ResultComparator implements Comparator<StoredObject> {
@Override
- @SuppressWarnings("unchecked")
+ @SuppressWarnings("unchecked")
public int compare(StoredObject so1, StoredObject so2) {
SortSpec s = orderBy.get(0);
CmisSelector sel = s.getSelector();
@@ -204,7 +205,7 @@ public class InMemoryQueryProcessor {
} else if (sel instanceof ColumnReference) {
String propId = ((ColumnReference) sel).getPropertyId();
PropertyDefinition<?> pd = ((ColumnReference) sel).getPropertyDefinition();
-
+
Object propVal1 = PropertyQueryUtil.getProperty(so1, propId, pd);
Object propVal2 = PropertyQueryUtil.getProperty(so2, propId, pd);
@@ -238,19 +239,19 @@ public class InMemoryQueryProcessor {
* Check for each object contained in the in-memory repository if it matches
* the current query expression. If yes add it to the list of matched
* objects.
- *
+ *
* @param so
* object stored in the in-memory repository
*/
private void match(StoredObject so, String user, boolean searchAllVersions) {
// first check if type is matching...
// as we don't support joins take first type
- String queryName = queryObj.getTypes().values().iterator().next();
+ String queryName = queryObj.getTypes().values().iterator().next();
TypeDefinition td = queryObj.getTypeDefinitionFromQueryName(queryName);
-
+
// we are only interested in versions not in the series
- boolean skip = so instanceof VersionedDocument;
+ boolean skip = so instanceof VersionedDocument;
boolean typeMatches = typeMatches(td, so);
if (!searchAllVersions && so instanceof DocumentVersion
@@ -268,8 +269,7 @@ public class InMemoryQueryProcessor {
if (null != node) {
match = evalWhereNode(so, user, node);
}
- if (match && objStore.hasReadAccess(user, so))
- {
+ if (match && objStore.hasReadAccess(user, so)) {
matches.add(so); // add to list
}
}
@@ -278,7 +278,7 @@ public class InMemoryQueryProcessor {
* For each object check if it matches and append it to match-list if it
* does. We do here our own walking mechanism so that we can pass additional
* parameters and define the return types.
- *
+ *
* @param node
* node in where clause
* @return true if it matches, false if it not matches
@@ -485,15 +485,15 @@ public class InMemoryQueryProcessor {
}
String propVal = (String) PropertyQueryUtil.getProperty(so, colRef.getPropertyId(), pd);
-
+
if (null == propVal) {
- return false;
+ return false;
} else {
- String pattern = translatePattern((String) rVal); // SQL to Java
- // regex
- // syntax
- Pattern p = Pattern.compile(pattern);
- return p.matcher(propVal).matches();
+ String pattern = translatePattern((String) rVal); // SQL to Java
+ // regex
+ // syntax
+ Pattern p = Pattern.compile(pattern);
+ return p.matcher(propVal).matches();
}
}
@@ -550,10 +550,11 @@ public class InMemoryQueryProcessor {
ColumnReference colRef = getColumnReference(leftChild);
PropertyDefinition<?> pd = colRef.getPropertyDefinition();
Object val = PropertyQueryUtil.getProperty(so, colRef.getPropertyId(), pd);
- if (val==null) {
+ if (val == null) {
return null;
} else if (val instanceof List<?>) {
- throw new IllegalStateException("You can't query operators <, <=, ==, !=, >=, > on multi-value properties ");
+ throw new IllegalStateException(
+ "You can't query operators <, <=, ==, !=, >=, > on multi-value properties ");
} else {
return InMemoryQueryProcessor.this.compareTo(pd, val, rVal);
}
@@ -563,79 +564,84 @@ public class InMemoryQueryProcessor {
public List<Object> onLiteralList(Tree node) {
return (List<Object>) walkExpr(node);
}
-
+
@Override
protected Boolean walkTextAnd(Tree node) {
List<Tree> terms = getChildrenAsList(node);
- for (Tree term: terms) {
+ for (Tree term : terms) {
Boolean foundOnce = walkSearchExpr(term);
- if (foundOnce== null || !foundOnce) {
+ if (foundOnce == null || !foundOnce) {
return false;
}
}
return true;
}
-
+
@Override
protected Boolean walkTextOr(Tree node) {
List<Tree> terms = getChildrenAsList(node);
- for (Tree term: terms) {
+ for (Tree term : terms) {
Boolean foundOnce = walkSearchExpr(term);
- if (foundOnce!= null && foundOnce) {
+ if (foundOnce != null && foundOnce) {
return true;
}
}
return false;
}
-
+
@Override
protected Boolean walkTextMinus(Tree node) {
return !findText(node.getChild(0).getText());
}
-
+
@Override
protected Boolean walkTextWord(Tree node) {
return findText(node.getText());
}
-
+
@Override
protected Boolean walkTextPhrase(Tree node) {
String phrase = node.getText();
- return findText(phrase.substring(1, phrase.length()-1));
+ return findText(phrase.substring(1, phrase.length() - 1));
}
-
+
private List<Tree> getChildrenAsList(Tree node) {
List<Tree> res = new ArrayList<Tree>(node.getChildCount());
- for (int i=0; i<node.getChildCount(); i++) {
- Tree childNnode = node.getChild(i);
+ for (int i = 0; i < node.getChildCount(); i++) {
+ Tree childNnode = node.getChild(i);
res.add(childNnode);
}
return res;
}
-
+
private boolean findText(String nodeText) {
- Content cont = (Content)so;
+ Content cont = (Content) so;
String pattern = StringUtil.unescape(nodeText, "\\'-");
if (null == pattern) {
throw new CmisInvalidArgumentException("Illegal Escape sequence in text search expression " + nodeText);
}
-
+
if (so instanceof Content && cont.hasContent()) {
ContentStreamDataImpl cdi = (ContentStreamDataImpl) cont.getContent(0, -1);
if (cdi.getMimeType().startsWith("text/")) {
- byte[] ba = cdi.getBytes();
- String text = new String(ba);
- int match = text.indexOf(pattern);
- return match >= 0;
+ byte[] ba = cdi.getBytes();
+ String text;
+ try {
+ text = new String(ba, "UTF-8");
+ } catch (UnsupportedEncodingException e) {
+ throw new CmisRuntimeException("Internal error: Unsupported encoding UTF-8", e);
+ }
+ int match = text.indexOf(pattern);
+ return match >= 0;
} else {
return false;
}
}
return false;
}
-
+
}
-
+
private boolean hasParent(Filing objInFolder, String folderId, String user) {
List<String> parents = objStore.getParentIds(objInFolder, user);
@@ -696,7 +702,7 @@ public class InMemoryQueryProcessor {
if (rVal instanceof Double) {
return lDoubleValue.compareTo((Double) rVal);
} else if (rVal instanceof Long) {
- return lDoubleValue.compareTo(Double.valueOf( ((Long)rVal)) );
+ return lDoubleValue.compareTo(Double.valueOf(((Long) rVal)));
} else {
throwIncompatibleTypesException(lValue, rVal);
}
@@ -743,11 +749,13 @@ public class InMemoryQueryProcessor {
}
List<JoinSpec> joins = queryObj.getJoins();
if (null == secondaryTypeIds && joins.size() > 0) {
- throw new CmisInvalidArgumentException("JOINs are not supported with the exception of secondary types and a LEFT OUTER JOIN");
+ throw new CmisInvalidArgumentException(
+ "JOINs are not supported with the exception of secondary types and a LEFT OUTER JOIN");
} else if (null != secondaryTypeIds) {
for (JoinSpec join : joins) {
if (!join.kind.equals("LEFT")) {
- throw new CmisInvalidArgumentException("JOINs are not supported with the exception of secondary types and a LEFT OUTER JOIN");
+ throw new CmisInvalidArgumentException(
+ "JOINs are not supported with the exception of secondary types and a LEFT OUTER JOIN");
}
}
}
@@ -757,35 +765,37 @@ public class InMemoryQueryProcessor {
public static String translatePattern(String wildcardString) {
int index = 0;
int start = 0;
+ String wildcard = wildcardString;
+
StringBuffer res = new StringBuffer();
while (index >= 0) {
- index = wildcardString.indexOf('%', start);
+ index = wildcard.indexOf('%', start);
if (index < 0) {
- res.append(wildcardString.substring(start));
- } else if (index == 0 || index > 0 && wildcardString.charAt(index - 1) != '\\') {
- res.append(wildcardString.substring(start, index));
+ res.append(wildcard.substring(start));
+ } else if (index == 0 || index > 0 && wildcard.charAt(index - 1) != '\\') {
+ res.append(wildcard.substring(start, index));
res.append(".*");
} else {
- res.append(wildcardString.substring(start, index + 1));
+ res.append(wildcard.substring(start, index + 1));
}
start = index + 1;
}
- wildcardString = res.toString();
+ wildcard = res.toString();
index = 0;
start = 0;
res = new StringBuffer();
while (index >= 0) {
- index = wildcardString.indexOf('_', start);
+ index = wildcard.indexOf('_', start);
if (index < 0) {
- res.append(wildcardString.substring(start));
- } else if (index == 0 || index > 0 && wildcardString.charAt(index - 1) != '\\') {
- res.append(wildcardString.substring(start, index));
+ res.append(wildcard.substring(start));
+ } else if (index == 0 || index > 0 && wildcard.charAt(index - 1) != '\\') {
+ res.append(wildcard.substring(start, index));
res.append(".");
} else {
- res.append(wildcardString.substring(start, index + 1));
+ res.append(wildcard.substring(start, index + 1));
}
start = index + 1;
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/query/PropertyQueryUtil.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/query/PropertyQueryUtil.java?rev=1514619&r1=1514618&r2=1514619&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/query/PropertyQueryUtil.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/query/PropertyQueryUtil.java Fri Aug 16 08:47:50 2013
@@ -34,11 +34,11 @@ import org.apache.chemistry.opencmis.inm
import org.apache.chemistry.opencmis.inmemory.storedobj.api.StoredObject;
import org.apache.chemistry.opencmis.inmemory.storedobj.api.VersionedDocument;
-public class PropertyQueryUtil {
-
- private PropertyQueryUtil() {
+public final class PropertyQueryUtil {
+
+ private PropertyQueryUtil() {
}
-
+
public static Object getProperty(StoredObject so, String propertyId, PropertyDefinition<?> pd) {
ContentStream content = null;
DocumentVersion ver = null;
@@ -47,7 +47,7 @@ public class PropertyQueryUtil {
Document doc = null;
Relationship rel = null;
Policy pol = null;
-
+
boolean cmis11 = InMemoryServiceContext.getCallContext().getCmisVersion() != CmisVersion.CMIS_1_0;
if (so instanceof Content) {
@@ -154,18 +154,12 @@ public class PropertyQueryUtil {
}
}
- if (folder != null) {
- // not supported: ALLOWED_CHILD_OBJECT_TYPE_IDS
- // not supported: PATH
- if (propertyId.equals(PropertyIds.PARENT_ID)) {
- return folder.getParentId();
- }
+ if (folder != null && propertyId.equals(PropertyIds.PARENT_ID)) {
+ return folder.getParentId();
}
- if (doc != null) {
- if (propertyId.equals(PropertyIds.IS_IMMUTABLE)) {
- return false;
- }
+ if (doc != null && propertyId.equals(PropertyIds.IS_IMMUTABLE)) {
+ return false;
}
if (rel != null) {
@@ -176,22 +170,20 @@ public class PropertyQueryUtil {
return rel.getTargetObjectId();
}
}
-
- if (pol != null) {
- if (propertyId.equals(PropertyIds.POLICY_TEXT)) {
- return pol.getPolicyText();
- }
- }
-
- // try custom property:
- PropertyData<?> lVal = so.getProperties().get(propertyId);
- if (null == lVal) {
- return null;
- } else if (pd.getCardinality() == Cardinality.SINGLE) {
- return lVal.getFirstValue();
- } else {
- return lVal.getValues();
- }
+
+ if (pol != null && propertyId.equals(PropertyIds.POLICY_TEXT)) {
+ return pol.getPolicyText();
+ }
+
+ // try custom property:
+ PropertyData<?> lVal = so.getProperties().get(propertyId);
+ if (null == lVal) {
+ return null;
+ } else if (pd.getCardinality() == Cardinality.SINGLE) {
+ return lVal.getFirstValue();
+ } else {
+ return lVal.getValues();
+ }
}
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/BaseServiceValidatorImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/BaseServiceValidatorImpl.java?rev=1514619&r1=1514618&r2=1514619&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/BaseServiceValidatorImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/BaseServiceValidatorImpl.java Fri Aug 16 08:47:50 2013
@@ -171,7 +171,7 @@ public class BaseServiceValidatorImpl im
so[1] = checkExistingObjectId(objectStore, objectId2);
return so;
}
-
+
protected void checkPolicies(String repositoryId, List<String> policyIds) {
if (policyIds != null && policyIds.size() > 0) {
for (String policyId : policyIds) {
@@ -180,76 +180,76 @@ public class BaseServiceValidatorImpl im
throw new CmisInvalidArgumentException("Unknown policy type: " + policyId);
}
if (tdc.getTypeDefinition().getBaseTypeId() != BaseTypeId.CMIS_POLICY) {
- throw new CmisInvalidArgumentException( policyId + " is not a policy type");
+ throw new CmisInvalidArgumentException(policyId + " is not a policy type");
}
}
}
}
@Override
- public void getRepositoryInfos(CallContext context, ExtensionsData extension) {
+ public void getRepositoryInfos(CallContext context, ExtensionsData extension) {
}
@Override
- public void getRepositoryInfo(CallContext context, String repositoryId, ExtensionsData extension) {
+ public void getRepositoryInfo(CallContext context, String repositoryId, ExtensionsData extension) {
checkRepositoryId(repositoryId);
}
@Override
- public void getTypeChildren(CallContext context, String repositoryId, String typeId, ExtensionsData extension) {
+ public void getTypeChildren(CallContext context, String repositoryId, String typeId, ExtensionsData extension) {
checkRepositoryId(repositoryId);
}
@Override
- public void getTypeDescendants(CallContext context, String repositoryId, String typeId, ExtensionsData extension) {
+ public void getTypeDescendants(CallContext context, String repositoryId, String typeId, ExtensionsData extension) {
checkRepositoryId(repositoryId);
}
@Override
- public void getTypeDefinition(CallContext context, String repositoryId, String typeId, ExtensionsData extension) {
+ public void getTypeDefinition(CallContext context, String repositoryId, String typeId, ExtensionsData extension) {
checkRepositoryId(repositoryId);
}
@Override
- public StoredObject getChildren(CallContext context, String repositoryId, String folderId, ExtensionsData extension) {
+ public StoredObject getChildren(CallContext context, String repositoryId, String folderId, ExtensionsData extension) {
return checkStandardParameters(repositoryId, folderId);
}
@Override
- public StoredObject getDescendants(CallContext context, String repositoryId, String folderId,
+ public StoredObject getDescendants(CallContext context, String repositoryId, String folderId,
ExtensionsData extension) {
return checkStandardParameters(repositoryId, folderId);
}
@Override
- public StoredObject getFolderTree(CallContext context, String repositoryId, String folderId,
+ public StoredObject getFolderTree(CallContext context, String repositoryId, String folderId,
ExtensionsData extension) {
return checkStandardParameters(repositoryId, folderId);
}
@Override
- public StoredObject getObjectParents(CallContext context, String repositoryId, String objectId,
+ public StoredObject getObjectParents(CallContext context, String repositoryId, String objectId,
ExtensionsData extension) {
return checkStandardParameters(repositoryId, objectId);
}
@Override
- public StoredObject getFolderParent(CallContext context, String repositoryId, String folderId,
+ public StoredObject getFolderParent(CallContext context, String repositoryId, String folderId,
ExtensionsData extension) {
return checkStandardParameters(repositoryId, folderId);
}
@Override
- public StoredObject getCheckedOutDocs(CallContext context, String repositoryId, String folderId,
+ public StoredObject getCheckedOutDocs(CallContext context, String repositoryId, String folderId,
ExtensionsData extension) {
if (null != folderId) {
@@ -262,26 +262,26 @@ public class BaseServiceValidatorImpl im
}
@Override
- public StoredObject createDocument(CallContext context, String repositoryId, String folderId,
+ public StoredObject createDocument(CallContext context, String repositoryId, String folderId,
List<String> policyIds, ExtensionsData extension) {
return checkStandardParametersAllowNull(repositoryId, folderId);
}
@Override
- public StoredObject createDocumentFromSource(CallContext context, String repositoryId, String sourceId,
+ public StoredObject createDocumentFromSource(CallContext context, String repositoryId, String sourceId,
String folderId, List<String> policyIds, ExtensionsData extension) {
return checkStandardParametersAllowNull(repositoryId, sourceId);
}
@Override
- public StoredObject createFolder(CallContext context, String repositoryId, String folderId, List<String> policyIds,
+ public StoredObject createFolder(CallContext context, String repositoryId, String folderId, List<String> policyIds,
ExtensionsData extension) {
return checkStandardParameters(repositoryId, folderId);
}
@Override
- public StoredObject[] createRelationship(CallContext context, String repositoryId, String sourceId,
+ public StoredObject[] createRelationship(CallContext context, String repositoryId, String sourceId,
String targetId, List<String> policyIds, ExtensionsData extension) {
checkRepositoryId(repositoryId);
checkStandardParametersAllowNull(repositoryId, null);
@@ -289,69 +289,69 @@ public class BaseServiceValidatorImpl im
}
@Override
- public StoredObject createPolicy(CallContext context, String repositoryId, String folderId, Acl addAces,
+ public StoredObject createPolicy(CallContext context, String repositoryId, String folderId, Acl addAces,
Acl removeAces, List<String> policyIds, ExtensionsData extension) {
- return checkStandardParametersAllowNull(repositoryId, null);
+ return checkStandardParametersAllowNull(repositoryId, folderId);
}
// CMIS 1.1
@Override
- public StoredObject createItem(CallContext context, String repositoryId, Properties properties, String folderId,
+ public StoredObject createItem(CallContext context, String repositoryId, Properties properties, String folderId,
List<String> policies, Acl addAces, Acl removeAces, ExtensionsData extension) {
return checkStandardParametersAllowNull(repositoryId, folderId);
}
@Override
- public StoredObject getAllowableActions(CallContext context, String repositoryId, String objectId,
+ public StoredObject getAllowableActions(CallContext context, String repositoryId, String objectId,
ExtensionsData extension) {
//
return checkStandardParameters(repositoryId, objectId);
}
@Override
- public StoredObject getObject(CallContext context, String repositoryId, String objectId, ExtensionsData extension) {
+ public StoredObject getObject(CallContext context, String repositoryId, String objectId, ExtensionsData extension) {
StoredObject so = checkStandardParameters(repositoryId, objectId);
return so;
}
@Override
- public StoredObject getProperties(CallContext context, String repositoryId, String objectId,
+ public StoredObject getProperties(CallContext context, String repositoryId, String objectId,
ExtensionsData extension) {
return checkStandardParameters(repositoryId, objectId);
}
@Override
- public StoredObject getRenditions(CallContext context, String repositoryId, String objectId,
+ public StoredObject getRenditions(CallContext context, String repositoryId, String objectId,
ExtensionsData extension) {
return checkStandardParameters(repositoryId, objectId);
}
@Override
- public StoredObject getObjectByPath(CallContext context, String repositoryId, String path, ExtensionsData extension) {
+ public StoredObject getObjectByPath(CallContext context, String repositoryId, String path, ExtensionsData extension) {
return checkStandardParametersByPath(repositoryId, path, context.getUsername());
}
@Override
- public StoredObject getContentStream(CallContext context, String repositoryId, String objectId, String streamId,
+ public StoredObject getContentStream(CallContext context, String repositoryId, String objectId, String streamId,
ExtensionsData extension) {
return checkStandardParameters(repositoryId, objectId);
}
@Override
- public StoredObject updateProperties(CallContext context, String repositoryId, Holder<String> objectId,
+ public StoredObject updateProperties(CallContext context, String repositoryId, Holder<String> objectId,
ExtensionsData extension) {
return checkStandardParameters(repositoryId, objectId.getValue());
}
@Override
- public StoredObject[] moveObject(CallContext context, String repositoryId, Holder<String> objectId,
+ public StoredObject[] moveObject(CallContext context, String repositoryId, Holder<String> objectId,
String targetFolderId, String sourceFolderId, ExtensionsData extension) {
StoredObject[] res = new StoredObject[3];
@@ -362,117 +362,114 @@ public class BaseServiceValidatorImpl im
}
@Override
- public StoredObject deleteObject(CallContext context, String repositoryId, String objectId, Boolean allVersions,
+ public StoredObject deleteObject(CallContext context, String repositoryId, String objectId, Boolean allVersions,
ExtensionsData extension) {
return checkStandardParameters(repositoryId, objectId);
}
@Override
- public StoredObject deleteTree(CallContext context, String repositoryId, String folderId, Boolean allVersions,
+ public StoredObject deleteTree(CallContext context, String repositoryId, String folderId, Boolean allVersions,
UnfileObject unfileObjects, ExtensionsData extension) {
return checkStandardParameters(repositoryId, folderId);
}
@Override
- public StoredObject setContentStream(CallContext context, String repositoryId, Holder<String> objectId,
+ public StoredObject setContentStream(CallContext context, String repositoryId, Holder<String> objectId,
Boolean overwriteFlag, ExtensionsData extension) {
return checkStandardParameters(repositoryId, objectId.getValue());
}
@Override
- public StoredObject appendContentStream(CallContext context, String repositoryId, Holder<String> objectId,
+ public StoredObject appendContentStream(CallContext context, String repositoryId, Holder<String> objectId,
ExtensionsData extension) {
return checkStandardParameters(repositoryId, objectId.getValue());
}
@Override
- public StoredObject deleteContentStream(CallContext context, String repositoryId, Holder<String> objectId,
+ public StoredObject deleteContentStream(CallContext context, String repositoryId, Holder<String> objectId,
ExtensionsData extension) {
return checkStandardParameters(repositoryId, objectId.getValue());
}
@Override
- public StoredObject checkOut(CallContext context, String repositoryId, Holder<String> objectId,
+ public StoredObject checkOut(CallContext context, String repositoryId, Holder<String> objectId,
ExtensionsData extension, Holder<Boolean> contentCopied) {
return checkStandardParameters(repositoryId, objectId.getValue());
}
@Override
- public StoredObject cancelCheckOut(CallContext context, String repositoryId, String objectId,
+ public StoredObject cancelCheckOut(CallContext context, String repositoryId, String objectId,
ExtensionsData extension) {
return checkStandardParameters(repositoryId, objectId);
}
@Override
- public StoredObject checkIn(CallContext context, String repositoryId, Holder<String> objectId, Acl addAces,
+ public StoredObject checkIn(CallContext context, String repositoryId, Holder<String> objectId, Acl addAces,
Acl removeAces, List<String> policyIds, ExtensionsData extension) {
return checkStandardParameters(repositoryId, objectId.getValue());
}
@Override
- public StoredObject getObjectOfLatestVersion(CallContext context, String repositoryId, String objectId,
+ public StoredObject getObjectOfLatestVersion(CallContext context, String repositoryId, String objectId,
String versionSeriesId, ExtensionsData extension) {
return checkStandardParameters(repositoryId, versionSeriesId == null ? objectId : versionSeriesId);
}
@Override
- public StoredObject getPropertiesOfLatestVersion(CallContext context, String repositoryId, String objectId,
+ public StoredObject getPropertiesOfLatestVersion(CallContext context, String repositoryId, String objectId,
String versionSeriesId, ExtensionsData extension) {
return checkStandardParameters(repositoryId, versionSeriesId == null ? objectId : versionSeriesId);
}
@Override
- public StoredObject getAllVersions(CallContext context, String repositoryId, String objectId,
+ public StoredObject getAllVersions(CallContext context, String repositoryId, String objectId,
String versionSeriesId, ExtensionsData extension) {
return checkStandardParameters(repositoryId, versionSeriesId == null ? objectId : versionSeriesId);
}
@Override
- public void query(CallContext context, String repositoryId, ExtensionsData extension) {
+ public void query(CallContext context, String repositoryId, ExtensionsData extension) {
checkRepositoryId(repositoryId);
}
@Override
- public void getContentChanges(CallContext context, String repositoryId, ExtensionsData extension) {
+ public void getContentChanges(CallContext context, String repositoryId, ExtensionsData extension) {
checkRepositoryId(repositoryId);
}
@Override
- public StoredObject[] addObjectToFolder(CallContext context, String repositoryId, String objectId, String folderId,
+ public StoredObject[] addObjectToFolder(CallContext context, String repositoryId, String objectId, String folderId,
Boolean allVersions, ExtensionsData extension) {
return checkParams(repositoryId, objectId, folderId);
}
@Override
- public StoredObject[] removeObjectFromFolder(CallContext context, String repositoryId, String objectId,
+ public StoredObject[] removeObjectFromFolder(CallContext context, String repositoryId, String objectId,
String folderId, ExtensionsData extension) {
- if (folderId != null)
- {
+ if (folderId != null) {
return checkParams(repositoryId, objectId, folderId);
- }
- else
- {
+ } else {
StoredObject[] so = new StoredObject[1];
checkRepositoryId(repositoryId);
ObjectStore objectStore = fStoreManager.getObjectStore(repositoryId);
so[0] = checkExistingObjectId(objectStore, objectId);
return so;
- }
+ }
}
@Override
- public StoredObject getObjectRelationships(CallContext context, String repositoryId, String objectId,
+ public StoredObject getObjectRelationships(CallContext context, String repositoryId, String objectId,
RelationshipDirection relationshipDirection, String typeId, ExtensionsData extension) {
StoredObject so = checkStandardParameters(repositoryId, objectId);
@@ -496,27 +493,27 @@ public class BaseServiceValidatorImpl im
}
@Override
- public StoredObject getAcl(CallContext context, String repositoryId, String objectId, ExtensionsData extension) {
+ public StoredObject getAcl(CallContext context, String repositoryId, String objectId, ExtensionsData extension) {
return checkStandardParameters(repositoryId, objectId);
}
@Override
- public StoredObject applyAcl(CallContext context, String repositoryId, String objectId,
+ public StoredObject applyAcl(CallContext context, String repositoryId, String objectId,
AclPropagation aclPropagation, ExtensionsData extension) {
return checkStandardParameters(repositoryId, objectId);
}
@Override
- public StoredObject[] applyPolicy(CallContext context, String repositoryId, String policyId, String objectId,
+ public StoredObject[] applyPolicy(CallContext context, String repositoryId, String policyId, String objectId,
ExtensionsData extension) {
return checkParams(repositoryId, policyId, objectId);
}
@Override
- public StoredObject[] removePolicy(CallContext context, String repositoryId, String policyId, String objectId,
+ public StoredObject[] removePolicy(CallContext context, String repositoryId, String policyId, String objectId,
ExtensionsData extension) {
StoredObject[] sos = checkParams(repositoryId, policyId, objectId);
@@ -528,14 +525,14 @@ public class BaseServiceValidatorImpl im
}
@Override
- public StoredObject getAppliedPolicies(CallContext context, String repositoryId, String objectId,
+ public StoredObject getAppliedPolicies(CallContext context, String repositoryId, String objectId,
ExtensionsData extension) {
return checkStandardParameters(repositoryId, objectId);
}
@Override
- public StoredObject create(CallContext context, String repositoryId, String folderId, ExtensionsData extension) {
+ public StoredObject create(CallContext context, String repositoryId, String folderId, ExtensionsData extension) {
return checkStandardParameters(repositoryId, folderId);
}
@@ -547,7 +544,7 @@ public class BaseServiceValidatorImpl im
}
@Override
- public StoredObject applyAcl(CallContext context, String repositoryId, String objectId) {
+ public StoredObject applyAcl(CallContext context, String repositoryId, String objectId) {
return checkStandardParameters(repositoryId, objectId);
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/ExtensionSample.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/ExtensionSample.java?rev=1514619&r1=1514618&r2=1514619&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/ExtensionSample.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/ExtensionSample.java Fri Aug 16 08:47:50 2013
@@ -24,13 +24,14 @@ import javax.xml.bind.annotation.XmlType
"s", "i", "f"
})
public class ExtensionSample {
+ private static final int MAGIC_NUMBER = 42;
private final String s;
private final int i;
private final double f;
public ExtensionSample() {
s = "This is an example for a CMIS extension.";
- i = 42;
+ i = MAGIC_NUMBER;
f = Math.PI;
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryAclService.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryAclService.java?rev=1514619&r1=1514618&r2=1514619&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryAclService.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryAclService.java Fri Aug 16 08:47:50 2013
@@ -51,7 +51,7 @@ public class InMemoryAclService extends
} else {
aclId = so.getAclId();
}
-
+
Acl acl = objectStore.getAcl(aclId);
if (context.isObjectInfoRequired()) {
@@ -59,33 +59,35 @@ public class InMemoryAclService extends
fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, so, objectInfo);
objectInfos.addObjectInfo(objectInfo);
}
-
+
return acl;
}
- public Acl applyAcl(CallContext context, String repositoryId, String objectId, Acl aclAdd, Acl aclRemove, AclPropagation aclPropagation,
- ExtensionsData extension, ObjectInfoHandler objectInfos) {
+ public Acl applyAcl(CallContext context, String repositoryId, String objectId, Acl aclAdd, Acl aclRemove,
+ AclPropagation aclPropagation, ExtensionsData extension, ObjectInfoHandler objectInfos) {
+
+ Acl addAces = TypeValidator.expandAclMakros(context.getUsername(), aclAdd);
+ Acl removeAces = TypeValidator.expandAclMakros(context.getUsername(), aclRemove);
+
+ StoredObject so = validator.applyAcl(context, repositoryId, objectId, aclPropagation, extension);
+ Acl acl = fStoreManager.getObjectStore(repositoryId).applyAcl(so, addAces, removeAces, aclPropagation,
+ context.getUsername());
- Acl addAces = TypeValidator.expandAclMakros(context.getUsername(), aclAdd);
- Acl removeAces = TypeValidator.expandAclMakros(context.getUsername(), aclRemove);
-
- StoredObject so = validator.applyAcl(context, repositoryId, objectId, aclPropagation, extension);
- Acl acl = fStoreManager.getObjectStore(repositoryId).applyAcl(so, addAces, removeAces, aclPropagation, context.getUsername());
-
if (context.isObjectInfoRequired()) {
ObjectInfoImpl objectInfo = new ObjectInfoImpl();
fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, so, objectInfo);
objectInfos.addObjectInfo(objectInfo);
}
- return acl;
+ return acl;
}
-
- public Acl applyAcl(CallContext context, String repositoryId, String objectId, Acl acesParam, AclPropagation aclPropagation) {
-
- Acl aces = TypeValidator.expandAclMakros(context.getUsername(), acesParam);
- StoredObject so = validator.applyAcl(context, repositoryId, objectId);
- return fStoreManager.getObjectStore(repositoryId).applyAcl(so, aces, aclPropagation, context.getUsername());
+ public Acl applyAcl(CallContext context, String repositoryId, String objectId, Acl acesParam,
+ AclPropagation aclPropagation) {
+
+ Acl aces = TypeValidator.expandAclMakros(context.getUsername(), acesParam);
+
+ StoredObject so = validator.applyAcl(context, repositoryId, objectId);
+ return fStoreManager.getObjectStore(repositoryId).applyAcl(so, aces, aclPropagation, context.getUsername());
}
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryMultiFilingServiceImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryMultiFilingServiceImpl.java?rev=1514619&r1=1514618&r2=1514619&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryMultiFilingServiceImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryMultiFilingServiceImpl.java Fri Aug 16 08:47:50 2013
@@ -49,12 +49,13 @@ public class InMemoryMultiFilingServiceI
LOG.debug("Begin addObjectToFolder()");
- StoredObject[] sos = validator.addObjectToFolder(context, repositoryId, objectId, folderId, allVersions, extension);
-
if (allVersions != null && null != allVersions && !allVersions.booleanValue()) {
throw new CmisNotSupportedException(
"Cannot add object to folder, version specific filing is not supported.");
}
+
+ StoredObject[] sos = validator.addObjectToFolder(context, repositoryId, objectId, folderId, allVersions, extension);
+
StoredObject so = sos[0];
StoredObject folder = sos[1];
ObjectStoreMultiFiling osmf = checkObjects(repositoryId, so, folder);