You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@continuum.apache.org by ol...@apache.org on 2008/05/10 23:20:17 UTC
svn commit: r655192 - in /continuum/trunk:
continuum-api/src/main/java/org/apache/maven/continuum/profile/
continuum-core/src/main/java/org/apache/maven/continuum/profile/
continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/
Author: olamy
Date: Sat May 10 14:20:17 2008
New Revision: 655192
URL: http://svn.apache.org/viewvc?rev=655192&view=rev
Log:
[CONTINUUM-1746] Duplicate Profile names are accepted
fix editProfile action when the profile name is not changed
Thanks Wendy for catching
Modified:
continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/profile/ProfileService.java
continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/profile/DefaultProfileService.java
continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/ProfileAction.java
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=655192&r1=655191&r2=655192&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 Sat May 10 14:20:17 2008
@@ -81,4 +81,7 @@
*/
public void removeInstallationFromProfile( Profile profile, Installation installation )
throws ProfileException;
+
+ public Profile getProfileWithName( String profileName )
+ throws ProfileException;
}
Modified: continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/profile/DefaultProfileService.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/profile/DefaultProfileService.java?rev=655192&r1=655191&r2=655192&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/profile/DefaultProfileService.java (original)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/profile/DefaultProfileService.java Sat May 10 14:20:17 2008
@@ -19,8 +19,10 @@
* under the License.
*/
+import java.util.ArrayList;
+import java.util.List;
+
import org.apache.commons.lang.StringUtils;
-import org.apache.maven.continuum.installation.InstallationException;
import org.apache.maven.continuum.installation.InstallationService;
import org.apache.maven.continuum.model.system.Installation;
import org.apache.maven.continuum.model.system.Profile;
@@ -28,9 +30,6 @@
import org.apache.maven.continuum.store.ContinuumStore;
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$
@@ -280,23 +279,29 @@
}
- /**
- * @param profile
- * @return true if profile with same name (<b>case sensitive) exists
- * @throws ProfileException
- */
- private boolean alreadyExistsProfileName( Profile profile )
+ public Profile getProfileWithName( String profileName )
throws ProfileException
{
List<Profile> allProfiles = getAllProfiles();
- for ( Profile prof : allProfiles )
+ for ( Profile profile : allProfiles )
{
- if ( StringUtils.equals( prof.getName(), profile.getName() ) )
+ if ( StringUtils.equals( profile.getName(), profileName ) )
{
- return true;
+ return profile;
}
}
- return false;
+ return null;
+ }
+
+ /**
+ * @param profile
+ * @return true if profile with same name (<b>case sensitive</b>) exists
+ * @throws ProfileException
+ */
+ private 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/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=655192&r1=655191&r2=655192&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 Sat May 10 14:20:17 2008
@@ -22,8 +22,8 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import java.util.ResourceBundle;
+import org.apache.commons.lang.StringUtils;
import org.apache.maven.continuum.installation.InstallationService;
import org.apache.maven.continuum.model.system.Installation;
import org.apache.maven.continuum.model.system.Profile;
@@ -130,13 +130,17 @@
}
else
{
- // olamy : the only this to change here is the profile
+ // olamy : the only thing to change here is the profile name
// but in the UI maybe some installations has been we retrieve it
// and only set the name related to CONTINUUM-1361
String name = profile.getName();
profile = profileService.getProfile( profile.getId() );
- profile.setName( name );
- profileService.updateProfile( profile );
+ // CONTINUUM-1746 we update the profile only if the name has changed
+ if ( !StringUtils.equals( name, profile.getName() ) )
+ {
+ profile.setName( name );
+ profileService.updateProfile( profile );
+ }
}
}
catch ( AlreadyExistsProfileException e )