continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r690561 - in /continuum/branches/continuum-1.2.x: ./ continuum-api/src/main/java/org/apache/continuum/configuration/ continuum-api/src/main/java/org/apache/maven/continuum/ continuum-base/continuum-configuration/ continuum-base/continuum-co...
Date Sat, 30 Aug 2008 19:30:54 GMT
Author: olamy
Date: Sat Aug 30 12:30:53 2008
New Revision: 690561

URL: http://svn.apache.org/viewvc?rev=690561&view=rev
Log:
svn merge -r690493:690520 https://svn.apache.org/repos/asf/continuum/trunk

Added:
    continuum/branches/continuum-1.2.x/continuum-base/continuum-configuration/src/main/mdo/
      - copied from r690520, continuum/trunk/continuum-base/continuum-configuration/src/main/mdo/
    continuum/branches/continuum-1.2.x/continuum-base/continuum-configuration/src/main/mdo/continuum-configuration.xml
      - copied unchanged from r690520, continuum/trunk/continuum-base/continuum-configuration/src/main/mdo/continuum-configuration.xml
    continuum/branches/continuum-1.2.x/continuum-webapp/src/main/mdo/appearance-models.mdo
      - copied unchanged from r690520, continuum/trunk/continuum-webapp/src/main/mdo/appearance-models.mdo
Removed:
    continuum/branches/continuum-1.2.x/continuum-base/continuum-configuration/src/test/resources/META-INF/
    continuum/branches/continuum-1.2.x/continuum-core/src/test/resources/META-INF/
Modified:
    continuum/branches/continuum-1.2.x/   (props changed)
    continuum/branches/continuum-1.2.x/continuum-api/src/main/java/org/apache/continuum/configuration/ContinuumConfiguration.java
    continuum/branches/continuum-1.2.x/continuum-api/src/main/java/org/apache/continuum/configuration/ProxyConfiguration.java
    continuum/branches/continuum-1.2.x/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java
    continuum/branches/continuum-1.2.x/continuum-base/continuum-configuration/pom.xml
    continuum/branches/continuum-1.2.x/continuum-base/continuum-configuration/src/main/java/org/apache/continuum/configuration/DefaultContinuumConfiguration.java
    continuum/branches/continuum-1.2.x/continuum-base/continuum-configuration/src/main/resources/META-INF/spring-context.xml
    continuum/branches/continuum-1.2.x/continuum-base/continuum-configuration/src/test/java/org/apache/continuum/configuration/TestDefaultContinuumConfiguration.java
    continuum/branches/continuum-1.2.x/continuum-base/continuum-configuration/src/test/resources/conf/continuum.xml
    continuum/branches/continuum-1.2.x/continuum-commons/src/test/resources/conf/continuum.xml
    continuum/branches/continuum-1.2.x/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
    continuum/branches/continuum-1.2.x/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/AbstractContinuumProjectBuilder.java
  (contents, props changed)
    continuum/branches/continuum-1.2.x/continuum-core/src/main/java/org/apache/maven/continuum/utils/ContinuumUtils.java
  (props changed)
    continuum/branches/continuum-1.2.x/continuum-core/src/test/java/org/apache/maven/continuum/project/builder/AbstractContinuumProjectBuilderTest.java
  (props changed)
    continuum/branches/continuum-1.2.x/continuum-core/src/test/java/org/apache/maven/continuum/utils/ContinuumUtilsTest.java
  (props changed)
    continuum/branches/continuum-1.2.x/continuum-webapp/pom.xml
    continuum/branches/continuum-1.2.x/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/ConfigureFooterAction.java
    continuum/branches/continuum-1.2.x/continuum-webapp/src/main/java/org/apache/maven/continuum/web/appareance/AppareanceConfiguration.java
    continuum/branches/continuum-1.2.x/continuum-webapp/src/main/java/org/apache/maven/continuum/web/appareance/DefaultAppareanceConfiguration.java
    continuum/branches/continuum-1.2.x/pom.xml

Propchange: continuum/branches/continuum-1.2.x/
------------------------------------------------------------------------------
    svn:mergeinfo = /continuum/trunk:690494-690520

Modified: continuum/branches/continuum-1.2.x/continuum-api/src/main/java/org/apache/continuum/configuration/ContinuumConfiguration.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.2.x/continuum-api/src/main/java/org/apache/continuum/configuration/ContinuumConfiguration.java?rev=690561&r1=690560&r2=690561&view=diff
==============================================================================
--- continuum/branches/continuum-1.2.x/continuum-api/src/main/java/org/apache/continuum/configuration/ContinuumConfiguration.java
(original)
+++ continuum/branches/continuum-1.2.x/continuum-api/src/main/java/org/apache/continuum/configuration/ContinuumConfiguration.java
Sat Aug 30 12:30:53 2008
@@ -1,5 +1,7 @@
 package org.apache.continuum.configuration;
 
+import java.io.File;
+
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -26,6 +28,10 @@
  */
 public interface ContinuumConfiguration
 {
+    /**
+     * @return an empty or a filled on but never null !
+     * @throws ContinuumConfigurationException
+     */
     GeneralConfiguration getGeneralConfiguration()
         throws ContinuumConfigurationException;
 
@@ -35,6 +41,12 @@
     void save()
         throws ContinuumConfigurationException;
 
-    void reload()
+    void save( File file )
+        throws ContinuumConfigurationException;
+
+    void reload( )
+    throws ContinuumConfigurationException;    
+    
+    void reload( File file )
         throws ContinuumConfigurationException;
 }

