Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

summaryrefslogtreecommitdiffstats
blob: 33ecbe2a8498ff8bb9d586ba8253a337a823f88a (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
/*******************************************************************************
 * Copyright (c) 2006 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 * IBM Corporation - initial API and implementation
 * yyyymmdd bug      Email and other contact information
 * -------- -------- -----------------------------------------------------------
 * 20060509   125094 sengpl@ca.ibm.com - Seng Phung-Lu
 * 20060515   115225 sengpl@ca.ibm.com - Seng Phung-Lu
 * 20060728   145426 kathy@ca.ibm.com - Kathy Chan
 *******************************************************************************/
package org.eclipse.jst.ws.internal.axis.consumption.ui.task;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jst.ws.internal.axis.consumption.core.command.WSDL2JavaCommand;
import org.eclipse.jst.ws.internal.axis.consumption.core.common.JavaWSDLParameter;
import org.eclipse.ui.actions.WorkspaceModifyOperation;
import org.eclipse.wst.common.environment.IEnvironment;
import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
import org.eclipse.wst.ws.internal.parser.wsil.WebServicesParser;

public class ClientCodeGenOperation extends AbstractDataModelOperation {

	private CopyAxisJarCommand copyAxisJarCommand = null;
	
	private WSDL2JavaCommand wsdl2JavaCommand = null;
	private JavaWSDLParameter javaWSDLParam;
	private String wsdlURI;
	
	private IProject project;
	
	private Stub2BeanCommand stub2BeanCommand = null;
	private WebServicesParser webServicesParser;
	private String outputFolder;
	private String proxyBean;
	private String proxyEndpoint;
	
	private RefreshProjectCommand refreshProjectCommand = null;

	public ClientCodeGenOperation(){
		copyAxisJarCommand = new CopyAxisJarCommand();
		wsdl2JavaCommand = new WSDL2JavaCommand();
		stub2BeanCommand = new Stub2BeanCommand();
		refreshProjectCommand = new RefreshProjectCommand();
	}
	
	public IStatus execute(IProgressMonitor monitor, IAdaptable info) {

		IEnvironment env = getEnvironment();
		ClientWSModifyOperation buOperation = new ClientWSModifyOperation(info, env);
		try {
			buOperation.execute(monitor);
		}
		catch(CoreException ce){
			IStatus status = ce.getStatus();
			return status;
		}
		return Status.OK_STATUS;

	}

	
	private class ClientWSModifyOperation extends WorkspaceModifyOperation {
		
		  private IAdaptable info = null;
		  private IEnvironment env = null;

		  
		  protected ClientWSModifyOperation(IAdaptable adaptable, IEnvironment environment){
			  info = adaptable;
			  env = environment;
		  }
		  
		  protected void execute(IProgressMonitor monitor) throws CoreException{
		  
			    IStatus status = null;

			    // CopyAxisJarCommand
			    copyAxisJarCommand.setEnvironment(env);
			    copyAxisJarCommand.setProject(project);
			    status = copyAxisJarCommand.execute(monitor, info);
			    if (status.getSeverity() == Status.ERROR){
			    	throw new CoreException(status);
			    }
				
				// WSDL2JavaCommand
				wsdl2JavaCommand.setEnvironment(env);
				wsdl2JavaCommand.setJavaWSDLParam(javaWSDLParam);
				wsdl2JavaCommand.setWsdlURI(wsdlURI);
				status = wsdl2JavaCommand.execute(monitor, info);
				if (status.getSeverity() == Status.ERROR) {
					throw new CoreException(status);
				}
				
				// Stub2BeanCommand
				stub2BeanCommand.setEnvironment(env);
				stub2BeanCommand.setWebServicesParser(webServicesParser);
				stub2BeanCommand.setOutputFolder(outputFolder);
				stub2BeanCommand.setJavaWSDLParam(javaWSDLParam);
				stub2BeanCommand.setClientProject(project);
				status = stub2BeanCommand.execute(monitor, info);
				if (status.getSeverity() == Status.ERROR) {
					throw new CoreException(status);
				}
				proxyBean = stub2BeanCommand.getProxyBean();
				proxyEndpoint = stub2BeanCommand.getProxyEndpoint();
			  
				// RefreshProjectCommand
				refreshProjectCommand.setEnvironment(env);
				refreshProjectCommand.setProject(project);
				status = refreshProjectCommand.execute(monitor, info);
				if (status.getSeverity() == Status.ERROR) {
					throw new CoreException(status);
				}
				
		  }
		
	}


	public void setJavaWSDLParam(JavaWSDLParameter javaWSDLParam) {
		this.javaWSDLParam = javaWSDLParam;
	}

	public void setOutputFolder(String outputFolder) {
		this.outputFolder = outputFolder;
	}

	public void setProject(IProject project) {
		this.project = project;
	}

	public void setWebServicesParser(WebServicesParser webServicesParser) {
		this.webServicesParser = webServicesParser;
	}

	public void setWsdlURI(String wsdlURI) {
		this.wsdlURI = wsdlURI;
	}
		
	public String getProxyBean() {
		return proxyBean;
	}
	
	public String getProxyEndpoint() {
		return proxyEndpoint;
	}
	
}

Back to the top