chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fguilla...@apache.org
Subject svn commit: r796821 - in /incubator/chemistry/trunk/chemistry: chemistry-api/src/main/java/org/apache/chemistry/ chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/ chemistry-atompub-client/src/test/resources/ chemistry-atompub-...
Date Wed, 22 Jul 2009 18:25:14 GMT
Author: fguillaume
Date: Wed Jul 22 18:25:13 2009
New Revision: 796821

URL: http://svn.apache.org/viewvc?rev=796821&view=rev
Log:
CMIS-44: cleanup of type id vs name

Modified:
    incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/CMISObject.java
    incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/ObjectEntry.java
    incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/Property.java
    incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/Type.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPConnection.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPFolder.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPObject.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPObjectEntry.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPType.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/TypeEntryReader.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/resources/feed-types.xml
    incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISObjectsCollection.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISTypesCollection.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/CMIS.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/abdera/PropertiesElement.java
    incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/base/BaseObject.java
    incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleConnection.java
    incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleData.java
    incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleObject.java
    incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleObjectEntry.java
    incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleRepository.java
    incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleType.java
    incubator/chemistry/trunk/chemistry/chemistry-commons/src/test/java/org/apache/chemistry/impl/simple/TestSimpleRepository.java
    incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrDocument.java
    incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrFolder.java
    incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrObjectEntry.java
    incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrType.java

