You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@continuum.apache.org by ev...@apache.org on 2006/01/02 15:04:57 UTC
svn commit: r365348 - in /maven/continuum/trunk/continuum-webapp/src/main:
java/org/apache/maven/continuum/web/action/
java/org/apache/maven/continuum/web/util/ resources/
resources/META-INF/plexus/ resources/localization/ webapp/
Author: evenisse
Date: Mon Jan 2 06:04:48 2006
New Revision: 365348
URL: http://svn.apache.org/viewcvs?rev=365348&view=rev
Log:
Add working copy
Added:
maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/WorkingCopyAction.java (with props)
maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/util/WorkingCopyContentGenerator.java (with props)
maven/continuum/trunk/continuum-webapp/src/main/webapp/workingCopy.jsp (with props)
Modified:
maven/continuum/trunk/continuum-webapp/src/main/resources/META-INF/plexus/components.xml
maven/continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties
maven/continuum/trunk/continuum-webapp/src/main/resources/xwork.xml
Added: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/WorkingCopyAction.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/WorkingCopyAction.java?rev=365348&view=auto
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/WorkingCopyAction.java (added)
+++ maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/WorkingCopyAction.java Mon Jan 2 06:04:48 2006
@@ -0,0 +1,117 @@
+package org.apache.maven.continuum.web.action;
+
+/*
+ * 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.apache.maven.continuum.Continuum;
+import org.apache.maven.continuum.ContinuumException;
+import org.apache.maven.continuum.web.util.WorkingCopyContentGenerator;
+
+import com.opensymphony.webwork.ServletActionContext;
+import com.opensymphony.webwork.views.util.UrlHelper;
+import com.opensymphony.xwork.ActionSupport;
+
+import java.util.HashMap;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
+ * @version $Id$
+ */
+public class WorkingCopyAction
+ extends ActionSupport
+{
+ private Continuum continuum;
+
+ private WorkingCopyContentGenerator generator;
+
+ private int projectId;
+
+ private String projectName;
+
+ private String userDirectory;
+
+ private List files;
+
+ private String output;
+
+ public String execute()
+ {
+ try
+ {
+ files = continuum.getFiles( projectId, userDirectory );
+
+ HashMap params = new HashMap();
+
+ params.put( "projectId", new Integer( projectId ) );
+
+ params.put( "projectName", new Integer( projectName ) );
+
+ String baseUrl = UrlHelper.buildUrl( "/workingCopy.action", ServletActionContext.getRequest(), ServletActionContext.getResponse(), params );
+
+ output = generator.generate( files, baseUrl, continuum.getWorkingDirectory( projectId ) );
+ }
+ catch ( ContinuumException e )
+ {
+ addActionError( "Can't get file list for project (id=" + projectId + ") : " + e.getMessage() );
+
+ e.printStackTrace();
+
+ return ERROR;
+ }
+ return SUCCESS;
+ }
+
+ public int getProjectId()
+ {
+ return projectId;
+ }
+
+ public void setProjectId( int projectId )
+ {
+ this.projectId = projectId;
+ }
+
+ public String getProjectName()
+ {
+ return projectName;
+ }
+
+ public void setProjectName( String projectName )
+ {
+ this.projectName = projectName;
+ }
+
+ public String getUserDirectory()
+ {
+ return userDirectory;
+ }
+
+ public void setUserDirectory( String userDirectory )
+ {
+ this.userDirectory = userDirectory;
+ }
+
+ public List getFiles()
+ {
+ return files;
+ }
+
+ public String getOutput()
+ {
+ return output;
+ }
+}
\ No newline at end of file
Propchange: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/WorkingCopyAction.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/WorkingCopyAction.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/util/WorkingCopyContentGenerator.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/util/WorkingCopyContentGenerator.java?rev=365348&view=auto
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/util/WorkingCopyContentGenerator.java (added)
+++ maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/util/WorkingCopyContentGenerator.java Mon Jan 2 06:04:48 2006
@@ -0,0 +1,116 @@
+package org.apache.maven.continuum.web.util;
+
+/*
+ * 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;
+
+ private String urlParamSeparator;
+
+ public String generate( Object item, String baseUrl, File basedir )
+ {
+ this.basedir = basedir;
+ if ( baseUrl.indexOf( "?" ) > 0 )
+ {
+ urlParamSeparator = "&";
+ }
+ else
+ {
+ urlParamSeparator = "?";
+ }
+
+ List directoryEntries = (List) item;
+
+ StringBuffer buf = new StringBuffer();
+
+ buf.append( "+ <a href=\"" + baseUrl + urlParamSeparator + "userDirectory=/\">/</a><br />" );
+
+ print( directoryEntries, " ", 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 fileName = f.getName();
+
+ if ( !".cvsignore".equals( fileName ) && !"vssver.scc".equals( fileName ) && !".DS_Store".equals( fileName ) )
+ {
+ 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 + " <a href=\"" + baseUrl + urlParamSeparator + "userDirectory=" + userDirectory + "&file=" + fileName + "\">" + fileName + "</a><br />" );
+ }
+ }
+ else
+ {
+ String directoryName = f.getName();
+
+ if ( !"CVS".equals( directoryName ) && !".svn".equals( directoryName ) && !"SCCS".equals( directoryName ) )
+ {
+ String userDirectory = f.getAbsolutePath().substring( basedir.getAbsolutePath().length() + 1 );
+
+ userDirectory = StringUtils.replace( userDirectory, "\\", "/" );
+
+ buf.append( indent + "+ <a href=\"" + baseUrl + urlParamSeparator + "userDirectory=" + userDirectory + "\">" + directoryName + "</a><br />" );
+ }
+ }
+ }
+ else
+ {
+ print( (List) obj, indent + " ", baseUrl, buf );
+ }
+ }
+}
\ No newline at end of file
Propchange: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/util/WorkingCopyContentGenerator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/util/WorkingCopyContentGenerator.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Modified: maven/continuum/trunk/continuum-webapp/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-webapp/src/main/resources/META-INF/plexus/components.xml?rev=365348&r1=365347&r2=365348&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/resources/META-INF/plexus/components.xml (original)
+++ maven/continuum/trunk/continuum-webapp/src/main/resources/META-INF/plexus/components.xml Mon Jan 2 06:04:48 2006
@@ -227,6 +227,20 @@
</requirement>
</requirements>
</component>
+ <component>
+ <role>com.opensymphony.xwork.Action</role>
+ <role-hint>workingCopy</role-hint>
+ <implementation>org.apache.maven.continuum.web.action.WorkingCopyAction</implementation>
+ <instantiation-strategy>per-lookup</instantiation-strategy>
+ <requirements>
+ <requirement>
+ <role>org.apache.maven.continuum.Continuum</role>
+ </requirement>
+ <requirement>
+ <role>org.apache.maven.continuum.web.util.WorkingCopyContentGenerator</role>
+ </requirement>
+ </requirements>
+ </component>
<!--
| Components
@@ -333,6 +347,10 @@
</property>
</properties>
</configuration>
+ </component>
+ <component>
+ <role>org.apache.maven.continuum.web.util.WorkingCopyContentGenerator</role>
+ <implementation>org.apache.maven.continuum.web.util.WorkingCopyContentGenerator</implementation>
</component>
</components>
Modified: maven/continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties?rev=365348&r1=365347&r2=365348&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties (original)
+++ maven/continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties Mon Jan 2 06:04:48 2006
@@ -246,3 +246,9 @@
buildResults.startTime = Start Time
buildResults.endTime = End Time
buildResults.state = State
+
+// ----------------------------------------------------------------------
+// Page: WorkingCopy
+// ----------------------------------------------------------------------
+workingCopy.page.title = Continuum - Working Copy
+workingCopy.section.title = Working Copy for {0}
Modified: maven/continuum/trunk/continuum-webapp/src/main/resources/xwork.xml
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-webapp/src/main/resources/xwork.xml?rev=365348&r1=365347&r2=365348&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/resources/xwork.xml (original)
+++ maven/continuum/trunk/continuum-webapp/src/main/resources/xwork.xml Mon Jan 2 06:04:48 2006
@@ -149,5 +149,10 @@
class="buildResults">
<result name="success">buildResults.jsp</result>
</action>
+
+ <action name="workingCopy"
+ class="workingCopy">
+ <result name="success">workingCopy.jsp</result>
+ </action>
</package>
</xwork>
Added: maven/continuum/trunk/continuum-webapp/src/main/webapp/workingCopy.jsp
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-webapp/src/main/webapp/workingCopy.jsp?rev=365348&view=auto
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/webapp/workingCopy.jsp (added)
+++ maven/continuum/trunk/continuum-webapp/src/main/webapp/workingCopy.jsp Mon Jan 2 06:04:48 2006
@@ -0,0 +1,27 @@
+<%@ taglib uri="webwork" prefix="ww" %>
+<html>
+ <ww:i18n name="localization.Continuum">
+ <head>
+ <title><ww:text name="workingCopy.page.title"/></title>
+ </head>
+ <body>
+ <div id="h3">
+ <div>
+ <p style="border-top: 1px solid transparent; border-bottom: 1px solid black;">
+ <a style="border: 1px solid black; padding-left: 1em; padding-right: 1em; text-decoration:none;" href="<ww:url value="/projectView.action?projectId="/><ww:property value="projectId"/>&projectName=<ww:property value="projectName"/>">Info</a>
+ <a style="border: 1px solid black; padding-left: 1em; padding-right: 1em; text-decoration:none;" href="<ww:url value="/buildResults.action?projectId="/><ww:property value="projectId"/>&projectName=<ww:property value="projectName"/>">Builds</a>
+ <b style="border: 1px solid black; padding-left: 1em; padding-right: 1em;">Working Copy</b>
+ </p>
+ </div>
+
+ <h3>
+ <ww:text name="workingCopy.section.title">
+ <ww:param><ww:property value="projectName"/></ww:param>
+ </ww:text>
+ </h3>
+
+ <ww:property value="output"/>
+ </div>
+ </body>
+ </ww:i18n>
+</html>
Propchange: maven/continuum/trunk/continuum-webapp/src/main/webapp/workingCopy.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/continuum/trunk/continuum-webapp/src/main/webapp/workingCopy.jsp
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"