[89924] Support generation of Axis clients to Java projects.
diff --git a/bundles/org.eclipse.jst.ws.axis.consumption.ui/src/org/eclipse/jst/ws/internal/axis/consumption/ui/command/DefaultsForClientJavaWSDLCommand.java b/bundles/org.eclipse.jst.ws.axis.consumption.ui/src/org/eclipse/jst/ws/internal/axis/consumption/ui/command/DefaultsForClientJavaWSDLCommand.java
index bdd9d35..04a24f4 100644
--- a/bundles/org.eclipse.jst.ws.axis.consumption.ui/src/org/eclipse/jst/ws/internal/axis/consumption/ui/command/DefaultsForClientJavaWSDLCommand.java
+++ b/bundles/org.eclipse.jst.ws.axis.consumption.ui/src/org/eclipse/jst/ws/internal/axis/consumption/ui/command/DefaultsForClientJavaWSDLCommand.java
@@ -15,6 +15,8 @@
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IResource;
 import org.eclipse.core.runtime.IPath;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
 import org.eclipse.jst.ws.internal.axis.consumption.core.common.JavaWSDLParameter;
 import org.eclipse.jst.ws.internal.axis.consumption.ui.util.PlatformUtils;
 import org.eclipse.jst.ws.internal.common.ResourceUtils;
@@ -23,6 +25,7 @@
 import org.eclipse.wst.command.internal.provisional.env.core.common.MessageUtils;
 import org.eclipse.wst.command.internal.provisional.env.core.common.SimpleStatus;
 import org.eclipse.wst.command.internal.provisional.env.core.common.Status;
+import org.eclipse.wst.common.componentcore.ModuleCoreNature;
 import org.eclipse.wst.ws.internal.datamodel.Model;
 
 
@@ -78,24 +81,51 @@
 		javaWSDLParam_.setMetaInfOnly(false);
 		javaWSDLParam_.setServerSide(JavaWSDLParameter.SERVER_SIDE_NONE);
 		
