ERXXmlRestResponseWriter Class Reference

Inherits er::rest::entityDelegates::ERXAbstractRestResponseWriter.

Collaboration diagram for ERXXmlRestResponseWriter:

Collaboration graph
[legend]

List of all members.

Public Member Functions

void appendToResponse (ERXRestContext context, IERXRestResponse response, ERXRestKey result) throws ERXRestException, ERXRestSecurityException, ERXRestNotFoundException, ParseException
 ERXXmlRestResponseWriter (ERXKeyFilter filter)
 ERXXmlRestResponseWriter (boolean displayAllProperties, boolean displayAllToMany)
 ERXXmlRestResponseWriter ()

Protected Member Functions

void appendArrayToResponse (ERXRestContext context, IERXRestResponse response, ERXRestKey result, String arrayName, String entityName, NSArray valueKeys, int indent, NSMutableSet< Object > visitedObjects) throws ERXRestException, ERXRestSecurityException, ERXRestNotFoundException, ParseException
void appendDetailsToResponse (ERXRestContext context, IERXRestResponse response, EOEntity entity, EOEnterpriseObject eo, String objectName, String entityName, Object id, NSArray displayKeys, int indent, NSMutableSet< Object > visitedObjects) throws ERXRestException, ERXRestSecurityException, ERXRestNotFoundException, ParseException
void appendNoDetailsToResponse (ERXRestContext context, IERXRestResponse response, EOEntity entity, EOEnterpriseObject eo, String objectName, String entityName, Object id, int indent)
void appendPrimitiveToResponse (ERXRestContext context, IERXRestResponse response, ERXRestKey result, int indent, Object value) throws ERXRestException
void appendTypeToResponse (IERXRestResponse response, Object value)
void appendVisitedToResponse (ERXRestContext context, IERXRestResponse response, EOEntity entity, EOEnterpriseObject eo, String objectName, String entityName, Object id, int indent)


Detailed Description

Provides the common output methods for generating XML responses to a REST request.

The response writers can be used in two styles. In one style, they can be connected to a rest request handler and are controlled with Properties. In another form, they can be used programmatically and can be configured with ERXKeyFilters to control their output. ERXKeyFilters provides a really bad version of Rails' to_json :include maps.

 ERXKeyFilter companyFilter = new ERXKeyFilter(ERXKeyFilter.Base.Attributes);
 ERXKeyFilter remindersFilter = companyFilter.include(Company.REMINDERS);
 remindersFilter.include(Reminder.SUMMARY);
 remindersFilter.exclude(Reminder.CREATION_DATE);

 ERXPListRestResponseWriter writer = new ERXPListRestResponseWriter(companyFilter);
 String str = writer.toString(Company.fetchRequiredCompany(ERXEC.newEditingContext(), Company.NAME.is("mDT Consulting")));
 

Author:
mschrag

Constructor & Destructor Documentation

Constructs an ERXXmlRestResponseWriter with displayAllProperties = false.

ERXXmlRestResponseWriter ( boolean  displayAllProperties,
boolean  displayAllToMany 
)

Constructs an ERXXmlRestResponseWriter.

