continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject svn commit: r751947 - in /continuum/trunk: continuum-api/src/main/java/org/apache/maven/continuum/profile/ continuum-commons/src/main/java/org/apache/continuum/installation/ continuum-commons/src/main/java/org/apache/continuum/profile/ continuum-webapp...
Date Tue, 10 Mar 2009 01:44:36 GMT
Author: ctan
Date: Tue Mar 10 01:44:36 2009
New Revision: 751947

URL: http://svn.apache.org/viewvc?rev=751947&view=rev
Log:
[CONTINUUM-2058] [CONTINUUM-2059] 
- redirect to installations list page after editing an installation
- catch duplicate continuum profile name error and display it properly

Submitted By: Jose Morales Martinez


Modified:
    continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/profile/ProfileService.java
    continuum/trunk/continuum-commons/src/main/java/org/apache/continuum/installation/DefaultInstallationService.java
    continuum/trunk/continuum-commons/src/main/java/org/apache/continuum/profile/DefaultProfileService.java
    continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/InstallationAction.java
    continuum/trunk/continuum-webapp/src/main/resources/struts.xml
    continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/admin/editInstallation.jsp

Modified: continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/profile/ProfileService.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/profile/ProfileService.java?rev=751947&r1=751946&r2=751947&view=diff
==============================================================================
--- continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/profile/ProfileService.java
(original)
+++ continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/profile/ProfileService.java
Tue Mar 10 01:44:36 2009
@@ -1,10 +1,10 @@
 package org.apache.maven.continuum.profile;
 
+import java.util.List;
+
 import org.apache.maven.continuum.model.system.Installation;
 import org.apache.maven.continuum.model.system.Profile;
 
-import java.util.List;
-
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -69,10 +69,10 @@
 
     public void addEnvVarInProfile( Profile profile, Installation envVar )
         throws ProfileException;
-    
+
     public void addInstallationInProfile( Profile profile, Installation installation )
         throws ProfileException;
-    
+
     /**
      * @param profile
      * @param installation
@@ -81,7 +81,10 @@
      */
     public void removeInstallationFromProfile( Profile profile, Installation installation
)
         throws ProfileException;
-    
+
     public Profile getProfileWithName( String profileName )
         throws ProfileException;
+
+    public boolean alreadyExistsProfileName( Profile profile )
+        throws ProfileException;
 }

Modified: continuum/trunk/continuum-commons/src/main/java/org/apache/continuum/installation/DefaultInstallationService.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-commons/src/main/java/org/apache/continuum/installation/DefaultInstallationService.java?rev=751947&r1=751946&r2=751947&view=diff
==============================================================================
--- continuum/trunk/continuum-commons/src/main/java/org/apache/continuum/installation/DefaultInstallationService.java
(original)
+++ continuum/trunk/continuum-commons/src/main/java/org/apache/continuum/installation/DefaultInstallationService.java
Tue Mar 10 01:44:36 2009
@@ -205,7 +205,7 @@
      * @see org.apache.maven.continuum.installation.InstallationService#update(org.apache.maven.continuum.model.system.Installation)
      */
     public void update( Installation installation )