Modified: incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/CMISObject.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/CMISObject.java?rev=796821&r1=796820&r2=796821&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/CMISObject.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/CMISObject.java
Wed Jul 22 18:25:13 2009
@@ -191,6 +191,11 @@
     Type getType();
 
     /**
+     * The object's base type.
+     */
+    BaseType getBaseType();
+
+    /**
      * Gets a property.
      *
      * @param name the property name

Modified: incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/ObjectEntry.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/ObjectEntry.java?rev=796821&r1=796820&r2=796821&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/ObjectEntry.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/ObjectEntry.java
Wed Jul 22 18:25:13 2009
@@ -37,6 +37,13 @@
     String getTypeId();
 
     /**
+     * Gets the base type for this entry.
+     *
+     * @return the base type
+     */
+    BaseType getBaseType();
+
+    /**
      * Gets a property value.
      * <p>
      * Returns {@code null} is the property is not set, not fetched or unknown.

Modified: incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/Property.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/Property.java?rev=796821&r1=796820&r2=796821&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/Property.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/Property.java
Wed Jul 22 18:25:13 2009
@@ -33,6 +33,8 @@
 
     String TYPE_ID = "ObjectTypeId";
 
+    String BASE_TYPE_ID = "BaseTypeId";
+
     String CREATED_BY = "CreatedBy";
 
     String CREATION_DATE = "CreationDate";

Modified: incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/Type.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/Type.java?rev=796821&r1=796820&r2=796821&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/Type.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/Type.java
Wed Jul 22 18:25:13 2009
@@ -69,16 +69,6 @@
     BaseType getBaseType();
 
     /**
-     * The base type's query name.
-     * <p>
-     * This can be only {@code Document}, {@code Folder}, {@code Relationship},
-     * or {@code Policy}.
-     *
-     * @return the base type's query name
-     */
-    String getBaseTypeQueryName();
-
-    /**
      * The type's description.
      * <p>
      * This is an application's description of this type, such as the nature of

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPConnection.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPConnection.java?rev=796821&r1=796820&r2=796821&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPConnection.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPConnection.java
Wed Jul 22 18:25:13 2009
@@ -180,7 +180,7 @@
                 includeAllowableActions, includeRelationships,
                 Integer.MAX_VALUE, 0, orderBy, new boolean[1]);
         for (ObjectEntry child : children) {
-            BaseType childType = repository.getType(child.getTypeId()).getBaseType();
+            BaseType childType = child.getBaseType();
             if (type == null || childType.equals(type)) {
                 list.add(child);
             }
@@ -228,9 +228,7 @@
         boolean done = false;
         for (ObjectEntry entry : feed) {
             // type filtering
-            if (type != null
-                    && !repository.getType(entry.getTypeId()).getBaseType().equals(
-                            type)) {
+            if (type != null && !entry.getBaseType().equals(type)) {
                 continue;
             }
             // skip
@@ -259,8 +257,7 @@
         // TODO filter, includeRelationship, includeAllowableActions
         List<ObjectEntry> result = new LinkedList<ObjectEntry>();
         APPObjectEntry current = getObjectEntry(folder);
-        Type type = repository.getType(current.getTypeId());
-        if (!type.getBaseType().equals(BaseType.FOLDER)) {
+        if (!current.getBaseType().equals(BaseType.FOLDER)) {
             throw new IllegalArgumentException("Not a folder: " + folder);
         }
         String rootId = current.connection.getRootFolder().getId();
@@ -344,7 +341,7 @@
         }
         APPObjectEntry entry = getObjectEntry(object);
         Type type = getRepository().getType(entry.getTypeId());
-        switch (type.getBaseType()) {
+        switch (entry.getBaseType()) {
         case DOCUMENT:
             return new APPDocument(entry, type);
         case FOLDER:
@@ -354,7 +351,7 @@
         case RELATIONSHIP:
             throw new UnsupportedOperationException("Not yet implemented");
         default:
-            throw new AssertionError(type.getBaseType());
+            throw new AssertionError(entry.getBaseType());
         }
 
         // throw new UnsupportedOperationException("Not yet implemented");

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPFolder.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPFolder.java?rev=796821&r1=796820&r2=796821&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPFolder.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPFolder.java
Wed Jul 22 18:25:13 2009
@@ -73,11 +73,8 @@
         List<ObjectEntry> feed = resp.getObjectFeed(new ReadContext(
                 entry.connection));
         List<CMISObject> children = new ArrayList<CMISObject>(feed.size());
-        APPRepository repository = entry.connection.repository;
         for (ObjectEntry child : feed) {
-            if (type != null
-                    && !repository.getType(child.getTypeId()).getBaseType().equals(
-                            type)) {
+            if (type != null && !child.getBaseType().equals(type)) {
                 continue;
             }
             children.add(APPObject.construct((APPObjectEntry) child));

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPObject.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPObject.java?rev=796821&r1=796820&r2=796821&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPObject.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPObject.java
Wed Jul 22 18:25:13 2009
@@ -55,8 +55,7 @@
 
     protected static APPObject construct(APPObjectEntry entry) {
         Type type = entry.connection.repository.getType(entry.getTypeId());
-        BaseType baseType = type.getBaseType();
-        switch (baseType) {
+        switch (entry.getBaseType()) {
         case DOCUMENT:
             return new APPDocument(entry, type);
         case FOLDER:
@@ -66,7 +65,7 @@
         case RELATIONSHIP:
             // return new APPRelationship(entry, type);
         default:
-            throw new AssertionError(baseType.toString());
+            throw new AssertionError(entry.getBaseType().toString());
         }
     }
 
@@ -164,6 +163,10 @@
         return type;
     }
 
+    public BaseType getBaseType() {
+        return type.getBaseType();
+    }
+
     public Property getProperty(String name) {
         PropertyDefinition pd = getType().getPropertyDefinition(name);
         if (pd == null) {

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPObjectEntry.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPObjectEntry.java?rev=796821&r1=796820&r2=796821&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPObjectEntry.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPObjectEntry.java
Wed Jul 22 18:25:13 2009
@@ -28,6 +28,7 @@
 import java.util.Set;
 import java.util.Map.Entry;
 
+import org.apache.chemistry.BaseType;
 import org.apache.chemistry.ObjectEntry;
 import org.apache.chemistry.Property;
 import org.apache.chemistry.PropertyDefinition;
@@ -107,6 +108,10 @@
         return (String) getValue(Property.TYPE_ID);
     }
 
+    public BaseType getBaseType() {
+        return BaseType.get((String) getValue(Property.BASE_TYPE_ID));
+    }
+
     public Serializable getValue(String name) {
         XmlProperty p = properties.get(name);
         return p == null ? null : p.getValue();

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPType.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPType.java?rev=796821&r1=796820&r2=796821&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPType.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPType.java
Wed Jul 22 18:25:13 2009
@@ -56,22 +56,6 @@
         propertyDefs = props;
     }
 
-    // should be added to API
-    public boolean isFolder() {
-        return getBaseType() == BaseType.FOLDER;
-    }
-
-    public BaseType getBaseType() {
-        if (baseType == null) {
-            baseType = BaseType.get(map.get(CMIS.BASE_TYPE.getLocalPart()));
-        }
-        return baseType;
-    }
-
-    public String getBaseTypeQueryName() {
-        return map.get(CMIS.BASE_TYPE_QUERY_NAME.getLocalPart());
-    }
-
     public String getDescription() {
         return map.get(CMIS.DESCRIPTION.getLocalPart());
     }
@@ -87,7 +71,20 @@
 
     @Override
     public String getTypeId() {
-        return map.get(CMIS.TYPE_ID.getLocalPart());
+        return map.get(CMIS.ID.getLocalPart());
+    }
+
+    @Override
+    public BaseType getBaseType() {
+        if (baseType == null) {
+            baseType = BaseType.get(map.get(CMIS.BASE_TYPE_ID.getLocalPart()));
+        }
+        return baseType;
+    }
+
+    // should be added to API
+    public boolean isFolder() {
+        return getBaseType() == BaseType.FOLDER;
     }
 
     public String getParentId() {

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/TypeEntryReader.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/TypeEntryReader.java?rev=796821&r1=796820&r2=796821&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/TypeEntryReader.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/TypeEntryReader.java
Wed Jul 22 18:25:13 2009
@@ -18,9 +18,11 @@
  */
 package org.apache.chemistry.atompub.client;
 
