Mercurial > repos > uga-galaxy-group > webservice_toolsuite_v1_1
comparison WebServiceExtensionsV1.1/WebServiceToolWorkflow_REST_SOAP/lib/SAWADLParser/src/edu/uga/cs/lsdis/meteors/wadls/ResourceImpl.java @ 0:049760c677de default tip
Galaxy WSExtensions added successfully
author | uga-galaxy-group |
---|---|
date | Tue, 05 Jul 2011 19:34:18 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:049760c677de |
---|---|
1 /* | |
2 * (c) Copyright IBM Corp 2001, 2005 | |
3 */ | |
4 | |
5 package edu.uga.cs.lsdis.meteors.wadls; | |
6 | |
7 import java.util.*; | |
8 | |
9 import javax.wadls.*; | |
10 import javax.wadls.ModelReference; | |
11 import javax.xml.namespace.*; | |
12 import org.w3c.dom.*; | |
13 | |
14 /** | |
15 * This class represents a port type. It contains information about | |
16 * operations associated with this port type. | |
17 * | |
18 * @author Paul Fremantle | |
19 * @author Nirmal Mukhi | |
20 * @author Matthew J. Duftler | |
21 * @author Zixin Wu | |
22 */ | |
23 public class ResourceImpl implements Resource | |
24 { | |
25 protected QName name = null; | |
26 protected List<ModelReference> modelReferences = null; | |
27 protected List methods = new Vector(); | |
28 protected List categories = new Vector(); | |
29 protected Element docEl = null; | |
30 protected Map extensionAttributes = new HashMap(); | |
31 protected List nativeAttributeNames = | |
32 Arrays.asList(Constants.PORT_TYPE_ATTR_NAMES); | |
33 protected boolean isUndefined = true; | |
34 | |
35 public static final long serialVersionUID = 1; | |
36 | |
37 | |
38 /** | |
39 * Get the category specifications in this portType. | |
40 * @return All the categories in this portType. | |
41 */ | |
42 public List getCategories() | |
43 { | |
44 return this.categories; | |
45 } | |
46 | |
47 /** | |
48 * Set the name of this port type. | |
49 * | |
50 * @param name the desired name | |
51 */ | |
52 public void setQName(QName name) | |
53 { | |
54 this.name = name; | |
55 } | |
56 | |
57 /** | |
58 * Get the name of this port type. | |
59 * | |
60 * @return the port type name | |
61 */ | |
62 public QName getQName() | |
63 { | |
64 return name; | |
65 } | |
66 | |
67 /** | |
68 * Add an operation to this port type. | |
69 * | |
70 * @param operation the operation to be added | |
71 */ | |
72 public void addMethod(Method operation) | |
73 { | |
74 methods.add(operation); | |
75 } | |
76 | |
77 /** | |
78 * Get the specified operation. Note that operation names can | |
79 * be overloaded within a PortType. In case of overloading, the | |
80 * names of the input and output messages can be used to further | |
81 * refine the search. | |
82 * | |
83 * @param name the name of the desired operation. | |
84 * @param inputName the name of the input message; if this is null | |
85 * it will be ignored. | |
86 * @param outputName the name of the output message; if this is null | |
87 * it will be ignored. | |
88 * @return the corresponding operation, or null if there wasn't | |
89 * any matching operation | |
90 */ | |
91 public Method getMethod(String name, | |
92 String inputName, | |
93 String outputName) | |
94 { | |
95 boolean found = false; | |
96 Method ret = null; | |
97 Iterator opIterator = methods.iterator(); | |
98 | |
99 while (opIterator.hasNext()) | |
100 { | |
101 Method op = (Method)opIterator.next(); | |
102 String opName = op.getName(); | |
103 | |
104 if (name != null && opName != null) | |
105 { | |
106 if (!name.equals(opName)) | |
107 { | |
108 op = null; | |
109 } | |
110 } | |
111 else if (name != null || opName != null) | |
112 { | |
113 op = null; | |
114 } | |
115 | |
116 if (op != null && inputName != null) | |
117 { | |
118 | |
119 String defaultInputName = opName; | |
120 defaultInputName = opName + "Request"; | |
121 boolean specifiedDefault = inputName.equals(defaultInputName); | |
122 Request input = op.getRequest(); | |
123 | |
124 if (input != null) | |
125 { | |
126 String opInputName = input.getName(); | |
127 | |
128 if (opInputName == null) | |
129 { | |
130 if (!specifiedDefault) | |
131 { | |
132 op = null; | |
133 } | |
134 } | |
135 else if (!opInputName.equals(inputName)) | |
136 { | |
137 op = null; | |
138 } | |
139 } | |
140 else | |
141 { | |
142 op = null; | |
143 } | |
144 } | |
145 | |
146 if (op != null && outputName != null) | |
147 { | |
148 String defaultOutputName = opName; | |
149 defaultOutputName = opName + "Response"; | |
150 boolean specifiedDefault = outputName.equals(defaultOutputName); | |
151 Response output = op.getResponse(); | |
152 | |
153 if (output != null) | |
154 { | |
155 String opOutputName = output.getName(); | |
156 | |
157 if (opOutputName == null) | |
158 { | |
159 if (!specifiedDefault) | |
160 { | |
161 op = null; | |
162 } | |
163 } | |
164 else if (!opOutputName.equals(outputName)) | |
165 { | |
166 op = null; | |
167 } | |
168 } | |
169 else | |
170 { | |
171 op = null; | |
172 } | |
173 } | |
174 | |
175 if (op != null) | |
176 { | |
177 if (found) | |
178 { | |
179 throw new IllegalArgumentException("Duplicate operation with " + | |
180 "name=" + name + | |
181 (inputName != null | |
182 ? ", inputName=" + inputName | |
183 : "") + | |
184 (outputName != null | |
185 ? ", outputName=" + outputName | |
186 : "") + | |
187 ", found in portType '" + | |
188 getQName() + "'."); | |
189 } | |
190 else | |
191 { | |
192 found = true; | |
193 ret = op; | |
194 } | |
195 } | |
196 } | |
197 | |
198 return ret; | |
199 } | |
200 public ModelReference getModelReference(){ | |
201 if(modelReferences == null) | |
202 return null; | |
203 return modelReferences.get(0); | |
204 } | |
205 | |
206 /** | |
207 * Set the modelReference. | |
208 * | |
209 * @param modelReference The desired modelReference. | |
210 */ | |
211 public void addModelReference(ModelReference modelReference){ | |
212 if(modelReferences == null) | |
213 modelReferences = new ArrayList<ModelReference>(); | |
214 modelReferences.add(0, modelReference); | |
215 } | |
216 public List<ModelReference> getModelReferences() { | |
217 return modelReferences; | |
218 } | |
219 | |
220 public void setModelReferences(List<ModelReference> refs) { | |
221 modelReferences = refs; | |
222 } | |
223 /** | |
224 * Get all the operations defined here. | |
225 */ | |
226 public List getMethods() | |
227 { | |
228 return methods; | |
229 } | |
230 | |
231 /** | |
232 * Set the documentation element for this document. This dependency | |
233 * on org.w3c.dom.Element should eventually be removed when a more | |
234 * appropriate way of representing this information is employed. | |
235 * | |
236 * @param docEl the documentation element | |
237 */ | |
238 public void setDocumentationElement(Element docEl) | |
239 { | |
240 this.docEl = docEl; | |
241 } | |
242 | |
243 /** | |
244 * Get the documentation element. This dependency on org.w3c.dom.Element | |
245 * should eventually be removed when a more appropriate way of | |
246 * representing this information is employed. | |
247 * | |
248 * @return the documentation element | |
249 */ | |
250 public Element getDocumentationElement() | |
251 { | |
252 return docEl; | |
253 } | |
254 | |
255 public void setUndefined(boolean isUndefined) | |
256 { | |
257 this.isUndefined = isUndefined; | |
258 } | |
259 | |
260 public boolean isUndefined() | |
261 { | |
262 return isUndefined; | |
263 } | |
264 | |
265 /** | |
266 * Set an extension attribute on this element. Pass in a null value to remove | |
267 * an extension attribute. | |
268 * | |
269 * @param name the extension attribute name | |
270 * @param value the extension attribute value. Can be a String, a QName, a | |
271 * List of Strings, or a List of QNames. | |
272 * | |
273 * @see #getExtensionAttribute | |
274 * @see #getExtensionAttributes | |
275 * @see ExtensionRegistry#registerExtensionAttributeType | |
276 * @see ExtensionRegistry#queryExtensionAttributeType | |
277 */ | |
278 public void setExtensionAttribute(QName name, Object value) | |
279 { | |
280 if (value != null) | |
281 { | |
282 extensionAttributes.put(name, value); | |
283 } | |
284 else | |
285 { | |
286 extensionAttributes.remove(name); | |
287 } | |
288 } | |
289 | |
290 /** | |
291 * Retrieve an extension attribute from this element. If the extension | |
292 * attribute is not defined, null is returned. | |
293 * | |
294 * @param name the extension attribute name | |
295 * | |
296 * @return the value of the extension attribute, or null if | |
297 * it is not defined. Can be a String, a QName, a List of Strings, or a List | |
298 * of QNames. | |
299 * | |
300 * @see #setExtensionAttribute | |
301 * @see #getExtensionAttributes | |
302 * @see ExtensionRegistry#registerExtensionAttributeType | |
303 * @see ExtensionRegistry#queryExtensionAttributeType | |
304 */ | |
305 public Object getExtensionAttribute(QName name) | |
306 { | |
307 return extensionAttributes.get(name); | |
308 } | |
309 | |
310 /** | |
311 * Get the map containing all the extension attributes defined | |
312 * on this element. The keys are the qnames of the attributes. | |
313 * | |
314 * @return a map containing all the extension attributes defined | |
315 * on this element | |
316 * | |
317 * @see #setExtensionAttribute | |
318 * @see #getExtensionAttribute | |
319 */ | |
320 public Map getExtensionAttributes() | |
321 { | |
322 return extensionAttributes; | |
323 } | |
324 | |
325 /** | |
326 * Get the list of local attribute names defined for this element in | |
327 * the WSDL specification. | |
328 * | |
329 * @return a List of Strings, one for each local attribute name | |
330 */ | |
331 public List getNativeAttributeNames() | |
332 { | |
333 return nativeAttributeNames; | |
334 } | |
335 | |
336 public String toString() | |
337 { | |
338 StringBuffer strBuf = new StringBuffer(); | |
339 | |
340 strBuf.append("PortType: name=" + name); | |
341 | |
342 if (methods != null) | |
343 { | |
344 Iterator opIterator = methods.iterator(); | |
345 | |
346 while (opIterator.hasNext()) | |
347 { | |
348 strBuf.append("\n" + opIterator.next()); | |
349 } | |
350 } | |
351 | |
352 Iterator keys = extensionAttributes.keySet().iterator(); | |
353 | |
354 while (keys.hasNext()) | |
355 { | |
356 QName name = (QName)keys.next(); | |
357 | |
358 strBuf.append("\nextension attribute: " + name + "=" + | |
359 extensionAttributes.get(name)); | |
360 } | |
361 | |
362 return strBuf.toString(); | |
363 } | |
364 } |