jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r397831 - /jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/AbstractItemResource.java
Date Fri, 28 Apr 2006 09:39:40 GMT
Author: angela
Date: Fri Apr 28 02:39:38 2006
New Revision: 397831

URL: http://svn.apache.org/viewcvs?rev=397831&view=rev
Log:
AbstractItemResource:
add DAV:current-user-privilege set.

Modified:
    jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/AbstractItemResource.java

Modified: jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/AbstractItemResource.java
URL: http://svn.apache.org/viewcvs/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/AbstractItemResource.java?rev=397831&r1=397830&r2=397831&view=diff
==============================================================================
--- jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/AbstractItemResource.java
(original)
+++ jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/AbstractItemResource.java
Fri Apr 28 02:39:38 2006
@@ -30,6 +30,8 @@
 import org.apache.jackrabbit.webdav.jcr.version.report.RepositoryDescriptorsReport;
 import org.apache.jackrabbit.webdav.property.DefaultDavProperty;
 import org.apache.jackrabbit.webdav.property.HrefProperty;
+import org.apache.jackrabbit.webdav.security.CurrentUserPrivilegeSetProperty;
+import org.apache.jackrabbit.webdav.security.Privilege;
 import org.apache.jackrabbit.webdav.transaction.TxLockEntry;
 import org.apache.jackrabbit.webdav.version.report.ReportType;
 import org.apache.jackrabbit.webdav.version.report.SupportedReportSetProperty;
@@ -42,6 +44,9 @@
 import javax.jcr.Property;
 import javax.jcr.RepositoryException;
 import javax.jcr.Workspace;
+import java.security.AccessControlException;
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * <code>AbstractItemResource</code> covers common functionality for the various
@@ -287,6 +292,28 @@
                 properties.add(new DefaultDavProperty(JCR_ISMODIFIED, null, true));
             }
         }
+
+        // TODO complete set of properties defined by RFC 3744
+        Privilege[] allPrivs = new Privilege[] {PRIVILEGE_JCR_READ,
+                                                PRIVILEGE_JCR_ADD_NODE,
+                                                PRIVILEGE_JCR_SET_PROPERTY,
+                                                PRIVILEGE_JCR_REMOVE};
+        // Add list of privileges granted to the current user. Note, that for
+        // this property it is not required that the item already exists.
+        List currentPrivs = new ArrayList();
+        for (int i = 0; i < allPrivs.length; i++) {
+            try {
+                getRepositorySession().checkPermission(getLocator().getRepositoryPath(),
allPrivs[i].getName());
+                currentPrivs.add(allPrivs[i]);
+            } catch (AccessControlException e) {
+                // ignore
+                log.debug(e.toString());
+            } catch (RepositoryException e) {
+                // ignore
+                log.debug(e.toString());
+            }
+        }
+        properties.add(new CurrentUserPrivilegeSetProperty((Privilege[])currentPrivs.toArray(new
Privilege[currentPrivs.size()])));
     }
 
     /**



Mime
View raw message