org.xwiki.annotation.rest.internal
Class AbstractAnnotationRESTResource

java.lang.Object
  extended by org.xwiki.rest.XWikiResource
      extended by org.xwiki.annotation.rest.internal.AbstractAnnotationRESTResource
All Implemented Interfaces:
org.xwiki.component.phase.Initializable, XWikiRestComponent
Direct Known Subclasses:
AnnotationsRESTResource, SingleAnnotationRESTResource

public abstract class AbstractAnnotationRESTResource
extends XWikiResource

Base class for the annotation REST services, to implement common functionality to all annotation REST services.

Since:
2.3M1
Version:
$Id$

Nested Class Summary
 
Nested classes/interfaces inherited from class org.xwiki.rest.XWikiResource
XWikiResource.DocumentInfo
 
Field Summary
protected  AnnotationRightService annotationRightService
          The annotations rights checking service, to check user rights to perform annotations actions.
protected  AnnotationService annotationService
          The annotations service to be used by this REST interface.
protected static java.lang.String DEFAULT_ACTION
          The default action to render the document for.
protected  org.xwiki.context.Execution execution
          The execution needed to get the annotation author from the context user.
 
Fields inherited from class org.xwiki.rest.XWikiResource
componentManager, logger, objectFactory, queryManager, uriInfo
 
Constructor Summary
AbstractAnnotationRESTResource()
           
 
Method Summary
protected  java.util.Collection<Annotation> filterAnnotations(java.util.Collection<Annotation> annotations, AnnotationRequest request)
          Helper method to filter a set of annotations according to the criteria in the passed annotation request.
protected  AnnotationResponse getErrorResponse(java.lang.Throwable exception)
          Helper function to create an error response from a passed exception.
protected  AnnotationResponse getSuccessResponseWithAnnotatedContent(java.lang.String documentName, AnnotationRequest request)
          Builds an annotation response containing the annotated content along with the annotation stubs, according to the requirements in the passed annotations request.
protected  java.lang.String getXWikiUser()
           
 
Methods inherited from class org.xwiki.rest.XWikiResource
getDocumentInfo, getUriTemplate, initialize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_ACTION

protected static final java.lang.String DEFAULT_ACTION
The default action to render the document for.
TODO: action should be obtained from the calling client in the parameters

See Also:
Constant Field Values

annotationService

@Inject
protected AnnotationService annotationService
The annotations service to be used by this REST interface.


annotationRightService

@Inject
protected AnnotationRightService annotationRightService
The annotations rights checking service, to check user rights to perform annotations actions.


execution

@Inject
protected org.xwiki.context.Execution execution
The execution needed to get the annotation author from the context user.

Constructor Detail

AbstractAnnotationRESTResource

public AbstractAnnotationRESTResource()
Method Detail

getSuccessResponseWithAnnotatedContent

protected AnnotationResponse getSuccessResponseWithAnnotatedContent(java.lang.String documentName,
                                                                    AnnotationRequest request)
                                                             throws AnnotationServiceException,
                                                                    XWikiException
Builds an annotation response containing the annotated content along with the annotation stubs, according to the requirements in the passed annotations request.

Parameters:
request - the annotations request
documentName - the name of the document to provide an annotated response for
Returns:
an annotation response with the annotated content and the annotation stubs
Throws:
AnnotationServiceException - in case something goes wrong handling the annotations
XWikiException - in case something goes wrong manipulating the xwiki context & documents

getErrorResponse

protected AnnotationResponse getErrorResponse(java.lang.Throwable exception)
Helper function to create an error response from a passed exception.

Parameters:
exception - the exception that was encountered during regular execution of service
Returns:
an error response

filterAnnotations

protected java.util.Collection<Annotation> filterAnnotations(java.util.Collection<Annotation> annotations,
                                                             AnnotationRequest request)
Helper method to filter a set of annotations according to the criteria in the passed annotation request. The fields in the filter of the request will be interpreted as a filter for equality with the value in the actual annotation, and all the fields conditions will be put together with an "or" operation.

Parameters:
annotations - the collection of annotations to filter
request - the request according which to filter
Returns:
the filtered collection of annotations

getXWikiUser

protected java.lang.String getXWikiUser()
Returns:
the xwiki user in the context.


Copyright © 2004-2011 XWiki. All Rights Reserved.