diff options
author | Rob Stryker | 2018-01-25 18:11:24 +0000 |
---|---|---|
committer | Rob Stryker | 2018-01-25 18:11:24 +0000 |
commit | 932502c1094bdefdc463690b2292589b72f0cae4 (patch) | |
tree | b958d9097b645946999f9b1f0e3eb33ad94d84b3 /bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/common | |
parent | a3b4f57ca16c1d8b05dd04e23e374ca080d2f2f1 (diff) | |
download | webtools.webservices-932502c1094bdefdc463690b2292589b72f0cae4.tar.gz webtools.webservices-932502c1094bdefdc463690b2292589b72f0cae4.tar.xz webtools.webservices-932502c1094bdefdc463690b2292589b72f0cae4.zip |
Move all files into core subdirectory
Signed-off-by: Rob Stryker <rob@oxbeef.net>
Diffstat (limited to 'bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/common')
12 files changed, 0 insertions, 2517 deletions
diff --git a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/common/DefaultingUtils.java b/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/common/DefaultingUtils.java deleted file mode 100644 index 92526e58f..000000000 --- a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/common/DefaultingUtils.java +++ /dev/null @@ -1,303 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2015 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * yyyymmdd bug Email and other contact information - * -------- -------- ----------------------------------------------------------- - * 20060427 138058 joan@ca.ibm.com - Joan Haggarty - * 20070723 194434 kathy@ca.ibm.com - Kathy Chan, Check for non-existing EAR with content not deleted - * 20150311 461526 jgwest@ca.ibm.com - Jonathan West, Allow OSGi bundles to be selected in the Wizard - *******************************************************************************/ -package org.eclipse.jst.ws.internal.consumption.ui.common; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IWorkspaceRoot; -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.IStatus; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -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 DefaultingUtils { - - // Immutable map - private static final Map<String /*template id*/, IWebServiceOSGISupportExtension> osgiExtensions; - - private static final String EXTENSION_POINT_WS_OSGI_SUPPORT = "webServiceOSGISupport"; - private static final String OSGI_SUPPORT_ELEMENT = "webServiceOSGISupport"; - private static final String OSGI_SUPPORT_CLASS_ATTR = "class"; - - private static final String OSGI_SUPPORT_TEMPLATES_ATTR = "applicableTemplates"; - - static { - - Map<String, IWebServiceOSGISupportExtension> result = new HashMap<String, IWebServiceOSGISupportExtension>(); - - try { - IExtensionRegistry reg = Platform.getExtensionRegistry(); - - IConfigurationElement[] wsImplExts = reg.getConfigurationElementsFor( - "org.eclipse.jst.ws.consumption.ui", EXTENSION_POINT_WS_OSGI_SUPPORT); - - for(int idx=0; idx<wsImplExts.length; idx++) - { - IConfigurationElement elem = wsImplExts[idx]; - if (elem.getName().equals(OSGI_SUPPORT_ELEMENT)) - { - try { - String applicableTemplatesStr = elem.getAttribute(OSGI_SUPPORT_TEMPLATES_ATTR); - if(applicableTemplatesStr != null) { - - IWebServiceOSGISupportExtension provider = (IWebServiceOSGISupportExtension) elem.createExecutableExtension(OSGI_SUPPORT_CLASS_ATTR); - - if(provider != null) { - // Split by all whitespace - String[] templates = applicableTemplatesStr.split("\\s+"); - for(String template : templates) { - result.put(template.toLowerCase(), provider); - } - } - } - - } catch (CoreException e) { - // Ignore issues with individual implementors - e.printStackTrace(); - } - - } - } - } finally { - osgiExtensions = Collections.unmodifiableMap(result); - } - - } - - public DefaultingUtils() - { - - } - - /** - * - * Uses the following steps to determine a valid default EAR project name: - * - * 1. If project does exist: - * a - look for an existing, referencing EAR component, if one exists return that EAR name - * b - look for an existing EAR component with the same J2EE version as the project - * 2. If can't find an appropriate existing EAR component or project does not exist in the - * workspace, return a new EAR name of form projectNameEAR - * 3. If project name is null or an empty string return the default EAR name - * - * @param projectName a string representing the name of the project for the service - * @return a string to be used as the default EAR project name for the project name provided - */ - public static String getDefaultEARProjectName(String projectName) - { - - if (projectName != null && projectName.length() > 0) { - - if(isOSGIProject(projectName)) - { - return getDefaultOSGIAppProjectName(projectName); - } - - IProject proj = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); - - if (proj.exists()) { - - //Step 1a - return a referencing EAR project - IVirtualComponent[] ears = J2EEUtils.getReferencingEARComponents(proj); - if (ears != null && ears.length > 0) { - return ears[0].getName(); - } - - //Step 1b - return an appropriate existing EAR project - IVirtualComponent[] allEarComps = J2EEUtils.getAllEARComponents(); - - if (allEarComps.length > 0) - { - for (int i=0; i < allEarComps.length; i++) - { - IProject earProject = allEarComps[i].getProject(); - boolean canAssociate = J2EEUtils.canAssociateProjectToEARWithoutWarning(proj, earProject); - if (canAssociate) - { - return allEarComps[i].getName(); - } - } - } - } - - - String baseEARName = projectName + ResourceUtils.getDefaultEARExtension(); - String earName = baseEARName; - - boolean foundEAR = false; - int i = 1; - - while (!foundEAR) { - // 194434 - Check for non-existing EAR with contents that's not deleted previously - IStatus canCreateEARStatus = J2EEUtils.canCreateEAR(ProjectUtilities.getProject(earName)); - if (canCreateEARStatus.isOK()) { - foundEAR = true; - } else { - earName = baseEARName + i; - i++; - } - } - - - //Step 2 - return project name with EAR on the end - return earName; - } - - //Step 3 - return the default EAR project name - return ResourceUtils.getDefaultServiceEARProjectName(); - } - - public static boolean isOSGITemplate(String name) - { - if(name == null) { return false; } - - try { - if(osgiExtensions == null) { return false; } - - for(String template : osgiExtensions.keySet()) - { - if(name.equalsIgnoreCase(template.trim())) - { - return true; - } - - } - - } catch(Exception e) - { - // Ignore; first, do no harm. - e.printStackTrace(); - } - - return false; - } - - private static IProject utilFindProjectWithName(String proj) - { - if(proj == null) - { - return null; - } - IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); - - IProject project = root.getProject(proj); - return project; - } - - public static boolean isOSGIProject(String proj) - { - try - { - IProject project = utilFindProjectWithName(proj); - if(project == null) - { - return false; - } else { - return isSupportedOSGIProject(project); - } - } catch(Exception e) - { - // First, do no harm. - e.printStackTrace(); - return false; - } - - } - - - - public static boolean isSupportedOSGIProject(IProject project) - { - try { - - if(osgiExtensions == null || project == null) { return false; } - - for(Map.Entry<String, IWebServiceOSGISupportExtension> entry : osgiExtensions.entrySet()) - { - - if(entry.getValue().isSupportedOSGIProject(project)) - { - return true; - } - - } - - return false; - - } catch(Exception e) { - // First, do no harm. - e.printStackTrace(); - return false; - } - - } - - /** Return the interface of the first extension that says it supports this project */ - private static IWebServiceOSGISupportExtension getFirstSupportedExtension(String projectName) - { - IProject proj = utilFindProjectWithName(projectName); - if(proj == null) { return null; } - - for(Map.Entry<String, IWebServiceOSGISupportExtension> entry : osgiExtensions.entrySet()) - { - - if(entry.getValue().isSupportedOSGIProject(proj)) - { - return entry.getValue(); - } - - } - - return null; - - } - - public static String getDefaultOSGIAppProjectName(String projectName) - { - try - { - if(osgiExtensions == null || projectName == null) { return null; } - - IWebServiceOSGISupportExtension ext = getFirstSupportedExtension(projectName); - - if(ext != null) - { - return ext.getDefaultOSGIAppProjectName(projectName); - } - - } catch(Exception e) - { - // First, do no harm. - e.printStackTrace(); - } - - - return projectName+".app"; - - } - - - -} diff --git a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/common/FacetOperationDelegate.java b/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/common/FacetOperationDelegate.java deleted file mode 100644 index 5abbc8cb6..000000000 --- a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/common/FacetOperationDelegate.java +++ /dev/null @@ -1,346 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * yyyymmdd bug Email and other contact information - * -------- -------- ----------------------------------------------------------- - * 20090303 242635 mahutch@ca.ibm.com - Mark Hutchinson, Remove unnecessary UI dependencies from org.eclipse.jst.ws.consumption - * 20090819 286874 zina@ca.ibm.com - Zina Mostafia - *******************************************************************************/ -package org.eclipse.jst.ws.internal.consumption.ui.common; - -import java.lang.reflect.InvocationTargetException; -import java.util.Collections; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -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.Status; -import org.eclipse.jdt.core.IClasspathEntry; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jst.ws.internal.common.J2EEUtils; -import org.eclipse.jst.ws.internal.consumption.ConsumptionMessages; -import org.eclipse.jst.ws.internal.consumption.common.FacetUtils; -import org.eclipse.jst.ws.internal.consumption.common.IFacetOperationDelegate; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.PlatformUI; -import org.eclipse.wst.command.internal.env.core.common.StatusUtils; -import org.eclipse.wst.common.project.facet.core.IFacetedProject; -import org.eclipse.wst.common.project.facet.core.IProjectFacet; -import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; -import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; -import org.eclipse.wst.common.project.facet.core.runtime.IRuntime; -import org.osgi.framework.Bundle; - -public class FacetOperationDelegate implements IFacetOperationDelegate { - - public IStatus addFacetsToProject(final IFacetedProject fproject, final Set projectFacetVersions) { - final IStatus[] status = new IStatus[1]; - status[0] = Status.OK_STATUS; - final Set actions = FacetUtils.getInstallActions(projectFacetVersions); - - // Create a runnable that applies the install actions to the faceted project - IRunnableWithProgress runnable = new IRunnableWithProgress() { - public void run(IProgressMonitor shellMonitor) throws InvocationTargetException, InterruptedException { - try { - fproject.modify(actions, shellMonitor); - fixEJBClassPath(fproject); - } catch (CoreException e) { - status[0] = getErrorStatusForAddingFacets(fproject.getProject().getName(), projectFacetVersions, e); - } - } - }; - - // Run the runnable in another thread unless there is no UI thread (Ant scenarios) - if (displayPresent()) { - try { - PlatformUI.getWorkbench().getProgressService().run(true, false, runnable); - } catch (InvocationTargetException ite) { - status[0] = getErrorStatusForAddingFacets(fproject.getProject().getName(), projectFacetVersions, ite); - } catch (InterruptedException ie) { - status[0] = getErrorStatusForAddingFacets(fproject.getProject().getName(), projectFacetVersions, ie); - } - } else { - try { - fproject.modify(actions, null); - fixEJBClassPath(fproject); - } catch (CoreException e) { - status[0] = getErrorStatusForAddingFacets(fproject.getProject().getName(), projectFacetVersions, e); - } - } - - return status[0]; - } - - private void fixEJBClassPath(IFacetedProject project) { - if (!J2EEUtils.isEJBComponent(project.getProject())) return; - IProject ejbProject = project.getProject(); - IJavaProject javaProject = JavaCore.create(ejbProject); - Path projectRoot = new Path(Path.ROOT.append(new Path(ejbProject.getName())).toString()); - IPath ejbModulePath = projectRoot.append("ejbModule"); - try { - IClasspathEntry[] originalSet = javaProject.getRawClasspath(); - boolean foundEJBModulEntry = false; - for (IClasspathEntry entry : originalSet) { - if (entry.getPath().equals(ejbModulePath)) - foundEJBModulEntry = true; - } - if (!foundEJBModulEntry) { - IClasspathEntry[] newSet = new IClasspathEntry[originalSet.length + 1]; - int i=0; - - for (IClasspathEntry entry : originalSet) { - newSet[i++] = entry; - } - newSet[i] = JavaCore.newSourceEntry(ejbModulePath); - javaProject.setRawClasspath(newSet,null); - } - } - catch (Exception e) { - // TODO: handle exception - } - - } - - public IStatus createNewFacetedProject(final String projectName) { - final IStatus[] status = new IStatus[1]; - status[0] = Status.OK_STATUS; - IProject project = ProjectUtilities.getProject(projectName); - if (!project.exists()) { - // Create a runnable that creates a new faceted project. - IRunnableWithProgress runnable = new IRunnableWithProgress() { - public void run(IProgressMonitor shellMonitor) throws InvocationTargetException, InterruptedException { - try { - IFacetedProject fProject = ProjectFacetsManager.create(projectName, null, shellMonitor); - if (fProject == null) { - status[0] = StatusUtils.errorStatus(NLS.bind(ConsumptionMessages.MSG_ERROR_PROJECT_CREATION, new String[] { projectName })); - } - } catch (CoreException e) { - status[0] = StatusUtils.errorStatus(NLS.bind(ConsumptionMessages.MSG_ERROR_PROJECT_CREATION, new String[] { projectName }), e); - } - } - }; - - // Run the runnable in another thread unless there is no UI thread (Ant scenarios) - try { - if (displayPresent()) { - PlatformUI.getWorkbench().getProgressService().run(true, false, runnable); - } else { - try { - IFacetedProject fProject = ProjectFacetsManager.create(projectName, null, null); - if (fProject == null) { - status[0] = StatusUtils.errorStatus(NLS.bind(ConsumptionMessages.MSG_ERROR_PROJECT_CREATION, new String[] { projectName })); - } - } catch (CoreException e) { - status[0] = StatusUtils.errorStatus(NLS.bind(ConsumptionMessages.MSG_ERROR_PROJECT_CREATION, new String[] { projectName }), e); - } - } - } catch (InvocationTargetException ite) { - status[0] = StatusUtils.errorStatus(NLS.bind(ConsumptionMessages.MSG_ERROR_PROJECT_CREATION, new String[] { projectName }), ite); - } catch (InterruptedException ie) { - status[0] = StatusUtils.errorStatus(NLS.bind(ConsumptionMessages.MSG_ERROR_PROJECT_CREATION, new String[] { projectName }), ie); - } - } - - return status[0]; - } - - public IStatus setFacetRuntimeOnProject(final IFacetedProject fProject, final IRuntime fRuntime) { - final IStatus[] status = new IStatus[1]; - status[0] = Status.OK_STATUS; - - // Create a runnable that sets the facet runtime on the faceted project - IRunnableWithProgress runnable = new IRunnableWithProgress() { - public void run(IProgressMonitor shellMonitor) throws InvocationTargetException, InterruptedException { - try { - fProject.setTargetedRuntimes(Collections.singleton(fRuntime), shellMonitor); - } catch (CoreException e) { - status[0] = StatusUtils.errorStatus(NLS.bind(ConsumptionMessages.MSG_ERROR_SETTING_RUNTIME, new String[] { fProject.getProject().getName(), fRuntime.getName() }), e); - } - } - }; - - // Run the runnable in another thread unless there is no UI thread (Ant scenarios) - if (displayPresent()) { - try { - PlatformUI.getWorkbench().getProgressService().run(true, false, runnable); - } catch (InvocationTargetException ite) { - status[0] = StatusUtils.errorStatus(NLS.bind(ConsumptionMessages.MSG_ERROR_SETTING_RUNTIME, new String[] { fProject.getProject().getName(), fRuntime.getName() }), ite); - } catch (InterruptedException ie) { - status[0] = StatusUtils.errorStatus(NLS.bind(ConsumptionMessages.MSG_ERROR_SETTING_RUNTIME, new String[] { fProject.getProject().getName(), fRuntime.getName() }), ie); - } - } else { - try { - fProject.setTargetedRuntimes(Collections.singleton(fRuntime), null); - - } catch (CoreException e) { - status[0] = StatusUtils.errorStatus(NLS.bind(ConsumptionMessages.MSG_ERROR_SETTING_RUNTIME, new String[] { fProject.getProject().getName(), fRuntime.getName() }), e); - } - } - - return status[0]; - } - - public IStatus setFixedFacetsOnProject(final IFacetedProject fProject, final Set fixedFacets) { - final IStatus[] status = new IStatus[1]; - status[0] = Status.OK_STATUS; - - // Create a runnable that sets the fixed facets on the faceted project - IRunnableWithProgress runnable = new IRunnableWithProgress() { - public void run(IProgressMonitor shellMonitor) throws InvocationTargetException, InterruptedException { - try { - fProject.setFixedProjectFacets(fixedFacets); - } catch (CoreException e) { - status[0] = getErrorStatusForSettingFixedFacets(fProject.getProject().getName(), fixedFacets, e); - } - } - }; - - // Run the runnable in another thread unless there is no UI thread (Ant scenarios) - if (displayPresent()) { - try { - PlatformUI.getWorkbench().getProgressService().run(true, false, runnable); - } catch (InvocationTargetException ite) { - status[0] = getErrorStatusForSettingFixedFacets(fProject.getProject().getName(), fixedFacets, ite); - } catch (InterruptedException ie) { - status[0] = getErrorStatusForSettingFixedFacets(fProject.getProject().getName(), fixedFacets, ie); - } - } else { - try { - fProject.setFixedProjectFacets(fixedFacets); - } catch (CoreException e) { - status[0] = getErrorStatusForSettingFixedFacets(fProject.getProject().getName(), fixedFacets, e); - } - } - - return status[0]; - } - - // Check to see if SWT is active and the Display is present or not - private static boolean displayPresent() { - Bundle b = Platform.getBundle("org.eclipse.swt"); - if (b == null) { - return false; - } - if ((b.getState() != Bundle.RESOLVED && b.getState() != Bundle.ACTIVE)) { - return false; - } - try { - if (Display.getCurrent() == null) { - return false; - } else { - return true; - } - } catch (NoClassDefFoundError e1) { - return false; - } catch (Exception e) { - // if the Display class cannot be loaded for whatever reason - return false; - - } - } - - // the following private methods had to be copied from FacetUtils - /** - * Returns a translatable delimited list of facet labels derived from the - * provided set of facets - * - * @param facets - * a set containing elements of type {@link IProjectFacet} - * @return String a delimited list of facet labels - */ - private static String getFacetListMessageString(Set facets) { - String facetListMessage = ""; - int size = facets.size(); - if (size > 0) { - Iterator itr = facets.iterator(); - IProjectFacet firstProjectFacet = (IProjectFacet) itr.next(); - facetListMessage = firstProjectFacet.getLabel(); - - // Continue appending to facetListMessage until all the facet labels - // are in the list. - while (itr.hasNext()) { - IProjectFacet projectFacet = (IProjectFacet) itr.next(); - String pfLabel = projectFacet.getLabel(); - facetListMessage = NLS.bind(ConsumptionMessages.MSG_FACETS, new String[] { facetListMessage, pfLabel }); - } - } - - return facetListMessage; - } - - /** - * Returns an error status indicating that the facets could not be set as - * fixed facets on the faceted project - * - * @param projectName - * a project name to insert in the error message in the IStatus - * @param facets - * a set containing elements of type {@link IProjectFacet}. The - * facets in this set will be listed in the error message in the - * IStatus. - * @param t - * a Throwable which will be inserted in the IStatus - * @return an IStatus with severity IStatus.ERROR - */ - private static IStatus getErrorStatusForSettingFixedFacets(String projectName, Set facets, Throwable t) { - IStatus status = Status.OK_STATUS; - int size = facets.size(); - if (size > 0) { - String facetList = getFacetListMessageString(facets); - status = StatusUtils.errorStatus(NLS.bind(ConsumptionMessages.MSG_ERROR_FIXED_FACETS, new String[] { projectName, facetList }), t); - } - - return status; - } - - /** - * Returns an error status indicating that the facet versions could not be - * added to the faceted project - * - * @param projectName - * a project name to insert in the error message in the IStatus - * @param projectFacetVersions - * a set containing elements of type {@link IProjectFacetVersion} - * . The facets in this set will be listed in the error message - * in the IStatus. - * @param t - * a Throwable which will be inserted in the IStatus - * @return an IStatus with severity IStatus.ERROR - */ - private static IStatus getErrorStatusForAddingFacets(String projectName, Set projectFacetVersions, Throwable t) { - IStatus status = Status.OK_STATUS; - int size = projectFacetVersions.size(); - if (size > 0) { - Set facets = new HashSet(); - // Iterate over projectFacetVersions to form a set of IProjectFacets - Iterator itr = projectFacetVersions.iterator(); - while (itr.hasNext()) { - IProjectFacetVersion projectFacet = (IProjectFacetVersion) itr.next(); - IProjectFacet facet = projectFacet.getProjectFacet(); - facets.add(facet); - } - String facetList = getFacetListMessageString(facets); - status = StatusUtils.errorStatus(NLS.bind(ConsumptionMessages.MSG_ERROR_ADDING_FACETS_TO_PROJECT, new String[] { projectName, facetList }), t); - } - - return status; - } - -} diff --git a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/common/FinishFragment.java b/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/common/FinishFragment.java deleted file mode 100644 index cd8e70962..000000000 --- a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/common/FinishFragment.java +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - * Created on May 4, 2004 - * - * TODO To change the template for this generated file go to - * Window - Preferences - Java - Code Style - Code Templates - */ -package org.eclipse.jst.ws.internal.consumption.ui.common; - -import org.eclipse.jst.ws.internal.consumption.ui.widgets.test.FinishTestFragment; -import org.eclipse.wst.command.internal.env.core.fragment.SequenceFragment; - - -/** - * @author gilberta - * - * TODO To change the template for this generated type comment go to - * Window - Preferences - Java - Code Style - Code Templates - */ -public class FinishFragment extends SequenceFragment -{ - public FinishFragment() - { - add(new FinishTestFragment() ); - } -} diff --git a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/common/HandlerDescriptionHelper.java b/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/common/HandlerDescriptionHelper.java deleted file mode 100644 index de63bbbec..000000000 --- a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/common/HandlerDescriptionHelper.java +++ /dev/null @@ -1,67 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * yyyymmdd bug Email and other contact information - * 20060404 134913 sengpl@ca.ibm.com - Seng Phung-Lu - * -------- -------- ----------------------------------------------------------- - */ -package org.eclipse.jst.ws.internal.consumption.ui.common; - -import java.util.List; -import java.util.Vector; - -import org.eclipse.jst.ws.internal.consumption.ui.widgets.object.HandlerTableItem; - - - -public class HandlerDescriptionHelper { - - /** - * Helper method for getting the HandlerDescriptorHolder given the name - * @param hdhs - * @param descName - * @return - */ - public static HandlerDescriptionHolder getForDescriptionName(HandlerDescriptionHolder[] hdhs, String descName){ - for (int i=0;i<hdhs.length;i++){ - String name = hdhs[i].getDescriptionName(); - if (name!=null && name.equals(descName)){ - return hdhs[i]; - } - } - return null; - } - - /** - * Helper method for getting all description names - * @param hdhs - * @return - */ - public static String[] getAllDescriptionNames(HandlerDescriptionHolder[] hdhs){ - String[] names = new String[hdhs.length]; - for(int i=0;i<hdhs.length;i++){ - names[i]=hdhs[i].getDescriptionName(); - } - return names; - } - - public static String[] getAllHandlerClassNames(HandlerDescriptionHolder[] hdhs){ - Vector v = new Vector(); - for (int i=0;i<hdhs.length;i++){ - List list = hdhs[i].getHandlerList(); - if (list!=null && !list.isEmpty()){ - for (int j=0;j<list.size();j++){ - HandlerTableItem hti = (HandlerTableItem)list.get(j); - v.add(hti.getHandlerClassName()); - } - } - } - return (String[])v.toArray(new String[0]); - } -} diff --git a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/common/HandlerDescriptionHolder.java b/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/common/HandlerDescriptionHolder.java deleted file mode 100644 index 00cbadde2..000000000 --- a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/common/HandlerDescriptionHolder.java +++ /dev/null @@ -1,137 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * yyyymmdd bug Email and other contact information - * -------- -------- ----------------------------------------------------------- - * 20060404 134913 sengpl@ca.ibm.com - Seng Phung-Lu - * 20060518 142554 sengpl@ca.ibm.com - Seng Phung-Lu - *******************************************************************************/ -package org.eclipse.jst.ws.internal.consumption.ui.common; - -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IPath; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.jst.j2ee.webservice.wsdd.Handler; -import org.eclipse.jst.j2ee.webservice.wsdd.PortComponent; -import org.eclipse.jst.j2ee.webservice.wsdd.WebServiceDescription; -import org.eclipse.jst.j2ee.webservice.wsdd.WsddFactory; -import org.eclipse.jst.j2ee.webservice.wsdd.internal.impl.WsddFactoryImpl; -import org.eclipse.jst.ws.internal.consumption.ui.widgets.object.HandlerTableItem; - - -public class HandlerDescriptionHolder { - - private String descriptionName; - private List handlerList; - private WebServiceDescription descriptionObject; - private IPath sourceOutputPath; - - - public IPath getSourceOutputPath() { - return sourceOutputPath; - } - - public void setSourceOutputPath(IPath sourceOutputPath) { - this.sourceOutputPath = sourceOutputPath; - } - - public IProject getProject(){ - if (descriptionObject!=null) - return ProjectUtilities.getProject(descriptionObject); - else - return null; - } - - /* - * get the WebServiceDescription object - */ - public WebServiceDescription getDescriptionObject() { - return descriptionObject; - } - - /** - * set WebServiceDescription object - * @param descriptionObject - */ - public void setDescriptionObject(WebServiceDescription descriptionObject) { - this.descriptionObject = descriptionObject; - } - - /** - * get Description name - * @return - */ - public String getDescriptionName() { - return descriptionName; - } - - /** - * set Description name - * @param descriptionName - */ - public void setDescriptionName(String descriptionName) { - this.descriptionName = descriptionName; - } - - /** - * get List of HandlerTableItem associated with this service description - * @return - */ - public List getHandlerList() { - return handlerList; - } - - /** - * set List of HandlerTableItem associated with this service description - * @param handlerList - */ - public void setHandlerList(List handlerList) { - this.handlerList = handlerList; - } - - public void addHandlerToAllPorts(){ - - if (handlerList!=null && !handlerList.isEmpty()){ - - for (int z=0;z<handlerList.size();z++){ - HandlerTableItem hti = (HandlerTableItem)handlerList.get(z); - if (descriptionObject!=null) { - List portComponents = descriptionObject.getPortComponents(); - for (int x=0;x<portComponents.size();x++){ - PortComponent wsPort = (PortComponent) portComponents.get(x); - List wsHandlers = wsPort.getHandlers(); - if (wsHandlers!=null){ - boolean alreadyExists = false; - for (int y=0;y<wsHandlers.size();y++){ - Handler handler = (Handler)wsHandlers.get(y); - if (handler.getHandlerClass().equals(hti.getHandlerClassName())){ - alreadyExists = true; - } - } - - if (!alreadyExists) { - //create it and add to the list - WsddFactory wsddFactory = new WsddFactoryImpl(); - Handler newHandler = wsddFactory.createHandler(); - newHandler.setHandlerName(hti.getHandlerName()); - newHandler.setHandlerClass(hti.getHandlerClassName()); - wsHandlers.add(newHandler); - } - } - } - } - } - } - - } - - -} diff --git a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/common/HandlerServiceRefHelper.java b/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/common/HandlerServiceRefHelper.java deleted file mode 100644 index 3daff3bfd..000000000 --- a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/common/HandlerServiceRefHelper.java +++ /dev/null @@ -1,72 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * yyyymmdd bug Email and other contact information - * 20060404 134913 sengpl@ca.ibm.com - Seng Phung-Lu - * -------- -------- ----------------------------------------------------------- - */ -package org.eclipse.jst.ws.internal.consumption.ui.common; - -import java.util.List; -import java.util.Vector; - -import org.eclipse.jst.ws.internal.consumption.ui.widgets.object.HandlerTableItem; - - -public class HandlerServiceRefHelper { - - /** - * Helper method for getting the HandlerServiceRefHolder given the name - * @param hsrh - * @param descName - * @return - */ - public static HandlerServiceRefHolder getForServiceRefName(HandlerServiceRefHolder[] hsrh, String descName){ - for (int i=0;i<hsrh.length;i++){ - String name = hsrh[i].getServiceRefName(); - if (name!=null && name.equals(descName)){ - return hsrh[i]; - } - } - return null; - } - - /** - * Gets all the handler Class names associated with each service ref - * @param hsrh - * @return - */ - public static String[] getAllHandlerClassNames(HandlerServiceRefHolder[] hsrh){ - Vector v = new Vector(); - for (int i=0;i<hsrh.length;i++){ - List list = hsrh[i].getHandlerList(); - if (list!=null && !list.isEmpty()){ - for (int j=0;j<list.size();j++){ - HandlerTableItem hti = (HandlerTableItem)list.get(j); - v.add(hti.getHandlerClassName()); - } - } - } - return (String[])v.toArray(new String[0]); - } - - /** - * Get all the service Ref names - * @param hsrh - * @return - */ - public static String[] getAllServiceRefNames(HandlerServiceRefHolder[] hsrh){ - String[] names = new String[hsrh.length]; - for(int i=0;i<hsrh.length;i++){ - names[i]=hsrh[i].getServiceRefName(); - } - return names; - } - -} diff --git a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/common/HandlerServiceRefHolder.java b/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/common/HandlerServiceRefHolder.java deleted file mode 100644 index b1b004bdf..000000000 --- a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/common/HandlerServiceRefHolder.java +++ /dev/null @@ -1,118 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * yyyymmdd bug Email and other contact information - * -------- -------- ----------------------------------------------------------- - * 20060404 134913sengpl@ca.ibm.com - Seng Phung-Lu - * 20060517 142339 sengpl@ca.ibm.com - Seng Phung-Lu - *******************************************************************************/ -package org.eclipse.jst.ws.internal.consumption.ui.common; - -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IPath; -import org.eclipse.jem.java.JavaClass; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.jst.j2ee.webservice.wsclient.Handler; -import org.eclipse.jst.j2ee.webservice.wsclient.ServiceRef; -import org.eclipse.jst.j2ee.webservice.wsclient.Webservice_clientFactory; -import org.eclipse.jst.j2ee.webservice.wsclient.internal.impl.Webservice_clientFactoryImpl; -import org.eclipse.jst.ws.internal.common.JavaMOFUtils; -import org.eclipse.jst.ws.internal.consumption.ui.widgets.object.HandlerTableItem; - - -public class HandlerServiceRefHolder { - - private String serviceRefName; - private List handlerList; - private ServiceRef serviceRef; - private IPath sourceOutputPath; - - public IPath getSourceOutputPath() { - return sourceOutputPath; - } - - public void setSourceOutputPath(IPath sourceOutputPath) { - this.sourceOutputPath = sourceOutputPath; - } - - public IProject getProject() { - if (serviceRef!=null) - return ProjectUtilities.getProject(serviceRef); - else - return null; - } - - public List getHandlerList() { - return handlerList; - } - - public void setHandlerList(List handlerList) { - this.handlerList = handlerList; - } - - public ServiceRef getServiceRef() { - return serviceRef; - } - - public void setServiceRef(ServiceRef serviceRef) { - this.serviceRef = serviceRef; - } - - public String getServiceRefName() { - return serviceRefName; - } - - public void setServiceRefName(String serviceRefName) { - this.serviceRefName = serviceRefName; - } - - public void addHandlerToServiceRef(){ - if (handlerList!=null && !handlerList.isEmpty()){ - - for (int x=0;x<handlerList.size();x++){ - HandlerTableItem hti = (HandlerTableItem)handlerList.get(x); - if (serviceRef!=null){ - List existingHandlers = serviceRef.getHandlers(); - boolean alreadyExists = false; - for (int i=0;i<existingHandlers.size();i++){ - Handler handler = (Handler)existingHandlers.get(i); - if (handler.getHandlerClass().getJavaName().equals(hti.getHandlerClassName())){ - alreadyExists = true; - } - } - - if (!alreadyExists) { - - Webservice_clientFactory wsClientFactory = new Webservice_clientFactoryImpl(); - Handler newHandler = wsClientFactory.createHandler(); - newHandler.setHandlerName(hti.getHandlerName()); - try { - IProject project = ProjectUtilities.getProject(serviceRef); - if (project!=null) { - JavaClass javaClass = JavaMOFUtils.getJavaClass(hti.getHandlerClassName(), project); - if (javaClass != null) { - newHandler.setHandlerClass(javaClass); - } - existingHandlers.add(newHandler); - } - } - catch(Exception e){ - e.printStackTrace(); - } - } - - } - - } - } - } - -} diff --git a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/common/IWebServiceOSGISupportExtension.java b/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/common/IWebServiceOSGISupportExtension.java deleted file mode 100644 index 61f9e53cf..000000000 --- a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/common/IWebServiceOSGISupportExtension.java +++ /dev/null @@ -1,34 +0,0 @@ -/*******************************************************************************
- * Copyright (c) 2015 IBM Corporation and others
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- */
-package org.eclipse.jst.ws.internal.consumption.ui.common;
-
-import org.eclipse.core.resources.IProject;
-
-/*
- * Implementing consumers may consume the webServiceOSGISupport extension point, in order to allow OSGi bundles and applications to be supported by the Web Services Wizard.
- *
- * Implementing the extension point and this interface will alter the Web Service wizard language from EAR to OSGi when an OSGi supported project is detected.
- * Likewise, the value of the OSGi App field will be stored in ServiceOsgiAppProjectName, rather than in ServiceEarProjectName.
- */
-
-public interface IWebServiceOSGISupportExtension {
-
- /**
- * Return the default name of a composite OSGi app, given a bundle
- * 'projectName', for example, MyWebProj would return MyWebProj.app; this is
- * similar to DefaultingUtils.getDefaultEARProjectName(...)
- */
- public String getDefaultOSGIAppProjectName(String projectName);
-
- /**
- * Whether or not a given project is an OSGi project that is supported by
- * this consuming extension.
- */
- public boolean isSupportedOSGIProject(IProject project);
-
-}
diff --git a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/common/LabelsAndIds.java b/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/common/LabelsAndIds.java deleted file mode 100644 index a4a6016e5..000000000 --- a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/common/LabelsAndIds.java +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * yyyymmdd bug Email and other contact information - * -------- -------- ----------------------------------------------------------- - * 20080221 146023 gilberta@ca.ibm.com - Gilbert Andrews - * 20080425 221232 gilberta@ca.ibm.com - Gilbert Andrews - * 20080616 237298 gilberta@ca.ibm.com - Gilbert Andrews - * 20080619 237797 gilberta@ca.ibm.com - Gilbert Andrews - *******************************************************************************/ -/** - */ -package org.eclipse.jst.ws.internal.consumption.ui.common; - -import java.util.Vector; - -public class LabelsAndIds -{ - private Vector labels_ = new Vector(); - private Vector ids_ = new Vector(); - - - public void add(String id, String label){ - ids_.add(id); - labels_.add(label); - } - - public int size(){ - return labels_.size(); - } - - public String getId(int index){ - if (index < 0 || index + 1 > ids_.size()) return null; - return (String)ids_.get(index); - } - - public void clear(){ - labels_.clear(); - ids_.clear(); - } - - /** - * @return Returns the ids_. - */ - public String[] getIds() - { - String[] stringArray = new String[ids_.size()]; - ids_.copyInto(stringArray); - return stringArray; - } - - public String[] getLabels() - { - String[] stringArray = new String[ids_.size()]; - labels_.copyInto(stringArray); - return stringArray; - } - -} diff --git a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/common/ScenarioCleanupCommand.java b/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/common/ScenarioCleanupCommand.java deleted file mode 100644 index a9b44f6b5..000000000 --- a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/common/ScenarioCleanupCommand.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * yyyymmdd bug Email and other contact information - * -------- -------- ----------------------------------------------------------- - * 20060825 155114 pmoogk@ca.ibm.com - Peter Moogk - *******************************************************************************/ - -package org.eclipse.jst.ws.internal.consumption.ui.common; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jst.ws.internal.consumption.common.WSDLParserFactory; -import org.eclipse.jst.ws.internal.consumption.ui.widgets.object.ObjectSelectionRegistry; -import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation; - -/** - * This command is intended to clean up data after either the - * client or service wizards. Currently is just resets the - * parser factory. - * - */ -public class ScenarioCleanupCommand extends AbstractDataModelOperation -{ - - public IStatus execute( IProgressMonitor monitor, IAdaptable adaptable ) - { - WSDLParserFactory.killParser(); - ObjectSelectionRegistry.getInstance().cleanup(); - - return Status.OK_STATUS; - } - - - public IStatus undo( IProgressMonitor monitor, IAdaptable adaptable ) - { - // Even if the user cancels out of the wizard we want to - // kill the parser. - WSDLParserFactory.killParser(); - ObjectSelectionRegistry.getInstance().cleanup(); - - return Status.OK_STATUS; - } -} diff --git a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/common/ServerSelectionUtils.java b/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/common/ServerSelectionUtils.java deleted file mode 100644 index 2adfab0b8..000000000 --- a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/common/ServerSelectionUtils.java +++ /dev/null @@ -1,133 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * yyyymmdd bug Email and other contact information - * -------- -------- ----------------------------------------------------------- - * 20060324 116750 rsinha@ca.ibm.com - Rupam Kuehner - * 20070119 159458 mahutch@ca.ibm.com - Mark Hutchinson - *******************************************************************************/ - -package org.eclipse.jst.ws.internal.consumption.ui.common; - -import java.util.ArrayList; - -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.consumption.common.IServerDefaulter; -import org.eclipse.jst.ws.internal.consumption.common.ServerInfo; -import org.eclipse.wst.server.core.IRuntime; -import org.eclipse.wst.server.core.IRuntimeType; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.core.ServerCore; - - -public class ServerSelectionUtils -{ - - public static IRuntime getRuntimeTarget(String projectName) - { - if( projectName != null && projectName.length() > 0 ){ //$NON-NLS-1$ - IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); - if( project != null && project.exists() ){ - return ServerCore.getProjectProperties(project).getRuntimeTarget(); - } - } - return null; - } - - public static IServer getFirstExistingServerFromFactoryId(String factoryId) - { - IServer[] servers = ServerCore.getServers(); - if (servers==null || servers.length!=0) - return null; - else - { - for (int i=0; i<servers.length; i++) - { - IServer server = (IServer)servers[i]; - if (server.getServerType().getId().equals(factoryId)) - { - return server; - } - } - } - return null; - } - - public static IServer[] getCompatibleExistingServers(IRuntime runtime) - { - if (runtime == null) - return null; - - IServer[] servers = ServerCore.getServers(); - if (servers==null || servers.length==0) - return null; - - ArrayList compatibleServersList = new ArrayList(); - IRuntimeType runtimeType = runtime.getRuntimeType(); - if (runtimeType != null) - { - String runtimeId = runtimeType.getId(); - for (int i=0; i<servers.length; i++) - { - IServer server = (IServer)servers[i]; - IRuntimeType runtimeType2 = server.getRuntime().getRuntimeType(); - if (runtimeType2 != null) - { - String serverRuntimeId = runtimeType2.getId(); - if (serverRuntimeId.equals(runtimeId)) - compatibleServersList.add(server); - } - - } - } - if (compatibleServersList.size()<1) - return null; - - - Object[] compatibleServersArray = compatibleServersList.toArray(); - IServer[] compatibleServers = new IServer[compatibleServersArray.length]; - for (int j=0; j<compatibleServersArray.length; j++) - { - compatibleServers[j] = (IServer)compatibleServersArray[j]; - } - - return compatibleServers; - } - - public static ServerInfo getExtenderRecommendation(IProject project) - { - try - { - IExtensionRegistry reg = Platform.getExtensionRegistry(); - IConfigurationElement[] elements = reg.getConfigurationElementsFor("org.eclipse.jst.ws.consumption", "serverDefaulter"); - for (int i=0; i<elements.length; i++) - { - Object serverDefaulterObject = elements[i].createExecutableExtension("class"); - if (serverDefaulterObject instanceof IServerDefaulter) - { - IServerDefaulter serverDefaulter = (IServerDefaulter)serverDefaulterObject; - ServerInfo serverInfo = serverDefaulter.recommendDefaultServer(project); - if (serverInfo != null) - return serverInfo; - } - - } - } catch (CoreException ce) - { - return null; - } - - return null; - } -} 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 deleted file mode 100644 index 7306baf18..000000000 --- a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/common/ValidationUtils.java +++ /dev/null @@ -1,1155 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2013 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * yyyymmdd bug Email and other contact information - * -------- -------- ----------------------------------------------------------- - * 20060222 115834 rsinha@ca.ibm.com - Rupam Kuehner - * 20060413 135581 rsinha@ca.ibm.com - Rupam Kuehner - * 20060420 136158 rsinha@ca.ibm.com - Rupam Kuehner - * 20060420 136705 rsinha@ca.ibm.com - Rupam Kuehner - * 20060421 136761 rsinha@ca.ibm.com - Rupam Kuehner - * 20060425 137831 rsinha@ca.ibm.com - Rupam Kuehner - * 20060427 126780 rsinha@ca.ibm.com - Rupam Kuehner - * 20060427 138058 joan@ca.ibm.com - Joan Haggarty - * 20060905 156230 kathy@ca.ibm.com - Kathy Chan, Handling projects with no target runtime - * 20070119 159458 mahutch@ca.ibm.com - Mark Hutchinson - * 20070723 194434 kathy@ca.ibm.com - Kathy Chan, Check for non-existing EAR with content not deleted - * 20071107 203826 kathy@ca.ibm.com - Kathy Chan - * 20071130 203826 kathy@ca.ibm.com - Kathy Chan - * 20080205 170141 kathy@ca.ibm.com - Kathy Chan - * 20080416 215084 gilberta@ca.ibm.com - Gilbert Andrews - * 20080417 227599 kathy@ca.ibm.com - Kathy Chan - * 20080717 241283 ericdp@ca.ibm.com - Eric D. Peters, Class version error when invoking sample JSP on Tomcat 5.5 when Java project is Java 6 - * 20081001 243869 ericdp@ca.ibm.com - Eric D. Peters, Web Service tools allowing mixed J2EE levels - * 20090121 261730 zhang@ca.ibm.com - Allan Zhang, WebService client runtime id return null - * 20090302 249602 ericdp@ca.ibm.com - Eric D. Peters, PII- association warning message needs update - * 20090401 269994 ericdp@ca.ibm.com - Eric D. Peters, NLS- Validation messages unclear when servers don't support runtime/project combo - * 20100511 309395 mahutch@ca.ibm.com - Mark Hutchinson, WS Wizard Converting Java Project into Utility Project without any warning - * 20101207 332067 mahutch@ca.ibm.com - Mark Hutchinson, Consider server in web service wizard validation - *******************************************************************************/ -package org.eclipse.jst.ws.internal.consumption.ui.common; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.wsdl.Definition; -import javax.wsdl.Port; -import javax.wsdl.Service; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.jem.util.emf.workbench.WorkbenchResourceHelperBase; -import org.eclipse.jst.common.project.facet.JavaFacetUtils; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; -import org.eclipse.jst.j2ee.project.JavaEEProjectUtilities; -import org.eclipse.jst.j2ee.webservice.internal.WebServiceConstants; -import org.eclipse.jst.j2ee.webservice.wsdd.PortComponent; -import org.eclipse.jst.j2ee.webservice.wsdd.WSDLPort; -import org.eclipse.jst.j2ee.webservice.wsdd.WebServiceDescription; -import org.eclipse.jst.j2ee.webservice.wsdd.WebServices; -import org.eclipse.jst.j2ee.webservice.wsdd.WsddResource; -import org.eclipse.jst.server.core.FacetUtil; -import org.eclipse.jst.ws.internal.common.J2EEUtils; -import org.eclipse.jst.ws.internal.common.ResourceUtils; -import org.eclipse.jst.ws.internal.common.ServerUtils; -import org.eclipse.jst.ws.internal.consumption.common.FacetUtils; -import org.eclipse.jst.ws.internal.consumption.ui.ConsumptionUIMessages; -import org.eclipse.jst.ws.internal.consumption.ui.wsrt.RuntimeDescriptor; -import org.eclipse.jst.ws.internal.consumption.ui.wsrt.WebServiceRuntimeExtensionUtils2; -import org.eclipse.jst.ws.internal.context.ScenarioContext; -import org.eclipse.jst.ws.internal.data.TypeRuntimeServer; -import org.eclipse.osgi.util.NLS; -import org.eclipse.wst.command.internal.env.core.common.StatusUtils; -import org.eclipse.wst.command.internal.env.core.selection.SelectionListChoices; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.project.facet.core.IFacetedProjectTemplate; -import org.eclipse.wst.common.project.facet.core.IProjectFacet; -import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; -import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; -import org.eclipse.wst.common.project.facet.core.VersionFormatException; -import org.eclipse.wst.common.project.facet.core.internal.ProjectFacetVersion; -import org.eclipse.wst.server.core.IRuntime; -import org.eclipse.wst.server.core.IRuntimeType; -import org.eclipse.wst.server.core.IServerType; -import org.eclipse.wst.server.core.ServerCore; -import org.eclipse.wst.ws.internal.parser.wsil.WebServicesParser; -import org.eclipse.wst.ws.internal.wsrt.IWebServiceRuntimeChecker; -import org.eclipse.wst.ws.internal.wsrt.WebServiceScenario; - -/** - * - */ -public class ValidationUtils -{ - //Constants to help decide how much validation to do. - public static final int VALIDATE_NONE = 0; - public static final int VALIDATE_ALL = 1; - public static final int VALIDATE_SERVER_RUNTIME_CHANGES = 2; - public static final int VALIDATE_PROJECT_CHANGES = 3; - public static final int VALIDATE_SCALE_CHANGES = 4; - - /** - * - */ - public ValidationUtils() - { - } - - /** - * Returns a new validation state based on the current validation state - * and the requested validation state. If the requested validation state - * does not cover all the validation covered by the current validation - * state, VALIDATE_ALL is returned. Otherwise, the requested validation - * state is returned. - * - * @param currentValidationState the validaton state at the time the caller's requests a change - * @param requestedValidationState the validation state being requested by the caller. - * @return Returns VALIDATE_ALL if the requested validation state - * does not cover all the validation covered by the current validation - * state. Returned requestedValidationState otherwise. - */ - public int getNewValidationState(int currentValidationState, int requestedValidationState) { - int newValidationState; - if (currentValidationState == VALIDATE_NONE - || currentValidationState == requestedValidationState) { - newValidationState = requestedValidationState; - } else { - newValidationState = VALIDATE_ALL; - } - - return newValidationState; - - } - - /** - * Returns IStatus resulting from checking for empty fields. Used for validation of page 1 of the - * Web service/client wizards. - * @param validationState one of VALIDATE_NONE, VALIDATE_ALL, VALIDATE_SERVER_RUNTIME_CHANGES, VALIDATE_PROJECT_CHANGES, VALIDATE_SCALE_CHANGES - * @param typeId Web service type id (isClient=false) or Web service client implementation type id (isClient=true) - * @param serviceImpl String representation of the object selection from page 1 - * @param runtimeId Web service runtime id - * @param serverId server type id - * @param projectName name of project - * @param needEar boolean <code>true</code> if EAR is required, <code>false</code> if not. - * @param earProjectName name of EAR project - * @param projectTypeId template id - * @param isClient boolean <code>true</code> if the method is being called for client side validation, - * <code>false</code> for service side validation. - * @return IStatus with severity IStatus.OK if all mandatory fields are non-null and non-empty. - * IStatus with severity IStatus.ERROR otherwise. - */ - public IStatus checkMissingFieldStatus(int validationState, String typeId, String serviceImpl, String runtimeId, String serverId, - String projectName, boolean needEar, String earProjectName, String projectTypeId, - boolean isClient) - { - // Object selection - if (validationState==VALIDATE_ALL && !isClient) - { - if (serviceImpl.length() == 0) { - int scenario = WebServiceRuntimeExtensionUtils2.getScenarioFromTypeId(typeId); - if (scenario == WebServiceScenario.BOTTOMUP) - { - return StatusUtils - .errorStatus(ConsumptionUIMessages.MSG_NO_OBJECT_SELECTION); - } - else - { - return StatusUtils - .errorStatus(ConsumptionUIMessages.MSG_NO_SERVICE_SELECTION); - } - } - } - - // Web service runtime - if (validationState == VALIDATE_ALL || validationState == VALIDATE_SERVER_RUNTIME_CHANGES) { - if (runtimeId == null || runtimeId.length() == 0) { - if (isClient) { - return StatusUtils.errorStatus(NLS.bind(ConsumptionUIMessages.MSG_NO_RUNTIME, - new String[] { ConsumptionUIMessages.MSG_CLIENT_SUB })); - } else { - return StatusUtils.errorStatus(NLS.bind(ConsumptionUIMessages.MSG_NO_RUNTIME, - new String[] { ConsumptionUIMessages.MSG_SERVICE_SUB })); - } - } - } - - if (validationState == VALIDATE_ALL || validationState == VALIDATE_PROJECT_CHANGES) { - // Project - if (projectName == null || projectName.length() == 0) { - if (isClient) { - return StatusUtils.errorStatus(NLS.bind( - ConsumptionUIMessages.MSG_CLIENT_PROJECT_EMPTY, new String[] { "" })); - } else { - return StatusUtils.errorStatus(NLS.bind( - ConsumptionUIMessages.MSG_SERVICE_PROJECT_EMPTY, new String[] { "" })); - } - } - - // Project type (if project does not exist) - IProject project = ProjectUtilities.getProject(projectName); - if (!project.exists()) { - if (projectTypeId == null || projectTypeId.length() == 0) { - - if (isClient) { - return StatusUtils - .errorStatus(ConsumptionUIMessages.MSG_CLIENT_PROJECT_TYPE_EMPTY); - } else { - return StatusUtils - .errorStatus(ConsumptionUIMessages.MSG_SERVICE_PROJECT_TYPE_EMPTY); - } - } - } - - // Ear (if need ear) - if (needEar) { - if (earProjectName == null || earProjectName.length() == 0) { - if (isClient) { - return StatusUtils.errorStatus(NLS.bind( - ConsumptionUIMessages.MSG_CLIENT_EAR_EMPTY, new String[] { "" })); - } else { - return StatusUtils.errorStatus(NLS.bind( - ConsumptionUIMessages.MSG_SERVICE_EAR_EMPTY, new String[] { "" })); - } - } - } - } - - // Server (if Web service runtime requires a server or project does not - // exist) - if (validationState == VALIDATE_ALL || validationState == VALIDATE_SERVER_RUNTIME_CHANGES - || validationState == VALIDATE_PROJECT_CHANGES) { - if (serverId == null || serverId.length() == 0) { - RuntimeDescriptor desc = WebServiceRuntimeExtensionUtils2.getRuntimeById(runtimeId); - if (desc.getServerRequired()) { - if (isClient) { - StatusUtils.errorStatus(NLS.bind(ConsumptionUIMessages.MSG_NO_SERVER, - new String[] { ConsumptionUIMessages.MSG_CLIENT_SUB })); - } else { - StatusUtils.errorStatus(NLS.bind(ConsumptionUIMessages.MSG_NO_SERVER, - new String[] { ConsumptionUIMessages.MSG_SERVICE_SUB })); - } - } else { - IProject project = ProjectUtilities.getProject(projectName); - if (!project.exists()) { - return StatusUtils.errorStatus(NLS.bind( - ConsumptionUIMessages.MSG_PROJECT_MUST_EXIST, - new String[] { projectName })); - - } - } - } - } - - return Status.OK_STATUS; - } - - /** - * Returns IStatus resulting from checking for errors. Used for validation of page 1 of the - * Web service/client wizards. - * @param validationState one of VALIDATE_NONE, VALIDATE_ALL, VALIDATE_SERVER_RUNTIME_CHANGES, VALIDATE_PROJECT_CHANGES, VALIDATE_SCALE_CHANGES - * @param typeRuntimeServer Web service runtime, type and server - * @param projectName name of project - * @param needEar boolean <code>true</code> if EAR is required, <code>false</code> if not. - * @param earProjectName name of EAR project - * @param projectTypeId template id - * @param isClient boolean <code>true</code> if the method is being called for client side validation, - * <code>false</code> for service side validation. - * @return IStatus with severity IStatus.OK if no errors are present, - * IStatus with severity IStatus.ERROR otherwise. - */ - public IStatus checkErrorStatus(int validationState, TypeRuntimeServer typeRuntimeServer, String projectName, String initialProjectName, boolean needEar, String earProjectName, String projectTypeId, - boolean isClient) { - - // Ensure server, Web service runtime, and Web service type are - // compatible - - String typeId = typeRuntimeServer.getTypeId(); - String runtimeId = typeRuntimeServer.getRuntimeId(); - String serverId = typeRuntimeServer.getServerId(); - String serverInstanceId = typeRuntimeServer.getServerInstanceId(); - - // Labels - String serverLabel = ""; - if (serverId != null && serverId.length()>0) - { - serverLabel = WebServiceRuntimeExtensionUtils2.getServerLabelById(serverId); - } - String runtimeLabel = WebServiceRuntimeExtensionUtils2.getRuntimeLabelById(runtimeId); - - if (validationState == VALIDATE_ALL || validationState == VALIDATE_SERVER_RUNTIME_CHANGES) { - if (serverId != null && serverId.length() > 0) { - if (isClient) { - if (!WebServiceRuntimeExtensionUtils2 - .isServerClientRuntimeTypeSupported(serverId, - runtimeId, typeId)) { - return StatusUtils - .errorStatus(NLS - .bind( - ConsumptionUIMessages.MSG_INVALID_SRT_SELECTIONS, - new String[] { serverLabel, - runtimeLabel })); - } - } else { - if (!WebServiceRuntimeExtensionUtils2 - .isServerRuntimeTypeSupported(serverId, runtimeId, - typeId)) { - return StatusUtils - .errorStatus(NLS - .bind( - ConsumptionUIMessages.MSG_INVALID_SRT_SELECTIONS, - new String[] { serverLabel, - runtimeLabel })); - } - - if (initialProjectName != "" && serverId != null && !projectName.equals(initialProjectName) && - (WebServiceRuntimeExtensionUtils2.getScenarioFromTypeId(typeId) == WebServiceScenario.BOTTOMUP) && - J2EEUtils.isJavaComponent(ProjectUtilities.getProject(initialProjectName))){ - - if(!doesServerSupportProject(serverId,initialProjectName)){ - return StatusUtils.errorStatus(NLS.bind( - ConsumptionUIMessages.MSG_SERVICE_SERVER_DOES_NOT_SUPPORT_JAVAPROJECT, - new String[] { serverLabel, initialProjectName })); - } - } - } - } - - } - - // If the project exists, ensure it supports the Web service type, Web - // service runtime, and server. If the Ear also exists and the project - // and Ear are not already associated, ensure they can be. - // If the project does not exist, ensure the project type supports the - // Web service type, Web service runtime, and server - if (validationState == VALIDATE_ALL || validationState == VALIDATE_SERVER_RUNTIME_CHANGES - || validationState == VALIDATE_PROJECT_CHANGES) { - ValidationUtils valUtils = new ValidationUtils(); - IProject project = ProjectUtilities.getProject(projectName); - if (project.exists()) { - - if (isClient) { - // Check if the runtime supports it. - if (!WebServiceRuntimeExtensionUtils2.doesClientTypeAndRuntimeSupportProject( - typeId, runtimeId, projectName)) { - return StatusUtils.errorStatus(NLS.bind( - ConsumptionUIMessages.MSG_CLIENT_RUNTIME_DOES_NOT_SUPPORT_PROJECT, - new String[] { runtimeLabel, serverLabel, projectName })); - } - - // Check if the server supports it. - if (serverId != null && serverId.length() > 0) { - - if (!valUtils.doesServerSupportProject(serverId, projectName)) { - // Server does not support the project... - - boolean isJavaUtilProject = project != null ? FacetUtils.isJavaProject(project) : false ; - - // If this error is due to differing Java facet versions on a Java utility project, display a specific error message - if(isJavaUtilProject && doesServerSupportClientProject(serverId, projectName, true)) { - return StatusUtils.errorStatus(NLS.bind( - ConsumptionUIMessages.MSG_CLIENT_SERVER_DOES_NOT_SUPPORT_PROJECT_JAVA_UTIL_VERSION, - new String[] { serverLabel, projectName })); - - } else { - // Otherwise display a general error - return StatusUtils.errorStatus(NLS.bind( - ConsumptionUIMessages.MSG_CLIENT_SERVER_DOES_NOT_SUPPORT_PROJECT, - new String[] { serverLabel, projectName })); - } - } - } - } else { - // Check if the runtime supports it. - if (!WebServiceRuntimeExtensionUtils2.doesServiceTypeAndRuntimeSupportProject( - typeId, runtimeId, projectName)) { - return StatusUtils.errorStatus(NLS.bind( - ConsumptionUIMessages.MSG_SERVICE_RUNTIME_DOES_NOT_SUPPORT_PROJECT, - new String[] { runtimeLabel, serverLabel, projectName })); - } - - // Check if the server supports it. - if (serverId != null && serverId.length() > 0) - { - if (!valUtils.doesServerSupportProject(serverId, projectName)) { - return StatusUtils.errorStatus(NLS.bind( - ConsumptionUIMessages.MSG_SERVICE_SERVER_DOES_NOT_SUPPORT_PROJECT, - new String[] { serverLabel, projectName })); - } - } - } - } else { - // Look at the project type to ensure that it is suitable for - // the - // selected runtime and server. - String templateId = projectTypeId; - String templateLabel = FacetUtils.getTemplateLabelById(templateId); - - if (isClient) { - // Check if the runtime supports it. - if (!WebServiceRuntimeExtensionUtils2.doesClientTypeAndRuntimeSupportTemplate( - typeId, runtimeId, templateId, serverId)) { - - return StatusUtils.errorStatus(NLS.bind( - ConsumptionUIMessages.MSG_CLIENT_RUNTIME_DOES_NOT_SUPPORT_TEMPLATE, - new String[] { runtimeLabel, serverLabel, templateLabel })); - } - - // Check if the server supports it. - if (serverId != null && serverId.length()>0) - { - if (!valUtils.doesServerSupportTemplate(serverId, templateId)) { - return StatusUtils.errorStatus(NLS.bind( - ConsumptionUIMessages.MSG_CLIENT_SERVER_DOES_NOT_SUPPORT_TEMPLATE, - new String[] { serverLabel, templateLabel })); - } - } - - if (WebServiceRuntimeExtensionUtils2.getClientRuntimeId(typeRuntimeServer, projectName, projectTypeId) == "") - { - return StatusUtils.errorStatus(NLS.bind( - ConsumptionUIMessages.MSG_CLIENT_RUNTIME_DOES_NOT_SUPPORT_TEMPLATE, - new String[] { runtimeLabel, serverLabel, templateLabel })); - } - - } else { - // Check if the runtime supports it. - if (!WebServiceRuntimeExtensionUtils2.doesServiceTypeAndRuntimeSupportTemplate( - typeId, runtimeId, templateId, serverId)) { - return StatusUtils - .errorStatus(NLS - .bind( - ConsumptionUIMessages.MSG_SERVICE_RUNTIME_DOES_NOT_SUPPORT_TEMPLATE, - new String[] { runtimeLabel, serverLabel, templateLabel })); - } - - // Check if the server supports it. - if (serverId != null && serverId.length()>0) - { - if (!valUtils.doesServerSupportTemplate(serverId, templateId)) { - return StatusUtils.errorStatus(NLS.bind( - ConsumptionUIMessages.MSG_SERVICE_SERVER_DOES_NOT_SUPPORT_TEMPLATE, - new String[] { serverLabel, templateLabel })); - } - } - } - - } - - } - - if (validationState == VALIDATE_ALL || validationState == VALIDATE_PROJECT_CHANGES) { - // Check if project/EAR association is good. - if (needEar) { - IProject project = ProjectUtilities.getProject(projectName); - IProject ep = ProjectUtilities.getProject(earProjectName); - - // 194434 - Check for non-existing EAR with contents that's not deleted previously - IStatus canCreateEARStatus = J2EEUtils.canCreateEAR(ep); - if (!canCreateEARStatus.isOK()) { - return canCreateEARStatus; - } - - if (project.exists() && ep.exists()) { - if (!J2EEUtils.isComponentAssociated(ep, project)) { - boolean associateStatus = J2EEUtils.canAssociateProjectToEARWithoutWarning(project, ep); - if (!associateStatus) { - if (isClient) { - return StatusUtils.warningStatus(NLS.bind( - ConsumptionUIMessages.MSG_CLIENT_CANNOT_ASSOCIATE, - new String[] { projectName, ep.getName()})); - } else { - return StatusUtils.warningStatus(NLS.bind( - ConsumptionUIMessages.MSG_SERVICE_CANNOT_ASSOCIATE, - new String[] { projectName, ep.getName()})); - } - } - } - } - } - } - - // Defect 203826 - Give extender a way to veto server, project, project type and EAR choices - if (validationState == VALIDATE_ALL || validationState == VALIDATE_SERVER_RUNTIME_CHANGES - || validationState == VALIDATE_PROJECT_CHANGES) { - TypeRuntimeServer trs = new TypeRuntimeServer(); - trs.setTypeId(typeId); - trs.setRuntimeId(runtimeId); - trs.setServerId(serverId); - IWebServiceRuntimeChecker runtimeChecker = null; - if (isClient) { - String clientRuntimeId = WebServiceRuntimeExtensionUtils2.getClientRuntimeId(trs, projectName, projectTypeId); - runtimeChecker = WebServiceRuntimeExtensionUtils2.getClientRuntimeChecker(clientRuntimeId); - - } else { - String serviceRuntimeId = WebServiceRuntimeExtensionUtils2.getServiceRuntimeId(trs, projectName, projectTypeId); - runtimeChecker = WebServiceRuntimeExtensionUtils2.getServiceRuntimeChecker(serviceRuntimeId); - } - if (runtimeChecker != null) { - return runtimeChecker.checkRuntimeCompatibility(serverId, serverInstanceId, projectName, projectTypeId, earProjectName); - } - } - - return Status.OK_STATUS; - - } - - /** - * Returns IStatus resulting from checking for warnings. Used for validation of page 1 of the - * Web service/client wizards. - * @param validationState one of VALIDATE_NONE, VALIDATE_ALL, VALIDATE_SERVER_RUNTIME_CHANGES, VALIDATE_PROJECT_CHANGES, VALIDATE_SCALE_CHANGES - * @param scaleSetting one of <BR/> - * ScenarioContext.WS_TEST<BR/> - * ScenarioContext.WS_START<BR/> - * ScenarioContext.WS_INSTALL<BR/> - * ScenarioContext.WS_DEPLOY<BR/> - * ScenarioContext.WS_ASSEMBLE<BR/> - * ScenarioContext.WS_DEVELOP<BR/> - * ScenarioContext.WS_NONE - * @param serverId server type id - * @param serverId server instance id - * @param isClient boolean <code>true</code> if the method is being called for client side validation, - * <code>false</code> for service side validation. - * @return IStatus with severity IStatus.OK if no errors are present, - * IStatus with severity IStatus.WARNING otherwise. - */ - public IStatus checkWarningStatus(int validationState, int scaleSetting, String serverId, - String serverInstanceId, boolean isClient) { - return checkWarningStatus(validationState, scaleSetting, serverId, serverInstanceId, isClient, null, null, null); - } - - /** - * Returns IStatus resulting from checking for warnings. Used for validation of page 1 of the - * Web service/client wizards. - * @param validationState one of VALIDATE_NONE, VALIDATE_ALL, VALIDATE_SERVER_RUNTIME_CHANGES, VALIDATE_PROJECT_CHANGES, VALIDATE_SCALE_CHANGES - * @param scaleSetting one of <BR/> - * ScenarioContext.WS_TEST<BR/> - * ScenarioContext.WS_START<BR/> - * ScenarioContext.WS_INSTALL<BR/> - * ScenarioContext.WS_DEPLOY<BR/> - * ScenarioContext.WS_ASSEMBLE<BR/> - * ScenarioContext.WS_DEVELOP<BR/> - * ScenarioContext.WS_NONE - * @param serverId server type id - * @param serverId server instance id - * @param isClient boolean <code>true</code> if the method is being called for client side validation, - * <code>false</code> for service side validation. - * @return IStatus with severity IStatus.OK if no errors are present, - * IStatus with severity IStatus.WARNING otherwise. - */ - public IStatus checkWarningStatus(int validationState, int scaleSetting, String serverId, - String serverInstanceId, boolean isClient, String projectName, IProject initialProject, String typeId) { - // Return a warning if there is no server selection and scale setting is - // anything beyond assemble. - if (validationState == VALIDATE_ALL || validationState == VALIDATE_SCALE_CHANGES - || validationState == VALIDATE_SERVER_RUNTIME_CHANGES) { - if (serverId == null || serverId.length() == 0) { - if (scaleSetting < ScenarioContext.WS_ASSEMBLE) { - if (isClient) { - return StatusUtils.warningStatus(NLS.bind( - ConsumptionUIMessages.MSG_WARN_NO_CLIENT_SERVER, new String[0])); - } else { - return StatusUtils.warningStatus(NLS.bind( - ConsumptionUIMessages.MSG_WARN_NO_SERVICE_SERVER, new String[0])); - } - } - } else { - // Return a warning if the selected server has only stub - // runtimes - // and the scale setting is anything beyond deploy. - IServerType serverType = ServerCore.findServerType(serverId); - if (serverType != null) { - // Find a Runtime which is not a stub - IRuntime nonStubRuntime = ServerUtils.getNonStubRuntime(serverId); - if ((scaleSetting < ScenarioContext.WS_DEPLOY) && nonStubRuntime == null && serverInstanceId == null) { - String servertypeLabel = WebServiceRuntimeExtensionUtils2 - .getServerLabelById(serverId); - return StatusUtils.warningStatus(NLS.bind( - ConsumptionUIMessages.MSG_WARN_STUB_ONLY, - new String[] { servertypeLabel })); - } - } - - } - } - //return a warning in bottom up scenarios where the intial project will be converted into a java utility project - if (initialProject != null && projectName != null && !projectName.equals(initialProject.getName()) && !JavaEEProjectUtilities.isUtilityProject(initialProject) && FacetUtils.isJavaProject(initialProject) && - (WebServiceRuntimeExtensionUtils2.getScenarioFromTypeId(typeId) == WebServiceScenario.BOTTOMUP)){ - return StatusUtils.warningStatus(NLS.bind(ConsumptionUIMessages.MSG_WARN_CONVERTED_TO_UTIL, initialProject.getName())); - } - - return Status.OK_STATUS; - - } - - - /** - * Returns whether or not the provided server type supports the facet versions on the provided client project - * @param serverFactoryId server type id - * @param projectName name of a project that may or may not exist. - * @param ignoreJavaVersionFacet Whether or not to ignore differences in java facet version - * @return boolean <code>true</code> if the server type supports the facet versions on the project (facets versions are inferred from a Java project), - * <code>false</code> if the server type does not support the facet versions or facet versions on the project cannot be determined. */ - public boolean doesServerSupportClientProject(String serverFactoryId, String projectName, boolean ignoreJavaVersionFacet) { - Set facets = FacetUtils.getFacetsForProject(projectName); - - if (ignoreJavaVersionFacet && facets != null) { - - Set facetsCopy = new HashSet(); - facetsCopy.addAll(facets); - for (Iterator it = facetsCopy.iterator(); it.hasNext();) { - ProjectFacetVersion pfv = (ProjectFacetVersion) it.next(); - String facetId = pfv.getProjectFacet().getId(); - if (facetId != null && facetId.equalsIgnoreCase(JavaFacetUtils.JAVA_FACET.getId())) { - it.remove(); - } - } - - facets = facetsCopy; - - } - - if (facets == null) { - return true; - } else { - return doesServerSupportFacets(serverFactoryId, facets); - } - } - - /** - * Returns whether or not the provided server type supports the facet versions on the provided project - * @param serverFactoryId server type id - * @param projectName name of a project that may or may not exist. - * @return boolean <code>true</code> if the server type supports the facet versions on the project (facets versions are inferred from a Java project), - * <code>false</code> if the server type does not support the facet versions or facet versions on the project cannot be determined. */ - public boolean doesServerSupportProject(String serverFactoryId, String projectName) - { - Set facets = FacetUtils.getFacetsForProject(projectName); - if (facets == null) - return true; - else - return doesServerSupportFacets(serverFactoryId, facets); - } - - /** - * Returns whether or not the provided server type supports the facet versions in the provided set. - * @param serverFactoryId server type id - * @param facets set containing elements of type {@link IProjectFacetVersion} - * @return boolean <code>true</code> if the server type supports the facet versions in the provided set, - * <code>false</code> otherwise. - */ - public boolean doesServerSupportFacets(String serverFactoryId, Set facets) - { - Set runtimes = FacetUtils.getRuntimes(new Set[]{facets}); - - Iterator itr = runtimes.iterator(); - IServerType st = ServerCore.findServerType(serverFactoryId); - String runtimeTypeId = st.getRuntimeType().getId(); - while (itr.hasNext()) - { - org.eclipse.wst.common.project.facet.core.runtime.IRuntime fRuntime = (org.eclipse.wst.common.project.facet.core.runtime.IRuntime)itr.next(); - IRuntime sRuntime = FacetUtil.getRuntime(fRuntime); - if (sRuntime != null) - { - IRuntimeType runtimeType = sRuntime.getRuntimeType(); - if (runtimeType != null && runtimeTypeId.equals(runtimeType.getId())) - { - //found a match - return true; - } - } - } - - return false; - } - - /** - * Returns whether or not the provided server type supports at least one version of - * each of the fixed facets on the provided template - * @param serverFactoryId server type id - * @param templateId id of a {@link IFacetedProjectTemplate} - * @return boolean <code>true</code> if the server type supports at least one version of - * each of the fixed facets on the provided template, <code>false</code> otherwise. - */ - public boolean doesServerSupportTemplate(String serverFactoryId, String templateId) - { - IFacetedProjectTemplate template = ProjectFacetsManager.getTemplate(templateId); - Set templateFacets = template.getFixedProjectFacets(); - Iterator templateFacetsItr = templateFacets.iterator(); - while (templateFacetsItr.hasNext()) - { - boolean serverSupportsThisOne = false; - IProjectFacet fixedFacet = (IProjectFacet)templateFacetsItr.next(); - List versions = null; - try - { - versions = fixedFacet.getSortedVersions(true); - } catch (VersionFormatException e) - { - Set versionSet = fixedFacet.getVersions(); - Iterator itr = versionSet.iterator(); - versions = new ArrayList(); - while (itr.hasNext()) - { - versions.add(itr.next()); - } - } catch (CoreException e) - { - Set versionSet = fixedFacet.getVersions(); - Iterator itr = versionSet.iterator(); - versions = new ArrayList(); - while (itr.hasNext()) - { - versions.add(itr.next()); - } - } - Iterator versionsItr = versions.iterator(); - while(versionsItr.hasNext()) - { - IProjectFacetVersion pfv = (IProjectFacetVersion)versionsItr.next(); - Set pfvs = new HashSet(); - pfvs.add(pfv); - if (doesServerSupportFacets(serverFactoryId, pfvs)) - { - serverSupportsThisOne = true; - break; - } - } - - if (!serverSupportsThisOne) - { - return false; - } - } - - return true; - } - - /** - * Returns whether or not the provided project or project type (if the project is null or does not exist) - * rules out the need for an EAR. - * @param projectName name of a project - * @param projectTypeId id of a {@link IFacetedProjectTemplate}. Must be non-empty if the project is null or - * does not exist. - * @return boolean <code>true</code> if the need for an EAR is not ruled out, <code>false</code> otherwise. - */ - public boolean projectOrProjectTypeNeedsEar(String projectName, String projectTypeId) - { - // If the project is a simple Java project or the project type is - // Java utility return false. - if (projectName != null && projectName.length() > 0) { - IProject project = ResourceUtils.getWorkspaceRoot().getProject(projectName); - if (project.exists()) { - if (FacetUtils.isJavaProject(project)) { - return false; - } - } - } - - // Project didn't rule out the need for an EAR - // so check the proect type - String templateId = projectTypeId; - if (templateId != null && templateId.length() > 0) { - if (FacetUtils.isUtilityTemplate(templateId)) { - return false; - } - } - - return true; - } - - /** - * Returns whether or not an J2EE 1.3 EAR project can be installed on a server of - * the provided server type. - * @param serverTypeId server type id - * @return boolean <code>true</code> if a J2EE 1.3 EAR project can be installed on a server of - * the provided server type, <code>false</code> otherwise. - */ - public boolean serverNeedsEAR(String serverTypeId) - { - if (serverTypeId == null) { - return false; - } - if (serverTypeId.length() > 0) { - String targetId = ServerUtils.getRuntimeTargetIdFromFactoryId(serverTypeId); - if (targetId != null && targetId.length() > 0) { - if (!ServerUtils.isTargetValidForEAR(targetId, "13")) // rm j2ee - { - return false; - } - } - } - - return true; - } - - public IStatus validateProjectTargetAndJ2EE(String projectName, String compName, String earName, String earCompName, String serverFactoryId, String j2eeLevel) - { - IProject p = ProjectUtilities.getProject(projectName); - IProject earP = null; - if (earName!=null && !earName.equalsIgnoreCase("")) { - earP = ProjectUtilities.getProject(earName); - } - IStatus targetStatus = doesProjectTargetMatchServerType(p, serverFactoryId); - if (earP!=null && targetStatus.getSeverity()==Status.OK) - { - //check the EAR - IStatus earTargetStatus = doesProjectTargetMatchServerType(earP, serverFactoryId); - if(earTargetStatus.getSeverity()==Status.ERROR) - { - return earTargetStatus; - } - } - else - { - return targetStatus; - } - - - //Validate service side J2EE level - IStatus j2eeStatus = doesProjectMatchJ2EELevel(p, compName, j2eeLevel); - if(earP!=null && j2eeStatus.getSeverity()==Status.OK) - { - IStatus earJ2EEStatus = doesProjectMatchJ2EELevel(earP, earCompName, j2eeLevel); - if(earJ2EEStatus.getSeverity()==Status.ERROR) - { - return earJ2EEStatus; - } - } - else - { - return j2eeStatus; - } - - return Status.OK_STATUS; - } - - //TODO: This method is obselete - should be removed. - private IStatus doesProjectTargetMatchServerType(IProject p, String serverFactoryId) - { - if (p!=null && p.exists()) - { - IRuntime projectTarget = ServerSelectionUtils.getRuntimeTarget(p.getName()); - if (projectTarget!=null) - { - String projectTargetId = projectTarget.getRuntimeType().getId(); - String serverTargetId = ServerUtils.getRuntimeTargetIdFromFactoryId(serverFactoryId); - if (serverTargetId!=null && serverTargetId.length()>0) - { - if(!projectTargetId.equals(serverTargetId)) - { - return StatusUtils.errorStatus( NLS.bind(ConsumptionUIMessages.MSG_SERVER_TARGET_MISMATCH,new String[]{p.getName()}) ); - } - } - } - } - return Status.OK_STATUS; - } - - //TODO: This method is obselete - should be removed. - private IStatus doesProjectMatchJ2EELevel(IProject p, String compName, String j2eeLevel) - { - - try { - if (p!=null && p.exists()) - { - int projectJ2EELevel = J2EEUtils.getJ2EEVersion(p); - if (projectJ2EELevel!=-1) - { - String projectJ2EELevelString = String.valueOf(projectJ2EELevel); - if (j2eeLevel!=null && j2eeLevel.length()>0) - { - if (!projectJ2EELevelString.equals(j2eeLevel)) - { - return StatusUtils.errorStatus( NLS.bind(ConsumptionUIMessages.MSG_J2EE_MISMATCH,new String[]{p.getName()}) ); - } - } - } - } - } catch(Exception e){ - - } - - return Status.OK_STATUS; - } - - //TODO: This method is obselete - should be removed. - public IStatus validateProjectType(String projectName, SelectionListChoices runtime2ClientTypes) - { - IStatus status = Status.OK_STATUS; - IProject p = ProjectUtilities.getProject(projectName); - if (p==null || !p.exists()) - { - //Project does not exist which means a new project of the correct type will be created - //We're done. All is good. - return status; - } - - //If the project exists, we should see it in the project list for the selected client - //project type. - String[] projectNames = runtime2ClientTypes.getChoice().getChoice().getList().getList(); - for (int i=0; i<projectNames.length; i++) - { - if (projectName.equals(projectNames[i])) - { - //Found the project. All is good. - return status; - } - } - - //Didn't find the project. Return an error. - //Get the label for the client type id - String clientTypeLabel = getClientTypeLabel(runtime2ClientTypes.getChoice().getList().getSelection()); - String message = NLS.bind(ConsumptionUIMessages.MSG_WRONG_CLIENT_PROJECT_TYPE,new String[]{projectName, clientTypeLabel}); - IStatus eStatus = StatusUtils.errorStatus( message ); - return eStatus; - - } - - //TODO: This method is obselete - should be removed. - private String getClientTypeLabel( String type ) - { - if (type.equals(IModuleConstants.JST_WEB_MODULE)) - { - return ConsumptionUIMessages.LABEL_CLIENT_COMP_TYPE_WEB; - } - else if (type.equals(IModuleConstants.JST_EJB_MODULE)) - { - return ConsumptionUIMessages.LABEL_CLIENT_COMP_TYPE_EJB; - } - else if (type.equals(IModuleConstants.JST_APPCLIENT_MODULE)) - { - return ConsumptionUIMessages.LABEL_CLIENT_COMP_TYPE_APP_CLIENT; - } - else if (type.equals(IModuleConstants.JST_UTILITY_MODULE)) - { - return ConsumptionUIMessages.LABEL_CLIENT_COMP_TYPE_CONTAINERLESS; - } - else - { - //No known label, return the typeId itself. - return type; - } - } - - /** - * Returns whether or not this project is likely hosting any of the services - * in the provided WSDL as a J2EE Web service. - * @param p IProject in the workspace - * @param wsdlURL URL of a WSDL document - * @param parser - * @return boolean <code>true</code> if the project contains a webservices.xml - * deployment descriptor that points to at least one of the ports in the provided WSDL. - * Returns <code>false</code> otherwise. - */ - public boolean isProjectServiceProject(IProject p, String wsdlURL, WebServicesParser parser) - { - if (p==null || wsdlURL==null || wsdlURL.length()==0 || parser==null) - return false; - - IResource wsXML = getWebServcesXML(p); - if (wsXML==null) - return false; - - - //Make a list of all the wsdl-port's in webservices.xml - if (!(wsXML instanceof IFile)) - { - return false; - } - - Resource res = WorkbenchResourceHelperBase.getResource((IFile)wsXML, true); - WsddResource wsddRes = (WsddResource)res; - WebServices webServices = wsddRes.getWebServices(); - Iterator wsDescs = webServices.getWebServiceDescriptions().iterator(); - ArrayList wsdlPortList = new ArrayList(); - while(wsDescs.hasNext()) - { - WebServiceDescription wsDesc = (WebServiceDescription)wsDescs.next(); - Iterator pcs = wsDesc.getPortComponents().iterator(); - while(pcs.hasNext()) - { - PortComponent pc = (PortComponent)pcs.next(); - WSDLPort wsdlPort = pc.getWsdlPort(); - wsdlPortList.add(new QualifiedName(wsdlPort.getNamespaceURI(), wsdlPort.getLocalPart())); - } - } - - ArrayList portList = getPortNamesFromWsdl(wsdlURL, parser); - - //If any of the QualifiedNames in portList equals any of the QualifiedNames - //in wsdlPortList, this is the service project. Return true. - Object[] ports = portList.toArray(); - Object[] wsdlPorts = wsdlPortList.toArray(); - for (int i = 0; i < ports.length; i++) - { - QualifiedName portName = (QualifiedName) ports[i]; - for (int j = 0; j < wsdlPorts.length; j++) - { - QualifiedName wsdlPortName = (QualifiedName) wsdlPorts[j]; - if (portName.equals(wsdlPortName)) - { - return true; - } - } - } - - return false; - } - - /** - * Returns the IResource corresponding to the webservices.xml in the provided project. - * @param p an IProject in the workspace. - * @return IResource corresponding to the webservices.xml in the provided project, - * null if there is no webservices.xml in the project. - */ - private IResource getWebServcesXML(IProject p) - { - //Get the module root. - IResource moduleRoot = getModuleRoot(p); - if (!(moduleRoot instanceof IContainer)) - return null; - - IResource webServicesXML = null; - if (J2EEProjectUtilities.isDynamicWebProject(p)) - { - StringBuffer wsPath = new StringBuffer(); - wsPath.append("WEB-INF/"); - wsPath.append(WebServiceConstants.WEBSERVICE_DD_SHORT_NAME); - webServicesXML = ((IContainer) moduleRoot).findMember(wsPath.toString()); - } - else - { - StringBuffer wsPath = new StringBuffer(); - wsPath.append("META-INF/"); - wsPath.append(WebServiceConstants.WEBSERVICE_DD_SHORT_NAME); - webServicesXML = ((IContainer) moduleRoot).findMember(wsPath.toString()); - } - return webServicesXML; - } - - private IResource getModuleRoot(IProject p) - { - IPath modulePath = null; - try - { - IVirtualComponent vc = ComponentCore.createComponent(p); - if (vc != null) - { - modulePath = vc.getRootFolder().getWorkspaceRelativePath(); - } - } - catch(Exception ex) - { - - } - - IResource res = ResourceUtils.findResource(modulePath); - return res; - } - - /** - * Returns a list of WSDL ports in the provided WSDL - * @param wsdlURL URL of a WSDL document - * @param parser - * @return ArrayList containing elements of type {@link QualifiedName} - */ - private ArrayList getPortNamesFromWsdl(String wsdlURL, WebServicesParser parser) - { - ArrayList portNameList = new ArrayList(); - Definition def = parser.getWSDLDefinition(wsdlURL); - Map services = def.getServices(); - Service service = null; - for (Iterator it = services.values().iterator(); it.hasNext();) - { - service = (Service)it.next(); - String namespace = service.getQName().getNamespaceURI(); - Map ports = service.getPorts(); - for (Iterator it2 = ports.values().iterator(); it2.hasNext();) - { - Port port = (Port)it2.next(); - portNameList.add(new QualifiedName(namespace, port.getName())); - } - } - - return portNameList; - - } - - private class QualifiedName - { - String namespaceURI; - - String localPart; - - /** - * @param namespaceURI - * @param localPart - */ - public QualifiedName(String namespaceURI, String localPart) - { - super(); - this.namespaceURI = namespaceURI; - this.localPart = localPart; - } - - /** - * @return Returns the localPart. - */ - public String getLocalPart() - { - return localPart; - } - - /** - * @param localPart - * The localPart to set. - */ - public void setLocalPart(String localPart) - { - this.localPart = localPart; - } - - /** - * @return Returns the namespaceURI. - */ - public String getNamespaceURI() - { - return namespaceURI; - } - - /** - * @param namespaceURI - * The namespaceURI to set. - */ - public void setNamespaceURI(String namespaceURI) - { - this.namespaceURI = namespaceURI; - } - - public boolean equals(QualifiedName qn) - { - return (qn.getNamespaceURI().equals(namespaceURI) && qn.getLocalPart() - .equals(localPart)); - } - } -} |