+import java.util.Arrays;
 import java.util.HashMap;
 import java.util.Map;
 
+import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamException;
 
 import org.apache.chemistry.PropertyDefinition;
@@ -90,7 +92,7 @@
                         log.error("Cannot read text element for: " + name, e);
                         continue;
                     }
-                    if (name.equals(CMIS.BASE_TYPE.getLocalPart())) {
+                    if (name.equals(CMIS.BASE_TYPE_ID.getLocalPart())) {
                         // check base type coherent with base element
                         // eg "folder" for a <cmis:folderType>
                         if (!localName.startsWith(text)) {
@@ -103,6 +105,30 @@
                     map.put(name, text);
                 }
             }
+            // check some mandatory properties
+            // TODO also for documents: versionable, contentStreamAllowed
+            // TODO also for relationships: allowedSourceTypes, allowedTargetTypes
+            for (QName qname : Arrays.asList( //
+                    CMIS.ID, //
+                    // TODO localName, localNamespace
+                    CMIS.QUERY_NAME, //
+                    CMIS.DISPLAY_NAME, //
+                    CMIS.BASE_TYPE_ID, //
+                    CMIS.PARENT_ID, //
+                    CMIS.DESCRIPTION, //
+                    CMIS.CREATABLE, //
+                    CMIS.FILEABLE, //
+                    CMIS.QUERYABLE, //
+                    CMIS.CONTROLLABLE, //
+                    CMIS.INCLUDED_IN_SUPERTYPE_QUERY //
+            )) {
+                if (!map.containsKey(qname.getLocalPart())) {
+                    throw new IllegalArgumentException(
+                            "Invalid type definition: missing "
+                                    + qname.getPrefix() + ':'
+                                    + qname.getLocalPart());
+                }
+            }
             entry.init(map, pdefs);
         }
     }

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/resources/feed-types.xml
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/resources/feed-types.xml?rev=796821&r1=796820&r2=796821&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/resources/feed-types.xml
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/resources/feed-types.xml
Wed Jul 22 18:25:13 2009
@@ -15,11 +15,10 @@
     <link href="http://127.0.0.1:8080/cmis/type/document" rel="alternate" />
     <link href="http://127.0.0.1:8080/cmis/repository" rel="repository" />
     <cmis:documentType>
