public class ASUploadConnection extends Object
getOutputStream() an write their content to the returned OutputStreamfinishUpload() to actually upload the contentcancelUpload()
instead of finishUpload() if, for example, an IOException occured while writing their content
to the OutputStream.
Original code taken from https://github.com/jbossas/jboss-as/blob/master/testsuite/smoke/src/test/java/org/jboss/as/test/surefire/servermodule/HttpDeploymentUploadUnitTestCase.java| Constructor and Description |
|---|
ASUploadConnection(ASConnection asConnection)
Deprecated.
as of 4.6. This class is not reusable so there is no reason not to provide the filename to the
constructor. Use {@link #ASUploadConnection(ASConnection, String) instead.
|
ASUploadConnection(ASConnection asConnection,
String fileName)
Creates a new
ASUploadConnection from an existing ASConnection. |
ASUploadConnection(String host,
int port,
String user,
String password)
Deprecated.
as of 4.6. This class is not reusable so there is no reason not to provide the filename to the
constructor. Use
ASUploadConnection(String, int, String, String, String) instead. |
ASUploadConnection(String host,
int port,
String user,
String password,
String fileName)
Creates a new
ASUploadConnection for a remote http management interface. |
| Modifier and Type | Method and Description |
|---|---|
void |
cancelUpload()
To be called instead of
finishUpload() if one doesn't want to upload the cached content. |
org.codehaus.jackson.JsonNode |
finishUpload()
Triggers the real upload to the AS7 instance.
|
static String |
getFailureDescription(org.codehaus.jackson.JsonNode jsonNode)
Inspects the supplied
JsonNode instance and returns the json 'failure-description' node value as text. |
OutputStream |
getOutputStream()
Gives an outpustream where callers should write the content which will be uploaded to AS7
when
finishUpload() will be called. |
OutputStream |
getOutputStream(String fileName)
Deprecated.
as of 4.6. Instances of this class should be created with fileName supplied to the constructor.
If the caller does that there is no reason for late initialization of fileName. Then use
getOutputStream() instead. |
int |
getTimeout()
Get the currently active upload timeout
|
static boolean |
isErrorReply(org.codehaus.jackson.JsonNode jsonNode)
Inspects the supplied
JsonNode instance to determine if it represents an error outcome. |
static ASUploadConnection |
newInstanceForServerPluginConfiguration(ServerPluginConfiguration pluginConfig,
String fileName)
This factory method simplifies creation of a new
ASUploadConnection instance given the caller has
access to the ServerPluginConfiguration. |
void |
setTimeout(int timeout)
Set upload timeout in seconds.
|
@Deprecated public ASUploadConnection(String host, int port, String user, String password)
ASUploadConnection(String, int, String, String, String) instead.public ASUploadConnection(String host, int port, String user, String password, String fileName)
ASUploadConnection for a remote http management interface.
If null user or password is given, this instance will not be able to reply to an authentication challenge.
It's the responsibility of the caller to make sure either finishUpload() or cancelUpload()
will be called to free resources this class helds.host - - hostname of the remote http management interfaceport - - port of the remote http management interfaceuser - - username to logon with to the remote http management interface.password - - password to logon with to the remote http management interfacefileName - - fileName of the content (to provide in multipart post request)@Deprecated public ASUploadConnection(ASConnection asConnection)
public ASUploadConnection(ASConnection asConnection, String fileName)
ASUploadConnection from an existing ASConnection.
This constructor has the same requirements as ASUploadConnection(String, int, String, String, String)
which it uses internally.asConnection - - existing ASConnection instancefileName - - fileName of the content (to provide in multipart post request)public static ASUploadConnection newInstanceForServerPluginConfiguration(ServerPluginConfiguration pluginConfig, String fileName)
ASUploadConnection instance given the caller has
access to the ServerPluginConfiguration.pluginConfig - - the ServerPluginConfigurationfileName - - fileName of the content (to provide in multipart post request)@Deprecated public OutputStream getOutputStream(String fileName)
getOutputStream() instead.public OutputStream getOutputStream()
finishUpload() will be called.OutputStream or null if it could not be created.public void cancelUpload()
finishUpload() if one doesn't want to upload the cached content.
It's important to call this method if not actually uploading as it frees resources this class helds.public org.codehaus.jackson.JsonNode finishUpload()
OutputStream given by getOutputStream().JsonNode instance read from the upload response body or null if something went wrong.public static String getFailureDescription(org.codehaus.jackson.JsonNode jsonNode)
JsonNode instance and returns the json 'failure-description' node value as text.jsonNode - public static boolean isErrorReply(org.codehaus.jackson.JsonNode jsonNode)
JsonNode instance to determine if it represents an error outcome.jsonNode - public int getTimeout()
public void setTimeout(int timeout)
timeout - upload timeout in secondsCopyright © 2008-2013 Red Hat, Inc.. All Rights Reserved.