You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by fg...@apache.org on 2010/03/03 17:22:45 UTC

svn commit: r918547 - 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/main/java/org/apache/chemistry/ato...

Author: fguillaume
Date: Wed Mar  3 16:22:44 2010
New Revision: 918547

URL: http://svn.apache.org/viewvc?rev=918547&view=rev
Log:
Framework for Allowable Actions.

Added:
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/AllowableActionsReader.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISAllowableActionsEntry.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/abdera/AllowableActionsDocument.java   (with props)
Modified:
    incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/AllowableAction.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/SPI.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/APPObjectEntry.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPObjectEntryReader.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/Connector.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/stax/AbstractObjectReader.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISCollection.java
    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/CMISProvider.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISWorkspaceManager.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/abdera/AllowableActionsElement.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/abdera/ObjectElement.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/SimpleObjectEntry.java
    incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrConnection.java
    incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrObjectEntry.java
    incubator/chemistry/trunk/chemistry/chemistry-tests/src/main/java/org/apache/chemistry/test/BasicTestCase.java

Modified: incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/AllowableAction.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/AllowableAction.java?rev=918547&r1=918546&r2=918547&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/AllowableAction.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/AllowableAction.java Wed Mar  3 16:22:44 2010
@@ -33,162 +33,155 @@
     private AllowableAction() {
     }
 
-    public static final QName CAN_DELETE_OBJECT = CMISName("canDeleteObject");
+    public static final QName CAN_GET_DESCENDANTS = CMISName("canGetDescendants");
 
-    public static final QName CAN_UPDATE_PROPERTIES = CMISName("canUpdateProperties");
+    public static final QName CAN_GET_FOLDER_TREE = CMISName("canGetFolderTree");
 
-    public static final QName CAN_GET_PROPERTIES = CMISName("canGetProperties");
+    public static final QName CAN_GET_CHILDREN = CMISName("canGetChildren");
 
-    public static final QName CAN_GET_OBJECT_RELATIONSHIPS = CMISName("canGetRelationships");
+    public static final QName CAN_GET_FOLDER_PARENT = CMISName("canGetFolderParent");
 
     public static final QName CAN_GET_OBJECT_PARENTS = CMISName("canGetObjectParents");
 
-    public static final QName CAN_GET_FOLDER_PARENT = CMISName("canGetFolderParent");
+    public static final QName CAN_CREATE_DOCUMENT = CMISName("canCreateDocument");
 
-    public static final QName CAN_GET_DESCENDANTS = CMISName("canGetDescendants");
+    public static final QName CAN_CREATE_FOLDER = CMISName("canCreateFolder");
 
-    public static final QName CAN_GET_FOLDER_TREE = CMISName("canGetFolderTree");
+    public static final QName CAN_CREATE_RELATIONSHIP = CMISName("canCreateRelationship");
 
-    public static final QName CAN_MOVE_OBJECT = CMISName("canMoveObject");
+    public static final QName CAN_GET_PROPERTIES = CMISName("canGetProperties");
 
-    public static final QName CAN_DELETE_CONTENT_STREAM = CMISName("canDeleteContentStream");
+    public static final QName CAN_GET_RENDITIONS = CMISName("canGetRenditions");
 
-    public static final QName CAN_CHECK_OUT = CMISName("canCheckOut");
+    public static final QName CAN_GET_CONTENT_STREAM = CMISName("canGetContentStream");
 
-    public static final QName CAN_CANCEL_CHECK_OUT = CMISName("canCancelCheckOut");
+    public static final QName CAN_UPDATE_PROPERTIES = CMISName("canUpdateProperties");
 
-    public static final QName CAN_CHECK_IN = CMISName("canCheckIn");
+    public static final QName CAN_MOVE_OBJECT = CMISName("canMoveObject");
+
+    public static final QName CAN_DELETE_OBJECT = CMISName("canDeleteObject");
 
     public static final QName CAN_SET_CONTENT_STREAM = CMISName("canSetContentStream");
 
-    public static final QName CAN_GET_ALL_VERSIONS = CMISName("canGetAllVersions");
+    public static final QName CAN_DELETE_CONTENT_STREAM = CMISName("canDeleteContentStream");
+
+    public static final QName CAN_DELETE_TREE = CMISName("canDeleteTree");
 
     public static final QName CAN_ADD_OBJECT_TO_FOLDER = CMISName("canAddObjectToFolder");
 
     public static final QName CAN_REMOVE_OBJECT_FROM_FOLDER = CMISName("canRemoveObjectFromFolder");
 
-    public static final QName CAN_GET_CONTENT_STREAM = CMISName("canGetContentStream");
-
-    public static final QName CAN_APPLY_POLICY = CMISName("canApplyPolicy");
-
-    public static final QName CAN_GET_APPLIED_POLICIES = CMISName("canGetAppliedPolicies");
-
-    public static final QName CAN_REMOVE_POLICY = CMISName("canRemovePolicy");
+    public static final QName CAN_CHECK_OUT = CMISName("canCheckOut");
 
-    public static final QName CAN_GET_CHILDREN = CMISName("canGetChildren");
+    public static final QName CAN_CANCEL_CHECK_OUT = CMISName("canCancelCheckOut");
 
-    public static final QName CAN_CREATE_DOCUMENT = CMISName("canCreateDocument");
+    public static final QName CAN_CHECK_IN = CMISName("canCheckIn");
 
-    public static final QName CAN_CREATE_FOLDER = CMISName("canCreateFolder");
+    public static final QName CAN_GET_ALL_VERSIONS = CMISName("canGetAllVersions");
 