-		IPath webModuleServerRoot = ResourceUtils.getJavaSourceLocation(proxyProject_, moduleName_ );
-		//String output = PlatformUtils.getPlatformURL(webModuleServerRoot);
-		String output =	ResourceUtils.findResource(webModuleServerRoot).getLocation().toString();
-//		String output = ResourceUtils.getWorkspaceRoot().getFolder(webModuleServerRoot).getLocation().toString();
-		javaWSDLParam_.setJavaOutput(output);
+	    ModuleCoreNature mn = ModuleCoreNature.getModuleCoreNature(proxyProject_);
+	    if (mn!=null)
+	    {
+			IPath webModuleServerRoot = ResourceUtils.getJavaSourceLocation(proxyProject_, moduleName_ );
+			//String output = PlatformUtils.getPlatformURL(webModuleServerRoot);
+			String output =	ResourceUtils.findResource(webModuleServerRoot).getLocation().toString();
+//			String output = ResourceUtils.getWorkspaceRoot().getFolder(webModuleServerRoot).getLocation().toString();
+			javaWSDLParam_.setJavaOutput(output);
 
 
-		IFolder webModuleContainer = ResourceUtils.getWebComponentServerRoot(proxyProject_, moduleName_);
-		if (webModuleContainer !=null)
-		{
-		  IPath webModulePath = webModuleContainer.getFullPath();
-		  //output =  PlatformUtils.getPlatformURL(webModulePath);
-		  IResource res = ResourceUtils.findResource(webModulePath);
-		  if (res!=null){
-			  output = res.getLocation().toString();
-		  } 
-		  javaWSDLParam_.setOutput(output);
-		}
+			IFolder webModuleContainer = ResourceUtils.getWebComponentServerRoot(proxyProject_, moduleName_);
+			if (webModuleContainer !=null)
+			{
+			  IPath webModulePath = webModuleContainer.getFullPath();
+			  //output =  PlatformUtils.getPlatformURL(webModulePath);
+			  IResource res = ResourceUtils.findResource(webModulePath);
+			  if (res!=null){
+				  output = res.getLocation().toString();
+			  } 
+			  javaWSDLParam_.setOutput(output);
+			}	
+	    }
+	    else
+	    {
+	    	//Check if it's a plain old Java project
+	    	IJavaProject javaProject = null;
+	  
+	 		 javaProject = JavaCore.create(proxyProject_);    
+	 		 if (javaProject != null)
+	 		 {
+	 			IPath webModuleServerRoot = ResourceUtils.getJavaSourceLocation(proxyProject_);
+				String output =	ResourceUtils.findResource(webModuleServerRoot).getLocation().toString();
+				javaWSDLParam_.setJavaOutput(output);
+				javaWSDLParam_.setOutput(output);
+	 		 }
+	 		 else
+	 		 {
+	 			 //Not familiar with this kind of project
+	 	 		 status = new SimpleStatus("", msgUtils_.getMessage("MSG_WARN_NO_JAVA_NATURE"), Status.ERROR);	
+	 	 		 environment.getStatusHandler().reportError(status);
+	 	 		 return status;
+	 			 
+	 		 }
+	    }
+
 
 
 		if (WSDLServicePathname_ == null) {
diff --git a/bundles/org.eclipse.jst.ws.axis.consumption.ui/src/org/eclipse/jst/ws/internal/axis/consumption/ui/task/CopyAxisJarCommand.java b/bundles/org.eclipse.jst.ws.axis.consumption.ui/src/org/eclipse/jst/ws/internal/axis/consumption/ui/task/CopyAxisJarCommand.java
index e6cac74..1a8493c 100644
--- a/bundles/org.eclipse.jst.ws.axis.consumption.ui/src/org/eclipse/jst/ws/internal/axis/consumption/ui/task/CopyAxisJarCommand.java
+++ b/bundles/org.eclipse.jst.ws.axis.consumption.ui/src/org/eclipse/jst/ws/internal/axis/consumption/ui/task/CopyAxisJarCommand.java
@@ -11,24 +11,41 @@
 package org.eclipse.jst.ws.internal.axis.consumption.ui.task;
 
 
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IPluginDescriptor;
 import org.eclipse.core.runtime.IPluginRegistry;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Path;
 import org.eclipse.core.runtime.Platform;
 import org.eclipse.core.runtime.Plugin;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jst.ws.internal.axis.consumption.ui.plugin.WebServiceAxisConsumptionUIPlugin;
 import org.eclipse.jst.ws.internal.common.J2EEUtils;
 import org.eclipse.jst.ws.internal.common.ResourceUtils;
 import org.eclipse.wst.command.internal.env.common.FileResourceUtils;
+import org.eclipse.wst.command.internal.env.ui.eclipse.EclipseProgressMonitor;
 import org.eclipse.wst.command.internal.provisional.env.core.SimpleCommand;
 import org.eclipse.wst.command.internal.provisional.env.core.common.Environment;
 import org.eclipse.wst.command.internal.provisional.env.core.common.MessageUtils;
+import org.eclipse.wst.command.internal.provisional.env.core.common.ProgressMonitor;
 import org.eclipse.wst.command.internal.provisional.env.core.common.SimpleStatus;
 import org.eclipse.wst.command.internal.provisional.env.core.common.Status;
+import org.eclipse.wst.command.internal.provisional.env.core.common.StatusException;
 import org.eclipse.wst.command.internal.provisional.env.core.context.ResourceContext;
 import org.eclipse.wst.command.internal.provisional.env.core.context.TransientResourceContext;
+import org.eclipse.wst.common.componentcore.ModuleCoreNature;
 
 
 public class CopyAxisJarCommand extends SimpleCommand {
@@ -44,6 +61,7 @@
 	  "saaj.jar",
 	  "wsdl4j-1.5.1.jar"
   };
+  public static String PATH_TO_JARS_IN_PLUGIN = "lib/";
 
   private String DESCRIPTION = "TASK_DESC_COPY_JARS_TO_PROJECT";
   private String LABEL = "TASK_LABEL_COPY_JARS_TO_PROJECT";
@@ -73,7 +91,36 @@
   public Status execute(Environment env) {
     Status status = new SimpleStatus("");
     env.getProgressMonitor().report(msgUtils_.getMessage("PROGRESS_INFO_COPY_AXIS_CFG"));
-    copyAxisJarsToProject(project, status, env);
+    
+    ModuleCoreNature mn = ModuleCoreNature.getModuleCoreNature(project);
+    if (mn!=null)
+    {
+    	copyAxisJarsToProject(project, status, env);	
+    }
+    else
+    {
+    	//Check if it's a plain old Java project
+    	IJavaProject javaProject = null;
+  
+ 		 javaProject = JavaCore.create(project);    
+ 		 if (javaProject != null)
+ 		 {
+ 			status = addAxisJarsToBuildPath(project, env);
+ 			if (status.getSeverity()==Status.ERROR)
+ 			{
+ 				env.getStatusHandler().reportError(status);
+ 				return status;
+ 			}
+ 		 }
+ 		 else
+ 		 {
+ 		   status = new SimpleStatus("", msgUtils_.getMessage("MSG_WARN_NO_JAVA_NATURE"), Status.ERROR);	
+ 		   env.getStatusHandler().reportError(status);
+ 		   return status;
+ 		 }
+
+    }
+    
     return status;
 
   }
@@ -127,6 +174,133 @@
     }
   }
 
