continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r291830 - in /maven/continuum/trunk: continuum-api/src/main/java/org/apache/maven/continuum/ continuum-core/src/main/java/org/apache/maven/continuum/ continuum-core/src/main/resources/META-INF/plexus/ continuum-web/src/main/java/org/apache/...
Date Tue, 27 Sep 2005 06:33:35 GMT
Author: evenisse
Date: Mon Sep 26 23:33:19 2005
New Revision: 291830

URL: http://svn.apache.org/viewcvs?rev=291830&view=rev
Log:
[CONTINUUM-286] Add working copy browser

Added:
    maven/continuum/trunk/continuum-web/src/main/java/org/apache/maven/continuum/web/tool/WorkingCopyContentGenerator.java
  (with props)
    maven/continuum/trunk/continuum-web/src/main/resources/templates/screens/WorkingCopy.vm
  (with props)
Modified:
    maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
    maven/continuum/trunk/continuum-core/src/main/resources/META-INF/plexus/components.xml
    maven/continuum/trunk/continuum-web/src/main/resources/META-INF/plexus/components.xml
    maven/continuum/trunk/continuum-web/src/main/resources/templates/screens/ProjectBuild.vm
    maven/continuum/trunk/continuum-web/src/main/resources/templates/screens/ProjectBuilds.vm
    maven/continuum/trunk/continuum-web/src/main/resources/templates/screens/View.vm

Modified: maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java?rev=291830&r1=291829&r2=291830&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java
(original)
+++ maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java
Mon Sep 26 23:33:19 2005
@@ -25,6 +25,7 @@
 import org.apache.maven.continuum.project.builder.ContinuumProjectBuildingResult;
 import org.codehaus.plexus.util.dag.CycleDetectedException;
 
+import java.io.File;
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
@@ -182,6 +183,19 @@
         throws ContinuumException;
 
     void removeSchedule( int scheduleId )
+        throws ContinuumException;
+
+    // ----------------------------------------------------------------------
+    // Working copy
+    // ----------------------------------------------------------------------
+
+    File getWorkingDirectory( int projectId )
+        throws ContinuumException;
+
+    String getFileContent( int projectId, String directory, String filename )
+        throws ContinuumException;
+
+    List getFiles( int projectId, String currentDirectory )
         throws ContinuumException;
 
     // ----------------------------------------------------------------------

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java?rev=291830&r1=291829&r2=291830&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
Mon Sep 26 23:33:19 2005
@@ -42,6 +42,7 @@
 import org.apache.maven.continuum.store.ContinuumStore;
 import org.apache.maven.continuum.store.ContinuumStoreException;
 import org.apache.maven.continuum.utils.ProjectSorter;
+import org.apache.maven.continuum.utils.WorkingDirectoryService;
 import org.codehaus.plexus.action.Action;
 import org.codehaus.plexus.action.ActionManager;
 import org.codehaus.plexus.action.ActionNotFoundException;
@@ -53,6 +54,7 @@
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.StoppingException;
 import org.codehaus.plexus.taskqueue.TaskQueue;
 import org.codehaus.plexus.taskqueue.TaskQueueException;
+import org.codehaus.plexus.util.FileUtils;
 import org.codehaus.plexus.util.StringUtils;
 import org.codehaus.plexus.util.dag.CycleDetectedException;
 
@@ -116,6 +118,11 @@
      */
     private String workingDirectory;
 
+    /**
+     * @plexus.requirement
+     */
+    private WorkingDirectoryService workingDirectoryService;
+
     // ----------------------------------------------------------------------
     // Projects
     // ----------------------------------------------------------------------
@@ -935,6 +942,97 @@
         {
             throw logAndCreateException( "Error while storing schedule.", ex );
         }
