diff options
Diffstat (limited to 'framework/bundles/org.eclipse.ecf.remoteservice.rest/src/org/eclipse/ecf/remoteservice/rest/client/AbstractEntityRequestType.java')
-rw-r--r-- | framework/bundles/org.eclipse.ecf.remoteservice.rest/src/org/eclipse/ecf/remoteservice/rest/client/AbstractEntityRequestType.java | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/framework/bundles/org.eclipse.ecf.remoteservice.rest/src/org/eclipse/ecf/remoteservice/rest/client/AbstractEntityRequestType.java b/framework/bundles/org.eclipse.ecf.remoteservice.rest/src/org/eclipse/ecf/remoteservice/rest/client/AbstractEntityRequestType.java index 7bf44ad2b..d10e4d45d 100644 --- a/framework/bundles/org.eclipse.ecf.remoteservice.rest/src/org/eclipse/ecf/remoteservice/rest/client/AbstractEntityRequestType.java +++ b/framework/bundles/org.eclipse.ecf.remoteservice.rest/src/org/eclipse/ecf/remoteservice/rest/client/AbstractEntityRequestType.java @@ -11,7 +11,8 @@ package org.eclipse.ecf.remoteservice.rest.client; import java.io.*; import java.util.Map; -import org.apache.commons.httpclient.methods.*; +import org.apache.http.HttpEntity; +import org.apache.http.entity.*; import org.eclipse.ecf.remoteservice.IRemoteCall; import org.eclipse.ecf.remoteservice.client.IRemoteCallParameter; import org.eclipse.ecf.remoteservice.client.IRemoteCallable; @@ -23,13 +24,14 @@ public abstract class AbstractEntityRequestType extends AbstractRequestType { public static final int STRING_REQUEST_ENTITY = 1; public static final int BYTEARRAY_REQUEST_ENTITY = 2; public static final int FILE_REQUEST_ENTITY = 3; + public static final long CONTENT_LENGTH_AUTO = -2; public static final String CHARSET_PARAM_NAME = "charset"; //$NON-NLS-1$ public static final String CONTENT_TYPE_PARAM_NAME = "contentType"; //$NON-NLS-1$ public static final String CONTENT_LENGTH_PARAM_NAME = "contentLength"; //$NON-NLS-1$ protected int requestEntityType = NO_REQUEST_ENTITY; - protected long defaultContentLength = InputStreamRequestEntity.CONTENT_LENGTH_AUTO; + protected long defaultContentLength = AbstractEntityRequestType.CONTENT_LENGTH_AUTO; protected String defaultContentType = null; protected String defaultCharset = null; @@ -54,7 +56,7 @@ public abstract class AbstractEntityRequestType extends AbstractRequestType { } public AbstractEntityRequestType(int requestEntityType, String defaultContentType, Map defaultRequestHeaders) { - this(requestEntityType, defaultContentType, InputStreamRequestEntity.CONTENT_LENGTH_AUTO, null, defaultRequestHeaders); + this(requestEntityType, defaultContentType, AbstractEntityRequestType.CONTENT_LENGTH_AUTO, null, defaultRequestHeaders); } public AbstractEntityRequestType(int requestEntityType, String defaultContentType) { @@ -77,19 +79,19 @@ public abstract class AbstractEntityRequestType extends AbstractRequestType { return requestEntityType > -1; } - public RequestEntity generateRequestEntity(String uri, IRemoteCall call, IRemoteCallable callable, IRemoteCallParameter paramDefault, Object paramToSerialize) throws NotSerializableException { - if (paramToSerialize instanceof RequestEntity) - return (RequestEntity) paramToSerialize; + public HttpEntity generateRequestEntity(String uri, IRemoteCall call, IRemoteCallable callable, IRemoteCallParameter paramDefault, Object paramToSerialize) throws NotSerializableException { + if (paramToSerialize instanceof HttpEntity) + return (HttpEntity) paramToSerialize; switch (requestEntityType) { case INPUT_STREAM_REQUEST_ENTITY : if (paramToSerialize instanceof InputStream) { - return new InputStreamRequestEntity((InputStream) paramToSerialize, getContentLength(call, callable, paramDefault), getContentType(call, callable, paramDefault)); + return new InputStreamEntity((InputStream) paramToSerialize, getContentLength(call, callable, paramDefault)); } throw new NotSerializableException("Cannot generate request entity. Expecting InputStream and got class=" + paramToSerialize.getClass().getName()); //$NON-NLS-1$ case STRING_REQUEST_ENTITY : if (paramToSerialize instanceof String) { try { - return new StringRequestEntity((String) paramToSerialize, getContentType(call, callable, paramDefault), getCharset(call, callable, paramDefault)); + return new StringEntity((String) paramToSerialize, getContentType(call, callable, paramDefault), getCharset(call, callable, paramDefault)); } catch (UnsupportedEncodingException e) { throw new NotSerializableException("Could not create request entity from call parameters: " + e.getMessage()); //$NON-NLS-1$ } @@ -97,12 +99,12 @@ public abstract class AbstractEntityRequestType extends AbstractRequestType { throw new NotSerializableException("Cannot generate request entity. Expecting String and got class=" + paramToSerialize.getClass().getName()); //$NON-NLS-1$ case BYTEARRAY_REQUEST_ENTITY : if (paramToSerialize instanceof byte[]) { - return new ByteArrayRequestEntity((byte[]) paramToSerialize, getContentType(call, callable, paramDefault)); + return new ByteArrayEntity((byte[]) paramToSerialize); } throw new NotSerializableException("Cannot generate request entity. Expecting byte[] and got class=" + paramToSerialize.getClass().getName()); //$NON-NLS-1$ case FILE_REQUEST_ENTITY : if (paramToSerialize instanceof File) { - return new FileRequestEntity((File) paramToSerialize, getContentType(call, callable, paramDefault)); + return new FileEntity((File) paramToSerialize, getContentType(call, callable, paramDefault)); } throw new NotSerializableException("Remote call parameter with name=" + paramDefault.getName() + " is incorrect type for creating request entity."); //$NON-NLS-1$ //$NON-NLS-2$ default : @@ -139,7 +141,7 @@ public abstract class AbstractEntityRequestType extends AbstractRequestType { try { return Integer.parseInt((String) o); } catch (NumberFormatException e) { - return InputStreamRequestEntity.CONTENT_LENGTH_AUTO; + return AbstractEntityRequestType.CONTENT_LENGTH_AUTO; } } } |