continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r582423 - in /maven/continuum/trunk: continuum-core/src/main/java/org/apache/maven/continuum/core/action/ continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ continuum-webapp/src/main/java/org/apache/maven/continuum/web/ac...
Date Fri, 05 Oct 2007 23:28:20 GMT
Author: olamy
Date: Fri Oct  5 16:28:18 2007
New Revision: 582423

URL: http://svn.apache.org/viewvc?rev=582423&view=rev
Log:
[CONTINUUM-1487] prevent user deleting buildResult current building

Added:
    maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AbstractBuildAction.java
  (with props)
Modified:
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/ExecuteBuilderContinuumAction.java
    maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/BuildResultAction.java
    maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/BuildResultsListAction.java
    maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ContinuumActionSupport.java
    maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/InstallationAction.java
    maven/continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties
    maven/continuum/trunk/continuum-webapp/src/main/resources/log4j.xml
    maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/buildResult.jsp
    maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/confirmBuildResultsRemoval.jsp

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/ExecuteBuilderContinuumAction.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/ExecuteBuilderContinuumAction.java?rev=582423&r1=582422&r2=582423&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/ExecuteBuilderContinuumAction.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/ExecuteBuilderContinuumAction.java
Fri Oct  5 16:28:18 2007
@@ -126,6 +126,8 @@
 
         buildResult.setModifiedDependencies( updatedDependencies );
 
+        buildResult.setBuildDefinition( getBuildDefinition( context ) );
+        
         store.addBuildResult( project, buildResult );
 
         context.put( KEY_BUILD_ID, Integer.toString( buildResult.getId() ) );

Added: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AbstractBuildAction.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AbstractBuildAction.java?rev=582423&view=auto
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AbstractBuildAction.java
(added)
+++ maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AbstractBuildAction.java
Fri Oct  5 16:28:18 2007
@@ -0,0 +1,81 @@
+/*
+ * 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.maven.continuum.web.action;
+
+import org.apache.maven.continuum.buildqueue.BuildProjectTask;
+import org.apache.maven.continuum.model.project.BuildResult;
+import org.apache.maven.continuum.project.ContinuumProjectState;
+import org.codehaus.plexus.taskqueue.execution.TaskQueueExecutor;
+
+/**
+ * @author <a href="mailto:olamy@apache.org">olamy</a>
+ * @since 5 oct. 07
+ * @version $Id$
+ */
+public abstract class AbstractBuildAction
+    extends ContinuumConfirmAction
+{
+    
+    private int projectId;
+    
+    private boolean canDelete = true;
+    
+    /**
+     * @plexus.requirement role-hint='build-project'
+     */
+    private TaskQueueExecutor taskQueueExecutor; 
+    
+    
+    
+    protected TaskQueueExecutor getTaskQueueExecutor()
+    {
+        return this.taskQueueExecutor;
+    }
+    
+    protected boolean canRemoveBuildResult(BuildResult buildResult)
+    {
+        BuildProjectTask buildProjectTask = (BuildProjectTask) getTaskQueueExecutor().getCurrentTask();
+        if ( buildProjectTask != null && buildResult != null )
+        {
+            return !( buildResult.getState() == ContinuumProjectState.BUILDING &&
( buildProjectTask
+                .getBuildDefinitionId() == buildResult.getBuildDefinition().getId() &&
buildProjectTask.getProjectId() == this.getProjectId() ) );
+        }
+        return true;
+    }
+
+    public int getProjectId()
+    {
+        return projectId;
+    }
+
+    public void setProjectId( int projectId )
+    {
+        this.projectId = projectId;
+    }
+
+    public boolean isCanDelete()
+    {
+        return canDelete;
+    }
+
+    public void setCanDelete( boolean canDelete )
+    {
+        this.canDelete = canDelete;
+    }
+}

Propchange: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AbstractBuildAction.java
------------------------------------------------------------------------------
    svn:eol-style = LF