+  public Status addAxisJarsToBuildPath(IProject p, Environment env)
+  {
+	  for (int i=0; i<JARLIST.length; i++)
+	  {
+		  StringBuffer sb = new StringBuffer();
+		  sb.append(PATH_TO_JARS_IN_PLUGIN);
+		  sb.append(JARLIST[i]);
+		  String jarName = sb.toString();
+		  Status status = AddJar(p, AXIS_RUNTIME_PLUGIN_ID, jarName, env);
+		  if (status.getSeverity()==Status.ERROR)
+		  {			  
+			  return status;
+		  }
+	  }
+	  return new SimpleStatus("");
+  }
+  
+	private Status AddJar(IProject webProject, String pluginId, String jarName, Environment env)  {
+		
+		   Status status = new SimpleStatus("");
+		   //
+		   // Get the current classpath.
+		   //
+		   IJavaProject javaProject_ = null;
+		   IClasspathEntry[] oldClasspath = null;
+    	   javaProject_ = JavaCore.create(webProject); 
+    	   try
+    	   {
+		   oldClasspath = javaProject_.getRawClasspath();
+    	   }
+    	   catch(JavaModelException jme)
+    	   {
+    		   status = new SimpleStatus("", msgUtils_.getMessage("MSG_ERROR_BAD_BUILDPATH"), Status.ERROR, jme);
+    		   //env.getStatusHandler().reportError(status);
+    		   return status;
+    	   }
+
+
+		   boolean found = false;
+		   for (int i=0; i<oldClasspath.length; i++)
+		   {
+			 found = found || oldClasspath[i].getPath().toString().toLowerCase().endsWith(jarName.toLowerCase());
+		   }
+
+		   if (found) 
+		   {
+			 return status;
+		   }
+
+		   IClasspathEntry[] newClasspath = new IClasspathEntry[oldClasspath.length + 1];
+		   int i=0;
+		   while (i<oldClasspath.length)
+		   {
+			 newClasspath[i] = oldClasspath[i];
+			 i++;
+		   }
+
+		   try
+		   {
+
+			   newClasspath[i++] = JavaCore.newLibraryEntry(getTheJarPath(pluginId,jarName), null, null);
+
+		   }
+		   catch (CoreException e)
+		   {
+			 status = new SimpleStatus("", msgUtils_.getMessage("MSG_ERROR_BAD_BUILDPATH"), Status.ERROR, e);
+			 return status;
+		   }
+
+		   //
+		   // Then update the project classpath.
+		   //
+		   try
+		   {
+		   	 ProgressMonitor monitor = env.getProgressMonitor();
+		   	 IProgressMonitor eclipseMonitor = null;
+		   	 if (monitor instanceof EclipseProgressMonitor)
+		   	 {
+		   	 	eclipseMonitor = ((EclipseProgressMonitor)monitor).getMonitor();
+		   	 }
+			 javaProject_.setRawClasspath(newClasspath,eclipseMonitor);
+		   }
+		   catch (JavaModelException e)
+		   {
+			 status = new SimpleStatus("", msgUtils_.getMessage("MSG_ERROR_BAD_BUILDPATH"), Status.ERROR, e);
+			 return status;
+		   }
+		   
+		   return status;
+		 }
+
+		//
+		// Returns the local native pathname of the jar.
+		//
+		private IPath getTheJarPath(String pluginId, String theJar)
+			throws CoreException {
+			try {
+				if (pluginId != null) {
+					IPluginRegistry pluginRegistry = Platform.getPluginRegistry();
+					IPluginDescriptor pluginDescriptor =
+						pluginRegistry.getPluginDescriptor(pluginId);
+					URL localURL =
+						Platform.asLocalURL(
+							new URL(pluginDescriptor.getInstallURL(), theJar));
+					return new Path(localURL.getFile());
+				} else {
+					return new Path(theJar);
+				}
+			} catch (MalformedURLException e) {
+				throw new CoreException(
+					new org.eclipse.core.runtime.Status(
+						IStatus.WARNING,
+						WebServiceAxisConsumptionUIPlugin.ID,
+						0,
+						msgUtils_.getMessage("MSG_BAD_AXIS_JAR_URL"),
+						e));
+			} catch (IOException e) {
+				throw new CoreException(
+					new org.eclipse.core.runtime.Status(
+						IStatus.WARNING,
+						WebServiceAxisConsumptionUIPlugin.ID,
+						0,
+						msgUtils_.getMessage("MSG_BAD_AXIS_JAR_URL"),
+						e));
+			}
+		}  
+  
   public void setProject(IProject project) {
     this.project = project;
   }
