continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject svn commit: r776644 - in /continuum/trunk/continuum-webapp/src/main: java/org/apache/continuum/web/action/admin/ java/org/apache/maven/continuum/web/action/ java/org/apache/maven/continuum/web/action/admin/ resources/ resources/localization/ webapp/WEB...
Date Wed, 20 May 2009 10:02:48 GMT
Author: ctan
Date: Wed May 20 10:02:47 2009
New Revision: 776644

URL: http://svn.apache.org/viewvc?rev=776644&view=rev
Log:
better handling of error messages
merge -r 776639:776640 from 1.3.x branch

Modified:
    continuum/trunk/continuum-webapp/src/main/java/org/apache/continuum/web/action/admin/LocalRepositoryAction.java
    continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/BuildResultsListAction.java
    continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/DeleteProjectAction.java
    continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectGroupAction.java
    continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectsListAction.java
    continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/ProfileAction.java
    continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties
    continuum/trunk/continuum-webapp/src/main/resources/struts.xml
    continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/buildResults.jsp
    continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/groupSummary.jsp

Modified: continuum/trunk/continuum-webapp/src/main/java/org/apache/continuum/web/action/admin/LocalRepositoryAction.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/java/org/apache/continuum/web/action/admin/LocalRepositoryAction.java?rev=776644&r1=776643&r2=776644&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/java/org/apache/continuum/web/action/admin/LocalRepositoryAction.java
(original)
+++ continuum/trunk/continuum-webapp/src/main/java/org/apache/continuum/web/action/admin/LocalRepositoryAction.java
Wed May 20 10:02:47 2009
@@ -68,9 +68,7 @@
     private List<String> layouts;
     
     private Map<String, Boolean> defaultPurgeMap;
-    
-    private String message;
-    
+
     /**
      * @plexus.requirement
      */