-      <cmis:typeId>document</cmis:typeId>
+      <cmis:id>document</cmis:id>
       <cmis:queryName>Document</cmis:queryName>
       <cmis:displayName>Document Type</cmis:displayName>
-      <cmis:baseType>document</cmis:baseType>
-      <cmis:baseTypeQueryName>Document</cmis:baseTypeQueryName>
+      <cmis:baseTypeId>document</cmis:baseTypeId>
       <cmis:parentId />
       <cmis:description></cmis:description>
       <cmis:creatable>true</cmis:creatable>
@@ -39,11 +38,10 @@
     <link href="http://127.0.0.1:8080/cmis/type/folder" rel="alternate" />
     <link href="http://127.0.0.1:8080/cmis/repository" rel="repository" />
     <cmis:folderType>
-      <cmis:typeId>folder</cmis:typeId>
+      <cmis:id>folder</cmis:id>
       <cmis:queryName>Folder</cmis:queryName>
       <cmis:displayName>Folder Type</cmis:displayName>
-      <cmis:baseType>folder</cmis:baseType>
-      <cmis:baseTypeQueryName>Folder</cmis:baseTypeQueryName>
+      <cmis:baseTypeId>folder</cmis:baseTypeId>
       <cmis:parentId />
       <cmis:description></cmis:description>
       <cmis:creatable>true</cmis:creatable>
@@ -63,11 +61,10 @@
     <link href="http://127.0.0.1:8080/cmis/type/relationship" rel="alternate" />
     <link href="http://127.0.0.1:8080/cmis/repository" rel="repository" />
     <cmis:relationshipType>
-      <cmis:typeId>relationship</cmis:typeId>
+      <cmis:id>relationship</cmis:id>
       <cmis:queryName>Relationship</cmis:queryName>
       <cmis:displayName>Relationship Type</cmis:displayName>
-      <cmis:baseType>relationship</cmis:baseType>
-      <cmis:baseTypeQueryName>Relationship</cmis:baseTypeQueryName>
+      <cmis:baseTypeId>relationship</cmis:baseTypeId>
       <cmis:parentId />
       <cmis:description></cmis:description>
       <cmis:creatable>true</cmis:creatable>
@@ -87,11 +84,10 @@
     <link href="http://127.0.0.1:8080/cmis/type/policy" rel="alternate" />
     <link href="http://127.0.0.1:8080/cmis/repository" rel="repository" />
     <cmis:policyType>
-      <cmis:typeId>policy</cmis:typeId>
+      <cmis:id>policy</cmis:id>
       <cmis:queryName>Policy</cmis:queryName>
       <cmis:displayName>Policy Type</cmis:displayName>
-      <cmis:baseType>policy</cmis:baseType>
-      <cmis:baseTypeQueryName>Policy</cmis:baseTypeQueryName>
+      <cmis:baseTypeId>policy</cmis:baseTypeId>
       <cmis:parentId />
       <cmis:description></cmis:description>
       <cmis:creatable>true</cmis:creatable>
@@ -111,11 +107,10 @@
     <link href="http://127.0.0.1:8080/cmis/type/Root" rel="alternate" />
     <link href="http://127.0.0.1:8080/cmis/repository" rel="repository" />
     <cmis:folderType>
-      <cmis:typeId>Root</cmis:typeId>
+      <cmis:id>Root</cmis:id>
       <cmis:queryName>Root</cmis:queryName>
       <cmis:displayName>Root Folder Type</cmis:displayName>
