Skip to main content
summaryrefslogtreecommitdiffstats
blob: bae22597790d6830a8ccc8949bc739f674b5477e (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
/*******************************************************************************
 * 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, Use WorkspaceModifyOperation
 * 20060515   115225 sengpl@ca.ibm.com - Seng Phung-Lu
 * 20060517   142327 kathy@ca.ibm.com - Kathy Chan
 *******************************************************************************/
package org.eclipse.jst.ws.internal.axis.creation.ui.command;

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.Java2WSDLCommand;
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.jst.ws.internal.axis.consumption.ui.task.CopyAxisJarCommand;
import org.eclipse.jst.ws.internal.axis.consumption.ui.task.RefreshProjectCommand;
import org.eclipse.jst.ws.internal.axis.creation.ui.task.UpdateAxisWSDDFileTask;
import org.eclipse.ui.actions.WorkspaceModifyOperation;
import org.eclipse.wst.common.environment.IEnvironment;
import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;

public class BUCodeGenOperation extends AbstractDataModelOperation {

	// CopyAxisJarCommand
	private CopyAxisJarCommand copyAxisJarCommand = null;
	
	// Java2WSDLCommand
	private Java2WSDLCommand java2WSDLCommand = null;
	private JavaWSDLParameter javaWSDLParam;  
	private String wsdlURI; 
	
	// wsdl2JavaCommand
	private WSDL2JavaCommand wsdl2JavaCommand = null;
		
	// UpdateAxisWSDDFileTask
	private UpdateAxisWSDDFileTask updateAxisWsddCommand = null;
	private IProject serviceProject;
	
	// UpdateWEBXMLCommand
	private UpdateWEBXMLCommand updateWebXMLCommand = null;
	
	// RefreshProjectCommand
	private RefreshProjectCommand refreshProjectCommand = null;

	/**
	 * This command runs the commands in the constructor in a WorkspaceModifyOperation.
	 * The commands are listed above, along with their relevant data registry parameters 
	 * @param java2WSDL
	 * @param wsdl2Java
	 * @param updateAxisWsdd
	 * @param updateWebXML
	 */
	public BUCodeGenOperation(){
		copyAxisJarCommand = new CopyAxisJarCommand();
		java2WSDLCommand = new Java2WSDLCommand();
		wsdl2JavaCommand = new WSDL2JavaCommand();
		updateAxisWsddCommand = new UpdateAxisWSDDFileTask();
		updateWebXMLCommand = new UpdateWEBXMLCommand();
		refreshProjectCommand = new RefreshProjectCommand();
	}

	public IStatus execute(IProgressMonitor monitor, IAdaptable info) {

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

	}

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

		  
		  protected BottomUpWSModifyOperation(IAdaptable adaptable, IEnvironment environment){
			  info = adaptable;
			  env = environment;
		  }
		  
		  protected void execute(IProgressMonitor monitor) throws CoreException{
		  
			    IStatus status = null;
			  
			    // CopyAxisJarCommand
			    copyAxisJarCommand.setEnvironment(env);
			    copyAxisJarCommand.setProject(serviceProject);
			    status = copyAxisJarCommand.execute(monitor, info);
			    if (status.getSeverity() == Status.ERROR){
			    	throw new CoreException(status);
			    }
			    
			  	// Java2WSDLCommand
				java2WSDLCommand.setEnvironment(env);
				java2WSDLCommand.setJavaWSDLParam(javaWSDLParam);
				status = java2WSDLCommand.execute(monitor, info);
				if (status.getSeverity() == Status.ERROR) {
					throw new CoreException(status);
				}
				wsdlURI = java2WSDLCommand.getWsdlURI();
				
				// WSDL2JavaCommand
				wsdl2JavaCommand.setEnvironment(env);
				wsdl2JavaCommand.setJavaWSDLParam(javaWSDLParam);
				status = wsdl2JavaCommand.execute(monitor, info);
				if (status.getSeverity() == Status.ERROR) {
					throw new CoreException(status);
				}
				javaWSDLParam = wsdl2JavaCommand.getJavaWSDLParam();
				
				// UpdateAxisWsddCommand
				updateAxisWsddCommand.setEnvironment(env);
				updateAxisWsddCommand.setJavaWSDLParam(javaWSDLParam);
				updateAxisWsddCommand.setServiceProject(serviceProject);
				status = updateAxisWsddCommand.execute(monitor, info);
				if (status.getSeverity() == Status.ERROR) {
					throw new CoreException(status);
				}
				javaWSDLParam = updateAxisWsddCommand.getJavaWSDLParam();
				
				// UpdateWebXMLCommand
				updateWebXMLCommand.setEnvironment(env);
				updateWebXMLCommand.setServerProject(serviceProject);
				status = updateWebXMLCommand.execute(monitor, info);
				if (status.getSeverity() == Status.ERROR) {
					throw new CoreException(status);
				}
				
				// RefreshProjectCommand
				refreshProjectCommand.setEnvironment(env);
				refreshProjectCommand.setProject(serviceProject);
				status = refreshProjectCommand.execute(monitor, info);
				if (status.getSeverity() == Status.ERROR) {
					throw new CoreException(status);
				}

			  
		  }
		
	}

	public String getWsdlURI() {
		return wsdlURI;
	}
	
	public JavaWSDLParameter getJavaWSDLParam() {
		return javaWSDLParam;
	}

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

	public void setServiceProject(IProject serviceProject) {
		this.serviceProject = serviceProject;
	}
	
}

Back to the top