You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by ra...@apache.org on 2010/11/28 16:41:32 UTC

svn commit: r1039893 - in /lenya/branches/BRANCH_2_1_X/src/modules/webdav: java/src/org/apache/lenya/cms/usecases/webdav/Propfind.java sitemap.xmap usecases/webdav/filePropfind.jx usecases/webdav/propfind.jx webdav.js

Author: rainer
Date: Sun Nov 28 15:41:32 2010
New Revision: 1039893

URL: http://svn.apache.org/viewvc?rev=1039893&view=rev
Log:
WebDAV fixes:

Catch AccessControlException raised when neither username nor password are set,
fixes https://issues.apache.org/bugzilla/show_bug.cgi?id=42854.
Corrections to sitemap and webdav.js.
Reduce number of 500 Internal server errors.
Return correct MIME Type and file extension for opendocument, improve
reply to PROPFIND requests.

Modified:
    lenya/branches/BRANCH_2_1_X/src/modules/webdav/java/src/org/apache/lenya/cms/usecases/webdav/Propfind.java
    lenya/branches/BRANCH_2_1_X/src/modules/webdav/sitemap.xmap
    lenya/branches/BRANCH_2_1_X/src/modules/webdav/usecases/webdav/filePropfind.jx
    lenya/branches/BRANCH_2_1_X/src/modules/webdav/usecases/webdav/propfind.jx
    lenya/branches/BRANCH_2_1_X/src/modules/webdav/webdav.js

Modified: lenya/branches/BRANCH_2_1_X/src/modules/webdav/java/src/org/apache/lenya/cms/usecases/webdav/Propfind.java
URL: http://svn.apache.org/viewvc/lenya/branches/BRANCH_2_1_X/src/modules/webdav/java/src/org/apache/lenya/cms/usecases/webdav/Propfind.java?rev=1039893&r1=1039892&r2=1039893&view=diff
==============================================================================
--- lenya/branches/BRANCH_2_1_X/src/modules/webdav/java/src/org/apache/lenya/cms/usecases/webdav/Propfind.java (original)
+++ lenya/branches/BRANCH_2_1_X/src/modules/webdav/java/src/org/apache/lenya/cms/usecases/webdav/Propfind.java Sun Nov 28 15:41:32 2010
@@ -96,6 +96,13 @@ public class Propfind extends SiteUsecas
                 }
             }
 
+	    //FIXME: This is a workaround for the error
+	    //  "This usecase can only be invoked on documents!"
+	    // triggered in (superclass) DocumentUsecase.doCheckPreconditions()
+	    // when the usecase parameter "document" is not set properly.
+	    if (docs.size() > 0) {
+		setParameter(DOCUMENT, docs.get(0));
+	    }
             setParameter(DOCUMENTS, docs);
             setParameter(RC, checkedOut);
             setParameter(SOURCEURL, request);

Modified: lenya/branches/BRANCH_2_1_X/src/modules/webdav/sitemap.xmap
URL: http://svn.apache.org/viewvc/lenya/branches/BRANCH_2_1_X/src/modules/webdav/sitemap.xmap?rev=1039893&r1=1039892&r2=1039893&view=diff
==============================================================================
--- lenya/branches/BRANCH_2_1_X/src/modules/webdav/sitemap.xmap (original)
+++ lenya/branches/BRANCH_2_1_X/src/modules/webdav/sitemap.xmap Sun Nov 28 15:41:32 2010
@@ -76,7 +76,7 @@
         <map:transform type="xslt" src="fallback://lenya/modules/webdav/xslt/NSclean.xsl"/>
         <map:select type="request-method">
           <map:when test="PROPFIND">
-            <map:transform src="cocoon:/limitResponse.xsl" />
+<!--            <map:transform src="cocoon:/limitResponse.xsl" />-->
             <map:serialize type="xml" status-code="207"/>
           </map:when>
           <map:otherwise>
