Project Wonder 5.0

er.rest.entityDelegates
Interface IERXRestEntityDelegate

All Superinterfaces:
IERXRestSecurityDelegate
All Known Implementing Classes:
ERD2RestDefaultEntityDelegate, ERXAbstractRestEntityDelegate, ERXDenyRestEntityDelegate, ERXStandardRestEntityDelegate, ERXUnsafeReadOnlyRestEntityDelegate, ERXUnsafeRestEntityDelegate

public interface IERXRestEntityDelegate
extends IERXRestSecurityDelegate

IERXRestEntityDelegate provides the interface for the applications to hook into the rest process on a per-entity basis. Entity delegates are typically registered on the ERXRestDelegate of ERXRestContext in your Application constructor.

 ERXDefaultRestDelegate restDelegate = new ERXDefaultRestDelegate();
 restDelegate.addDelegateForEntityNamed(new OrganizationRestEntityDelegate(), Organization.ENTITY_NAME);
 

Author:
mschrag

Method Summary
 void delete(com.webobjects.eoaccess.EOEntity entity, com.webobjects.eocontrol.EOEnterpriseObject eo, ERXRestContext context)
          Deletes the given object.
 boolean displayDetails(ERXRestKey key, ERXRestContext context)
           
 java.lang.String[] displayProperties(ERXRestKey key, boolean allProperties, boolean allToMany, ERXRestContext context)
           
 java.lang.String entityAliasForEntityNamed(java.lang.String entityName)
          Returns the alias for the given entity name.
 java.lang.String formatAttributeValue(com.webobjects.eoaccess.EOEntity entity, java.lang.Object object, java.lang.String attributeName, java.lang.Object attributeValue)
          Coerce the given value into a String for use in the restful response.
 java.lang.Object idForEO(com.webobjects.eoaccess.EOEntity entity, com.webobjects.eocontrol.EOEnterpriseObject eo)
          Returns the primary key of the given EO.
 void initializeEntityNamed(java.lang.String entityName)
          Called by the rest delegate for each entity that gets requested.
 com.webobjects.eocontrol.EOEnterpriseObject insertObjectFromDocument(com.webobjects.eoaccess.EOEntity entity, ERXRestRequestNode insertNode, com.webobjects.eoaccess.EOEntity parentEntity, com.webobjects.eocontrol.EOEnterpriseObject parentObject, java.lang.String parentKey, ERXRestContext context)
          Insert a new object of the given type into a parent object's keypath from an XML document.
 boolean isEOID(ERXRestKey restKey)
          Returns whether or not the given key value is the primary key of an EO.
 com.webobjects.eoaccess.EOEntity nextEntity(com.webobjects.eoaccess.EOEntity entity, java.lang.String key)
          Returns the destination entity for the given key on the specified entity.
 com.webobjects.eocontrol.EOEnterpriseObject objectForNode(com.webobjects.eoaccess.EOEntity entity, ERXRestRequestNode node, ERXRestContext context)
          Returns the object that is associated with the given node.
 com.webobjects.foundation.NSArray objectsForEntity(com.webobjects.eoaccess.EOEntity entity, ERXRestContext context)
          Returns an array of all of the EOs visible to the user for the given entity.
 com.webobjects.eocontrol.EOEnterpriseObject objectWithKey(com.webobjects.eoaccess.EOEntity entity, java.lang.String key, ERXRestContext context)
          Returns the object that has the given key.
 com.webobjects.eocontrol.EOEnterpriseObject objectWithKey(com.webobjects.eoaccess.EOEntity entity, java.lang.String key, com.webobjects.foundation.NSArray objs, ERXRestContext context)
          Returns the object that has the given key from the provided array.
 void preprocess(com.webobjects.eoaccess.EOEntity entity, com.webobjects.foundation.NSArray objects, ERXRestContext context)
          Called before enumerating the given array of objects for display.
 com.webobjects.eocontrol.EOEnterpriseObject processObjectFromDocument(com.webobjects.eoaccess.EOEntity entity, ERXRestRequestNode eoNode, ERXRestContext context)
          Inserts or updates an object of the given type.
 java.lang.String propertyAliasForPropertyNamed(com.webobjects.eoaccess.EOEntity entity, java.lang.String propertyName)
          Just like for entity names, it may be necessary to rename certain properties of your entities for consumers of your restful service.
 java.lang.String propertyNameForPropertyAlias(com.webobjects.eoaccess.EOEntity entity, java.lang.String propertyAlias)
          The inverse of propertyAliasForPropertyNamed.
 java.lang.String stringIDForEO(com.webobjects.eoaccess.EOEntity entity, com.webobjects.eocontrol.EOEnterpriseObject eo)
          Returns the string form of the primary key of the given EO.
 void takeValueForKey(com.webobjects.eoaccess.EOEntity entity, java.lang.Object obj, java.lang.String propertyName, java.lang.String value, ERXRestContext context)
          Sets the value for the specified property name on the given object.
 void updateArrayFromDocument(com.webobjects.eoaccess.EOEntity parentEntity, com.webobjects.eocontrol.EOEnterpriseObject parentObject, java.lang.String attributeName, com.webobjects.eoaccess.EOEntity entity, com.webobjects.foundation.NSArray currentObjects, com.webobjects.foundation.NSArray toManyNodes, ERXRestContext context)
          Updates an array of objects for a to-many relationship from an XML document.
 void updateObjectFromDocument(com.webobjects.eoaccess.EOEntity entity, com.webobjects.eocontrol.EOEnterpriseObject eo, ERXRestRequestNode eoNode, ERXRestContext context)
          Updates an existing object from an XML document.
 java.lang.Object valueForKey(com.webobjects.eoaccess.EOEntity entity, java.lang.Object obj, java.lang.String propertyName, ERXRestContext context)
          Returns the value for the specified property name on the given object.
 com.webobjects.foundation.NSArray visibleObjects(com.webobjects.eoaccess.EOEntity parentEntity, java.lang.Object parentObject, java.lang.String parentKey, com.webobjects.eoaccess.EOEntity entity, com.webobjects.foundation.NSArray objects, ERXRestContext context)
          Given an array, this method filters the array based on the callers permission level.
 
