You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@axis.apache.org by sa...@apache.org on 2012/04/18 14:16:43 UTC
svn commit: r1327468 - in
/axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http:
./ impl/httpclient4/
Author: sagara
Date: Wed Apr 18 12:16:43 2012
New Revision: 1327468
URL: http://svn.apache.org/viewvc?rev=1327468&view=rev
Log:
Applied provided patch AXIS2-4318.
Added:
axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/
axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/AxisRequestEntityImpl.java (with props)
axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HTTPTransportHeaders.java (with props)
axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HttpTransportPropertiesImpl.java (with props)
axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/RESTRequestEntity2Impl.java (with props)
axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/RESTRequestEntityImpl.java (with props)
Modified:
axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/AxisRequestEntity.java
axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/RESTRequestEntity2.java
Modified: axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/AxisRequestEntity.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/AxisRequestEntity.java?rev=1327468&r1=1327467&r2=1327468&view=diff
==============================================================================
--- axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/AxisRequestEntity.java (original)
+++ axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/AxisRequestEntity.java Wed Apr 18 12:16:43 2012
@@ -26,7 +26,9 @@ import org.apache.axis2.transport.Messag
import org.apache.axis2.util.JavaUtils;
import javax.xml.stream.FactoryConfigurationError;
+import java.io.ByteArrayInputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.io.OutputStream;
import java.util.zip.GZIPOutputStream;
@@ -124,6 +126,10 @@ public abstract class AxisRequestEntity
public void setChunked(boolean chunked) {
this.chunked = chunked;
}
+
+ public InputStream getRequestEntityContent() throws IOException {
+ return new ByteArrayInputStream(messageFormatter.getBytes(messageContext, format));
+ }
}
Modified: axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/RESTRequestEntity2.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/RESTRequestEntity2.java?rev=1327468&r1=1327467&r2=1327468&view=diff
==============================================================================
--- axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/RESTRequestEntity2.java (original)
+++ axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/RESTRequestEntity2.java Wed Apr 18 12:16:43 2012
@@ -19,7 +19,9 @@
package org.apache.axis2.transport.http;
+import java.io.ByteArrayInputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.io.OutputStream;
public abstract class RESTRequestEntity2 {
@@ -59,5 +61,9 @@ public abstract class RESTRequestEntity2
public void setPostRequestBody(String postRequestBody) {
this.postRequestBody = postRequestBody;
}
-
+
+ public InputStream getRequestEntityContent() {
+ return new ByteArrayInputStream(this.postRequestBody.getBytes());
+ }
+
}
Added: axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/AxisRequestEntityImpl.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/AxisRequestEntityImpl.java?rev=1327468&view=auto
==============================================================================
--- axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/AxisRequestEntityImpl.java (added)
+++ axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/AxisRequestEntityImpl.java Wed Apr 18 12:16:43 2012
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.transport.http.impl.httpclient4;
+
+import org.apache.axiom.om.OMOutputFormat;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.transport.MessageFormatter;
+import org.apache.axis2.transport.http.AxisRequestEntity;
+import org.apache.axis2.transport.http.HTTPConstants;
+import org.apache.http.Header;
+import org.apache.http.HttpEntity;
+import org.apache.http.message.BasicHeader;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+/**
+ * This Request Entity is used by the HttpComponentsTransportSender. This wraps the
+ * Axis2 message formatter object.
+ */
+public class AxisRequestEntityImpl extends AxisRequestEntity implements HttpEntity {
+
+ /**
+ * Method calls to this request entity are delegated to the following Axis2
+ * message formatter object.
+ *
+ * @param messageFormatter
+ * @param msgContext
+ * @param format
+ * @param soapAction
+ * @param chunked
+ * @param isAllowedRetry
+ */
+ public AxisRequestEntityImpl(MessageFormatter messageFormatter, MessageContext msgContext,
+ OMOutputFormat format, String soapAction, boolean chunked, boolean isAllowedRetry) {
+ super(messageFormatter, msgContext, format, soapAction, chunked, isAllowedRetry);
+ }
+
+ public Header getContentType() {
+ return new BasicHeader(HTTPConstants.HEADER_CONTENT_TYPE, getContentTypeAsString());
+ }
+
+ public Header getContentEncoding() {
+ return null;
+ }
+
+ public InputStream getContent() throws IOException {
+ return getRequestEntityContent();
+ }
+
+ public void writeTo(OutputStream outputStream) throws IOException {
+ writeRequest(outputStream);
+ }
+
+ public boolean isStreaming() {
+ return false;
+ }
+
+ public void consumeContent() {
+ // TODO: Handle this correctly
+ }
+
+}
Propchange: axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/AxisRequestEntityImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HTTPTransportHeaders.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HTTPTransportHeaders.java?rev=1327468&view=auto
==============================================================================
--- axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HTTPTransportHeaders.java (added)
+++ axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HTTPTransportHeaders.java Wed Apr 18 12:16:43 2012
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.transport.http.impl.httpclient4;
+
+import org.apache.axis2.transport.http.CommonsTransportHeaders;
+import org.apache.http.Header;
+
+import java.util.HashMap;
+
+
+public class HTTPTransportHeaders extends CommonsTransportHeaders {
+
+ private Header[] headers;
+
+ public HTTPTransportHeaders(Header[] headers) {
+ this.headers = headers;
+
+ }
+
+ protected void init() {
+ setHeaderMap(new HashMap());
+ for (int i = 0; i < headers.length; i++) {
+ getHeaderMap().put(headers[i].getName(), headers[i].getValue());
+ }
+ }
+
+}
Propchange: axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HTTPTransportHeaders.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HttpTransportPropertiesImpl.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HttpTransportPropertiesImpl.java?rev=1327468&view=auto
==============================================================================
--- axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HttpTransportPropertiesImpl.java (added)
+++ axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HttpTransportPropertiesImpl.java Wed Apr 18 12:16:43 2012
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.transport.http.impl.httpclient4;
+
+import org.apache.axis2.transport.http.HTTPAuthenticator;
+import org.apache.axis2.transport.http.HttpTransportProperties;
+import org.apache.http.HttpVersion;
+import org.apache.http.auth.AuthScope;
+import org.apache.http.client.params.AuthPolicy;
+
+public class HttpTransportPropertiesImpl extends HttpTransportProperties {
+
+ protected HttpVersion httpVersion;
+
+ @Override
+ public void setHttpVersion(Object httpVerion) {
+ this.httpVersion = (HttpVersion) httpVerion;
+ }
+
+ @Override
+ public Object getHttpVersion() {
+ return this.httpVersion;
+ }
+
+ /*
+ * This class is responsible for holding all the necessary information
+ * needed for NTML, Digest, Basic and SPNEGO(Keberos) Authentication.
+ * Authentication itself is handled by httpclient. User doesn't need
+ * to worry about what authentication mechanism it uses. Axis2 uses
+ * httpclinet's default authentication patterns.
+ */
+ public static class Authenticator extends HTTPAuthenticator {
+
+ /* port of the host that needed to be authenticated with */
+ private int port = AuthScope.ANY_PORT;
+ /* Realm for authentication scope */
+ private String realm = AuthScope.ANY_REALM;
+ /* Default Auth Schems */
+ public static final String NTLM = AuthPolicy.NTLM;
+ public static final String DIGEST = AuthPolicy.DIGEST;
+ public static final String BASIC = AuthPolicy.BASIC;
+ public static final String SPNEGO = AuthPolicy.SPNEGO;
+
+ public int getPort() {
+ return port;
+ }
+
+ public void setPort(int port) {
+ this.port = port;
+ }
+
+ public String getRealm() {
+ return realm;
+ }
+
+ public void setRealm(String realm) {
+ this.realm = realm;
+ }
+
+ @Override
+ public Object getAuthPolicyPref(String scheme) {
+ if (BASIC.equals(scheme)) {
+ return AuthPolicy.BASIC;
+ } else if (NTLM.equals(scheme)) {
+ return AuthPolicy.NTLM;
+ } else if (DIGEST.equals(scheme)) {
+ return AuthPolicy.DIGEST;
+ } else if (SPNEGO.equals(scheme)) {
+ return AuthPolicy.SPNEGO;
+ }
+ return null;
+ }
+
+ }
+
+}
Propchange: axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HttpTransportPropertiesImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/RESTRequestEntity2Impl.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/RESTRequestEntity2Impl.java?rev=1327468&view=auto
==============================================================================
--- axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/RESTRequestEntity2Impl.java (added)
+++ axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/RESTRequestEntity2Impl.java Wed Apr 18 12:16:43 2012
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.transport.http.impl.httpclient4;
+
+import org.apache.axis2.transport.http.HTTPConstants;
+import org.apache.axis2.transport.http.RESTRequestEntity2;
+import org.apache.http.Header;
+import org.apache.http.HttpEntity;
+import org.apache.http.message.BasicHeader;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+public class RESTRequestEntity2Impl extends RESTRequestEntity2 implements HttpEntity{
+
+ public RESTRequestEntity2Impl(String postRequestBody, String contentType) {
+ super(postRequestBody, contentType);
+ }
+
+ public boolean isChunked() {
+ return false;
+ }
+
+ public Header getContentType() {
+ return new BasicHeader(HTTPConstants.HEADER_CONTENT_TYPE, getContentTypeAsString());
+ }
+
+ public Header getContentEncoding() {
+ return null;
+ }
+
+ public InputStream getContent() throws IOException{
+ return getRequestEntityContent();
+ }
+
+ public void writeTo(OutputStream outputStream) throws IOException {
+ writeRequest(outputStream);
+ }
+
+ public boolean isStreaming() {
+ return false;
+ }
+
+ public void consumeContent() {
+ //TODO : Handle this correctly
+ }
+}
Propchange: axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/RESTRequestEntity2Impl.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/RESTRequestEntityImpl.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/RESTRequestEntityImpl.java?rev=1327468&view=auto
==============================================================================
--- axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/RESTRequestEntityImpl.java (added)
+++ axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/RESTRequestEntityImpl.java Wed Apr 18 12:16:43 2012
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.transport.http.impl.httpclient4;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMOutputFormat;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.transport.http.HTTPConstants;
+import org.apache.axis2.transport.http.RESTRequestEntity;
+import org.apache.http.Header;
+import org.apache.http.HttpEntity;
+import org.apache.http.message.BasicHeader;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+public class RESTRequestEntityImpl extends RESTRequestEntity implements HttpEntity {
+
+ public RESTRequestEntityImpl(OMElement element, boolean chunked, MessageContext msgCtxt,
+ String charSetEncoding, String soapActionString, OMOutputFormat format) {
+ super(element, chunked, msgCtxt, charSetEncoding, soapActionString, format);
+ }
+
+ public Header getContentType() {
+ return new BasicHeader(HTTPConstants.HEADER_CONTENT_TYPE, getContentTypeAsString());
+ }
+
+ public Header getContentEncoding() {
+ return null;
+ }
+
+ public InputStream getContent() throws AxisFault {
+ return new ByteArrayInputStream(writeBytes());
+ }
+
+ public void writeTo(OutputStream outputStream) throws IOException {
+ writeRequest(outputStream);
+ }
+
+ public boolean isStreaming() {
+ return false;
+ }
+
+ public void consumeContent() {
+ //TODO : Handle this correctly
+ }
+
+}
Propchange: axis/axis2/java/core/branches/AXIS2-4318/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/RESTRequestEntityImpl.java
------------------------------------------------------------------------------
svn:eol-style = native