-        throws InstallationException
+        throws InstallationException, AlreadyExistsInstallationException
     {
         try
         {
@@ -216,6 +216,11 @@
             }
 
             stored.setName( installation.getName() );
+            if ( alreadyExistInstallationName( installation ) )
+            {
+                throw new AlreadyExistsInstallationException(
+                    "Installation with name " + installation.getName() + " already exists"
);
+            }
             stored.setType( installation.getType() );
             String envVarName = this.getEnvVar( installation.getType() );
             // override with the defined var name for defined types
@@ -449,7 +454,8 @@
         List<Installation> all = getAllInstallations();
         for ( Installation install : all )
         {
-            if ( org.apache.commons.lang.StringUtils.equals( installation.getName(), install.getName()
) )
+            if ( org.apache.commons.lang.StringUtils.equals( installation.getName(), install.getName()
)
+                && ( installation.getInstallationId() == 0 || installation.getInstallationId()
!= install.getInstallationId() ) )
             {
                 return true;
             }

Modified: continuum/trunk/continuum-commons/src/main/java/org/apache/continuum/profile/DefaultProfileService.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-commons/src/main/java/org/apache/continuum/profile/DefaultProfileService.java?rev=751947&r1=751946&r2=751947&view=diff
==============================================================================
--- continuum/trunk/continuum-commons/src/main/java/org/apache/continuum/profile/DefaultProfileService.java
(original)
+++ continuum/trunk/continuum-commons/src/main/java/org/apache/continuum/profile/DefaultProfileService.java
Tue Mar 10 01:44:36 2009
@@ -311,7 +311,7 @@
      * @return true if profile with same name (<b>case sensitive</b>) exists
      * @throws ProfileException
      */
-    private boolean alreadyExistsProfileName( Profile profile )
+    public boolean alreadyExistsProfileName( Profile profile )
         throws ProfileException
     {
         return getProfileWithName( profile.getName() ) != null;

Modified: continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/InstallationAction.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/InstallationAction.java?rev=751947&r1=751946&r2=751947&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/InstallationAction.java
(original)
+++ continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/InstallationAction.java
Tue Mar 10 01:44:36 2009
@@ -6,9 +6,11 @@
 import java.util.Map;
 import java.util.ResourceBundle;
 
+import org.apache.commons.lang.StringUtils;
 import org.apache.maven.continuum.installation.AlreadyExistsInstallationException;
 import org.apache.maven.continuum.installation.InstallationService;
 import org.apache.maven.continuum.model.system.Installation;
+import org.apache.maven.continuum.profile.AlreadyExistsProfileException;
 import org.apache.maven.continuum.security.ContinuumRoleConstants;
 import org.apache.maven.continuum.web.action.ContinuumActionSupport;
 import org.codehaus.plexus.redback.rbac.Resource;
@@ -61,21 +63,21 @@
     private List<String> types;
 
     private boolean varNameUpdatable = false;
-   
+
     private boolean automaticProfile;
-   
+
     private boolean varNameDisplayable = false;
-    
+
     private boolean displayTypes = true;
-    
+
     private String installationType;
-    
+
     private Map<String, String> installationTypes;
-    
+
     private static final String TOOL_TYPE_KEY = "tool";
-    
+
     private boolean automaticProfileDisplayable = true;
-   
+
     // -----------------------------------------------------
     // Webwork methods
     // -----------------------------------------------------
@@ -125,6 +127,12 @@
         if ( InstallationService.ENVVAR_TYPE.equalsIgnoreCase( this.getInstallationType()
) )
         {
             this.installation.setType( InstallationService.ENVVAR_TYPE );
+            if ( StringUtils.isEmpty( installation.getVarName() ) )
+            {
+                addFieldError( "installation.varName", getResourceBundle().getString( "installation.varName.required"
) );
+                return INPUT;
+            }
+
         }
         if ( installation.getInstallationId() == 0 )
         {
@@ -137,14 +145,24 @@
                 this.addActionError( getResourceBundle().getString( "installation.name.duplicate"
) );
                 return INPUT;
             }
+            catch ( AlreadyExistsProfileException e )
+            {
+                this.addActionError( getResourceBundle().getString( "profile.name.already.exists"
) );
+                return INPUT;
+            }
         }
         else
         {
             this.configureUiFlags();
-            installationService.update( installation );
-            return "edit";
+            try{
+                installationService.update( installation );
+            }
+            catch ( AlreadyExistsInstallationException e )
+            {
+                this.addActionError( getResourceBundle().getString( "installation.name.duplicate"
) );
+                return INPUT;
+            }
         }
-        this.configureUiFlags();
         return SUCCESS;
     }
 
@@ -166,11 +184,11 @@
 
         return SUCCESS;
     }
-    
+
     // -----------------------------------------------------
     // security
-    // -----------------------------------------------------    
-    
+    // -----------------------------------------------------
+
     public SecureActionBundle getSecureActionBundle()
         throws SecureActionException
     {
@@ -183,7 +201,7 @@
 
     // -----------------------------------------------------
     // utils
-    // -----------------------------------------------------    
+    // -----------------------------------------------------
     private void configureUiFlags()
     {
         // we can update env var name only with env var type
@@ -200,8 +218,8 @@
         }
         this.setInstallationType( this.getInstallation().getType() );
     }
-    
-    
+
+
     // -----------------------------------------------------
     // getter/setters
     // -----------------------------------------------------
@@ -341,6 +359,6 @@
     public void setAutomaticProfileDisplayable( boolean automaticProfileDisplayable )
     {
         this.automaticProfileDisplayable = automaticProfileDisplayable;
-    }    
-    
+    }
+
 }

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=751947&r1=751946&r2=751947&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/resources/struts.xml (original)
+++ continuum/trunk/continuum-webapp/src/main/resources/struts.xml Tue Mar 10 01:44:36 2009
@@ -693,11 +693,7 @@
     
     <action name="installationsList" class="installation" method="list">
       <result name="success">/WEB-INF/jsp/admin/installationsList.jsp</result>
-    </action>   
-      
-    <action name="addInstallation" class="installation" method="add">
-      <result name="input">/WEB-INF/jsp/admin/editInstallation.jsp</result>
-    </action>       
+    </action>        
       
     <action name="editInstallation" class="installation" method="edit">
       <result name="success">/WEB-INF/jsp/admin/editInstallation.jsp</result>
@@ -706,9 +702,9 @@
       
     <action name="saveInstallation" class="installation" method="save">
       <result name="input">/WEB-INF/jsp/admin/editInstallation.jsp</result>
-      <result name="edit">/WEB-INF/jsp/admin/editInstallation.jsp</result>
       <result name="success" type="redirect-action">installationsList</result>
     </action> 
+    
     <action name="deleteInstallation" class="installation" method="delete">
       <result name="input">/WEB-INF/jsp/admin/installationsList.jsp</result>
       <result name="success">/WEB-INF/jsp/admin/installationsList.jsp</result>

Modified: continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/admin/editInstallation.jsp
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/admin/editInstallation.jsp?rev=751947&r1=751946&r2=751947&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/admin/editInstallation.jsp
(original)
+++ continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/admin/editInstallation.jsp
Tue Mar 10 01:44:36 2009
@@ -48,6 +48,9 @@
           <tbody>
             <s:hidden name="installation.installationId" />
             <s:hidden name="installationType" />
+            <s:hidden name="displayTypes" />
+            <s:hidden name="varNameUpdatable" />
+            <s:hidden name="varNameDisplayable" />
             <s:textfield label="%{getText('installation.name.label')}" name="installation.name"
                             required="true"/>
             <s:if test="displayTypes">



Mime
View raw message