diff --git a/bundles/org.eclipse.jst.ws.axis.consumption.ui/src/org/eclipse/jst/ws/internal/axis/consumption/ui/task/Stub2BeanCommand.java b/bundles/org.eclipse.jst.ws.axis.consumption.ui/src/org/eclipse/jst/ws/internal/axis/consumption/ui/task/Stub2BeanCommand.java
index 4bd3e91..534b532 100644
--- a/bundles/org.eclipse.jst.ws.axis.consumption.ui/src/org/eclipse/jst/ws/internal/axis/consumption/ui/task/Stub2BeanCommand.java
+++ b/bundles/org.eclipse.jst.ws.axis.consumption.ui/src/org/eclipse/jst/ws/internal/axis/consumption/ui/task/Stub2BeanCommand.java
@@ -28,12 +28,17 @@
 
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
 import org.eclipse.jst.ws.internal.axis.consumption.core.common.JavaWSDLParameter;
 import org.eclipse.jst.ws.internal.axis.consumption.ui.util.WSDLUtils;
+import org.eclipse.jst.ws.internal.common.ResourceUtils;
 import org.eclipse.wst.command.internal.provisional.env.core.SimpleCommand;
 import org.eclipse.wst.command.internal.provisional.env.core.common.Environment;
+import org.eclipse.wst.command.internal.provisional.env.core.common.MessageUtils;
 import org.eclipse.wst.command.internal.provisional.env.core.common.SimpleStatus;
 import org.eclipse.wst.command.internal.provisional.env.core.common.Status;
+import org.eclipse.wst.common.componentcore.ModuleCoreNature;
 import org.eclipse.wst.ws.internal.parser.wsil.WebServicesParser;
 
 
@@ -48,11 +53,15 @@
   private String module_ = "";
   
   private IProject clientProject_;
+  
+  private MessageUtils msgUtils_;
 
   public Stub2BeanCommand()
   {
     super("org.eclipse.jst.ws.was.creation.ui.task.Stub2BeanCommand", "org.eclipse.jst.ws.was.creation.ui.task.Stub2BeanCommand");
     portTypes_ = new Vector();
+    String pluginId = "org.eclipse.jst.ws.axis.consumption.ui";
+    msgUtils_ = new MessageUtils(pluginId + ".plugin", this);    
     //setRunInWorkspaceModifyOperation(false);
   }
   
@@ -60,6 +69,8 @@
 	  super("org.eclipse.jst.ws.was.creation.ui.task.Stub2BeanCommand", "org.eclipse.jst.ws.was.creation.ui.task.Stub2BeanCommand");
 	  portTypes_ = new Vector();	  
 	  module_ = moduleName;
