continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject svn commit: r955116 - in /continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action: AddMavenProjectAction.java AddProjectAction.java
Date Wed, 16 Jun 2010 02:41:34 GMT
Author: ctan
Date: Wed Jun 16 02:41:33 2010
New Revision: 955116

URL: http://svn.apache.org/viewvc?rev=955116&view=rev
Log:
[CONTINUUM-2169] fixed NPE in getText when using execAndWait interceptors

Modified:
    continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenProjectAction.java
    continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddProjectAction.java

Modified: continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenProjectAction.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenProjectAction.java?rev=955116&r1=955115&r2=955116&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenProjectAction.java
(original)
+++ continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenProjectAction.java
Wed Jun 16 02:41:33 2010
@@ -41,6 +41,13 @@ import org.apache.maven.continuum.web.ex
 import org.apache.struts2.interceptor.ServletRequestAware;
 import org.codehaus.plexus.util.StringUtils;
 
+import com.opensymphony.xwork2.ActionContext;
+import com.opensymphony.xwork2.config.ConfigurationManager;
+import com.opensymphony.xwork2.config.providers.XWorkConfigurationProvider;
+import com.opensymphony.xwork2.inject.Container;
+import com.opensymphony.xwork2.util.ValueStack;
+import com.opensymphony.xwork2.util.ValueStackFactory;
+
 /**
  * Action to add a Maven project to Continuum, either Maven 1 or Maven 2.
  *
@@ -107,6 +114,21 @@ public abstract class AddMavenProjectAct
             return REQUIRES_AUTHORIZATION;
         }
 
+        // ctan: hack for WW-3161
+        if ( ActionContext.getContext() == null )
+        {
+            // This fix allow initialization of ActionContext.getContext() to avoid NPE
+
+            ConfigurationManager configurationManager = new ConfigurationManager();
+            configurationManager.addContainerProvider( new XWorkConfigurationProvider() );
+            com.opensymphony.xwork2.config.Configuration config = configurationManager.getConfiguration();
+            Container container = config.getContainer();
+    
+            ValueStack stack = container.getInstance( ValueStackFactory.class ).createValueStack();
+            stack.getContext().put( ActionContext.CONTAINER, container );
+            ActionContext.setContext( new ActionContext( stack.getContext() ) );
+        }
+
         boolean checkProtocol = true;
 
         if ( !StringUtils.isEmpty( pomUrl ) )

Modified: continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddProjectAction.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddProjectAction.java?rev=955116&r1=955115&r2=955116&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddProjectAction.java
(original)
+++ continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddProjectAction.java
Wed Jun 16 02:41:33 2010
@@ -38,6 +38,13 @@ import org.codehaus.plexus.util.StringUt
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.opensymphony.xwork2.ActionContext;
+import com.opensymphony.xwork2.config.ConfigurationManager;
+import com.opensymphony.xwork2.config.providers.XWorkConfigurationProvider;
+import com.opensymphony.xwork2.inject.Container;
+import com.opensymphony.xwork2.util.ValueStack;
+import com.opensymphony.xwork2.util.ValueStackFactory;
+
 /**
  * @author Nick Gonzalez
  * @version $Id$
@@ -92,6 +99,8 @@ public class AddProjectAction
     public void validate()
     {
         clearErrorsAndMessages();
+        initializeActionContext();
+        
         try
         {
             if ( ( projectName != null ) && !( projectName.trim().length() > 0
) )
@@ -254,6 +263,24 @@ public class AddProjectAction
         }
     }
 
+    private void initializeActionContext()
+    {
+        // ctan: hack for WW-3161
+        if ( ActionContext.getContext() == null )
+        {
+            // This fix allow initialization of ActionContext.getContext() to avoid NPE
+
+            ConfigurationManager configurationManager = new ConfigurationManager();
+            configurationManager.addContainerProvider( new XWorkConfigurationProvider() );
+            com.opensymphony.xwork2.config.Configuration config = configurationManager.getConfiguration();
+            Container container = config.getContainer();
+    
+            ValueStack stack = container.getInstance( ValueStackFactory.class ).createValueStack();
+            stack.getContext().put( ActionContext.CONTAINER, container );
+            ActionContext.setContext( new ActionContext( stack.getContext() ) );
+        }
+    }
+
     public String getProjectName()
     {
         return projectName;



Mime
View raw message