Author: keith
Date: Thu Apr 3 01:50:34 2008
New Revision: 15511
Log:
Reformating and deleting redundant code
Modified:
trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/wsrequest/WSRequestHostImpl.java
Modified:
trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/wsrequest/WSRequestHostImpl.java
==============================================================================
---
trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/wsrequest/WSRequestHostImpl.java
(original)
+++
trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/wsrequest/WSRequestHostImpl.java
Thu Apr 3 01:50:34 2008
@@ -27,9 +27,9 @@
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.client.async.AxisCallback;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.context.ConfigurationContextFactory;
import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.axis2.context.MessageContext;
import org.apache.axis2.description.WSDL2Constants;
import org.apache.axis2.transport.http.HTTPConstants;
import org.apache.axis2.transport.http.HttpTransportProperties;
@@ -40,35 +40,41 @@
import org.apache.commons.httpclient.cookie.CookiePolicy;
import org.apache.neethi.Policy;
import org.apache.rampart.RampartMessageData;
-import org.mozilla.javascript.*;
+import org.mozilla.javascript.Context;
+import org.mozilla.javascript.Function;
+import org.mozilla.javascript.NativeArray;
+import org.mozilla.javascript.Scriptable;
+import org.mozilla.javascript.ScriptableObject;
+import org.mozilla.javascript.Undefined;
+import org.mozilla.javascript.UniqueTag;
+import org.w3c.dom.Document;
import org.wso2.javascript.rhino.JavaScriptEngineConstants;
import org.wso2.javascript.xmlimpl.XML;
import org.wso2.mashup.MashupFault;
import org.wso2.mashup.utils.MashupUtils;
-import org.w3c.dom.Document;
+import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.wsdl.Service;
+import javax.wsdl.extensions.http.HTTPAddress;
+import javax.wsdl.extensions.soap.SOAPAddress;
+import javax.wsdl.extensions.soap12.SOAP12Address;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
-import javax.wsdl.xml.WSDLReader;
-import javax.wsdl.factory.WSDLFactory;
-import javax.wsdl.Definition;
-import javax.wsdl.Service;
-import javax.wsdl.Port;
-import javax.wsdl.extensions.soap12.SOAP12Address;
-import javax.wsdl.extensions.soap.SOAPAddress;
-import javax.wsdl.extensions.http.HTTPAddress;
import java.io.File;
import java.io.FileNotFoundException;
-import java.io.StringReader;
-import java.io.InputStream;
import java.io.IOException;
-import java.net.URL;
+import java.io.InputStream;
+import java.io.StringReader;
import java.net.MalformedURLException;
-import java.util.Map;
+import java.net.URL;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
/**
* <p/>
@@ -201,26 +207,7 @@
break;
case 4:
- if (arguments[1] instanceof org.wso2.javascript.xmlimpl.QName)
{
- org.wso2.javascript.xmlimpl.QName qName =
(org.wso2.javascript.xmlimpl.QName) arguments[1];
- String uri = (String) qName.get("uri", qName);
- String localName = (String) qName.get("localName", qName);
- service = new QName(uri, localName);
- if (arguments[2] instanceof String)
- endpointName = (String) arguments[2];
- else
- throw
Context.reportRuntimeError("INVALID_SYNTAX_EXCEPTION");
- if (arguments[3] instanceof Boolean)
- wsRequest.async = ((Boolean)
arguments[3]).booleanValue();
- else
- throw
Context.reportRuntimeError("INVALID_SYNTAX_EXCEPTION");
- if (arguments[0] instanceof String)
- url = (String) arguments[0];
- else
- throw
Context.reportRuntimeError("INVALID_SYNTAX_EXCEPTION");
- wsRequest.wsdlMode = true;
- }
- else if (arguments[2] instanceof String) {
+ if (arguments[2] instanceof String) {
username = (String) arguments[2];
if (arguments[3] instanceof String)
passwd = (String) arguments[3];
@@ -245,94 +232,78 @@
break;
}
- if (wsRequest.wsdlMode) {
- try {
- ConfigurationContext defaultConfigurationContext =
-
ConfigurationContextFactory.createDefaultConfigurationContext();
- wsRequest.sender =
- new ServiceClient(defaultConfigurationContext, new
URL(url), service,
- endpointName);
- } catch (MalformedURLException e) {
- throw new MashupFault(e);
- } catch (Exception e) {
- throw new MashupFault(e);
+ if (arguments[0] instanceof String) {
+ httpMethod = (String) arguments[0];
+ } else if (arguments[0] instanceof NativeArray) {
+ optionsArray = (NativeArray) arguments[0];
+ Object useSOAPObject = optionsArray.get("useSOAP", optionsArray);
+ if (useSOAPObject != null && !(useSOAPObject instanceof Undefined)
+ && !(useSOAPObject instanceof UniqueTag)) {
+ useSOAP = useSOAPObject.toString();
}
- } else {
- if (arguments[0] instanceof String) {
- httpMethod = (String) arguments[0];
- } else if (arguments[0] instanceof NativeArray) {
- optionsArray = (NativeArray) arguments[0];
- Object useSOAPObject = optionsArray.get("useSOAP",
optionsArray);
- if (useSOAPObject != null && !(useSOAPObject instanceof
Undefined)
- && !(useSOAPObject instanceof UniqueTag)) {
- useSOAP = useSOAPObject.toString();
- }
- Object hTTPMethodObject = optionsArray.get("HTTPMethod",
optionsArray);
- if (hTTPMethodObject != null && !(hTTPMethodObject instanceof
Undefined)
- && !(hTTPMethodObject instanceof UniqueTag)) {
- httpMethod = hTTPMethodObject.toString();
- }
-
- Object useWSAObject = optionsArray.get("useWSA", optionsArray);
- if (useWSAObject != null && !(useWSAObject instanceof
Undefined)
- && !(useWSAObject instanceof UniqueTag)) {
- useWSA = useWSAObject.toString();
- }
+ Object hTTPMethodObject = optionsArray.get("HTTPMethod",
optionsArray);
+ if (hTTPMethodObject != null && !(hTTPMethodObject instanceof
Undefined)
+ && !(hTTPMethodObject instanceof UniqueTag)) {
+ httpMethod = hTTPMethodObject.toString();
+ }
- Object useWSSObject = optionsArray.get("useWSS", optionsArray);
- if (useWSSObject != null && !(useWSSObject instanceof
Undefined)
- && !(useWSSObject instanceof UniqueTag)) {
- useWSS = useWSSObject.toString();
- }
+ Object useWSAObject = optionsArray.get("useWSA", optionsArray);
+ if (useWSAObject != null && !(useWSAObject instanceof Undefined)
+ && !(useWSAObject instanceof UniqueTag)) {
+ useWSA = useWSAObject.toString();
+ }
- Object actionObject = optionsArray.get("action", optionsArray);
- if (actionObject != null && !(actionObject instanceof
Undefined)
- && !(actionObject instanceof UniqueTag)) {
- action = actionObject.toString();
- }
+ Object useWSSObject = optionsArray.get("useWSS", optionsArray);
+ if (useWSSObject != null && !(useWSSObject instanceof Undefined)
+ && !(useWSSObject instanceof UniqueTag)) {
+ useWSS = useWSSObject.toString();
+ }
- Object httpLocationObject = optionsArray.get("HTTPLocation",
optionsArray);
- if (httpLocationObject != null && !(httpLocationObject
instanceof Undefined)
- && !(httpLocationObject instanceof UniqueTag)) {
- httpLocation = httpLocationObject.toString();
- }
+ Object actionObject = optionsArray.get("action", optionsArray);
+ if (actionObject != null && !(actionObject instanceof Undefined)
+ && !(actionObject instanceof UniqueTag)) {
+ action = actionObject.toString();
+ }
- Object httpLocationIgnoreUncitedObject =
- optionsArray.get("HTTPLocationIgnoreUncited",
optionsArray);
- if (httpLocationIgnoreUncitedObject != null &&
- !(httpLocationIgnoreUncitedObject instanceof Undefined)
- && !(httpLocationIgnoreUncitedObject instanceof
UniqueTag)) {
- httpLocationIgnoreUncited =
httpLocationIgnoreUncitedObject.toString();
- }
+ Object httpLocationObject = optionsArray.get("HTTPLocation",
optionsArray);
+ if (httpLocationObject != null && !(httpLocationObject instanceof
Undefined)
+ && !(httpLocationObject instanceof UniqueTag)) {
+ httpLocation = httpLocationObject.toString();
+ }
- Object httpQueryParameterSeparatorObject =
- optionsArray.get("HTTPQueryParameterSeparator",
optionsArray);
- if (httpQueryParameterSeparatorObject != null &&
- !(httpQueryParameterSeparatorObject instanceof
Undefined)
- && !(httpQueryParameterSeparatorObject instanceof
UniqueTag)) {
- httpQueryParameterSeparator =
httpQueryParameterSeparatorObject.toString();
- }
+ Object httpLocationIgnoreUncitedObject =
+ optionsArray.get("HTTPLocationIgnoreUncited",
optionsArray);
+ if (httpLocationIgnoreUncitedObject != null &&
+ !(httpLocationIgnoreUncitedObject instanceof Undefined)
+ && !(httpLocationIgnoreUncitedObject instanceof
UniqueTag)) {
+ httpLocationIgnoreUncited =
httpLocationIgnoreUncitedObject.toString();
+ }
- Object httpInputSerializationObject =
- optionsArray.get("HTTPInputSerialization",
optionsArray);
- if (httpInputSerializationObject != null &&
- !(httpInputSerializationObject instanceof Undefined)
- && !(httpInputSerializationObject instanceof
UniqueTag)) {
- httpInputSerialization =
httpInputSerializationObject.toString();
- }
+ Object httpQueryParameterSeparatorObject =
+ optionsArray.get("HTTPQueryParameterSeparator",
optionsArray);
+ if (httpQueryParameterSeparatorObject != null &&
+ !(httpQueryParameterSeparatorObject instanceof Undefined)
+ && !(httpQueryParameterSeparatorObject instanceof
UniqueTag)) {
+ httpQueryParameterSeparator =
httpQueryParameterSeparatorObject.toString();
+ }
- Object HTTPContentEncodingObject =
- optionsArray.get("HTTPContentEncoding", optionsArray);
- if (HTTPContentEncodingObject != null &&
- !(HTTPContentEncodingObject instanceof Undefined)
- && !(HTTPContentEncodingObject instanceof UniqueTag)) {
- httpLocation = HTTPContentEncodingObject.toString();
- }
+ Object httpInputSerializationObject =
+ optionsArray.get("HTTPInputSerialization", optionsArray);
+ if (httpInputSerializationObject != null &&
+ !(httpInputSerializationObject instanceof Undefined)
+ && !(httpInputSerializationObject instanceof UniqueTag)) {
+ httpInputSerialization =
httpInputSerializationObject.toString();
+ }
- } else {
- throw Context.reportRuntimeError("INVALID_SYNTAX_EXCEPTION");
+ Object HTTPContentEncodingObject =
+ optionsArray.get("HTTPContentEncoding", optionsArray);
+ if (HTTPContentEncodingObject != null &&
+ !(HTTPContentEncodingObject instanceof Undefined)
+ && !(HTTPContentEncodingObject instanceof UniqueTag)) {
+ httpLocation = HTTPContentEncodingObject.toString();
}
+
if (arguments[1] instanceof String) {
url = (String) arguments[1];
} else {
@@ -919,4 +890,4 @@
}
return (WSRequestHostImpl) obj;
}
-}
+}
\ No newline at end of file
_______________________________________________
Mashup-dev mailing list
[email protected]
http://www.wso2.org/cgi-bin/mailman/listinfo/mashup-dev