+	  String pluginId = "org.eclipse.jst.ws.axis.consumption.ui";
+	  msgUtils_ = new MessageUtils(pluginId + ".plugin", this);	  
   }
 
   /**
@@ -87,6 +98,22 @@
         }
       }
     }
+    
+    //Ensure the client project is either a flexible project or a Java project
+    ModuleCoreNature mn = ModuleCoreNature.getModuleCoreNature(clientProject_);
+    if (mn==null)
+    {
+        // Check if it's a plain old Java project
+    	IJavaProject javaProject = null;    	  
+		javaProject = JavaCore.create(clientProject_);    
+		if (javaProject == null)
+		{
+	 		   Status status = new SimpleStatus("", msgUtils_.getMessage("MSG_WARN_NO_JAVA_NATURE"), Status.ERROR);	
+	 		   env.getStatusHandler().reportError(status);
+	 		   return status;
+		}    	
+    }
+    
     Map pkg2nsMapping = javaWSDLParam_.getMappings();
     Map services = def.getServices();
     for (Iterator it = services.values().iterator(); it.hasNext();)
diff --git a/bundles/org.eclipse.jst.ws.axis.consumption.ui/src/org/eclipse/jst/ws/internal/axis/consumption/ui/task/Stub2BeanInfo.java b/bundles/org.eclipse.jst.ws.axis.consumption.ui/src/org/eclipse/jst/ws/internal/axis/consumption/ui/task/Stub2BeanInfo.java
index 04b3ab1..1bca2ea 100644
--- a/bundles/org.eclipse.jst.ws.axis.consumption.ui/src/org/eclipse/jst/ws/internal/axis/consumption/ui/task/Stub2BeanInfo.java
+++ b/bundles/org.eclipse.jst.ws.axis.consumption.ui/src/org/eclipse/jst/ws/internal/axis/consumption/ui/task/Stub2BeanInfo.java
@@ -26,6 +26,8 @@
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
 import org.eclipse.jem.internal.plugin.JavaEMFNature;
 import org.eclipse.jem.java.JavaClass;
 import org.eclipse.jem.java.JavaHelpers;
@@ -39,6 +41,7 @@
 import org.eclipse.wst.command.internal.env.common.FileResourceUtils;
 import org.eclipse.wst.command.internal.provisional.env.core.common.ProgressMonitor;
 import org.eclipse.wst.command.internal.provisional.env.core.common.StatusHandler;
+import org.eclipse.wst.common.componentcore.ModuleCoreNature;
 
 public class Stub2BeanInfo
 {
@@ -216,9 +219,35 @@
 
     JavaEMFNature javaMOF = (JavaEMFNature)JavaEMFNature.createRuntime(clientProject_);
     ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
-    IPath sourceFolderPath = ResourceUtils.getJavaSourceLocation(clientProject_, moduleName_);
-    IFolder sourceFolder = (IFolder)ResourceUtils.findResource(sourceFolderPath);
-    IPath filePath = sourceFolder.getFile(new Path(sb.toString())).getFullPath();
+    IPath sourceFolderPath = null;
+    IPath filePath = null;
+    ModuleCoreNature mn = ModuleCoreNature.getModuleCoreNature(clientProject_);
+    if (mn!=null)
+    {
+    	sourceFolderPath = ResourceUtils.getJavaSourceLocation(clientProject_, moduleName_);
+        IFolder sourceFolder = (IFolder)ResourceUtils.findResource(sourceFolderPath);
+        filePath = sourceFolder.getFile(new Path(sb.toString())).getFullPath();    	
+    }
+    else
+    {
+        // It's a plain old Java project
+    	IJavaProject javaProject = null;    	  
+		javaProject = JavaCore.create(clientProject_);
+
+		sourceFolderPath = ResourceUtils.getJavaSourceLocation(clientProject_);
+		IResource sourceFolderResource = ResourceUtils.findResource(sourceFolderPath);
+		if (sourceFolderResource instanceof IFolder) 
+		{
+				IFolder sourceFolder = (IFolder) sourceFolderResource;
+				filePath = sourceFolder.getFile(new Path(sb.toString())).getFullPath();
+		} else 
+		{
+			// The source must be going directly in the project
+			filePath = clientProject_.getFile(new Path(sb.toString())).getFullPath();
+		}
+		
+    }
+
     FileResourceUtils.createFile(WebServicePlugin.getInstance().getResourceContext(), filePath, bais, progressMonitor, statusMonitor);
   }