Propchange: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AbstractBuildAction.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AbstractBuildAction.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Fri Oct  5 16:28:18 2007
@@ -0,0 +1 @@
+URL HeadURL Author LastChangedBy Date LastChangedDate Rev Revision LastChangedRevision Id

Modified: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/BuildResultAction.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/BuildResultAction.java?rev=582423&r1=582422&r2=582423&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/BuildResultAction.java
(original)
+++ maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/BuildResultAction.java
Fri Oct  5 16:28:18 2007
@@ -19,23 +19,25 @@
  * under the License.
  */
 
-import com.opensymphony.webwork.ServletActionContext;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.List;
 
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang.StringEscapeUtils;
 import org.apache.maven.continuum.ContinuumException;
+import org.apache.maven.continuum.buildqueue.BuildProjectTask;
 import org.apache.maven.continuum.configuration.ConfigurationException;
 import org.apache.maven.continuum.model.project.BuildResult;
 import org.apache.maven.continuum.model.project.Project;
+import org.apache.maven.continuum.project.ContinuumProjectState;
 import org.apache.maven.continuum.web.exception.AuthorizationRequiredException;
 import org.apache.maven.continuum.web.util.StateGenerator;
 import org.codehaus.plexus.util.FileUtils;
 import org.codehaus.plexus.util.StringUtils;
 
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.List;
+import com.opensymphony.webwork.ServletActionContext;
 
 /**
  * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
@@ -43,7 +45,7 @@
  * @plexus.component role="com.opensymphony.xwork.Action" role-hint="buildResult"
  */
 public class BuildResultAction
-    extends ContinuumConfirmAction
+    extends AbstractBuildAction
 {
     private Project project;
 
@@ -51,8 +53,6 @@
 
     private int buildId;
 
-    private int projectId;
-
     private List changeSet;
 
     private boolean hasSurefireResults;
@@ -63,7 +63,6 @@
 
     private String projectGroupName = "";
     
-
     public String execute()
         throws ContinuumException, ConfigurationException, IOException
     {
@@ -83,7 +82,7 @@
         buildResult = getContinuum().getBuildResult( getBuildId() );
 
         // directory contains files ?
-        File surefireReportsDirectory = getContinuum().getConfiguration().getTestReportsDirectory(
buildId, projectId );
+        File surefireReportsDirectory = getContinuum().getConfiguration().getTestReportsDirectory(
buildId, getProjectId() );
         File[] files = surefireReportsDirectory.listFiles();
         if ( files == null )
         {
@@ -99,6 +98,7 @@
         
         state = StateGenerator.generate( buildResult.getState(), ServletActionContext.getRequest().getContextPath()
);
 
+        this.setCanDelete( this.canRemoveBuildResult( buildResult ) );
         return SUCCESS;
     }
     
@@ -164,16 +164,6 @@
         return project;
     }
 
-    public int getProjectId()
-    {
-        return projectId;
-    }
-
-    public void setProjectId( int projectId )
-    {
-        this.projectId = projectId;
-    }
-
     public BuildResult getBuildResult()
     {
         return buildResult;
@@ -214,4 +204,5 @@
 
         return projectGroupName;
     }
+
 }

Modified: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/BuildResultsListAction.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/BuildResultsListAction.java?rev=582423&r1=582422&r2=582423&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/BuildResultsListAction.java
(original)
+++ maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/BuildResultsListAction.java
Fri Oct  5 16:28:18 2007
@@ -19,13 +19,18 @@
  * under the License.
  */
 
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ResourceBundle;
+
 import org.apache.maven.continuum.ContinuumException;
 import org.apache.maven.continuum.model.project.Project;
 import org.apache.maven.continuum.web.exception.AuthorizationRequiredException;
 import org.codehaus.plexus.util.StringUtils;
 