+    }
+
+    // ----------------------------------------------------------------------
+    // Working copy
+    // ----------------------------------------------------------------------
+
+    public File getWorkingDirectory( int projectId )
+        throws ContinuumException
+    {
+        try
+        {
+            return workingDirectoryService.getWorkingDirectory( store.getProject( projectId
) );
+        }
+        catch( ContinuumStoreException e )
+        {
+            throw new ContinuumException( "Can't get files list.", e );
+        }
+    }
+
+    public String getFileContent( int projectId, String directory, String filename )
+        throws ContinuumException
+    {
+        File workingDirectory = getWorkingDirectory( projectId );
+
+        File fileDirectory = new File( workingDirectory, directory );
+
+        File userFile = new File( fileDirectory, filename );
+
+        try
+        {
+            return FileUtils.fileRead( userFile );
+        }
+        catch( IOException e )
+        {
+            throw new ContinuumException( "Can't read file " + filename, e );
+        }
+    }
+
+    public List getFiles( int projectId, String userDirectory )
+        throws ContinuumException
+    {
+        File workingDirectory = getWorkingDirectory( projectId );
+
+        return getFiles( workingDirectory, null, userDirectory );
+    }
+
+    private List getFiles( File baseDirectory, String currentSubDirectory, String userDirectory
)
+    {
+        List dirs = new ArrayList();
+
+        File workingDirectory = null;
+
+        if ( currentSubDirectory != null )
+        {
+            workingDirectory = new File( baseDirectory, currentSubDirectory);
+        }
+        else
+        {
+            workingDirectory = baseDirectory;
+        }
+
+        String[] files = workingDirectory.list();
+
+        for ( int i = 0; i < files.length; i++ )
+        {
+            File current = new File( workingDirectory, files[i] );
+
+            String currentFile = null;
+
+            if ( currentSubDirectory == null )
+            {
+                currentFile = files[i];
+            }
+            else
+            {
+                currentFile = currentSubDirectory + "/" + files[i];
+            }
+
+            if ( userDirectory != null && current.isDirectory() && userDirectory.startsWith(
currentFile ) )
+            {
+                dirs.add( current );
+
+                dirs.add( getFiles( baseDirectory, currentFile, userDirectory ) );
+            }
+            else
+            {
+                dirs.add( current );
+            }
+        }
+
+        return dirs;
     }
 
     // ----------------------------------------------------------------------

Modified: maven/continuum/trunk/continuum-core/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/resources/META-INF/plexus/components.xml?rev=291830&r1=291829&r2=291830&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/resources/META-INF/plexus/components.xml
(original)
+++ maven/continuum/trunk/continuum-core/src/main/resources/META-INF/plexus/components.xml
Mon Sep 26 23:33:19 2005
@@ -25,6 +25,9 @@
           <role-hint>build-project</role-hint>
           <field-name>buildQueue</field-name>
         </requirement>
+        <requirement>
+          <role>org.apache.maven.continuum.utils.WorkingDirectoryService</role>
+        </requirement>
       </requirements>
       <configuration>
         <working-directory>${plexus.home}/temp</working-directory>

