From 9c227ec7edd2169c8efec5d7130e9fc583ab43ae Mon Sep 17 00:00:00 2001 From: kchan Date: Thu, 19 May 2005 18:20:30 +0000 Subject: [95664] Web service scenarios broken due to dependency changes in J2EE. --- .../ui/command/CheckForServiceProjectCommand.java | 4 +- .../consumption/ui/common/ValidationUtils.java | 49 +++++++++++----------- .../runtime/ClientRuntimeSelectionWidget.java | 5 ++- .../widgets/test/AddModuleDependenciesCommand.java | 14 +++---- .../ui/widgets/test/ClientTestDelegateCommand.java | 3 -- .../test/CopyWebServiceUtilsJarCommand.java | 15 +++---- .../widgets/test/wssample/GSTCGenerateCommand.java | 1 + .../ui/wizard/ClientProjectTypeRegistry.java | 17 ++++---- 8 files changed, 57 insertions(+), 51 deletions(-) (limited to 'bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui') diff --git a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/command/CheckForServiceProjectCommand.java b/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/command/CheckForServiceProjectCommand.java index 8cf6eda22..56f58a884 100644 --- a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/command/CheckForServiceProjectCommand.java +++ b/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/command/CheckForServiceProjectCommand.java @@ -14,7 +14,7 @@ import java.util.Calendar; import java.util.GregorianCalendar; import org.eclipse.core.resources.IProject; -import org.eclipse.jst.ws.internal.common.StringToIProjectTransformer; +import org.eclipse.jem.util.emf.workbench.ProjectUtilities; import org.eclipse.jst.ws.internal.consumption.ui.common.ValidationUtils; import org.eclipse.wst.command.internal.provisional.env.core.SimpleCommand; import org.eclipse.wst.command.internal.provisional.env.core.common.Environment; @@ -72,7 +72,7 @@ public class CheckForServiceProjectCommand extends SimpleCommand if (clientProjectName==null || clientProjectName.length()==0) return status; - IProject clientProject = (IProject)((new StringToIProjectTransformer()).transform(clientProjectName)); + IProject clientProject = ProjectUtilities.getProject(clientProjectName); ValidationUtils vu = new ValidationUtils(); Calendar cal = new GregorianCalendar(); boolean isServiceProject = vu.isProjectServiceProject(clientProject, wsdlURI, webServicesParser); diff --git a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/common/ValidationUtils.java b/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/common/ValidationUtils.java index 0178b2eff..392979922 100644 --- a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/common/ValidationUtils.java +++ b/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/common/ValidationUtils.java @@ -21,6 +21,7 @@ import javax.wsdl.Service; import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; +import org.eclipse.jem.util.emf.workbench.ProjectUtilities; import org.eclipse.jst.j2ee.internal.webservices.WebServiceEditModel; import org.eclipse.jst.j2ee.internal.webservices.WebServicesManager; import org.eclipse.jst.j2ee.webservice.internal.WebServiceConstants; @@ -34,13 +35,10 @@ import org.eclipse.jst.ws.internal.common.ServerUtils; import org.eclipse.jst.ws.internal.common.StringToIProjectTransformer; import org.eclipse.jst.ws.internal.consumption.ui.plugin.WebServiceConsumptionUIPlugin; import org.eclipse.jst.ws.internal.consumption.ui.wizard.ClientProjectTypeRegistry; -import org.eclipse.wst.command.internal.env.common.FileResourceUtils; 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.command.internal.provisional.env.core.selection.SelectionListChoices; -import org.eclipse.wst.common.componentcore.internal.StructureEdit; -import org.eclipse.wst.common.componentcore.internal.WorkbenchComponent; import org.eclipse.wst.server.core.IRuntime; import org.eclipse.wst.ws.internal.parser.wsil.WebServicesParser; @@ -60,13 +58,13 @@ public class ValidationUtils msgUtils = new MessageUtils( pluginId + ".plugin", this ); } - public Status validateProjectTargetAndJ2EE(String projectName, String earName, String serverFactoryId, String j2eeLevel) + public Status validateProjectTargetAndJ2EE(String projectName, String compName, String earName, String earCompName, String serverFactoryId, String j2eeLevel) { - IProject p = FileResourceUtils.getWorkspaceRoot().getProject(projectName); - IProject earP = null; - if (earName!=null && !earName.equalsIgnoreCase("")) { - earP = FileResourceUtils.getWorkspaceRoot().getProject(earName); - } + IProject p = ProjectUtilities.getProject(projectName); + IProject earP = null; + if (earName!=null && !earName.equalsIgnoreCase("")) { + earP = ProjectUtilities.getProject(earName); + } Status targetStatus = doesProjectTargetMatchServerType(p, serverFactoryId); if (earP!=null && targetStatus.getSeverity()==Status.OK) { @@ -84,10 +82,10 @@ public class ValidationUtils //Validate service side J2EE level - Status j2eeStatus = doesProjectMatchJ2EELevel(p, j2eeLevel); + Status j2eeStatus = doesProjectMatchJ2EELevel(p, compName, j2eeLevel); if(earP!=null && j2eeStatus.getSeverity()==Status.OK) { - Status earJ2EEStatus = doesProjectMatchJ2EELevel(earP, j2eeLevel); + Status earJ2EEStatus = doesProjectMatchJ2EELevel(earP, earCompName, j2eeLevel); if(earJ2EEStatus.getSeverity()==Status.ERROR) { return earJ2EEStatus; @@ -123,17 +121,13 @@ public class ValidationUtils return new SimpleStatus(""); } - private Status doesProjectMatchJ2EELevel(IProject p, String j2eeLevel) + private Status doesProjectMatchJ2EELevel(IProject p, String compName, String j2eeLevel) { - StructureEdit mc = null; + try { if (p!=null && p.exists()) { - mc = StructureEdit.getStructureEditForRead(p); - WorkbenchComponent[] wbcs = mc.getWorkbenchModules(); - - - int projectJ2EELevel = J2EEUtils.getJ2EEVersion(p); + int projectJ2EELevel = J2EEUtils.getJ2EEVersion(p, compName); if (projectJ2EELevel!=-1) { String projectJ2EELevelString = String.valueOf(projectJ2EELevel); @@ -146,10 +140,10 @@ public class ValidationUtils } } } - } finally { - if (mc != null) - mc.dispose(); - } + } catch(Exception e){ + + } + return new SimpleStatus(""); } @@ -159,7 +153,7 @@ public class ValidationUtils IProject p = (IProject)((new StringToIProjectTransformer()).transform(projectName)); if (p==null || !p.exists()) { - //Project does not exist which means a new project of the correct type will be creates + //Project does not exist which means a new project of the correct type will be created //We're done. All is good. return status; } @@ -195,6 +189,13 @@ public class ValidationUtils return clientTypeLabel; } + /** + * + * @param p + * @param wsdlURL + * @param parser + * @return + */ public boolean isProjectServiceProject(IProject p, String wsdlURL, WebServicesParser parser) { if (p==null || wsdlURL==null || wsdlURL.length()==0 || parser==null) @@ -245,7 +246,7 @@ public class ValidationUtils return false; } - /* + /** * @deprecated * */ diff --git a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/runtime/ClientRuntimeSelectionWidget.java b/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/runtime/ClientRuntimeSelectionWidget.java index f9f44cd8f..2904a82ab 100644 --- a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/runtime/ClientRuntimeSelectionWidget.java +++ b/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/runtime/ClientRuntimeSelectionWidget.java @@ -322,6 +322,9 @@ public class ClientRuntimeSelectionWidget extends SimpleWidgetDataContributor { String clientEARName = clientProjects.getChoice().getList().getSelection(); String clientProjName = clientProjects.getList().getSelection(); + + String clientCompName = projectWidget_.getComponentName(); + String clientEARCompName = projectWidget_.getEarComponentName(); //Validate that the selected client project is of the type indicated by client project type. Status clientProjectTypeStatus = valUtils.validateProjectType(clientProjName, runtime2ClientTypes_); @@ -333,7 +336,7 @@ public class ClientRuntimeSelectionWidget extends SimpleWidgetDataContributor //Validate client side server targets and J2EE levels String clientServerFactoryId = getClientTypeRuntimeServer().getServerId(); String clientJ2EElevel = getJ2EEVersion(); - Status clientProjectStatus = valUtils.validateProjectTargetAndJ2EE(clientProjName, clientEARName, clientServerFactoryId, + Status clientProjectStatus = valUtils.validateProjectTargetAndJ2EE(clientProjName, clientCompName, clientEARName, clientEARCompName, clientServerFactoryId, clientJ2EElevel); if (clientProjectStatus.getSeverity() == Status.ERROR) { diff --git a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/AddModuleDependenciesCommand.java b/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/AddModuleDependenciesCommand.java index 2d1c390f5..2dbae5731 100644 --- a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/AddModuleDependenciesCommand.java +++ b/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/AddModuleDependenciesCommand.java @@ -95,15 +95,15 @@ public class AddModuleDependenciesCommand extends SimpleCommand clientP = clientProject.substring(0,index); clientC = clientProject.substring(index + 1); } - IProject clientIProject = (IProject)ProjectUtilities.getProject(clientP); + IProject clientIProject = ProjectUtilities.getProject(clientP); - if (clientIProject != null && !ResourceUtils.isWebProject(clientIProject)) + if (clientIProject != null && !J2EEUtils.isWebComponent(clientIProject, clientC)) { String uri = clientIProject.getName() + ".jar"; if (ResourceUtils.isTrueJavaProject(clientIProject)) addJavaProjectAsUtilityJar(clientIProject, sampleIEAR, uri); - addJAROrModuleDependency(sampleIProject, uri); + addJAROrModuleDependency(sampleIProject, sampleC, uri); addBuildPath(sampleIProject, clientIProject); } } @@ -122,14 +122,14 @@ public class AddModuleDependenciesCommand extends SimpleCommand cmd.execute(); } - private void addJAROrModuleDependency(IProject project, String uri) throws IOException, CoreException + private void addJAROrModuleDependency(IProject project, String compName, String uri) throws IOException, CoreException { J2EENature nature = null; - if (ResourceUtils.isWebProject(project)) + if (J2EEUtils.isWebComponent(project, compName)) nature = getWebNature(project); - else if (ResourceUtils.isAppClientProject(project)) + else if (J2EEUtils.isAppClientComponent(project, compName)) nature = getAppClientNature(project); - else if (ResourceUtils.isEJBProject(project)) + else if (J2EEUtils.isEJBComponent(project, compName)) nature = getEJBNature(project); if (nature != null) { diff --git a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/ClientTestDelegateCommand.java b/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/ClientTestDelegateCommand.java index 62732f075..cab75f9ed 100644 --- a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/ClientTestDelegateCommand.java +++ b/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/ClientTestDelegateCommand.java @@ -14,14 +14,11 @@ package org.eclipse.jst.ws.internal.consumption.ui.widgets.test; import java.util.List; import java.util.Vector; -import org.eclipse.core.resources.IProject; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; import org.eclipse.jst.ws.internal.context.ScenarioContext; import org.eclipse.jst.ws.internal.data.TypeRuntimeServer; import org.eclipse.jst.ws.internal.ext.test.WebServiceTestExtension; import org.eclipse.jst.ws.internal.ext.test.WebServiceTestRegistry; import org.eclipse.jst.ws.internal.plugin.WebServicePlugin; -import org.eclipse.wst.command.internal.provisional.env.core.Command; import org.eclipse.wst.command.internal.provisional.env.core.ICommandFactory; import org.eclipse.wst.command.internal.provisional.env.core.SimpleCommand; import org.eclipse.wst.command.internal.provisional.env.core.common.Environment; diff --git a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/CopyWebServiceUtilsJarCommand.java b/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/CopyWebServiceUtilsJarCommand.java index 7c8f82c75..708a27cb5 100644 --- a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/CopyWebServiceUtilsJarCommand.java +++ b/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/CopyWebServiceUtilsJarCommand.java @@ -37,11 +37,10 @@ import org.eclipse.wst.command.internal.provisional.env.core.context.TransientRe public class CopyWebServiceUtilsJarCommand extends SimpleCommand { private static java.lang.String DESCRIPTION = "Copy WebserviceUtils.jar"; - private static java.lang.String LABEL = "CopyWebserviceJarCommand"; - private String sampleProject; - private String sampleP; + private static java.lang.String LABEL = "CopyWebServiceUtilsJarCommand"; + private String sampleProject; private String sampleC; - private MessageUtils msgUtils; + private MessageUtils msgUtils; /** * Default CTOR; @@ -63,9 +62,8 @@ public Status execute(Environment env) try { env.getProgressMonitor().report( msgUtils.getMessage( "PROGRESS_INFO_COPY_WEBSERVICE_UTILS" ) ); - IProject sampleIProject = (IProject)ProjectUtilities.getProject(sampleProject); -// IPath webModulePath = ResourceUtils.getWebModuleServerRoot(sampleIProject).getFullPath(); - IPath webModulePath = J2EEUtils.getFirstWebContentPath(sampleIProject); + IProject sampleIProject = ProjectUtilities.getProject(sampleProject); + IPath webModulePath = J2EEUtils.getWebContentPath(sampleIProject, sampleC); if (webModulePath == null) return new SimpleStatus(WebServiceConsumptionUIPlugin.ID,msgUtils.getMessage("MSG_ERROR_PROJECT_NOT_FOUND"), Status.ERROR); @@ -133,6 +131,9 @@ public void setSampleProject(String sampleProject) this.sampleProject = sampleProject; } +public void setSampleComponent(String sampleComponent){ + this.sampleC = sampleComponent; +} } diff --git a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/wssample/GSTCGenerateCommand.java b/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/wssample/GSTCGenerateCommand.java index 9c1cd6a97..1ce5e1c52 100644 --- a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/wssample/GSTCGenerateCommand.java +++ b/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/test/wssample/GSTCGenerateCommand.java @@ -39,6 +39,7 @@ public class GSTCGenerateCommand extends SimpleCommand { Status status = new SimpleStatus( "" ); CopyWebServiceUtilsJarCommand copy = new CopyWebServiceUtilsJarCommand(); copy.setSampleProject(testInfo.getGenerationProject()); + copy.setSampleComponent(testInfo.getGenerationModule()); status = copy.execute(env); if (status.getSeverity() == Status.ERROR) return status; status = createModel(env); diff --git a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/wizard/ClientProjectTypeRegistry.java b/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/wizard/ClientProjectTypeRegistry.java index 3f298ffb5..daf6c46ef 100644 --- a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/wizard/ClientProjectTypeRegistry.java +++ b/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/wizard/ClientProjectTypeRegistry.java @@ -15,12 +15,13 @@ import java.util.StringTokenizer; import java.util.Vector; import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IExtensionRegistry; import org.eclipse.core.runtime.Platform; +import org.eclipse.jst.ws.internal.common.J2EEUtils; import org.eclipse.jst.ws.internal.common.ResourceUtils; +import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; public class ClientProjectTypeRegistry { @@ -86,13 +87,15 @@ public class ClientProjectTypeRegistry IConfigurationElement element = getElementById(id); if (element != null) { - IProject[] workspaceProjs = ResourcesPlugin.getWorkspace().getRoot().getProjects(); - for (int i = 0; i < workspaceProjs.length; i++) { - // TODO: Needs to be refactored to work with project/module topology described in XP + IProject[] workspaceProjs = ResourceUtils.getWorkspaceRoot().getProjects(); + IVirtualComponent[] comps = J2EEUtils.getAllComponents(); + for (int i = 0; i < comps.length; i++) { + // TODO: Needs to be refactored to work with project/module topology described in XP //if (include(workspaceProjs[i], element.getAttribute("include")) && exclude(workspaceProjs[i], element.getAttribute("exclude"))) - if (ResourceUtils.isWebProject(workspaceProjs[i]) || ResourceUtils.isEJBProject(workspaceProjs[i])) - { - v.add(workspaceProjs[i]); + // Note: Adding a project if the project contains a web or ejb module. + if (J2EEUtils.isWebComponent(comps[i].getProject(), comps[i].getName()) + || J2EEUtils.isEJBComponent(comps[i].getProject(), comps[i].getName())) { + v.add(comps[i].getProject()); } } } -- cgit v1.2.3