continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject svn commit: r978986 - in /continuum/trunk/continuum-buildagent/continuum-buildagent-webdav: ./ src/main/java/org/apache/continuum/webdav/ src/main/java/org/apache/continuum/webdav/util/ src/test/java/org/apache/continuum/webdav/
Date Sun, 25 Jul 2010 06:02:04 GMT
Author: ctan
Date: Sun Jul 25 06:02:03 2010
New Revision: 978986

URL: http://svn.apache.org/viewvc?rev=978986&view=rev
Log:
[CONTINUUM-2545] do not write content as html when dav resource is a collection

Added:
    continuum/trunk/continuum-buildagent/continuum-buildagent-webdav/src/test/java/org/apache/continuum/webdav/MockContinuumBuildAgentDavResource.java
Modified:
    continuum/trunk/continuum-buildagent/continuum-buildagent-webdav/pom.xml
    continuum/trunk/continuum-buildagent/continuum-buildagent-webdav/src/main/java/org/apache/continuum/webdav/ContinuumBuildAgentDavResource.java
    continuum/trunk/continuum-buildagent/continuum-buildagent-webdav/src/main/java/org/apache/continuum/webdav/ContinuumBuildAgentDavResourceFactory.java
    continuum/trunk/continuum-buildagent/continuum-buildagent-webdav/src/main/java/org/apache/continuum/webdav/util/IndexWriter.java
    continuum/trunk/continuum-buildagent/continuum-buildagent-webdav/src/test/java/org/apache/continuum/webdav/MockContinuumBuildAgentDavResourceFactory.java

Modified: continuum/trunk/continuum-buildagent/continuum-buildagent-webdav/pom.xml
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-webdav/pom.xml?rev=978986&r1=978985&r2=978986&view=diff
==============================================================================
--- continuum/trunk/continuum-buildagent/continuum-buildagent-webdav/pom.xml (original)
+++ continuum/trunk/continuum-buildagent/continuum-buildagent-webdav/pom.xml Sun Jul 25 06:02:03
2010
@@ -33,6 +33,10 @@
       <artifactId>continuum-buildagent-core</artifactId>
     </dependency>
     <dependency>
+      <groupId>org.codehaus.redback</groupId>
+      <artifactId>plexus-spring</artifactId>
+    </dependency>
+    <dependency>
       <groupId>org.apache.jackrabbit</groupId>
       <artifactId>jackrabbit-webdav</artifactId>
     </dependency>
@@ -77,4 +81,21 @@
       <scope>test</scope>
     </dependency>
   </dependencies>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.codehaus.plexus</groupId>
+        <artifactId>plexus-maven-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>generate</id>
+            <phase>generate-resources</phase>
+            <goals>
+              <goal>descriptor</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
 </project>
\ No newline at end of file

Modified: continuum/trunk/continuum-buildagent/continuum-buildagent-webdav/src/main/java/org/apache/continuum/webdav/ContinuumBuildAgentDavResource.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-webdav/src/main/java/org/apache/continuum/webdav/ContinuumBuildAgentDavResource.java?rev=978986&r1=978985&r2=978986&view=diff
==============================================================================
--- continuum/trunk/continuum-buildagent/continuum-buildagent-webdav/src/main/java/org/apache/continuum/webdav/ContinuumBuildAgentDavResource.java
(original)
+++ continuum/trunk/continuum-buildagent/continuum-buildagent-webdav/src/main/java/org/apache/continuum/webdav/ContinuumBuildAgentDavResource.java
Sun Jul 25 06:02:03 2010
@@ -194,6 +194,11 @@ public class ContinuumBuildAgentDavResou
         return null;
     }
 
+    public String getLogicalResource()
+    {
+        return logicalResource;
+    }
+
     public DavResourceIterator getMembers()
     {
         List<DavResource> list = new ArrayList<DavResource>();
@@ -227,6 +232,11 @@ public class ContinuumBuildAgentDavResou
         return new DavResourceIteratorImpl( list );
     }
 
+    public MimetypesFileTypeMap getMimeTypes()
+    {
+        return mimeTypes;
+    }
+
     public long getModificationTime()
     {
         return localResource.lastModified();
@@ -336,11 +346,6 @@ public class ContinuumBuildAgentDavResou
                 IOUtils.closeQuietly( is );
             }
         }
-        else if ( outputContext.hasStream() )
-        {
-            IndexWriter writer = new IndexWriter( this, localResource, logicalResource );
-            writer.write( outputContext );
-        }
     }
 
     public void unlock( String lockTocken )

