continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r690520 - in /continuum/trunk/continuum-webapp: ./ src/main/java/org/apache/maven/continuum/web/action/admin/ src/main/java/org/apache/maven/continuum/web/appareance/ src/main/mdo/
Date Sat, 30 Aug 2008 15:31:58 GMT
Author: olamy
Date: Sat Aug 30 08:31:57 2008
New Revision: 690520

URL: http://svn.apache.org/viewvc?rev=690520&view=rev
Log:
[CONTINUUM-1831] When click "save" or "cancel" button on the Appearance page (with or without
making changes), get java.lang.NullPointerException error



Added:
    continuum/trunk/continuum-webapp/src/main/mdo/appearance-models.mdo   (with props)
Modified:
    continuum/trunk/continuum-webapp/pom.xml
    continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/ConfigureFooterAction.java
    continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/appareance/AppareanceConfiguration.java
    continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/appareance/DefaultAppareanceConfiguration.java

Modified: continuum/trunk/continuum-webapp/pom.xml
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/pom.xml?rev=690520&r1=690519&r2=690520&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/pom.xml (original)
+++ continuum/trunk/continuum-webapp/pom.xml Sat Aug 30 08:31:57 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/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/ConfigureFooterAction.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/ConfigureFooterAction.java?rev=690520&r1=690519&r2=690520&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/ConfigureFooterAction.java
(original)
+++ continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/ConfigureFooterAction.java
Sat Aug 30 08:31:57 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/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/appareance/AppareanceConfiguration.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/appareance/AppareanceConfiguration.java?rev=690520&r1=690519&r2=690520&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/appareance/AppareanceConfiguration.java
(original)
+++ continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/appareance/AppareanceConfiguration.java
Sat Aug 30 08:31:57 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/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/appareance/DefaultAppareanceConfiguration.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/appareance/DefaultAppareanceConfiguration.java?rev=690520&r1=690519&r2=690520&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/appareance/DefaultAppareanceConfiguration.java
(original)
+++ continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/appareance/DefaultAppareanceConfiguration.java
Sat Aug 30 08:31:57 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 );
+    }
 }

Added: continuum/trunk/continuum-webapp/src/main/mdo/appearance-models.mdo
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/mdo/appearance-models.mdo?rev=690520&view=auto
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/mdo/appearance-models.mdo (added)
+++ continuum/trunk/continuum-webapp/src/main/mdo/appearance-models.mdo Sat Aug 30 08:31:57
2008
@@ -0,0 +1,25 @@
+<model>
+  <id>continuum-appearance-models</id>
+  <name>ContinuumAppearanceModels</name>
+  <defaults>
+    <default>
+      <key>package</key>
+      <value>org.apache.continuum.web.appearance</value>
+    </default>
+  </defaults>
+  <classes>
+    <class rootElement="true">
+      <name>ContinuumAppearance</name>
+      <version>1.0.0</version>
+      <fields>
+        <field>
+          <name>footer</name>
+          <version>1.0.0</version>
+          <description></description>
+          <type>String</type>
+          <required>false</required>
+        </field>
+      </fields>
+    </class>
+  </classes>
+</model>
\ No newline at end of file

Propchange: continuum/trunk/continuum-webapp/src/main/mdo/appearance-models.mdo
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: continuum/trunk/continuum-webapp/src/main/mdo/appearance-models.mdo
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision



Mime
View raw message