Added: maven/continuum/trunk/continuum-web/src/main/java/org/apache/maven/continuum/web/tool/WorkingCopyContentGenerator.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-web/src/main/java/org/apache/maven/continuum/web/tool/WorkingCopyContentGenerator.java?rev=291830&view=auto
==============================================================================
--- maven/continuum/trunk/continuum-web/src/main/java/org/apache/maven/continuum/web/tool/WorkingCopyContentGenerator.java
(added)
+++ maven/continuum/trunk/continuum-web/src/main/java/org/apache/maven/continuum/web/tool/WorkingCopyContentGenerator.java
Mon Sep 26 23:33:19 2005
@@ -0,0 +1,96 @@
+package org.apache.maven.continuum.web.tool;
+
+/*
+ * Copyright 2004-2005 The Apache Software Foundation.
+ *
+ * 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.
+ */
+
+import org.codehaus.plexus.logging.AbstractLogEnabled;
+import org.codehaus.plexus.util.StringUtils;
+
+import java.io.File;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
+ * @version $Id$
+ */
+public class WorkingCopyContentGenerator
+    extends AbstractLogEnabled
+{
+    private File basedir;
+
+    public String generate( Object item, String baseUrl, File basedir )
+    {
+        this.basedir = basedir;
+
+        List directoryEntries = (List) item;
+
+        StringBuffer buf = new StringBuffer();
+
+        buf.append( "+&nbsp;<a href=\"" + baseUrl + "?userDirectory=/\">/</a><br
/>" );
+
+        print( directoryEntries, "&nbsp;&nbsp;", baseUrl, buf );
+
+        return buf.toString();
+    }
+
+    private void print( List dirs, String indent, String baseUrl, StringBuffer buf )
+    {
+        for ( Iterator i = dirs.iterator(); i.hasNext(); )
+        {
+            Object obj = i.next();
+
+            print( obj, indent, baseUrl, buf );
+        }
+    }
+    private void print( Object obj, String indent, String baseUrl, StringBuffer buf )
+    {
+        if ( obj instanceof File )
+        {
+            File f = (File) obj;;
+
+            if ( !f.isDirectory() )
+            {
+                String userDirectory = null;
+
+                if ( f.getParentFile().getAbsolutePath().equals( basedir.getAbsolutePath()
) )
+                {
+                    userDirectory = "/";
+                }
+                else
+                {
+                    userDirectory = f.getParentFile().getAbsolutePath().substring( basedir.getAbsolutePath().length()
+ 1 );
+                }
+
+                userDirectory = StringUtils.replace( userDirectory, "\\", "/" );
+
+                buf.append( indent + "&nbsp;&nbsp;&nbsp;<a href=\"" + baseUrl
+ "?userDirectory=" + userDirectory + "&file=" + f.getName() + "\">" + f.getName()
+ "</a><br />" );
+            }
+            else
+            {
+                String userDirectory = f.getAbsolutePath().substring( basedir.getAbsolutePath().length()
+ 1 );
+
+                userDirectory = StringUtils.replace( userDirectory, "\\", "/" );
+
+                buf.append( indent + "+&nbsp;<a href=\"" + baseUrl + "?userDirectory="
+ userDirectory + "\">" + f.getName() + "</a><br />" );
+            }
+        }
+        else
+        {
+            print( (List) obj, indent + "&nbsp;&nbsp;", baseUrl, buf );
+        }
+    }
+}
\ No newline at end of file

Propchange: maven/continuum/trunk/continuum-web/src/main/java/org/apache/maven/continuum/web/tool/WorkingCopyContentGenerator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/continuum/trunk/continuum-web/src/main/java/org/apache/maven/continuum/web/tool/WorkingCopyContentGenerator.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Modified: maven/continuum/trunk/continuum-web/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-web/src/main/resources/META-INF/plexus/components.xml?rev=291830&r1=291829&r2=291830&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-web/src/main/resources/META-INF/plexus/components.xml
(original)
+++ maven/continuum/trunk/continuum-web/src/main/resources/META-INF/plexus/components.xml
Mon Sep 26 23:33:19 2005
@@ -103,6 +103,11 @@
             <scope>global</scope>
           </tool>
           <tool>
+            <name>workingCopy</name>
+            <role>workingCopy</role>
+            <scope>request</scope>
+          </tool>
+          <tool>
             <name>formtool</name>
             <role>org.apache.maven.continuum.web.tool.FormicaTool</role>
             <scope>global</scope>
@@ -146,6 +151,11 @@
       </requirements>
     </component>
 
+    <component>
+      <role>workingCopy</role>
+      <implementation>org.apache.maven.continuum.web.tool.WorkingCopyContentGenerator</implementation>
+    </component>
+
     <!--
      |
      | Valves
@@ -168,6 +178,20 @@
               <scalar>
                 <id>project</id>
                 <expression>getProjectWithAllDetails(#id)</expression>
+              </scalar>
+            </scalars>
+          </view>
+          <!--
+           |
+           | Working Copy
+           |
+           -->
+          <view>
+            <id>WorkingCopy</id>
+            <scalars>
+              <scalar>
+                <id>project</id>
+                <expression>getProject(#id)</expression>
               </scalar>
             </scalars>
           </view>

Modified: maven/continuum/trunk/continuum-web/src/main/resources/templates/screens/ProjectBuild.vm
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-web/src/main/resources/templates/screens/ProjectBuild.vm?rev=291830&r1=291829&r2=291830&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-web/src/main/resources/templates/screens/ProjectBuild.vm
(original)
+++ maven/continuum/trunk/continuum-web/src/main/resources/templates/screens/ProjectBuild.vm
Mon Sep 26 23:33:19 2005
@@ -7,8 +7,8 @@
       #set ( $infoLink = $link.setPage('View.vm').addPathInfo('fid', "$!{project.executorId}Project").addPathInfo('id',
$project.id) )
       <a style="border: 1px solid black; padding-left: 1em; padding-right: 1em; text-decoration:none;"
href="$infoLink">Info</a>
       <b style="border: 1px solid black; padding-left: 1em; padding-right: 1em;">Builds</b>
-      <!-- a style="border: 1px solid black; padding-left: 1em; padding-right: 1em; text-decoration:none;"
-         href="workingCopy.html">Working&nbsp;Copy</a -->
+      #set ( $workingCopy = $link.setPage('WorkingCopy.vm').addPathInfo('view', "WorkingCopy").addPathInfo('id',
$project.id) )
+      <a style="border: 1px solid black; padding-left: 1em; padding-right: 1em; text-decoration:none;"
href="$workingCopy">Working&nbsp;Copy</a>
     </p>
   </div>
 

