jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r449677 - in /jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr: AbstractItemResource.java WorkspaceResourceImpl.java version/report/JcrPrivilegeReport.java
Date Mon, 25 Sep 2006 13:07:19 GMT
Author: angela
Date: Mon Sep 25 06:07:18 2006
New Revision: 449677

URL: http://svn.apache.org/viewvc?view=rev&rev=449677
Log:
work in progress

- fix checkPermission

Added:
    jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/JcrPrivilegeReport.java
  (with props)
Modified:
    jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/AbstractItemResource.java
    jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/WorkspaceResourceImpl.java

Modified: jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/AbstractItemResource.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/AbstractItemResource.java?view=diff&rev=449677&r1=449676&r2=449677
==============================================================================
--- 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
Mon Sep 25 06:07:18 2006
@@ -358,8 +358,6 @@
                                                 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 {

Modified: jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/WorkspaceResourceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/WorkspaceResourceImpl.java?view=diff&rev=449677&r1=449676&r2=449677
==============================================================================
--- jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/WorkspaceResourceImpl.java
(original)
+++ jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/WorkspaceResourceImpl.java
Mon Sep 25 06:07:18 2006
@@ -38,6 +38,7 @@
 import org.apache.jackrabbit.webdav.xml.DomUtil;
 import org.apache.jackrabbit.webdav.search.SearchResource;
 import org.apache.jackrabbit.webdav.jcr.property.NamespacesProperty;
+import org.apache.jackrabbit.webdav.jcr.version.report.JcrPrivilegeReport;
 import org.apache.jackrabbit.webdav.property.DavProperty;
 import org.apache.jackrabbit.webdav.io.InputContext;
 import org.apache.jackrabbit.webdav.io.OutputContext;
@@ -388,6 +389,11 @@
         // lock not allowed
     }
 
+    protected void initSupportedReports() {
+        super.initSupportedReports();
+        supportedReports.addReportType(JcrPrivilegeReport.PRIVILEGES_REPORT);
+    }
+    
     protected String getWorkspaceHref() {
         return getHref();
     }

Added: jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/JcrPrivilegeReport.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/JcrPrivilegeReport.java?view=auto&rev=449677
==============================================================================
--- jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/JcrPrivilegeReport.java
(added)
+++ jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/JcrPrivilegeReport.java
Mon Sep 25 06:07:18 2006
@@ -0,0 +1,134 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.jackrabbit.webdav.jcr.version.report;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.jackrabbit.webdav.version.report.Report;
+import org.apache.jackrabbit.webdav.version.report.ReportType;
+import org.apache.jackrabbit.webdav.version.report.ReportInfo;
+import org.apache.jackrabbit.webdav.jcr.ItemResourceConstants;
+import org.apache.jackrabbit.webdav.MultiStatus;
+import org.apache.jackrabbit.webdav.DavResource;
+import org.apache.jackrabbit.webdav.DavException;
+import org.apache.jackrabbit.webdav.DavConstants;
+import org.apache.jackrabbit.webdav.MultiStatusResponse;
+import org.apache.jackrabbit.webdav.DavServletResponse;
+import org.apache.jackrabbit.webdav.DavResourceLocator;
+import org.apache.jackrabbit.webdav.xml.DomUtil;
+import org.apache.jackrabbit.webdav.security.Privilege;
+import org.apache.jackrabbit.webdav.security.CurrentUserPrivilegeSetProperty;
+import org.w3c.dom.Element;
+import org.w3c.dom.Document;
+
+import javax.jcr.RepositoryException;
+import java.util.List;
+import java.util.ArrayList;
+import java.security.AccessControlException;
+
+/**
+ * <code>JcrPrivilegeReport</code>...
+ */
+public class JcrPrivilegeReport extends AbstractJcrReport {
+
+    private static Logger log = LoggerFactory.getLogger(JcrPrivilegeReport.class);
+
+    private static final String REPORT_NAME = "privileges";
+
+    /**
+     * The exportview report type
+     */
+    public static final ReportType PRIVILEGES_REPORT = ReportType.register(REPORT_NAME, ItemResourceConstants.NAMESPACE,
JcrPrivilegeReport.class);
+
+    private static final Privilege[] PRIVS = new Privilege[] {
+        ItemResourceConstants.PRIVILEGE_JCR_READ,
+        ItemResourceConstants.PRIVILEGE_JCR_ADD_NODE,
+        ItemResourceConstants.PRIVILEGE_JCR_SET_PROPERTY,
+        ItemResourceConstants.PRIVILEGE_JCR_REMOVE};
+
+    private final MultiStatus ms = new MultiStatus();
+
+    /**
+     * Returns {@link #PRIVILEGES_REPORT} report type.
+     *
+     * @return {@link #PRIVILEGES_REPORT}
+     * @see org.apache.jackrabbit.webdav.version.report.Report#getType()
+     */
+    public ReportType getType() {
+        return PRIVILEGES_REPORT;
+    }
+
+    /**
+     * Always returns <code>true</code>.
+     *
+     * @return true
+     * @see org.apache.jackrabbit.webdav.version.report.Report#isMultiStatusReport()
+     */
+    public boolean isMultiStatusReport() {
+        return true;
+    }
+
+    /**
+     * @see Report#init(DavResource, ReportInfo)
+     */
+    public void init(DavResource resource, ReportInfo info) throws DavException {
+        // delegate basic validation to super class
+        super.init(resource, info);
+        // make also sure, the info contains a DAV:href child element
+        if (!info.containsContentElement(DavConstants.XML_HREF, DavConstants.NAMESPACE))
{
+            throw new DavException(DavServletResponse.SC_BAD_REQUEST, "dcr:privileges element
must at least contain a single DAV:href child.");
+        }
+        // immediately build the final multistatus element
+        Element hrefElem = info.getContentElement(DavConstants.XML_HREF, DavConstants.NAMESPACE);
+        String href = DomUtil.getTextTrim(hrefElem);
+        DavResourceLocator resourceLoc = resource.getLocator();
+        DavResourceLocator loc = resourceLoc.getFactory().createResourceLocator(resourceLoc.getPrefix(),
href);
+        // immediately build the final multistatus element
+        addResponses(loc);
+    }
+
+    /**
+     * Creates a Xml document from the generated view.
+     *
+     * @param document
+     * @return Xml element representing the output of the specified view.
+     * @see org.apache.jackrabbit.webdav.xml.XmlSerializable#toXml(Document)
+     */
+    public Element toXml(Document document) {
+        return ms.toXml(document);
+    }
+
+    private void addResponses(DavResourceLocator locator) {
+        String repositoryPath = locator.getRepositoryPath();
+        MultiStatusResponse resp = new MultiStatusResponse(locator.getHref(false), null);
+        List currentPrivs = new ArrayList();
+        for (int i = 0; i < PRIVS.length; i++) {
+            try {
+                getRepositorySession().checkPermission(repositoryPath, PRIVS[i].getName());
+                currentPrivs.add(PRIVS[i]);
+            } catch (AccessControlException e) {
+                // ignore
+                log.debug(e.toString());
+            } catch (RepositoryException e) {
+                // ignore
+                log.debug(e.toString());
+            }
+        }
+        resp.add(new CurrentUserPrivilegeSetProperty((Privilege[])currentPrivs.toArray(new
Privilege[currentPrivs.size()])));
+        ms.addResponse(resp);
+    }
+}
\ No newline at end of file

Propchange: jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/JcrPrivilegeReport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/JcrPrivilegeReport.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url



Mime
View raw message