diff options
Diffstat (limited to 'bundles/org.eclipse.jst.ws/src/org')
41 files changed, 0 insertions, 6881 deletions
diff --git a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/command/NullStatusMonitor.java b/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/command/NullStatusMonitor.java deleted file mode 100644 index c0454d107..000000000 --- a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/command/NullStatusMonitor.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 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 - *******************************************************************************/ - -package org.eclipse.jst.ws.internal.command; - -import java.util.Vector; -import org.eclipse.core.runtime.IStatus; - -/** -* A NullStatusRenderer throws away IStatus information. -*/ -public class NullStatusMonitor implements StatusMonitor -{ - - // Copyright - public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002."; - - protected boolean result; - - /** - * Default constructor. - */ - public NullStatusMonitor () {} - /** - * Does nothing. - */ - public int reportStatus(IStatus status, Vector options) { return 0; } - public boolean reportStatus(IStatus status) - { - switch (status.getSeverity()) - { - case IStatus.ERROR: - case IStatus.WARNING: - result = false; - break; - case IStatus.INFO: - default: //IStatus.OK - result = true; - break; - } - return result; - } - public void dumpSavedStatus() { } - public boolean canContinue() - { - return result; - } - - public void reset () { - result = true; - } -} - diff --git a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/command/StatusMonitor.java b/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/command/StatusMonitor.java deleted file mode 100644 index de0758f77..000000000 --- a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/command/StatusMonitor.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 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 - *******************************************************************************/ - -package org.eclipse.jst.ws.internal.command; - -import java.util.Vector; -import org.eclipse.core.runtime.IStatus; - -/** -* A StatusMonitor reports IStatus information to a display system. -*/ -public interface StatusMonitor -{ - - // Copyright - public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002."; - - /** - * reports the contents of the given status object. - * Subclasses must implement this method to report - * IStatus information to a given display system, - * such as SWT, the command line, or a trace file. - */ - public int reportStatus(IStatus status, Vector options); - public boolean reportStatus(IStatus status); - public void dumpSavedStatus(); - public boolean canContinue(); - public void reset(); -} diff --git a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/command/StatusRenderer.java b/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/command/StatusRenderer.java deleted file mode 100644 index 0cff3a6b8..000000000 --- a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/command/StatusRenderer.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 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 - *******************************************************************************/ - -package org.eclipse.jst.ws.internal.command; - -import org.eclipse.core.runtime.IStatus; - -/** -* A StatusRenderer renders IStatus information to a display system. -*/ -public interface StatusRenderer -{ - - // Copyright - public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002."; - - /** - * Renders the contents of the given status object. - * Subclasses must implement this method to render - * IStatus information to a given display system, - * such as SWT, the command line, or a trace file. - */ - public void render ( IStatus status ); -} diff --git a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/common/AnyFilter.java b/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/common/AnyFilter.java deleted file mode 100644 index ba00a104c..000000000 --- a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/common/AnyFilter.java +++ /dev/null @@ -1,85 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 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 - *******************************************************************************/ - -package org.eclipse.jst.ws.internal.common; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jst.ws.internal.plugin.WebServicePlugin; - - -/** -* This is a kind of {@link Filter} that accepts all objects, -* and is a suitable base class for new <code>Filters</code>. -*/ -public class AnyFilter implements Filter -{ - - // Copyright - public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002."; - - /** - * Constructs a new <code>AnyFilter</code>. - */ - public AnyFilter () - { - } - - /** - * Returns the locale-specific name of this filter. - * @return The locale-specific name of this filter. - */ - public String getName () - { - return WebServicePlugin.getMessage("%ANY_FILTER_NAME"); - } - - /** - * Returns the locale-specific description of this filter. - * @return The locale-specific description of this filter. - */ - public String getDescription () - { - return WebServicePlugin.getMessage("%ANY_FILTER_DESC"); - } - - /** - * Returns an {@link org.eclipse.core.runtime.IStatus} - * describing the <code>Filter</code>'s assessment of - * the given <code>object</code>. - * See {@link Filter#statusOf} for general comments. - * The default implementation of <code>AnyFilter</code> - * returns a status with severity <code>IStatus.OK</code>. - * Subclasses may override. - * @param object The object to filter. - * @return An {@link org.eclipse.core.runtime.IStatus}. - */ - public IStatus statusOf ( Object object ) - { - return new Status(IStatus.OK,WebServicePlugin.ID,0,"",null); - } - - /** - * Returns true if and only if {@link #statusOf} returns - * an {@link org.eclipse.core.runtime.IStatus} with a - * severity of less than <code>IStatus.ERROR</code>. - * Subclasses may override to provide a higher-performance - * implementation. - * @param object The object to filter. - * @return True if and only if {@link #statusOf} returns - * an {@link org.eclipse.core.runtime.IStatus} with a - * severity of less than <code>IStatus.ERROR</code>. - */ - public boolean accepts ( Object object ) - { - return !statusOf(object).matches(IStatus.ERROR); - } -} diff --git a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/common/Filter.java b/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/common/Filter.java deleted file mode 100644 index 91f0bf8a7..000000000 --- a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/common/Filter.java +++ /dev/null @@ -1,89 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 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 - *******************************************************************************/ - -package org.eclipse.jst.ws.internal.common; - -import org.eclipse.core.runtime.IStatus; - -/** -* This is the interface for a class of objects that filter -* other objects for inclusion or exclusion by some consumer. -*/ -public interface Filter -{ - - // Copyright - public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002."; - - /** - * Returns the locale-specific name of this filter. - * @return The locale-specific name of this filter. - */ - public String getName (); - - /** - * Returns the locale-specific description of this filter. - * @return The locale-specific description of this filter. - */ - public String getDescription (); - - /** - * Returns an {@link org.eclipse.core.runtime.IStatus} - * describing the <code>Filter</code>'s assessment of - * the given <code>object</code>. - * The severity of the - * returned <code>IStatus</code> is as follows: - * <ul> - * <li> - * {@link org.eclipse.core.runtime.IStatus#OK} - * if the <code>Filter</code> accepts the <code>object</code> - * with no further information for the caller (meaning the - * {@link org.eclipse.core.runtime.IStatus#getMessage} and - * {@link org.eclipse.core.runtime.IStatus#getException} methods - * are ignored). - * <li> - * {@link org.eclipse.core.runtime.IStatus#INFO} - * if the <code>Filter</code> accepts the <code>object</code> - * Additional information may be available from the - * {@link org.eclipse.core.runtime.IStatus#getMessage} and - * {@link org.eclipse.core.runtime.IStatus#getException} methods. - * <li> - * {@link org.eclipse.core.runtime.IStatus#WARNING} - * if the <code>Filter</code> accepts the <code>object</code>. - * Additional information may be available from the - * {@link org.eclipse.core.runtime.IStatus#getMessage} and - * {@link org.eclipse.core.runtime.IStatus#getException} methods. - * <li> - * {@link org.eclipse.core.runtime.IStatus#ERROR} - * if the <code>Filter</code> does not accept the <code>object</code>. - * Additional information may be available from the - * {@link org.eclipse.core.runtime.IStatus#getMessage} and - * {@link org.eclipse.core.runtime.IStatus#getException} methods. - * </ul> - * @param object The object to filter. - * @return An {@link org.eclipse.core.runtime.IStatus} - * describing the <code>Filter</code>'s assessment of - * the given <code>object</code>. - */ - public IStatus statusOf ( Object object ); - - /** - * Returns true if and only if this <code>Filter</code> - * accepts the given <code>object</code>. This method - * must return true if and only if {@link #statusOf} - * returns an <code>IStatus</code> with a severity of - * less than <code>IStatus.ERROR</code>. - * @param object The object to filter. - * @return True if and only if this <code>Filter</code> - * accepts the given <code>object</code>. - */ - public boolean accepts ( Object object ); -} diff --git a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/common/IProjectToStringTransformer.java b/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/common/IProjectToStringTransformer.java deleted file mode 100644 index 5bec5527e..000000000 --- a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/common/IProjectToStringTransformer.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 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 - *******************************************************************************/ -package org.eclipse.jst.ws.internal.common; - -import org.eclipse.core.resources.IProject; -import org.eclipse.wst.command.internal.env.core.data.Transformer; - - - -/** - * Transfroms a org.eclipse.core.runtime.IProject to java.lang.String - */ -public class IProjectToStringTransformer implements Transformer { - - public Object transform(Object value) - { - IProject project = (IProject)value; - return project.getName(); - } -} diff --git a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/common/J2EEActionAdapterFactory.java b/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/common/J2EEActionAdapterFactory.java deleted file mode 100644 index 63b9f9ab5..000000000 --- a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/common/J2EEActionAdapterFactory.java +++ /dev/null @@ -1,98 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 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 8, 2004 - */ -package org.eclipse.jst.ws.internal.common; - -import java.io.File; -import java.net.MalformedURLException; -import java.net.URL; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.IPath; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.jst.j2ee.webservice.wsclient.ServiceRef; -import org.eclipse.wst.wsdl.Definition; -import org.eclipse.wst.wsdl.internal.impl.ServiceImpl; -import org.eclipse.wst.wsdl.util.WSDLResourceImpl; - - -/** - * @author gilberta - */ -public class J2EEActionAdapterFactory { - - - public static String getWSDLURI(ServiceImpl serviceImpl) - { - Definition definition = serviceImpl.getEnclosingDefinition(); - String location = definition.getLocation(); - - return location; - } - - //has to be under the webcontent - public static String WEB_CONTENT = "WebContent"; - public static String getWSDLURI(ServiceRef serviceImpl) - { - IProject project = ProjectUtilities.getProject(serviceImpl); - IPath path = project.getLocation().addTrailingSeparator(); - path = path.append(WEB_CONTENT).addTrailingSeparator(); - path = path.append(serviceImpl.getWsdlFile()); - File file = new File(path.toString()); - try{ - URL url = file.toURL(); - return url.toString(); - }catch(MalformedURLException e){return null;} - - } - - public static String getWSDLURI(WSDLResourceImpl wsdlRI) - { - Definition definition = wsdlRI.getDefinition(); - String location = definition.getLocation(); - - return location; - } - - public static String getWSILPath(WSDLResourceImpl wsdlRI) - { - return convertToRelative(getWSDLURI(wsdlRI)); - } - - public static String getWSILPath(ServiceRef serviceImpl) - { - return convertToRelative(getWSDLURI(serviceImpl)); - } - - public static String getWSILPath(ServiceImpl serviceImpl) - { - return convertToRelative(getWSDLURI(serviceImpl)); - } - - public static String FILE="file:/"; - public static String FILEL="file:"; - public static String convertToRelative(String uri) - { - //remove file: - String root = ResourcesPlugin.getWorkspace().getRoot().getLocation().toString(); - root = FILE + root; - String rootL = FILEL + root; - if(uri.startsWith(root) || uri.startsWith(rootL)){ - return uri.substring(root.length()); - } - return uri; - } - - - -} diff --git a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/common/J2EEUtils.java b/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/common/J2EEUtils.java deleted file mode 100644 index 71bae908b..000000000 --- a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/common/J2EEUtils.java +++ /dev/null @@ -1,1156 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 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 - *******************************************************************************/ - -package org.eclipse.jst.ws.internal.common; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Vector; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Path; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.jst.j2ee.application.internal.operations.AddComponentToEnterpriseApplicationDataModelProvider; -import org.eclipse.jst.j2ee.ejb.EJBJar; -import org.eclipse.jst.j2ee.ejb.EJBResource; -import org.eclipse.jst.j2ee.ejb.EnterpriseBean; -import org.eclipse.jst.j2ee.ejb.Session; -import org.eclipse.jst.j2ee.ejb.SessionType; -import org.eclipse.jst.j2ee.ejb.componentcore.util.EJBArtifactEdit; -import org.eclipse.jst.j2ee.internal.J2EEVersionConstants; -import org.eclipse.jst.j2ee.internal.common.J2EEVersionUtil; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.ModuleCoreNature; -import org.eclipse.wst.common.componentcore.datamodel.properties.ICreateReferenceComponentsDataModelProperties; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualFolder; -import org.eclipse.wst.common.componentcore.resources.IVirtualReference; -import org.eclipse.wst.common.environment.EnvironmentService; -import org.eclipse.wst.common.environment.ILog; -import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.server.core.IModule; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.core.ServerUtil; -/** - * This class contains some useful J2EE utilities for Web services internal use. - */ -public final class J2EEUtils { - - public final static int WEB = 1; - public final static int EJB = 2; - public final static int APPCLIENT = 4; - public final static int EAR = 8; - - /** - * Returns an IVirtualComponent - * @param project - * @return - */ - public static IVirtualComponent getVirtualComponent(IProject project){ - return ComponentCore.createComponent(project); - } - - /** - * - * @param projectName - * @return - */ - public static IVirtualComponent getVirtualComponent(String projectName){ - IProject project = null; - if (projectName!=null && projectName.length() > 0 ) - project = ProjectUtilities.getProject(projectName); - - return ComponentCore.createComponent(project); - } - - - /** - * Returns the J2EE version - * @param p project - * @return int - */ - public static int getJ2EEVersion(IProject p){ - - String ver = J2EEProjectUtilities.getJ2EEProjectVersion(p); - return J2EEVersionUtil.convertVersionStringToInt(ver); - - /* - int j2eeVer = -1; - try { - IVirtualComponent vc = ComponentCore.createComponent(p); - if (vc!=null){ - j2eeVer = getJ2EEVersion(vc); - } - } - catch (Exception e){ - //handle exception - } - return j2eeVer; - */ - } - - public static int getJ2EEVersion(IVirtualComponent ch){ - int j2eeVer = -1; - //check type - if (ch!=null){ - IProject project = ch.getProject(); - j2eeVer = getJ2EEVersion(project); - } - - /* Use new API provided by J2EE - if (ch!=null) { - if (isWebComponent(ch)) - j2eeVer = getWebComponentJ2EEVersion(ch); - else if (isAppClientComponent(ch)) - j2eeVer = getAppClientComponentJ2EEVersion(ch); - else if (isEJBComponent(ch)) - j2eeVer = getEJBComponentJ2EEVersion(ch); - else if (isEARComponent(ch)) - j2eeVer = getEARComponentJ2EEVersion(ch); - } - */ - - return j2eeVer; - } - - - /** - * Returns the J2EEVersion - * @param p IProject - * @return String - */ - public static String getJ2EEVersionAsString(IProject p){ - - String ver = J2EEProjectUtilities.getJ2EEProjectVersion(p); - return ver != null ? ver : null; - - /* - int j2eeVer = getJ2EEVersion(p); - if (j2eeVer!=-1){ - return J2EEVersionUtil.getJ2EETextVersion(j2eeVer); - } - else - return null; - - */ - } - - public static IVirtualComponent[] getAllComponents(){ - List v = new ArrayList(); - IProject[] projects = ResourceUtils.getWorkspaceRoot().getProjects(); - for (int i = 0; i < projects.length; i++) { - IVirtualComponent vc = ComponentCore.createComponent(projects[i]); - if(vc != null) - v.add(vc); - } - - return (IVirtualComponent[])v.toArray(new IVirtualComponent[0]); - } - - /** - * Returns all the EAR components in the workspace - * @return IVirtualComponent[]; empty if none - */ - public static IVirtualComponent[] getAllEARComponents() { - List v = new ArrayList(); - IProject[] projects = ResourceUtils.getWorkspaceRoot().getProjects(); - for (int i = 0; i < projects.length; i++) { - try { - IVirtualComponent[] components = getEARComponentsFromProject(projects[i]); - for (int j=0; j<components.length; j++) { - if (components[j]!=null) - v.add(components[j]); - } - } catch (Exception e) { - e.printStackTrace(); - //handle exception - } - - } - return (IVirtualComponent[])v.toArray(new IVirtualComponent[0]); - } - - public static IVirtualComponent[] getAllWebComponents(){ - List v = new ArrayList(); - IProject[] projects = ResourceUtils.getWorkspaceRoot().getProjects(); - for (int i = 0; i < projects.length; i++) { - try { - IVirtualComponent[] components = getWebComponents(projects[i]); - for (int j=0; j<components.length; j++) { - if (components[j]!=null) - v.add(components[j]); - } - } catch (Exception e) { - e.printStackTrace(); - //handle exception - } - - } - return (IVirtualComponent[])v.toArray(new IVirtualComponent[0]); - } - - /** - * Returns the EAR components in a given IProject - * @param project - * @return empty if no EAR components; must not return null - */ - public static IVirtualComponent[] getEARComponentsFromProject(IProject project){ - //get all components in the project - List v = new ArrayList(); - try { - IVirtualComponent component = ComponentCore.createComponent(project); - if (component != null && isEARComponent(component)){ - v.add(component); - } - } - catch (Exception e){ - //handle exception - } - - return (IVirtualComponent[])v.toArray(new IVirtualComponent[0]); - } - - /** - * Returns Web components in a project - * @param project - * @return empty array if no web components; must not return null - */ - public static IVirtualComponent[] getWebComponents(IProject project){ - - //get all components in the project - List v = new ArrayList(); - try { - IVirtualComponent component = ComponentCore.createComponent(project); - - if (component != null && isWebComponent(component)){ - v.add(component); - } - - } - catch (Exception e){ - //handle exception - } - - return (IVirtualComponent[])v.toArray(new IVirtualComponent[0]); - } - - public static String[] getWebComponentNames(IProject project){ - IVirtualComponent[] vcs = getWebComponents(project); - return toComponentNamesArray(vcs); - } - - public static String[] getEARComponentNames(IProject project){ - IVirtualComponent[] vcs = getEARComponentsFromProject(project); - return toComponentNamesArray(vcs); - } - - /** - * Returns all components of type, componentType in the project. - * @param project - * @param componentType i.e. J2EEUtils.WEB - * @return - */ - public static IVirtualComponent[] getComponentsByType(IProject project, int componentType){ - - List v = new ArrayList(); - if ( (WEB & componentType)==WEB ){ - IVirtualComponent[] webVC = getWebComponents(project); - addToArrayListHelper(webVC, v); - } - if ( (EJB & componentType)==EJB ){ - IVirtualComponent[] ejbVC = getEJBComponents(project); - addToArrayListHelper(ejbVC, v); - } - if ( (APPCLIENT & componentType)==APPCLIENT ) { - IVirtualComponent[] appClientVC = getAppClientComponents(project); - addToArrayListHelper(appClientVC, v); - } - if ( (EAR & componentType)==EAR ) { - IVirtualComponent[] earVC = getEARComponentsFromProject(project); - addToArrayListHelper(earVC, v); - } - - return (IVirtualComponent[])v.toArray(new IVirtualComponent[0]); - } - - /** - * Returns all components of type, componentType in the project. - * @param project - * @param componentTypeId as defined in IModuleConstants. - * @return - */ - public static IVirtualComponent[] getComponentsByType(IProject project, String componentTypeId){ - - //get all components in the project of type componentTypeId - List v = new ArrayList(); - try { - - IVirtualComponent vc = ComponentCore.createComponent(project); - if ( vc != null && J2EEProjectUtilities.isProjectOfType(project,componentTypeId)) - { - v.add(vc); - } - //if (isWebComponent(project, components[i].getName())){ - //v.add(components[i]); - //} - - } - catch (Exception e){ - //handle exception - } - - return (IVirtualComponent[])v.toArray(new IVirtualComponent[0]); - } - - public static String[] getProjectsContainingComponentOfType(String componentTypeId) - { - Vector v = new Vector(); - IVirtualComponent[] comps = getAllComponents(); - for (int i = 0; i < comps.length; i++) { - if (J2EEProjectUtilities.isProjectOfType(comps[i].getProject(),componentTypeId)) - { - //Add the project name to the vector if it has not been added already - String name = comps[i].getProject().getName(); - if (!v.contains(name)) - { - v.add(name); - } - } - - } - - return (String[])v.toArray(new String[0]); - } - - /** - * Helper method for getComponentsByType - * @param vcs - * @param vect - */ - private static void addToArrayListHelper(IVirtualComponent[] vcs, List al){ - for (int i=0;i<vcs.length;i++){ - al.add(vcs[i]); - } - } - - - /** - * Essentially, returns all projects in the workspace - * @return - */ - public static IProject[] getAllFlexibleProjects(){ - - List v = new ArrayList(); - try { - IProject[] projects = ProjectUtilities.getAllProjects(); - for(int i=0; i<projects.length;i++) { - if (ModuleCoreNature.getModuleCoreNature(projects[i])!=null){ - v.add(projects[i]); - } - } - } - catch(Exception e){ - } - - return (IProject[])v.toArray(new IProject[0]); - } - - - /** - * True if there exists a underlying resource backing up the component and project - * @param projectName - * @param componentName - * @return - */ - public static boolean exists(String projectName, String componentName){ - IProject project = null; - if (projectName!=null && projectName.length() > 0 ) { - project = ProjectUtilities.getProject(projectName); - } - else - return false; - - return exists(project); - } - - /** - * True if there exists a underlying resource backing up the component and project - * @param project - * @return - */ - public static boolean exists(IProject project){ - if (project!=null) { - if (!project.exists()) - return false; - - IVirtualComponent vc = ComponentCore.createComponent(project); - return vc.exists(); - } - else - return false; - - } - - /** - * Returns an array of EAR components which are referenced by the component - * @param project - * @return - */ - public static IVirtualComponent[] getReferencingEARComponents(IProject project){ - List ears = new ArrayList(); - try{ - IVirtualComponent targetVC = ComponentCore.createComponent(project); - - IVirtualComponent[] earVC = getAllEARComponents(); - for (int i=0; i<earVC.length;i++) { - IVirtualReference[] refs = earVC[i].getReferences(); - for (int k=0;k<refs.length;k++) { - if (targetVC.equals(refs[k].getReferencedComponent())){ - ears.add(refs[k].getEnclosingComponent()); - } - } - } - - } - catch (Exception e){ - } - - return (IVirtualComponent[])ears.toArray(new IVirtualComponent[0]); - } - - - /** - * Returns the EJB Components referenced by the ear - * @param project - * @return - */ - public static IVirtualComponent[] getReferencingEJBComponentsFromEAR(IProject project){ - - List ejbComps = new ArrayList(); - try{ - IVirtualComponent vc = ComponentCore.createComponent(project); - IVirtualReference[] refs = vc.getReferences(); - for (int i=0;i<refs.length;i++){ - if (isEJBComponent(refs[i].getReferencedComponent())){ - ejbComps.add(refs[i].getReferencedComponent()); - } - } - } - catch(Exception e){ - } - - return (IVirtualComponent[])ejbComps.toArray(new IVirtualComponent[0]); - } - - - /** - * - * @param jar - * @return Vector of bean String names. - */ - public static Vector getBeanNames(EJBJar jar) { - // We currently only support Stateless session beans. - // List cmpBeans = jar.getBeanManagedBeans(); - // List bmpBeans = jar.getContainerManagedBeans(); - List sessionBeans = jar.getSessionBeans(); - - Vector names = new Vector(); - - // getBeanNames( names, cmpBeans ); - // getBeanNames( names, bmpBeans ); - getBeanNames(names, sessionBeans); - - return names; - } - - /** - * @param names - * specifies that vector of strings that will be used to add bean - * names to. - * @param beans - * specifies a list of beans. - */ - private static void getBeanNames(Vector names, List beans) { - Iterator iterator = beans.iterator(); - - while (iterator.hasNext()) { - EnterpriseBean bean = (EnterpriseBean) (iterator.next()); - - if (bean.isSession()) { - Session sessionBean = (Session) bean; - - if (sessionBean.getSessionType().getValue() == SessionType.STATELESS) { - names.add(bean.getName()); - } - } - } - } - - /** - * Uses jem ProjectUtilities to get the project - * @param ejb eObject - * @return IProject - */ - public static IProject getProjectFromEJB(EnterpriseBean ejb) { - return ProjectUtilities.getProject(ejb); - } - - /** - * Returns a default J2EE 1.3 EAR component in the workspace - * @return EAR component name - */ - public static IVirtualComponent getDefault13EARComponent(){ - IVirtualComponent[] allEARComponents = getAllEARComponents(); - for (int j=0;j<allEARComponents.length;j++){ - int j2eeVersion = getJ2EEVersion(allEARComponents[j]); - if (j2eeVersion == J2EEVersionConstants.J2EE_1_3_ID) - return allEARComponents[j]; - } - return null; - } - - /** - * Returns a default J2EE 1.4 EAR component in the workspace - * @return EAR component name - */ - public static IVirtualComponent getDefault14EARComponent(){ - IVirtualComponent[] allEARComponents = getAllEARComponents(); - for (int j=0;j<allEARComponents.length;j++){ - int j2eeVersion = getJ2EEVersion(allEARComponents[j]); - if (j2eeVersion == J2EEVersionConstants.J2EE_1_4_ID) - return allEARComponents[j]; - } - return null; - } - - /** - * Returns the first EAR component of the J2EE version - * @param versionId - * @return - */ - public static IVirtualComponent getEARComponentofJ2EEVersion(int versionId){ - IVirtualComponent[] components = getAllEARComponents(); - for (int i=0; i<components.length; i++){ - if (getJ2EEVersion(components[i]) == versionId) - return components[i]; - } - return null; - } - - - /** - * - * @param j2eeVersionInt - * @return - */ - public static String getLabelFromJ2EEVersion(String j2eeVersionInt) { - if (j2eeVersionInt == null || j2eeVersionInt.length() == 0) - return ""; - - int j2eeVersion = Integer.parseInt(j2eeVersionInt); - switch (j2eeVersion) { - case J2EEVersionConstants.J2EE_1_2_ID : - return J2EEVersionConstants.VERSION_1_2_TEXT; - case J2EEVersionConstants.J2EE_1_3_ID : - return J2EEVersionConstants.VERSION_1_3_TEXT; - case J2EEVersionConstants.J2EE_1_4_ID : - return J2EEVersionConstants.VERSION_1_4_TEXT; - default : - return ""; - } - } - - public static String getJ2EEVersionFromLabel(String j2eeLabel) { - String j2ee12String = String.valueOf(J2EEVersionConstants.J2EE_1_2_ID); - String j2ee13String = String.valueOf(J2EEVersionConstants.J2EE_1_3_ID); - String j2ee14String = String.valueOf(J2EEVersionConstants.J2EE_1_4_ID); - if (j2eeLabel.equals(J2EEVersionConstants.VERSION_1_2_TEXT)) - return j2ee12String; - - if (j2eeLabel.equals(J2EEVersionConstants.VERSION_1_3_TEXT)) - return j2ee13String; - - if (j2eeLabel.equals(J2EEVersionConstants.VERSION_1_4_TEXT)) - return j2ee14String; - - return ""; - - } - - /** - * Returns String representations of J2EE versions - * @param aVersion - * @return - */ - public static String getJ2EEIntVersionAsString(String aVersion) { - if (aVersion.equals(J2EEVersionConstants.VERSION_1_4_TEXT)) - return new Integer(J2EEVersionConstants.J2EE_1_4_ID).toString(); - if (aVersion.equals(J2EEVersionConstants.VERSION_1_3_TEXT)) - return new Integer(J2EEVersionConstants.J2EE_1_3_ID).toString(); - if (aVersion.equals(J2EEVersionConstants.VERSION_1_2_TEXT)) - return new Integer(J2EEVersionConstants.J2EE_1_2_ID).toString(); - // default - return new Integer(J2EEVersionConstants.J2EE_1_4_ID).toString(); - } - - // ---------------------------------------------------------------------- - - - - /** - * - * @return - * - * @deprecated // use getALLEARComponents - */ - public static IProject[] getEARProjects() { - Vector v = new Vector(); - IProject[] projects = ResourceUtils.getWorkspaceRoot().getProjects(); - for (int i = 0; i < projects.length; i++) { - try { -// if (projects[i].hasNature(IEARNatureConstants.NATURE_ID)) { - if (ResourceUtils.isEARProject(projects[i])) { - v.add(projects[i]); - } - } catch (Exception e) { - e.printStackTrace(); - //handle exception - } - - } - - return (IProject[])v.toArray(new IProject[0]); - } - - - /** - * Returns the first EAR project associated with the project and server - * @param serviceProject - * @param server - * @return - * - * @deprecated // to be simplified - */ - public static IProject getDefaultEARProject(IProject serviceProject, IServer server) { - - IProject[] earProjects = null; - IProject ear = null; - - if (serviceProject != null && serviceProject.exists()) { - try { - - boolean isWebEJBOrAppClient = ResourceUtils.isWebProject(serviceProject) //serviceProject.hasNature(IWebNatureConstants.J2EE_NATURE_ID) - || ResourceUtils.isEJBProject(serviceProject) //serviceProject.hasNature(IEJBNatureConstants.NATURE_ID) - || ResourceUtils.isAppClientProject(serviceProject);//serviceProject.hasNature(IApplicationClientNatureConstants.NATURE_ID); - if (!isWebEJBOrAppClient) { - return null; - } - - IProject[] ears = getEARProjects(); - - // separate EARs which are already deployed to the existing - // server - if (ears != null && ears.length >= 1) { - ArrayList preferredEARList = new ArrayList(); - ArrayList secondaryEARList = new ArrayList(); - for (int i = 0; i < ears.length; i++) { - ear = ears[i]; - IModule module = ResourceUtils.getModule(ear); - if (module != null) { - if (server != null - || ServerUtil.containsModule(server, - module, new NullProgressMonitor())) { - preferredEARList.add(ear); - } else { - secondaryEARList.add(ear); - } - } - } - // add secondaryEARList items to end of primary list - for (int j = 0; j < secondaryEARList.size(); j++) { - preferredEARList.add(secondaryEARList.get(j)); - } - // toArray - if (preferredEARList != null) { - earProjects = (IProject[]) preferredEARList.toArray(new IProject[0]); - } - } - } catch (Exception ce) { - ILog log = EnvironmentService.getEclipseLog(); - log.log(ILog.ERROR, 5039, J2EEUtils.class, "getEARProjects", ce); - - } - } - return earProjects[0]; - } - - /** - * Gets the EJB Components in the project - * @param project - * @return - */ - public static IVirtualComponent[] getEJBComponents(IProject project){ - - //get all components in the project - List v = new ArrayList(); - IVirtualComponent component = ComponentCore.createComponent(project); - try { - if (component != null && isEJBComponent(component)){ - v.add(component); - } - } - catch (Exception e){ - //handle exception - } - - return (IVirtualComponent[])v.toArray(new IVirtualComponent[0]); - } - - /** - * Gets the Application Client components in a project. - * @param project - * @return - */ - public static IVirtualComponent[] getAppClientComponents(IProject project){ - - //get all components in the project - List v = new ArrayList(); - try { - IVirtualComponent component = ComponentCore.createComponent(project); - - if (component != null && isAppClientComponent(component)){ - v.add(component); - } - } - catch (Exception e){ - //handle exception - } - - return (IVirtualComponent[])v.toArray(new IVirtualComponent[0]); - } - - /** - * - * @param project - * @return - */ - public static IVirtualComponent[] getReferencingEJB20ComponentsFromEAR(IProject project){ - - List ejbComps = new ArrayList(); - try{ - IVirtualComponent vc = ComponentCore.createComponent(project); - IVirtualReference[] refs = vc.getReferences(); - for (int i=0; i<refs.length;i++) { - if (isEJB20Component(refs[i].getReferencedComponent())) - ejbComps.add(refs[i].getReferencedComponent()); - } - } - catch (Exception e){ - } - - return (IVirtualComponent[])ejbComps.toArray(new IVirtualComponent[0]); - } - - - /** - * Utility method to combine two IProject[] - * @param projectArray1 - * @param projectArray2 - * @return - */ - public static IProject[] combineProjectArrays(IProject[] projectArray1, - IProject[] projectArray2) { - - // check if either or both arrays are null. - if (projectArray1 == null && projectArray2 == null) - return null; - else if (projectArray1 != null && projectArray2 == null) - return projectArray1; - else if (projectArray1 == null && projectArray2 != null) - return projectArray2; - - IProject[] combinedProjects = new IProject[projectArray1.length - + projectArray2.length]; - - System.arraycopy(projectArray1, 0, combinedProjects, 0, - projectArray1.length); - if (projectArray2.length > 0) { - System.arraycopy(projectArray2, 0, combinedProjects, - projectArray1.length, projectArray2.length); - } - - return combinedProjects; - } - - /** - * - * @param project - * @return - */ - public static IVirtualComponent[] getReferencingWebComponentsFromEAR(IProject project){ - List webComps = new ArrayList(); - try{ - IVirtualComponent vc = ComponentCore.createComponent(project); - IVirtualReference[] refs = vc.getReferences(); - for (int i=0; i<refs.length;i++) { - if (isWebComponent(refs[i].getReferencedComponent())) - webComps.add(refs[i].getReferencedComponent()); - } - } - catch(Exception e){ - } - - return (IVirtualComponent[])webComps.toArray(new IVirtualComponent[0]); - } - - - - /** - * - * @param ejbComponent - * @return - */ - public static boolean isEJB20Component(IVirtualComponent ejbComponent){ - return isEJB20Component(ejbComponent.getProject()); - } - - /** - * - * @param project - * @return - */ - public static boolean isEJB20Component(IProject project){ - boolean isEJB = false; - try { - IVirtualComponent vc = ComponentCore.createComponent(project); - if (EJBArtifactEdit.isValidEJBModule(vc)) { - EJBArtifactEdit ejbEdit = null; - try { - ejbEdit = EJBArtifactEdit.getEJBArtifactEditForRead(vc); - EJBResource ejbRes = ejbEdit.getEJBJarXmiResource(); - if (ejbRes.getModuleVersionID()== J2EEVersionConstants.EJB_2_0_ID) { - return true; - } - } - finally { - if (ejbEdit!=null) - ejbEdit.dispose(); - } - } - } - catch(Exception ex){} - - return isEJB; - } - - - /** - * Checks if the component at compName is referenced by the ear at earCompName - * @param earProject - * @param project - * @return - */ - public static boolean isComponentAssociated(IProject earProject, IProject project) { - IVirtualComponent vc1 = ComponentCore.createComponent(earProject); - IVirtualComponent vc2 = ComponentCore.createComponent(project); - return isComponentAssociated(vc1, vc2); - } - - /** - * Checks if the component is referenced by the ear - * @param ear - * @param component - * @return - */ - private static boolean isComponentAssociated(IVirtualComponent ear, IVirtualComponent component){ - boolean isAssociated = false; - - // Note: not implemented by J2EE yet.. to be used later. - IVirtualReference[] compRefs = ear.getReferences(); - if (compRefs!= null) { - for (int i=0;i<compRefs.length;i++){ - IVirtualReference vref = compRefs[i]; - if (component.equals(vref.getReferencedComponent())) - isAssociated = true; - } - } - return isAssociated; - } - - /** - * - * @param project - * @param earProject - */ - public static void associateComponentToEAR(IProject project, IProject earProject) { - - IDataModel addComponentToEARDataModel = DataModelFactory.createDataModel(new AddComponentToEnterpriseApplicationDataModelProvider()); - IVirtualComponent earComp = ComponentCore.createComponent(earProject); - addComponentToEARDataModel.setProperty(ICreateReferenceComponentsDataModelProperties.SOURCE_COMPONENT, earComp); - List modList = (List) addComponentToEARDataModel.getProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST); - IVirtualComponent targetComp = ComponentCore.createComponent(project); - modList.add(targetComp); - addComponentToEARDataModel.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST, modList); - - try { - addComponentToEARDataModel.getDefaultOperation().execute(null, null); - } catch (ExecutionException e) { - Logger.getLogger().log(e); - } - - } - - - - - /** - * @param project - * @return - */ - public static IPath getWebInfPath(IProject project){ - - IVirtualComponent component = ComponentCore.createComponent(project); - IVirtualFolder webInfDir = component.getRootFolder().getFolder(new Path("/WEB-INF")); - IPath modulePath = webInfDir.getWorkspaceRelativePath(); - - return modulePath; - } - - - /** - * - * @param project - * @return - * - */ - public static IPath getFirstWebContentPath(IProject project){ - - IPath modulePath = null; - try { - IVirtualComponent vc = ComponentCore.createComponent(project); - if (ModuleCoreNature.isFlexibleProject(project)) { - modulePath = vc.getRootFolder().getWorkspaceRelativePath(); - } - } - catch(Exception ex){} - - return modulePath; - } - - /** - * @param project - * @return - */ - public static IPath getWebContentPath(IProject project){ - IVirtualComponent component = ComponentCore.createComponent(project); - IPath modulePath = component.getRootFolder().getWorkspaceRelativePath(); - return modulePath; - } - - /** - * - * @param project - * @return - * - */ - public static IContainer getFirstWebContentContainer(IProject project){ - IContainer container = null; - IPath modulePath = getFirstWebContentPath(project); - IResource res = ResourceUtils.findResource(modulePath); - if (res!=null){ - container = res.getParent(); - } - - return container; - } - - /** - * @param project - * @return - */ - public static IContainer getWebContentContainer(IProject project){ - IContainer container = null; - IPath modulePath = getWebContentPath(project); - IResource res = ResourceUtils.findResource(modulePath); - if (res instanceof IContainer){ - container = (IContainer)res; - } - return container; - } - - - /** - * Returns the first Module name - * @param project - * @return - * - */ - public static String getFirstWebModuleName(IProject project){ - String moduleName = null; - try { - IVirtualComponent vc = ComponentCore.createComponent(project); - moduleName = vc.getName(); - } - catch(Exception ex){} - - return moduleName; - } - - - public static boolean isWebComponent(IVirtualComponent comp){ - return J2EEProjectUtilities.isDynamicWebProject(comp.getProject()); - } - - public static boolean isEARComponent(IVirtualComponent comp){ - return J2EEProjectUtilities.isEARProject(comp.getProject()); - } - - /** - * True if the component is a valid EJB component - * @param project - * @return - */ - public static boolean isEJBComponent(IProject project) { - IVirtualComponent vc = ComponentCore.createComponent(project); - return isEJBComponent(vc); - } - - public static boolean isEJBComponent(IVirtualComponent comp){ - return J2EEProjectUtilities.isEJBProject(comp.getProject()); - } - - public static boolean isAppClientComponent(IVirtualComponent comp){ - return J2EEProjectUtilities.isApplicationClientProject(comp.getProject()); - } - - public static boolean isJavaComponent(IVirtualComponent comp){ - return J2EEProjectUtilities.isUtilityProject(comp.getProject()); - } - - public static String getComponentTypeId(IProject project) { - return J2EEProjectUtilities.getJ2EEProjectType(project); - } - - public static String[] toComponentNamesArray(IVirtualComponent[] components){ - String[] ecNames = new String[components.length]; - for(int i=0; i<components.length; i++){ - ecNames[i] = components[i].getName(); - } - return ecNames; - } - - public static IProject[] toProjectArray(IVirtualComponent[] components){ - IProject[] projects = new IProject[components.length]; - for (int i=0; i<components.length; i++){ - projects[i] = components[i].getProject(); - } - return projects; - } - - /** - * Given a J2EE level, this method returns the highest supported servlet level - * @param j2eeLevel - * @return web app version - */ - public static Integer getServletVersionForJ2EEVersion(String j2eeLevel){ - int aVersion = Integer.valueOf(j2eeLevel).intValue(); - switch (aVersion) { - case J2EEVersionConstants.J2EE_1_2_ID: - return new Integer(J2EEVersionConstants.WEB_2_2_ID); - - case J2EEVersionConstants.J2EE_1_3_ID: - return new Integer(J2EEVersionConstants.WEB_2_3_ID); - - case J2EEVersionConstants.J2EE_1_4_ID: - return new Integer(J2EEVersionConstants.WEB_2_4_ID); - - default: - return new Integer(J2EEVersionConstants.WEB_2_3_ID); - } - } - - /** - * Given a J2EE level, this method returns the highest supported EJB version - * @param j2eeLevel - * @return ejb spec version - */ - public static Integer getEJBVersionForJ2EEVersion(String j2eeLevel){ - int aVersion = Integer.valueOf(j2eeLevel).intValue(); - switch (aVersion) { - case J2EEVersionConstants.J2EE_1_2_ID: - return new Integer(J2EEVersionConstants.EJB_1_1_ID); - - case J2EEVersionConstants.J2EE_1_3_ID: - return new Integer(J2EEVersionConstants.EJB_2_0_ID); - - case J2EEVersionConstants.J2EE_1_4_ID: - return new Integer(J2EEVersionConstants.EJB_2_1_ID); - - default: - return new Integer(J2EEVersionConstants.EJB_2_0_ID); - } - } - - /** - * True if the component is a valid Java component - * @param project - * @return - */ - public static boolean isJavaComponent(IProject project) { - IVirtualComponent vc = ComponentCore.createComponent(project); - return isJavaComponent(vc); - } - - /** - * True if the component is a valid Web component - * @param project - * @return - */ - public static boolean isWebComponent(IProject project) { - IVirtualComponent vc = ComponentCore.createComponent(project); - return isWebComponent(vc); - } - - /** - * True if the component is a true Application client component - * @param project - * @return - */ - public static boolean isAppClientComponent(IProject project) { - IVirtualComponent vc = ComponentCore.createComponent(project); - return isAppClientComponent(vc); - } - - /** - * True is the component is a valid EAR component - * @param project - * @return - */ - public static boolean isEARComponent(IProject project){ - IVirtualComponent vc = ComponentCore.createComponent(project); - return isEARComponent(vc); - } - - public static IFolder getOutputContainerRoot (IVirtualComponent component) { - return (IFolder)J2EEProjectUtilities.getOutputContainers(component.getProject())[0]; - } - -} diff --git a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/common/JavaMOFUtils.java b/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/common/JavaMOFUtils.java deleted file mode 100644 index f883dd34c..000000000 --- a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/common/JavaMOFUtils.java +++ /dev/null @@ -1,248 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 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 - *******************************************************************************/ - -package org.eclipse.jst.ws.internal.common; - -import java.util.Iterator; -import java.util.List; -import java.util.Vector; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jem.util.emf.workbench.nature.EMFNature; -import org.eclipse.jem.workbench.utility.JemProjectUtilities; -import org.eclipse.jem.java.JavaClass; -import org.eclipse.jem.java.JavaRefFactory; -import org.eclipse.jem.java.JavaVisibilityKind; -import org.eclipse.jem.java.Method; - -/** -* This class contains some useful utilities for dealing with the JavaMOF -*/ - -public final class JavaMOFUtils -{ - /** - * Determine whether this class of the given name is loadable in the given - * project. - * @param className The fully qualified name of the class - * @param project The project - * @return True if the class is loadable and no exceptions are thrown. - */ - public static boolean isClassLoadable(String className, IProject project) throws CoreException - { - return isClassLoadable(getJavaClass(className,project)); - } - - public static boolean isClassLoadable(JavaClass javaClass) - { - return javaClass.isExistingType(); - } - - /** - * Determine whether the specified class has a public constructor - * with an empty parameter list. - * @param className The fully qualified name of the class - * @param project The project - * @return True if the class is loadable from the project and the - * class has a public constructor with an empty parameter list - */ - public static boolean hasPublicDefaultCtor(String className, IProject project) throws CoreException - { - return hasPublicDefaultCtor(getJavaClass(className, project)); - } - - - public static boolean hasPublicDefaultCtor(JavaClass javaClass) - { - - List methodList = javaClass.getMethods(); - if (methodList==null) - return true; - - Iterator iMethods = methodList.iterator(); - boolean userDefinedCtor = false; - while (iMethods.hasNext()) - { - Method thisMethod = (Method)iMethods.next(); - - if (thisMethod.isConstructor()) - { - userDefinedCtor = true; - - //Since the user has defined a ctor, the default ctor is no longer available. - //We must ensure that the user has provided a public ctor with no parameters. - - //check if public - if (thisMethod.getJavaVisibility().getValue() == JavaVisibilityKind.PUBLIC) - { - //see if parameter list is empty - List paramList = thisMethod.getParameters(); - if (paramList.isEmpty() ) - { - return true; - } - } - } - - } - - if (userDefinedCtor) - { - return false; //if the user defined a ctor and we still haven't - //returned true, none of them were public with no parameters. - } - else - { - return true; - } - - } - /** - * Determine whether the specified class implements the specified interface. - * @param className The fully qualified name of the class - * @param interfaceName The fully qualified name of the interface - * @param project The project - * @return True if the class and interface are loadable from the project and - * the class implements the interface. - */ - public static boolean implementsInterface(String className, String interfaceName, IProject project) - throws CoreException - { - return implementsInterface(getJavaClass(className, project), getJavaClass(interfaceName, project)); - } - -public static boolean implementsInterface(JavaClass javaClass, JavaClass interfaceClass) - { - - if (!javaClass.isExistingType()) return false; - - if (!interfaceClass.isExistingType()) return false; - - return javaClass.implementsInterface(interfaceClass); - } - - /** - * Determine whether the specified class extends the specified superclass - * @param className The fully qualified name of the class - * @param superClassName The fully qualified name of the superclass - * @param project The project - * @return True if the class and superClass are loadable from the project and - * the class extends the superClass - */ - public static boolean extendsClass(String className, String superClassName, IProject project) - throws CoreException - { - return extendsClass(getJavaClass(className,project), getJavaClass(superClassName, project)); - } - - public static boolean extendsClass(JavaClass javaClass, JavaClass superClass) - { - return superClass.isAssignableFrom(javaClass); - } - - /** - * Determine whether the specified class is actually an interface - * @param className The fully qualified name of the class - * @param project The project - * @return True if the class is loadable from the project and is - * actually an interface - */ - public static boolean isInterface(String className, IProject project) throws CoreException - { - return isInterface(getJavaClass(className, project)); - } - - public static boolean isInterface(JavaClass javaClass) - { - return javaClass.isInterface(); - } - public static boolean hasAbstractMethods (String className, IProject project) throws CoreException - { - return hasAbstractMethods(getJavaClass(className, project)); - } - - public static boolean hasAbstractMethods (JavaClass javaClass) - { - List methodList = javaClass.getMethods(); - if (methodList==null) - return false; - - Iterator iMethods = methodList.iterator(); - while (iMethods.hasNext()) - { - Method thisMethod = (Method)iMethods.next(); - if ( thisMethod.isAbstract()) return true; - } - return false; - } - - /* - * - */ - /** - * @param classQName Fully qualified classname (packageName + typeName) - * @param project - * @return - * @throws CoreException - */ -public static JavaClass getJavaClass(String classQName , IProject project) throws CoreException - { - EMFNature jMOF = JemProjectUtilities.getJEM_EMF_Nature(project, true); - return (JavaClass)JavaRefFactory.eINSTANCE.reflectType(classQName,jMOF.getResourceSet()); - } - - /** - * @param packageName - * @param typeName - * @param project - * @return - * @throws CoreException - */ -public static JavaClass getJavaClass(String packageName, String typeName , IProject project) throws CoreException - { - EMFNature jMOF = JemProjectUtilities.getJEM_EMF_Nature(project, true); - return (JavaClass)JavaRefFactory.eINSTANCE.reflectType(packageName, typeName, jMOF.getResourceSet()); - } - - public static boolean isValidSEIFile(JavaClass beanClass, JavaClass seiClass) - { - if (!seiClass.isInterface()) - return false; - - Vector beanMethodsList = new Vector(); - List beanMethods = beanClass.getMethods(); - Iterator beanMethodsIterator = beanMethods.iterator(); - while (beanMethodsIterator.hasNext()) - { - Method thisMethod = (Method)beanMethodsIterator.next(); - beanMethodsList.add(thisMethod.getMethodElementSignature()); - } - - List seiMethods = seiClass.getMethods(); - if (beanMethods == null ) { - if ( seiMethods == null) return true; - else return false; - } - if (seiMethods == null) return false; - - Iterator seiMethodsIterator = seiMethods.iterator(); - while (seiMethodsIterator.hasNext()) - { - Method thisMethod = (Method)seiMethodsIterator.next(); - if ( !beanMethodsList.contains(thisMethod.getMethodElementSignature())) { - return false; - } - } - return true; - - } - -} diff --git a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/common/ResourceUtils.java b/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/common/ResourceUtils.java deleted file mode 100644 index d09436a04..000000000 --- a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/common/ResourceUtils.java +++ /dev/null @@ -1,1850 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 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 - *******************************************************************************/ -package org.eclipse.jst.ws.internal.common; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.URL; -import java.net.URLEncoder; -import java.util.ArrayList; -import java.util.Enumeration; -import java.util.List; -import java.util.Vector; - -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.ResourcesPlugin; -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.NullProgressMonitor; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Plugin; -import org.eclipse.core.runtime.Status; -import org.eclipse.jdt.core.IClasspathEntry; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.IPackageFragment; -import org.eclipse.jdt.core.IPackageFragmentRoot; -import org.eclipse.jdt.core.JavaConventions; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.jst.j2ee.applicationclient.componentcore.util.AppClientArtifactEdit; -import org.eclipse.jst.j2ee.componentcore.util.EARArtifactEdit; -import org.eclipse.jst.j2ee.ejb.EnterpriseBean; -import org.eclipse.jst.j2ee.ejb.componentcore.util.EJBArtifactEdit; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; -import org.eclipse.jst.ws.internal.plugin.WebServicePlugin; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.internal.StructureEdit; -import org.eclipse.wst.common.componentcore.internal.WorkbenchComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualFolder; -import org.eclipse.wst.common.componentcore.resources.IVirtualResource; -import org.eclipse.wst.common.environment.EnvironmentService; -import org.eclipse.wst.common.environment.ILog; -import org.eclipse.wst.server.core.IModule; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.core.ServerUtil; -import org.eclipse.wst.server.core.model.IURLProvider; - -/** - * This class contains useful methods for working with Eclipse resources. - */ -public final class ResourceUtils { - - // Keeps the IWorkspaceRoot hanging around. See getWorkspaceRoot(). - private static IWorkspaceRoot root_ = null; - - // Keeps the IWorkspace hanging around. See getWorkspace(). - - private static IWorkspace workspace_ = null; - - /** - * As returned by {@link #getProjectType getProjectType()}, indicates that - * the given project has no Java or Web nature. - */ - public static byte PROJECT_TYPE_NONE = 0; - - /** - * As returned by {@link #getProjectType getProjectType()}, indicates that - * the given project has a Java project nature. - */ - public static byte PROJECT_TYPE_JAVA = 1; - - /** - * As returned by {@link #getProjectType getProjectType()}, indicates that - * the given project has a Web project nature. - */ - public static byte PROJECT_TYPE_WEB = 2; - - /** - * As returned by {@link #getProjectType getProjectType()}, indicates that - * the given project has an EJB project nature. - */ - public static byte PROJECT_TYPE_EJB = 4; - - /** - * As returned by {@link #getProjectType getProjectType()}, indicates that - * the given project has an Application client project nature. - */ - public static byte PROJECT_TYPE_APPCLIENT = 8; - - /** - * The SOAP rpcrouter servlet extension to be added to web project URL - */ - public static String SERVLET_EXT = "/servlet/rpcrouter"; - - private static final String DEFAULT_CLIENT_WEB_PROJECT_EXT = "Client"; - private static final String DEFAULT_CLIENT_EJB_PROJECT_EXT = "EJBClient"; - private static final String DEFAULT_EJB_PROJECT_NAME = "WebServiceEJBProject"; - private static final String DEFAULT_EJB_COMPONENT_NAME = "WebServiceEJB"; - private static final String DEFAULT_WEB_PROJECT_NAME = "WebServiceProject"; - private static final String DEFAULT_WEB_COMPONENT_NAME = "WebServiceProject"; - private static final String DEFAULT_ROUTER_PROJECT_EXT = "Router"; - - private static final String DEFAULT_SERVICE_EAR_PROJECT_NAME = "WebServiceProjectEAR"; - private static final String DEFAULT_SERVICE_EAR_COMPONENT_NAME = "WebServiceProjectEAR"; - private static final String DEFAULT_CLIENT_EAR_PROJECT_NAME = "WebServiceProjectClientEAR"; - private static final String DEFAULT_CLIENT_EAR_COMPONENT_NAME = "WebServiceProjectClientEAR"; - - /** - * Returns the IWorkspaceRoot object. - * @return The IWorkspaceRoot object. - */ - public static IWorkspaceRoot getWorkspaceRoot() { - if (root_ == null) { - root_ = ResourcesPlugin.getWorkspace().getRoot(); - } - return root_; - } - - /** - * Returns the IWorkspace object. - * @return The IWorkspace object. - */ - public static IWorkspace getWorkspace() { - if (workspace_ == null) { - if (root_ == null) { - root_ = ResourcesPlugin.getWorkspace().getRoot(); - } - workspace_ = root_.getWorkspace(); - } - return workspace_; - } - - /** - * Returns an {@link org.eclipse.core.resources.IResource IResource}of the - * given absolute pathname or null if no such resource exists. - * - * @param absolutePathname - * The absolute path of the resource. - * @return The <code>IResource</code>. - */ - public static IResource findResource(String absolutePathname) { - if (absolutePathname == null) { - return null; - } - return findResource(new Path(absolutePathname)); - } - - /** - * Returns an {@link org.eclipse.core.resources.IResource IResource}of the - * given absolute path or null if no such resource exists. - * - * @param absolutePath - * The absolute <code>IPath</code> of the resource. - * @return The <code>IResource</code>. - */ - public static IResource findResource(IPath absolutePath) { - if (absolutePath == null) { - return null; - } - return ResourceUtils.getWorkspaceRoot().findMember(absolutePath); - } - - /** - * Validates the given string as a name for a resource of the given type(s). - * This method obeys the contract of - * {@link org.eclipse.core.resources.IWorkspace#validateName IWorkspace.validateName()}. - * - * @param segment - * The path to validate. - * @param typeMask - * The <code>IResource</code> type or types. - * @return The status with a value if <code>IStatus.OK</code> if the path - * is valid, or with appropriate severity and message information if - * the path is not valid. - * - * @deprecated not used - */ - public static IStatus validateName(String segment, int typeMask) { - return getWorkspace().validateName(segment, typeMask); - } - - /** - * Validates the given string as the path of a resource of the given - * type(s). This method obeys the contract of - * {@link org.eclipse.core.resources.IWorkspace#validatePath IWorkspace.validatePath()}. - * - * @param path - * The path to validate. - * @param typeMask - * The <code>IResource</code> type or types. - * @return The status with a value if <code>IStatus.OK</code> if the path - * is valid, or with appropriate severity and message information if - * the path is not valid. - * @deprecated not used - */ - public static IStatus validatePath(String path, int typeMask) { - return getWorkspace().validatePath(path, typeMask); - } - - /** - * Validates the given Java type name. - * - * @param typeName - * The Java type name. - * @return The status with a value of <code>IStatus.OK</code> if the name - * is valid, or with appropriate severity and message information if - * name is not valid. The primitive types (boolean, char, byte, - * short, int, long, float, double) are valid. Arrays of valid types - * are themselves valid. - * @deprecated use JavaConventions in the jdt core - */ - public static IStatus validateJavaTypeName(String typeName) { - // - // Strip off the trailing array bits, if any. - // - int a = typeName.indexOf('['); - if (a > 0) { - typeName = typeName.substring(0, a); - } - // - // Allow primitives. - // - if (isPrimitiveJavaType(typeName)) { - return new Status(IStatus.OK, WebServicePlugin.ID, 0, "", null); - } - // - // Defer to JavaConventions. - // - return JavaConventions.validateJavaTypeName(typeName); - } - - /** - * Returns true if the given <code>typeName</code> is a Java primitive - * (boolean, char, byte, short, int, long, float, double). - * - * @return True if the type name is a Java primitive. - * - * @deprecated - */ - public static boolean isPrimitiveJavaType(String typeName) { - return (typeName.equals("boolean") || typeName.equals("char") - || typeName.equals("byte") || typeName.equals("short") - || typeName.equals("int") || typeName.equals("long") - || typeName.equals("float") || typeName.equals("double")); - } - - /** - * Returns the handle of the IProject at the beginning of the given - * <code>absolutePath</code>. Neither the given path nor the project need - * exist in the workspace. The path must be absolute, and must consist of at - * least one segment. - * - * @return An IProject handle for the project at the beginning of the given - * <code>absolutePath</code>, or null if the path does not - * specify a project. - */ - public static IProject getProjectOf(IPath absolutePath) { - if (absolutePath.isAbsolute()) { - String projectName = absolutePath.segment(0); - if (projectName != null) { - return getWorkspaceRoot().getProject(projectName); - } - } - return null; - } - - /** - * - * @param absolutePath - * @return - */ - public static IVirtualComponent getComponentOf(IPath absolutePath){ - if (absolutePath.isAbsolute()) { - String projectName = absolutePath.segment(0); - IProject project = getWorkspaceRoot().getProject(projectName); - if (projectName != null) { - return ComponentCore.createComponent(project); - } - } - return null; - } - - public static IVirtualComponent getComponentOf(IResource res) - { - IVirtualResource[] vresources = ComponentCore.createResources(res); - IVirtualComponent vcomp = null; - if (vresources != null && vresources.length>0) - { - IVirtualResource vres = vresources[0]; - vcomp = vres.getComponent(); - } - return vcomp; - } - - - /** - * Returns true if the given <code>project</code> is a Java Project. - * - * @param project - * The project. - * @return True if the project is a Java Project. - */ - public static boolean isJavaProject(IProject project) { - return (JavaCore.create(project) != null); - } - - /** - * Returns true if the given <code>project</code> is a Java Project. - * - * @param project - * The project. - * @return True if the project is a Java Project. - */ - public static boolean isTrueJavaProject(IProject project) { - return (!isWebProject(project) && !isAppClientProject(project) && !isEARProject(project) - && !isEJBProject(project) && isJavaProject(project)); - /* - * try { String[] natures = project.getDescription().getNatureIds(); - * return (natures.length == 1 && - * natures[0].equals(JavaCore.NATURE_ID)); } catch (CoreException e) { } - * return false; - */ - } - - /** - * Returns true if the given <code>project</code> is a Web Project. - * Note: For components; use J2EEUtils.isWebComponent() - * @param project - * The project. - * @return True if the project is a Web Project. - * - * @deprecated - */ - public static boolean isWebProject(IProject project) { - boolean isWeb = false; - StructureEdit mc = null; - try { - mc = StructureEdit.getStructureEditForRead(project); - WorkbenchComponent[] wbcs = mc.getWorkbenchModules(); - if (wbcs.length!=0) { - //isWeb = WebArtifactEdit.isValidWebModule(wbcs[0]); - } - } - catch(Exception ex){ - // handle exception - } - finally{ - if (mc!=null) - mc.dispose(); - } - - return isWeb; - } - - /** - * Note: for components; use J2EEUtils.isEARComponent() - * @param project - * @return - * - * @deprecated - */ - public static boolean isEARProject(IProject project){ - boolean isEAR = false; - StructureEdit mc = null; - try { - mc = StructureEdit.getStructureEditForRead(project); - WorkbenchComponent[] wbcs = mc.getWorkbenchModules(); - if (wbcs.length!=0) { - EARArtifactEdit earEdit = null; - try { - //earEdit = EARArtifactEdit.getEARArtifactEditForRead(wbcs[0]); - if (earEdit!=null){ - isEAR = true; - } - } - finally{ - if (earEdit!=null) - earEdit.dispose(); - } - } - } - catch(Exception ex){} - finally{ - if (mc!=null) - mc.dispose(); - } - - return isEAR; - } - /** - * Returns true if the given <code>project</code> is an EJB 1.1 or EJB 2.0 - * Project. - * Note: for components, use J2EEUtils.isEJBComponent - * @param project - * The project. - * @return True if the project is an EJB 1.1 or an EJB 2.0 Project. - * - * @deprecated - * - */ - public static boolean isEJBProject(IProject project) { - boolean isEJB = false; - StructureEdit mc = null; - try { - mc = StructureEdit.getStructureEditForRead(project); - WorkbenchComponent[] wbcs = mc.getWorkbenchModules(); - if (wbcs.length!=0) { - EJBArtifactEdit ejbEdit = null; - try { - //ejbEdit = EJBArtifactEdit.getEJBArtifactEditForRead(wbcs[0]); - if (ejbEdit!=null){ - isEJB = true; - } - } - finally{ - if (ejbEdit!=null) - ejbEdit.dispose(); - } - } - } - catch(Exception ex){} - finally{ - if (mc!=null) - mc.dispose(); - } - - return isEJB; - } - - /** - * Returns true if the given <code>project</code> is an Application Client - * Project. - * Note: for components, use J2EEUtils.isAppClientComponent() - * @param project - * The project. - * @return True if the project is an Application Client Project - * - * @deprecated - */ - public static boolean isAppClientProject(IProject project) { - boolean isAppClient = false; - StructureEdit mc = null; - try { - mc = StructureEdit.getStructureEditForRead(project); - WorkbenchComponent[] wbcs = mc.getWorkbenchModules(); - if (wbcs.length!=0) { - AppClientArtifactEdit appClientEdit = null; - try { - //appClientEdit = AppClientArtifactEdit.getAppClientArtifactEditForRead(wbcs[0]); - if (appClientEdit!=null){ - isAppClient = true; - } - } - finally{ - if (appClientEdit!=null) - appClientEdit.dispose(); - } - } - } - catch(Exception ex){} - finally{ - if (mc!=null) - mc.dispose(); - } - - return isAppClient; - } - - /** - * Returns the type of the given <code>project</code> as a bitmask. - * Relevant bitmask values are: - * <ol> - * <li>{@link #PROJECT_TYPE_JAVA PROJECT_TYPE_JAVA} - * <li>{@link #PROJECT_TYPE_WEB PROJECT_TYPE_WEB} - * <li>{@link #PROJECT_TYPE_EJB PROJECT_TYPE_EJB} - * <li>{@link #PROJECT_TYPE_NONE PROJECT_TYPE_NONE} - * </ol> - * - * @param project - * The project. - * @return The type bitmask of the project. - * - * @deprecated use getComponentType - */ - public static byte getProjectType(IProject project) { - byte projectType = PROJECT_TYPE_NONE; - if (ResourceUtils.isJavaProject(project)) { - projectType |= PROJECT_TYPE_JAVA; - } - if (ResourceUtils.isWebProject(project)) { - projectType |= PROJECT_TYPE_WEB; - } - if (ResourceUtils.isEJBProject(project)) { - projectType |= PROJECT_TYPE_EJB; - } - return projectType; - } - - /** - * Returns the component type id as defined in IModuleConstants - * i.e. IModuleConstants.JST_WEB_MODULE = "jst.web" - * @param project - * @return - */ - public static String getComponentType(IProject project){ - return J2EEProjectUtilities.getJ2EEProjectType(project); - } - - /** - * Returns the component type - * @param component - * @return - */ - public static String getComponentType(IVirtualComponent component){ - return getComponentType(component.getProject()); - } - - /** - * - * @param project - * @return - * - * @deprecated not used - */ - public static String getProjectTypeAsString(IProject project) { - if (ResourceUtils.isEJBProject(project)) - return WebServicePlugin.getMessage("%LABEL_EJB"); - else if (ResourceUtils.isWebProject(project)) - return WebServicePlugin.getMessage("%LABEL_WEB"); - else if (ResourceUtils.isJavaProject(project)) - return WebServicePlugin.getMessage("%LABEL_JAVA"); - else - return ""; - } - - - /** - * Returns WebModule Deployable of the <code>project</code> as an - * <code>IDeployable</code>, or null if the project has no Web nature. - * - * @param project - * The project. - * @return WebModule Deployable of the <code>project</code> or null if the - * project has no Web nature. - */ - public static IModule getModule(IProject project) { - return ServerUtil.getModule(project); -} - -// Workaround for 113621 -//public static IModule getModule(IProject project) { -// IModule[] modules = ServerUtil.getModules(project); -// if (modules!=null && modules.length!=0) { -// return modules[0]; -// } -// return null; -//} - - /** - * Returns the build output location of the <code>project</code> as an - * <code>IPath</code>, or null if the project has no Java nature. - * i.e. WP\.deployables\webModule\WEB-INF\classes - * @param project - * The project. - * @return The build output location of the <code>project</code> or null - * if the project has no Java nature. - * @deprecated not used - */ - public static IPath getJavaOutputLocation(IProject project) { - IPath outputLocation = null; - try { - IJavaProject javaProject = JavaCore.create(project); - if (javaProject != null) { - outputLocation = javaProject.getOutputLocation(); - } - } catch (JavaModelException e) { - } - ILog log = EnvironmentService.getEclipseLog(); - log.log(ILog.INFO, 5032, ResourceUtils.class, "getJavaOutputLocation", - "project=" + project + ",outputLocation=" + outputLocation); - - return outputLocation; - } - - /** - * Returns a build source location of the <code>project</code> as an - * <code>IPath</code>, or null if the project either has no Java nature - * or if the project's build classpath contains no folders local to the - * project. If the project has more than one of its own folders on the build - * classpath, then one of them is chosen arbitrarily as the build source - * location. To work with all entries on the build classpath, use - * {@link #getJavaPackageFragmentRoots getJavaPackageFragmentRoots()}or - * {@link #getJavaClasspath getJavaClasspath()}. - * - * @param project - * The project. - * @return A build source location of the <code>project</code> or null if - * the project has no Java nature or if the project's build - * classpath contains no folders local to the project. - * @deprecated use getJavaSourceLocation(IProject project, String compName) - */ -/* - public static IPath getJavaSourceLocation(IProject project) { - IPath sourceLocation = null; - IPackageFragmentRoot[] fragmentRoots = getJavaPackageFragmentRoots(project); - for (int i = 0; i < fragmentRoots.length && sourceLocation == null; i++) { - try { - IResource fragmentRoot = fragmentRoots[i] - .getCorrespondingResource(); - if (fragmentRoot != null - && (fragmentRoot.getProject().equals(project)) - && (fragmentRoot.getType() != IResource.FILE)) { - sourceLocation = fragmentRoot.getFullPath(); - } - } catch (JavaModelException e) { - } - } - - ILog log = EnvironmentService.getEclipseLog(); - log.log(ILog.INFO, 5030, ResourceUtils.class, "getJavaSourceLocation", - "project=" + project + ",sourceLocation=" + sourceLocation); - - return sourceLocation; - } -*/ - - /** - * Returns the "JavaSource" folder - * @param project - * @return - */ - public static IPath getJavaSourceLocation(IProject project){ - IVirtualComponent component = ComponentCore.createComponent(project); - return getJavaSourceLocation(component); - } - - /** - * Returns the JavaSource location folder - * @param comp - * @return - */ - public static IPath getJavaSourceLocation(IVirtualComponent comp){ - if (comp!=null){ - IVirtualFolder folder = comp.getRootFolder().getFolder(new Path("/WEB-INF/classes")); - return folder.getWorkspaceRelativePath(); - } - return null; - } - - /** - * Returns the JavaSource locations in each project - * @param project - * @return - */ - public static IPath[] getAllJavaSourceLocations(IProject project) { - Vector pathVector = new Vector(); - IPackageFragmentRoot[] fragmentRoots = getJavaPackageFragmentRoots(project); - - for (int i = 0; i < fragmentRoots.length; i++) { - try { - IResource fragmentRoot = fragmentRoots[i].getCorrespondingResource(); - if (fragmentRoot != null && (fragmentRoot.getProject().equals(project)) - && (fragmentRoot.getType() != IResource.FILE)) { - pathVector.add(fragmentRoot.getFullPath()); - } - } catch (JavaModelException e) { - } - } - return (IPath[]) pathVector.toArray(new Path[pathVector.size()]); - } - - public static IPath[] getAllJavaSourceLocations(IVirtualComponent[] components) { - - if (components!=null){ - List javaSourcePaths = new ArrayList(); - for (int i=0;i<components.length;i++){ - IPath path = getJavaSourceLocation(components[i]); - javaSourcePaths.add(path); - } - return (IPath[])javaSourcePaths.toArray(new IPath[0]); - } - return null; - } - - /** - * Returns a build source package fragment root of the <code>project</code> - * as an <code>IPackageFragmentRoot</code>, or null if the project either - * has no Java nature or if the project's build classpath contains no - * folders local to the project. If the project has more than one of its own - * folders on the build classpath, then one of them is chosen arbitrarily as - * the build source location. - * - * @param project - * The project. - * @return A build source package fragment root of the <code>project</code> - * or null if the project has no Java nature or if the project's - * build classpath contains no folders local to the project. - * - * @deprecated not used - */ - public static IPackageFragmentRoot getJavaSourcePackageFragmentRoot(IProject project) { - IPackageFragmentRoot packageFragmentRoot = null; - IPath javaSourceLocation = getJavaSourceLocation(project); - try { - IJavaProject javaProject = JavaCore.create(project); - if (javaProject != null) { - packageFragmentRoot = javaProject.findPackageFragmentRoot(javaSourceLocation); - } - } catch (JavaModelException e) { - } - return packageFragmentRoot; - } - - /** - * Returns the package fragment roots of the <code>project</code> as an - * array of <code>IPackageFragmentRoot</code> objects. If the project has - * no Java nature then the returned array will be of length zero. - * - * @param project - * The project. - * @return The package fragment roots of the <code>project</code>. - */ - public static IPackageFragmentRoot[] getJavaPackageFragmentRoots(IProject project) { - try { - IJavaProject javaProject = JavaCore.create(project); - if (javaProject != null) { - IPackageFragmentRoot[] packageFragmentRoots = javaProject - .getPackageFragmentRoots(); - return packageFragmentRoots; - } - } catch (JavaModelException e) { - } - return new IPackageFragmentRoot[0]; - } - - /** - * Returns the build classpath entries of the <code>project</code> as an - * array of <code>IClasspathEntry</code> objects. If the project has no - * Java nature then the returned array will be of length zero. - * - * @param project - * The project. - * @return The classpath entries of the <code>project</code>. - * - * @deprecated not used - */ - public static IClasspathEntry[] getJavaClasspath(IProject project) { - try { - IJavaProject javaProject = JavaCore.create(project); - if (javaProject != null) { - IClasspathEntry[] classpathEntries = javaProject.getRawClasspath(); - return classpathEntries; - } - } catch (JavaModelException e) { - } - return new IClasspathEntry[0]; - } - - /** - * - * @param project - * @return - */ - public static IFolder getWebComponentServerRoot(IProject project){ - - IFolder webModuleServerRoot = null; - IVirtualComponent vc = ComponentCore.createComponent(project); - if (vc.exists()) - webModuleServerRoot = J2EEUtils.getOutputContainerRoot(vc); - - return webModuleServerRoot; - } - - /** - * Returns the URL string corresponding to the web server module root of the - * project in a server instance or null if the project has no Web nature or - * has no association to a server instance. - * - * @param project - * The project. - * @return The web server module root URL or null if the project has no Web - * nature or has no association to a server instance. - * @deprecated use getWebComponentURL(..) which belongs in ServerUtils - */ - public static String getWebProjectURL(IProject project, - String serverFactoryId, IServer server) { - - String webProjectURL = null; - IModule module = getModule(project); - if (module != null) { - IServer serverInstance = ServerUtils.getServerForModule(module, - serverFactoryId, server, true, new NullProgressMonitor()); - if (serverInstance != null) { -// URL url = ((IURLProvider) serverInstance.getDelegate()).getModuleRootURL(module); - URL url = ((IURLProvider)serverInstance.getAdapter(IURLProvider.class)).getModuleRootURL(module); - if (url != null) { - String s = url.toString(); - webProjectURL = (s.endsWith("/") ? s.substring(0, s - .length() - 1) : s); - } - } - } - - ILog log = EnvironmentService.getEclipseLog(); - log.log(ILog.INFO, 5036, ResourceUtils.class, "getWebProjectURL", - "project=" + project + ",webProjectURL=" + webProjectURL); - - return webProjectURL; - } - - /** - * Returns the forged URL string corresponding to the web server module root - * of the project in a server instance or null if the project has no Web - * nature or has no association to a server instance. - * - * @param project - * @return The web server module root URL or null if the project has no Web - * nature or has no association to a server instance. - * @deprecated not used - */ -// public static String getForgedWebProjectURL(IProject project, String serverFactoryId, IServer server){ -// -// String webProjectURL = null; -// IModule module = getModule(project); -// if (module != null) -// { -// //IServer serverInstance = ServerUtils.getServerForModule(module, -// // serverFactoryId, server, true, new NullProgressMonitor()); -// if (server != null) -// { -// String hostname = server.getHost(); -// -// // get ServerPort -// int portNumber = 0; -// -// ServerPort[] ports = server.getServerPorts(null); -// ServerPort port = null; -// for (int it = 0; it<ports.length; it++) -// { -// ServerPort p = ports[it]; -// String protocol = p.getProtocol(); -// if (protocol != null && protocol.trim().toLowerCase().equals("http")) -// { -// port = p; -// portNumber = p.getPort(); -// break; -// } -// } -// -// -// -// URL url = null; -// try { -// url = new URL("http", hostname, portNumber, ""); -// } -// catch(Exception e){ -// e.printStackTrace(); -// } -// -// -// //URL url = ((IURLProvider) serverInstance.getDelegate()).getModuleRootURL(module); -// -// if (url != null) -// { -// String s = url.toString(); -// webProjectURL = s + "/"+project.getName(); -// //webProjectURL = (s.endsWith("/") ? s.substring(0,s.length()-1) : s); -// } -// } -// } -// ILog log = new EclipseLog(); -// log.log(ILog.INFO, 5036, ResourceUtils.class, "getWebProjectURL", "project="+project+",webProjectURL="+webProjectURL); -// return webProjectURL; -// } - /** - * Returns the URL string corresponding to the web server module root of the - * project in a server instance or null if the project has no Web nature or - * has no association to a server instance. - * - * @param project - * The project. - * @return The web server module root URL or null if the project has no Web - * nature or has no association to a server instance. - * @deprecated belongs in ServerUtils - * - */ - public static String getWebProjectURL(IProject project) { - String webProjectURL = null; - IModule module = getModule(project); - if (module != null) { - IServer serverInstance = ServerUtils.getServerForModule(module); - if (serverInstance != null) { - URL url = ((IURLProvider)serverInstance.getAdapter(IURLProvider.class)).getModuleRootURL(module); - if (url != null) { - String s = url.toString(); - webProjectURL = (s.endsWith("/") ? s.substring(0, s - .length() - 1) : s); - } - } - } - ILog log = EnvironmentService.getEclipseLog(); - log.log(ILog.INFO, 5037, ResourceUtils.class, "getWebProjectURL", - "project=" + project + ",webProjectURL=" + webProjectURL); - - return webProjectURL; - } - - /** - * - * @param project - * @return - * - * @deprecated should be in ServerUtils - */ - public static String getEncodedWebProjectURL(IProject project) { - String url = getWebProjectURL(project); - if (url != null) { - int index = url.lastIndexOf('/'); - if (index != -1) { - StringBuffer encodedURL = new StringBuffer(); - encodedURL.append(url.substring(0, index + 1)); - try { - String ctxtRoot = URLEncoder.encode(url.substring(index + 1, url.length()), "UTF-8"); - int plusIndex = ctxtRoot.indexOf('+'); - while (plusIndex != -1) { - StringBuffer sb = new StringBuffer(); - sb.append(ctxtRoot.substring(0, plusIndex)); - sb.append("%20"); - sb.append(ctxtRoot.substring(plusIndex + 1, ctxtRoot - .length())); - ctxtRoot = sb.toString(); - plusIndex = ctxtRoot.indexOf('+'); - } - encodedURL.append(ctxtRoot); - }catch (IOException io){ - //handler exception - } - url = encodedURL.toString(); - } - } - return url; - } - - /** - * Given the <code>absolutePath</code> of a Java resource, returns the - * package name of the resource or null if the resource is not properly - * located in a project or folder on the build classpath or that is the - * build output path. - * - * @param absolutePath - * The absolute path of the Java resource. - * @return the package name of the Java resource. - */ - public static String getJavaResourcePackageName(IPath absolutePath) { - try { - IPath javaFolderPath = absolutePath.removeLastSegments(1); - IProject project = getProjectOf(absolutePath); - IJavaProject javaProject = JavaCore.create(project); - if (javaProject != null) { - IPackageFragment fragment = javaProject - .findPackageFragment(javaFolderPath); - if (fragment != null) { - return fragment.getElementName(); - } - IPath outputPath = getJavaOutputLocation(project); - if (outputPath.isPrefixOf(javaFolderPath)) { - IPath javaPackagePath = javaFolderPath - .removeFirstSegments(outputPath.segmentCount()); - return javaPackagePath.isEmpty() ? null : javaPackagePath - .toString().replace(IPath.SEPARATOR, '.'); - } - } - } catch (JavaModelException e) { - } - return null; - } - - /** - * Given the <code>absolutePath</code> of a Java resource, returns the - * package name of the resource as a relative pathname or null if the - * resource is not properly located in a project or folder on the build - * classpath. - * - * @param absolutePath - * The absolute path of the Java resource. - * @return the package name of the Java resource as a relative path. - */ - public static IPath getJavaResourcePackagePath(IPath absolutePath) { - String packageName = ResourceUtils - .getJavaResourcePackageName(absolutePath); - return (packageName == null ? null : new Path(packageName.replace('.', - IPath.SEPARATOR))); - } - - /** - * Given the <code>absolutePath</code> of a Java resource, returns the - * absolute path of the project or folder that is on the build classpath or - * is the build output path and that contains the fully qualified Java - * resource, or null if no such project or folder exists. - * - * @param absolutePath - * The absolute path of the Java resource. - * @return The absolute path of the project or folder containing the fully - * qualified Java resource. - * @deprecated not used - */ - public static IPath getJavaResourceRootPath(IPath absolutePath) { - try { - IProject project = getProjectOf(absolutePath); - IJavaProject javaProject = JavaCore.create(project); - if (javaProject != null) { - IPackageFragmentRoot[] pfrs = javaProject - .getPackageFragmentRoots(); - for (int i = 0; i < pfrs.length; i++) { - IResource fragmentRoot = pfrs[i].getCorrespondingResource(); - if (fragmentRoot != null) { - IPath fragmentPath = fragmentRoot.getFullPath(); - if (fragmentPath.isPrefixOf(absolutePath)) { - return fragmentPath; - } - } - } - IPath outputPath = getJavaOutputLocation(project); - if (outputPath.isPrefixOf(absolutePath)) { - return outputPath; - } - } - } catch (JavaModelException e) { - } - return null; - } - - /** - * Determines an URL (HTTP or FILE) to an Eclipse resource, returning the - * URL string if successful and false otherwise. A value of null will - * definitely be returned if any of the following conditions are not met: - * <ol> - * <li>The absolute path begins with a Web Project. - * <li>The leading portion of the absolute path matches the path of the - * container returned by {#link #getWebModuleServerRoot - * getWebModuleServerRoot} for the project. - * <li>The path does not lead to the WEB-INF folder or any descendent - * thereof. - * <li>The Web Project is associated with an explicit or default server - * instance. - * </ol> - * - * @param absolutePath - * The absolute path of the resource. - * @return The URL of the file, or null if no URL can be determined. - * @deprecated not used - */ -// public static String getURLFromPath(IPath absolutePath, -// String serverFactoryId, IServer server) { -// return getURLFromPath(absolutePath, getWebProjectURL( -// getProjectOf(absolutePath), serverFactoryId, server)); -// } - - /** - * - * @param absolutePath - * @param webProjectURL - * @return - * @deprecated not used - */ -// public static String getURLFromPath(IPath absolutePath, String webProjectURL) { -// StringBuffer url = new StringBuffer(); -// IProject project = getProjectOf(absolutePath); -// IContainer webModuleServerRoot = getWebModuleServerRoot(project); -// if (webModuleServerRoot != null) { -// IPath webModuleServerRootPath = webModuleServerRoot.getFullPath(); -// if (webModuleServerRootPath.isPrefixOf(absolutePath)) { -// int numSegment = webModuleServerRootPath.segmentCount(); -// int numSegmentFromPath = absolutePath.segmentCount(); -// if (numSegmentFromPath > numSegment) { -// String nextSegment = absolutePath.segment(numSegment); -// // check if the segment after the WebModuleServerRoot is -// // WEB-INF (ignoring case) -// if (nextSegment != null && !nextSegment.equalsIgnoreCase("WEB-INF")) { -// IPath relativePath = absolutePath.removeFirstSegments(numSegment); -// if (webProjectURL != null) -// url.append(webProjectURL).append(IPath.SEPARATOR).append(relativePath.toString()); -// } -// } else if (numSegmentFromPath == numSegment) -// url.append(webProjectURL); -// } -// } -// if (url.length() < 1) { -// IWorkspaceRoot workspace = getWorkspaceRoot(); -// url.append(getResourceURI(workspace.getFile(absolutePath))); -// } -// ILog log = new EclipseLog(); -// log.log(ILog.INFO, 5038, ResourceUtils.class, "getURLFromPath", -// "absolutePath=" + absolutePath + ",url=" + url); -// -// return url.toString(); -// } - - /** - * Copies a set of files from a plugin's installation location to a native - * directory. The files are named in an index file located relative to the - * plugin's installation location. - * - * @param plugin - * The plugin containing the files to copy. Must not be null. - * @param sourcePath - * The path, relative to the <code>plugin</code> install - * location, containing the files to copy. If null, then the - * plugin install location is the source path (ie. null is - * equivalent to "."). - * @param indexPathname - * A file containing a whitespace-delimitted list of pathnames of - * the files to copy. The pathnames are relative to the - * <code>plugin sourcePath</code>. Must not be null. - * @param targetPath - * The absolute path of the native directory to which the files - * will be copied. The relative pathnames of the files named in - * the <code>indexPathname</code> file are preserved. Must not - * be null. - * @param progressMonitor - * The progress monitor for the operation, or null. - * @throws IOException - * An exception indicating an IO error has occured. - */ - static public void copyIndexedFilesToOS(Plugin plugin, IPath sourcePath, - IPath indexPathname, IPath targetPath, - IProgressMonitor progressMonitor) throws IOException { - InputStream input = plugin.openStream(indexPathname); - Enumeration filenames = StringUtils.parseFilenamesFromStream(input); - copyEnumeratedFilesToOS(plugin, sourcePath, filenames, targetPath, - progressMonitor); - } - - /** - * Copies a set of files from a plugin's installation location to a native - * directory. The files are named in an enumeration. - * - * @param plugin - * The plugin containing the files to copy. Must not be null. - * @param sourcePath - * The path, relative to the <code>plugin</code> install - * location, containing the files to copy. If null, then the - * plugin install location is the source path (ie. null is - * equivalent to "."). - * @param pathnames - * An enumeration of pathnames of the files to copy. The - * pathnames are relative to the <code>plugin sourcePath</code>. - * Must not be null. - * @param targetPath - * The absolute path of the native directory to which the files - * will be copied. The relative pathnames of the files named in - * the <code>pathnames</code> enumeration are preserved. Must - * not be null. - * @param progressMonitor - * The progress monitor for the operation, or null. - * @throws IOException - * An exception indicating an IO error has occured. - */ - static public void copyEnumeratedFilesToOS(Plugin plugin, IPath sourcePath, - Enumeration pathnames, IPath targetPath, - IProgressMonitor progressMonitor) throws IOException { - while (pathnames.hasMoreElements()) { - String filename = (String) pathnames.nextElement(); - copyFileToOS(plugin, sourcePath, new Path(filename), targetPath, - progressMonitor); - } - } - - /** - * Copies a file from a plugin's installation location to a native - * directory. - * - * @param plugin - * The plugin containing the files to copy. Must not be null. - * @param sourcePath - * The path, relative to the <code>plugin</code> install - * location, containing the files to copy. If null, then the - * plugin install location is the source path (ie. null is - * equivalent to "."). - * @param pathname - * The pathname of the file to copy. The pathname is relative to - * the <code>plugin sourcePath</code>. Must not be null. - * @param targetPath - * The absolute path of the native directory to which the file - * will be copied. The relative pathname of the file is - * preserved. Must not be null. - * @param progressMonitor - * The progress monitor for the operation, or null. - * @throws IOException - * An exception indicating an IO error has occured. - */ - static public void copyFileToOS(Plugin plugin, IPath sourcePath, - IPath pathname, IPath targetPath, IProgressMonitor progressMonitor) - throws IOException { - IPath target = targetPath.append(pathname); - IPath source = sourcePath == null ? pathname : sourcePath - .append(pathname); - InputStream input = plugin.openStream(source); - OutputStream output = new FileOutputStream(target.toOSString()); - copyStream(input, output); - input.close(); - output.close(); - } - - /** - * Copies data from one stream to another. - * - * @param input - * The input stream. - * @param output - * The output stream. - * @return The number of bytes copied. - * @throws IOException - * An exception if an error occurs while processing either of - * the streams. - */ - static public int copyStream(InputStream input, OutputStream output) - throws IOException { - int t = 0; - byte[] buffer = new byte[1024]; - int n = input.read(buffer); - while (n >= 0) { - output.write(buffer, 0, n); - t += n; - n = input.read(buffer); - } - return t; - } - - /** - * Creates a native directory path equal to the parent portion of the given - * <code>pathname</code>. If the directory already exists, then no action - * is taken. - * - * @param pathname - * The pathname to the file whose parent directory should be - * created. - * @throws IOException - * An exception if an IO error occurs. - */ - static public void createParentDirectoryFor(String pathname) - throws IOException { - File file = new File(pathname); - File parent = file.getParentFile(); - if (parent != null) { - parent.mkdirs(); - } - } - - /** - * Returns the IResource represented by the given selection. - * - * @param object - * The selection - * @return IResource if the selection represents an IResource. Returns null - * otherwise. - * @throws CoreException - */ - static public IResource getResourceFromSelection(Object obj) - throws CoreException { - IResource res = null; - if (obj != null) { - if (obj instanceof IResource) { - res = (IResource) obj; - } else if (obj instanceof IJavaElement) { - IJavaElement javaElement = (IJavaElement) obj; - res = javaElement.getCorrespondingResource(); - } else if (obj instanceof EnterpriseBean) { - EnterpriseBean ejbBean = (EnterpriseBean) obj; - IProject ejbProject = ProjectUtilities.getProject(ejbBean); - if (ejbProject != null) - res = ejbProject; - } - - } - - return res; - } - - //---------------------------------------------------------------------- - // Naughty bits... - //---------------------------------------------------------------------- - - // - // Creates a path of folders. - // Do not call with an absolutePath of less than one segment. - // - // private static IContainer makeFolderPath ( - // ResourceContext resourceContext, - // IPath absolutePath, - // IProgressMonitor progressMonitor, - // StatusMonitor statusMonitor - // ) - // throws CoreException - // { - // if (absolutePath.segmentCount() <= 1) - // { - // return getWorkspaceRoot().getProject(absolutePath.segment(0)); - // } - // else - // { - // IContainer parent = makeFolderPath(resourceContext, - // absolutePath.removeLastSegments(1), progressMonitor, statusMonitor); - // String folderName = absolutePath.lastSegment(); - // return makeFolder(resourceContext, parent,folderName, progressMonitor , - // statusMonitor); - // } - // } - // - // Creates a folder under a container. - // The container must already exist. - // - // private static IFolder makeFolder ( - // ResourceContext resourceContext, - // IContainer parent, - // String folderName, - // IProgressMonitor progressMonitor, - // StatusMonitor statusMonitor - // ) - // throws CoreException - // { - // IResource child = parent.findMember(folderName); - // if (child == null) - // { - // if (!resourceContext.isCreateFoldersEnabled()) { - // int result = statusMonitor.reportStatus(new - // Status(IStatus.WARNING,WebServicePlugin.ID,0, - // WebServicePlugin.getMessage("%MSG_ERROR_FOLDER_CREATION_DISABLED", - // new Object[] {parent.getFullPath().toString(),folderName}),null), - // getThreeStateFileOptions()); - // if (result == IStatusDialogConstants.CANCEL_ID) - // return null; - // - // if ( result == IStatusDialogConstants.YES_TO_ALL_ID) - // resourceContext.setCreateFoldersEnabled(true); - // - // } - // IFolder folder = parent.getFolder(new Path(folderName)); - // folder.create(true,true,progressMonitor); - // return folder; - // } - // else if (child.getType() == IResource.FOLDER) - // { - // return (IFolder)child; - // } - // else - // { - // throw new CoreException(new - // Status(IStatus.ERROR,WebServicePlugin.ID,0,WebServicePlugin.getMessage("%MSG_ERROR_RESOURCE_NOT_FOLDER",new - // Object[] {parent.getFullPath().append(folderName).toString()}),null)); - // } - // } - - // - // Creates a file under a container. - // The container must already exist. - // - // private static IFile makeFile ( - // ResourceContext resourceContext, - // IContainer parent, - // String fileName, - // InputStream inputStream, - // IProgressMonitor progressMonitor, - // StatusMonitor statusMonitor - // ) - // throws CoreException - // { - // IResource child = parent.findMember(fileName); - // if (child != null) - // { - // if (child.getType() == IResource.FILE) - // { - // if (!resourceContext.isOverwriteFilesEnabled()) { - // int result = statusMonitor.reportStatus( new - // Status(IStatus.WARNING,WebServicePlugin.ID,0, - // WebServicePlugin.getMessage("%MSG_ERROR_FILE_OVERWRITE_DISABLED", - // new Object[] {parent.getFullPath().toString(),fileName}),null), - // getThreeStateFileOptions()); - // - // if (result == IStatusDialogConstants.CANCEL_ID) - // return null; - // - // if ( result == IStatusDialogConstants.YES_TO_ALL_ID) - // resourceContext.setOverwriteFilesEnabled(true); - // } - // //We have permission to overwrite so check if file is read-only - // if (child.isReadOnly()) - // { - // if (!resourceContext.isCheckoutFilesEnabled()) { - // - // int result = statusMonitor.reportStatus( new - // Status(IStatus.WARNING,WebServicePlugin.ID,0, - // WebServicePlugin.getMessage("%MSG_ERROR_FILE_CHECKOUT_DISABLED", - // new Object[] {parent.getFullPath().toString(),fileName}),null), - // getThreeStateFileOptions()); - // - // if (result == IStatusDialogConstants.CANCEL_ID) - // return null; - // - // if ( result == IStatusDialogConstants.YES_TO_ALL_ID) - // resourceContext.setCheckoutFilesEnabled(true); - // } - // - // IFile[] files = new IFile[1]; - // files[0] = (IFile)child; - // - // if ( - // !statusMonitor.reportStatus(getWorkspace().validateEdit(files,null))) - // return null; - // } - // - // //Change the contents of the existing file. - // IFile file = parent.getFile(new Path(fileName)); - // file.setContents(inputStream,true,true,progressMonitor); - // return file; - // - // } - // else - // { - // throw new CoreException(new - // Status(IStatus.ERROR,WebServicePlugin.ID,0,WebServicePlugin.getMessage("%MSG_ERROR_RESOURCE_NOT_FILE",new - // Object[] {parent.getFullPath().append(fileName)}),null)); - // } - // } - // else - // { - // //Create a new file. - // IFile file = parent.getFile(new Path(fileName)); - // file.create(inputStream,true,progressMonitor); - // return file; - // } - // } - - /** - * Deletes a file under a container. The container must already exist. - * - * @param file - - * the IFile to be deleted - * @param progressMonitor - * @param statusMonitor - * @return True if the file does not exist or if it exists and is - * successfully deleted. False otherwise. - */ - // public static boolean deleteFile ( - // ResourceContext resourceContext, - // IFile file, - // IProgressMonitor progressMonitor, - // StatusMonitor statusMonitor ) - // throws CoreException - // { - // if (file.exists()) - // { - // if (!resourceContext.isOverwriteFilesEnabled()) { - // int result = statusMonitor.reportStatus( new - // Status(IStatus.WARNING,WebServicePlugin.ID,0, - // WebServicePlugin.getMessage("%MSG_ERROR_FILE_OVERWRITE_DISABLED", - // new Object[] - // {file.getParent().getFullPath().toString(),file.getName()}),null), - // getThreeStateFileOptions()); - // - // if (result == IStatusDialogConstants.CANCEL_ID) - // return false; - // - // if ( result == IStatusDialogConstants.YES_TO_ALL_ID) - // resourceContext.setOverwriteFilesEnabled(true); - // } - // //We have permission to overwrite so check if file is read-only - // if (file.isReadOnly()) - // { - // if (!resourceContext.isCheckoutFilesEnabled()) { - // int result = statusMonitor.reportStatus( new - // Status(IStatus.WARNING,WebServicePlugin.ID,0, - // WebServicePlugin.getMessage("%MSG_ERROR_FILE_CHECKOUT_DISABLED", - // new Object[] - // {file.getParent().getFullPath().toString(),file.getName()}),null), - // getThreeStateFileOptions()); - // if (result == IStatusDialogConstants.CANCEL_ID) - // return false; - // - // if ( result == IStatusDialogConstants.YES_TO_ALL_ID) - // resourceContext.setCheckoutFilesEnabled(true); - // - // } - // IFile[] files = new IFile[1]; - // files[0] = file; - // - // if ( - // !statusMonitor.reportStatus(getWorkspace().validateEdit(files,null))) - // return false; - // } - // file.delete(true,progressMonitor); - // } - // //At this point, either the file did not exist or we successfully deleted - // it. Return success. - // return true; - // } - /** - * Deletes a folder under a container. - * - * @param folder - - * the IFolder to be deleted - * @param progressMonitor - * @param statusMonitor - * @return True if the folder does not exist or if it exists and is - * successfully deleted along with its members. False otherwise. - */ - // public static boolean deleteFolder ( - // ResourceContext resourceContext, - // IFolder folder, - // IProgressMonitor progressMonitor, - // StatusMonitor statusMonitor - // ) - // throws CoreException - // { - // if (!folder.exists()) return true; - // - // boolean deleted = true; - // IResource[] resources = folder.members(); - // for (int i=0; i<resources.length; i++) - // { - // IResource resource = resources[i]; - // if (resource instanceof IFile) - // { - // deleted = deleteFile(resourceContext, (IFile)resource, progressMonitor, - // statusMonitor); - // } - // if (resource instanceof IFolder) - // { - // deleted = deleteFolder( resourceContext, (IFolder)resource, - // progressMonitor, statusMonitor); - // } - // - // if (!deleted) break; - // } - // if (deleted) { - // folder.delete(true, true, progressMonitor); - // return true; - // } - // else - // return false; - // - // } - /** - * Deletes a set of files that are named in an index file located relative - * to the plugin's installation location. - * - * @param plugin - * The plugin containing the indexed file Must not be null. - * @param sourcePath - - * relative path of the indexed file passing a null in has the - * same effect as passing a "." in - * @param indexFilePath - - * the indexed filename Must not be null - * @param targetPath - - * path containing the files named in the indexed file Must not - * be null, this path must end with a trailing separator - * @param progressMonitor - */ - // public static void deleteIndexFilesFromOS ( - // Plugin plugin, - // IPath indexFilePath, - // IPath targetPath - // ) - // throws IOException { - // InputStream input = plugin.openStream(indexFilePath); - // Enumeration filenames = StringUtils.parseFilenamesFromStream(input); - // while (filenames.hasMoreElements()) { - // File targetFile = - // targetPath.append((String)filenames.nextElement()).toFile(); - // if (targetFile.exists()) - // targetFile.delete(); - // } - // } - /** - * Returns a URI reference to the given Eclipse resource, or null if no such - * reference can be determined (for example, if the resource does not exist - * in the underlying filesystem). - * - * @param resource - * The resource. - * @return The URI as a string, or null if there is no URI to the resource. - */ - public static String getResourceURI(IResource resource) { - String uri = null; - IPath location = resource.getLocation(); - if (location != null) { - uri = "file:" + location.toString(); - } - return uri; - } - - /** - * Returns a URI reference to the given Eclipse resource using the - * "platform:" protocol, or null if no such reference can be determined (for - * example, if the resource does not exist in the underlying filesystem). - * - * @param resource - * The resource. - * @return The URI as a string, or null if there is no URI to the resource. - */ - public static String getPlatformResourceURI(IResource resource) { - String uri = null; - IPath location = resource.getFullPath(); - if (location != null) { - uri = "platform:/resource" + location.toString(); - } - return uri; - } - - /** - * Returns the default binding namespace string given a Java bean name - * (using the convention used by CTC in GM). e.g. Java bean MyClass result - * in binding namespace of - * "http://www.myclass.com/definitions/MyClassRemoteInterface" - * - * @param beanName - * The java bean. - * @return The binding namespace as a string. - */ - public static String getBindingNamespace(String beanName) { - return "http://www." + beanName.toLowerCase() + ".com/definitions/" - + beanName + "RemoteInterface"; - } - - /** - * Returns the default schema namespace string given a Java bean name (using - * the convention used by CTC in GM). e.g. Java bean MyClass result in - * schema namespace of - * "http://www.myclass.com/schemas/MyClassRemoteInterface" - * - * @param beanName - * The java bean. - * @return The schemas namespace as a string. - */ - public static String getSchemaNamespace(String beanName) { - return "http://www." + beanName.toLowerCase() + ".com/schemas/" - + beanName + "RemoteInterface"; - } - - // public static Vector getThreeStateFileOptions() { - // Vector options = new Vector(); - // options.add(new - // StatusOption(IStatusDialogConstants.YES_ID,IStatusDialogConstants.YES_LABEL,"","")); - // options.add(new - // StatusOption(IStatusDialogConstants.YES_TO_ALL_ID,IStatusDialogConstants.YES_TO_ALL_LABEL,"","")); - // options.add(new - // StatusOption(IStatusDialogConstants.CANCEL_ID,IStatusDialogConstants.CANCEL_LABEL,"","")); - // return options; - // } - - //---------------------------------------------------------------------- - - /** - * Gets the SOAP rpcrouter servlet URL for the service project - * - * @param project - * The project. - * @param serverFactoryId - * The server factory id - * @param server - * The server - * @return The URL, possibly null. - */ - - public static String getServletURL(IProject project, - String serverFactoryId, IServer server) { - return getServletURL(getWebProjectURL(project, serverFactoryId, server)); - } - - public static String getServletURL(String webProjectURL) { - if (webProjectURL == null) - return null; - else - return webProjectURL + SERVLET_EXT; - } - - /** - * Gets the client Web project name - * - * @param projectName - * The project name to base on. - * @param typeId the webservice type id. - * @return The client Web project name. - * - * @deprecated - */ - public static String getClientWebProjectName(String projectName, String typeId) - { - String baseClientWebProjectName = projectName + DEFAULT_CLIENT_WEB_PROJECT_EXT; - IPath projectPath; - IProject project; - boolean foundWebProject = false; - int i = 1; - - if( isSkeletonEJBType( typeId ) ) - { - // For the skeleton EJB scenario we need to create a slightly different - // base name. When the EJB project is created another project - // is created with "Client" tacked onto the end. We will - // add "WS" to our client so we don't collide with the other - // client project. - baseClientWebProjectName = projectName + "WS" + DEFAULT_CLIENT_WEB_PROJECT_EXT; - } - - String clientWebProjectName = baseClientWebProjectName; - - while (!foundWebProject) - { - projectPath = new Path(clientWebProjectName).makeAbsolute(); - project = ResourceUtils.getProjectOf(projectPath); - - if (project.exists() && !ResourceUtils.isWebProject(project)) - { - clientWebProjectName = baseClientWebProjectName + i; - i++; - } - else - { - foundWebProject = true; - } - } - - return clientWebProjectName; - } - - public static String[] getClientProjectComponentName(String projectName, String componentName, boolean isEJB) - { - String clientProjectName = null; - String clientComponentName = null; - if (isEJB) - { - clientProjectName = projectName + DEFAULT_CLIENT_EJB_PROJECT_EXT; - clientComponentName = componentName + DEFAULT_CLIENT_EJB_PROJECT_EXT; - } - else - { - clientProjectName = projectName + DEFAULT_CLIENT_WEB_PROJECT_EXT; -// String baseName = clientProjectName; - clientComponentName = componentName + DEFAULT_CLIENT_WEB_PROJECT_EXT; -// String baseCompName = clientComponentName; - } - - //TODO we may want to remove this if statement once defect 103366 is resolved. - //TODO: Defect 107997 - Revisit prject and module creation logic -// if( !FlexibleJavaProjectPreferenceUtil.getMultipleModulesPerProjectProp() ) -// { -// clientComponentName = clientProjectName; -// } - -// boolean foundWebProject = false; -// int i = 1; -// -// while (!foundWebProject) -// { -// IPath projectPath = new Path(clientProjectName).makeAbsolute(); -// IProject project = ResourceUtils.getProjectOf(projectPath); -// -// if (project.exists()) -// { -// clientProjectName = baseName + i; -// clientComponentName = baseCompName + i; -// i++; -// } -// else -// { -// foundWebProject = true; -// } -// } - - return new String[]{clientProjectName, clientComponentName}; - } - - /** - * - * @param typeID - * @return - * - * @deprecated - */ - public static boolean isSkeletonEJBType( String typeID ) - { - return typeID.equals( "org.eclipse.jst.ws.type.wsdl.ejb" ); - } - - public static String getDefaultEJBProjectName() { - return DEFAULT_EJB_PROJECT_NAME; - } - - public static String getDefaultEJBComponentName() { - return DEFAULT_EJB_COMPONENT_NAME; - } - - public static String getDefaultWebProjectName() { - return DEFAULT_WEB_PROJECT_NAME; - } - - public static String getDefaultWebComponentName() { - return DEFAULT_WEB_COMPONENT_NAME; - } - - public static String getDefaultClientExtension() { - return DEFAULT_CLIENT_WEB_PROJECT_EXT; - } - - /** - * - * @param projectName - * @return - * - */ - public static String getRouterProjectName(String projectName) { - return projectName + DEFAULT_ROUTER_PROJECT_EXT; - } - - public static String getDefaultServiceEARProjectName() { - return DEFAULT_SERVICE_EAR_PROJECT_NAME; - } - - public static String getDefaultServiceEARComponentName() { - return DEFAULT_SERVICE_EAR_COMPONENT_NAME; - } - - public static String getDefaultClientEARProjectName() { - return DEFAULT_CLIENT_EAR_PROJECT_NAME; - } - - public static String getDefaultClientEARComponentName() { - return DEFAULT_CLIENT_EAR_COMPONENT_NAME; - } -} - diff --git a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/common/SelectionToResource.java b/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/common/SelectionToResource.java deleted file mode 100644 index 7c77dabbc..000000000 --- a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/common/SelectionToResource.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 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 - *******************************************************************************/ -package org.eclipse.jst.ws.internal.common; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.jdt.core.ICompilationUnit; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jst.j2ee.ejb.EnterpriseBean; -import org.eclipse.wst.command.internal.env.core.data.Transformer; - -public class SelectionToResource implements Transformer -{ - /* (non-Javadoc) - * @see org.eclipse.wst.command.internal.env.core.data.Transformer#transform(java.lang.Object) - */ - public Object transform(Object value) - { - IStructuredSelection selection = (IStructuredSelection)value; - IResource resource = null; - - if( selection != null ) - { - Object object = selection.getFirstElement(); - - if( object != null ) - { - if( object instanceof IResource) - { - resource = (IResource)object; - } - else if( object instanceof ICompilationUnit ) - { - ICompilationUnit compUnit = (ICompilationUnit)object; - - try - { - resource = compUnit.getCorrespondingResource(); - } - catch( JavaModelException exc) - { - } - } - else if( object instanceof EnterpriseBean ) - { - EnterpriseBean ejbBean = (EnterpriseBean)object; - IProject ejbProject = ProjectUtilities.getProject( ejbBean ); - - if( ejbProject != null ) - { - resource = ejbProject; - } - } - } - } - - return resource; - } -} diff --git a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/common/ServerUtils.java b/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/common/ServerUtils.java deleted file mode 100644 index 303a27eed..000000000 --- a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/common/ServerUtils.java +++ /dev/null @@ -1,748 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 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 - *******************************************************************************/ - -package org.eclipse.jst.ws.internal.common; - -import java.io.IOException; -import java.net.URL; -import java.net.URLEncoder; -import java.util.Arrays; -import java.util.Hashtable; -import java.util.List; -import java.util.Vector; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Status; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.jst.j2ee.internal.J2EEVersionConstants; -import org.eclipse.jst.j2ee.internal.servertarget.IServerTargetConstants; -import org.eclipse.wst.command.internal.env.core.common.MessageUtils; -import org.eclipse.wst.command.internal.env.core.common.StatusUtils; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.environment.IEnvironment; -import org.eclipse.wst.server.core.IModule; -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.IServerType; -import org.eclipse.wst.server.core.IServerWorkingCopy; -import org.eclipse.wst.server.core.ServerCore; -import org.eclipse.wst.server.core.ServerUtil; -import org.eclipse.wst.server.core.model.IURLProvider; - -/** - * This class contains useful methods for working with Server plugin functions - */ -public final class ServerUtils { - - private MessageUtils msgUtils_; - - private Hashtable serverIdToLabel_; - - private Hashtable serverLabelToId_; - - private static ServerUtils instance_; - - public static ServerUtils getInstance() { - if (instance_ == null) { - instance_ = new ServerUtils(); - } - return instance_; - - } - - public ServerUtils() { - String pluginId = "org.eclipse.jst.ws"; - msgUtils_ = new MessageUtils(pluginId + ".plugin", this); - } - - // Gets the Server labels given the server factory id - public void getServerLabelsAndIds() { - serverIdToLabel_ = new Hashtable(); - serverLabelToId_ = new Hashtable(); - IServerType[] serverTypes = ServerCore.getServerTypes(); - for (int idx = 0; idx < serverTypes.length; idx++) { - - IServerType serverType = (IServerType) serverTypes[idx]; - - String id = serverType.getId(); - String serverLabel = serverType.getName(); - if (!(id == null) && !(serverLabel == null)) { - serverIdToLabel_.put(id, serverLabel); - serverLabelToId_.put(serverLabel, id); - } - } - } - - public String getServerLabelForId(String factoryId) { - if (serverIdToLabel_ == null) - this.getServerLabelsAndIds(); - return (String) serverIdToLabel_.get(factoryId); - } - - public String getServerIdForLabel(String factoryLabel) { - if (serverLabelToId_ == null) - this.getServerLabelsAndIds(); - return (String) serverLabelToId_.get(factoryLabel); - } - - public IStatus modifyModules(IEnvironment env, IServer server, - IModule module, boolean add, IProgressMonitor monitor) { - - IServerWorkingCopy wc = null; - IStatus status = Status.OK_STATUS; - - try { - - if (module == null || !module.getProject().exists()) { - return status; - } - - // check if module is a true Java project - if (module instanceof IModule) { - IModule pm = (IModule) module; - if (pm != null) { - IProject project = pm.getProject(); - if (project == null - || ResourceUtils.isTrueJavaProject(project)) { - return status; - } - } - } - - wc = server.createWorkingCopy(); - if (wc != null) { -// Object x = server.getAdapter(IRunningActionServer.class); -// if (x != null && x instanceof IRunningActionServer) { -// int state = server.getServerState(); -// if (state == IServer.STATE_STOPPED -// || state == IServer.STATE_UNKNOWN) { -// String mode = ILaunchManager.RUN_MODE; -// server.synchronousStart(mode, monitor); -// } -// } - - List list = Arrays.asList(server.getModules()); - if (add) { - if (!list.contains(module)) { - ServerUtil.modifyModules(wc, new IModule[] { module }, - new IModule[0], monitor); - } - } else { // removes module - if (list.contains(module)) { - ServerUtil.modifyModules(wc, new IModule[0], - new IModule[] { module }, monitor); - } - } - } else { - // handle case of Null WC; non-issue for now - } - } - catch (CoreException exc ) - { - status = StatusUtils.errorStatus( msgUtils_.getMessage("MSG_ERROR_SERVER"), exc ); - env.getStatusHandler().reportError(status); - return status; - } finally { - if (wc != null) { - // Always saveAll and release the serverWorkingCopy - try - { - wc.saveAll(true, monitor); - } - catch (CoreException exc ) - { - status = StatusUtils.errorStatus( msgUtils_.getMessage("MSG_ERROR_SERVER"), exc ); - env.getStatusHandler().reportError(status); - return status; - } - } - } - return status; - } - - public static IServer getServerForModule(IModule module, String serverTypeId, - IServer server, boolean create, IProgressMonitor monitor) { - if (server != null) - return server; - else - return getServerForModule(module, serverTypeId, create, monitor); - } - - public static IServer getServerForModule(IModule module, - String serverTypeId, boolean create, IProgressMonitor monitor) { - try { - - IServer[] servers = ServerUtil.getServersByModule(module, monitor); - - if (servers != null && servers.length > 0) { - if (serverTypeId == null || serverTypeId.length() == 0) - return servers[0]; // WSAD v4 behavior - - for (int i = 0; i < servers.length; i++) { - if (servers[i].getServerType().getId().equalsIgnoreCase( - serverTypeId)) - return servers[i]; - } - } - - return createServer(module, serverTypeId, monitor); - - } catch (Exception e) { - return null; - } - } - - public static IServer getServerForModule(IModule module) { - try { - IServer[] servers = ServerUtil.getServersByModule(module, null); - return ((servers != null && servers.length > 0) ? servers[0] : null); - } catch (Exception e) { - return null; - } - } - - /** - * - * @param env - * @param module - * @param serverTypeId - * @param monitor - * @return - * - * @deprecated - */ - public IServer createServer(IEnvironment env, IModule module, - String serverTypeId, IProgressMonitor monitor) { - IServerWorkingCopy serverWC = null; - IServer server = null; - try { - IServerType serverType = ServerCore.findServerType(serverTypeId); - serverWC = serverType.createServer(serverTypeId, null, monitor); - try { - if (serverWC != null) { - server = serverWC.saveAll(true, monitor); - } - } catch (CoreException ce) - { - IStatus status = StatusUtils.errorStatus( msgUtils_.getMessage("MSG_ERROR_SERVER"), ce); - env.getStatusHandler().reportError(status); - return null; - } - - if (server != null) { - -// Object x = server.getAdapter(IRunningActionServer.class); -// if (x != null && x instanceof IRunningActionServer) { -// int state = server.getServerState(); -// if (state == IServer.STATE_STOPPED -// || state == IServer.STATE_UNKNOWN) { -// String mode = ILaunchManager.RUN_MODE; -// server.synchronousStart(mode, monitor); -// } -// } - - if (module != null && module.getProject().exists()) { - IModule[] parentModules = server.getRootModules(module, - monitor); - if (parentModules != null && parentModules.length != 0) { - module = (IModule) parentModules[0]; - } - serverWC.modifyModules(new IModule[] { module }, - new IModule[0], monitor); - } - - } - - return server; - } - catch (Exception e) - { - IStatus status = StatusUtils.errorStatus( msgUtils_.getMessage("MSG_ERROR_SERVER"), e); - env.getStatusHandler().reportError(status); - return null; - } finally { - try { - if (serverWC != null) { - serverWC.saveAll(true, monitor); - } - } catch (CoreException ce) { - IStatus status = StatusUtils.errorStatus( msgUtils_.getMessage("MSG_ERROR_SERVER"), ce); - env.getStatusHandler().reportError(status); - return null; - } - } - } - - /** - * createServer This creates a server but does not report errors. @param - * module - * @param serverTypeId - * @param monitor progress monitor - * @return IServer returns null if unsuccessful - * - * @deprecated - */ - public static IServer createServer(IModule module, String serverTypeId, - IProgressMonitor monitor) { - IServerWorkingCopy serverWC = null; - IServer server = null; - try { - IServerType serverType = ServerCore.findServerType(serverTypeId); - serverWC = serverType.createServer(serverTypeId, null, monitor); - - try { - if (serverWC != null) { - server = serverWC.saveAll(true, monitor); - } - } catch (CoreException ce) { - return null; - } - - if (server != null) { - -// Object x = server.getAdapter(IRunningActionServer.class); -// if (x != null && x instanceof IRunningActionServer) { -// int state = server.getServerState(); -// if (state == IServer.STATE_STOPPED -// || state == IServer.STATE_UNKNOWN) { -// String mode = ILaunchManager.RUN_MODE; -// server.synchronousStart(mode, monitor); -// } -// } - if (module != null) { - IModule[] parentModules = server.getRootModules(module, - monitor); - if (parentModules != null && parentModules.length != 0) { - module = (IModule) parentModules[0]; - } - serverWC.modifyModules(new IModule[] { module }, - new IModule[0], monitor); - } - - } - - return server; - } catch (Exception e) { - return null; - } finally { - try { - if (serverWC != null) { - serverWC.saveAll(true, monitor); - } - } catch (CoreException ce) { - return null; - // handler core exception - } - } - } - - public static String[] getServerTypeIdsByModule(IVirtualComponent component) { - IProject project = component.getProject(); - String[] serverIds = null; - - if (project != null) { - IServer[] servers = ServerUtil.getServersByModule(getModule(project), null); - if (servers != null) { - serverIds = new String[servers.length]; - - for (int index = 0; index < servers.length; index++) { - serverIds[index] = servers[index].getId(); - - } - } - } - - if (serverIds == null) { - serverIds = new String[0]; - } - - return serverIds; - } - - /** - * @param project - * @return - * @deprecated should be using getServerTypeIdsByModule( IVirtualComponent ) - */ - public static String[] getServerTypeIdsByModule(IProject project) { - Vector serverIds = new Vector(); - if (project != null) { - IServer[] servers = ServerUtil.getServersByModule(ResourceUtils - .getModule(project), null); - if (servers != null && servers.length > 0) { - for (int i = 0; i < servers.length; i++) { - serverIds.add(servers[i].getId()); - } - } - } - return (String[]) serverIds.toArray(new String[serverIds.size()]); - } - - public static IModule getModule(IProject project) { - return ServerUtil.getModule(project); -} - -// Workaround for 113621 -//public static IModule getModule(IProject project) { -// IModule[] modules = ServerUtil.getModules(project); -// if (modules!=null && modules.length!=0) { -// return modules[0]; -// } -// return null; -//} - - /** - * Returns the URL string corresponding to the web server module root of the - * component in a server instance or null if the project has no Web nature - * or has no association to a server instance. - * - * @param project - * The project. - * @return The web server module root URL or null if the project has no Web - * nature or has no association to a server instance. - */ - public static String getWebComponentURL(IProject project, String serverFactoryId) { - String webProjectURL = null; - IModule module = getModule(project); - if (module != null) { - IServer serverInstance = getServerForModule(module); - if (serverInstance != null) { - IURLProvider urlProvider = (IURLProvider) serverInstance.loadAdapter(IURLProvider.class, null); - if (urlProvider!=null) { - URL url = urlProvider.getModuleRootURL(module); - if (url != null) { - String s = url.toString(); - webProjectURL = (s.endsWith("/") ? s.substring(0, s.length() - 1) : s); - } - } - } - else { - //IRuntime projectTarget = ServerCore.getProjectProperties(project).getRuntimeTarget(); - IServerType serverType = ServerCore.findServerType(serverFactoryId); - if (serverType!=null) - { - try { - //Choose a Runtime which is not a stub - IRuntime nonStubRuntime = null; - IRuntime[] runtimes = ServerUtil.getRuntimes(null, null); - String serverRuntimeTypeId = serverType.getRuntimeType().getId(); - for (int i = 0; i < runtimes.length; i++) { - IRuntime runtime = runtimes[i]; - String thisRuntimeTypeId = runtime.getRuntimeType().getId(); - if (thisRuntimeTypeId.equals(serverRuntimeTypeId) && !runtime.isStub()) { - //Found an appropriate IRuntime that is not a stub - nonStubRuntime = runtime; - break; - } - } - - if (nonStubRuntime != null) - { - IServerWorkingCopy serverWC = serverType.createServer(null, null, nonStubRuntime, null); - IURLProvider urlProvider = (IURLProvider) serverWC.loadAdapter(IURLProvider.class, null); - if (urlProvider!=null) { - URL url = urlProvider.getModuleRootURL(module); - if (url != null) { - String s = url.toString(); - webProjectURL = (s.endsWith("/") ? s.substring(0, s.length() - 1) : s); - } - } - } - - } catch(CoreException ce){ - Logger.getLogger().log(ce); - } - - } - } - } - return webProjectURL; - } - - /** - * Returns the URL string corresponding to the web server module root of the - * project in a server instance or null if the project has no Web nature or - * has no association to a server instance. - * - * @param project - * The project. - * @return The web server module root URL or null if the project has no Web - * nature or has no association to a server instance. - */ - public static String getWebComponentURL(IProject project, - String serverFactoryId, IServer server) { - - String webProjectURL = null; - IModule module = getModule(project); - if (module != null) { - IServer serverInstance = ServerUtils.getServerForModule(module, serverFactoryId, server, true, new NullProgressMonitor()); - if (serverInstance != null) { - IURLProvider urlProvider = (IURLProvider) serverInstance.loadAdapter(IURLProvider.class, null); - if (urlProvider!=null) { - URL url = urlProvider.getModuleRootURL(module); - if (url != null) { - String s = url.toString(); - webProjectURL = (s.endsWith("/") ? s.substring(0, s.length() - 1) : s); - } - } - } - } - return webProjectURL; - } - - public static String getEncodedWebComponentURL(IProject project, String serverFactoryId) { - String url = getWebComponentURL(project, serverFactoryId); - if (url != null) { - int index = url.lastIndexOf('/'); - if (index != -1) { - StringBuffer encodedURL = new StringBuffer(); - encodedURL.append(url.substring(0, index + 1)); - try { - String ctxtRoot = URLEncoder.encode(url.substring(index + 1, url.length()), "UTF-8"); - int plusIndex = ctxtRoot.indexOf('+'); - while (plusIndex != -1) { - StringBuffer sb = new StringBuffer(); - sb.append(ctxtRoot.substring(0, plusIndex)); - sb.append("%20"); - sb.append(ctxtRoot.substring(plusIndex + 1, ctxtRoot - .length())); - ctxtRoot = sb.toString(); - plusIndex = ctxtRoot.indexOf('+'); - } - encodedURL.append(ctxtRoot); - }catch (IOException io){ - //handler exception - } - url = encodedURL.toString(); - } - } - return url; - } - - public static IServer getDefaultExistingServer(IVirtualComponent component) { - IProject project = component.getProject(); - IModule module = getModule(project); - IServer preferredServer = ServerCore.getDefaultServer(module); - if (preferredServer != null) - return preferredServer; - - IServer[] configuredServers = ServerUtil.getServersByModule(module, - null); - - if (configuredServers != null && configuredServers.length > 0) { - preferredServer = configuredServers[0]; - } else { - IServer[] nonConfiguredServers = ServerUtil - .getAvailableServersForModule(module, false, null); - - if (nonConfiguredServers != null - && nonConfiguredServers.length > 0) { - preferredServer = nonConfiguredServers[0]; - } - } - - return preferredServer; - } - - /** - * @param project - * @return - * @deprecated should be using getDefaultExistingServer( IVirtualComponent ) - */ - public static IServer getDefaultExistingServer(IProject project) { - - IModule module = ServerUtil.getModule(project); - IServer preferredServer = null; - preferredServer = ServerCore.getDefaultServer(module); - -// Workaround for 113621 -// IModule[] modules = ServerUtil.getModules(project); -// IServer preferredServer = null; -// if (modules.length > 0){ -// preferredServer = ServerCore.getDefaultServer(modules[0]); -// } - - if (preferredServer != null) - return preferredServer; - - IServer[] configuredServers = ServerUtil.getServersByModule( - ResourceUtils.getModule(project), null); - if (configuredServers != null && configuredServers.length > 0) { - return configuredServers[0]; - } - - IServer[] nonConfiguredServers = ServerUtil - .getAvailableServersForModule(ResourceUtils.getModule(project), - false, null); - if (nonConfiguredServers != null && nonConfiguredServers.length > 0) { - return nonConfiguredServers[0]; - } - return null; - } - - /* - * @param moduleType - ad defined in IServerTargetConstants (i.e. EAR_TYPE, - * WEB_TYPE, etc.) @param j2eeVersion String representation of the int - * values in J2EEVersionConstants i.e. "12" or "13" or "14" @return String - * the id of the server target - to be used in project creation operations. - */ - public static String getServerTargetIdFromFactoryId(String serverFactoryId, - String moduleType, String j2eeVersion) { - IServerType serverType = ServerCore.findServerType(serverFactoryId); - if (serverType == null) - return null; - - String serverRuntimeTypeId = serverType.getRuntimeType().getId(); - - String stJ2EEVersion = ServerUtils.getServerTargetJ2EEVersion(j2eeVersion); - List runtimes = Arrays.asList(ServerUtil.getRuntimes(moduleType, stJ2EEVersion)); - for (int i = 0; i < runtimes.size(); i++) { - IRuntime runtime = (IRuntime) runtimes.get(i); - String thisRuntimeTypeId = runtime.getRuntimeType().getId(); - if (thisRuntimeTypeId.equals(serverRuntimeTypeId) && !runtime.isStub()) { - return runtime.getId(); - } - } - - return null; - } - - /* - * @param serverFactoryId the server's factory id @returns the runtime type - * id given the server's factory id. Returns a blank String if the no - * ServerType exists for the given factory id. - */ - public static String getRuntimeTargetIdFromFactoryId(String serverFactoryId) { - IServerType serverType = ServerCore.findServerType(serverFactoryId); - if (serverType != null) { - String serverRuntimeId = serverType.getRuntimeType().getId(); - return serverRuntimeId; - } else - return ""; - } - - public static String getFactoryIdFromRuntimeTargetId(String runtimeTargetId){ - IServerType[] serverTypes = ServerCore.getServerTypes(); - for (int i=0;i<serverTypes.length;i++) { - IRuntimeType runtimeTyp = serverTypes[i].getRuntimeType(); - if (runtimeTyp!=null){ - if (runtimeTyp.getId().equals(runtimeTargetId)) - return serverTypes[i].getId(); - } - } - return ""; - - } - - - /* - * @param serverFactoryId the server's factory id @returns the server type - * id given the server's factory id. Returns a blank String if the no - * ServerType exists for the given factory id. - */ - public static String getServerTypeIdFromFactoryId(String serverFactoryId) { - IServerType serverType = ServerCore.findServerType(serverFactoryId); - if (serverType != null) { - String serverTypeId = serverType.getId(); - return serverTypeId; - } else - return ""; - } - - /* - * @param j2eeVersion String representation of the int values in - * J2EEVersionConstants i.e. "12" or "13" or "14" - */ - public static boolean isTargetValidForEAR(String runtimeTargetId, - String j2eeVersion) { - if (runtimeTargetId == null) - return false; - - String earModuleType = IServerTargetConstants.EAR_TYPE; - String stJ2EEVersion = ServerUtils.getServerTargetJ2EEVersion(j2eeVersion); - List runtimes = Arrays.asList(ServerUtil.getRuntimes(earModuleType, stJ2EEVersion)); - for (int i = 0; i < runtimes.size(); i++) { - IRuntime runtime = (IRuntime) runtimes.get(i); - String thisId = runtime.getRuntimeType().getId(); - if (thisId.equals(runtimeTargetId)) - return true; - } - - return false; - } - - /* - * @param j2eeVersion String representation of the int values in - * J2EEVersionConstants i.e. "12" or "13" or "14" @param the project type - * from IServerTargetConstants - */ - public static boolean isTargetValidForProjectType(String runtimeTargetId, - String j2eeVersion, String projectType) { - if (runtimeTargetId == null) - return false; - - if (projectType == null || projectType.length() == 0) - return false; - - String stJ2EEVersion = ServerUtils.getServerTargetJ2EEVersion(j2eeVersion); - List runtimes = Arrays.asList(ServerUtil.getRuntimes(projectType, stJ2EEVersion)); - for (int i = 0; i < runtimes.size(); i++) { - IRuntime runtime = (IRuntime) runtimes.get(i); - String thisId = runtime.getRuntimeType().getId(); - if (thisId.equals(runtimeTargetId)) - return true; - } - - return false; - } - - public static String getServerTargetJ2EEVersion(String j2eeVersion) { - - if (j2eeVersion == null || j2eeVersion.length() == 0) - return null; - - int j2eeVersionInt = Integer.parseInt(j2eeVersion); - switch (j2eeVersionInt) { - case (J2EEVersionConstants.J2EE_1_2_ID): - return IServerTargetConstants.J2EE_12; - case (J2EEVersionConstants.J2EE_1_3_ID): - return IServerTargetConstants.J2EE_13; - case (J2EEVersionConstants.J2EE_1_4_ID): - return IServerTargetConstants.J2EE_14; - default: - return null; - } - } - - //Converts a module type from J2EEUtils to a module type like - //the one in IServerTargetConstants. - public static String getServerTargetModuleType(int moduleType) - { - switch (moduleType) - { - case J2EEUtils.WEB : - return IServerTargetConstants.WEB_TYPE; - case J2EEUtils.EJB : - return IServerTargetConstants.EJB_TYPE; - case J2EEUtils.APPCLIENT : - return IServerTargetConstants.APP_CLIENT_TYPE; - case J2EEUtils.EAR : - return IServerTargetConstants.EAR_TYPE; - default: - return null; - - } - } -} diff --git a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/common/StatusObjectHandler.java b/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/common/StatusObjectHandler.java deleted file mode 100644 index 1111d76c7..000000000 --- a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/common/StatusObjectHandler.java +++ /dev/null @@ -1,140 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 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 - *******************************************************************************/ - -package org.eclipse.jst.ws.internal.common; - -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.MultiStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.emf.common.util.WrappedException; -import org.eclipse.jst.ws.internal.plugin.WebServicePlugin; - - -public class StatusObjectHandler -{ - // Copyright - public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002."; - private static final int MAX_DETAILS = 16; - - public static IStatus generateTreeStatus (IStatus status) - { - // - // There could be lots of Throwables, CoreExceptions, - // WrappedExceptions and IStatus objects beneath the - // given status. Find them. - // - LinkedList statusList = new LinkedList(); - appendStatus(MAX_DETAILS, statusList, status, status.getSeverity()); - if (statusList.size() > 0) - { - IStatus newStatus = (IStatus)statusList.removeFirst(); - if (statusList.size() > 0) - { - IStatus[] secondaryStatusArray = new IStatus[statusList.size()]; - int n = 0; - Iterator i = statusList.iterator(); - while (i.hasNext()) - { - secondaryStatusArray[n++] = (IStatus)i.next(); - } - newStatus = new MultiStatus(status.getPlugin(),status.getCode(),secondaryStatusArray,status.getMessage(),status.getException()); - } - return newStatus; - } - else - return null; - } - - // - // Appends zero or more IStatus objects to the list of IStatus objects - // based upon an IStatus. - // - private static int appendStatus ( int max, List statusList, IStatus status, int severity ) - { - if (max > 0 && status != null) - { - // - // Append an IStatus object for the given status' message. - // - if (status.getMessage() != null) - { - max = append(statusList,max,severity,status.getPlugin(),status.getCode(),status.getMessage(),status.getException()); - } - // - // Append the IStatus' Throwable, if any. - // - max = appendThrowable(max,statusList,status.getException(),severity); - // - // If the IStatus is a multi status, append the children. - // - IStatus[] children = status.getChildren(); - for (int i=0; i<children.length && max>0; i++) - { - max = appendStatus(max,statusList,children[i],severity); - } - } - return max; - } - - // - // Appends zero or more IStatus objects to the list of IStatus objects - // based upon a Throwable. WrappedExceptions and CoreExceptions are - // given special treatment. - // - private static int appendThrowable ( int max, List statusList, Throwable throwable, int severity ) - { - if (max > 0 && throwable != null) - { - // - // Append an IStatus object for the exception's message. - // - if (throwable.getLocalizedMessage() != null) - { - max = append(statusList,max,severity,WebServicePlugin.ID,0,throwable.getLocalizedMessage(),throwable); - } - // - // If the exception is a WrappedException, append the wrapped Exception. - // - if (throwable instanceof WrappedException) - { - WrappedException wexc = (WrappedException)throwable; - max = appendThrowable(max,statusList,wexc.exception(),severity); - } - // - // If the exception is a CoreException, append the enclosed IStatus. - // - if (throwable instanceof CoreException) - { - CoreException cexc = (CoreException)throwable; - max = appendStatus(max,statusList,cexc.getStatus(),severity); - } - } - return max; - } - - // - // Creates and appends an IStatus to the list of IStatus objects. - // - private static int append ( List statusList, int max, int severity, String id, int code, String message, Throwable throwable ) - { - if (max > 0) - { - IStatus status = new Status(severity,id,code,message,throwable); - statusList.add(status); - max--; - } - return max; - } -} diff --git a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/common/StringToIProjectTransformer.java b/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/common/StringToIProjectTransformer.java deleted file mode 100644 index 92efc3b17..000000000 --- a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/common/StringToIProjectTransformer.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 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 - *******************************************************************************/ -package org.eclipse.jst.ws.internal.common; - -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.wst.command.internal.env.core.data.Transformer; - - -/** - * Transfroms a java.lang.String to an org.eclipse.core.runtime.IProject - */ -public class StringToIProjectTransformer implements Transformer -{ - /* (non-Javadoc) - * @see org.eclipse.wst.command.internal.env.core.data.Transformer#transform(java.lang.Object) - * @param Object This must be a java.lang.String - * @return Object Returns an IProject - */ - - public Object transform(Object value) - { - String project = (String)value; - int slashIndex = project.indexOf( '/' ); - String projectName = project; - - if( slashIndex != -1 ) - { - projectName = project.substring( 0, slashIndex ); - } - - return ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); - } -} diff --git a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/common/StringUtils.java b/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/common/StringUtils.java deleted file mode 100644 index 0c4bd2dc9..000000000 --- a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/common/StringUtils.java +++ /dev/null @@ -1,288 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 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 - *******************************************************************************/ - -package org.eclipse.jst.ws.internal.common; - -import java.io.IOException; -import java.io.InputStream; -import java.util.Enumeration; -import java.util.Vector; -import org.eclipse.jdt.core.JavaConventions; - -/** - * This class contains some useful string utilities that are not provided by - * either String or StringBuffer. - * - * @author Peter Moogk - * @date July 13, 2000 -**/ -public final class StringUtils -{ - - // Copyright - public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002."; - - /** - * The platform-specific line separator. - */ - public static final String NEWLINE = System.getProperty("line.separator"); - - private StringUtils(){}; - - /** - * This method splits a single line of text into multiple lines - * based on a maximum line length. The method will try to fit as - * many words as possible onto a line without exceeding the maximum - * line length. Note: the only case where a line might exceed the - * maximum is if a single word is longer than the maximum. - **/ - public static String[] splitter( String text, int max_length ) - { - Vector return_text = new Vector(20); - String[] return_str; - int index = 0; - - while( index < text.length() ) - { - String str = text.substring( index, Math.min( max_length + index, - text.length() ) ); - int space_index = str.lastIndexOf( " " ); - - if( index + str.length() < text.length() && - text.charAt( index + str.length() - 1 ) != ' ' && - text.charAt( index + str.length() ) != ' ' && - space_index != -1 ) - { - return_text.addElement( str.substring( 0, space_index ) ); - index += space_index + 1; - } - else - { - return_text.addElement( str.trim() ); - index += str.length(); - } - } - - return_str = new String[return_text.size()]; - - for( index = 0; index < return_text.size(); index++ ) - { - return_str[index] = (String)(return_text.elementAt(index)); - } - - return return_str; - } - - /** - * This method returns a string with a repeated number of characters. - **/ - static public String repeat( char the_char, int count ) - { - StringBuffer buf = new StringBuffer( count ); - - for( int index = 0; index < count; index++ ) - { - buf.append( the_char ); - } - - return buf.toString(); - } - - /** - * This method flattens an array of arguments to a string. - * The method respects embedded whitespace and quotes. - * <ul> - * <li>Any argument with embedded whitespace will be flattened out - * with enclosing quotes. For example, the single argument - * <u>Hello World</u> - * will be returned as - * <u>"Hello World"</u>. - * <li>Any argument with quotes will be flattened out with the - * quotes escaped. For example, the single argument - * <u>"Happy days"</u> - * will be returned as - * <u>\"Happy days\"</u>. - * </ul> - * @param arguments The array of strings to flatten. - * @return the flattened string. - */ - static public String flattenArguments ( String[] arguments ) - { - StringBuffer buf = new StringBuffer(); - - for (int i=0; i<arguments.length; i++) - { - // - // Append a separator (except the first time). - // - if (i > 0) buf.append(' '); - - // - // Look for whitespace. - // - boolean whitespace = false; - char[] chars = arguments[i].toCharArray(); - for (int j=0; !whitespace && j<chars.length; j++) - { - if (Character.isWhitespace(chars[j])) - { - whitespace = true; - } - } - - // - // Append the argument, quoted as necessary. - // - if (whitespace) buf.append('"'); - for (int j=0; j<chars.length; j++) - { - if (chars[j] == '"') buf.append('\\'); - buf.append(chars[j]); - } - if (whitespace) buf.append('"'); - } - - return buf.toString(); - } - - /** - * This method parses whitespace-delimitted filenames from - * the given <code>input</code> stream. <b>Limitation:</b> - * Quoted filenames or filenames with embedded whitespace - * are not currently supported. - * @param input The input stream. - * @return An enumeration of filenames from the stream. - */ - static public Enumeration parseFilenamesFromStream ( InputStream input ) - throws IOException - { - Vector filenames = new Vector(64,64); - StringBuffer buffer = null; - byte state = STATE_WS; - int ic = input.read(); - while (ic >= 0) - { - char c = (char)ic; - switch (state) - { - case STATE_WS: - if (!Character.isWhitespace(c)) - { - buffer = new StringBuffer(); - buffer.append(c); - state = STATE_NWS; - } - break; - case STATE_NWS: - if (!Character.isWhitespace(c)) - { - buffer.append(c); - } - else - { - String filename = buffer.toString(); - filenames.add(filename); - buffer = null; - state = STATE_WS; - } - break; - default: - break; - } - ic = input.read(); - } - return filenames.elements(); - } - - private static final byte STATE_WS = 0; - private static final byte STATE_NWS = 1; - - - /** - * Returns true is the type passed in is a primtive java type - * @param class name String - * @return true is primitive type - */ - public static boolean isPrimitiveType(String typeName) - { - - if (typeName.equalsIgnoreCase("boolean") || - typeName.equalsIgnoreCase("byte") || - typeName.equalsIgnoreCase("double") || - typeName.equalsIgnoreCase("float") || - typeName.equalsIgnoreCase("int") || - typeName.equalsIgnoreCase("long") || - typeName.equalsIgnoreCase("short") || - typeName.equalsIgnoreCase("char")) - return true; - return false; - - } - - /** - * The method replace the characters that are allowed in URIs - * and not allowed in Java class names to an underscore ('_') - * @param URI String - * @return valid Java class name String - */ - public static String URI2ClassName( String uri ) { - String className = uri; - for ( int i = 0; i < URI_SYMBOLS.length; i++ ) { - className = className.replace ( URI_SYMBOLS[i], UNDERSCORE ); - } - return className; - } - - private static final char[] URI_SYMBOLS = {'-', '~', '#', '/', '.'}; - private static final char UNDERSCORE = '_'; - - - /** - * This returns a valid Java identifier based on the given name. - * (follows JAX-RPC 1.0 Public Review Draft 2 recommendations) - */ - public static String javaIdentifierFor(String localName) - { - StringBuffer result = new StringBuffer(); - boolean skipped = false; - for (int i = 0, length = localName.length(); i < length; ++i) - { - char character = localName.charAt(i); - if (Character.isJavaIdentifierPart(character) && !isDelimiter(character)) - { - if (skipped && result.length() != 0) - { - character = Character.toUpperCase(character); - } - result.append(character); - skipped = false; - } - else - { - skipped =true; - } - } - - if (!JavaConventions.validateIdentifier(result.toString()).isOK()) - { - result.insert(0, "_"); - } - - return result.toString(); - } - - private static boolean isDelimiter(char character) - { - return "\u002D\u002E\u003A\u005F\u00B7\u0387\u06DD\u06DE".indexOf(character) != -1; - } - - -} diff --git a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/context/PersistentProjectTopologyContext.java b/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/context/PersistentProjectTopologyContext.java deleted file mode 100644 index ac8cc5b11..000000000 --- a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/context/PersistentProjectTopologyContext.java +++ /dev/null @@ -1,75 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 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 - *******************************************************************************/ - -package org.eclipse.jst.ws.internal.context; - -import java.util.StringTokenizer; -import org.eclipse.jst.ws.internal.plugin.WebServicePlugin; -import org.eclipse.wst.command.internal.env.context.PersistentContext; - - -public class PersistentProjectTopologyContext extends PersistentContext implements ProjectTopologyContext -{ - -public PersistentProjectTopologyContext () -{ - super( WebServicePlugin.getInstance()); -} - public void load() { - String[] ids = ProjectTopologyDefaults.getClientTypes(); - StringBuffer sb = new StringBuffer(); - for (int i = 0; i < ids.length; i++) - { - if (i != 0) - sb.append(" "); - sb.append(ids[i]); - } - setDefault(PREFERENCE_CLIENT_TYPES, sb.toString()); - setDefault(PREFERENCE_USE_TWO_EARS, ProjectTopologyDefaults.isUseTwoEARs()); - } - - public void setClientTypes(String[] ids) - { - StringBuffer sb = new StringBuffer(); - for (int i = 0; i < ids.length; i++) - { - if (i != 0) - sb.append(" "); - sb.append(ids[i]); - } - setValue(PREFERENCE_CLIENT_TYPES, sb.toString()); - } - - public String[] getClientTypes() - { - StringTokenizer st = new StringTokenizer(getValueAsString(PREFERENCE_CLIENT_TYPES)); - String[] s = new String[st.countTokens()]; - for (int i = 0; i < s.length; i++) - s[i] = st.nextToken(); - return s; - } - - public void setUseTwoEARs(boolean use) - { - setValue(PREFERENCE_USE_TWO_EARS, use); - } - public boolean isUseTwoEARs() - { - return getValueAsBoolean(PREFERENCE_USE_TWO_EARS); - } - - public ProjectTopologyContext copy() { - TransientProjectTopologyContext context = new TransientProjectTopologyContext(); - context.setClientTypes(getClientTypes()); - context.setUseTwoEARs(isUseTwoEARs()); - return context; -} -} diff --git a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/context/PersistentScenarioContext.java b/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/context/PersistentScenarioContext.java deleted file mode 100644 index 8d5ade995..000000000 --- a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/context/PersistentScenarioContext.java +++ /dev/null @@ -1,273 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 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 - *******************************************************************************/ - -package org.eclipse.jst.ws.internal.context; - -import java.util.StringTokenizer; -import org.eclipse.jst.ws.internal.ext.test.WebServiceTestExtension; -import org.eclipse.jst.ws.internal.ext.test.WebServiceTestRegistry; -import org.eclipse.jst.ws.internal.plugin.WebServicePlugin; -import org.eclipse.wst.command.internal.env.context.PersistentContext; - - -public class PersistentScenarioContext extends PersistentContext implements ScenarioContext -{ - public PersistentScenarioContext() - { - super(WebServicePlugin.getInstance()); - } - - public void load() - { - ScenarioDefaults defaults = new ScenarioDefaults(); - String[] ids = defaults.getWebServiceTestTypes(); - StringBuffer sb = new StringBuffer(); - for (int i = 0; i < ids.length; i++) - { - if (i != 0) sb.append(","); - sb.append(ids[i]); - } - String nonJavaTestService = defaults.getNonJavaTestServiceDefault(); - setDefaultStringIfNoDefault(PREFERENCE_WEBSERVICE_TEST_TYPES, sb.toString()); - setDefaultStringIfNoDefault(PREFERENCE_NON_JAVA_TEST_SERVICE, nonJavaTestService); - - setDefaultStringIfNoDefault(PREFERENCE_CLIENT_WEBSERVICE_TYPE, defaults.webserviceClientTypeDefault() ); - setDefaultStringIfNoDefault(PREFERENCE_WEBSERVICE_TYPE, defaults.webserviceTypeIdDefault() ); - setDefaultBooleanIfNoDefault(PREFERENCE_GENERATE_PROXY, defaults.generateProxyDefault() ); - setDefaultBooleanIfNoDefault(PREFERENCE_LAUNCH_WEBSERVICE_EXPLORER, defaults.launchWebserviceExplorerDefault() ); - setDefaultBooleanIfNoDefault(PREFERENCE_START_WEBSERVICE, defaults.startWebserviceDefault() ); - setDefaultBooleanIfNoDefault(PREFERENCE_TEST_WEBSERVICE, defaults.testWebserviceDefault() ); - setDefaultBooleanIfNoDefault(PREFERENCE_MONITOR_WEBSERVICE, defaults.getMonitorWebServiceDefault()); - setDefaultBooleanIfNoDefault(PREFERENCE_LAUNCH_SAMPLE, defaults.launchSample() ); - } - - public String getNonJavaTestService() - { - WebServiceTestRegistry registry = WebServiceTestRegistry.getInstance(); - String[] testTypes = getWebServiceTestTypes(); - for (int i = 0; i < testTypes.length; i++) - { - WebServiceTestExtension wse = (WebServiceTestExtension) registry - .getWebServiceExtensionsByName(testTypes[i]); - if (wse.testWSDL()) return testTypes[i]; - } - return ""; - } - - public void setWebServiceTestTypes(String[] ids) - { - StringBuffer sb = new StringBuffer(); - for (int i = 0; i < ids.length; i++) - { - if (i != 0) sb.append(","); - sb.append(ids[i]); - } - setValue(PREFERENCE_WEBSERVICE_TEST_TYPES, sb.toString()); - } - - public String[] getWebServiceTestTypes() - { - StringTokenizer st = new StringTokenizer( - getValueAsString(PREFERENCE_WEBSERVICE_TEST_TYPES), ","); - String[] s = new String[st.countTokens()]; - for (int i = 0; i < s.length; i++) - s[i] = st.nextToken(); - return s; - } - - public ScenarioContext copy() - { - TransientScenarioContext context = new TransientScenarioContext(); - context.setWebServiceTestTypes(getWebServiceTestTypes()); - context.setNonJavaTestService(getNonJavaTestService()); - - context.setClientWebServiceType( getClientWebServiceType() ); - context.setWebServiceType( getWebServiceType() ); - context.setLaunchWebServiceExplorer( getLaunchWebServiceExplorer() ); - context.setStartWebService( getStartWebService() ); - context.setGenerateProxy( getGenerateProxy() ); - context.setTestWebService( getTestWebService() ); - context.setMonitorWebService(getMonitorWebService()); - context.setLaunchSampleEnabled( isLaunchSampleEnabled() ); - - return context; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.ws.internal.context.ScenarioContext#getClientWebServiceType() - */ - public String getClientWebServiceType() - { - return getValueAsString(PREFERENCE_CLIENT_WEBSERVICE_TYPE); - } - - public String getClientWebServiceTypeDefault() - { - return getDefaultString(PREFERENCE_CLIENT_WEBSERVICE_TYPE); - } - - /* (non-Javadoc) - * @see org.eclipse.jst.ws.internal.context.ScenarioContext#getGenerateProxy() - */ - public boolean getGenerateProxy() - { - return getValueAsBoolean(PREFERENCE_GENERATE_PROXY); - } - - public boolean getGenerateProxyDefault() - { - return getDefaultBoolean(PREFERENCE_GENERATE_PROXY); - } - - /* (non-Javadoc) - * @see org.eclipse.jst.ws.internal.context.ScenarioContext#getLaunchWebServiceExplorer() - */ - public boolean getLaunchWebServiceExplorer() - { - return getValueAsBoolean(PREFERENCE_LAUNCH_WEBSERVICE_EXPLORER); - } - - public boolean getLaunchWebServiceExplorerDefault() - { - return getDefaultBoolean(PREFERENCE_LAUNCH_WEBSERVICE_EXPLORER); - } - - /* (non-Javadoc) - * @see org.eclipse.jst.ws.internal.context.ScenarioContext#getStartWebService() - */ - public boolean getStartWebService() - { - return getValueAsBoolean(PREFERENCE_START_WEBSERVICE); - } - - public boolean getStartWebServiceDefault() - { - return getDefaultBoolean(PREFERENCE_START_WEBSERVICE); - } - - /* (non-Javadoc) - * @see org.eclipse.jst.ws.internal.context.ScenarioContext#getTestWebService() - */ - public boolean getTestWebService() - { - return getValueAsBoolean(PREFERENCE_TEST_WEBSERVICE); - } - - public boolean getTestWebServiceDefault() - { - return getDefaultBoolean(PREFERENCE_TEST_WEBSERVICE); - } - - /* (non-Javadoc) - * @see org.eclipse.jst.ws.internal.context.ScenarioContext#getWebServiceType() - */ - public String getWebServiceType() - { - return getValueAsString(PREFERENCE_WEBSERVICE_TYPE); - } - - public String getWebServiceTypeDefault() - { - return getDefaultString(PREFERENCE_WEBSERVICE_TYPE); - } - - /* (non-Javadoc) - * @see org.eclipse.jst.ws.internal.context.ScenarioContext#setClientWebServiceType(java.lang.String) - */ - public void setClientWebServiceType(String value) - { - setValue( PREFERENCE_CLIENT_WEBSERVICE_TYPE, value); - } - - /* (non-Javadoc) - * @see org.eclipse.jst.ws.internal.context.ScenarioContext#setGenerateProxy(boolean) - */ - public void setGenerateProxy(boolean value) - { - setValue( PREFERENCE_GENERATE_PROXY, value); - } - - /* (non-Javadoc) - * @see org.eclipse.jst.ws.internal.context.ScenarioContext#setLaunchWebServiceExplorer(boolean) - */ - public void setLaunchWebServiceExplorer(boolean value) - { - setValue( PREFERENCE_LAUNCH_WEBSERVICE_EXPLORER, value); - } - - /* (non-Javadoc) - * @see org.eclipse.jst.ws.internal.context.ScenarioContext#setStartWebService(boolean) - */ - public void setStartWebService(boolean value) - { - setValue( PREFERENCE_START_WEBSERVICE, value); - } - - /* (non-Javadoc) - * @see org.eclipse.jst.ws.internal.context.ScenarioContext#setTestWebService(boolean) - */ - public void setTestWebService(boolean value) - { - setValue( PREFERENCE_TEST_WEBSERVICE, value); - } - /* (non-Javadoc) - * @see org.eclipse.jst.ws.internal.context.ScenarioContext#setWebServiceType(java.lang.String) - */ - public void setWebServiceType(String value) - { - setValue( PREFERENCE_WEBSERVICE_TYPE, value); - } - - /* (non-Javadoc) - * @see org.eclipse.jst.ws.internal.context.ScenarioContext#getMonitorWebService() - */ - public boolean getMonitorWebService() - { - return getValueAsBoolean(PREFERENCE_MONITOR_WEBSERVICE); - } - - public boolean getMonitorWebServiceDefault() - { - return getDefaultBoolean(PREFERENCE_MONITOR_WEBSERVICE); - } - - /* (non-Javadoc) - * @see org.eclipse.jst.ws.internal.context.ScenarioContext#setMonitorWebService(boolean) - */ - public void setMonitorWebService(boolean value) - { - setValue(PREFERENCE_MONITOR_WEBSERVICE, value); - } - - /* (non-Javadoc) - * @see org.eclipse.jst.ws.internal.context.ScenarioContext#getLaunchSampleEnabledDefault() - */ - public boolean getLaunchSampleEnabledDefault() - { - return getDefaultBoolean(PREFERENCE_LAUNCH_SAMPLE); - } - - /* (non-Javadoc) - * @see org.eclipse.jst.ws.internal.context.ScenarioContext#isLaunchSampleEnabled() - */ - public boolean isLaunchSampleEnabled() - { - return getValueAsBoolean(PREFERENCE_LAUNCH_SAMPLE); - } - - /* (non-Javadoc) - * @see org.eclipse.jst.ws.internal.context.ScenarioContext#setLaunchSampleEnabled(boolean) - */ - public void setLaunchSampleEnabled(boolean value) - { - setValue( PREFERENCE_LAUNCH_SAMPLE, value); - } -} diff --git a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/context/PersistentUDDIPreferenceContext.java b/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/context/PersistentUDDIPreferenceContext.java deleted file mode 100644 index f5888125b..000000000 --- a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/context/PersistentUDDIPreferenceContext.java +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 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 - *******************************************************************************/ -package org.eclipse.jst.ws.internal.context; - -import org.eclipse.jst.ws.internal.plugin.WebServicePlugin; -import org.eclipse.wst.command.internal.env.context.PersistentContext; - - -public class PersistentUDDIPreferenceContext extends PersistentContext implements UDDIPreferenceContext -{ - public PersistentUDDIPreferenceContext() - { - super(WebServicePlugin.getInstance()); - } - - public void load() - { - setDefault(PREFERENCE_UDDI_CAT_DATA_COLUMN_DELIMITER, UDDIPreferenceDefaults.getUddiCatDataColumnDelimiter()); - setDefault(PREFERENCE_UDDI_CAT_DATA_STRING_DELIMITER, UDDIPreferenceDefaults.getUddiCatDataStringDelimiter()); - } - - public void setUddiCatDataColumnDelimiter(String delimiter) - { - setValue(PREFERENCE_UDDI_CAT_DATA_COLUMN_DELIMITER, delimiter); - } - - public String getUddiCatDataColumnDelimiter() - { - return getValueAsString(PREFERENCE_UDDI_CAT_DATA_COLUMN_DELIMITER); - } - - public void setUddiCatDataStringDelimiter(String delimiter) - { - setValue(PREFERENCE_UDDI_CAT_DATA_STRING_DELIMITER, delimiter); - } - - public String getUddiCatDataStringDelimiter() - { - return getValueAsString(PREFERENCE_UDDI_CAT_DATA_STRING_DELIMITER); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/context/ProjectTopologyContext.java b/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/context/ProjectTopologyContext.java deleted file mode 100644 index 616d335a4..000000000 --- a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/context/ProjectTopologyContext.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 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 - *******************************************************************************/ - -package org.eclipse.jst.ws.internal.context; - -public interface ProjectTopologyContext -{ - /** - * This constant String is used to lookup the preferred order of the different client types - **/ - public static final String PREFERENCE_CLIENT_TYPES = "clientTypes"; - - /** - * This constant String is used to lookup the two EAR option - **/ - public static final String PREFERENCE_USE_TWO_EARS = "useTwoEARs"; - - public void setClientTypes(String[] ids); - public String[] getClientTypes(); - - public void setUseTwoEARs(boolean use); - public boolean isUseTwoEARs(); - - public ProjectTopologyContext copy(); -} diff --git a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/context/ProjectTopologyDefaults.java b/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/context/ProjectTopologyDefaults.java deleted file mode 100644 index b20c609db..000000000 --- a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/context/ProjectTopologyDefaults.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 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 - *******************************************************************************/ - -package org.eclipse.jst.ws.internal.context; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtensionRegistry; -import org.eclipse.core.runtime.Platform; - -public class ProjectTopologyDefaults -{ - public static final String[] getClientTypes() - { - IExtensionRegistry reg = Platform.getExtensionRegistry(); - IConfigurationElement[] elements = reg.getConfigurationElementsFor("org.eclipse.jst.ws.consumption.ui", "clientProjectType"); - String[] types = new String[elements.length]; - for (int i = 0; i < types.length; i++) - types[i] = elements[i].getAttribute("id"); - return types; - } - - public static final boolean isUseTwoEARs() - { - return true; - } -} diff --git a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/context/ScenarioContext.java b/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/context/ScenarioContext.java deleted file mode 100644 index 9bcbd2476..000000000 --- a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/context/ScenarioContext.java +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 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 - *******************************************************************************/ -package org.eclipse.jst.ws.internal.context; - -public interface ScenarioContext -{ - public final String PREFERENCE_WEBSERVICE_TEST_TYPES = "webServiceTestTypes"; - - public final String PREFERENCE_NON_JAVA_TEST_SERVICE= "nonJavaTestService"; - - public final String PREFERENCE_WEBSERVICE_TYPE = "webServiceType"; - - public final String PREFERENCE_START_WEBSERVICE = "startWebService"; - - public final String PREFERENCE_LAUNCH_WEBSERVICE_EXPLORER = "launchWebServiceExplorer"; - - public final String PREFERENCE_GENERATE_PROXY = "generateProxy"; - - public final String PREFERENCE_CLIENT_WEBSERVICE_TYPE = "clientWebServiceType"; - - public final String PREFERENCE_TEST_WEBSERVICE = "testWebService"; - - public final String PREFERENCE_MONITOR_WEBSERVICE = "monitorWebService"; - - public final String PREFERENCE_LAUNCH_SAMPLE = "launchSample"; - - public String[] getWebServiceTestTypes(); - public void setWebServiceTestTypes(String[] testTypes); - - public String getNonJavaTestService(); - - public String getWebServiceType(); - public String getWebServiceTypeDefault(); - public void setWebServiceType( String value ); - - public boolean getStartWebService(); - public boolean getStartWebServiceDefault(); - public void setStartWebService( boolean value ); - - public boolean getLaunchWebServiceExplorer(); - public boolean getLaunchWebServiceExplorerDefault(); - public void setLaunchWebServiceExplorer( boolean value ); - - public boolean getGenerateProxy(); - public boolean getGenerateProxyDefault(); - public void setGenerateProxy( boolean value ); - - public String getClientWebServiceType(); - public String getClientWebServiceTypeDefault(); - public void setClientWebServiceType( String value ); - - public boolean getTestWebService(); - public boolean getTestWebServiceDefault(); - public void setTestWebService( boolean value ); - - public boolean getMonitorWebService(); - public boolean getMonitorWebServiceDefault(); - public void setMonitorWebService(boolean value); - - public boolean isLaunchSampleEnabled(); - public boolean getLaunchSampleEnabledDefault(); - public void setLaunchSampleEnabled( boolean value ); - - public ScenarioContext copy(); -}
\ No newline at end of file diff --git a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/context/ScenarioDefaults.java b/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/context/ScenarioDefaults.java deleted file mode 100644 index ef9fe96b6..000000000 --- a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/context/ScenarioDefaults.java +++ /dev/null @@ -1,97 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 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 - *******************************************************************************/ -package org.eclipse.jst.ws.internal.context; - - -import org.eclipse.jst.ws.internal.data.LabelsAndIds; -import org.eclipse.jst.ws.internal.ext.test.WebServiceTestRegistry; - - - -public class ScenarioDefaults -{ - - - public String[] getWebServiceTestTypes() - { - //we will set the home grown sample as the first choice - WebServiceTestRegistry testRegistry = WebServiceTestRegistry.getInstance(); - - LabelsAndIds labelsandids = testRegistry.getLabelsAndIDs(); - String[] labels = labelsandids.getLabels_(); - String[] ids = labelsandids.getIds_(); - - String[] newNames = new String[labels.length]; - int index = -1; - for(int i = 0;i<ids.length;i++){ - if(ids[i].equals("org.eclipse.jst.ws.internal.consumption.ui.widgets.test.WebServiceSampleTest")) - index = i; - } - if(index != -1){ - newNames[0] = labels[index]; - int j = 1; - for(int i = 0;i<labels.length;i++){ - if(i != index){ - newNames[j] = labels[i]; - j++; - } - } - } - else return labels; - - return newNames; - } - - public String getNonJavaTestServiceDefault() - { - return "Web Services Explorer"; - } - - public String webserviceTypeIdDefault() - { - return "0/org.eclipse.jst.ws.wsImpl.java"; - } - - public boolean startWebserviceDefault() - { - return true; - } - - public boolean launchWebserviceExplorerDefault() - { - return false; - } - - public boolean generateProxyDefault() - { - return false; - } - - public String webserviceClientTypeDefault() - { - return "org.eclipse.jst.ws.client.type.java"; - } - - public boolean testWebserviceDefault() - { - return false; - } - - public boolean getMonitorWebServiceDefault() - { - return false; - } - - public boolean launchSample() - { - return true; - } -} diff --git a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/context/TransientProjectTopologyContext.java b/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/context/TransientProjectTopologyContext.java deleted file mode 100644 index e4a289bfc..000000000 --- a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/context/TransientProjectTopologyContext.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 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 - *******************************************************************************/ - -package org.eclipse.jst.ws.internal.context; - - -public class TransientProjectTopologyContext implements ProjectTopologyContext -{ - private String[] clientTypes; - private boolean twoEARs; - - public TransientProjectTopologyContext () {} - - public void setClientTypes(String[] clientTypes) - { - this.clientTypes = clientTypes; - } - public String[] getClientTypes() - { - return clientTypes; - } - - public void setUseTwoEARs(boolean use) - { - this.twoEARs = use; - } - public boolean isUseTwoEARs() - { - return twoEARs; - } - - public ProjectTopologyContext copy() { - TransientProjectTopologyContext context = new TransientProjectTopologyContext(); - context.setClientTypes(getClientTypes()); - context.setUseTwoEARs(isUseTwoEARs()); - return context; - } -} diff --git a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/context/TransientScenarioContext.java b/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/context/TransientScenarioContext.java deleted file mode 100644 index 87306196e..000000000 --- a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/context/TransientScenarioContext.java +++ /dev/null @@ -1,218 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 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 - *******************************************************************************/ - -package org.eclipse.jst.ws.internal.context; - -public class TransientScenarioContext implements ScenarioContext -{ - private String[] webServiceTestTypes; - private String nonJavaTestService; - private String webServiceType_; - private boolean startWebService_; - private boolean launchWebServiceExplorer_; - private boolean generateProxy_; - private String clientWebServiceType_; - private boolean testWebService_; - private boolean monitorWebService; - private boolean launchSample_; - - private ScenarioDefaults defaults = new ScenarioDefaults(); - - public TransientScenarioContext () {} - - public String getNonJavaTestService() - { - return nonJavaTestService; - } - - public void setNonJavaTestService(String nonJavaTestService) - { - this.nonJavaTestService = nonJavaTestService; - } - - public void setWebServiceTestTypes(String[] webServiceTestTypes) - { - this.webServiceTestTypes = webServiceTestTypes; - } - - public String[] getWebServiceTestTypes() - { - return webServiceTestTypes; - } - - public ScenarioContext copy() { - TransientScenarioContext context = new TransientScenarioContext(); - context.setWebServiceTestTypes(getWebServiceTestTypes()); - context.setNonJavaTestService(getNonJavaTestService()); - - context.setWebServiceType( getWebServiceType() ); - context.setClientWebServiceType( getClientWebServiceType() ); - context.setGenerateProxy( getGenerateProxy() ); - context.setLaunchWebServiceExplorer( getLaunchWebServiceExplorer() ); - context.setStartWebService( getStartWebService() ); - context.setTestWebService( getTestWebService() ); - context.setMonitorWebService(getMonitorWebService()); - context.setLaunchSampleEnabled( isLaunchSampleEnabled() ); - return context; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.ws.internal.context.ScenarioContext#getClientWebServiceType() - */ - public String getClientWebServiceType() - { - return clientWebServiceType_; - } - - public String getClientWebServiceTypeDefault(){ return defaults.webserviceClientTypeDefault(); } - - /* (non-Javadoc) - * @see org.eclipse.jst.ws.internal.context.ScenarioContext#getGenerateProxy() - */ - public boolean getGenerateProxy() - { - return generateProxy_; - } - - public boolean getGenerateProxyDefault(){ return defaults.generateProxyDefault(); } - - /* (non-Javadoc) - * @see org.eclipse.jst.ws.internal.context.ScenarioContext#getLaunchWebServiceExplorer() - */ - public boolean getLaunchWebServiceExplorer() - { - return launchWebServiceExplorer_; - } - - public boolean getLaunchWebServiceExplorerDefault(){ return defaults.launchWebserviceExplorerDefault(); } - - /* (non-Javadoc) - * @see org.eclipse.jst.ws.internal.context.ScenarioContext#getStartWebService() - */ - public boolean getStartWebService() - { - return startWebService_; - } - - public boolean getStartWebServiceDefault(){ return defaults.startWebserviceDefault(); } - - /* (non-Javadoc) - * @see org.eclipse.jst.ws.internal.context.ScenarioContext#getTestWebService() - */ - public boolean getTestWebService() - { - return testWebService_; - } - - public boolean getTestWebServiceDefault(){ return defaults.testWebserviceDefault(); } - - /* (non-Javadoc) - * @see org.eclipse.jst.ws.internal.context.ScenarioContext#getWebServiceType() - */ - public String getWebServiceType() - { - return webServiceType_; - } - - public String getWebServiceTypeDefault(){ return defaults.webserviceTypeIdDefault(); } - - /* (non-Javadoc) - * @see org.eclipse.jst.ws.internal.context.ScenarioContext#setClientWebServiceType(java.lang.String) - */ - public void setClientWebServiceType(String value) - { - clientWebServiceType_ = value; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.ws.internal.context.ScenarioContext#setGenerateProxy(boolean) - */ - public void setGenerateProxy(boolean value) - { - generateProxy_ = value; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.ws.internal.context.ScenarioContext#setLaunchWebServiceExplorer(boolean) - */ - public void setLaunchWebServiceExplorer(boolean value) - { - launchWebServiceExplorer_ = value; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.ws.internal.context.ScenarioContext#setStartWebService(boolean) - */ - public void setStartWebService(boolean value) - { - startWebService_ = value; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.ws.internal.context.ScenarioContext#setTestWebService(boolean) - */ - public void setTestWebService(boolean value) - { - testWebService_ = value; - } - /* (non-Javadoc) - * @see org.eclipse.jst.ws.internal.context.ScenarioContext#setWebServiceType(java.lang.String) - */ - public void setWebServiceType(String value) - { - webServiceType_ = value; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.ws.internal.context.ScenarioContext#getMonitorWebService() - */ - public boolean getMonitorWebService() - { - return monitorWebService; - } - - public boolean getMonitorWebServiceDefault() - { - return defaults.getMonitorWebServiceDefault(); - } - - /* (non-Javadoc) - * @see org.eclipse.jst.ws.internal.context.ScenarioContext#setMonitorWebService(boolean) - */ - public void setMonitorWebService(boolean value) - { - monitorWebService = value; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.ws.internal.context.ScenarioContext#getLaunchSampleEnabledDefault() - */ - public boolean getLaunchSampleEnabledDefault() - { - return defaults.launchSample(); - } - - /* (non-Javadoc) - * @see org.eclipse.jst.ws.internal.context.ScenarioContext#isLaunchSampleEnabled() - */ - public boolean isLaunchSampleEnabled() - { - return launchSample_; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.ws.internal.context.ScenarioContext#setLaunchSampleEnabled(boolean) - */ - public void setLaunchSampleEnabled(boolean value) - { - launchSample_ = value; - } -} diff --git a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/context/UDDIPreferenceContext.java b/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/context/UDDIPreferenceContext.java deleted file mode 100644 index a24addb41..000000000 --- a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/context/UDDIPreferenceContext.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 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 - *******************************************************************************/ -package org.eclipse.jst.ws.internal.context; - -public interface UDDIPreferenceContext -{ - /* - * This constant String is used to lookup the column delimiter for user-defined UDDI - * Category data. - */ - public static final String PREFERENCE_UDDI_CAT_DATA_COLUMN_DELIMITER = "uddiCatDataColumnDelimiter"; - - /* - * This constant String is used to lookup the string delimiter for user-defined UDDI - * Category data. - */ - public static final String PREFERENCE_UDDI_CAT_DATA_STRING_DELIMITER = "uddiCatDataStringDelimiter"; - - public void setUddiCatDataColumnDelimiter(String delimiter); - public String getUddiCatDataColumnDelimiter(); - public void setUddiCatDataStringDelimiter(String delimiter); - public String getUddiCatDataStringDelimiter(); -}
\ No newline at end of file diff --git a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/context/UDDIPreferenceDefaults.java b/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/context/UDDIPreferenceDefaults.java deleted file mode 100644 index 39eba91a8..000000000 --- a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/context/UDDIPreferenceDefaults.java +++ /dev/null @@ -1,24 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 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 - *******************************************************************************/ -package org.eclipse.jst.ws.internal.context; - -public class UDDIPreferenceDefaults -{ - public static final String getUddiCatDataColumnDelimiter() - { - return "#"; - } - - public static final String getUddiCatDataStringDelimiter() - { - return "\""; - } -} diff --git a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/data/LabelsAndIds.java b/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/data/LabelsAndIds.java deleted file mode 100644 index 4bd0f64e4..000000000 --- a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/data/LabelsAndIds.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 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 - *******************************************************************************/ -/** - */ -package org.eclipse.jst.ws.internal.data; - -public class LabelsAndIds -{ - private String[] labels_; - private String[] ids_; - - /** - * @return Returns the ids_. - */ - public String[] getIds_() - { - return ids_; - } - /** - * @param ids_ The ids_ to set. - */ - public void setIds_(String[] ids_) - { - this.ids_ = ids_; - } - /** - * @return Returns the labels_. - */ - public String[] getLabels_() - { - return labels_; - } - /** - * @param labels_ The labels_ to set. - */ - public void setLabels_(String[] labels_) - { - this.labels_ = labels_; - } -} diff --git a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/data/TypeRuntimeServer.java b/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/data/TypeRuntimeServer.java deleted file mode 100644 index 4dc349d16..000000000 --- a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/data/TypeRuntimeServer.java +++ /dev/null @@ -1,86 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 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 - *******************************************************************************/ -/** - */ -package org.eclipse.jst.ws.internal.data; - -public class TypeRuntimeServer -{ - private String typeId_ = ""; - private String runtimeId_ = ""; - private String serverId_ = ""; - private String serverInstanceId_; - - /** - * @return Returns the runtimeId_. - */ - public String getRuntimeId() - { - return runtimeId_; - } - /** - * @param runtimeId_ The runtimeId_ to set. - */ - public void setRuntimeId(String runtimeId_) - { - this.runtimeId_ = runtimeId_; - } - /** - * @return Returns the serverId_. - */ - public String getServerId() - { - return serverId_; - } - /** - * @param serverId_ The serverId_ to set. - */ - public void setServerId(String serverId_) - { - this.serverId_ = serverId_; - } - /** - * @return Returns the serverInstanceId_. - */ - public String getServerInstanceId() - { - return serverInstanceId_; - } - /** - * @param serverInstanceId_ The serverInstanceId_ to set. - */ - public void setServerInstanceId(String serverInstanceId_) - { - this.serverInstanceId_ = serverInstanceId_; - } - /** - * @return Returns the typeId_. - */ - public String getTypeId() - { - return typeId_; - } - /** - * @param typeId_ The typeId_ to set. - */ - public void setTypeId(String typeId_) - { - this.typeId_ = typeId_; - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - public String toString() - { - return "type(" + typeId_ + ") runtime(" + runtimeId_ + ") factory(" + serverId_ + ") servInstId(" + serverInstanceId_ + ")"; - } -} diff --git a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/dialog/IStatusDialogConstants.java b/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/dialog/IStatusDialogConstants.java deleted file mode 100644 index 687bfeb8e..000000000 --- a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/dialog/IStatusDialogConstants.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2004 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 - *******************************************************************************/ - -package org.eclipse.jst.ws.internal.dialog; - -import org.eclipse.jst.ws.internal.plugin.WebServicePlugin; - -/** -* Constants for status dialogs -*/ -public interface IStatusDialogConstants { - - // Copyright - public static final String copyright = "(c) Copyright IBM Corporation 2002."; - - /* - * Button ID for the "Yes" button - */ - public static final int YES_ID = 2; - /* - * Button ID for the "Yes to all" button - */ - public static final int YES_TO_ALL_ID = 4; - /* - * Button ID for the "Cancel" button - */ - public static final int CANCEL_ID = 1; - /* - * Button ID for the "OK" button - */ - public static final int OK_ID = 0; - /* - * Button ID for the "Details" button - */ - public static final int DETAILS_ID = 13; - - /* - * Button label for the "Yes" button - */ - public static final String YES_LABEL = WebServicePlugin.getMessage("%STATUS_DIALOG_YES_LABEL"); - /* - * Button label for the "Yes to all" button - */ - public static final String YES_TO_ALL_LABEL = WebServicePlugin.getMessage("%STATUS_DIALOG_YES_TO_ALL_LABEL"); - /* - * Button label for the "Cancel" button - */ - public static final String CANCEL_LABEL = WebServicePlugin.getMessage("%STATUS_DIALOG_CANCEL_LABEL"); -} diff --git a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/ext/WebServiceExecutable.java b/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/ext/WebServiceExecutable.java deleted file mode 100644 index 9660fbb82..000000000 --- a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/ext/WebServiceExecutable.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 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 - *******************************************************************************/ - -package org.eclipse.jst.ws.internal.ext; - -import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation; - -/** -* All Extensions with exectutable extensions should implement this -* to fit our framework -*/ -public interface WebServiceExecutable -{ - // Copyright - public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002."; - /** - *Returns a wizard fragment for this exention type - * - */ - public AbstractDataModelOperation getFinishCommand(); -} - - diff --git a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/ext/WebServiceExtension.java b/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/ext/WebServiceExtension.java deleted file mode 100644 index 4332d0a74..000000000 --- a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/ext/WebServiceExtension.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 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 - *******************************************************************************/ - -package org.eclipse.jst.ws.internal.ext; - -import org.eclipse.core.runtime.IConfigurationElement; - - -/** -* This represents an extension in the plugin registry -* It job is to act as a proxy to the iconfigelement -*/ -public interface WebServiceExtension -{ - // Copyright - public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002."; - - /** - * If the extension has code that needs to be executed or a fragment added - * @return WebServiceExecutable this interface holds executable code and a - * fragment - */ - public Object getWebServiceExecutableExtension(); - - /** - * This is the config element that holds the extension info - * @param IConfigurationElement Extension element - */ - public void setConfigElement(IConfigurationElement configElement); - - /** - * If the extension has code that - * @return IConfigurationElement Extension element - */ - public IConfigurationElement getConfigElement(); -} - - diff --git a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/ext/WebServiceExtensionImpl.java b/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/ext/WebServiceExtensionImpl.java deleted file mode 100644 index 7d9d92fe5..000000000 --- a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/ext/WebServiceExtensionImpl.java +++ /dev/null @@ -1,100 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 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 - *******************************************************************************/ - -package org.eclipse.jst.ws.internal.ext; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.wst.common.environment.EnvironmentService; -import org.eclipse.wst.common.environment.ILog; - - - - - -/** -* This represents an extension in the plugin registry -* It job is to act as a proxy to the iconfigelement -*/ -public class WebServiceExtensionImpl implements WebServiceExtension -{ - - private ILog log_; - - /* - * The ConfigElement that holds extension info - */ - protected IConfigurationElement configElement_; - - /* - * The extension executable - */ - protected WebServiceExecutable webServiceExecutable_; - - - public WebServiceExtensionImpl(IConfigurationElement configElement) - { - configElement_ = configElement; - log_ = EnvironmentService.getEclipseLog(); - } - - // Copyright - public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002."; - - /** - * If the extension has code that needs to be executed or a fragment added - * @return WebServiceExecutable this interface holds executable code and a - * fragment - */ - public Object getWebServiceExecutableExtension() - { - if(webServiceExecutable_ != null) return webServiceExecutable_; - - try{ - return configElement_.createExecutableExtension("class"); - }catch (CoreException e){ - log_.log(ILog.ERROR, 5029, this, "getWebServiceExecutableExtension",e); - } - - return null; - } - - /** - * This is the config element that holds the extension info - * @param IConfigurationElement Extension element - */ - public void setConfigElement(IConfigurationElement configElement) - { - configElement_ = configElement; - } - - /** - * This is the config element that holds the extension info - * @return IConfigurationElement Extension element - */ - public IConfigurationElement getConfigElement() - { - return configElement_; - } - - /** - * The name of the extension being used - * @return String name of this extension - */ - public String getName() - { - return getConfigElement().getAttribute( "name" ); - } - - -} - - diff --git a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/ext/WebServiceExtensionRegistry.java b/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/ext/WebServiceExtensionRegistry.java deleted file mode 100644 index afc1d0721..000000000 --- a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/ext/WebServiceExtensionRegistry.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 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 - *******************************************************************************/ - -package org.eclipse.jst.ws.internal.ext; - - -/** -* Returns the names of the extensions for a given extension-point -* also returns the extension objects -* -*/ -public interface WebServiceExtensionRegistry -{ - - /** - * Returns the names of all registered extensions - * @return The names of all registered extensions. - */ - public String[] getWebServiceExtensionNames (); - - /** - * Returns the extension object of the given name - *@return WebServiceExtension object - */ - public WebServiceExtension getWebServiceExtensionsByName( String name); - - /** - * Returns All extention objects in this registry - *@return WebServiceExtension objects - */ - public WebServiceExtension[] getWebServiceExtensions(); - - -} diff --git a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/ext/WebServiceExtensionRegistryImpl.java b/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/ext/WebServiceExtensionRegistryImpl.java deleted file mode 100644 index 5a9456f83..000000000 --- a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/ext/WebServiceExtensionRegistryImpl.java +++ /dev/null @@ -1,115 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 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 - *******************************************************************************/ - -package org.eclipse.jst.ws.internal.ext; - -import java.util.Hashtable; -import java.util.Vector; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.jst.ws.internal.data.LabelsAndIds; - - -/** -* This is a generic registry which sets up general code in handling -* IConfigElements for an extension -*/ -public abstract class WebServiceExtensionRegistryImpl implements WebServiceExtensionRegistry -{ - // Copyright - public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002."; - - private Hashtable nameExtensionTable_; - private Vector id_; - private Vector label_; - private LabelsAndIds labelsandids_; - - public WebServiceExtensionRegistryImpl() - { - nameExtensionTable_ = new Hashtable(); - label_ = new Vector(); - id_ = new Vector(); - loadExtensions(); - } - - /** - * Children registries will have different extension types - * @return WebserviceExtension holds a config elem - * for that extension capable of creating an executable file - */ - public abstract WebServiceExtension createWebServiceExtension(IConfigurationElement configElement); - - /** - * Children must implement how they get the IConfigurationElement[] - * @return IConfigurationElement[] an array of elements particular to that - * extension - */ - public abstract IConfigurationElement[] getConfigElements(); - - /* - * Loads WebServiceExtensions for WebServiceClientTest into this registry. - * This is done by querying the plugin registry for all extensions - * that extend webServiceClientTest - */ - private void loadExtensions () - { - IConfigurationElement[] config = getConfigElements(); - - for(int idx=0; idx<config.length; idx++) - { - IConfigurationElement elem = config[idx]; - String label = elem.getAttribute( "label" ); - String id = elem.getAttribute( "id" ); - WebServiceExtension webServiceExtension = createWebServiceExtension(elem); - nameExtensionTable_.put(label,webServiceExtension); - label_.add(label); - id_.add(id); - } - } - - /** - * Returns the names of all registered extensions - * @return The names of all registered extensions. - */ - public String[] getWebServiceExtensionNames () - { - return (String[])nameExtensionTable_.keySet().toArray( new String[0] ); - } - - /** - * Return the names and Ids - */ - public LabelsAndIds getLabelsAndIDs() - { - labelsandids_ = new LabelsAndIds(); - labelsandids_.setLabels_((String[])label_.toArray( new String[0] )); - labelsandids_.setIds_((String[])id_.toArray( new String[0] )); - return labelsandids_; - } - - /** - * Returns the extension object of the given name - * @return WebServiceExtension object - */ - public WebServiceExtension getWebServiceExtensionsByName( String name) - { - return (WebServiceExtension)nameExtensionTable_.get(name); - } - - /** - * Returns All extention objects in this registry - *@return WebServiceExtension objects - */ - public WebServiceExtension[] getWebServiceExtensions() - { - return (WebServiceExtension[])nameExtensionTable_.values().toArray( new WebServiceExtension[0] ); - } - -} diff --git a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/ext/test/JavaProxyTestCommand.java b/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/ext/test/JavaProxyTestCommand.java deleted file mode 100644 index 4eae34196..000000000 --- a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/ext/test/JavaProxyTestCommand.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2002 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 - *******************************************************************************/ - -package org.eclipse.jst.ws.internal.ext.test; - -import org.eclipse.wst.command.internal.env.core.selection.BooleanSelection; - -public interface JavaProxyTestCommand extends WebServiceTestFinishCommand -{ - - /** - * This holds an info class that comes from user input or some calcilations that needs to be - * used for the finish - */ - - public void setJspFolder(String jspFolder); - - public void setRunClientTest(boolean runClientTest); - - public void setSampleProject(String sampleProject); - - public void setProxyBean(String proxyBean); - - public void setSetEndpointMethod(String setEndpointMethod); - - public void setClientProject(String clientProject); - - public void setMethods(BooleanSelection[] methods); - - -} diff --git a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/ext/test/WSDLTestFinishCommand.java b/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/ext/test/WSDLTestFinishCommand.java deleted file mode 100644 index 1b29e53d4..000000000 --- a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/ext/test/WSDLTestFinishCommand.java +++ /dev/null @@ -1,19 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2002 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 - *******************************************************************************/ - -package org.eclipse.jst.ws.internal.ext.test; - -public interface WSDLTestFinishCommand extends WebServiceTestFinishCommand -{ - public void setServiceProject(String serverProject); - public void setWsdlServiceURL(String wsdlURI); - public void setExternalBrowser(boolean external); -} diff --git a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/ext/test/WebServiceTestExtension.java b/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/ext/test/WebServiceTestExtension.java deleted file mode 100644 index 76f7d777d..000000000 --- a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/ext/test/WebServiceTestExtension.java +++ /dev/null @@ -1,118 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 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 - *******************************************************************************/ - -package org.eclipse.jst.ws.internal.ext.test; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.jst.ws.internal.ext.WebServiceExtensionImpl; - - - -/** -* This represents an extension in the plugin registry -* It job is to act as a proxy to the iconfigelement -* In particular it holds a client test extension element -*/ -public class WebServiceTestExtension extends WebServiceExtensionImpl -{ - // Copyright - public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002."; - - public WebServiceTestExtension(IConfigurationElement configElement) - { - super(configElement); - } - - /** - * Will this testClient generate code - * @return boolean true if codegen needed - */ - public boolean isCodeGenNeeded() - { - return Boolean.valueOf(getConfigElement().getAttribute( "codegen" )).booleanValue(); - } - - /** - * Use the default Folder Provided by us - * @return boolean true if no special folder requires - */ - public boolean useDefaultCodeGenFolder() - { - return Boolean.valueOf(getConfigElement().getAttribute( "defaultcodegenfolder" )).booleanValue(); - } - - /** - * Use Special Folder for generated code - * @return String special folder name - */ - public String getCodeGenFolder() - { - return getConfigElement().getAttribute( "codegenfolder" ); - } - - /** - * Do we need to launch something - * @return Boolean if true launch codegen - */ - public boolean isLaunchRequired() - { - return Boolean.valueOf(getConfigElement().getAttribute( "launchRequired" )).booleanValue(); - } - - /** - * Do we need the methods for the proxy - * @return boolean true if proxy methods needed - */ - public boolean areMethodsNeeded() - { - return Boolean.valueOf(getConfigElement().getAttribute( "methodsneeded" )).booleanValue(); - } - - /** - * Does this test machine need a server - * @return boolean true if a server is required - */ - public boolean isServerNeeded() - { - return Boolean.valueOf(getConfigElement().getAttribute( "serverneeded" )).booleanValue(); - } - - /** - * Use the Default Server chosen by the wizard - * @return boolean true if the default server is wanted - */ - public boolean useDefaultServer() - { - return Boolean.valueOf(getConfigElement().getAttribute( "defaultserver" )).booleanValue(); - } - - /** - * Use the Default Server chosen by the wizard - * @return boolean true if the default server is wanted - */ - public String useServer() - { - return getConfigElement().getAttribute( "useserver" ); - } - - public boolean testWSDL() - { - String wsdl = getConfigElement().getAttribute( "testWSDL" ); - if(wsdl.equals("yes") || wsdl.equals("true")) - return true; - - return false; - } - - -} - - diff --git a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/ext/test/WebServiceTestFinishCommand.java b/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/ext/test/WebServiceTestFinishCommand.java deleted file mode 100644 index 74193670b..000000000 --- a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/ext/test/WebServiceTestFinishCommand.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2002 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 - *******************************************************************************/ - -package org.eclipse.jst.ws.internal.ext.test; - -import java.util.List; -import org.eclipse.wst.server.core.IServer; - -public interface WebServiceTestFinishCommand -{ - - /** - * If the command needs a server this is the chosen - * client serverID - * @param sampleServerTypeID - */ - public void setServerTypeID(String serviceServerTypeID); - - /** - * This is the IServer if required - * @param sampleExistingServer - */ - public void setExistingServer(IServer serviceExistingServer); - - /** - * This is the endpoints if monitor service is enabled - * @param endpoints - */ - public void setEndpoint(List endpoints); - -} diff --git a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/ext/test/WebServiceTestRegistry.java b/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/ext/test/WebServiceTestRegistry.java deleted file mode 100644 index 310e3d55c..000000000 --- a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/ext/test/WebServiceTestRegistry.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 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 - *******************************************************************************/ - -package org.eclipse.jst.ws.internal.ext.test; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtensionRegistry; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jst.ws.internal.ext.WebServiceExtension; -import org.eclipse.jst.ws.internal.ext.WebServiceExtensionRegistryImpl; - -public class WebServiceTestRegistry extends WebServiceExtensionRegistryImpl -{ - // Copyright - public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002."; - /* - * This is a singleton becasue it was decided that the memory foot print - * is not as expensive as the time taken retrieving the data - * - */ - - - private static WebServiceTestRegistry wstr; - - public static WebServiceTestRegistry getInstance() - { - if(wstr == null) wstr = new WebServiceTestRegistry(); - return wstr; - } - - private WebServiceTestRegistry() - { - super(); - } - - /** - * Children registries will have different extension types - * @return WebserviceExtension holds a config elem - * for that extension capable of creating an executable file - */ - public WebServiceExtension createWebServiceExtension(IConfigurationElement configElement) - { - return new WebServiceTestExtension(configElement); - } - - /** - * Children must implement how they get the IConfigurationElement[] - * @return IConfigurationElement[] an array of elements particular to that - * extension - */ - public IConfigurationElement[] getConfigElements() - { - IExtensionRegistry reg = Platform.getExtensionRegistry(); - IConfigurationElement[] config = reg.getConfigurationElementsFor( - "org.eclipse.jst.ws.consumption.ui", - "tester"); - return config; - } - - - - -} diff --git a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/plugin/WebServicePlugin.java b/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/plugin/WebServicePlugin.java deleted file mode 100644 index 0b5f0dd61..000000000 --- a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/internal/plugin/WebServicePlugin.java +++ /dev/null @@ -1,131 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 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 - *******************************************************************************/ - -package org.eclipse.jst.ws.internal.plugin; - -import java.text.MessageFormat; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.Plugin; -import org.eclipse.jst.ws.internal.context.PersistentProjectTopologyContext; -import org.eclipse.jst.ws.internal.context.PersistentScenarioContext; -import org.eclipse.jst.ws.internal.context.PersistentUDDIPreferenceContext; -import org.eclipse.jst.ws.internal.context.ProjectTopologyContext; -import org.eclipse.jst.ws.internal.context.ScenarioContext; -import org.eclipse.jst.ws.internal.context.UDDIPreferenceContext; -import org.eclipse.wst.command.internal.env.context.PersistentResourceContext; -import org.eclipse.wst.command.internal.env.core.context.ResourceContext; - - -/** -* This is the plugin class for the Web Services plugin. -* <p> -* This plugin contains the bulk of the Web Services runtime. -* Only the graphical user interface portion of the runtime is -* found elsewhere - in the org.eclipse.jst.ws.ui plugin. -*/ -public class WebServicePlugin extends Plugin -{ - /** - * The identifier of the descriptor of this plugin in plugin.xml. - */ - public static final String ID = "org.eclipse.jst.ws"; - - /** - * The reference to the singleton instance of this plugin. - */ - private static WebServicePlugin instance_; - - private PersistentResourceContext resourceContext_; - private PersistentScenarioContext scenarioContext_; - private PersistentProjectTopologyContext projectTopologyContext_; - private PersistentUDDIPreferenceContext uddiPreferenceContext; - - /** - * Constructs a runtime plugin object for this plugin. - */ - public WebServicePlugin() - { - super(); - instance_ = this; - } - - /** - * Returns the singleton instance of this plugin. - * @return The WebServicePlugin singleton. - */ - public static WebServicePlugin getInstance () - { - return instance_; - } - - protected void initializeDefaultPluginPreferences() - { - ((PersistentProjectTopologyContext) getProjectTopologyContext()).load(); - ((PersistentUDDIPreferenceContext) getUDDIPreferenceContext()).load(); - } - - public ResourceContext getResourceContext() - { - if (resourceContext_ == null) - resourceContext_ = PersistentResourceContext.getInstance(); - return resourceContext_; - } - - public ScenarioContext getScenarioContext() - { - if (scenarioContext_ == null) - { - scenarioContext_ = new PersistentScenarioContext(); - scenarioContext_.load(); - } - - return scenarioContext_; - } - - public ProjectTopologyContext getProjectTopologyContext() - { - if (projectTopologyContext_ == null) - projectTopologyContext_ = new PersistentProjectTopologyContext(); - return projectTopologyContext_; - } - - - public UDDIPreferenceContext getUDDIPreferenceContext() - { - if (uddiPreferenceContext == null) - uddiPreferenceContext = new PersistentUDDIPreferenceContext(); - return uddiPreferenceContext; - } - - /** - * Returns the message string identified by the given key from - * plugin.properties. - * @return The String message. - */ - public static String getMessage ( String key ) - { - return Platform.getResourceString(instance_.getBundle(),key); - } - - /** - * Returns the message string identified by the given key from - * plugin.properties. Substitution sequences in the message string - * are replaced by the given array of substitution objects (which - * are most frequently strings). See the JDK's - * {@link java.text.MessageFormat java.text.MessageFormat} - * class for further details on substitution. - * @return The String message. - */ - public static String getMessage ( String key, Object[] args ) - { - return MessageFormat.format(getMessage(key),args); - } -} diff --git a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/plugin.properties b/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/plugin.properties deleted file mode 100644 index 29bdaafde..000000000 --- a/bundles/org.eclipse.jst.ws/src/org/eclipse/jst/ws/plugin.properties +++ /dev/null @@ -1,16 +0,0 @@ -############################################################################### -# Copyright (c) 2004 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 -############################################################################### - -# -# Messages in plugin.xml. -# - -MSG_ERROR_SERVER=IWAB0213E Error in starting server. |