@@ -112,13 +110,6 @@
     public String list()
         throws Exception
     {
-        String errorMessage = ServletActionContext.getRequest().getParameter( "errorMessage"
);
-        
-        if ( errorMessage != null )
-        {
-            addActionError( getText( errorMessage ) );
-        }
-        
         repositories = repositoryService.getAllLocalRepositories();
         
         defaultPurgeMap = new HashMap<String, Boolean>();
@@ -209,29 +200,31 @@
         throws Exception
     {
         TaskQueueManager taskQueueManager = getContinuum().getTaskQueueManager();
+
+        repository = repositoryService.getLocalRepository( repository.getId() );
+
         if ( taskQueueManager.isRepositoryInUse( repository.getId() ) )
         {
-            message = "repository.error.remove.in.use";
-            return ERROR;
+            addActionError( getText( "repository.error.remove.in.use", "Unable to remove
local repository because it is in use" ) );
         }
-        
-        repository = repositoryService.getLocalRepository( repository.getId() );
-        
+
         if ( repository.getName().equals( "DEFAULT" ) )
         {
-            message = "repository.error.remove.default";
-            return ERROR;
-        }
-        
-        if ( confirmed )
-        {
-            repositoryService.removeLocalRepository( repository.getId() );
+            addActionError( getText( "repository.error.remove.default", "Unable to remove
default local repository" ) );
         }
-        else
+
+        if ( !hasActionErrors() )
         {
-            return CONFIRM;
+            if ( confirmed )
+            {
+                repositoryService.removeLocalRepository( repository.getId() );
+            }
+            else
+            {
+                return CONFIRM;
+            }
         }
-        
+
         return SUCCESS;
     }
     
@@ -244,18 +237,19 @@
         // check if repository is in use
         if ( taskQueueManager.isRepositoryInUse( repository.getId() ) )
         {
-            message = "repository.error.purge.in.use";
-            return ERROR;
+            addActionError( getText( "repository.error.purge.in.use", "Unable to purge repository
because it is in use" ) );
         }
-        
-        // get default purge configuration for repository
-        RepositoryPurgeConfiguration purgeConfig = purgeConfigService.getDefaultPurgeConfigurationForRepository(
repository.getId() );
-        
-        if ( purgeConfig != null )
+     
+        if ( !hasActionErrors() )
         {
-            purgeManager.purgeRepository( purgeConfig );
-        }
+            // get default purge configuration for repository
+            RepositoryPurgeConfiguration purgeConfig = purgeConfigService.getDefaultPurgeConfigurationForRepository(
repository.getId() );
         
+            if ( purgeConfig != null )
+            {
+                purgeManager.purgeRepository( purgeConfig );
+            }
+        }
         return SUCCESS;
     }
     
@@ -323,17 +317,7 @@
     {
         this.defaultPurgeMap = defaultPurgeMap;
     }
-    
-    public String getMessage()
-    {
-        return this.message;
-    }
-    
-    public void setMessage( String message )
-    {
-        this.message = message;
-    }
-    
+
     private void createDefaultPurgeConfiguration()
         throws Exception
     {

Modified: continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/BuildResultsListAction.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/BuildResultsListAction.java?rev=776644&r1=776643&r2=776644&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/BuildResultsListAction.java
(original)
+++ continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/BuildResultsListAction.java
Wed May 20 10:02:47 2009
@@ -103,7 +103,8 @@
                     catch ( ContinuumException e )
                     {
                         logger.error( "Error removing BuildResult with id=" + buildId );
-                        addActionError( getText( "Unable to remove BuildResult with id="
+ buildId ) );
+                        addActionError( getText( "buildResult.delete.error", "Unable to delete
build result",
+                                                 new Integer( buildId ).toString() ) );
                     }
                 }
             }
@@ -127,6 +128,7 @@
                         else
                         {
                             this.addActionMessage( getResourceBundle().getString( "buildResult.cannot.delete"
) );
+                            return SUCCESS;
                         }
                     }
                     catch ( BuildManagerException e )

Modified: continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/DeleteProjectAction.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/DeleteProjectAction.java?rev=776644&r1=776643&r2=776644&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/DeleteProjectAction.java
(original)
+++ continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/DeleteProjectAction.java
Wed May 20 10:02:47 2009
@@ -24,6 +24,8 @@
 import org.apache.maven.continuum.ContinuumException;
 import org.apache.maven.continuum.model.project.Project;
 import org.apache.maven.continuum.web.exception.AuthorizationRequiredException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
@@ -33,6 +35,8 @@
 public class DeleteProjectAction
     extends ContinuumActionSupport
 {
+    private Logger logger = LoggerFactory.getLogger( this.getClass() );
+
     private int projectId;
 
     private String projectName;
@@ -58,7 +62,16 @@
         event.setCategory( AuditLogConstants.PROJECT );
         event.log();
 
-        getContinuum().removeProject( projectId );
+        try
+        {
+            getContinuum().removeProject( projectId );
+        }
+        catch ( ContinuumException e )
+        {
+            logger.error( "Error removing project with id " + projectId, e );
+            addActionError( getText( "deleteProject.error", "Unable to delete project", 
+                                     new Integer( projectId ).toString() ) );
+        }
 
         return SUCCESS;
     }

Modified: continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectGroupAction.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectGroupAction.java?rev=776644&r1=776643&r2=776644&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectGroupAction.java
(original)
+++ continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectGroupAction.java
Wed May 20 10:02:47 2009
@@ -296,7 +296,16 @@
 
         if ( confirmed )
         {
-            getContinuum().removeProjectGroup( projectGroupId );
+            try
+            {
+                getContinuum().removeProjectGroup( projectGroupId );
+            }
+            catch ( ContinuumException e )
+            {
+                logger.error( "Error while removing project group with id " + projectGroupId,
e );
+                addActionError( getText( "projectGroup.delete.error", "Unable to remove project
group",
+                                new Integer( projectGroupId ).toString() ) );
+            }
         }
         else
         {

Modified: continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectsListAction.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectsListAction.java?rev=776644&r1=776643&r2=776644&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectsListAction.java
(original)
+++ continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectsListAction.java
Wed May 20 10:02:47 2009
@@ -109,7 +109,8 @@
                 catch ( ContinuumException e )
                 {
                     logger.error( "Error removing Project with id=" + projectId );
-                    addActionError( getText( "Unable to remove Project with id=" + projectId
) );
+                    addActionError( getText( "deleteProject.error", "Unable to delete project",
+                                             new Integer( projectId ).toString() ) );
                 }
             }
         }

Modified: continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/ProfileAction.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/ProfileAction.java?rev=776644&r1=776643&r2=776644&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/ProfileAction.java
(original)
+++ continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/ProfileAction.java
Wed May 20 10:02:47 2009
@@ -77,8 +77,6 @@
 
     private List<BuildAgentGroupConfiguration> buildAgentGroups;
 
-    private String message;
-
     public void prepare()
         throws Exception
     {
@@ -106,13 +104,6 @@
     public String list()
         throws Exception
     {
-        String errorMessage = ServletActionContext.getRequest().getParameter( "errorMessage"
);
-
-        if ( errorMessage != null )
-        {
-            addActionError( getText( errorMessage ) );
-        }
-
         this.profiles = profileService.getAllProfiles();
         return SUCCESS;
     }
@@ -188,13 +179,13 @@
         {
             profileService.deleteProfile( profile.getId() );
             this.profiles = profileService.getAllProfiles();
-            return SUCCESS;
         }
         catch ( ProfileException e )
         {
-            message = "profile.remove.error";
+            addActionError( getText( "profile.remove.error" ) );
             return ERROR;
         }
+        return SUCCESS;
     }
 
     public String confirmDelete()
@@ -326,16 +317,6 @@
         this.installationId = installationId;
     }
 
-    public String getMessage()
-    {
-        return message;
-    }
-
-    public void setMessage( String message )
-    {
-        this.message = message;
-    }
-
     public List<BuildAgentGroupConfiguration> getBuildAgentGroups()
     {
         return buildAgentGroups;

Modified: continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties?rev=776644&r1=776643&r2=776644&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties
(original)
+++ continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties
Wed May 20 10:02:47 2009
@@ -239,6 +239,11 @@
 confirmGroupRemoval.confirmation.message=Are you sure you want to delete the project group
"{0}"?
 
 # ----------------------------------------------------------------------
+# Page: Delete Project Group
+# ----------------------------------------------------------------------
+projectGroup.delete.error = Unable to remove project group
+
+# ----------------------------------------------------------------------
 # Page: Configuration
 # ----------------------------------------------------------------------
 configuration.page.title = Continuum - Configuration
@@ -378,6 +383,7 @@
 deleteProject.page.title = Continuum - Delete Continuum Project
 deleteProject.section.title = Delete Continuum Project
 deleteProject.confirmation.message = Are you sure you want to delete the project "{0}"?
+deleteProject.error = Unable to delete project with id {0}
 
 # ----------------------------------------------------------------------
 # Page: ProjectView
@@ -534,6 +540,7 @@
 buildResults.state = State
 buildResults.result = Result
 buildResults.buildDefinition.description = Build Definition Description
+buildResults.delete.error = Unable to delete Build Results
 
 # ----------------------------------------------------------------------
 # Page: BuildResults
@@ -904,7 +911,8 @@
 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.
+buildResult.cannot.delete = Cannot delete the build result of a currently building project.
+buildResult.delete.error = Unable to delete Build Result with id {0}
 
 # ----------------------------------------------------------------------
 # Legend
@@ -967,7 +975,7 @@
 repository.error.save.in.use = Unable to edit local repository because it is currently in
use 
 repository.error.remove.in.use = Unable to remove local repository because it is currently
in use
 repository.error.purge.in.use = Unable to purge local repository because it is currently
in use
-repository.error.remove.default = Cannot remove default local repository.
+repository.error.remove.default = Cannot remove default local repository
 
 #-----------------------------------------------------------------------
 # Page: Delete Local Repository

Modified: continuum/trunk/continuum-webapp/src/main/resources/struts.xml
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/resources/struts.xml?rev=776644&r1=776643&r2=776644&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/resources/struts.xml (original)
+++ continuum/trunk/continuum-webapp/src/main/resources/struts.xml Wed May 20 10:02:47 2009
@@ -67,6 +67,20 @@
           <param name="excludeMethods">input,back,cancel,browse,edit</param>
         </interceptor-ref>
       </interceptor-stack>
+      
+      <interceptor-stack name="storeStack">
+        <interceptor-ref name="defaultStack"/>
+        <interceptor-ref name="store">
+          <param name="operationMode">STORE</param>
+        </interceptor-ref>
+      </interceptor-stack>
+
+      <interceptor-stack name="retrieveStack">
+        <interceptor-ref name="defaultStack"/>
+        <interceptor-ref name="store">
+          <param name="operationMode">RETRIEVE</param>
+        </interceptor-ref>
+      </interceptor-stack> 
     </interceptors>
 
     <default-interceptor-ref name="configuredContinuumStack"/>
@@ -167,6 +181,7 @@
     
 
     <action name="groupSummary" class="groupSummary">
+      <interceptor-ref name="retrieveStack"/>
       <result name="success">/WEB-INF/jsp/groupSummary.jsp</result>
     </action>
 
@@ -223,6 +238,7 @@
     </action>
 
     <action name="deleteProject" class="deleteProject">
+      <interceptor-ref name="storeStack"/>
       <result name="delete">/WEB-INF/jsp/deleteProject.jsp</result>
       <result name="success" type="redirect-action">
         <param name="actionName">projectGroupSummary</param>
@@ -231,6 +247,7 @@
     </action>
 
     <action name="ProjectsList" class="projects">
+      <interceptor-ref name="storeStack"/>
       <result name="confirmRemove">/WEB-INF/jsp/confirmDeleteProjects.jsp</result>
       <result name="success" type="redirect-action">
         <param name="actionName">projectGroupSummary</param>
@@ -300,6 +317,7 @@
     * project group actions
     -->
     <action name="projectGroupSummary" class="projectGroup" method="summary">
+      <interceptor-ref name="retrieveStack"/>
       <result name="success">/WEB-INF/jsp/projectGroupSummary.jsp</result>
     </action>
 
@@ -324,6 +342,7 @@
     </action>
 
     <action name="removeProjectGroup" class="projectGroup" method="remove">
+      <interceptor-ref name="storeStack"/>
       <result name="confirm">/WEB-INF/jsp/confirmGroupRemoval.jsp</result>
       <result name="success" type="redirect-action">
         <param name="actionName">groupSummary</param>
@@ -362,10 +381,12 @@
     *  build results, test reporting, working copy actions
     -->
     <action name="buildResults" class="buildResults">
+      <interceptor-ref name="retrieveStack"/>
       <result name="success">/WEB-INF/jsp/buildResults.jsp</result>
     </action>
     
     <action name="removeBuildResults" class="buildResults" method="remove">
+      <interceptor-ref name="storeStack"/>
       <result name="success" type="redirect-action">
         <param name="actionName">buildResults</param>
         <param name="projectId">${projectId}</param>
@@ -374,6 +395,7 @@
     </action>
 
     <action name="buildResult" class="buildResult">
+      <interceptor-ref name="storeStack"/>
       <result name="success">/WEB-INF/jsp/buildResult.jsp</result>
       <result name="error" type="redirect-action">
         <param name="actionName">projectGroupSummary</param>
@@ -389,6 +411,7 @@
     </action>    
     
     <action name="removeBuildResult" class="buildResult" method="remove">
+      <interceptor-ref name="storeStack"/>
       <result name="success" type="redirect-action">
         <param name="actionName">buildResults</param>
         <param name="projectId">${projectId}</param>
@@ -648,6 +671,7 @@
     -->      
       
     <action name="buildEnvList" class="profileAdministration" method="list">
+      <interceptor-ref name="retrieveStack"/>
       <result name="success">/WEB-INF/jsp/admin/profilesList.jsp</result>
     </action>   
       
@@ -661,17 +685,12 @@
     </action>
       
     <action name="deleteBuildEnv" class="profileAdministration" method="delete">
+      <interceptor-ref name="storeStack"/>
       <result name="success" type="redirect-action">
         <param name="actionName">buildEnvList</param>
         <param name="namespace">/admin</param>
         <param name="method">list</param>
       </result>
-      <result name="error" type="redirect-action">
-        <param name="actionName">buildEnvList</param>
-        <param name="namespace">/admin</param>
-        <param name="method">list</param>
-        <param name="errorMessage">${message}</param>
-      </result>
     </action>      
     
     <action name="confirmDeleteBuildEnv" class="profileAdministration" method="confirmDelete">
@@ -891,6 +910,7 @@
     -->
     
     <action name="repositoryList" class="localRepository" method="list">
+      <interceptor-ref name="retrieveStack"/>
       <result name="success">/WEB-INF/jsp/admin/localRepositoriesList.jsp</result>
     </action>
     
@@ -908,10 +928,7 @@
     </action>
     
     <action name="removeRepository" class="localRepository" method="remove">
-      <result name="error" type="redirect-action">
-        <param name="actionName">repositoryList</param>
-        <param name="errorMessage">${message}</param>
-      </result>
+      <interceptor-ref name="storeStack"/>
       <result name="confirm">/WEB-INF/jsp/admin/confirmDeleteLocalRepository.jsp</result>
       <result name="success" type="redirect-action">
         <param name="actionName">repositoryList</param>
@@ -919,13 +936,10 @@
     </action>
     
     <action name="purgeRepository" class="localRepository" method="doPurge">
+      <interceptor-ref name="storeStack"/>
       <result name="success" type="redirect-action">
         <param name="actionName">repositoryList</param>
       </result>
-      <result name="error" type="redirect-action">
-        <param name="actionName">repositoryList</param>
-        <param name="errorMessage">${message}</param>
-      </result>
     </action>
     
     <!--

Modified: continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/buildResults.jsp
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/buildResults.jsp?rev=776644&r1=776643&r2=776644&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/buildResults.jsp (original)
+++ continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/buildResults.jsp Wed May
20 10:02:47 2009
@@ -39,6 +39,15 @@
                 <s:param><s:property value="project.name"/></s:param>
             </s:text>
         </h3>
+        
+        <c:if test="${!empty actionErrors}">
+          <div class="errormessage">
+            <s:iterator value="actionErrors">
+              <p><s:property/></p>
+            </s:iterator>
+          </div>
+        </c:if>
+    
         <form id="buildResultsForm" action="removeBuildResults.action" method="post">
           <s:hidden name="projectGroupId"/>
           <s:hidden name="projectId"/>

Modified: continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/groupSummary.jsp
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/groupSummary.jsp?rev=776644&r1=776643&r2=776644&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/groupSummary.jsp (original)
+++ continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/groupSummary.jsp Wed May
20 10:02:47 2009
@@ -39,6 +39,14 @@
        <h3><s:text name="groups.page.section.title"/></h3>
     </s:else>
   
+    <c:if test="${!empty actionErrors}">
+      <div class="errormessage">
+        <s:iterator value="actionErrors">
+          <p><s:property/></p>
+        </s:iterator>
+      </div>
+    </c:if>
+
     <c:if test="${empty groups}">
       <s:text name="groups.page.list.empty"/>
     </c:if>



Mime
View raw message