@@ -173,15 +173,17 @@
       </map:match>
 
       <map:match pattern="PROPFIND/**.*">
+<!--
         <map:match pattern="PROPFIND/**_*.html">
-          <map:act type="resource-exists" src="context://lenya/pubs/{page-envelope:publication-id}/content/authoring/{1}/index_{page-envelope:document-language}.xml">
+          <map:act type="resource-exists" src="site://{page-envelope:publication-id}/authoring/{2}/{1}">
             <map:call function="filePropfind" >
               <map:parameter name="last-modified" value="{page-envelope:document-lastmodified}"/>
             </map:call>
           </map:act>
         </map:match>
+-->
         <map:match pattern="PROPFIND/**_*.*">
-          <map:act type="resource-exists" src="context://lenya/pubs/{page-envelope:publication-id}/content/authoring/{1}/index_{page-envelope:document-language}.{3}">
+          <map:act type="resource-exists" src="site://{page-envelope:publication-id}/authoring/{2}/{1}">
             <map:call function="filePropfind" >
               <map:parameter name="last-modified" value="{page-envelope:document-lastmodified}"/>
             </map:call>
@@ -189,7 +191,10 @@
         </map:match>
         <!-- does not exist -->
         <map:generate src="context://lenya/content/util/empty.xml"/>
-        <map:serialize status-code="404"/>
+        <map:transform src="fallback://lenya/xslt/exception/generic.xsl"/>
+        <map:transform src="fallback://lenya/xslt/util/page2xhtml.xsl"/>
+        <map:transform src="fallback://lenya/xslt/util/strip_namespaces.xsl"/>
+        <map:serialize type="xhtml" status-code="404"/>
       </map:match>
  
       <map:match pattern="PROPFIND/**">        
@@ -275,18 +280,21 @@
                         
       <map:match pattern="LOCK/**">
         <map:select type="resource-exists">
-          <map:parameter name="prefix" value="lenya://"/>
-          <map:when test="lenya/pubs/{page-envelope:publication-id}/content/authoring/{page-envelope:document-path}">
+          <map:parameter name="prefix" value="site://"/>
+          <map:when test="{page-envelope:publication-id}/authoring/{page-envelope:document-language}{page-envelope:document-path}">
             <map:act type="reserved-checkout">
               <map:generate src="context://lenya/content/util/empty.xml"/>
               <map:serialize type="xml"  status-code="423"/>
             </map:act>
+           <map:act type="set-header">
+            <map:parameter name="Lock-Token" value="{page-envelope:document-uuid}"/>
             <map:generate type="file" src="cocoon:/request/generate"/>
             <map:transform type="xslt" src="fallback://lenya/modules/webdav/xslt/lock.xsl">
               <map:parameter name="userid" value="{access-control:user-id}"/>
               <map:parameter name="docid" value="{page-envelope:document-uuid}"/>
             </map:transform>
             <map:serialize type="xml" status-code="200" />
+            </map:act> 
           </map:when>
           <map:otherwise>
             <map:generate src="context://lenya/content/util/empty.xml"/>

Modified: lenya/branches/BRANCH_2_1_X/src/modules/webdav/usecases/webdav/filePropfind.jx
URL: http://svn.apache.org/viewvc/lenya/branches/BRANCH_2_1_X/src/modules/webdav/usecases/webdav/filePropfind.jx?rev=1039893&r1=1039892&r2=1039893&view=diff
==============================================================================
--- lenya/branches/BRANCH_2_1_X/src/modules/webdav/usecases/webdav/filePropfind.jx (original)
+++ lenya/branches/BRANCH_2_1_X/src/modules/webdav/usecases/webdav/filePropfind.jx Sun Nov 28 15:41:32 2010
@@ -6,11 +6,16 @@
   <jx:set var="checkedOut" value="${usecase.getParameter('rc')}"/>
   <jx:forEach var="doc" items="${usecase.getParameter('documents')}"
     varStatus="status">