Modified: continuum/branches/continuum-1.2.x/continuum-api/src/main/java/org/apache/continuum/configuration/ProxyConfiguration.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.2.x/continuum-api/src/main/java/org/apache/continuum/configuration/ProxyConfiguration.java?rev=690561&r1=690560&r2=690561&view=diff
==============================================================================
--- continuum/branches/continuum-1.2.x/continuum-api/src/main/java/org/apache/continuum/configuration/ProxyConfiguration.java
(original)
+++ continuum/branches/continuum-1.2.x/continuum-api/src/main/java/org/apache/continuum/configuration/ProxyConfiguration.java
Sat Aug 30 12:30:53 2008
@@ -19,6 +19,8 @@
  * under the License.
  */
 
+
+
 import org.apache.commons.lang.builder.ReflectionToStringBuilder;
 
 /**
@@ -35,11 +37,20 @@
     private String proxyUser;
 
     private String proxyPassword;
-
+    
     public ProxyConfiguration()
     {
         // nothing here
     }
+    
+    public ProxyConfiguration( String proxyHost, String proxyPassword, int proxyPort, String
proxyUser )
+    {
+        super();
+        this.proxyHost = proxyHost;
+        this.proxyPassword = proxyPassword;
+        this.proxyPort = proxyPort;
+        this.proxyUser = proxyUser;
+    }
 
     public String getProxyHost()
     {
@@ -86,4 +97,5 @@
     {
         return ReflectionToStringBuilder.toString( this );
     }
+
 }

Modified: continuum/branches/continuum-1.2.x/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.2.x/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java?rev=690561&r1=690560&r2=690561&view=diff
==============================================================================
--- continuum/branches/continuum-1.2.x/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java
(original)
+++ continuum/branches/continuum-1.2.x/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java
Sat Aug 30 12:30:53 2008
@@ -615,9 +615,6 @@
 
     ConfigurationService getConfiguration();
 
-    void updateConfiguration( Map<String, Object> parameters )
-        throws ContinuumException;
-
     void reloadConfiguration()
         throws ContinuumException;
 

Modified: continuum/branches/continuum-1.2.x/continuum-base/continuum-configuration/pom.xml
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.2.x/continuum-base/continuum-configuration/pom.xml?rev=690561&r1=690560&r2=690561&view=diff
==============================================================================
--- continuum/branches/continuum-1.2.x/continuum-base/continuum-configuration/pom.xml (original)
+++ continuum/branches/continuum-1.2.x/continuum-base/continuum-configuration/pom.xml Sat
Aug 30 12:30:53 2008
@@ -26,16 +26,55 @@
   <modelVersion>4.0.0</modelVersion>
   <artifactId>continuum-configuration</artifactId>
   <name>Continuum :: Configuration</name>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.codehaus.modello</groupId>
+        <artifactId>modello-maven-plugin</artifactId>
+        <configuration>
+          <models>
+            <model>src/main/mdo/continuum-configuration.xml</model>
+          </models>
+          <version>1.0.0</version>
+        </configuration>
+        <executions>
+          <execution>
+            <id>continuum-modello</id>
+            <phase>generate-sources</phase>
+            <goals>
+              <goal>java</goal>
+              <goal>xpp3-reader</goal>
+              <goal>xpp3-writer</goal>
+            </goals>
+          </execution>
+          <execution>
+            <id>site-docs</id>
+            <phase>pre-site</phase>
+            <goals>
+              <goal>xdoc</goal>
+              <goal>xsd</goal>
+            </goals>
+          </execution>
+          <execution>
+            <id>generate-xsd</id>
+            <phase>generate-resources</phase>
+            <goals>
+              <goal>xsd</goal>
+            </goals>
+            <configuration>
+              <outputDirectory>${project.build.outputDirectory}/META-INF/continuum/xsd</outputDirectory>
+            </configuration>
+          </execution>                    
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
   <dependencies>
     <dependency>
       <groupId>org.apache.continuum</groupId>
       <artifactId>continuum-api</artifactId>
     </dependency>
     <dependency>
-      <groupId>commons-configuration</groupId>
-      <artifactId>commons-configuration</artifactId>
-    </dependency>
-    <dependency>
       <groupId>commons-lang</groupId>
       <artifactId>commons-lang</artifactId>
     </dependency>    

Modified: continuum/branches/continuum-1.2.x/continuum-base/continuum-configuration/src/main/java/org/apache/continuum/configuration/DefaultContinuumConfiguration.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.2.x/continuum-base/continuum-configuration/src/main/java/org/apache/continuum/configuration/DefaultContinuumConfiguration.java?rev=690561&r1=690560&r2=690561&view=diff
==============================================================================
--- continuum/branches/continuum-1.2.x/continuum-base/continuum-configuration/src/main/java/org/apache/continuum/configuration/DefaultContinuumConfiguration.java
(original)
+++ continuum/branches/continuum-1.2.x/continuum-base/continuum-configuration/src/main/java/org/apache/continuum/configuration/DefaultContinuumConfiguration.java
Sat Aug 30 12:30:53 2008
@@ -19,16 +19,19 @@
  * under the License.
  */
 