-import java.util.Collection;
-import java.util.Iterator;
+import com.opensymphony.xwork.util.LocalizedTextUtil;
 
 /**
  * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
@@ -33,13 +38,13 @@
  * @plexus.component role="com.opensymphony.xwork.Action" role-hint="buildResults"
  */
 public class BuildResultsListAction
-    extends ContinuumConfirmAction
+    extends AbstractBuildAction
 {
     private Project project;
 
     private Collection buildResults;
     
-    private Collection selectedBuildResults;
+    private Collection<String> selectedBuildResults;
 
     private int projectId;
     
@@ -83,9 +88,9 @@
         {
             if ( selectedBuildResults != null && !selectedBuildResults.isEmpty()
)
             {
-                for ( Iterator i = selectedBuildResults.iterator(); i.hasNext(); )
+                for ( String id : selectedBuildResults )
                 {
-                    int buildId = Integer.parseInt( (String) i.next() );
+                    int buildId = Integer.parseInt( id );
 
                     try
                     {
@@ -101,6 +106,32 @@
                 }
             }
             return SUCCESS;
+        }
+        else
+        {
+            List<String> buildResultsRemovable = new ArrayList<String>();
+            if ( selectedBuildResults != null && !selectedBuildResults.isEmpty()
)
+            {
+                for ( String id : selectedBuildResults )
+                {
+                    int buildId = Integer.parseInt( id );
+
+                    if ( canRemoveBuildResult( getContinuum().getBuildResult( buildId ) )
)
+                    {
+                        buildResultsRemovable.add( Integer.toString( buildId ) );
+                    }
+                    else
+                    {
+
+                        ResourceBundle resourceBundle = getResourceBundle();
+                        String message = LocalizedTextUtil.findText( resourceBundle, "buildResult.cannot.delete",
+                                                                     getLocale(), "", new
String[] { Integer
+                                                                         .toString( buildId
) } );
+                        this.addActionMessage( message );
+                    }
+                }
+            }
+            this.setSelectedBuildResults( buildResultsRemovable );
         }
         return CONFIRM;
     }

Modified: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ContinuumActionSupport.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ContinuumActionSupport.java?rev=582423&r1=582422&r2=582423&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ContinuumActionSupport.java
(original)
+++ maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ContinuumActionSupport.java
Fri Oct  5 16:28:18 2007
@@ -19,6 +19,8 @@
  * under the License.
  */
 
+import java.util.ResourceBundle;
+
 import com.opensymphony.xwork.ActionContext;
 import com.opensymphony.xwork.Preparable;
 import org.apache.maven.continuum.Continuum;
@@ -510,4 +512,9 @@
 
         return true;
     }
+    
+    protected ResourceBundle getResourceBundle()
+    {
+        return getTexts( "localization/Continuum" );
+    }    
 }

Modified: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/InstallationAction.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/InstallationAction.java?rev=582423&r1=582422&r2=582423&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/InstallationAction.java
(original)
+++ maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/InstallationAction.java
Fri Oct  5 16:28:18 2007
@@ -1,6 +1,11 @@
 package org.apache.maven.continuum.web.action.admin;
 
-import com.opensymphony.xwork.Preparable;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.ResourceBundle;
+
 import org.apache.maven.continuum.installation.InstallationService;
 import org.apache.maven.continuum.model.system.Installation;
 import org.apache.maven.continuum.security.ContinuumRoleConstants;
@@ -10,12 +15,7 @@
 import org.codehaus.plexus.redback.xwork.interceptor.SecureActionBundle;
 import org.codehaus.plexus.redback.xwork.interceptor.SecureActionException;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.ResourceBundle;
+import com.opensymphony.xwork.Preparable;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -193,10 +193,7 @@
     // -----------------------------------------------------
     // getter/setters
     // -----------------------------------------------------