Modified: continuum/trunk/continuum-buildagent/continuum-buildagent-webdav/src/main/java/org/apache/continuum/webdav/ContinuumBuildAgentDavResourceFactory.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-webdav/src/main/java/org/apache/continuum/webdav/ContinuumBuildAgentDavResourceFactory.java?rev=978986&r1=978985&r2=978986&view=diff
==============================================================================
--- continuum/trunk/continuum-buildagent/continuum-buildagent-webdav/src/main/java/org/apache/continuum/webdav/ContinuumBuildAgentDavResourceFactory.java
(original)
+++ continuum/trunk/continuum-buildagent/continuum-buildagent-webdav/src/main/java/org/apache/continuum/webdav/ContinuumBuildAgentDavResourceFactory.java
Sun Jul 25 06:02:03 2010
@@ -37,6 +37,9 @@ import org.apache.jackrabbit.webdav.DavS
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+/**
+ * @plexus.component role="org.apache.continuum.webdav.ContinuumBuildAgentDavResourceFactory"
+ */
 public class ContinuumBuildAgentDavResourceFactory
     implements DavResourceFactory
 {
@@ -79,9 +82,7 @@ public class ContinuumBuildAgentDavResou
         }
         else
         {
-            DavResource resource = new ContinuumBuildAgentDavResource( resourceFile.getAbsolutePath(),
logicalResource,
-                                                                       davSession, continuumLocator,
this, mimeTypes );
-            return resource;
+            return createResource( resourceFile, logicalResource, davSession, continuumLocator
);
         }
     }
 
@@ -114,10 +115,7 @@ public class ContinuumBuildAgentDavResou
         }
         else
         {
-            DavResource resource = new ContinuumBuildAgentDavResource( resourceFile.getAbsolutePath(),
logicalResource,
-                                                                       request.getDavSession(),
continuumLocator, this,
-                                                                       mimeTypes );
-            return resource;
+            return createResource( resourceFile, logicalResource, request.getDavSession(),
continuumLocator );
         }
     }
 
@@ -126,6 +124,11 @@ public class ContinuumBuildAgentDavResou
         return buildAgentConfigurationService;
     }
 
+    public MimetypesFileTypeMap getMimeTypes()
+    {
+        return mimeTypes;
+    }
+
     public void setBuildAgentConfigurationService( BuildAgentConfigurationService buildAgentConfigurationService
)
     {
         this.buildAgentConfigurationService = buildAgentConfigurationService;
@@ -162,4 +165,11 @@ public class ContinuumBuildAgentDavResou
 
         return new File( workingDir, logicalResource );
     }
+
+    protected DavResource createResource( File resourceFile, String logicalResource, DavSession
session,
+                                          ContinuumBuildAgentDavResourceLocator locator )
+    {
+        return new ContinuumBuildAgentDavResource( resourceFile.getAbsolutePath(), logicalResource,
session, 
+                                                   locator, this, mimeTypes );
+    }
 }

