Class ActionReturn
- java.lang.Object
-
- 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
Nested Classes Modifier and Type Class Description static classActionReturn.Header
-
Field Summary
Fields Modifier and Type Field Description StringencodingThe encoding to use for the output when it is returnedList<EntityData>entitiesListA List of entities to return, leave as null if not usedEntityDataentityDataAn entity object to return, leave as null if not usedStringformatIndicates the format (fromFormats) to return the entity data in if there is any, if using an outputstream, use encoding and mimetypeMap<String,String>headersOptional 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");StringmimeTypeThe MIME type to use for the output when it is returnedOutputStreamoutputthe data to output (should use a provided OutputStream), can be binary, leave this null if not usedStringoutputStringthe output data in string form, leave this null if not usedintresponseCodeThe 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
Constructors Constructor Description ActionReturn(OutputStream output)Set the OutputStream to indicate it was used, uses default encoding UTF-8 and type of text/xmlActionReturn(Object data)Special constructor which will ensure the data is output exactly as is without adding in the entity meta dataActionReturn(Object data, Map<String,String> headers)Special constructor which will ensure the data is output exactly as is without adding in the entity meta dataActionReturn(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 dataActionReturn(String outputString)Set a string of data to return, uses default encoding UTF-8 and type of text/xmlActionReturn(String encoding, String mimeType, OutputStream output)Create a return that is appropriate for sending binary data or a large chunk of textActionReturn(String encoding, String mimeType, String outputString)Create a return that is appropriate for sending back a stringActionReturn(List<EntityData> entitiesList, String format)Create a return that is appropriate for sending back a list of entitiesActionReturn(EntityData entityData, String format)Create a return that is appropriate for sending back an entity
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetEncoding()List<EntityData>getEntitiesList()EntityDatagetEntityData()StringgetFormat()Map<String,String>getHeaders()StringgetMimeType()OutputStreamgetOutput()StringgetOutputString()intgetResponseCode()voidsetFormat(String format)Indicates the format (fromFormats) to return the entity data in if there is any, if using an outputstream, use encoding and mimetypevoidsetHeaders(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");voidsetResponseCode(int responseCode)StringtoString()
-
-
-
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 (fromFormats) 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 datamimeType- the mime type to use for the binary dataoutput- 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 datamimeType- the mime type to use for the binary dataoutputString- 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 (fromFormats), 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 (EntityDataobject)format- (optional) the format to return this data in (fromFormats), 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 (fromFormats), e.g. Formats.XML
-
-
Method Detail
-
setFormat
public void setFormat(String format)
Indicates the format (fromFormats) 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
-
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()
-
getResponseCode
public int getResponseCode()
-
-