Package org.sakaiproject.entitybroker.entityprovider.annotations
-
Annotation Types Summary Annotation Type Description EntityContent Marks a getter method or field as the main content text for an entity, Example: the main text body for a blog entry or email, the main content of an article or posting, the convention is to run toString on the return from the "getContent" method or the value in the "content" field
NOTE: This annotation should only be used once in a class, the getter method must take no arguments and return an objectEntityCustomAction This annotation indicates that this method is a custom action fromActionsExecutable, this should not be placed on any methods defined by a capability but should be placed on methods which you want to be exposed as custom actions
By default the name of the method is used as the action key and this will work for read requests (viewKey is set toEntityView.VIEW_SHOW), you can add in action and viewKey annotation params to change those settings
You can describe this action using the key:.action. = description
The methods annotated by this can have the following argument (parameter) types:
(type => data which will be given to the method)
EntityView: the current entity view for this request (contains extension, url, segments)
EntityReference: the current entity reference (prefix and optional id)
String: entity prefix
Search: the search object based on the incoming params
OutputStream: stream to place outbound data (probably binary) into for transmission
Map(String=>Object) : a map of the actions parameters (params from the action request)
These methods should return one of the following:
1) null (this is ok in most circumstances to indicate the method is done, use an exception to indicate failure)
2) anActionReturn(this is a special object used to indicate return states and handle binary data)
3) anEntityData(this is a special object used to wrap the object and provide meta data)
4) a UTF-8 encoded OutputStream or String
5) a List of entity objects
6) an entity object
7) a boolean value (true indicates success and is the same as returning null, false indicates failure and causes anEntityNotFoundException
Can throw the following exceptions and have them translated and handled, all others will pass through:
EntityNotFoundExceptionto indicate the entity request could not find the data that was requested
IllegalArgumentExceptionto indicate that the incoming params or the request was invalid
FormatUnsupportedExceptionto indicate that the requested format is not supported for this entity request
EntityExceptionto indicate a specific entity failure occurred, can include a response code and error message
SecurityExceptionto indicate that the the current user is no allowed to perform this action
UnsupportedOperationExceptionto indicate that the current action being requested is invalid (typically indicates bad combination of viewKey and action)
IllegalStateExceptionto indicate a general failure has occurred
EntityDateCreated Marks a getter method or field as the date created time code (unix time code) for an entity, this can be aDate,Long, long, orString(will attempt to convert this to a long)
the convention is to try to convert the return from the "getDateCreated" method or the value in the "dateCreated" field
NOTE: This annotation should only be used once in a class, the getter method must take no arguments and return an objectEntityFieldRequired Marks a getter method or field as required to be non-null and non-empty for an entity, this can be used many times in a class, this is mostly for documentation purposes and has little effect on operationsEntityHttpParam This annotation indicates that this method parameter should be replaced by the value in the HTTP query parameter, header, or form parameter whose name matches the name set in the annotation
Binds the value(s) of a HTTP query parameter to a resource method parameter.EntityId Marks a getter method or field as the unique local Id for an entity, the convention is to run toString on the return from the "getId" method or the value in the "id" field
NOTE: This annotation should only be used once in a class, the getter method must take no arguments and return an objectEntityLastModified Marks a getter method or field as the last modified time code (unix time code) for an entity, this can be aDate,Long, long, orString(will attempt to convert this to a long)
the convention is to try to convert the return from the "getLastModified" method or the value in the "lastModified" field
NOTE: This annotation should only be used once in a class, the getter method must take no arguments and return an objectEntityModifiedBy Marks a getter method or field as the user ref of the last user to modify an entity
the convention is to run toString on the return from the "getModifiedBy" method or the value in the "modifiedBy" field
NOTE: This annotation should only be used once in a class, the getter method must take no arguments and return an objectEntityOwner Marks a getter method or field as the user ref of the creator/owner of an entity, the convention is to run toString on the return from the "getOwner" method or the value in the "owner" field
NOTE: This annotation should only be used once in a class, the getter method must take no arguments and return an objectEntityParameters This annotation indicates that this method is accepts or expects certain parameters to be present before it can be executed, these parameters are accessible in the params map
Any parameters included in this annotation can be documented using the i18n properties files by placing a message at: prefix.action.actionname.field.fieldname OR prefix.view.viewkey.field.fieldname
NOTE: there is no need to list the field names of the fields which are included in the entity class or map here, this is for additional parameters only
EntitySummary Marks a getter method or field as the summary or description text for an entity, Example: the summary for a blog entry or email, the instructions text for a test or survey the convention is to run toString on the return from the "getSummary" method or the value in the "summary" field
NOTE: This annotation should only be used once in a class, the getter method must take no arguments and return an objectEntityTitle Marks a getter method or field as the display title for an entity, the convention is to run toString on the return from the "getTitle" method or the value in the "title" field
NOTE: This annotation should only be used once in a class, the getter method must take no arguments and return an objectEntityURLRedirect This annotation indicates that this method will handle an incoming URL and do some processing to turn it into an outgoing URL OR just do some processing OR indicate that a failure has occurred
Define the URL pattern to match AFTER the /prefix using {name} to indicate variables
Example: /{thing}/site/{siteId} will match the following URL:
/myprefix/123/site/456, the variables will be {prefix => myprefix, thing => 123, siteId => 456}
NOTE: all incoming URL templates must start with "/{prefix}" (TemplateParseUtil.TEMPLATE_PREFIX)
NOTE: The method template patterns will be compared in the order they appear in your source code so be careful that you do not have a really simple redirect pattern as the first one as this can cause the other patterns to never be reached
The methods that this annotates should return aStringor void
They can have the following parameter types:
(type => data which will be given to the method)
String: incoming URL
EntityView.Method: the submission method (GET,POST,etc)
String[] : incoming URL segments, Example: /myprefix/123/apple => {'prefix','123','apple'}
Map(String=>String) : a map of the variable values in the {}, Example: pattern: /{prefix}/{thing}/apple, url: /myprefix/123/apple, would yield: {'thing' => '123','prefix' => 'mypreifx'}
Don't forget to handle the extensions as they will not automatically pass through, use theTemplateParseUtil.DOT_EXTENSIONandTemplateParseUtil.EXTENSIONvalues from the variable map which will contain the extension that was passed in
Return should be one of the following:
1) the URL to redirect to, will be processed as an external redirect if it starts with "http" or "/" (unless it starts with "/{prefix}"), otherwise it will be processed as an internal forward
2) "" (empty string) to not redirect and return an empty success response
3) null to not redirect and allow standard processing of the URL to continue
For failures: if there is a failure you should throw an IllegalStateException to indicate failure
This is the convention part of theRedirectablecapability