chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1049469 - in /incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src: main/java/org/apache/chemistry/opencmis/inmemory/server/ main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/ ma...
Date Wed, 15 Dec 2010 10:04:40 GMT
Author: jens
Date: Wed Dec 15 10:04:40 2010
New Revision: 1049469

URL: http://svn.apache.org/viewvc?rev=1049469&view=rev
Log:
InMemory Repository fix a couple of minor bugs/enhancements:
 - better checking of repositoryId and objectId set to null
 - use CmisException and not RuntimeException for invalid arguments
 - fill optional property query name, display name and local name for properties
 - add numItems value to getChildren

Modified:
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryAbstractServiceImpl.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryNavigationServiceImpl.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryObjectServiceImpl.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryVersioningServiceImpl.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/ObjectStoreImpl.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/StoreManagerImpl.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/VersionedDocumentImpl.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/PropertyCreationHelper.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/NavigationServiceTest.java

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryAbstractServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryAbstractServiceImpl.java?rev=1049469&r1=1049468&r2=1049469&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryAbstractServiceImpl.java
(original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryAbstractServiceImpl.java
Wed Dec 15 10:04:40 2010
@@ -22,6 +22,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.data.Properties;
 import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
 import org.apache.chemistry.opencmis.commons.definitions.TypeDefinitionContainer;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisPermissionDeniedException;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisUpdateConflictException;
@@ -58,6 +59,12 @@ public class InMemoryAbstractServiceImpl
      */
     protected StoredObject checkStandardParameters(String repositoryId, String objectId)
{
 
+        if (null == repositoryId)
+            throw new CmisInvalidArgumentException("Repository Id cannot be null.");
+
+        if (null == objectId)
+            throw new CmisInvalidArgumentException("Object Id cannot be null.");
+
         ObjectStore objStore = fStoreManager.getObjectStore(repositoryId);
 
         if (objStore == null)
@@ -73,6 +80,9 @@ public class InMemoryAbstractServiceImpl
 
     protected StoredObject checkExistingObjectId(ObjectStore objStore, String objectId) {
 
+        if (null == objectId)
+            throw new CmisInvalidArgumentException("Object Id cannot be null.");
+
         StoredObject so = objStore.getObjectById(objectId);
 
         if (so == null)
@@ -82,6 +92,9 @@ public class InMemoryAbstractServiceImpl
     }
 
     protected void checkRepositoryId(String repositoryId) {
+        if (null == repositoryId)
+            throw new CmisInvalidArgumentException("Repository Id cannot be null.");
+        
         ObjectStore objStore = fStoreManager.getObjectStore(repositoryId);
 
         if (objStore == null)
@@ -92,7 +105,7 @@ public class InMemoryAbstractServiceImpl
         String typeId = (String) properties.getProperties().get(PropertyIds.OBJECT_TYPE_ID).getFirstValue();
         TypeDefinitionContainer typeDefC = fStoreManager.getTypeById(repositoryId, typeId);
         if (typeDefC == null)
-            throw new RuntimeException("Cannot create object, a type with id " + typeId +
" is unknown");
+            throw new CmisInvalidArgumentException("Cannot create object, a type with id
" + typeId + " is unknown");
 
         return typeDefC.getTypeDefinition();
     }
@@ -149,7 +162,7 @@ public class InMemoryAbstractServiceImpl
 
     protected void checkIsVersionableObject(StoredObject so) {
         if (!(so instanceof VersionedDocument || so instanceof DocumentVersion))
-            throw new RuntimeException(
+            throw new CmisInvalidArgumentException(
                     "Object is of a versionable type but not instance of VersionedDocument
or DocumentVersion.");
     }
 

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryNavigationServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryNavigationServiceImpl.java?rev=1049469&r1=1049468&r2=1049469&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryNavigationServiceImpl.java
(original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryNavigationServiceImpl.java
Wed Dec 15 10:04:40 2010
@@ -306,7 +306,7 @@ public class InMemoryNavigationServiceIm
             }
 
             TypeDefinition td = fStoreManager.getTypeById(repositoryId, spo.getTypeId()).getTypeDefinition();
-            Properties props = PropertyCreationHelper.getPropertiesFromObject(spo, td, requestedIds);
+            Properties props = PropertyCreationHelper.getPropertiesFromObject(spo, td, requestedIds,
true);
             objectData.setProperties(props);
 
             oifd.setObject(objectData);
@@ -320,6 +320,7 @@ public class InMemoryNavigationServiceIm
 
         }
         result.setObjects(folderList);
+        result.setNumItems(BigInteger.valueOf(folderList.size()));
         if (objectInfos != null) {
             ObjectInfoImpl objectInfo = new ObjectInfoImpl();
             fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, so, objectInfo);
@@ -431,7 +432,7 @@ public class InMemoryNavigationServiceIm
     void copyFilteredProperties(String repositoryId, StoredObject so, String filter, ObjectDataImpl
objData) {
         List<String> requestedIds = FilterParser.getRequestedIdsFromFilter(filter);
         TypeDefinition td = fStoreManager.getTypeById(repositoryId, so.getTypeId()).getTypeDefinition();
-        Properties props = PropertyCreationHelper.getPropertiesFromObject(so, td, requestedIds);
+        Properties props = PropertyCreationHelper.getPropertiesFromObject(so, td, requestedIds,
true);
         objData.setProperties(props);
     }
 

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryObjectServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryObjectServiceImpl.java?rev=1049469&r1=1049468&r2=1049469&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryObjectServiceImpl.java
(original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryObjectServiceImpl.java
Wed Dec 15 10:04:40 2010
@@ -127,7 +127,7 @@ public class InMemoryObjectServiceImpl e
         List<String> requestedIds = FilterParser.getRequestedIdsFromFilter("*");
 
         TypeDefinition td = fStoreManager.getTypeById(repositoryId, so.getTypeId()).getTypeDefinition();
-        Properties existingProps = PropertyCreationHelper.getPropertiesFromObject(so, td,
requestedIds);
+        Properties existingProps = PropertyCreationHelper.getPropertiesFromObject(so, td,
requestedIds, true);
 
         PropertiesImpl newPD = new PropertiesImpl();
         // copy all existing properties
@@ -185,18 +185,18 @@ public class InMemoryObjectServiceImpl e
             ExtensionsData extension, ObjectInfoHandler objectInfos) {
 
         if (null == properties || null == properties.getProperties())
-            throw new RuntimeException("Cannot create object, without properties.");
+            throw new CmisInvalidArgumentException("Cannot create object, without properties.");
 
         // Find out what kind of object needs to be created
         PropertyData<String> pd = (PropertyData<String>) properties.getProperties().get(PropertyIds.OBJECT_TYPE_ID);
         String typeId = pd == null ? null : pd.getFirstValue();
         if (null == typeId)
-            throw new RuntimeException(
+            throw new CmisInvalidArgumentException(
                     "Cannot create object, without a type (no property with id CMIS_OBJECT_TYPE_ID).");
 
         TypeDefinitionContainer typeDefC = fStoreManager.getTypeById(repositoryId, typeId);
         if (typeDefC == null)
-            throw new RuntimeException("Cannot create object, a type with id " + typeId +
" is unknown");
+            throw new CmisInvalidArgumentException("Cannot create object, a type with id
" + typeId + " is unknown");
 
         // check if the given type is a document type
         BaseTypeId typeBaseId = typeDefC.getTypeDefinition().getBaseTypeId();
@@ -279,10 +279,10 @@ public class InMemoryObjectServiceImpl e
         ObjectStore objectStore = fStoreManager.getObjectStore(repositoryId);
 
         if (null == so)
-            throw new RuntimeException("Cannot delete object with id  " + folderId + ". Object
does not exist.");
+            throw new CmisInvalidArgumentException("Cannot delete object with id  " + folderId
+ ". Object does not exist.");
 
         if (!(so instanceof Folder))
-            throw new RuntimeException("deleteTree can only be invoked on a folder, but id
" + folderId
+            throw new CmisInvalidArgumentException("deleteTree can only be invoked on a folder,
but id " + folderId
                     + " does not refer to a folder");
 
         if (unfileObjects == UnfileObject.UNFILE)
@@ -423,7 +423,7 @@ public class InMemoryObjectServiceImpl e
         // build properties collection
         List<String> requestedIds = FilterParser.getRequestedIdsFromFilter(filter);
         TypeDefinition td = fStoreManager.getTypeById(repositoryId, so.getTypeId()).getTypeDefinition();
-        Properties props = PropertyCreationHelper.getPropertiesFromObject(so, td, requestedIds);
+        Properties props = PropertyCreationHelper.getPropertiesFromObject(so, td, requestedIds,
true);
         LOG.debug("stop getProperties()");
         return props;
     }
@@ -696,7 +696,7 @@ public class InMemoryObjectServiceImpl e
 
         // check if the given type is a document type
         if (!typeDef.getBaseTypeId().equals(BaseTypeId.CMIS_DOCUMENT))
-            throw new RuntimeException("Cannot create a document, with a non-document type:
" + typeDef.getId());
+            throw new CmisInvalidArgumentException("Cannot create a document, with a non-document
type: " + typeDef.getId());
 
         // check name syntax
         if (!NameValidator.isValidId(name))
@@ -799,7 +799,7 @@ public class InMemoryObjectServiceImpl e
 
         // check if the given type is a folder type
         if (!typeDef.getBaseTypeId().equals(BaseTypeId.CMIS_FOLDER))
-            throw new RuntimeException("Cannot create a folder, with a non-folder type: "
+ typeDef.getId());
+            throw new CmisInvalidArgumentException("Cannot create a folder, with a non-folder
type: " + typeDef.getId());
 
         Map<String, PropertyData<?>> propMap = properties.getProperties();
         Map<String, PropertyData<?>> propMapNew = setDefaultProperties(typeDef,
propMap);

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryVersioningServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryVersioningServiceImpl.java?rev=1049469&r1=1049468&r2=1049469&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryVersioningServiceImpl.java
(original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryVersioningServiceImpl.java
Wed Dec 15 10:04:40 2010
@@ -30,6 +30,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
 import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
 import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisNotSupportedException;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisUpdateConflictException;
 import org.apache.chemistry.opencmis.commons.impl.server.ObjectInfoImpl;
@@ -141,12 +142,12 @@ public class InMemoryVersioningServiceIm
             String filter, Boolean includeAllowableActions, ExtensionsData extension, ObjectInfoHandler
objectInfos) {
 
         if (null == versionSeriesId)
-            throw new RuntimeException("getAllVersions requires a version series id, but
ist was null.");
+            throw new CmisInvalidArgumentException("getAllVersions requires a version series
id, but ist was null.");
 
         StoredObject so = checkStandardParameters(repositoryId, versionSeriesId);
 
         if (!(so instanceof VersionedDocument))
-            throw new RuntimeException("Object is not instance of a VersionedDocument (version
series)");
+            throw new CmisInvalidArgumentException("Object is not instance of a VersionedDocument
(version series)");
 
         VersionedDocument verDoc = (VersionedDocument) so;
         List<ObjectData> res = new ArrayList<ObjectData>();
@@ -184,7 +185,7 @@ public class InMemoryVersioningServiceIm
             objData = getObject(context, repositoryId, so.getId(), filter, includeAllowableActions,
extension,
                     objectInfos);
         } else
-            throw new RuntimeException("Object is not instance of a document (version series)");
+            throw new CmisInvalidArgumentException("Object is not instance of a document
(version series)");
 
         // provide information for Atom links for version series:
         if (context.isObjectInfoRequired()) {
@@ -208,12 +209,12 @@ public class InMemoryVersioningServiceIm
         } else if (so instanceof Document) {
             latestVersionObject = so;
         } else
-            throw new RuntimeException("Object is not instance of a document (version series)");
+            throw new CmisInvalidArgumentException("Object is not instance of a document
(version series)");
 
         List<String> requestedIds = FilterParser.getRequestedIdsFromFilter(filter);
         TypeDefinition td = fStoreManager.getTypeById(repositoryId, so.getTypeId()).getTypeDefinition();
         Properties props = PropertyCreationHelper.getPropertiesFromObject(latestVersionObject,
td, 
-                requestedIds);
+                requestedIds, true);
 
         return props;
     }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/ObjectStoreImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/ObjectStoreImpl.java?rev=1049469&r1=1049468&r2=1049469&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/ObjectStoreImpl.java
(original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/ObjectStoreImpl.java
Wed Dec 15 10:04:40 2010
@@ -28,6 +28,7 @@ import java.util.concurrent.locks.Reentr
 
 import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.Document;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.DocumentVersion;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.Folder;
@@ -181,7 +182,7 @@ public class ObjectStoreImpl implements 
         StoredObject found = fStoredObjectMap.remove(vers.getId());
 
         if (null == found)
-            throw new RuntimeException("Cannot delete object with id  " + vers.getId() +
". Object does not exist.");
+            throw new CmisInvalidArgumentException("Cannot delete object with id  " + vers.getId()
+ ". Object does not exist.");
     }
 
     // public void changePath(StoredObject obj, String oldPath, String newPath)
@@ -297,10 +298,10 @@ public class ObjectStoreImpl implements 
     private void deleteFolder(String folderId) {
         StoredObject folder = fStoredObjectMap.get(folderId);
         if (folder == null)
-            throw new RuntimeException("Unknown object with id:  " + folderId);
+            throw new CmisInvalidArgumentException("Unknown object with id:  " + folderId);
 
         if (!(folder instanceof FolderImpl)) {
-            throw new RuntimeException("Cannot delete folder with id:  " + folderId
+            throw new CmisInvalidArgumentException("Cannot delete folder with id:  " + folderId
                     + ". Object exists but is not a folder.");
         }
 

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/StoreManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/StoreManagerImpl.java?rev=1049469&r1=1049468&r2=1049469&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/StoreManagerImpl.java
(original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/StoreManagerImpl.java
Wed Dec 15 10:04:40 2010
@@ -129,7 +129,7 @@ public class StoreManagerImpl implements
             int depth) {
         TypeManager typeManager = fMapRepositoryToTypeManager.get(repositoryId);
         if (null == typeManager)
-            throw new RuntimeException("Unknown repository " + repositoryId);
+            throw new CmisInvalidArgumentException("Unknown repository " + repositoryId);
 
         TypeDefinitionContainer tc = typeManager.getTypeById(typeId);
         List<TypeDefinitionContainer> result = null;
@@ -154,7 +154,7 @@ public class StoreManagerImpl implements
         Collection<TypeDefinitionContainer> result;
         TypeManager typeManager = fMapRepositoryToTypeManager.get(repositoryId);
         if (null == typeManager)
-            throw new RuntimeException("Unknown repository " + repositoryId);
+            throw new CmisInvalidArgumentException("Unknown repository " + repositoryId);
         Collection<TypeDefinitionContainer> typeColl = typeManager.getTypeDefinitionList();
         if (includePropertyDefinitions) {
             result = typeColl;
@@ -179,7 +179,7 @@ public class StoreManagerImpl implements
     public List<TypeDefinitionContainer> getRootTypes(String repositoryId) {
         TypeManager typeManager = fMapRepositoryToTypeManager.get(repositoryId);
         if (null == typeManager)
-            throw new RuntimeException("Unknown repository " + repositoryId);
+            throw new CmisInvalidArgumentException("Unknown repository " + repositoryId);
         List<TypeDefinitionContainer> rootTypes = typeManager.getRootTypes();
 
         return rootTypes;
@@ -198,7 +198,7 @@ public class StoreManagerImpl implements
     public void clearTypeSystem(String repositoryId) {
         TypeManagerImpl typeManager = fMapRepositoryToTypeManager.get(repositoryId);
         if (null == typeManager)
-            throw new RuntimeException("Unknown repository " + repositoryId);
+            throw new CmisInvalidArgumentException("Unknown repository " + repositoryId);
 
         typeManager.clearTypeSystem();
     }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/VersionedDocumentImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/VersionedDocumentImpl.java?rev=1049469&r1=1049468&r2=1049469&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/VersionedDocumentImpl.java
(original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/VersionedDocumentImpl.java
Wed Dec 15 10:04:40 2010
@@ -27,6 +27,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.data.PropertyData;
 import org.apache.chemistry.opencmis.commons.enums.VersioningState;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
 import org.apache.chemistry.opencmis.commons.spi.BindingsObjectFactory;
 import org.apache.chemistry.opencmis.inmemory.FilterParser;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.DocumentVersion;
@@ -71,10 +72,10 @@ public class VersionedDocumentImpl exten
 
     public boolean deleteVersion(DocumentVersion version) {
         if (fIsCheckedOut)
-            throw new RuntimeException("version cannot be deleted if document is checked-out:
" + version.getId());
+            throw new CmisInvalidArgumentException("version cannot be deleted if document
is checked-out: " + version.getId());
         boolean found = fVersions.remove(version);
         if (!found)
-            throw new RuntimeException("Version is not contained in the document:" + version.getId());
+            throw new CmisInvalidArgumentException("Version is not contained in the document:"
+ version.getId());
 
         return !fVersions.isEmpty();
     }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/PropertyCreationHelper.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/PropertyCreationHelper.java?rev=1049469&r1=1049468&r2=1049469&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/PropertyCreationHelper.java
(original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/PropertyCreationHelper.java
Wed Dec 15 10:04:40 2010
@@ -34,6 +34,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.data.PropertyData;
 import org.apache.chemistry.opencmis.commons.data.PropertyInteger;
 import org.apache.chemistry.opencmis.commons.definitions.Choice;
+import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
 import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
 import org.apache.chemistry.opencmis.commons.enums.Cardinality;
 import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
@@ -183,32 +184,7 @@ public class PropertyCreationHelper {
         prop.setDefaultValue(Collections.singletonList(defVal));
     }
 
-    // internal helpers
-    private static void createStandardDefinition(AbstractPropertyDefinition<?> prop,
String id, PropertyType propType,
-            String displayName, Cardinality card) {
-
-        if (!NameValidator.isValidId(id))
-            if (!NameValidator.isValidId(id))
-                throw new CmisInvalidArgumentException(NameValidator.ERROR_ILLEGAL_NAME);
-
-        prop.setId(id);
-        if (displayName == null)
-            prop.setDisplayName("Sample " + prop.getId() + " boolean property");
-        else
-            prop.setDisplayName(displayName);
-        prop.setLocalName(id);
-        prop.setLocalNamespace("local");
-        prop.setQueryName(id);
-        prop.setIsInherited(false);
-        prop.setCardinality(card);
-        prop.setIsOpenChoice(false);
-        prop.setIsQueryable(true);
-        prop.setIsRequired(false);
-        prop.setPropertyType(propType);
-        prop.setUpdatability(Updatability.READWRITE);
-    }
-
-    public static Properties getPropertiesFromObject(StoredObject so, TypeDefinition td,
List<String> requestedIds) {
+    public static Properties getPropertiesFromObject(StoredObject so, TypeDefinition td,
List<String> requestedIds, boolean fillOptionalPropertyData) {
         // build properties collection
 
         BindingsObjectFactory objectFactory = new BindingsObjectFactoryImpl();
@@ -229,6 +205,11 @@ public class PropertyCreationHelper {
             }
         }
         List<PropertyData<?>> propertiesList = new ArrayList<PropertyData<?>>(properties.values());
+
+        if (fillOptionalPropertyData) {  // add query name, local name, display name
+            fillOptionalPropertyData(td, propertiesList);
+        }
+        
         Properties props = objectFactory.createPropertiesData(propertiesList);
         return props;
     }
@@ -254,21 +235,30 @@ public class PropertyCreationHelper {
             }
         }
 
+        
         Map<String, PropertyData<?>> mappedProperties = new HashMap<String,
PropertyData<?>>();
         if (requestedIds.containsKey("*")) {
             for (Map.Entry<String, PropertyData<?>> prop : properties.entrySet())
{
                 // map property id to property query name
                 String queryName = td.getPropertyDefinitions().get(prop.getKey()).getQueryName();
+                String localName = td.getPropertyDefinitions().get(prop.getKey()).getLocalName();
+                String displayName = td.getPropertyDefinitions().get(prop.getKey()).getDisplayName();
                 AbstractPropertyData<?> ad = (AbstractPropertyData<?>) prop.getValue();
// a bit dirty
                 ad.setQueryName(queryName);
+                ad.setLocalName(localName);
+                ad.setDisplayName(displayName);
                 mappedProperties.put(queryName, prop.getValue());
             }
         } else {
             // replace all ids with query names or alias:
             for (Map.Entry<String, PropertyData<?>> prop : properties.entrySet())
{
                 String queryNameOrAlias = requestedIds.get(prop.getKey());
+                String localName = td.getPropertyDefinitions().get(prop.getKey()).getLocalName();
+                String displayName = td.getPropertyDefinitions().get(prop.getKey()).getDisplayName();
                 AbstractPropertyData<?> ad = (AbstractPropertyData<?>) prop.getValue();
// a bit dirty
                 ad.setQueryName(queryNameOrAlias);
+                ad.setLocalName(localName);
+                ad.setDisplayName(displayName);
                 mappedProperties.put(queryNameOrAlias, prop.getValue());
             }
         }
@@ -295,7 +285,7 @@ public class PropertyCreationHelper {
 
         // build properties collection
         List<String> requestedIds = FilterParser.getRequestedIdsFromFilter(filter);
-        Properties props = getPropertiesFromObject(so, typeDef, requestedIds);
+        Properties props = getPropertiesFromObject(so, typeDef, requestedIds, true);
 
         // fill output object
         if (null != includeAllowableActions && includeAllowableActions) {
@@ -347,4 +337,47 @@ public class PropertyCreationHelper {
 
         return od;
     }
+    
+    // internal helpers
+    private static void createStandardDefinition(AbstractPropertyDefinition<?> prop,
String id, PropertyType propType,
+            String displayName, Cardinality card) {
+
+        if (!NameValidator.isValidId(id))
+            if (!NameValidator.isValidId(id))
+                throw new CmisInvalidArgumentException(NameValidator.ERROR_ILLEGAL_NAME);
+
+        prop.setId(id);
+        if (displayName == null)
+            prop.setDisplayName("Sample " + prop.getId() + " boolean property");
+        else
+            prop.setDisplayName(displayName);
+        prop.setLocalName(id);
+        prop.setLocalNamespace("local");
+        prop.setQueryName(id);
+        prop.setIsInherited(false);
+        prop.setCardinality(card);
+        prop.setIsOpenChoice(false);
+        prop.setIsQueryable(true);
+        prop.setIsRequired(false);
+        prop.setPropertyType(propType);
+        prop.setUpdatability(Updatability.READWRITE);
+    }
+
+    private static void fillOptionalPropertyData(TypeDefinition td, List<PropertyData<?>>
properties) {
+        for (PropertyData<?> pd : properties)
+            fillOptionalPropertyData(td, (AbstractPropertyData<?>) pd);        
+    }
+    
+    private static void fillOptionalPropertyData(TypeDefinition td, AbstractPropertyData<?>
property) {
+        PropertyDefinition<?> pd = td.getPropertyDefinitions().get(property.getId());
+        if (null != pd) {
+            String displayName = pd.getDisplayName();
+            String queryName = pd.getQueryName();
+            String localName = pd.getLocalName();
+            property.setDisplayName(displayName);
+            property.setLocalName(localName);
+            property.setQueryName(queryName);
+        }
+    }
+    
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/NavigationServiceTest.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/NavigationServiceTest.java?rev=1049469&r1=1049468&r2=1049469&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/NavigationServiceTest.java
(original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/NavigationServiceTest.java
Wed Dec 15 10:04:40 2010
@@ -19,6 +19,7 @@
 package org.apache.chemistry.opencmis.inmemory;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
 import java.math.BigInteger;
@@ -89,6 +90,7 @@ public class NavigationServiceTest exten
         }
         assertEquals(3, folders.size());
         assertEquals("Folder 3", folders.get(0).getPathSegment());
+        assertTrue(result.getNumItems().longValue() > 0);
         log.info("... testGetChildren() finished.");
     }
 



Mime
View raw message