Modified: maven/continuum/trunk/continuum-web/src/main/resources/templates/screens/ProjectBuilds.vm
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-web/src/main/resources/templates/screens/ProjectBuilds.vm?rev=291830&r1=291829&r2=291830&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-web/src/main/resources/templates/screens/ProjectBuilds.vm
(original)
+++ maven/continuum/trunk/continuum-web/src/main/resources/templates/screens/ProjectBuilds.vm
Mon Sep 26 23:33:19 2005
@@ -7,8 +7,8 @@
       #set ( $infoLink = $link.setPage('View.vm').addPathInfo('fid', "$!{project.executorId}Project").addPathInfo('id',
$project.id) )
       <a style="border: 1px solid black; padding-left: 1em; padding-right: 1em; text-decoration:none;"
href="$infoLink">Info</a>
       <b style="border: 1px solid black; padding-left: 1em; padding-right: 1em;">Builds</b>
-      <!-- a style="border: 1px solid black; padding-left: 1em; padding-right: 1em; text-decoration:none;"
-         href="workingCopy.html">Working&nbsp;Copy</a -->
+      #set ( $workingCopy = $link.setPage('WorkingCopy.vm').addPathInfo('view', "WorkingCopy").addPathInfo('id',
$project.id) )
+      <a style="border: 1px solid black; padding-left: 1em; padding-right: 1em; text-decoration:none;"
href="$workingCopy">Working&nbsp;Copy</a>
     </p>
   </div>
 

Modified: maven/continuum/trunk/continuum-web/src/main/resources/templates/screens/View.vm
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-web/src/main/resources/templates/screens/View.vm?rev=291830&r1=291829&r2=291830&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-web/src/main/resources/templates/screens/View.vm (original)
+++ maven/continuum/trunk/continuum-web/src/main/resources/templates/screens/View.vm Mon Sep
26 23:33:19 2005
@@ -4,11 +4,11 @@
 
   <div>
     <p style="border-top: 1px solid transparent; border-bottom: 1px solid black;">