-import org.apache.commons.configuration.CombinedConfiguration;
-import org.apache.commons.configuration.Configuration;
-import org.apache.commons.configuration.DefaultConfigurationBuilder;
-import org.apache.commons.configuration.FileConfiguration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.core.io.ClassPathResource;
-
 import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileWriter;
 import java.io.IOException;
+import java.io.InputStreamReader;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.continuum.configuration.model.ContinuumConfigurationModel;
+import org.apache.continuum.configuration.model.io.xpp3.ContinuumConfigurationModelXpp3Reader;
+import org.apache.continuum.configuration.model.io.xpp3.ContinuumConfigurationModelXpp3Writer;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * @author <a href="mailto:olamy@apache.org">olamy</a>
@@ -40,28 +43,10 @@
 {
     private Logger log = LoggerFactory.getLogger( getClass() );
 
-    private ClassPathResource classPathResource;
-
-    private Configuration configuration;
+    private File configurationFile;
 
     private GeneralConfiguration generalConfiguration;
 
-    public static final String BASE_URL_KEY = "continuum.baseUrl";
-
-    public static final String BUILDOUTPUT_DIR_KEY = "continuum.buildOutputDirectory";
-
-    public static final String DEPLOYMENT_REPOSITORY_DIR_KEY = "continuum.deploymentRepositoryDirectory";
-
-    public static final String WORKING_DIR_KEY = "continuum.workingDirectory";
-
-    public static final String PROXY_HOST_KEY = "continuum.proxyHost";
-
-    public static final String PROXY_PORT_KEY = "continuum.proxyPort";
-
-    public static final String PROXY_USER_KEY = "continuum.proxyUser";
-
-    public static final String PROXY_PASSWORD_KEY = "continuum.proxyPassword";
-
     //----------------------------------------------------
     //  Initialize method configured in the Spring xml 
     //   configuration file
@@ -70,70 +55,25 @@
     {
         if ( log.isDebugEnabled() )
         {
-            log.debug( "classPathResource null " + ( classPathResource == null ) );
+            log.debug( "configurationFile null " + ( configurationFile.getPath() == null
) );
         }
-
-        try
+        if ( configurationFile != null && configurationFile.exists() )
         {
-            DefaultConfigurationBuilder defaultConfigurationBuilder =
-                new DefaultConfigurationBuilder( classPathResource.getURL() );
-            defaultConfigurationBuilder.load( classPathResource.getInputStream() );
-
-            CombinedConfiguration combinedConfiguration = defaultConfigurationBuilder.getConfiguration(
false );
-            configuration = combinedConfiguration.getConfiguration( "org.apache.continuum"
);
-
-            this.generalConfiguration = new GeneralConfiguration();
-            this.generalConfiguration.setBaseUrl( getConfigurationString( BASE_URL_KEY )
);
-            log.info( "BaseUrl=" + this.generalConfiguration.getBaseUrl() );
-            // TODO check if files exists ?
-            String buildOutputDirectory = getConfigurationString( BUILDOUTPUT_DIR_KEY );
-            if ( buildOutputDirectory != null )
-            {
-                this.generalConfiguration.setBuildOutputDirectory( new File( buildOutputDirectory
) );
-            }
-            String deploymentRepositoryDirectory = getConfigurationString( DEPLOYMENT_REPOSITORY_DIR_KEY
);
-            if ( deploymentRepositoryDirectory != null )
+            try
             {
-                this.generalConfiguration.setDeploymentRepositoryDirectory( new File( deploymentRepositoryDirectory
) );
+                reload( configurationFile );
             }
-            String workingDirectory = getConfigurationString( WORKING_DIR_KEY );
-            if ( workingDirectory != null )
+            catch ( ContinuumConfigurationException e )
             {
-                this.generalConfiguration.setWorkingDirectory( new File( workingDirectory
) );
+                // skip this and only log a warn
+                log.warn( " error on loading configuration from file " + configurationFile.getPath()
);
             }
-
-            this.generalConfiguration.setProxyConfiguration( new ProxyConfiguration() );
-            this.generalConfiguration.getProxyConfiguration().setProxyHost( getConfigurationString(
PROXY_HOST_KEY ) );
-            this.generalConfiguration.getProxyConfiguration().setProxyPort(
-                getConfigurationValue( PROXY_PORT_KEY, 0 ) );
-            this.generalConfiguration.getProxyConfiguration().setProxyUser( getConfigurationString(
PROXY_USER_KEY ) );
-            this.generalConfiguration.getProxyConfiguration().setProxyPassword( configuration
-                .getString( PROXY_PASSWORD_KEY ) );
-        }
-        catch ( org.apache.commons.configuration.ConfigurationException e )
-        {
-            log.error( e.getMessage(), e );
-            throw new RuntimeException( e.getMessage(), e );
         }
-        catch ( IOException e )
+        else
         {
-            log.error( e.getMessage(), e );
-            throw new RuntimeException( e.getMessage(), e );
-        }
-    }
-
-    private String getConfigurationString( String key )
-    {
-        if ( log.isDebugEnabled() )
-        {
-            log.debug( "Configuration=" + configuration );
+            log.info( "configuration file not exists" );
+            this.generalConfiguration = new GeneralConfiguration();
         }
-        return configuration.getString( key );
-    }
-
-    private int getConfigurationValue( String key, int defaultValue )
-    {
-        return configuration.getInt( key, defaultValue );
     }
 
     public void reload()
@@ -145,15 +85,11 @@
     public void save()
         throws ContinuumConfigurationException
     {
-        FileConfiguration fileConfiguration = (FileConfiguration) configuration;
-        try
+        if ( !configurationFile.exists() )
         {
-            fileConfiguration.save();
-        }
-        catch ( org.apache.commons.configuration.ConfigurationException e )
-        {
-            throw new ContinuumConfigurationException( e.getMessage(), e );
+            configurationFile.getParentFile().mkdir();
         }
+        save( configurationFile );
     }
 
     /**
@@ -169,44 +105,124 @@
         throws ContinuumConfigurationException
     {
         this.generalConfiguration = generalConfiguration;
-        this.configuration.setProperty( BASE_URL_KEY, generalConfiguration.getBaseUrl() );
-        if ( generalConfiguration.getBuildOutputDirectory() != null )
+    }
+    
+    public void reload( File file )
+        throws ContinuumConfigurationException
+    {
+        try
         {
-            this.configuration.setProperty( BUILDOUTPUT_DIR_KEY, generalConfiguration.getBuildOutputDirectory()
-                .getPath() );
+            ContinuumConfigurationModelXpp3Reader configurationXpp3Reader = new ContinuumConfigurationModelXpp3Reader();
+            ContinuumConfigurationModel configuration = configurationXpp3Reader
+                .read( new InputStreamReader( new FileInputStream( file ) ) );
+
+            this.generalConfiguration = new GeneralConfiguration();
+            this.generalConfiguration.setBaseUrl( configuration.getBaseUrl() );
+            if ( StringUtils.isNotEmpty( configuration.getBuildOutputDirectory() ) )
+            {
+                // TODO take care if file exists ?
+                this.generalConfiguration.setBuildOutputDirectory( new File( configuration
+                    .getBuildOutputDirectory() ) );
+            }
+            if ( StringUtils.isNotEmpty( configuration.getDeploymentRepositoryDirectory()
) )
+            {
+                // TODO take care if file exists ?
+                this.generalConfiguration.setDeploymentRepositoryDirectory( new File( configuration
+                    .getDeploymentRepositoryDirectory() ) );
+            }
+            if ( StringUtils.isNotEmpty( configuration.getWorkingDirectory() ) )
+            {
+                // TODO take care if file exists ?
+                this.generalConfiguration.setWorkingDirectory( new File( configuration.getWorkingDirectory()
) );
+            }
+            if ( configuration.getProxyConfiguration() != null )
+            {
+                ProxyConfiguration proxyConfiguration = new ProxyConfiguration( configuration
+                    .getProxyConfiguration().getProxyHost(), configuration.getProxyConfiguration()
+                    .getProxyPassword(), configuration.getProxyConfiguration().getProxyPort(),
configuration
+                    .getProxyConfiguration().getProxyUser() );
+                this.generalConfiguration.setProxyConfiguration( proxyConfiguration );
+            }
+        }
+        catch ( IOException e )
+        {
+            log.error( e.getMessage(), e );
+            throw new RuntimeException( e.getMessage(), e );
         }
-        if ( generalConfiguration.getDeploymentRepositoryDirectory() != null )
+        catch ( XmlPullParserException e )
         {
-            this.configuration.setProperty( DEPLOYMENT_REPOSITORY_DIR_KEY, generalConfiguration
-                .getDeploymentRepositoryDirectory().getPath() );
+            log.error( e.getMessage(), e );
+            throw new RuntimeException( e.getMessage(), e );
         }
-        if ( generalConfiguration.getWorkingDirectory() != null )
+        
+    }
+
+    public void save( File file )
+        throws ContinuumConfigurationException
+    {
+        try
         {
-            this.configuration.setProperty( WORKING_DIR_KEY, generalConfiguration.getWorkingDirectory().getPath()
);
+            ContinuumConfigurationModel configurationModel = new ContinuumConfigurationModel();
+            configurationModel.setBaseUrl( this.generalConfiguration.getBaseUrl() );
+            // normally not null but NPE free is better !
+            if ( this.generalConfiguration.getBuildOutputDirectory() != null )
+            {
+                configurationModel.setBuildOutputDirectory( this.generalConfiguration.getBuildOutputDirectory()
+                    .getPath() );
+            }
+            if ( this.generalConfiguration.getWorkingDirectory() != null )
+            {
+                configurationModel.setWorkingDirectory( this.generalConfiguration.getWorkingDirectory().getPath()
);
+            }
+            if ( this.generalConfiguration.getDeploymentRepositoryDirectory() != null )
+            {
+                configurationModel.setDeploymentRepositoryDirectory( this.generalConfiguration
+                    .getDeploymentRepositoryDirectory().getPath() );
+            }
+            if ( this.generalConfiguration.getProxyConfiguration() != null )
+            {
+                configurationModel
+                    .setProxyConfiguration( new org.apache.continuum.configuration.model.ProxyConfiguration()
);
+                configurationModel.getProxyConfiguration().setProxyHost(
+                                                                         this.generalConfiguration
+                                                                             .getProxyConfiguration().getProxyHost()
);
+                configurationModel.getProxyConfiguration().setProxyPassword(
+                                                                             this.generalConfiguration
+                                                                                 .getProxyConfiguration()
+                                                                                 .getProxyPassword()
);
+                configurationModel.getProxyConfiguration().setProxyPort(
+                                                                         this.generalConfiguration
+                                                                             .getProxyConfiguration().getProxyPort()
);
+                configurationModel.getProxyConfiguration().setProxyHost(
+                                                                         this.generalConfiguration
+                                                                             .getProxyConfiguration().getProxyHost()
);
+            }
+
+            ContinuumConfigurationModelXpp3Writer writer = new ContinuumConfigurationModelXpp3Writer();
+            FileWriter fileWriter = new FileWriter( file );
+            writer.write( fileWriter, configurationModel );
         }
-        ProxyConfiguration proxyConfiguration = this.generalConfiguration.getProxyConfiguration();
-        if ( proxyConfiguration != null )
+        catch ( IOException e )
         {
-            this.configuration.setProperty( PROXY_HOST_KEY, proxyConfiguration.getProxyHost()
);
-            this.configuration.setProperty( PROXY_PORT_KEY, proxyConfiguration.getProxyPort()
);
-            this.configuration.setProperty( PROXY_USER_KEY, proxyConfiguration.getProxyUser()
);
-            this.configuration.setProperty( PROXY_PASSWORD_KEY, proxyConfiguration.getProxyPassword()
);
+            throw new ContinuumConfigurationException( e.getMessage(), e );
         }
+        
     }
-
+    
+    
     // ----------------------------------------
     //  Spring injection
     // ----------------------------------------
 
-    public ClassPathResource getClassPathResource()
+
+    public File getConfigurationFile()
     {
-        return classPathResource;
+        return configurationFile;
     }
 
-
-    public void setClassPathResource( ClassPathResource classPathResource )
+    public void setConfigurationFile( File configurationFile )
     {
-        this.classPathResource = classPathResource;
+        this.configurationFile = configurationFile;
     }
-
+    
 }

Modified: continuum/branches/continuum-1.2.x/continuum-base/continuum-configuration/src/main/resources/META-INF/spring-context.xml
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.2.x/continuum-base/continuum-configuration/src/main/resources/META-INF/spring-context.xml?rev=690561&r1=690560&r2=690561&view=diff
==============================================================================
--- continuum/branches/continuum-1.2.x/continuum-base/continuum-configuration/src/main/resources/META-INF/spring-context.xml
(original)
+++ continuum/branches/continuum-1.2.x/continuum-base/continuum-configuration/src/main/resources/META-INF/spring-context.xml
Sat Aug 30 12:30:53 2008
@@ -25,6 +25,6 @@
 
   <bean id="continuumConfiguration" class="org.apache.continuum.configuration.DefaultContinuumConfiguration"
         init-method="initialize">
-    <property name="classPathResource" value="classpath:META-INF/continuum/continuum-configuration.xml"/>
+    <property name="configurationFile" value="file:${appserver.base}/conf/continuum.xml"/>
   </bean>
 </beans>
\ No newline at end of file

Modified: continuum/branches/continuum-1.2.x/continuum-base/continuum-configuration/src/test/java/org/apache/continuum/configuration/TestDefaultContinuumConfiguration.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.2.x/continuum-base/continuum-configuration/src/test/java/org/apache/continuum/configuration/TestDefaultContinuumConfiguration.java?rev=690561&r1=690560&r2=690561&view=diff
==============================================================================
--- continuum/branches/continuum-1.2.x/continuum-base/continuum-configuration/src/test/java/org/apache/continuum/configuration/TestDefaultContinuumConfiguration.java
(original)
+++ continuum/branches/continuum-1.2.x/continuum-base/continuum-configuration/src/test/java/org/apache/continuum/configuration/TestDefaultContinuumConfiguration.java
Sat Aug 30 12:30:53 2008
@@ -42,14 +42,17 @@
     protected void setUp()
         throws Exception
     {
+        log.info( "appserver.base : " + System.getProperty( "appserver.base" ) );
+        
         File originalConf = new File( getBasedir(), "src/test/resources/conf/continuum.xml"
);
-
+        
         File confUsed = new File( getBasedir(), confFile );
         if ( confUsed.exists() )
         {
             confUsed.delete();
         }
         FileUtils.copyFile( originalConf, confUsed );
+        
         super.setUp();
     }
 
@@ -82,6 +85,8 @@
         generalConfiguration.setProxyConfiguration( new ProxyConfiguration() );
         generalConfiguration.getProxyConfiguration().setProxyHost( "localhost" );
         generalConfiguration.getProxyConfiguration().setProxyPort( 8080 );
+        File targetDir = new File(getBasedir(), "target");
+        generalConfiguration.setBuildOutputDirectory( targetDir );
         configuration.setGeneralConfiguration( generalConfiguration );
         configuration.save();
 
@@ -94,6 +99,7 @@
         assertEquals( "http://test/zloug", configuration.getGeneralConfiguration().getBaseUrl()
);
         assertEquals( "localhost", configuration.getGeneralConfiguration().getProxyConfiguration().getProxyHost()
);
         assertEquals( 8080, configuration.getGeneralConfiguration().getProxyConfiguration().getProxyPort()
);
+        assertEquals(targetDir.getPath(), configuration.getGeneralConfiguration().getBuildOutputDirectory().getPath());
         log.info( "generalConfiguration " + configuration.getGeneralConfiguration().toString()
);
     }
 }

Modified: continuum/branches/continuum-1.2.x/continuum-base/continuum-configuration/src/test/resources/conf/continuum.xml
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.2.x/continuum-base/continuum-configuration/src/test/resources/conf/continuum.xml?rev=690561&r1=690560&r2=690561&view=diff
==============================================================================
--- continuum/branches/continuum-1.2.x/continuum-base/continuum-configuration/src/test/resources/conf/continuum.xml
(original)
+++ continuum/branches/continuum-1.2.x/continuum-base/continuum-configuration/src/test/resources/conf/continuum.xml
Sat Aug 30 12:30:53 2008
@@ -1,7 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<configuration>
-  <continuum>
-    <baseUrl>http://test</baseUrl>
-    <buildOutputDirectory>myBuildOutputDir</buildOutputDirectory>
-  </continuum>
-</configuration>
\ No newline at end of file
+<continuum-configuration>
+  <baseUrl>http://test</baseUrl>
+  <buildOutputDirectory>myBuildOutputDir</buildOutputDirectory>
+</continuum-configuration>
\ No newline at end of file

Modified: continuum/branches/continuum-1.2.x/continuum-commons/src/test/resources/conf/continuum.xml
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.2.x/continuum-commons/src/test/resources/conf/continuum.xml?rev=690561&r1=690560&r2=690561&view=diff
==============================================================================
--- continuum/branches/continuum-1.2.x/continuum-commons/src/test/resources/conf/continuum.xml
(original)
+++ continuum/branches/continuum-1.2.x/continuum-commons/src/test/resources/conf/continuum.xml
Sat Aug 30 12:30:53 2008
@@ -1,7 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<configuration>
-  <continuum>
-    <baseUrl>http://test</baseUrl>
-    <buildOutputDirectory>target/myBuildOutputDir</buildOutputDirectory>
-  </continuum>
-</configuration>
\ No newline at end of file
+<continuum-configuration>
+  <baseUrl>http://test</baseUrl>
+  <buildOutputDirectory>target/myBuildOutputDir</buildOutputDirectory>
+</continuum-configuration>
\ No newline at end of file

Modified: continuum/branches/continuum-1.2.x/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.2.x/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java?rev=690561&r1=690560&r2=690561&view=diff
==============================================================================
--- continuum/branches/continuum-1.2.x/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
(original)
+++ continuum/branches/continuum-1.2.x/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
Sat Aug 30 12:30:53 2008
@@ -2702,54 +2702,6 @@
         return configurationService;
     }
 
-    public void updateConfiguration( Map<String, Object> configuration )
-        throws ContinuumException
-    {
-        try
-        {
-            if ( configuration.get( "conf.workingDirectory" ) != null )
-            {
-                configurationService.setWorkingDirectory( configurationService.getFile( (String)
configuration
-                    .get( "conf.workingDirectory" ) ) );
-            }
-            else
-            {
-                throw new ContinuumException( "working directory can't be null" );
-            }
-
-            if ( configuration.get( "conf.buildOutputDirectory" ) != null )
-            {
-                configurationService.setBuildOutputDirectory( configurationService.getFile(
(String) configuration
-                    .get( "conf.buildOutputDirectory" ) ) );
-            }
-            else
-            {
-                throw new ContinuumException( "build output directory can't be null" );
-            }
-
-            if ( configuration.get( "conf.deploymentRepositoryDirectory" ) != null )
-            {
-                configurationService.setDeploymentRepositoryDirectory( configurationService
-                    .getFile( (String) configuration.get( "conf.deploymentRepositoryDirectory"
) ) );
-            }
-
-            if ( configuration.get( "conf.url" ) != null )
-            {
-                configurationService.setUrl( (String) configuration.get( "conf.url" ) );
-            }
-            else
-            {
-                throw new ContinuumException( "base url can't be null" );
-            }
-
-            configurationService.store();
-        }
-        catch ( Exception e )
-        {
-            throw new ContinuumException( "Can't store configuration.", e );
-        }
-    }
-
     public void reloadConfiguration()
         throws ContinuumException
     {

Modified: continuum/branches/continuum-1.2.x/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/AbstractContinuumProjectBuilder.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.2.x/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/AbstractContinuumProjectBuilder.java?rev=690561&r1=690560&r2=690561&view=diff
==============================================================================
--- continuum/branches/continuum-1.2.x/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/AbstractContinuumProjectBuilder.java
(original)
+++ continuum/branches/continuum-1.2.x/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/AbstractContinuumProjectBuilder.java
Sat Aug 30 12:30:53 2008
@@ -38,8 +38,8 @@
 import org.apache.http.auth.UsernamePasswordCredentials;
 import org.apache.http.client.methods.HttpGet;
 import org.apache.http.conn.ClientConnectionManager;
+import org.apache.http.conn.params.ConnManagerPNames;
 import org.apache.http.conn.params.ConnPerRouteBean;
-import org.apache.http.conn.params.HttpConnectionManagerParams;
 import org.apache.http.conn.scheme.PlainSocketFactory;
 import org.apache.http.conn.scheme.Scheme;
 import org.apache.http.conn.scheme.SchemeRegistry;
@@ -87,11 +87,12 @@
         
         HttpParams params = new BasicHttpParams();
         // TODO put this values to a configuration way ???
-        HttpConnectionManagerParams.setMaxTotalConnections( params, 30 );
-        HttpConnectionManagerParams.setMaxConnectionsPerRoute( params, new ConnPerRouteBean(
30 ) );
+        params.setParameter( ConnManagerPNames.MAX_TOTAL_CONNECTIONS, new Integer( 30 ) );
+        params.setParameter( ConnManagerPNames.MAX_CONNECTIONS_PER_ROUTE, new ConnPerRouteBean(
30 ) );
         HttpProtocolParams.setVersion( params, HttpVersion.HTTP_1_1 );
-        
+
         ClientConnectionManager cm = new ThreadSafeClientConnManager( params, schemeRegistry
);
+        
         httpClient = new DefaultHttpClient( cm, params );
 
         

Propchange: continuum/branches/continuum-1.2.x/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/AbstractContinuumProjectBuilder.java
            ('svn:mergeinfo' removed)

Propchange: continuum/branches/continuum-1.2.x/continuum-core/src/main/java/org/apache/maven/continuum/utils/ContinuumUtils.java
            ('svn:mergeinfo' removed)

Propchange: continuum/branches/continuum-1.2.x/continuum-core/src/test/java/org/apache/maven/continuum/project/builder/AbstractContinuumProjectBuilderTest.java
            ('svn:mergeinfo' removed)

Propchange: continuum/branches/continuum-1.2.x/continuum-core/src/test/java/org/apache/maven/continuum/utils/ContinuumUtilsTest.java
            ('svn:mergeinfo' removed)

Modified: continuum/branches/continuum-1.2.x/continuum-webapp/pom.xml
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.2.x/continuum-webapp/pom.xml?rev=690561&r1=690560&r2=690561&view=diff
==============================================================================
--- continuum/branches/continuum-1.2.x/continuum-webapp/pom.xml (original)
+++ continuum/branches/continuum-1.2.x/continuum-webapp/pom.xml Sat Aug 30 12:30:53 2008
@@ -176,6 +176,18 @@
               <goal>java</goal>
             </goals>
           </execution>
+          <execution>
+            <id>appearence model classes</id>
+            <configuration>
+              <model>src/main/mdo/appearance-models.mdo</model>
+              <version>1.0.0</version>
+            </configuration>
+            <goals>
+              <goal>java</goal>
+              <goal>xpp3-reader</goal>
+              <goal>xpp3-writer</goal>
+            </goals>
+          </execution>          
         </executions>
       </plugin>
       <plugin>

Modified: continuum/branches/continuum-1.2.x/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/ConfigureFooterAction.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/ConfigureFooterAction.java?rev=690561&r1=690560&r2=690561&view=diff
==============================================================================
--- continuum/branches/continuum-1.2.x/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/ConfigureFooterAction.java
(original)
+++ continuum/branches/continuum-1.2.x/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/ConfigureFooterAction.java
Sat Aug 30 12:30:53 2008
@@ -18,9 +18,10 @@
  */
 package org.apache.maven.continuum.web.action.admin;
 
+import java.io.IOException;
+
 import org.apache.maven.continuum.web.action.component.AbstractFooterAction;
 import org.apache.maven.continuum.web.appareance.AppareanceConfiguration;
-import org.codehaus.plexus.registry.RegistryException;
 
 /**
  * @author <a href="mailto:olamy@apache.org">olamy</a>
@@ -38,7 +39,7 @@
     private AppareanceConfiguration appareanceConfiguration;
 
     public String saveFooter()
-        throws RegistryException
+        throws IOException
     {
         appareanceConfiguration.saveFooter( getFooter() );
         return SUCCESS;

Modified: continuum/branches/continuum-1.2.x/continuum-webapp/src/main/java/org/apache/maven/continuum/web/appareance/AppareanceConfiguration.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.2.x/continuum-webapp/src/main/java/org/apache/maven/continuum/web/appareance/AppareanceConfiguration.java?rev=690561&r1=690560&r2=690561&view=diff
==============================================================================
--- continuum/branches/continuum-1.2.x/continuum-webapp/src/main/java/org/apache/maven/continuum/web/appareance/AppareanceConfiguration.java
(original)
+++ continuum/branches/continuum-1.2.x/continuum-webapp/src/main/java/org/apache/maven/continuum/web/appareance/AppareanceConfiguration.java
Sat Aug 30 12:30:53 2008
@@ -18,6 +18,8 @@
  */
 package org.apache.maven.continuum.web.appareance;
 
+import java.io.IOException;
+
 import org.codehaus.plexus.registry.RegistryException;
 
 /**
@@ -33,7 +35,7 @@
      * @throws RegistryException
      */
     public void saveFooter( String footerHtmlContent )
-        throws RegistryException;
+        throws IOException;
 
     /**
      * If no user configuration a default one will be user 

Modified: continuum/branches/continuum-1.2.x/continuum-webapp/src/main/java/org/apache/maven/continuum/web/appareance/DefaultAppareanceConfiguration.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.2.x/continuum-webapp/src/main/java/org/apache/maven/continuum/web/appareance/DefaultAppareanceConfiguration.java?rev=690561&r1=690560&r2=690561&view=diff
==============================================================================
--- continuum/branches/continuum-1.2.x/continuum-webapp/src/main/java/org/apache/maven/continuum/web/appareance/DefaultAppareanceConfiguration.java
(original)
+++ continuum/branches/continuum-1.2.x/continuum-webapp/src/main/java/org/apache/maven/continuum/web/appareance/DefaultAppareanceConfiguration.java
Sat Aug 30 12:30:53 2008
@@ -18,13 +18,21 @@
  */
 package org.apache.maven.continuum.web.appareance;
 
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
 import java.util.Calendar;
 
+import org.apache.continuum.web.appearance.ContinuumAppearance;
+import org.apache.continuum.web.appearance.io.xpp3.ContinuumAppearanceModelsXpp3Reader;
+import org.apache.continuum.web.appearance.io.xpp3.ContinuumAppearanceModelsXpp3Writer;
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
-import org.codehaus.plexus.registry.Registry;
-import org.codehaus.plexus.registry.RegistryException;
+import org.codehaus.plexus.util.ReaderFactory;
 import org.codehaus.plexus.util.StringUtils;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * @author <a href="mailto:olamy@apache.org">olamy</a>
@@ -35,18 +43,14 @@
 public class DefaultAppareanceConfiguration
     implements AppareanceConfiguration, Initializable
 {
-
-    private String FOOTER_REGISTRY_KEY = "footer";
-    
-    private String REGISTRY_SECTION_KEY = "org.apache.maven.continuum.user";
+    private Logger log = LoggerFactory.getLogger( getClass() );
     
     private String footer;
     
-    /**
-     * @plexus.requirement role-hint="commons-configuration"
-     */
-    private Registry registry;
+    public static final String APPEARANCE_FILE_NAME = "continuum-appearance.xml";
     
+    private ContinuumAppearance continuumAppearance = new ContinuumAppearance(); 
+   
     // ------------------------------------------------
     //  Plexus Lifecycle
     // ------------------------------------------------
@@ -54,12 +58,32 @@
     public void initialize()
         throws InitializationException
     {
-        Registry continuumRegistry = getContinuumRegistry();
-        if (continuumRegistry != null)
+        
+        File appearanceConfFile = getAppearanceConfigurationFile();
+
+        if ( appearanceConfFile.exists() )
         {
-            this.footer = continuumRegistry.getString( FOOTER_REGISTRY_KEY );
+            try
+            {
+                ContinuumAppearanceModelsXpp3Reader appearanceReader = new ContinuumAppearanceModelsXpp3Reader();
+                this.continuumAppearance = appearanceReader.read( ReaderFactory
+                    .newXmlReader( appearanceConfFile ) );
+                if ( continuumAppearance != null )
+                {
+                    this.footer = continuumAppearance.getFooter();
+                }
+            }
+            catch ( IOException e )
+            {
+                log.warn( "skip IOException reading appearance file " + APPEARANCE_FILE_NAME
+ ", msg "
+                    + e.getMessage() );
+            }
+            catch ( XmlPullParserException e )
+            {
+                log.warn( "skip XmlPullParserException reading appearance file " + APPEARANCE_FILE_NAME
+ ", msg "
+                    + e.getMessage() );
+            }
         }
-
         if ( StringUtils.isEmpty( this.footer ) )
         {
             // initiate with default footer (save in registry ?)
@@ -79,23 +103,19 @@
      * @see org.apache.maven.continuum.web.appareance.AppareanceConfiguration#saveFooter(java.lang.String)
      */
     public void saveFooter( String footerHtmlContent )
-        throws RegistryException
+        throws IOException
     {
-        Registry continuumRegistry = getContinuumRegistry();
-        
-        continuumRegistry.setString( FOOTER_REGISTRY_KEY, footerHtmlContent );
-        continuumRegistry.save();
+        continuumAppearance.setFooter( footerHtmlContent );
+        ContinuumAppearanceModelsXpp3Writer writer = new ContinuumAppearanceModelsXpp3Writer();
+        File confFile = getAppearanceConfigurationFile();
+        if (!confFile.exists())
+        {
+            confFile.getParentFile().mkdirs();
+        }
+        writer.write( new FileWriter( confFile ), continuumAppearance );
         this.footer = footerHtmlContent;
     }
 
-    // ------------------------------------------------
-    //  Internal stuff
-    // ------------------------------------------------
-
-    private Registry getContinuumRegistry()
-    {
-        return registry.getSection( REGISTRY_SECTION_KEY );
-    }
 
     private String getDefaultFooter()
     {
@@ -110,4 +130,10 @@
         return stringBuilder.toString();
     }    
     
+    
+    private File getAppearanceConfigurationFile()
+    {
+        return new File( System.getProperty( "appserver.base" ) + File.separator + "conf"
+ File.separator
+            + APPEARANCE_FILE_NAME );
+    }
 }

Modified: continuum/branches/continuum-1.2.x/pom.xml
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.2.x/pom.xml?rev=690561&r1=690560&r2=690561&view=diff
==============================================================================
--- continuum/branches/continuum-1.2.x/pom.xml (original)
+++ continuum/branches/continuum-1.2.x/pom.xml Sat Aug 30 12:30:53 2008
@@ -694,7 +694,7 @@
       <dependency>
         <groupId>org.apache.httpcomponents</groupId>
         <artifactId>httpclient</artifactId>
-        <version>4.0-alpha4</version>
+        <version>4.0-beta1</version>
       </dependency>
       <dependency>
         <groupId>org.codehaus.plexus</groupId>



Mime
View raw message