org.sakaiproject.entitybroker.entityprovider.extension
Class ActionReturn

java.lang.Object
  extended by org.sakaiproject.entitybroker.entityprovider.extension.ActionReturn

public class ActionReturn
extends Object

A special object used to return specialized results from a custom action execution, includes fields to allow for handling of encoded binary data and to indicate that entity action processing should continue as it would have if there had been no custom action call (rather than exiting the standard chain)

Author:
Aaron Zeckoski (azeckoski @ gmail.com)

Nested Class Summary
static class ActionReturn.Header
           
 
Field Summary
 String encoding
          The encoding to use for the output when it is returned
 List<EntityData> entitiesList
          A List of entities to return, leave as null if not used
 EntityData entityData
          An entity object to return, leave as null if not used
 String format
          Indicates the format (from Formats) to return the entity data in if there is any, if using an outputstream, use encoding and mimetype
 Map<String,String> headers
          Optional headers to include in the response (can use the header constants if desired: ActionReturn.Header), Example:
headers.put(Header.EXPIRES.toString(), "12378389233737");
headers.put("myHeaderKey", "my Value to put in the header");
 String mimeType
          The MIME type to use for the output when it is returned
 OutputStream output
          the data to output (should use a provided OutputStream), can be binary, leave this null if not used
 String outputString
          the output data in string form, leave this null if not used
 int responseCode
          The response code to send back from the processing of this action, the default which also indicates the response code as determined by the system should be used is -1
 
Constructor Summary
ActionReturn(EntityData entityData, String format)
          Create a return that is appropriate for sending back an entity
ActionReturn(List<EntityData> entitiesList, String format)
          Create a return that is appropriate for sending back a list of entities
ActionReturn(Object data)
          Special constructor which will ensure the data is output exactly as is without adding in the entity meta data
ActionReturn(Object data, Map<String,String> headers)
          Special constructor which will ensure the data is output exactly as is without adding in the entity meta data
ActionReturn(Object data, Map<String,String> headers, String format)
          Special constructor which will ensure the data is output exactly as is without adding in the entity meta data
ActionReturn(OutputStream output)
          Set the OutputStream to indicate it was used, uses default encoding UTF-8 and type of text/xml
ActionReturn(String outputString)
          Set a string of data to return, uses default encoding UTF-8 and type of text/xml
ActionReturn(String encoding, String mimeType, OutputStream output)
          Create a return that is appropriate for sending binary data or a large chunk of text
ActionReturn(String encoding, String mimeType, String outputString)
          Create a return that is appropriate for sending back a string
 
Method Summary
 String getEncoding()
           
 List<EntityData> getEntitiesList()
           
 EntityData getEntityData()
           
 String getFormat()
           
 Map<String,String> getHeaders()
           
 String getMimeType()
           
 OutputStream getOutput()
           
 String getOutputString()
           
 int getResponseCode()
           
 void setFormat(String format)
          Indicates the format (from Formats) to return the entity data in if there is any, if using an outputstream, use encoding and mimetype
 void setHeaders(Map<String,String> headers)
          Set the optional headers to include in the response (can use the header constants if desired: ActionReturn.Header), Example:
headers.put(Header.EXPIRES.toString(), "12378389233737");
headers.put("myHeaderKey", "my Value to put in the header");
 void setResponseCode(int responseCode)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

encoding

public String encoding
The encoding to use for the output when it is returned


mimeType

public String mimeType
The MIME type to use for the output when it is returned


output

public OutputStream output
the data to output (should use a provided OutputStream), can be binary, leave this null if not used


outputString

public String outputString
the output data in string form, leave this null if not used


entityData

public EntityData entityData
An entity object to return, leave as null if not used


entitiesList

public List<EntityData> entitiesList
A List of entities to return, leave as null if not used


format

public String format
Indicates the format (from Formats) to return the entity data in if there is any, if using an outputstream, use encoding and mimetype


headers