-    <jx:if test="${doc.getId()}">
+    <jx:if test="${doc.getIdentifier()}">
     <jx:set var="fileExtension" value="${doc.getSourceExtension()}"/>
+    <jx:set var="resourceType" value="${doc.getResourceType().getName()}"/>
+    <jx:set var="mimeType" value="${doc.getMimeType()}"/>
     <jx:if test="${doc.getSourceExtension().equals('xml')}">
         <jx:set var="fileExtension" value="html"/>
     </jx:if>
+    <jx:if test="${doc.getResourceType().getName().equals('opendocument')}">
+        <jx:set var="fileExtension" value="odt"/>
+    </jx:if>
       <D:response>
         <D:href>${request.getContextPath()}/${doc.getPublication().getId()}/webdav${doc.getPath()}_${doc.getLanguage()}.${fileExtension}</D:href>
         <D:propstat>
@@ -18,7 +23,7 @@
             <D:displayname>${doc.getName()}_${doc.getLanguage()}.${fileExtension}</D:displayname>
             <D:getlastmodified>${dateFormat.format(doc.getLastModified())}</D:getlastmodified>
             <D:creationdate/>
-            <D:getcontenttype>application/xml</D:getcontenttype>
+            <D:getcontenttype>${mimeType}</D:getcontenttype>
             <D:getcontentlength>${doc.getFile().length()}</D:getcontentlength>
             <D:resourcetype/>
             <D:lockdiscovery>

Modified: lenya/branches/BRANCH_2_1_X/src/modules/webdav/usecases/webdav/propfind.jx
URL: http://svn.apache.org/viewvc/lenya/branches/BRANCH_2_1_X/src/modules/webdav/usecases/webdav/propfind.jx?rev=1039893&r1=1039892&r2=1039893&view=diff
==============================================================================
--- lenya/branches/BRANCH_2_1_X/src/modules/webdav/usecases/webdav/propfind.jx (original)
+++ lenya/branches/BRANCH_2_1_X/src/modules/webdav/usecases/webdav/propfind.jx Sun Nov 28 15:41:32 2010
@@ -26,7 +26,7 @@
   <jx:if test="${request.getHeader('depth') &gt; 0}">
     <jx:forEach var="doc" items="${usecase.getParameter('documents')}">
       <!-- FIXME: shouldn't this conditional be doc.exists()? -->
-      <jx:if test="${doc.getId()}">
+      <jx:if test="${doc.getIdentifier()}">
         <jx:if test="${doc.getLanguage().equals(defaultLang)}">
          <!-- create a directory for each document;
           the language check is to prevent multiple folders appearing with the same name
@@ -54,11 +54,16 @@
     <jx:set var="checkedOut" value="${usecase.getParameter('rc')}"/>
     <jx:forEach var="doc" items="${usecase.getParameter('documents')}"
       varStatus="status">
-      <jx:if test="${doc.getId()}">
+      <jx:if test="${doc.getIdentifier()}">
       <jx:set var="fileExtension" value="${doc.getSourceExtension()}"/>
+      <jx:set var="resourceType" value="${doc.getResourceType().getName()}"/>
+      <jx:set var="mimeType" value="${doc.getMimeType()}"/>
       <jx:if test="${doc.getSourceExtension().equals('xml')}">
           <jx:set var="fileExtension" value="html"/>
       </jx:if>
+      <jx:if test="${doc.getResourceType().getName().equals('opendocument')}">
+          <jx:set var="fileExtension" value="odt"/>
+      </jx:if>
        <!-- create a file for each document, the href is the path to the file and the 
         display name is what will appear in the webdav folder -->
         <D:response>
@@ -68,7 +73,7 @@
               <D:displayname>${doc.getName()}_${doc.getLanguage()}.${fileExtension}</D:displayname>
               <D:getlastmodified>${dateFormat.format(doc.getLastModified())}</D:getlastmodified>
               <D:creationdate/>
