Skip to main content
summaryrefslogtreecommitdiffstats
blob: 7aa6af38b008c15aa5986301b4b001457d44b19a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
/*******************************************************************************
 * Copyright (c) 2003, 2008 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 * IBM Corporation - initial API and implementation
 * yyyymmdd bug      Email and other contact information
 * -------- -------- -----------------------------------------------------------
 * 20060216   115144 pmoogk@ca.ibm.com - Peter Moogk
 * 20060503   126819 rsinha@ca.ibm.com - Rupam Kuehner
 * 20080122   215866 trungha@ca.ibm.com - Trung Ha
 *******************************************************************************/
package org.eclipse.jst.ws.internal.axis.consumption.ui.command;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.jst.ws.internal.axis.consumption.core.AxisConsumptionCoreMessages;
import org.eclipse.jst.ws.internal.axis.consumption.core.common.JavaWSDLParameter;
import org.eclipse.jst.ws.internal.axis.consumption.ui.AxisConsumptionUIMessages;
import org.eclipse.jst.ws.internal.axis.consumption.ui.util.PlatformUtils;
import org.eclipse.jst.ws.internal.common.ResourceUtils;
import org.eclipse.wst.command.internal.env.core.common.StatusUtils;
import org.eclipse.wst.common.componentcore.ModuleCoreNature;
import org.eclipse.wst.common.environment.IEnvironment;
import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;

public class DefaultsForClientJavaWSDLCommand extends AbstractDataModelOperation
{
	private JavaWSDLParameter	javaWSDLParam_;
	private IProject					proxyProject_;
	private String						WSDLServiceURL_;
	private String						WSDLServicePathname_;
	private String						outputFolder_;

	public DefaultsForClientJavaWSDLCommand()
	{
	}

	public IStatus execute(IProgressMonitor monitor, IAdaptable adaptable)
	{
		IEnvironment environment = getEnvironment();
		IStatus status;
		
		if( outputFolder_ == null )
		{
			IPath[] paths = ResourceUtils.getAllJavaSourceLocations(proxyProject_);
			outputFolder_ = paths[0].toString();
		}
		
		if (javaWSDLParam_ == null)
		{
			status = StatusUtils
					.errorStatus(AxisConsumptionCoreMessages.MSG_ERROR_JAVA_WSDL_PARAM_NOT_SET);
			environment.getStatusHandler().reportError(status);
			return status;
		}
		javaWSDLParam_.setMetaInfOnly(false);
		javaWSDLParam_.setServerSide(JavaWSDLParameter.SERVER_SIDE_NONE);
		ModuleCoreNature mn = ModuleCoreNature.getModuleCoreNature(proxyProject_);
		if (mn != null)
		{
			IPath webModuleServerRoot = ResourceUtils.getJavaSourceLocation(proxyProject_);
			// String output = PlatformUtils.getPlatformURL(webModuleServerRoot);
			String output = ResourceUtils.findResource(webModuleServerRoot).getLocation().toString();
			// String output =
			// ResourceUtils.getWorkspaceRoot().getFolder(webModuleServerRoot).getLocation().toString();
			IPath javaOutput = ResourceUtils.findResource( new Path( outputFolder_ )).getLocation();
			javaWSDLParam_.setJavaOutput(javaOutput.toString());
			

			IPath webModulePath = ResourceUtils.getWebComponentServerRootPath(proxyProject_);
			// output = PlatformUtils.getPlatformURL(webModulePath);
			IResource res = ResourceUtils.findResource(webModulePath);
			if (res != null) {
				output = res.getLocation().toString();
			}
			javaWSDLParam_.setOutput(output);
		}
		else
		{
			// Check if it's a plain old Java project
			if (ResourceUtils.isJavaProject(proxyProject_))
			{
				IPath output = ResourceUtils.findResource( new Path( outputFolder_ )).getLocation();
				javaWSDLParam_.setJavaOutput(output.toString());
				javaWSDLParam_.setOutput(output.toString());
			}
			else
			{
				// Not familiar with this kind of project
				status = StatusUtils.errorStatus(AxisConsumptionUIMessages.MSG_WARN_NO_JAVA_NATURE);
				environment.getStatusHandler().reportError(status);
				return status;
			}
		}
		if (WSDLServicePathname_ == null)
		{
			if (WSDLServiceURL_ == null)
			{
				status = StatusUtils.errorStatus(AxisConsumptionUIMessages.MSG_ERROR_WSDL_LOCATION_NOT_SET);
				environment.getStatusHandler().reportError(status);
				return status;
			}
		}
		else
		{
			WSDLServiceURL_ = PlatformUtils.getFileFromPlatform(WSDLServicePathname_);
		}
		javaWSDLParam_.setInputWsdlLocation(WSDLServiceURL_);
		return Status.OK_STATUS;
	}

	/**
	 * Returns the javaWSDLParam.
	 * 
	 * @return JavaWSDLParameter
	 */
	public JavaWSDLParameter getJavaWSDLParam()
	{
		return javaWSDLParam_;
	}

	/**
	 * Sets the javaWSDLParam.
	 * 
	 * @param javaWSDLParam
	 *          The javaWSDLParam to set
	 */
	public void setJavaWSDLParam(JavaWSDLParameter javaWSDLParam)
	{
		this.javaWSDLParam_ = javaWSDLParam;
	}

	/**
	 * @param proxyProject_
	 *          The proxyProject_ to set.
	 */
	public void setProxyProject(IProject proxyProject)
	{
		this.proxyProject_ = proxyProject;
	}

	/**
	 * @param serviceURL_
	 *          The wSDLServiceURL_ to set.
	 */
	public void setWSDLServiceURL(String serviceURL)
	{
		WSDLServiceURL_ = serviceURL;
	}

	/**
	 * @param servicePathname_
	 *          The wSDLServicePathname_ to set.
	 */
	public void setWSDLServicePathname(String servicePathname)
	{
		WSDLServicePathname_ = servicePathname;
	}

	public String getOutputFolder()
	{
	  return outputFolder_;	
	}
	
	public void setOutputFolder(String outputFolder)
	{
		outputFolder_ = outputFolder;
	}
}

Back to the top