-    public static final QName CAN_CREATE_RELATIONSHIP = CMISName("canCreateRelationship");
+    public static final QName CAN_GET_OBJECT_RELATIONSHIPS = CMISName("canGetObjectRelationships");
 
-    public static final QName CAN_CREATE_POLICY = CMISName("canCreatePolicy");
+    public static final QName CAN_APPLY_POLICY = CMISName("canApplyPolicy");
 
-    public static final QName CAN_DELETE_TREE = CMISName("canDeleteTree");
+    public static final QName CAN_REMOVE_POLICY = CMISName("canRemovePolicy");
 
-    public static final QName CAN_GET_RENDITIONS = CMISName("canGetRenditions");
+    public static final QName CAN_GET_APPLIED_POLICIES = CMISName("canGetAppliedPolicies");
 
     public static final QName CAN_GET_ACL = CMISName("canGetACL");
 
     public static final QName CAN_APPLY_ACL = CMISName("canApplyACL");
 
     public static List<QName> DEFAULT = Collections.unmodifiableList(Arrays.asList(
-            CAN_DELETE_OBJECT, //
-            CAN_UPDATE_PROPERTIES, //
-            CAN_GET_PROPERTIES, //
-            CAN_GET_OBJECT_RELATIONSHIPS, //
-            CAN_GET_OBJECT_PARENTS, //
-            CAN_GET_FOLDER_PARENT, //
             CAN_GET_DESCENDANTS, //
             CAN_GET_FOLDER_TREE, //
+            CAN_GET_CHILDREN, //
+            CAN_GET_FOLDER_PARENT, //
+            CAN_GET_OBJECT_PARENTS, //
+            CAN_CREATE_DOCUMENT, //
+            CAN_CREATE_FOLDER, //
+            CAN_CREATE_RELATIONSHIP, //
+            CAN_GET_PROPERTIES, //
+            CAN_GET_RENDITIONS, //
+            CAN_GET_CONTENT_STREAM, //
+            CAN_UPDATE_PROPERTIES, //
             CAN_MOVE_OBJECT, //
+            CAN_DELETE_OBJECT, //
+            CAN_SET_CONTENT_STREAM, //
             CAN_DELETE_CONTENT_STREAM, //
+            CAN_DELETE_TREE, //
+            CAN_ADD_OBJECT_TO_FOLDER, //
+            CAN_REMOVE_OBJECT_FROM_FOLDER, //
             CAN_CHECK_OUT, //
             CAN_CANCEL_CHECK_OUT, //
             CAN_CHECK_IN, //
-            CAN_SET_CONTENT_STREAM, //
             CAN_GET_ALL_VERSIONS, //
-            CAN_ADD_OBJECT_TO_FOLDER, //
-            CAN_REMOVE_OBJECT_FROM_FOLDER, //
-            CAN_GET_CONTENT_STREAM, //
+            CAN_GET_OBJECT_RELATIONSHIPS, //
             CAN_APPLY_POLICY, //
-            CAN_GET_APPLIED_POLICIES, //
             CAN_REMOVE_POLICY, //
-            CAN_GET_CHILDREN, //
-            CAN_CREATE_DOCUMENT, //
-            CAN_CREATE_FOLDER, //
-            CAN_CREATE_RELATIONSHIP, //
-            CAN_CREATE_POLICY, //
-            CAN_DELETE_TREE, //
-            CAN_GET_RENDITIONS, //
+            CAN_GET_APPLIED_POLICIES, //
             CAN_GET_ACL, //
             CAN_APPLY_ACL //
     ));
 
-    // keys for permissions mapping TODO
-
     public static final String GET_DESCENDENTS_FOLDER = "canGetDescendents.Folder";
 
-    public static final String GET_CHILDREN_FOLDER = "canGetChildren.Folder";
+    public static final String GET_FOLDER_TREE_FOLDER = "canGetFolderTree.Folder";
 
-    public static final String GET_PARENTS_FOLDER = "canGetParents.Folder";
+    public static final String GET_CHILDREN_FOLDER = "canGetChildren.Folder";
 
-    public static final String GET_FOLDER_PARENT_OBJECT = "canGetFolderParent.Object";
+    public static final String GET_FOLDER_PARENT_FOLDER = "canGetFolderParent.Folder";
 
-    public static final String CREATE_DOCUMENT_TYPE = "canCreateDocument.Type";
+    public static final String GET_OBJECT_PARENTS_OBJECT = "canGetObjectParents.Object";
 
     public static final String CREATE_DOCUMENT_FOLDER = "canCreateDocument.Folder";
 
-    public static final String CREATE_FOLDER_TYPE = "canCreateFolder.Type";
-
     public static final String CREATE_FOLDER_FOLDER = "canCreateFolder.Folder";
 
-    public static final String CREATE_RELATIONSHIP_TYPE = "canCreateRelationship.Type";
-
     public static final String CREATE_RELATIONSHIP_SOURCE = "canCreateRelationship.Source";
 
     public static final String CREATE_RELATIONSHIP_TARGET = "canCreateRelationship.Target";
 
-    public static final String CREATE_POLICY_TYPE = "canCreatePolicy.Type";
-
     public static final String GET_PROPERTIES_OBJECT = "canGetProperties.Object";
 
-    public static final String VIEW_CONTENT_OBJECT = "canViewContent.Object";
+    public static final String GET_RENDITIONS_OBJECT = "canGetRenditions.Object";
+
+    public static final String GET_CONTENT_STREAM_OBJECT = "canGetContentStream.Object";
 
     public static final String UPDATE_PROPERTIES_OBJECT = "canUpdateProperties.Object";
 
-    public static final String MOVE_OBJECT = "canMove.Object";
+    public static final String MOVE_OBJECT_OBJECT = "canMoveObject.Object";
 
