Project Wonder 5.0

er.rest.entityDelegates
Class ERXXmlRestResponseWriter

java.lang.Object
  extended by er.rest.entityDelegates.ERXAbstractRestResponseWriter
      extended by er.rest.entityDelegates.ERXXmlRestResponseWriter
All Implemented Interfaces:
IERXRestResponseWriter

public class ERXXmlRestResponseWriter
extends ERXAbstractRestResponseWriter

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

Field Summary
 
Fields inherited from interface er.rest.entityDelegates.IERXRestResponseWriter
DETAILS_PREFIX, DETAILS_PROPERTIES_PREFIX, REST_PREFIX
 
Constructor Summary
ERXXmlRestResponseWriter()
          Constructs an ERXXmlRestResponseWriter with displayAllProperties = false.
ERXXmlRestResponseWriter(boolean displayAllProperties, boolean displayAllToMany)
          Constructs an ERXXmlRestResponseWriter.
ERXXmlRestResponseWriter(ERXKeyFilter filter)
          Constructs an ERXXmlRestResponseWriter.
 
Method Summary
protected  void appendArrayToResponse(ERXRestContext context, IERXRestResponse response, ERXRestKey result, java.lang.String arrayName, java.lang.String entityName, com.webobjects.foundation.NSArray valueKeys, int indent, com.webobjects.foundation.NSMutableSet<java.lang.Object> visitedObjects)
          Writes the given array of objects to the response.
protected  void appendDetailsToResponse(ERXRestContext context, IERXRestResponse response, com.webobjects.eoaccess.EOEntity entity, com.webobjects.eocontrol.EOEnterpriseObject eo, java.lang.String objectName, java.lang.String entityName, java.lang.Object id, com.webobjects.foundation.NSArray displayKeys, int indent, com.webobjects.foundation.NSMutableSet<java.lang.Object> visitedObjects)
          Writes the visible details of an object to the response.
protected  void appendNoDetailsToResponse(ERXRestContext context, IERXRestResponse response, com.webobjects.eoaccess.EOEntity entity, com.webobjects.eocontrol.EOEnterpriseObject eo, java.lang.String objectName, java.lang.String entityName, java.lang.Object id, int indent)
          Write an object to the response without showing its details.
protected  void appendPrimitiveToResponse(ERXRestContext context, IERXRestResponse response, ERXRestKey result, int indent, java.lang.Object value)
          Writes the bare primitive out to the response.
 void appendToResponse(ERXRestContext context, IERXRestResponse response, ERXRestKey result)
          Called at the end of a request to produce the output to the user.
protected  void appendTypeToResponse(IERXRestResponse response, java.lang.Object value)
           
protected  void appendVisitedToResponse(ERXRestContext context, IERXRestResponse response, com.webobjects.eoaccess.EOEntity entity, com.webobjects.eocontrol.EOEnterpriseObject eo, java.lang.String objectName, java.lang.String entityName, java.lang.Object id, int indent)
          Write an object to the response that has already been visited.
 
Methods inherited from class er.rest.entityDelegates.ERXAbstractRestResponseWriter
appendArrayToResponse, appendDictionaryToResponse, appendToResponse, displayDetails, displayProperties, indent, toString, toString, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ERXXmlRestResponseWriter

public ERXXmlRestResponseWriter()
Constructs an ERXXmlRestResponseWriter with displayAllProperties = false.


ERXXmlRestResponseWriter

public 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

ERXXmlRestResponseWriter

public ERXXmlRestResponseWriter(ERXKeyFilter filter)
Constructs an ERXXmlRestResponseWriter.

Method Detail

appendToResponse

public void appendToResponse(ERXRestContext context,
                             IERXRestResponse response,
                             ERXRestKey result)
                      throws ERXRestException,
                             ERXRestSecurityException,
                             ERXRestNotFoundException,
                             java.text.ParseException
Description copied from interface: IERXRestResponseWriter
Called at the end of a request to produce the output to the user.