Parameters:
displayAllProperties if true, by default all properties are eligible to be displayed (probably should only be true in development, but it won't really hurt anything). Note that entity delegates will still control permissions on the properties, it just defaults to checking all of them.
displayAllToMany if true, all to-many relationships will be displayed

Constructs an ERXXmlRestResponseWriter.


Member Function Documentation

void appendArrayToResponse ( ERXRestContext  context,
IERXRestResponse  response,
ERXRestKey  key,
String  arrayName,
String  entityName,
NSArray  valueKeys,
int  indent,
NSMutableSet< Object >  visitedObjects 
) throws ERXRestException, ERXRestSecurityException, ERXRestNotFoundException, ParseException [protected, virtual]

Writes the given array of objects to the response. Permissions have already been checked by the time this method is called.

Parameters:
context the rest context
response the response
key the current key
arrayName the name of the array in the context of its parent
entityName the entity name of the contents of the array
valueKeys an array of ERXRestKeys that represent the entries in the array
indent the indent level
visitedObjects the list of objects that have been visited already in this request (to prevent infinite loops)
Exceptions:
ERXRestException if a general error occurs
ERXRestSecurityException if a security error occurs
ERXRestNotFoundException if an object is not found
ParseException if a parse error occurs

Implements ERXAbstractRestResponseWriter.

void appendDetailsToResponse ( ERXRestContext  context,
IERXRestResponse  response,
EOEntity  entity,
EOEnterpriseObject  eo,
String  objectName,
String  entityName,
Object  id,
NSArray  displayKeys,
int  indent,
NSMutableSet< Object >  visitedObjects 
) throws ERXRestException, ERXRestSecurityException, ERXRestNotFoundException, ParseException [protected, virtual]

Writes the visible details of an object to the response. Permissions have already been checked by the time this method is called.

Parameters:
context the rest context
response the response
entity the entity of the object
eo the current object
objectName the name of the object (relative to its parent)
entityName the entity name of the object
id the id of the object
displayKeys the list of ERXRestKeys to display
indent the indent level
visitedObjects the list of objects that have been visited already in this request (to prevent infinite loops)
Exceptions:
ERXRestException if a general error occurs
ERXRestSecurityException if a security error occurs
ERXRestNotFoundException if an object is not found
ParseException if a parse error occurs

Implements ERXAbstractRestResponseWriter.

void appendNoDetailsToResponse ( ERXRestContext  context,
IERXRestResponse  response,
EOEntity  entity,
EOEnterpriseObject  eo,
String  objectName,
String  entityName,
Object  id,
int  indent 
) [protected, virtual]

Write an object to the response without showing its details. This is typically similar to appendVisitedToResponse, but is provided as a separate call because it is semantically a different scenario. Permissions have already been checked by the time this method is called.

Parameters:
context the rest context
response the response
entity the entity of the object
eo the current object
objectName the name of the object (relative to its parent)
entityName the entity name of the object
id the id of the object
indent the indent level

Implements ERXAbstractRestResponseWriter.

void appendPrimitiveToResponse ( ERXRestContext  context,
IERXRestResponse  response,
ERXRestKey  result,
int  indent,
Object  value 
) throws ERXRestException [protected, virtual]

Writes the bare primitive out to the response. Permissions have already been checked by the time this method is called.

Parameters:
context the rest context
response the response
result the current key
indent the indent level
value the value to append
Exceptions:
ERXRestException if a general failure occurs

Implements ERXAbstractRestResponseWriter.

void appendToResponse ( ERXRestContext  context,
IERXRestResponse  response,
ERXRestKey  result 
) throws ERXRestException, ERXRestSecurityException, ERXRestNotFoundException, ParseException

Called at the end of a request to produce the output to the user.

Parameters:
context the rest context
response the response to write into
result the result of the rest request
Exceptions:
ERXRestException if there is a general failure
ERXRestSecurityException if there is a security violation
ERXRestNotFoundException if there is a missing entity
ParseException if there is a parse error

Reimplemented from ERXAbstractRestResponseWriter.

void appendTypeToResponse ( IERXRestResponse  response,
Object  value 
) [protected]

void appendVisitedToResponse ( ERXRestContext  context,
IERXRestResponse  response,
EOEntity  entity,
EOEnterpriseObject  eo,
String  objectName,
String  entityName,
Object  id,
int  indent 
) [protected, virtual]

Write an object to the response that has already been visited. Typically this would just write out the type and id of the object, to prevent entering an infinite loop in the renderer. Permissions have already been checked by the time this method is called.

Parameters:
context the rest context
response the response
entity the entity of the object
eo the current object
objectName the name of the object (relative to its parent)
entityName the entity name of the object
id the id of the object
indent the indent level

Implements ERXAbstractRestResponseWriter.


The documentation for this class was generated from the following file:

Generated on Sat May 26 06:43:28 2012 for Project Wonder by  doxygen 1.5.8