Methods inherited from interface er.rest.entityDelegates.IERXRestSecurityDelegate
canDeleteObject, canInsertObject, canInsertObject, canInsertProperty, canUpdateObject, canUpdateProperty, canViewObject, canViewProperty
 

Method Detail

initializeEntityNamed

void initializeEntityNamed(java.lang.String entityName)
Called by the rest delegate for each entity that gets requested. This is called every time, so your entity delegate should manage only executing one time if necessary.

Parameters:
entityName - the name of the entity to initialize

entityAliasForEntityNamed

java.lang.String entityAliasForEntityNamed(java.lang.String entityName)
Returns the alias for the given entity name. It is often the case that the actual name of the entity in your model may not be the name that you want to expose to the outside world. From this method, you can return the externally visible name. This method should never return null (just return entityName if you don't have an alias), and you will only get requests for entities that you are registered for.

Parameters:
entityName - the name of the entity to lookup
Returns:
the alias for the given entity name

propertyAliasForPropertyNamed

java.lang.String propertyAliasForPropertyNamed(com.webobjects.eoaccess.EOEntity entity,
                                               java.lang.String propertyName)
Just like for entity names, it may be necessary to rename certain properties of your entities for consumers of your restful service. This method should return the alias for the given propertyName for the given entity. This method should never return null (just return propertyName if you don't have an alias), and you will only get requests for entities that you are registered for.

Parameters:
entity - the entity that contains the property
propertyName - the property name
Returns:
the alias for the given property name

propertyNameForPropertyAlias

java.lang.String propertyNameForPropertyAlias(com.webobjects.eoaccess.EOEntity entity,
                                              java.lang.String propertyAlias)
The inverse of propertyAliasForPropertyNamed. Entity names are known, but property names aren't. So the inverse lookup must be provided. You must always provide an inverse lookup that matches the corresponding lookup from propertyAliasForPropertyNamed, and you must never return null form this method (just return propertyAlias if there is no alias).

Parameters:
entity - the entity that contains the property
propertyAlias - the alias to lookup
Returns:
the original property names for the given alias

objectWithKey

com.webobjects.eocontrol.EOEnterpriseObject objectWithKey(com.webobjects.eoaccess.EOEntity entity,
                                                          java.lang.String key,
                                                          ERXRestContext context)
                                                          throws ERXRestException,
                                                                 ERXRestNotFoundException,
                                                                 ERXRestSecurityException
Returns the object that has the given key. In all of the provided implementations, key is interpreted to be an integer primary key in string form.

Parameters:
entity - the entity
key - the unique key for an object
context - the rest context
Returns:
the matching object
Throws:
ERXRestException - if a general failure occurs
ERXRestNotFoundException - if there is no object with the given key
ERXRestSecurityException - if the caller is not permitted to view the requested object

objectWithKey

com.webobjects.eocontrol.EOEnterpriseObject objectWithKey(com.webobjects.eoaccess.EOEntity entity,
                                                          java.lang.String key,
                                                          com.webobjects.foundation.NSArray objs,
                                                          ERXRestContext context)
                                                          throws ERXRestException,
                                                                 ERXRestSecurityException,
                                                                 ERXRestNotFoundException
Returns the object that has the given key from the provided array. This is just like objectWithKey except limited to an array instead of the entire set of objects for the entity. In all of the provided implementations, key is interpreted to be an integer primary key in string form.

Parameters:
entity - the entity
key - the unique key for an object
objs - the objects to restrict the match to
context - the rest context
Returns:
the matching object
Throws:
ERXRestException - if a general failure occurs
ERXRestNotFoundException - if there is no object in the array with the given key
ERXRestSecurityException - if the caller is not permitted to view the requested object

objectForNode

com.webobjects.eocontrol.EOEnterpriseObject objectForNode(com.webobjects.eoaccess.EOEntity entity,
                                                          ERXRestRequestNode node,
                                                          ERXRestContext context)
                                                          throws ERXRestException,
                                                                 ERXRestNotFoundException,
                                                                 ERXRestSecurityException
Returns the object that is associated with the given node.

Parameters:
entity - the entity
node - the node that represents the object
context - the rest context
Returns:
the matching object
Throws:
ERXRestException - if a general failure occurs
ERXRestNotFoundException - if there is no object with the given key
ERXRestSecurityException - if the caller is not permitted to view the requested object

valueForKey

java.lang.Object valueForKey(com.webobjects.eoaccess.EOEntity entity,
                             java.lang.Object obj,
                             java.lang.String propertyName,
                             ERXRestContext context)
Returns the value for the specified property name on the given object. This method does not need to deal with security issues.

Parameters:
entity - the entity of the given object
obj - the object itself
propertyName - the property name to lookup
context - the rest context
Returns:
the value for the given property

takeValueForKey

void takeValueForKey(com.webobjects.eoaccess.EOEntity entity,
                     java.lang.Object obj,
                     java.lang.String propertyName,
                     java.lang.String value,
                     ERXRestContext context)
                     throws java.text.ParseException,
                            ERXRestException
Sets the value for the specified property name on the given object. Notice that the value is a String. You will need to parse the String appropriately to coerce it into the property type for the property. This method does not need to deal with security issues.

Parameters:
entity - the entity of the object
obj - the object to set a property on
propertyName - the property name to set
value - the new value of the property
context - the rest context
Throws:
ParseException - if the property value cannot be parsed
ERXRestException - if a general failure occurs.

delete

void delete(com.webobjects.eoaccess.EOEntity entity,
            com.webobjects.eocontrol.EOEnterpriseObject eo,
            ERXRestContext context)
            throws ERXRestException,
                   ERXRestSecurityException
Deletes the given object.

Parameters:
entity - the entity of the object
eo - the object to delete
context - the rest context
Throws:
ERXRestException - if a general failure occurs.
ERXRestSecurityException - if a security failure occurs

processObjectFromDocument

com.webobjects.eocontrol.EOEnterpriseObject processObjectFromDocument(com.webobjects.eoaccess.EOEntity entity,
                                                                      ERXRestRequestNode eoNode,
                                                                      ERXRestContext context)
                                                                      throws ERXRestSecurityException,
                                                                             ERXRestException,
                                                                             ERXRestNotFoundException
Inserts or updates an object of the given type.

Parameters:
entity - the entity of the object to insert or update
eoNode - the node that describes the insert or update
context - the rest context
Returns:
the inserted or updated object
Throws:
ERXRestSecurityException - if a security failure occurs
ERXRestException - if a general failure occurs
ERXRestNotFoundException - if a related object cannot be found

insertObjectFromDocument

com.webobjects.eocontrol.EOEnterpriseObject insertObjectFromDocument(com.webobjects.eoaccess.EOEntity entity,
                                                                     ERXRestRequestNode insertNode,
                                                                     com.webobjects.eoaccess.EOEntity parentEntity,
                                                                     com.webobjects.eocontrol.EOEnterpriseObject parentObject,
                                                                     java.lang.String parentKey,
                                                                     ERXRestContext context)
                                                                     throws ERXRestSecurityException,
                                                                            ERXRestException,
                                                                            ERXRestNotFoundException
Insert a new object of the given type into a parent object's keypath from an XML document.

Parameters:
entity - the entity of the object to insert
insertNode - the node that describes the insert
parentEntity - the entity of the parent object to insert into
parentObject - the parent object of the insert
parentKey - the key on the parent that represents the relationship to this new object
context - the rest context
Returns:
the newly created object
Throws:
ERXRestSecurityException - if a security failure occurs
ERXRestException - if a general failure occurs
ERXRestNotFoundException - if a related object cannot be found

updateArrayFromDocument

void updateArrayFromDocument(com.webobjects.eoaccess.EOEntity parentEntity,
                             com.webobjects.eocontrol.EOEnterpriseObject parentObject,
                             java.lang.String attributeName,
                             com.webobjects.eoaccess.EOEntity entity,
                             com.webobjects.foundation.NSArray currentObjects,
                             com.webobjects.foundation.NSArray toManyNodes,
                             ERXRestContext context)
                             throws ERXRestException,
                                    ERXRestNotFoundException,
                                    ERXRestSecurityException
Updates an array of objects for a to-many relationship from an XML document. This method is responsible for deleting and inserting objects into the specified relationship.

Parameters:
parentEntity - the entity of the parent object
parentObject - the parent object
attributeName - the name of the to-many key on the parent
entity - the entity of the objects in the array
currentObjects - the existing objects in the to-many relationship
toManyNodes - the array containing the nodes that describe the update
context - the rest context
Throws:
ERXRestSecurityException - if a security failure occurs
ERXRestException - if a general failure occurs
ERXRestNotFoundException - if a related object cannot be found

updateObjectFromDocument

void updateObjectFromDocument(com.webobjects.eoaccess.EOEntity entity,
                              com.webobjects.eocontrol.EOEnterpriseObject eo,
                              ERXRestRequestNode eoNode,
                              ERXRestContext context)
                              throws ERXRestSecurityException,
                                     ERXRestException,
                                     ERXRestNotFoundException
Updates an existing object from an XML document.

Parameters:
entity - the entity of the object to update
eo - the object to update
eoNode - the node that describes the update
context - the rest context
Throws:
ERXRestSecurityException - if a security failure occurs
ERXRestException - if a general failure occurs
ERXRestNotFoundException - if a related object cannot be found

formatAttributeValue

java.lang.String formatAttributeValue(com.webobjects.eoaccess.EOEntity entity,
                                      java.lang.Object object,
                                      java.lang.String attributeName,
                                      java.lang.Object attributeValue)
                                      throws java.text.ParseException,
                                             ERXRestException
Coerce the given value into a String for use in the restful response. This may move to the RestResponseWriter at some point, but it's kind of a strange design issue.

Parameters:
entity - the entity of the object
object - the object
attributeName - the name of the key
attributeValue - the value of the key to format
Returns:
the formatted string for the attributeValue
Throws:
ParseException - if a parse error occurs
ERXRestException - if a general error occurs

objectsForEntity

com.webobjects.foundation.NSArray objectsForEntity(com.webobjects.eoaccess.EOEntity entity,
                                                   ERXRestContext context)
                                                   throws ERXRestException,
                                                          ERXRestSecurityException
Returns an array of all of the EOs visible to the user for the given entity.

Parameters:
entity - the entity to fetch
context - the rest context
Returns:
the array of EOs
Throws:
ERXRestException - if there is a general failure
ERXRestSecurityException - if the user requests objects that he/she is not permitted to see

preprocess

void preprocess(com.webobjects.eoaccess.EOEntity entity,
                com.webobjects.foundation.NSArray objects,
                ERXRestContext context)
                throws ERXRestException
Called before enumerating the given array of objects for display. This provides an opportunity to prefetch any of the properties that will be displayed.

Parameters:
entity - the entity of the objects
objects - the objects to be displayed
Throws:
ERXRestException - if there is a general failure

visibleObjects

com.webobjects.foundation.NSArray visibleObjects(com.webobjects.eoaccess.EOEntity parentEntity,
                                                 java.lang.Object parentObject,
                                                 java.lang.String parentKey,
                                                 com.webobjects.eoaccess.EOEntity entity,
                                                 com.webobjects.foundation.NSArray objects,
                                                 ERXRestContext context)
                                                 throws ERXRestException,
                                                        ERXRestSecurityException,
                                                        ERXRestNotFoundException
Given an array, this method filters the array based on the callers permission level. This method should never return null. To cut off access to the array entirely, return NSArray.EmptyArray. This method is only called after having verified access to the specified key on the parent object.

Parameters:
parentEntity - the entity of the parent
parentObject - the parent object
parentKey - the key in the parent that references this array
entity - the entity of the objects in the array
objects - the actual array of objects to filter
context - the rest context
Returns:
a filtered array
Throws:
ERXRestException - if a general failure occurs
ERXRestSecurityException - if a security violation occurs (note that filtering results should not constitute a security violation)
ERXRestNotFoundException - if an object cannot be found

nextEntity

com.webobjects.eoaccess.EOEntity nextEntity(com.webobjects.eoaccess.EOEntity entity,
                                            java.lang.String key)
Returns the destination entity for the given key on the specified entity. If the key is a non-entity, you can return null.

Parameters:
entity - the entity to check
key - the key to return the entity for
Returns:
the destination entity for the given key (or null if there isn't one)

isEOID

boolean isEOID(ERXRestKey restKey)
Returns whether or not the given key value is the primary key of an EO. This is crazy -- It tries to guess if it's looking at a key or not.

Parameters:
restKey - the possible EO key
Returns:
true if key is a primary key

stringIDForEO

java.lang.String stringIDForEO(com.webobjects.eoaccess.EOEntity entity,
                               com.webobjects.eocontrol.EOEnterpriseObject eo)
Returns the string form of the primary key of the given EO.

Parameters:
eo - the EO to get a primary key for
Returns:
the primary key

idForEO

java.lang.Object idForEO(com.webobjects.eoaccess.EOEntity entity,
                         com.webobjects.eocontrol.EOEnterpriseObject eo)
Returns the primary key of the given EO.

Parameters:
eo - the EO to get a primary key for
Returns:
the primary key

displayProperties

java.lang.String[] displayProperties(ERXRestKey key,
                                     boolean allProperties,
                                     boolean allToMany,
                                     ERXRestContext context)
                                     throws ERXRestException,
                                            ERXRestNotFoundException,
                                            ERXRestSecurityException
Throws:
ERXRestException
ERXRestNotFoundException
ERXRestSecurityException

displayDetails

boolean displayDetails(ERXRestKey key,
                       ERXRestContext context)
                       throws ERXRestException,
                              ERXRestNotFoundException,
                              ERXRestSecurityException
Throws:
ERXRestException
ERXRestNotFoundException
ERXRestSecurityException

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

Copyright © 2002 – 2007 Project Wonder.