public Map<String,String> headers
Optional headers to include in the response (can use the header constants if desired: ActionReturn.Header), Example:
headers.put(Header.EXPIRES.toString(), "12378389233737");
headers.put("myHeaderKey", "my Value to put in the header");


responseCode

public int responseCode
The response code to send back from the processing of this action, the default which also indicates the response code as determined by the system should be used is -1

Constructor Detail

ActionReturn

public ActionReturn(OutputStream output)
Set the OutputStream to indicate it was used, uses default encoding UTF-8 and type of text/xml

Parameters:
output - an OutputStream of data to send as is

ActionReturn

public ActionReturn(String outputString)
Set a string of data to return, uses default encoding UTF-8 and type of text/xml

Parameters:
outputString - a string to send as is

ActionReturn

public ActionReturn(String encoding,
                    String mimeType,
                    OutputStream output)
Create a return that is appropriate for sending binary data or a large chunk of text

Parameters:
encoding - the encoding to use for the binary data
mimeType - the mime type to use for the binary data
output - the stream of binary data

ActionReturn

public ActionReturn(String encoding,
                    String mimeType,
                    String outputString)
Create a return that is appropriate for sending back a string

Parameters:
encoding - the encoding to use for the binary data
mimeType - the mime type to use for the binary data
outputString - the string value

ActionReturn

public ActionReturn(Object data)
Special constructor which will ensure the data is output exactly as is without adding in the entity meta data

Parameters:
data - the data to encode (any java objects including collections, POJOs, maps, etc.)

ActionReturn

public ActionReturn(Object data,
                    Map<String,String> headers)
Special constructor which will ensure the data is output exactly as is without adding in the entity meta data

Parameters:
data - the data to encode (any java objects including collections, POJOs, maps, etc.)
headers - (optional) headers to include in the response (can use the header constants if desired: ActionReturn.Header)

ActionReturn

public ActionReturn(Object data,
                    Map<String,String> headers,
                    String format)
Special constructor which will ensure the data is output exactly as is without adding in the entity meta data

Parameters:
data - the data to encode (any java objects including collections, POJOs, maps, etc.)
headers - (optional) headers to include in the response (can use the header constants if desired: ActionReturn.Header)
format - (optional) the format to return this data in (from Formats), e.g. Formats.XML

ActionReturn

public ActionReturn(EntityData entityData,
                    String format)
Create a return that is appropriate for sending back an entity

Parameters:
entityData - an entity object (EntityData object)
format - (optional) the format to return this data in (from Formats), e.g. Formats.XML

ActionReturn

public ActionReturn(List<EntityData> entitiesList,
                    String format)
Create a return that is appropriate for sending back a list of entities

Parameters:
entityData - a List of entities (EntityData) (can be empty)
format - (optional) the format to return this data in (from Formats), e.g. Formats.XML
Method Detail

setFormat

public void setFormat(String format)
Indicates the format (from Formats) to return the entity data in if there is any, if using an outputstream, use encoding and mimetype


setHeaders

public void setHeaders(Map<String,String> headers)
Set the optional headers to include in the response (can use the header constants if desired: ActionReturn.Header), Example:
headers.put(Header.EXPIRES.toString(), "12378389233737");
headers.put("myHeaderKey", "my Value to put in the header");


setResponseCode

public void setResponseCode(int responseCode)
Parameters:
responseCode - the response code to send back from the processing of this action, the default which also indicates the response code as determined by the system should be used is -1

toString

public String toString()
Overrides:
toString in class Object

getEncoding

public String getEncoding()

getMimeType

public String getMimeType()

getOutput

public OutputStream getOutput()

getOutputString

public String getOutputString()

getEntityData

public EntityData getEntityData()

getEntitiesList

public List<EntityData> getEntitiesList()

getFormat

public String getFormat()

getHeaders

public Map<String,String> getHeaders()

getResponseCode

public int getResponseCode()


Copyright © 2007-2012 Sakai Project. All Rights Reserved.