-      <cmis:baseType>folder</cmis:baseType>
-      <cmis:baseTypeQueryName>Folder</cmis:baseTypeQueryName>
+      <cmis:baseTypeId>folder</cmis:baseTypeId>
       <cmis:parentId>folder</cmis:parentId>
       <cmis:description></cmis:description>
       <cmis:creatable>false</cmis:creatable>

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISObjectsCollection.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISObjectsCollection.java?rev=796821&r1=796820&r2=796821&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISObjectsCollection.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISObjectsCollection.java
Wed Jul 22 18:25:13 2009
@@ -153,8 +153,7 @@
         entry.addLink(getTypeLink(object.getTypeId(), request), CMIS.LINK_TYPE);
         String oid = object.getId();
         entry.addLink(getParentsLink(oid, request), CMIS.LINK_PARENTS);
-        Type objectType = repository.getType(object.getTypeId());
-        if (objectType.getBaseType() == BaseType.FOLDER) {
+        if (object.getBaseType() == BaseType.FOLDER) {
             entry.addLink(getChildrenLink(oid, request), CMIS.LINK_CHILDREN);
             entry.addLink(getDescendantsLink(oid, request),
                     CMIS.LINK_DESCENDANTS);
@@ -165,6 +164,7 @@
         // ContentStreamUri needs to know the media link
         String mediaLink = isMediaEntry(object) ? getMediaLink(object.getId(),
                 request) : null;
+        Type objectType = repository.getType(object.getTypeId());
         entry.addExtension(new ObjectElement(factory, object, objectType,
                 mediaLink));
 

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISTypesCollection.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISTypesCollection.java?rev=796821&r1=796820&r2=796821&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISTypesCollection.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISTypesCollection.java
Wed Jul 22 18:25:13 2009
@@ -128,16 +128,15 @@
         Element el;
         // note: setText is called in a separate statement as JDK 5 has problems
         // compiling when it's on one line (compiler generics bug)
-        el = factory.newElement(CMIS.TYPE_ID, dt);
+        el = factory.newElement(CMIS.ID, dt);
         el.setText(type.getId());
+        // TODO localName, localNamespace
         el = factory.newElement(CMIS.QUERY_NAME, dt);
         el.setText(type.getQueryName());
         el = factory.newElement(CMIS.DISPLAY_NAME, dt);
         el.setText(type.getDisplayName());
-        el = factory.newElement(CMIS.BASE_TYPE, dt);
+        el = factory.newElement(CMIS.BASE_TYPE_ID, dt);
         el.setText(type.getBaseType().toString());
-        el = factory.newElement(CMIS.BASE_TYPE_QUERY_NAME, dt);
-        el.setText(type.getBaseTypeQueryName());
         el = factory.newElement(CMIS.PARENT_ID, dt);
         el.setText(type.getParentId());
         el = factory.newElement(CMIS.DESCRIPTION, dt);
@@ -150,12 +149,13 @@
         el.setText(bool(type.isQueryable()));
         el = factory.newElement(CMIS.CONTROLLABLE, dt);
         el.setText(bool(type.isControllable()));
-        el = factory.newElement(CMIS.VERSIONABLE, dt);
-        el.setText(bool(type.isVersionable()));
-        el = factory.newElement(CMIS.CONTENT_STREAM_ALLOWED, dt);
-        el.setText(type.getContentStreamAllowed().toString()); // TODO null
         el = factory.newElement(CMIS.INCLUDED_IN_SUPERTYPE_QUERY, dt);
         el.setText(bool(type.isIncludedInSuperTypeQuery()));
+        el = factory.newElement(CMIS.VERSIONABLE, dt); // docs only
+        el.setText(bool(type.isVersionable()));
+        el = factory.newElement(CMIS.CONTENT_STREAM_ALLOWED, dt); // docs only
+        el.setText(type.getContentStreamAllowed().toString()); // TODO null
+        // TODO allowedSourceTypes, allowedTargetTypes
         if ("true".equals(request.getParameter("includePropertyDefinitions"))) {
             for (PropertyDefinition pd : type.getPropertyDefinitions()) {
                 QName qname;

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/CMIS.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/CMIS.java?rev=796821&r1=796820&r2=796821&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/CMIS.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/CMIS.java
Wed Jul 22 18:25:13 2009
@@ -89,16 +89,12 @@
 
     public static final QName POLICY_TYPE = CMISName("policyType");
 
-    public static final QName TYPE_ID = CMISName("typeId");
+    public static final QName BASE_TYPE_ID = CMISName("baseTypeId");
 
     public static final QName QUERY_NAME = CMISName("queryName");
 
     public static final QName DISPLAY_NAME = CMISName("displayName");
 
-    public static final QName BASE_TYPE = CMISName("baseType");
-
-    public static final QName BASE_TYPE_QUERY_NAME = CMISName("baseTypeQueryName");
-
     public static final QName PARENT_ID = CMISName("parentId");
 
     public static final QName DESCRIPTION = CMISName("description");

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/abdera/PropertiesElement.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/abdera/PropertiesElement.java?rev=796821&r1=796820&r2=796821&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/abdera/PropertiesElement.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/abdera/PropertiesElement.java
Wed Jul 22 18:25:13 2009
@@ -163,7 +163,7 @@
             setProperty(values.get(name), propertyDefinition);
 
             // Alfresco COMPAT (BaseType not in 0.6)
-            if (name.equals(Property.TYPE_ID)) {
+            if (name.equals(Property.BASE_TYPE_ID)) {
                 // emit BaseType as well
                 ExtensibleElement el = addExtension(CMIS.PROPERTY_STRING);
                 el.setAttributeValue(CMIS.NAME, "BaseType");

Modified: incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/base/BaseObject.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/base/BaseObject.java?rev=796821&r1=796820&r2=796821&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/base/BaseObject.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/base/BaseObject.java
Wed Jul 22 18:25:13 2009
@@ -145,6 +145,10 @@
         return getId(Property.TYPE_ID);
     }
 
+    public String getBaseTypeId() {
+        return getId(Property.BASE_TYPE_ID);
+    }
+
     public String getCreatedBy() {
         return getString(Property.CREATED_BY);
     }

Modified: incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleConnection.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleConnection.java?rev=796821&r1=796820&r2=796821&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleConnection.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleConnection.java
Wed Jul 22 18:25:13 2009
@@ -103,7 +103,8 @@
     }
 
     public SimpleObjectEntry newObjectEntry(String typeId) {
-        return new SimpleObjectEntry(new SimpleData(typeId), this);
+        BaseType baseType = repository.getType(typeId).getBaseType();
+        return new SimpleObjectEntry(new SimpleData(typeId, baseType), this);
     }
 
     public Document newDocument(String typeId, Folder folder) {
@@ -380,10 +381,11 @@
             Map<String, Serializable> properties, ObjectId folder,
             ContentStream contentStream, VersioningState versioningState) {
         Type type = repository.getType(typeId);
-        if (type == null || type.getBaseType() != BaseType.DOCUMENT) {
+        BaseType baseType = type.getBaseType();
+        if (type == null || baseType != BaseType.DOCUMENT) {
             throw new IllegalArgumentException(typeId);
         }
-        SimpleData data = new SimpleData(typeId);
+        SimpleData data = new SimpleData(typeId, baseType);
         data.putAll(properties);
         if (folder != null) {
             data.put(Property.PARENT_ID, folder.getId());

Modified: incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleData.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleData.java?rev=796821&r1=796820&r2=796821&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleData.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleData.java
Wed Jul 22 18:25:13 2009
@@ -19,6 +19,7 @@
 import java.io.Serializable;
 import java.util.concurrent.ConcurrentHashMap;
 
+import org.apache.chemistry.BaseType;
 import org.apache.chemistry.Property;
 
 /**
@@ -31,8 +32,9 @@
 
     private static final long serialVersionUID = 1L;
 
-    public SimpleData(String typeId) {
+    public SimpleData(String typeId, BaseType baseType) {
         put(Property.TYPE_ID, typeId);
+        put(Property.BASE_TYPE_ID, baseType.toString());
     }
 
 }

Modified: incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleObject.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleObject.java?rev=796821&r1=796820&r2=796821&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleObject.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleObject.java
Wed Jul 22 18:25:13 2009
@@ -120,6 +120,10 @@
         return type;
     }
 
+    public BaseType getBaseType() {
+        return type.getBaseType();
+    }
+
     public Serializable getValue(String name) {
         PropertyDefinition pd = getType().getPropertyDefinition(name);
         if (pd == null) {

Modified: incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleObjectEntry.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleObjectEntry.java?rev=796821&r1=796820&r2=796821&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleObjectEntry.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleObjectEntry.java
Wed Jul 22 18:25:13 2009
@@ -21,6 +21,7 @@
 import java.util.HashMap;
 import java.util.Map;
 
+import org.apache.chemistry.BaseType;
 import org.apache.chemistry.ObjectEntry;
 import org.apache.chemistry.Property;
 
@@ -48,6 +49,10 @@
         return (String) data.get(Property.TYPE_ID);
     }
 
+    public BaseType getBaseType() {
+        return BaseType.get((String) data.get(Property.BASE_TYPE_ID));
+    }
+
     public Map<String, Serializable> getValues() {
         return new HashMap<String, Serializable>(data);
     }

Modified: incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleRepository.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleRepository.java?rev=796821&r1=796820&r2=796821&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleRepository.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleRepository.java
Wed Jul 22 18:25:13 2009
@@ -26,6 +26,7 @@
 import java.util.UUID;
 import java.util.concurrent.ConcurrentHashMap;
 
+import org.apache.chemistry.BaseType;
 import org.apache.chemistry.Connection;
 import org.apache.chemistry.JoinCapability;
 import org.apache.chemistry.ObjectId;
@@ -65,7 +66,7 @@
         children = new ConcurrentHashMap<String, Set<String>>();
         parents = new ConcurrentHashMap<String, Set<String>>();
 
-        SimpleData rootData = new SimpleData(ROOT_TYPE_ID);
+        SimpleData rootData = new SimpleData(ROOT_TYPE_ID, BaseType.FOLDER);
         if (rootId == null) {
             rootId = generateId();
         }

Modified: incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleType.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleType.java?rev=796821&r1=796820&r2=796821&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleType.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleType.java
Wed Jul 22 18:25:13 2009
@@ -49,6 +49,11 @@
             PropertyType.ID, false, null, false, true, null,
             Updatability.READ_ONLY, true, true, 0, null, null, -1, null);
 
+    public static final SimplePropertyDefinition PROP_BASE_TYPE_ID = new SimplePropertyDefinition(
+            Property.BASE_TYPE_ID, "def:basetypeid", "Base Type ID", "", false,
+            PropertyType.ID, false, null, false, true, null,
+            Updatability.READ_ONLY, true, true, 0, null, null, -1, null);
+
     public static final SimplePropertyDefinition PROP_CREATED_BY = new SimplePropertyDefinition(
             Property.CREATED_BY, "def:createdby", "Created By", "", false,
             PropertyType.STRING, false, null, false, true, null,
@@ -188,10 +193,10 @@
             PropertyType.STRING, false, null, false, true, null,
             Updatability.READ_WRITE, true, true, 0, null, null, -1, null);
 
-    private static final PropertyDefinition[] PROPS_COMMON = {
-            PROP_ID, //
+    private static final PropertyDefinition[] PROPS_COMMON = { PROP_ID, //
             PROP_URI, //
             PROP_TYPE_ID, //
+            PROP_BASE_TYPE_ID, //
             PROP_CREATED_BY, //
             PROP_CREATION_DATE, //
             PROP_LAST_MODIFIED_BY, //
@@ -354,20 +359,6 @@
         return baseType;
     }
 
-    public String getBaseTypeQueryName() {
-        switch (baseType) {
-        case DOCUMENT:
-            return "Document";
-        case FOLDER:
-            return "Folder";
-        case POLICY:
-            return "Policy";
-        case RELATIONSHIP:
-            return "Relationship";
-        }
-        throw new UnsupportedOperationException(baseType.toString());
-    }
-
     public String getDescription() {
         return description;
     }

Modified: incubator/chemistry/trunk/chemistry/chemistry-commons/src/test/java/org/apache/chemistry/impl/simple/TestSimpleRepository.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-commons/src/test/java/org/apache/chemistry/impl/simple/TestSimpleRepository.java?rev=796821&r1=796820&r2=796821&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-commons/src/test/java/org/apache/chemistry/impl/simple/TestSimpleRepository.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-commons/src/test/java/org/apache/chemistry/impl/simple/TestSimpleRepository.java
Wed Jul 22 18:25:13 2009
@@ -116,7 +116,8 @@
         Connection conn = repo.getConnection(null);
         Folder root = conn.getRootFolder();
         Folder f1 = root.newFolder("fold");
-        assertEquals(12 + 1, f1.getType().getPropertyDefinitions().size());
+        assertEquals(SimpleType.PROPS_FOLDER_BASE.size() + 2,
+                f1.getType().getPropertyDefinitions().size());
 
         List<CMISObject> children = root.getChildren(null);
         assertEquals(0, children.size());
@@ -140,7 +141,8 @@
         Connection conn = repo.getConnection(null);
         Folder root = conn.getRootFolder();
         Document d1 = root.newDocument("doc");
-        assertEquals(22 + 3, d1.getType().getPropertyDefinitions().size());
+        assertEquals(SimpleType.PROPS_DOCUMENT_BASE.size() + 3,
+                d1.getType().getPropertyDefinitions().size());
 
         d1.save();
         assertEquals(root.getId(), d1.getParent().getId());

Modified: incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrDocument.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrDocument.java?rev=796821&r1=796820&r2=796821&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrDocument.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrDocument.java
Wed Jul 22 18:25:13 2009
@@ -153,8 +153,7 @@
         throw new UnsupportedOperationException();
     }
 
-    @Override
-    protected BaseType getBaseType() {
+    public BaseType getBaseType() {
         return BaseType.DOCUMENT;
     }
 }

Modified: incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrFolder.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrFolder.java?rev=796821&r1=796820&r2=796821&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrFolder.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrFolder.java
Wed Jul 22 18:25:13 2009
@@ -63,7 +63,7 @@
                 } else {
                     continue;
                 }
-                if (type == null || type == entry.getType().getBaseType()) {
+                if (type == null || type == entry.getBaseType()) {
                     result.add(entry);
                 }
             }
@@ -136,8 +136,7 @@
         throw new UnsupportedOperationException();
     }
 
-    @Override
-    protected BaseType getBaseType() {
+    public BaseType getBaseType() {
         return BaseType.FOLDER;
     }
 }

Modified: incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrObjectEntry.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrObjectEntry.java?rev=796821&r1=796820&r2=796821&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrObjectEntry.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrObjectEntry.java
Wed Jul 22 18:25:13 2009
@@ -32,7 +32,6 @@
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
 
-import org.apache.chemistry.BaseType;
 import org.apache.chemistry.Document;
 import org.apache.chemistry.Folder;
 import org.apache.chemistry.ObjectEntry;
@@ -350,8 +349,6 @@
         return null;
     }
 
-    protected abstract BaseType getBaseType();
-
     public String getTypeId() {
         return getType().getId();
     }

Modified: incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrType.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrType.java?rev=796821&r1=796820&r2=796821&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrType.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrType.java
Wed Jul 22 18:25:13 2009
@@ -50,10 +50,6 @@
         return baseType;
     }
 
-    public String getBaseTypeQueryName() {
-        return baseType.toString();
-    }
-
     public ContentStreamPresence getContentStreamAllowed() {
         if (baseType == BaseType.DOCUMENT) {
             return ContentStreamPresence.ALLOWED;



Mime
View raw message