Modified: continuum/trunk/continuum-buildagent/continuum-buildagent-webdav/src/main/java/org/apache/continuum/webdav/util/IndexWriter.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-webdav/src/main/java/org/apache/continuum/webdav/util/IndexWriter.java?rev=978986&r1=978985&r2=978986&view=diff
==============================================================================
--- continuum/trunk/continuum-buildagent/continuum-buildagent-webdav/src/main/java/org/apache/continuum/webdav/util/IndexWriter.java
(original)
+++ continuum/trunk/continuum-buildagent/continuum-buildagent-webdav/src/main/java/org/apache/continuum/webdav/util/IndexWriter.java
Sun Jul 25 06:02:03 2010
@@ -52,15 +52,15 @@ public class IndexWriter
 
     public void write( OutputContext outputContext )
     {
-        outputContext.setModificationTime(new Date().getTime());
-        outputContext.setContentType("text/html");
-        outputContext.setETag("");
+        outputContext.setModificationTime( new Date().getTime() );
+        outputContext.setContentType( "text/html" );
+        outputContext.setETag( "" );
         if ( outputContext.hasStream() )
         {
             PrintWriter writer = new PrintWriter( outputContext.getOutputStream() );
             writeDocumentStart( writer );
-            writeHyperlinks(writer);
-            writeDocumentEnd(writer);
+            writeHyperlinks( writer );
+            writeDocumentEnd( writer );
             writer.flush();
             writer.close();
         }

Added: continuum/trunk/continuum-buildagent/continuum-buildagent-webdav/src/test/java/org/apache/continuum/webdav/MockContinuumBuildAgentDavResource.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-webdav/src/test/java/org/apache/continuum/webdav/MockContinuumBuildAgentDavResource.java?rev=978986&view=auto
==============================================================================
--- continuum/trunk/continuum-buildagent/continuum-buildagent-webdav/src/test/java/org/apache/continuum/webdav/MockContinuumBuildAgentDavResource.java
(added)
+++ continuum/trunk/continuum-buildagent/continuum-buildagent-webdav/src/test/java/org/apache/continuum/webdav/MockContinuumBuildAgentDavResource.java
Sun Jul 25 06:02:03 2010
@@ -0,0 +1,73 @@
+package org.apache.continuum.webdav;
+
+/*
+ * 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.
+ */
+
+import java.io.FileInputStream;
+import java.io.IOException;
+
+import javax.activation.MimetypesFileTypeMap;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.continuum.webdav.util.IndexWriter;
+import org.apache.jackrabbit.webdav.DavResourceFactory;
+import org.apache.jackrabbit.webdav.DavSession;
+import org.apache.jackrabbit.webdav.io.OutputContext;
+
+public class MockContinuumBuildAgentDavResource
+    extends ContinuumBuildAgentDavResource
+{
+    public MockContinuumBuildAgentDavResource( String localResource, String logicalResource,
DavSession session,
+                                               ContinuumBuildAgentDavResourceLocator locator,
+                                               DavResourceFactory factory, MimetypesFileTypeMap
mimeTypes )
+    {
+        super( localResource, logicalResource, session, locator, factory, mimeTypes );
+    }
+
+    @Override
+    public void spool( OutputContext outputContext )
+        throws IOException
+    {
+        if ( !isCollection() )
+        {
+            outputContext.setContentLength( getLocalResource().length() );
+            outputContext.setContentType( getMimeTypes().getContentType( getLocalResource()
) );
+        }
+
+        if ( !isCollection() && outputContext.hasStream() )
+        {
+            FileInputStream is = null;
+            try
+            {
+                // Write content to stream
+                is = new FileInputStream( getLocalResource() );
+                IOUtils.copy( is, outputContext.getOutputStream() );
+            }
+            finally
+            {
+                IOUtils.closeQuietly( is );
+            }
+        }
+        else if ( outputContext.hasStream() )
+        {
+            IndexWriter writer = new IndexWriter( this, getLocalResource(), getLogicalResource()
);
+            writer.write( outputContext );
+        }
+    }
+}

Modified: continuum/trunk/continuum-buildagent/continuum-buildagent-webdav/src/test/java/org/apache/continuum/webdav/MockContinuumBuildAgentDavResourceFactory.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-webdav/src/test/java/org/apache/continuum/webdav/MockContinuumBuildAgentDavResourceFactory.java?rev=978986&r1=978985&r2=978986&view=diff
==============================================================================
--- continuum/trunk/continuum-buildagent/continuum-buildagent-webdav/src/test/java/org/apache/continuum/webdav/MockContinuumBuildAgentDavResourceFactory.java
(original)
+++ continuum/trunk/continuum-buildagent/continuum-buildagent-webdav/src/test/java/org/apache/continuum/webdav/MockContinuumBuildAgentDavResourceFactory.java
Sun Jul 25 06:02:03 2010
@@ -22,6 +22,9 @@ package org.apache.continuum.webdav;
 import java.io.File;
 import java.io.IOException;
 
+import org.apache.jackrabbit.webdav.DavResource;
+import org.apache.jackrabbit.webdav.DavSession;
+
 public class MockContinuumBuildAgentDavResourceFactory
     extends ContinuumBuildAgentDavResourceFactory
 {
@@ -31,6 +34,14 @@ public class MockContinuumBuildAgentDavR
         return new File( getWorkingDirectory( projectId ), logicalResource );
     }
 
+    @Override
+    protected DavResource createResource( File resourceFile, String logicalResource, DavSession
session,
+                                          ContinuumBuildAgentDavResourceLocator locator )
+    {
+        return new MockContinuumBuildAgentDavResource( resourceFile.getAbsolutePath(), logicalResource,
session, 
+                                                       locator, this, getMimeTypes() );
+    }
+
     private File getWorkingDirectory( int projectId )
     {
         String basedir = System.getProperty( "basedir" );



Mime
View raw message