-    protected ResourceBundle getResourceBundle()
-    {
-        return getTexts( "localization/Continuum" );
-    }
+
     public List<Installation> getInstallations()
     {
         return installations;

Modified: maven/continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties?rev=582423&r1=582422&r2=582423&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
Fri Oct  5 16:28:18 2007
@@ -748,4 +748,4 @@
 buildResult.delete.confirmation.page.title = Continuum - Delete Build Results
 buildResult.delete.confirmation.section.title = Delete Build Results
 buildResult.delete.confirmation.message = Are you sure you want to delete {0} build results
? 
-
+buildResult.cannot.delete = Cannot delete a build result which is currently building '{0}'

Modified: maven/continuum/trunk/continuum-webapp/src/main/resources/log4j.xml
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/resources/log4j.xml?rev=582423&r1=582422&r2=582423&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/resources/log4j.xml (original)
+++ maven/continuum/trunk/continuum-webapp/src/main/resources/log4j.xml Fri Oct  5 16:28:18
2007
@@ -67,7 +67,7 @@
 
   <!-- CONTINUUM-1228 -->
   <logger name="com.opensymphony.xwork.util.OgnlUtil">
-    <level value="info"/>
+    <level value="error"/>
   </logger>
 
   <logger name="com.opensymphony.webwork">
@@ -103,7 +103,7 @@
   </logger>
 
   <root>
-    <priority value ="info" />
+    <priority value="info" />
     <appender-ref ref="console" />
     <appender-ref ref="rolling" />
   </root>

Modified: maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/buildResult.jsp
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/buildResult.jsp?rev=582423&r1=582422&r2=582423&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/buildResult.jsp (original)
+++ maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/buildResult.jsp Fri
Oct  5 16:28:18 2007
@@ -77,7 +77,12 @@
                   <form action="removeBuildResult.action">
                     <input type="hidden" name="projectId" value="<ww:property value="projectId"/>"/>
                     <input type="hidden" name="buildId" value="<ww:property value="buildId"/>"/>
-                    <input type="submit" name="delete-project" value="<ww:text name="delete"/>"/>
+                    <ww:if test="canDelete">
+                      <input type="submit" name="delete-project" value="<ww:text name="delete"/>"/>
+                    </ww:if>
+                    <ww:else>
+                      <input type="submit" disabled="true" name="delete-project" value="<ww:text
name="delete"/>"/>
+                    </ww:else>                    
                   </form>
                 </redback:ifAuthorized>
               </td>

Modified: maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/confirmBuildResultsRemoval.jsp
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/confirmBuildResultsRemoval.jsp?rev=582423&r1=582422&r2=582423&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/confirmBuildResultsRemoval.jsp
(original)
+++ maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/confirmBuildResultsRemoval.jsp
Fri Oct  5 16:28:18 2007
@@ -28,6 +28,13 @@
       <div id="axial" class="h3">
         <h3><ww:text name="buildResult.delete.confirmation.section.title"/></h3>
         <div class="axial">
+        <ww:if test="hasActionMessages()">
+          <div class="warningmessage">
+            <p>
+              <ww:actionmessage/>
+            </p>        
+          </div>
+        </ww:if>
         <!-- in this case we come from the build result edit -->
         <ww:if test="buildId">
           <form action="removeBuildResult.action" method="post">
@@ -61,7 +68,15 @@
           </div>
 
           <div class="functnbar3">
-            <c1:submitcancel value="%{getText('delete')}" cancel="%{getText('cancel')}"/>
+            <ww:if test="buildId > 0">
+              <c1:submitcancel value="%{getText('delete')}" cancel="%{getText('cancel')}"/>
+            </ww:if>
+            <ww:elseif test="selectedBuildResults.size > 0">
+              <c1:submitcancel value="%{getText('delete')}" cancel="%{getText('cancel')}"/>
+            </ww:elseif>
+            <ww:else>
+              <input type="submit" value="<ww:text name="cancel"/>" onClick="history.back()"/>

+            </ww:else>
           </div>
         </form>
         </div>



Mime
View raw message