continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r582015 - in /maven/continuum/trunk: continuum-api/src/main/java/org/apache/maven/continuum/profile/ continuum-core/src/main/java/org/apache/maven/continuum/profile/ continuum-core/src/test/java/org/apache/maven/continuum/profile/ continuum...
Date Thu, 04 Oct 2007 21:29:39 GMT
Author: olamy
Date: Thu Oct  4 14:29:38 2007
New Revision: 582015

URL: http://svn.apache.org/viewvc?rev=582015&view=rev
Log:
move jobs on profile from webapp part to continuum-core

Modified:
    maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/profile/ProfileService.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/profile/DefaultProfileService.java
    maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/profile/DefaultProfileServiceTest.java
    maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/ProfileAction.java

Modified: maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/profile/ProfileService.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/profile/ProfileService.java?rev=582015&r1=582014&r2=582015&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/profile/ProfileService.java
(original)
+++ maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/profile/ProfileService.java
Thu Oct  4 14:29:38 2007
@@ -66,4 +66,13 @@
     
     public void addInstallationInProfile( Profile profile, Installation installation )
         throws ProfileException;
+    
+    /**
+     * @param profile
+     * @param installation
+     * @throws ProfileException
+     * @since 1.1-beta-4
+     */
+    public void removeInstallationFromProfile( Profile profile, Installation installation
)
+        throws ProfileException;
 }

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/profile/DefaultProfileService.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/profile/DefaultProfileService.java?rev=582015&r1=582014&r2=582015&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/profile/DefaultProfileService.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/profile/DefaultProfileService.java
Thu Oct  4 14:29:38 2007
@@ -25,7 +25,9 @@
 import org.apache.maven.continuum.store.ContinuumObjectNotFoundException;
 import org.apache.maven.continuum.store.ContinuumStore;
 import org.apache.maven.continuum.store.ContinuumStoreException;
+import org.codehaus.plexus.util.StringUtils;
 
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -192,6 +194,38 @@
             addEnvVarInProfile( profile, installation );
         }
 
+    }
+
+    public void removeInstallationFromProfile( Profile profile, Installation installation
)
+        throws ProfileException
+    {
+        Profile stored = getProfile( profile.getId() );
+        if ( InstallationService.JDK_TYPE.equals( installation.getType() ) )
+        {
+            stored.setJdk( null );
+        }
+        else if ( InstallationService.MAVEN1_TYPE.equals( installation.getType() ) ||
+            InstallationService.MAVEN2_TYPE.equals( installation.getType() ) ||
+            InstallationService.ANT_TYPE.equals( installation.getType() ) )
+        {
+            stored.setBuilder( null );
+        }
+        else
+        {
+            // remove one
+            List<Installation> storedEnvVars = stored.getEnvironmentVariables();
+            List<Installation> newEnvVars = new ArrayList<Installation>();
+            for ( Installation storedInstallation : storedEnvVars )
+            {
+                if ( !StringUtils.equals( storedInstallation.getName(), installation.getName()
) )
+                {
+                    newEnvVars.add( storedInstallation );
+                }
+            }
+            stored.setEnvironmentVariables( newEnvVars );
+        }
+        updateProfile( stored );
+        
     }
 
 }

Modified: maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/profile/DefaultProfileServiceTest.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/profile/DefaultProfileServiceTest.java?rev=582015&r1=582014&r2=582015&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/profile/DefaultProfileServiceTest.java
(original)
+++ maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/profile/DefaultProfileServiceTest.java
Thu Oct  4 14:29:38 2007
@@ -223,5 +223,36 @@
         InstallationService installationService = (InstallationService) lookup( InstallationService.ROLE,
"default" );
         installationService.delete( jdk2 );
     }
+    
+    public void testRemoveEnvVarFromProfile()
+        throws Exception
+    {
+        Profile profile = getProfileService().getProfile( jdk1mvn205.getId() );
+        getProfileService().setJdkInProfile( profile, jdk2 );
+        getProfileService().addEnvVarInProfile( profile, mvnOpts1 );
+        getProfileService().addEnvVarInProfile( profile, mvnOpts2 );
+
+        profile = getProfileService().getProfile( jdk1mvn205.getId() );
+        assertNotNull( profile.getJdk() );
+        assertEquals( 2, profile.getEnvironmentVariables().size() );
+        
+        getProfileService().removeInstallationFromProfile( profile, mvnOpts1 );
+        
+        profile = getProfileService().getProfile( jdk1mvn205.getId() );
+        assertNotNull( profile.getJdk() );
+        assertEquals( 1, profile.getEnvironmentVariables().size() );
+        
+        getProfileService().removeInstallationFromProfile( profile, jdk2 );
+        
+        profile = getProfileService().getProfile( jdk1mvn205.getId() );
+        assertNull( profile.getJdk() );
+        assertEquals( 1, profile.getEnvironmentVariables().size() );
+        
+        getProfileService().removeInstallationFromProfile( profile, mvnOpts2 );
+        profile = getProfileService().getProfile( jdk1mvn205.getId() );
+        assertNull( profile.getJdk() );
+        assertEquals( 0, profile.getEnvironmentVariables().size() );
+    }
+    
 
 }

Modified: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/ProfileAction.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/ProfileAction.java?rev=582015&r1=582014&r2=582015&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/ProfileAction.java
(original)
+++ maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/ProfileAction.java
Thu Oct  4 14:29:38 2007
@@ -33,7 +33,6 @@
 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;
 
@@ -165,33 +164,7 @@
     {
 
         Installation installation = installationService.getInstallation( this.getInstallationId()
);
-        Profile stored = profileService.getProfile( profile.getId() );
-        if ( InstallationService.JDK_TYPE.equals( installation.getType() ) )
-        {
-            stored.setJdk( null );
-        }
-        else if ( InstallationService.MAVEN1_TYPE.equals( installation.getType() ) ||
-            InstallationService.MAVEN2_TYPE.equals( installation.getType() ) ||
-            InstallationService.ANT_TYPE.equals( installation.getType() ) )
-        {
-            stored.setBuilder( null );
-        }
-        else
-        {
-            // remove one
-            // TODO move this in ProfileService
-            List<Installation> storedEnvVars = stored.getEnvironmentVariables();
-            List<Installation> newEnvVars = new ArrayList<Installation>();
-            for ( Installation storedInstallation : storedEnvVars )
-            {
-                if ( !StringUtils.equals( storedInstallation.getName(), installation.getName()
) )
-                {
-                    newEnvVars.add( storedInstallation );
-                }
-            }
-            stored.setEnvironmentVariables( newEnvVars );
-        }
-        profileService.updateProfile( stored );
+        profileService.removeInstallationFromProfile( profile, installation );
         this.profile = profileService.getProfile( profile.getId() );
         return SUCCESS;
     }



Mime
View raw message