com.autodesk.workflows
Class Response

java.lang.Object
  extended by com.autodesk.workflows.Response

public class Response
extends java.lang.Object

Encapsulates Command responses. This class encapsulates the responses from workflow commands. Commands can respond with several possible types of values, job IDs, job status, error messages, etc. This class allows a command to set a descriptive response.

A response can include several parts, binary and non-binary. Separate methods allow these two parts to be sent to OutputStreams.

Additionally this class is used by clients to retrieve the data from a server response.


Constructor Summary
Response()
          Creates an initialized Response object.
Response(java.io.InputStream is, java.io.OutputStream os)
          Construct a client-side response.
Response(java.lang.String str)
          Construct a client-side response.
 
Method Summary
 byte[] getBinary()
          Get the binary portion of the response.
 java.lang.String getDebug()
          Get the unknown debug text portion of the response.
 java.io.File getFile()
          Get the file portion of the response.
 int getJobExitValue()
          Get the exit value from the process.
 long getJobID()
          Get the jobID.
 java.lang.String getJobMessage()
          Get the non-localized message for the job status.
 java.lang.String getJobStderr()
          Get the contents of the job's stdout stream.
 java.lang.String getJobStdout()
          Get the contents of the job's stdout stream.
 java.lang.String getLocalizedJobMessage()
          Get the localized message for the job status.
 int getPercentComplete()
          Get the percentage complete portion of the response.
 java.lang.String getStatus()
          Get the command status.
 java.lang.String getText()
          Get the text portion of the response.
 java.util.List getXML()
          Get the XML response.
 void output(java.io.OutputStream outputStream)
          Outputs the response to the stream.
 void setBinary(byte[] buffer)
          Set the binary response.
 void setDebug(java.lang.String text)
          Set some unknown debug text.
 void setFile(java.io.File file)
          Set the file to return.
 void setJobExitValue(int value)
          Set the exit value from the process.
 void setJobID(long jobID)
          Set the jobID.
 void setJobMessage(java.lang.String msg)
          Set a non-localized message for the job status.
 void setJobStderr(java.lang.String str)
          Set the contents of the job's stderr stream.
 void setJobStdout(java.lang.String str)
          Set the contents of the job's stdout stream.
 void setLocalizedJobMessage(java.lang.String msg)
          Set a localized message for the job status.
 void setPercentComplete(int percent)
          Set the percentage complete.
 void setStatus(java.lang.String status)
          Set the status of the command.
 void setText(java.lang.String text)
          Set some unknown text.
 void setXML(org.jdom.Element xml)
          Set the XML response.
 void setXML(java.util.List xml)
          Set the XML response.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Response

public Response()
Creates an initialized Response object. Call the various set*() methods to set the response.


Response

public Response(java.io.InputStream is,
                java.io.OutputStream os)
Construct a client-side response. This method is called from a client when it has received a message from a server. If mark/reset is supported on the input stream we can avoid reading the whole file into memory.

Parameters:
is - an input stream from the server. May not be null.
os - an output stream to write binary data to. May be null. (This is kind of klunky. There should be a better way to do this.)

Response

public Response(java.lang.String str)
Construct a client-side response. This method is called for a client when it has received a message from a server.

Parameters:
str - A string containing the XML response. Since this is a String, this method only works with simple responses. i.e. If a response contains a file, this method will not do anything with it.
Method Detail

setJobID

public void setJobID(long jobID)
Set the jobID. No validity checking is done to ensure the ID is valid.

Parameters:
jobID - the value to set.

getJobID

public long getJobID()
Get the jobID.


setStatus

public void setStatus(java.lang.String status)
Set the status of the command.

Parameters:
status - a string representing the status of the command.

getStatus

public java.lang.String getStatus()
Get the command status.


setJobMessage

public void setJobMessage(java.lang.String msg)
Set a non-localized message for the job status.

Parameters:
msg - a text description of the job status.

setLocalizedJobMessage

public void setLocalizedJobMessage(java.lang.String msg)
Set a localized message for the job status.

Parameters:
msg - a text description of the job status.

getJobMessage

public java.lang.String getJobMessage()
Get the non-localized message for the job status.


getLocalizedJobMessage

public java.lang.String getLocalizedJobMessage()
Get the localized message for the job status.


setJobStdout

public void setJobStdout(java.lang.String str)
Set the contents of the job's stdout stream.

Parameters:
str - textual contents of the stdout stream.

getJobStdout

public java.lang.String getJobStdout()
Get the contents of the job's stdout stream.


setJobStderr

public void setJobStderr(java.lang.String str)
Set the contents of the job's stderr stream.

Parameters:
str - textual contents of the stderr stream.

getJobStderr

public java.lang.String getJobStderr()
Get the contents of the job's stdout stream.


setXML

public void setXML(org.jdom.Element xml)
Set the XML response. The passed in Element node will not be cloned.

Parameters:
xml - an Element.

setXML

public void setXML(java.util.List xml)
Set the XML response. The passed in Element nodes will not be cloned.

Parameters:
xml - a List of XML elements.

getXML

public java.util.List getXML()
Get the XML response.


setBinary

public void setBinary(byte[] buffer)
Set the binary response. Only one of setBinary() or setFile() can be set for any one response. This method inherits the passed in buffer, it does not copy it. Callers must not modify the buffer after this method is called.

Parameters:
buffer - the binary data to return.

getBinary

public byte[] getBinary()
Get the binary portion of the response. This method returns the interal array for efficiency. Callers must not modify this array.


setFile

public void setFile(java.io.File file)
Set the file to return. Only one of setBinary() or setFile() can be set for any one response.

Parameters:
file - the file to return.

getFile

public java.io.File getFile()
Get the file portion of the response. This will only be a file name. There will be no actual file at the location.


setPercentComplete

public void setPercentComplete(int percent)
Set the percentage complete. This is currently unused and provided for future use.

Parameters:
percent - the percentage complete - a value from 0 to 100. No validity check is done.

getPercentComplete

public int getPercentComplete()
Get the percentage complete portion of the response.


setText

public void setText(java.lang.String text)
Set some unknown text. This allows a command to set a typeless response.

Parameters:
text - the typless text to return.

getText

public java.lang.String getText()
Get the text portion of the response.


setDebug

public void setDebug(java.lang.String text)
Set some unknown debug text. This allows a command to send any debug information required.

Parameters:
text - the typless text to return.

getDebug

public java.lang.String getDebug()
Get the unknown debug text portion of the response.


setJobExitValue

public void setJobExitValue(int value)
Set the exit value from the process.


getJobExitValue

public int getJobExitValue()
Get the exit value from the process. If the process hasn't completed yet this will be -1.


output

public void output(java.io.OutputStream outputStream)
Outputs the response to the stream. Depending on the value of greenbox.handler.version either simple text will be output or XML will be output. Eventually the text output will be deprecated.

Parameters:
outputStream - the stream to write the XML to.