-    public static final String MOVE_TARGET = "canMove.Target";
+    public static final String MOVE_OBJECT_TARGET = "canMoveObject.Target";
 
-    public static final String MOVE_SOURCE = "canMove.Source";
+    public static final String MOVE_OBJECT_SOURCE = "canMoveObject.Source";
 
     public static final String DELETE_OBJECT = "canDelete.Object";
 
-    public static final String DELETE_TREE_FOLDER = "canDeleteTree.Folder";
+    public static final String DELETE_FOLDER = "canDelete.Folder";
 
-    public static final String SET_CONTENT_DOCUMENT = "canSetContent.Document";
+    public static final String SET_CONTENT_STREAM_DOCUMENT = "canSetContentStream.Document";
 
-    public static final String DELETE_CONTENT_DOCUMENT = "canDeleteContent.Document";
+    public static final String DELETE_CONTENT_STREAM_DOCUMENT = "canDeleteContentStream.Document";
+
+    public static final String DELETE_TREE_FOLDER = "canDeleteTree.Folder";
 
     public static final String ADD_TO_FOLDER_OBJECT = "canAddToFolder.Object";
 
     public static final String ADD_TO_FOLDER_FOLDER = "canAddToFolder.Folder";
 
-    public static final String REMOVE_FROM_FOLDER_OBJECT = "canRemoveFromFolder.Object";
+    public static final String REMOVE_FROM_OBJECT_FROM_FOLDER_OBJECT = "canRemoveObjectFromFolder.Object";
 
-    public static final String REMOVE_FROM_FOLDER_FOLDER = "canRemoveFromFolder.Folder";
+    public static final String REMOVE_FROM_OBJECT_FROM_FOLDER_FOLDER = "canRemoveObjectFromFolder.Folder";
 
     public static final String CHECK_OUT_DOCUMENT = "canCheckOut.Document";
 
-    public static final String CANCEL_CHECK_OUT_DOCUMENT = "canCancelCheckOut.Document";
+    public static final String CANCEL_CHECK_OUT_DOCUMENT = "canCancelCheckout.Document";
 
     public static final String CHECK_IN_DOCUMENT = "canCheckIn.Document";
 
-    public static final String GET_ALL_VERSIONS_VERSIONSERIES = "canGetAllVersions.VersionSeries";
+    public static final String GET_ALL_VERSIONS_DOCUMENT = "canGetAllVersions.Document";
 
-    public static final String GET_RELATIONSHIP_OBJECT = "canGetRelationship.Object";
+    public static final String GET_OBJECT_RELATIONSHIPS_OBJECT = "canGetObjectRelationships.Object";
 
     public static final String ADD_POLICY_OBJECT = "canAddPolicy.Object";
 

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=918547&r1=918546&r2=918547&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 Mar  3 16:22:44 2010
@@ -19,6 +19,7 @@
 import java.io.Serializable;
 import java.util.Collection;
 import java.util.Map;
+import java.util.Set;
 
 import javax.xml.namespace.QName;
 
@@ -114,8 +115,10 @@
 
     /**
      * The allowable actions, if fetched.
+     *
+     * @return a set of allowable actions, or {@code null} if not fecthed
      */
-    Map<QName, Boolean> getAllowableActions();
+    Set<QName> getAllowableActions();
 
     /**
      * The relationships in relation to this document, if fetched.

Modified: incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/SPI.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/SPI.java?rev=918547&r1=918546&r2=918547&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/SPI.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/SPI.java Wed Mar  3 16:22:44 2010
@@ -21,6 +21,7 @@
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import javax.xml.namespace.QName;
 
@@ -318,14 +319,16 @@
     /**
      * Gets the allowable actions.
      * <p>
-     * Returns the list of allowable actions on an object based on the current
+     * Returns the set of allowable actions on an object based on the current
      * user's context, subject to any access constraints that are currently
      * imposed by the repository.
      *
      * @param object the object
-     * @return the allowable actions
+     * @return the set of allowable actions
+     * @see AllowableAction
+     * @see AllowableAction#DEFAULT
      */
-    Collection<QName> getAllowableActions(ObjectId object);
+    Set<QName> getAllowableActions(ObjectId object);
 
     // TODO 1.0 getObject
 

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=918547&r1=918546&r2=918547&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 Mar  3 16:22:44 2010
@@ -27,6 +27,7 @@
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.Map.Entry;
 
 import javax.xml.namespace.QName;
