continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject svn commit: r751970 - in /continuum/branches/continuum-1.2.x: 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/profil...
Date Tue, 10 Mar 2009 02:33:18 GMT
Author: ctan
Date: Tue Mar 10 02:33:17 2009
New Revision: 751970

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

Submitted By: Jose Morales Martinez

Modified:
    continuum/branches/continuum-1.2.x/continuum-api/src/main/java/org/apache/maven/continuum/profile/ProfileService.java
    continuum/branches/continuum-1.2.x/continuum-commons/src/main/java/org/apache/continuum/installation/DefaultInstallationService.java
    continuum/branches/continuum-1.2.x/continuum-commons/src/main/java/org/apache/continuum/profile/DefaultProfileService.java
    continuum/branches/continuum-1.2.x/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/InstallationAction.java
    continuum/branches/continuum-1.2.x/continuum-webapp/src/main/resources/localization/Continuum.properties
    continuum/branches/continuum-1.2.x/continuum-webapp/src/main/webapp/WEB-INF/jsp/admin/editInstallation.jsp

Modified: continuum/branches/continuum-1.2.x/continuum-api/src/main/java/org/apache/maven/continuum/profile/ProfileService.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.2.x/continuum-api/src/main/java/org/apache/maven/continuum/profile/ProfileService.java?rev=751970&r1=751969&r2=751970&view=diff
==============================================================================
--- continuum/branches/continuum-1.2.x/continuum-api/src/main/java/org/apache/maven/continuum/profile/ProfileService.java
(original)
+++ continuum/branches/continuum-1.2.x/continuum-api/src/main/java/org/apache/maven/continuum/profile/ProfileService.java
Tue Mar 10 02:33:17 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/branches/continuum-1.2.x/continuum-commons/src/main/java/org/apache/continuum/installation/DefaultInstallationService.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.2.x/continuum-commons/src/main/java/org/apache/continuum/installation/DefaultInstallationService.java?rev=751970&r1=751969&r2=751970&view=diff
==============================================================================
--- continuum/branches/continuum-1.2.x/continuum-commons/src/main/java/org/apache/continuum/installation/DefaultInstallationService.java
(original)
+++ continuum/branches/continuum-1.2.x/continuum-commons/src/main/java/org/apache/continuum/installation/DefaultInstallationService.java
Tue Mar 10 02:33:17 2009
@@ -19,6 +19,16 @@
  * under the License.
  */
 
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
 import org.apache.continuum.dao.InstallationDao;
 import org.apache.maven.continuum.execution.ExecutorConfigurator;
 import org.apache.maven.continuum.installation.AlreadyExistsInstallationException;
@@ -39,16 +49,6 @@
 import org.codehaus.plexus.util.cli.Commandline;
 import org.codehaus.plexus.util.cli.StreamConsumer;
 
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
 /**
  * @author <a href="mailto:olamy@codehaus.org">olamy</a>
  * @version $Id: DefaultInstallationService.java 684085 2008-08-08 20:48:14Z evenisse $
@@ -117,6 +117,23 @@
             throw new AlreadyExistsInstallationException(
                 "Installation with name " + installation.getName() + " already exists" );
         }
+        else if ( automaticProfile )
+        {
+            Profile profile = new Profile();
+            profile.setName( installation.getName() );
+            try
+            {
+                if ( profileService.alreadyExistsProfileName( profile ) )
+                {
+                    throw new AlreadyExistsProfileException( "Profile with name " + installation.getName()
+                        + " already exists" );
+                }
+            }
+            catch ( ProfileException e )
+            {
+                throw new InstallationException( "failed to search Profile " + e.getMessage(),
e );
+            }
+        }
         // TODO must be done in the same transaction
         Installation storedOne = null;
         try
@@ -205,7 +222,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 +233,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
@@ -451,7 +473,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/branches/continuum-1.2.x/continuum-commons/src/main/java/org/apache/continuum/profile/DefaultProfileService.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.2.x/continuum-commons/src/main/java/org/apache/continuum/profile/DefaultProfileService.java?rev=751970&r1=751969&r2=751970&view=diff
==============================================================================
--- continuum/branches/continuum-1.2.x/continuum-commons/src/main/java/org/apache/continuum/profile/DefaultProfileService.java
(original)
+++ continuum/branches/continuum-1.2.x/continuum-commons/src/main/java/org/apache/continuum/profile/DefaultProfileService.java
Tue Mar 10 02:33:17 2009
@@ -19,6 +19,9 @@
  * under the License.
  */
 