-      #set ( $buildsLink = $link.setPage('ProjectBuilds.vm').addPathInfo('view', "ProjectBuilds").addPathInfo('id',
$item.id) )
       <b style="border: 1px solid black; padding-left: 1em; padding-right: 1em;">Info</b>
+      #set ( $buildsLink = $link.setPage('ProjectBuilds.vm').addPathInfo('view', "ProjectBuilds").addPathInfo('id',
$item.id) )
       <a style="border: 1px solid black; padding-left: 1em; padding-right: 1em; text-decoration:none;"
href="$buildsLink">Builds</a>
-      <!-- a style="border: 1px solid black; padding-left: 1em; padding-right: 1em; text-decoration:none;"
-         href="workingCopy.html">Working&nbsp;Copy</a -->
+      #set ( $workingCopy = $link.setPage('WorkingCopy.vm').addPathInfo('view', "WorkingCopy").addPathInfo('id',
$item.id) )
+      <a style="border: 1px solid black; padding-left: 1em; padding-right: 1em; text-decoration:none;"
href="$workingCopy">Working&nbsp;Copy</a>
     </p>
   </div>
 

Added: maven/continuum/trunk/continuum-web/src/main/resources/templates/screens/WorkingCopy.vm
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-web/src/main/resources/templates/screens/WorkingCopy.vm?rev=291830&view=auto
==============================================================================
--- maven/continuum/trunk/continuum-web/src/main/resources/templates/screens/WorkingCopy.vm
(added)
+++ maven/continuum/trunk/continuum-web/src/main/resources/templates/screens/WorkingCopy.vm
Mon Sep 26 23:33:19 2005
@@ -0,0 +1,28 @@
+$page.setTitle( "Continuum - Working Copy of ${project.name}" )
+
+<div class="app">
+
+  <div>
+    <p style="border-top: 1px solid transparent; border-bottom: 1px solid black;">
+      #set ( $infoLink = $link.setPage('View.vm').addPathInfo('fid', "$!{project.executorId}Project").addPathInfo('id',
$project.id) )
+      <a style="border: 1px solid black; padding-left: 1em; padding-right: 1em; text-decoration:none;"
href="$infoLink">Info</a>
+      #set ( $buildsLink = $link.setPage('ProjectBuilds.vm').addPathInfo('view', "ProjectBuilds").addPathInfo('id',
$project.id) )
+      <a style="border: 1px solid black; padding-left: 1em; padding-right: 1em; text-decoration:none;"
href="$buildsLink">Builds</a>
+      <b style="border: 1px solid black; padding-left: 1em; padding-right: 1em;">Working&nbsp;Copy</b>
+    </p>
+  </div>
+
+  <h3>Working Copy of $project.name</h3>
+  <!-- <p><a href="#">Delete Working Copy</a></p> -->
+  #set ( $files = $continuum.getFiles( $project.id, $data.getParameters().getString( "userDirectory"
) ) )
+  #set ( $baseUrl = $link.setPage('WorkingCopy.vm').addPathInfo('view', "WorkingCopy").addPathInfo('id',
$project.id) )
+  $workingCopy.generate( $files, $baseUrl.toString(), $continuum.getWorkingDirectory( $project.id
) )
+
+  #if ( $data.getParameters().getString( "file" ) )
+    #set( $filename = $data.getParameters().getString( "file" ) )
+    <br />
+    <form>
+      <textarea rows="50" cols="100">$continuum.getFileContent( $project.id, $data.getParameters().getString(
"userDirectory" ), $filename )</textarea>
+    </form>
+  #end
+</div>
\ No newline at end of file

Propchange: maven/continuum/trunk/continuum-web/src/main/resources/templates/screens/WorkingCopy.vm
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/continuum/trunk/continuum-web/src/main/resources/templates/screens/WorkingCopy.vm
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"



Mime
View raw message