@@ -81,8 +82,8 @@
     public APPConnection(APPRepository repository,
             Map<String, Serializable> params) {
         this.repository = repository;
-        connector = new Connector(repository.getClient(params),
-                new APPContext(this));
+        connector = new Connector(repository.getClient(params), new APPContext(
+                this));
     }
 
     public Connection getConnection() {
@@ -289,23 +290,30 @@
      * ----- Object Services -----
      */
 
-    // TODO add hints about what we'd like to fetch from the entry (stream,
-    // props, etc.)
-    protected APPObjectEntry getObjectEntry(ObjectId objectId) {
+    protected APPObjectEntry getObjectEntryOrNull(ObjectId objectId) {
         if (objectId instanceof APPObjectEntry) {
             return (APPObjectEntry) objectId;
         } else if (objectId instanceof APPObject) {
             return ((APPObject) objectId).getEntry();
+        } else {
+            return null;
+        }
+    }
+
+    protected APPObjectEntry getObjectEntry(ObjectId objectId) {
+        return getObjectEntry(objectId, null);
+    }
+
+    protected APPObjectEntry getObjectEntry(ObjectId objectId,
+            Inclusion inclusion) {
+        APPObjectEntry entry = getObjectEntryOrNull(objectId);
+        if (entry != null) {
+            return entry;
         }
         URITemplate uriTemplate = repository.getURITemplate(AtomPubCMIS.URITMPL_OBJECT_BY_ID);
         String href = uriTemplate.template;
         href = replace(href, AtomPubCMIS.PARAM_ID, objectId.getId());
-        href = replace(href, AtomPubCMIS.PARAM_FILTER, "");
-        href = replace(href, AtomPubCMIS.PARAM_RENDITION_FILTER, "");
-        href = replace(href, AtomPubCMIS.PARAM_INCLUDE_RELATIONSHIPS, "");
-        href = replace(href, AtomPubCMIS.PARAM_INCLUDE_ALLOWABLE_ACTIONS, "");
-        href = replace(href, AtomPubCMIS.PARAM_INCLUDE_POLICY_IDS, "");
-        href = replace(href, AtomPubCMIS.PARAM_INCLUDE_ACL, "");
+        href = replaceInclusion(href, inclusion);
         return connector.getEntry(href, objectId.getId());
     }
 
@@ -317,6 +325,25 @@
         return entry;
     }
 
+    protected String replaceInclusion(String href, Inclusion inclusion) {
+        if (inclusion == null) {
+            inclusion = new Inclusion(null, null, null, false, false, false);
+        }
+        href = replace(href, AtomPubCMIS.PARAM_FILTER,
+                inclusion.properties == null ? "" : inclusion.properties);
+        href = replace(href, AtomPubCMIS.PARAM_RENDITION_FILTER,
+                inclusion.renditions == null ? "" : inclusion.renditions);
+        href = replace(href, AtomPubCMIS.PARAM_INCLUDE_RELATIONSHIPS,
+                RelationshipDirection.toInclusion(inclusion.relationships));
+        href = replace(href, AtomPubCMIS.PARAM_INCLUDE_ALLOWABLE_ACTIONS,
+                Boolean.toString(inclusion.allowableActions));
+        href = replace(href, AtomPubCMIS.PARAM_INCLUDE_POLICY_IDS,
+                Boolean.toString(inclusion.policies));
+        href = replace(href, AtomPubCMIS.PARAM_INCLUDE_ACL,
+                Boolean.toString(inclusion.acls));
+        return href;
+    }
+
     protected String replace(String template, String param, String value) {
         return template.replace('{' + param + '}', value);
     }
@@ -409,9 +436,25 @@
         throw new UnsupportedOperationException();
     }
 