-              <D:getcontenttype>application/xml</D:getcontenttype>
+              <D:getcontenttype>${mimeType}</D:getcontenttype>
               <D:getcontentlength>${doc.getFile().length()}</D:getcontentlength>
               <D:resourcetype/>
               <D:lockdiscovery>

Modified: lenya/branches/BRANCH_2_1_X/src/modules/webdav/webdav.js
URL: http://svn.apache.org/viewvc/lenya/branches/BRANCH_2_1_X/src/modules/webdav/webdav.js?rev=1039893&r1=1039892&r2=1039893&view=diff
==============================================================================
--- lenya/branches/BRANCH_2_1_X/src/modules/webdav/webdav.js (original)
+++ lenya/branches/BRANCH_2_1_X/src/modules/webdav/webdav.js Sun Nov 28 15:41:32 2010
@@ -104,8 +104,9 @@ function propfind() {
   sendStatus(500);
 }
 
-function options(type) {
+function options() {
   cocoon.response.setHeader("DAV","1");
+  var type = "";
   var options = "";
   if (type == "file") {
     options = "OPTIONS,GET,HEAD,POST,DELETE,TRACE,PROPFIND,PROPPATCH,COPY,MOVE,PUT,LOCK,UNLOCK";
@@ -165,7 +166,7 @@ function executeUsecase(usecaseName) {
     var preconditionsOk;
     
     if (cocoon.log.isDebugEnabled())
-       cocoon.log.debug("usecases.js::executeUsecase() called, parameter lenya.usecase = [" + usecaseName + "]");
+       cocoon.log.debug("webdav.js::executeUsecase() called, parameter lenya.usecase = [" + usecaseName + "]");
     
     try {
 
@@ -219,11 +220,11 @@ function executeUsecase(usecaseName) {
         while (!ready) {
 
             try {
-                var templateUri = view.getTemplateURI();
+                var templateUri = view.getViewURI();
                 if (templateUri) {
-                    var viewUri = "view/" + menu + "/" + view.getTemplateURI();
+                    var viewUri = "view/" + menu + "/" + view.getViewURI();
                     if (cocoon.log.isDebugEnabled())
-                        cocoon.log.debug("usecases.js::executeUsecase() in usecase " + usecaseName + ", creating view, calling Cocoon with viewUri = [" + viewUri + "]");
+                        cocoon.log.debug("webdav.js::executeUsecase() in usecase " + usecaseName + ", creating view, calling Cocoon with viewUri = [" + viewUri + "]");
 
                     cocoon.sendPageAndWait(viewUri, {"usecase" : proxy});
                     
@@ -236,6 +237,9 @@ function executeUsecase(usecaseName) {
             }
             catch (exception) {
                 /* if an exception was thrown by the view, allow the usecase to rollback the transition */
+		if (cocoon.log.isDebugEnabled())
+		    cocoon.log.debug("webdav.js::executeUsecase() in usecase " + usecaseName + ": exception " + exception.name + " caught, message is:\n" + exception.message);
+
                 try {
                     usecaseResolver = cocoon.getComponent("org.apache.lenya.cms.usecase.UsecaseResolver");
                     usecase = usecaseResolver.resolve(sourceUrl, usecaseName);
@@ -255,7 +259,7 @@ function executeUsecase(usecaseName) {
             }
             
             if (cocoon.log.isDebugEnabled())
-                cocoon.log.debug("usecases.js::executeUsecase() in usecase " + usecaseName + ", after view, now advancing in usecase");
+                cocoon.log.debug("webdav.js::executeUsecase() in usecase " + usecaseName + ", after view, now advancing in usecase");
         
             try {
                 usecaseResolver = cocoon.getComponent("org.apache.lenya.cms.usecase.UsecaseResolver");



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org