com.silverpeas.web
Class RESTWebService

java.lang.Object
  extended by com.silverpeas.web.RESTWebService
Direct Known Subclasses:
AbstractAdminResource, AbstractAttachmentResource, AbstractContributionResource, AbstractLookResource, AbstractMessageResource, AbstractNodeResource, AbstractPasswordResource, AbstractPublicationResource, AbstractSimpleDocumentResource, BundleResource, CipherKeyResource, CommentResource, DocumentViewResource, FileUploadResource, FilteredPdcResource, InvitationResource, LanguageResource, ListNodeResource, MyLinksResource, MyPreferencesResource, PdcClassificationResource, PdcPredefinedClassificationResource, PdcResource, PreviewResource, RatingResource, SharingResource, SubscribeResource, SubscriptionResource, ThumbnailResource, TicketResource, UnsubscribeResource, UserGroupProfileResource, UserProfileResource

public abstract class RESTWebService
extends Object

The class of the Silverpeas REST web services. It provides all of the common features required by the web services in Silverpeas like the user priviledge checking.


Nested Class Summary
protected  class RESTWebService.WebProcess<RETURN_VALUE>
          This class handles the execution of a RESTWebService.WebTreatment.
protected  class RESTWebService.WebTreatment<RETURN_VALUE>
          Inner class handled by
 
Field Summary
static String RESPONSE_HEADER_ARRAYSIZE
          The HTTP header parameter that provides the real size of an array of resources.
static String REST_WEB_SERVICES_URI_BASE
           
 
Constructor Summary
RESTWebService()
           
 
Method Summary
protected  ResourceLocator getBundle()
          Gets the bundle to use.
protected  String getBundleLocation()
          Gets the location of the bundle to use.
abstract  String getComponentId()
          Gets the identifier of the component instance to which the requested resource belongs to.
 SilverpeasRole getGreaterUserRole()
          Gets the greater role of the user behind the service call.
 HttpRequest getHttpRequest()
          Gets the HTTP request mapped with the execution context of this web service.
 javax.servlet.http.HttpServletRequest getHttpServletRequest()
          Gets the HTTP servlet request mapped with the execution context of this web service.
 javax.servlet.http.HttpServletResponse getHttpServletResponse()
          Gets the HTTP servlet response mapped with the execution context of this web service.
protected  OrganisationController getOrganisationController()
          Gets the organization controller.
 javax.ws.rs.core.UriInfo getUriInfo()
          Gets information about the URI with which this web service was invoked.
protected  UserDetail getUserDetail()
          Gets the detail about the user that has called this web service.
protected  UserPreferences getUserPreferences()
          Gets the preference of the user that requested the resource backed by this web service.
protected  Collection<SilverpeasRole> getUserRoles()
          Gets roles of the authenticated user.
protected
<RETURN_VALUE>
RESTWebService.WebProcess<RETURN_VALUE>
process(RESTWebService.WebTreatment<RETURN_VALUE> webTreatment)
          This method permits to start the setting of a .WebTreatment.
 void validateUserAuthentication(UserPriviledgeValidation validation)
          Validates the authentication of the user requesting this web service.
 void validateUserAuthorization(UserPriviledgeValidation validation)
          Validates the authorization of the user to request this web service.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REST_WEB_SERVICES_URI_BASE

public static final String REST_WEB_SERVICES_URI_BASE

RESPONSE_HEADER_ARRAYSIZE

public static final String RESPONSE_HEADER_ARRAYSIZE
The HTTP header parameter that provides the real size of an array of resources. It is for client side when a pagination mechanism is used in order to calculate the number of pages.

See Also:
Constant Field Values
Constructor Detail

RESTWebService

public RESTWebService()
Method Detail

getComponentId

public abstract String getComponentId()
Gets the identifier of the component instance to which the requested resource belongs to.

Returns:
the identifier of the Silverpeas component instance.

validateUserAuthentication

public void validateUserAuthentication(UserPriviledgeValidation validation)
                                throws javax.ws.rs.WebApplicationException
Validates the authentication of the user requesting this web service. If no session was opened for the user, then open a new one. The validation is actually delegated to the validation service by passing it the required information. This method should be invoked for web service requiring an authenticated user. Otherwise, the annotation Authenticated can be also used instead at class level.

Parameters:
validation - the validation instance to use.
Throws:
javax.ws.rs.WebApplicationException - if the authentication isn't valid (no authentication and authentication failure).
See Also:
UserPriviledgeValidation

validateUserAuthorization

public void validateUserAuthorization(UserPriviledgeValidation validation)
                               throws javax.ws.rs.WebApplicationException
Validates the authorization of the user to request this web service. For doing, the user must have the rights to access the component instance that manages this web resource. The validation is actually delegated to the validation service by passing it the required information. This method should be invoked for web service requiring an authorized access. For doing, the authentication of the user must be first valdiated. Otherwise, the annotation Authorized can be also used instead at class level for both authentication and authorization.

Parameters:
validation - the validation instance to use.
Throws:
javax.ws.rs.WebApplicationException - if the rights of the user are not enough to access this web resource.
See Also:
UserPriviledgeValidation

getUriInfo

public javax.ws.rs.core.UriInfo getUriInfo()
Gets information about the URI with which this web service was invoked.

Returns:
an UriInfo instance.

getHttpServletRequest

public javax.servlet.http.HttpServletRequest getHttpServletRequest()
Gets the HTTP servlet request mapped with the execution context of this web service.

Returns:
the HTTP servlet request.

getHttpRequest

public HttpRequest getHttpRequest()
Gets the HTTP request mapped with the execution context of this web service.

Returns:
the HTTP request.

getHttpServletResponse

public javax.servlet.http.HttpServletResponse getHttpServletResponse()
Gets the HTTP servlet response mapped with the execution context of this web service.

Returns:
the HTTP servlet response.

getUserDetail

protected UserDetail getUserDetail()
Gets the detail about the user that has called this web service. If the user isn't already identified by this web service, then null is returned.

Returns:
the detail about the user.

getUserPreferences

protected UserPreferences getUserPreferences()
Gets the preference of the user that requested the resource backed by this web service. If the user isn't already identified by this web service, then an identification is performed before through an authentication operation followed by an authorization validation. If the identification or the authorization fails, then a WebApplicationException is thrown with respectively a HTTP status code UNAUTHORIZED (401) or FORBIDEN (403). If the preferences can be retrieved, then null is returned.

Returns:
the user preference or null if its preferences can be retrieved.

getUserRoles

protected Collection<SilverpeasRole> getUserRoles()
Gets roles of the authenticated user.

Returns:

getOrganisationController

protected OrganisationController getOrganisationController()
Gets the organization controller.

Returns:
an OrganizationController instance.

getBundleLocation

protected String getBundleLocation()
Gets the location of the bundle to use.

Returns:

getBundle

protected ResourceLocator getBundle()
Gets the bundle to use.

Returns:

getGreaterUserRole

public SilverpeasRole getGreaterUserRole()
Gets the greater role of the user behind the service call.

Returns:

process

protected <RETURN_VALUE> RESTWebService.WebProcess<RETURN_VALUE> process(RESTWebService.WebTreatment<RETURN_VALUE> webTreatment)
This method permits to start the setting of a .WebTreatment.

Type Parameters:
RETURN_VALUE -
Parameters:
webTreatment -
Returns:


Copyright © 2016 Silverpeas. All Rights Reserved.