-    public Collection<QName> getAllowableActions(ObjectId object) {
-        // TODO Auto-generated method stub
-        throw new UnsupportedOperationException();
+    public Set<QName> getAllowableActions(ObjectId object) {
+        APPObjectEntry entry = getObjectEntryOrNull(object);
+        if (entry != null && entry.getAllowableActions() == null) {
+            // use the allowable action link
+            String href = entry.getLink(AtomPubCMIS.LINK_ALLOWABLE_ACTIONS);
+            if (href == null) {
+                throw new CMISRuntimeException("Missing allowableactions link");
+            }
+            Set<QName> allowableActions = connector.getAllowableActions(href);
+            entry.setAllowableActions(allowableActions);
+            return allowableActions;
+        }
+        if (entry == null) {
+            // fetch including allowableActions
+            Inclusion inclusion = new Inclusion(null, null, null, true, false,
+                    false);
+            entry = getObjectEntry(object, inclusion);
+        }
+        return entry.getAllowableActions();
     }
 
     public ObjectEntry getProperties(ObjectId object, Inclusion inclusion) {
@@ -445,12 +488,7 @@
         String encodedPath = path.replace(" ", "%20");
         String href = uriTemplate.template;
         href = replace(href, AtomPubCMIS.PARAM_PATH, encodedPath);
-        href = replace(href, AtomPubCMIS.PARAM_FILTER, "");
-        href = replace(href, AtomPubCMIS.PARAM_RENDITION_FILTER, "");
-        href = replace(href, AtomPubCMIS.PARAM_INCLUDE_RELATIONSHIPS, "");
-        href = replace(href, AtomPubCMIS.PARAM_INCLUDE_ALLOWABLE_ACTIONS, "");
-        href = replace(href, AtomPubCMIS.PARAM_INCLUDE_POLICY_IDS, "");
-        href = replace(href, AtomPubCMIS.PARAM_INCLUDE_ACL, "");
+        href = replaceInclusion(href, inclusion);
         try {
             return connector.getEntry(href, path);
             // TODO fill current

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=918547&r1=918546&r2=918547&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 Mar  3 16:22:44 2010
@@ -26,6 +26,7 @@
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.Map.Entry;
 import java.util.regex.Pattern;
 
@@ -62,7 +63,7 @@
 
     protected ContentStream localContentStream = REMOTE_CONTENT_STREAM;
 
-    protected Map<QName, Boolean> allowableActions;
+    protected Set<QName> allowableActions;
 
     protected String remoteContentHref;
 
@@ -112,22 +113,19 @@
 
     protected APPObjectEntry(APPRepository repository,
             APPConnection connection, Map<String, XmlProperty> properties,
-            Map<QName, Boolean> allowableActions) {
+            Set<QName> allowableActions) {
         this.repository = repository;
         this.connection = connection;
         this.properties = properties;
-        if (allowableActions == null) {
-            allowableActions = Collections.emptyMap();
-        } else {
-            allowableActions = Collections.unmodifiableMap(allowableActions);
+        if (allowableActions != null) {
+            allowableActions = Collections.unmodifiableSet(allowableActions);
         }
         this.allowableActions = allowableActions;
         links = new ArrayList<Link>();
     }
 
     public APPObjectEntry(APPConnection connection,
-            Map<String, XmlProperty> properties,
-            Map<QName, Boolean> allowableActions) {
+            Map<String, XmlProperty> properties, Set<QName> allowableActions) {
         this((APPRepository) connection.getRepository(), connection,
                 properties, allowableActions);
     }
@@ -296,7 +294,11 @@
     // return null;
     // }
 
-    public Map<QName, Boolean> getAllowableActions() {
+    public void setAllowableActions(Set<QName> allowableActions) {
+        this.allowableActions = allowableActions;
+    }
+
+    public Set<QName> getAllowableActions() {
         return allowableActions;
     }
 

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPObjectEntryReader.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPObjectEntryReader.java?rev=918547&r1=918546&r2=918547&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPObjectEntryReader.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPObjectEntryReader.java Wed Mar  3 16:22:44 2010
@@ -20,7 +20,7 @@
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
+import java.util.Set;
 
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamException;
@@ -51,8 +51,8 @@
 
     @Override
     protected void setAllowableActions(APPObjectEntry object,
-            Map<QName, Boolean> allowableActions) {
-        object.allowableActions = Collections.unmodifiableMap(allowableActions);
+            Set<QName> allowableActions) {
+        object.allowableActions = Collections.unmodifiableSet(allowableActions);
     }
 
     @Override

Added: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/AllowableActionsReader.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/AllowableActionsReader.java?rev=918547&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/AllowableActionsReader.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/AllowableActionsReader.java Wed Mar  3 16:22:44 2010
@@ -0,0 +1,68 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Authors:
+ *     Florent Guillaume, Nuxeo
+ */
+package org.apache.chemistry.atompub.client;
+
+import java.io.InputStream;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.chemistry.CMIS;
+import org.apache.chemistry.atompub.client.stax.EntryReader;
+import org.apache.chemistry.xml.stax.ChildrenNavigator;
+import org.apache.chemistry.xml.stax.StaxReader;
+
+/**
+ * Reader for AllowableActions objects.
+ */
+public class AllowableActionsReader implements EntryReader<Set<QName>> {
+
+    private static final String AA_PREFIX = "can";
+
+    public Set<QName> read(APPContext ctx, InputStream in)
+            throws XMLStreamException {
+        return read(ctx, StaxReader.newReader(in));
+    }
+
+    public Set<QName> read(APPContext ctx, XMLStreamReader reader)
+            throws XMLStreamException {
+        return read(ctx, StaxReader.newReader(reader));
+    }
+
+    public Set<QName> read(APPContext ctx, StaxReader reader)
+            throws XMLStreamException {
+        if (!reader.getFirstTag(CMIS.ALLOWABLE_ACTIONS)) {
+            return null;
+        }
+        Set<QName> set = new HashSet<QName>();
+        ChildrenNavigator children = reader.getChildren();
+        while (children.next()) {
+            if (reader.getNamespaceURI().equals(CMIS.CMIS_NS)
+                    || reader.getLocalName().startsWith(AA_PREFIX)) {
+                boolean bool = Boolean.parseBoolean(reader.getElementText());
+                if (bool) {
+                    set.add(reader.getName());
+                }
+            }
+        }
+        return set;
+    }
+
+}

Propchange: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/AllowableActionsReader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/AllowableActionsReader.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/Connector.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/Connector.java?rev=918547&r1=918546&r2=918547&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/Connector.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/Connector.java Wed Mar  3 16:22:44 2010
@@ -22,7 +22,9 @@
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.util.List;
+import java.util.Set;
 
+import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamException;
 
 import org.apache.chemistry.ConstraintViolationException;
@@ -185,6 +187,11 @@
 
     }
 
+    public Set<QName> getAllowableActions(String href) {
+        return getObject(href, "", new AllowableActionsReader());
+    }
+
+
     public APPObjectEntry putEntry(String href, Header header,
             APPObjectEntry entry) {
         RequestEntity requestEntity = new XmlObjectWriterRequestEntity<ObjectEntry>(

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/stax/AbstractObjectReader.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/stax/AbstractObjectReader.java?rev=918547&r1=918546&r2=918547&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/stax/AbstractObjectReader.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/stax/AbstractObjectReader.java Wed Mar  3 16:22:44 2010
@@ -18,9 +18,9 @@
  */
 package org.apache.chemistry.atompub.client.stax;
 
-import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
-import java.util.Map;
+import java.util.Set;
 
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamException;
@@ -44,7 +44,7 @@
     protected abstract void setProperty(T object, XmlProperty p);
 
     protected abstract void setAllowableActions(T object,
-            Map<QName, Boolean> allowableActions);
+            Set<QName> allowableActions);
 
     protected abstract void setPathSegment(T object, String pathSegment);
 
@@ -114,12 +114,12 @@
 
     protected void readAllowableActions(APPContext ctx, StaxReader reader,
             T object) throws XMLStreamException {
-        Map<QName, Boolean> allowableActions = new HashMap<QName, Boolean>();
+        Set<QName> allowableActions = new HashSet<QName>();
         ChildrenNavigator children = reader.getChildren();
         while (children.next()) {
-            QName qname = reader.getName();
-            Boolean bool = Boolean.valueOf(reader.getElementText());
-            allowableActions.put(qname, bool);
+            if (Boolean.parseBoolean(reader.getElementText())) {
+                allowableActions.add(reader.getName());
+            }
         }
         setAllowableActions(object, allowableActions);
     }
@@ -142,7 +142,8 @@
     protected void readChildren(APPContext ctx, StaxReader reader, T object)
             throws XMLStreamException {
         // TODO better use of generics
-        List<Tree<ObjectEntry>> list = new APPObjectFeedTreeReader().read(ctx, reader);
+        List<Tree<ObjectEntry>> list = new APPObjectFeedTreeReader().read(ctx,
+                reader);
         setChildren(object, list);
     }
 

Added: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISAllowableActionsEntry.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISAllowableActionsEntry.java?rev=918547&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISAllowableActionsEntry.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISAllowableActionsEntry.java Wed Mar  3 16:22:44 2010
@@ -0,0 +1,124 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Authors:
+ *     Florent Guillaume, Nuxeo
+ */
+package org.apache.chemistry.atompub.server;
+
+import java.io.Serializable;
+import java.util.Map;
+
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.i18n.text.UrlEncoding;
+import org.apache.abdera.model.Document;
+import org.apache.abdera.model.Element;
+import org.apache.abdera.protocol.server.CollectionAdapter;
+import org.apache.abdera.protocol.server.RequestContext;
+import org.apache.abdera.protocol.server.ResponseContext;
+import org.apache.abdera.protocol.server.context.BaseResponseContext;
+import org.apache.abdera.protocol.server.context.EmptyResponseContext;
+import org.apache.axiom.om.OMContainer;
+import org.apache.chemistry.Inclusion;
+import org.apache.chemistry.ObjectEntry;
+import org.apache.chemistry.Repository;
+import org.apache.chemistry.SPI;
+import org.apache.chemistry.atompub.abdera.AllowableActionsDocument;
+
+/**
+ * CMIS allowableActions document (fetched through {@link #getEntry}).
+ */
+public class CMISAllowableActionsEntry implements CollectionAdapter {
+
+    protected final Repository repository;
+
+    public CMISAllowableActionsEntry(Repository repository) {
+        this.repository = repository;
+    }
+
+    public ResponseContext getEntry(RequestContext request) {
+        SPI spi = getSPI(request);
+        try {
+            String id = getResourceName(request);
+            Inclusion inclusion = new Inclusion(null, null, null, true, false,
+                    false);
+            ObjectEntry object = spi.getProperties(spi.newObjectId(id),
+                    inclusion);
+            if (object == null) {
+                return new EmptyResponseContext(404);
+            }
+            // create resulting document
+            Factory factory = request.getAbdera().getFactory();
+            Document<Element> doc = factory.newDocument();
+            AllowableActionsDocument el = new AllowableActionsDocument(
+                    (OMContainer) doc, factory);
+            el.setAllowableActions(object.getAllowableActions());
+            return new BaseResponseContext<Document<Element>>(doc);
+        } catch (Exception e) {
+            return new EmptyResponseContext(500, e.toString());
+        } finally {
+            spi.close();
+        }
+    }
+
+    // duplicated in CMISCollection
+    public SPI getSPI(RequestContext request) {
+        return repository.getSPI(getConnectionParams(request));
+    }
+
+    // duplicated in CMISCollection
+    protected Map<String, Serializable> getConnectionParams(
+            RequestContext request) {
+        return null; // TODO username, password
+    }
+
+    // duplicated in CMISCollection
+    protected String getResourceName(RequestContext request) {
+        String resourceName = request.getTarget().getParameter("objectid");
+        return UrlEncoding.decode(resourceName);
+    }
+
+    public ResponseContext headEntry(RequestContext request) {
+        // TODO just in case
+        return getEntry(request);
+    }
+
+    public ResponseContext deleteEntry(RequestContext request) {
+        throw new UnsupportedOperationException();
+    }
+
+    public ResponseContext extensionRequest(RequestContext request) {
+        throw new UnsupportedOperationException();
+    }
+
+    public ResponseContext getCategories(RequestContext request) {
+        throw new UnsupportedOperationException();
+    }
+
+    public ResponseContext getFeed(RequestContext request) {
+        throw new UnsupportedOperationException();
+    }
+
+    public ResponseContext optionsEntry(RequestContext request) {
+        throw new UnsupportedOperationException();
+    }
+
+    public ResponseContext postEntry(RequestContext request) {
+        throw new UnsupportedOperationException();
+    }
+
+    public ResponseContext putEntry(RequestContext request) {
+        throw new UnsupportedOperationException();
+    }
+
+}

Propchange: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISAllowableActionsEntry.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISAllowableActionsEntry.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISCollection.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISCollection.java?rev=918547&r1=918546&r2=918547&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISCollection.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISCollection.java Wed Mar  3 16:22:44 2010
@@ -179,6 +179,10 @@
         return getEntrylink("file", id, request);
     }
 
+    public String getAllowableActionsLink(String id, RequestContext request) {
+        return getEntrylink("allowableactions", id, request);
+    }
+
     public String getTypeChildrenLink(String tid, RequestContext request) {
         return getCollectionLink("typechildren", tid, request);
     }

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=918547&r1=918546&r2=918547&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 Mar  3 16:22:44 2010
@@ -295,7 +295,9 @@
             entry.addLink(getParentsLink(oid, request), AtomPub.LINK_UP,
                     AtomPub.MEDIA_TYPE_ATOM_FEED, null, null, -1);
         }
-        // entry.addLink("XXX", CMIS.LINK_ALLOWABLE_ACTIONS);
+        entry.addLink(getAllowableActionsLink(oid, request),
+                AtomPubCMIS.LINK_ALLOWABLE_ACTIONS,
+                AtomPubCMIS.MEDIA_TYPE_CMIS_ALLOWABLE_ACTIONS, null, null, -1);
         // entry.addLink("XXX", CMIS.LINK_RELATIONSHIPS);
 
         Type objectType = repository.getType(typeId);

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISProvider.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISProvider.java?rev=918547&r1=918546&r2=918547&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISProvider.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISProvider.java Wed Mar  3 16:22:44 2010
@@ -69,7 +69,7 @@
         targetResolver.setPattern("/object(?:/?)([^/?]*)(\\?.*)?",
                 TargetType.TYPE_ENTRY, "objectid");
         targetResolver.setPattern("/allowableactions/([^/?]+)",
-                TargetType.TYPE_ENTRY, "objectid"); // XXX entry?
+                TargetType.TYPE_ENTRY, "objectid");
         targetResolver.setPattern("/type/([^/?]+)(\\?.*)?",
                 TargetType.TYPE_ENTRY, "typeid");
         targetResolver.setPattern("/path/([^?]*)(\\?.*)?",

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISWorkspaceManager.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISWorkspaceManager.java?rev=918547&r1=918546&r2=918547&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISWorkspaceManager.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISWorkspaceManager.java Wed Mar  3 16:22:44 2010
@@ -102,6 +102,9 @@
         if (paths.startsWith("/query/") || paths.startsWith("/query?")) {
             return new CMISQueryFeed(repository);
         }
+        if (paths.startsWith("/allowableactions/")) {
+            return new CMISAllowableActionsEntry(repository);
+        }
         return null;
     }
 

Added: incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/abdera/AllowableActionsDocument.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/abdera/AllowableActionsDocument.java?rev=918547&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/abdera/AllowableActionsDocument.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/abdera/AllowableActionsDocument.java Wed Mar  3 16:22:44 2010
@@ -0,0 +1,46 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Authors:
+ *     Florent Guillaume, Nuxeo
+ */
+package org.apache.chemistry.atompub.abdera;
+
+import java.util.Set;
+
+import javax.xml.namespace.QName;
+
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.model.Element;
+import org.apache.abdera.parser.stax.FOMExtensibleElement;
+import org.apache.axiom.om.OMContainer;
+import org.apache.axiom.om.OMFactory;
+import org.apache.chemistry.CMIS;
+
+/**
+ * FOM extensible element for a cmis:allowableActions document.
+ */
+public class AllowableActionsDocument extends FOMExtensibleElement {
+
+    public AllowableActionsDocument(OMContainer parent, Factory factory) {
+        super(CMIS.ALLOWABLE_ACTIONS, parent, (OMFactory) factory);
+    }
+
+    public void setAllowableActions(Set<QName> set) {
+        for (QName qname : set) {
+            Element el = addExtension(qname);
+            el.setText("true");
+        }
+    }
+
+}

Propchange: incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/abdera/AllowableActionsDocument.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/abdera/AllowableActionsDocument.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/abdera/AllowableActionsElement.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/abdera/AllowableActionsElement.java?rev=918547&r1=918546&r2=918547&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/abdera/AllowableActionsElement.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/abdera/AllowableActionsElement.java Wed Mar  3 16:22:44 2010
@@ -16,7 +16,12 @@
  */
 package org.apache.chemistry.atompub.abdera;
 
+import java.util.Set;
+
+import javax.xml.namespace.QName;
+
 import org.apache.abdera.factory.Factory;
+import org.apache.abdera.model.Element;
 import org.apache.abdera.model.ExtensibleElementWrapper;
 import org.apache.chemistry.CMIS;
 
@@ -29,4 +34,11 @@
         super(factory, CMIS.ALLOWABLE_ACTIONS);
     }
 
+    public void setAllowableActions(Set<QName> set) {
+        for (QName qname : set) {
+            Element el = addExtension(qname);
+            el.setText("true");
+        }
+    }
+
 }

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/abdera/ObjectElement.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/abdera/ObjectElement.java?rev=918547&r1=918546&r2=918547&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/abdera/ObjectElement.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/abdera/ObjectElement.java Wed Mar  3 16:22:44 2010
@@ -19,6 +19,9 @@
 import java.io.Serializable;
 import java.util.Collections;
 import java.util.Map;