Specified by:
appendToResponse in interface IERXRestResponseWriter
Overrides:
appendToResponse in class ERXAbstractRestResponseWriter
Parameters:
context - the rest context
response - the response to write into
result - the result of the rest request
Throws:
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

appendTypeToResponse

protected void appendTypeToResponse(IERXRestResponse response,
                                    java.lang.Object value)

appendArrayToResponse

protected void appendArrayToResponse(ERXRestContext context,
                                     IERXRestResponse response,
                                     ERXRestKey result,
                                     java.lang.String arrayName,
                                     java.lang.String entityName,
                                     com.webobjects.foundation.NSArray valueKeys,
                                     int indent,
                                     com.webobjects.foundation.NSMutableSet<java.lang.Object> visitedObjects)
                              throws ERXRestException,
                                     ERXRestSecurityException,
                                     ERXRestNotFoundException,
                                     java.text.ParseException
Description copied from class: ERXAbstractRestResponseWriter
Writes the given array of objects to the response. Permissions have already been checked by the time this method is called.

Specified by:
appendArrayToResponse in class ERXAbstractRestResponseWriter
Parameters:
context - the rest context
response - the response
result - 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)
Throws:
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

appendVisitedToResponse

protected void appendVisitedToResponse(ERXRestContext context,
                                       IERXRestResponse response,
                                       com.webobjects.eoaccess.EOEntity entity,
                                       com.webobjects.eocontrol.EOEnterpriseObject eo,
                                       java.lang.String objectName,
                                       java.lang.String entityName,
                                       java.lang.Object id,
                                       int indent)
Description copied from class: ERXAbstractRestResponseWriter
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.

Specified by:
appendVisitedToResponse in class ERXAbstractRestResponseWriter
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

appendNoDetailsToResponse

protected void appendNoDetailsToResponse(ERXRestContext context,
                                         IERXRestResponse response,
                                         com.webobjects.eoaccess.EOEntity entity,
                                         com.webobjects.eocontrol.EOEnterpriseObject eo,
                                         java.lang.String objectName,
                                         java.lang.String entityName,
                                         java.lang.Object id,
                                         int indent)
Description copied from class: ERXAbstractRestResponseWriter
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.

Specified by:
appendNoDetailsToResponse in class ERXAbstractRestResponseWriter
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

appendDetailsToResponse

protected void appendDetailsToResponse(ERXRestContext context,
                                       IERXRestResponse response,
                                       com.webobjects.eoaccess.EOEntity entity,
                                       com.webobjects.eocontrol.EOEnterpriseObject eo,
                                       java.lang.String objectName,
                                       java.lang.String entityName,
                                       java.lang.Object id,
                                       com.webobjects.foundation.NSArray displayKeys,
                                       int indent,
                                       com.webobjects.foundation.NSMutableSet<java.lang.Object> visitedObjects)
                                throws ERXRestException,
                                       ERXRestSecurityException,
                                       ERXRestNotFoundException,
                                       java.text.ParseException
Description copied from class: ERXAbstractRestResponseWriter
Writes the visible details of an object to the response. Permissions have already been checked by the time this method is called.

Specified by:
appendDetailsToResponse in class ERXAbstractRestResponseWriter
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)
Throws:
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

appendPrimitiveToResponse

protected void appendPrimitiveToResponse(ERXRestContext context,
                                         IERXRestResponse response,
                                         ERXRestKey result,
                                         int indent,
                                         java.lang.Object value)
                                  throws ERXRestException
Description copied from class: ERXAbstractRestResponseWriter
Writes the bare primitive out to the response. Permissions have already been checked by the time this method is called.

Specified by:
appendPrimitiveToResponse in class ERXAbstractRestResponseWriter
Parameters:
context - the rest context
response - the response
result - the current key
indent - the indent level
value - the value to append
Throws:
ERXRestException - if a general failure occurs

Last updated: Tue, Feb 21, 2017 • 05:45 PM CET

Copyright © 2002 – 2007 Project Wonder.