+import java.util.ArrayList;
+import java.util.List;
+
 import org.apache.commons.lang.StringUtils;
 import org.apache.continuum.dao.ProfileDao;
 import org.apache.maven.continuum.installation.InstallationService;
@@ -30,9 +33,6 @@
 import org.apache.maven.continuum.store.ContinuumObjectNotFoundException;
 import org.apache.maven.continuum.store.ContinuumStoreException;
 
-import java.util.ArrayList;
-import java.util.List;
-
 /**
  * @author <a href="mailto:olamy@codehaus.org">olamy</a>
  * @version $Id: DefaultProfileService.java 698412 2008-09-24 01:55:19Z ctan $
@@ -307,7 +307,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/branches/continuum-1.2.x/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/InstallationAction.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.2.x/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/InstallationAction.java?rev=751970&r1=751969&r2=751970&view=diff
==============================================================================
--- continuum/branches/continuum-1.2.x/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/InstallationAction.java
(original)
+++ continuum/branches/continuum-1.2.x/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/InstallationAction.java
Tue Mar 10 02:33:17 2009
@@ -9,12 +9,14 @@
 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;
 import org.codehaus.plexus.redback.xwork.interceptor.SecureAction;
 import org.codehaus.plexus.redback.xwork.interceptor.SecureActionBundle;
 import org.codehaus.plexus.redback.xwork.interceptor.SecureActionException;
+import org.codehaus.plexus.util.StringUtils;
 
 import com.opensymphony.xwork.Preparable;
 
@@ -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/branches/continuum-1.2.x/continuum-webapp/src/main/resources/localization/Continuum.properties
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.2.x/continuum-webapp/src/main/resources/localization/Continuum.properties?rev=751970&r1=751969&r2=751970&view=diff
==============================================================================
--- continuum/branches/continuum-1.2.x/continuum-webapp/src/main/resources/localization/Continuum.properties
(original)
+++ continuum/branches/continuum-1.2.x/continuum-webapp/src/main/resources/localization/Continuum.properties
Tue Mar 10 02:33:17 2009
@@ -742,6 +742,7 @@
 installation.ant.type.label = ANT
 installation.automaticProfile.label=Create a Build Environment with the Installation name
 installation.name.duplicate = Installation name already exists.
+installation.varName.required = You must define an environment variable
 
 # ----------------------------------------------------------------------
 # Page: Installations Type Choice

Modified: continuum/branches/continuum-1.2.x/continuum-webapp/src/main/webapp/WEB-INF/jsp/admin/editInstallation.jsp
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.2.x/continuum-webapp/src/main/webapp/WEB-INF/jsp/admin/editInstallation.jsp?rev=751970&r1=751969&r2=751970&view=diff
==============================================================================
--- continuum/branches/continuum-1.2.x/continuum-webapp/src/main/webapp/WEB-INF/jsp/admin/editInstallation.jsp
(original)
+++ continuum/branches/continuum-1.2.x/continuum-webapp/src/main/webapp/WEB-INF/jsp/admin/editInstallation.jsp
Tue Mar 10 02:33:17 2009
@@ -48,6 +48,9 @@
           <tbody>
             <ww:hidden name="installation.installationId" />
             <ww:hidden name="installationType" />
+            <ww:hidden name="displayTypes" />
+            <ww:hidden name="varNameUpdatable" />
+            <ww:hidden name="varNameDisplayable" />
             <ww:textfield label="%{getText('installation.name.label')}" name="installation.name"
                             required="true"/>
             <ww:if test="displayTypes">
@@ -55,7 +58,7 @@
             </ww:if>
             <ww:if test="varNameUpdatable">
               <ww:if test="varNameDisplayable">
-                <ww:textfield label="%{getText('installation.varName.label')}" name="installation.varName"
required="${varNameUpdatable}" />
+                <ww:textfield label="%{getText('installation.varName.label')}" name="installation.varName"
required="true"/>
               </ww:if>
             </ww:if>
             <ww:else>



Mime
View raw message