+import java.util.Set;
+
+import javax.xml.namespace.QName;
 
 import org.apache.abdera.factory.Factory;
 import org.apache.abdera.model.Element;
@@ -34,7 +37,9 @@
  */
 public class ObjectElement extends ExtensibleElementWrapper {
 
-    protected final PropertiesElement properties;
+    protected PropertiesElement properties;
+
+    protected AllowableActionsElement allowableActions;
 
     /**
      * Constructor used when parsing XML.
@@ -51,9 +56,8 @@
      */
     public ObjectElement(Factory factory, ObjectEntry object, Type type) {
         super(factory, AtomPubCMIS.OBJECT);
-        properties = new PropertiesElement(getFactory());
-        addExtension(properties);
         setProperties(object.getValues(), type);
+        setAllowableActions(object.getAllowableActions());
     }
 
     public Map<String, Serializable> getProperties(String typeId) {
@@ -64,10 +68,20 @@
     }
 
     public void setProperties(Map<String, Serializable> values, Type type) {
+        properties = new PropertiesElement(getFactory());
+        addExtension(properties);
         properties.setProperties(values, type);
     }
 
-    // TODO allowable actions
+    public void setAllowableActions(Set<QName> aa) {
+        if (aa == null) {
+            allowableActions = null;
+        } else {
+            allowableActions = new AllowableActionsElement(getFactory());
+            addExtension(allowableActions);
+            allowableActions.setAllowableActions(aa);
+        }
+    }
 
     // TODO change event info
 

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=918547&r1=918546&r2=918547&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 Mar  3 16:22:44 2010
@@ -24,6 +24,7 @@
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
@@ -42,6 +43,7 @@
 import org.antlr.runtime.tree.CommonTreeNodeStream;
 import org.apache.chemistry.ACE;
 import org.apache.chemistry.ACLPropagation;
+import org.apache.chemistry.AllowableAction;
 import org.apache.chemistry.BaseType;
 import org.apache.chemistry.CMISObject;
 import org.apache.chemistry.CMISRuntimeException;
@@ -478,9 +480,11 @@
         throw new UnsupportedOperationException();
     }
 
-    public Collection<QName> getAllowableActions(ObjectId object) {
-        // TODO Auto-generated method stub
-        return SimpleListPage.emptyList();
+    public Set<QName> getAllowableActions(ObjectId object) {
+        // TODO see SimpleObjectEntry.getAllowableActions
+        Set<QName> set = new HashSet<QName>();
+        set.add(AllowableAction.CAN_UPDATE_PROPERTIES);
+        return set;
     }
 
     public ObjectEntry getProperties(ObjectId object, Inclusion inclusion) {

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=918547&r1=918546&r2=918547&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 Mar  3 16:22:44 2010
@@ -19,10 +19,13 @@
 import java.io.Serializable;
 import java.util.Collection;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Map;
+import java.util.Set;
 
 import javax.xml.namespace.QName;
 
+import org.apache.chemistry.AllowableAction;
 import org.apache.chemistry.BaseType;
 import org.apache.chemistry.ChangeInfo;
 import org.apache.chemistry.Connection;
@@ -145,9 +148,11 @@
         }
     }
 
-    public Map<QName, Boolean> getAllowableActions() {
-        // TODO Auto-generated method stub
-        throw new UnsupportedOperationException();
+    public Set<QName> getAllowableActions() {
+        // TODO see SimpleConnection.getAllowableActions
+        Set<QName> set = new HashSet<QName>();
+        set.add(AllowableAction.CAN_UPDATE_PROPERTIES);
+        return set;
     }
 
     public Collection<ObjectEntry> getRelationships() {

Modified: incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrConnection.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrConnection.java?rev=918547&r1=918546&r2=918547&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrConnection.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrConnection.java Wed Mar  3 16:22:44 2010
@@ -27,6 +27,7 @@
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import javax.jcr.Node;
 import javax.jcr.NodeIterator;
@@ -265,9 +266,9 @@
         throw new UnsupportedOperationException();
     }
 
-    public Collection<QName> getAllowableActions(ObjectId objectId) {
+    public Set<QName> getAllowableActions(ObjectId objectId) {
         // TODO Auto-generated method stub
-        throw new UnsupportedOperationException();
+        return null;
     }
 
     public Collection<ObjectEntry> getAppliedPolicies(ObjectId objectId,

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=918547&r1=918546&r2=918547&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 Mar  3 16:22:44 2010
@@ -29,6 +29,7 @@
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import javax.jcr.Item;
 import javax.jcr.Node;
@@ -72,8 +73,8 @@
         return connection;
     }
 
-    public Map<QName, Boolean> getAllowableActions() {
-        throw new UnsupportedOperationException();
+    public Set<QName> getAllowableActions() {
+        throw null;
     }
 
     public String getPathSegment() {

Modified: incubator/chemistry/trunk/chemistry/chemistry-tests/src/main/java/org/apache/chemistry/test/BasicTestCase.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tests/src/main/java/org/apache/chemistry/test/BasicTestCase.java?rev=918547&r1=918546&r2=918547&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-tests/src/main/java/org/apache/chemistry/test/BasicTestCase.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-tests/src/main/java/org/apache/chemistry/test/BasicTestCase.java Wed Mar  3 16:22:44 2010
@@ -29,8 +29,11 @@
 import java.util.Set;
 import java.util.TimeZone;
 
+import javax.xml.namespace.QName;
+
 import junit.framework.TestCase;
 
+import org.apache.chemistry.AllowableAction;
 import org.apache.chemistry.BaseType;
 import org.apache.chemistry.CMISObject;
 import org.apache.chemistry.CMISRuntimeException;
@@ -56,6 +59,7 @@
 import org.apache.chemistry.SPI;
 import org.apache.chemistry.Tree;
 import org.apache.chemistry.Type;
+import org.apache.chemistry.atompub.client.APPObjectEntry;
 import org.apache.chemistry.impl.simple.SimpleContentStream;
 import org.apache.chemistry.impl.simple.SimpleObjectId;
 import org.apache.chemistry.util.GregorianCalendar;
@@ -772,4 +776,35 @@
         assertNotNull(d);
     }
 
+    public void testObjectAllowableActions() throws Exception {
+        ObjectEntry fold = spi.getObjectByPath("/folder 1", null);
+        Set<QName> aa = fold.getAllowableActions();
+        assertNotNull(aa);
+        assertTrue(aa.contains(AllowableAction.CAN_UPDATE_PROPERTIES));
+    }
+
+    public void testAllowableActionsSPI() throws Exception {
+        ObjectEntry foldentry = spi.getObjectByPath("/folder 1", null);
+        // fetch from existing entry
+        assertNotNull(foldentry.getAllowableActions());
+        Set<QName> aa = spi.getAllowableActions(foldentry);
+        assertNotNull(aa);
+        assertTrue(aa.contains(AllowableAction.CAN_UPDATE_PROPERTIES));
+
+        // check can refetch part of entry if missing aa
+        if (foldentry instanceof APPObjectEntry) {
+            ((APPObjectEntry) foldentry).setAllowableActions(null);
+            aa = spi.getAllowableActions(foldentry);
+            assertNotNull(aa);
+            assertTrue(aa.contains(AllowableAction.CAN_UPDATE_PROPERTIES));
+            assertNotNull(foldentry.getAllowableActions());
+        }
+
+        // fetch from just id
+        ObjectId foldid = spi.newObjectId(foldentry.getId());
+        aa = spi.getAllowableActions(foldid);
+        assertNotNull(aa);
+        assertTrue(aa.contains(AllowableAction.CAN_UPDATE_PROPERTIES));
+    }
+
 }