com.silverpeas.bundle.web
Class BundleResource

java.lang.Object
  extended by com.silverpeas.web.RESTWebService
      extended by com.silverpeas.bundle.web.BundleResource

@Service
@Scope(value="request")
@Authenticated
public class BundleResource
extends RESTWebService

The bundle resource represents either a settings bundle or an i18n messages bundle. This WEB service is an entry point to access the different bundles in use in Silverpeas. It can be accessed only by authenticated users so that is is easy to know the language of the bundle to sent back. The i18n bundled is refered in the URI by its absolute location in the classpath of the Silverpeas portal with as well / or . as path separators, and it can be or not suffixed with properties. For i18n bundles, the language can be indicated with the resource bundle name, otherwise the language of the current user underlying at the HTTP request is taken. If the specified language isn't supported by Silverpeas, then the default language in Silverpeas (yet the French), is taken. In order to add some flexibility, particularly with client-side scripts, the language of the user can be explictly indicated with the i18n bundle name, whatever it is and without knowing it, by using the wildcard $$ as language code; this wildcard means whatever the language (then takes the prefered language of the current user in the session). This parameter isn't taken into account with the settings bundles.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.silverpeas.web.RESTWebService
RESTWebService.WebProcess<RETURN_VALUE>, RESTWebService.WebTreatment<RETURN_VALUE>
 
Field Summary
 
Fields inherited from class com.silverpeas.web.RESTWebService
RESPONSE_HEADER_ARRAYSIZE, REST_WEB_SERVICES_URI_BASE
 
Constructor Summary
BundleResource()
           
 
Method Summary
 String getComponentId()
          Gets the identifier of the component instance to which the requested resource belongs to.
 javax.ws.rs.core.Response getLocalizedBundle(String bundle)
          Asks for an i18n resource bundle either in the language of the current user in the session or in the specified language.
 javax.ws.rs.core.Response getSettingsBundle(String bundle)
          Asks for a settings bundle.
 void validateUserAuthentication(UserPriviledgeValidation validation)
          User authentication is not necessary for this WEB Service.
 
Methods inherited from class com.silverpeas.web.RESTWebService
getBundle, getBundleLocation, getGreaterUserRole, getHttpRequest, getHttpServletRequest, getHttpServletResponse, getOrganisationController, getUriInfo, getUserDetail, getUserPreferences, getUserRoles, process, validateUserAuthorization
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BundleResource

public BundleResource()
Method Detail

getComponentId

public String getComponentId()
Description copied from class: RESTWebService
Gets the identifier of the component instance to which the requested resource belongs to.

Specified by:
getComponentId in class RESTWebService
Returns:
the identifier of the Silverpeas component instance.

validateUserAuthentication

public void validateUserAuthentication(UserPriviledgeValidation validation)
                                throws javax.ws.rs.WebApplicationException
User authentication is not necessary for this WEB Service. The authentication processing is used here to identify the user behind the call if possible.

Overrides:
validateUserAuthentication in class RESTWebService
Parameters:
validation - the validation instance to use.
Throws:
javax.ws.rs.WebApplicationException
See Also:
UserPriviledgeValidation

getLocalizedBundle

public javax.ws.rs.core.Response getLocalizedBundle(String bundle)
                                             throws IOException
Asks for an i18n resource bundle either in the language of the current user in the session or in the specified language. The returned bundle is a merge of both the asked i18n properties and the general Silverpeas i18n texts. The resource bundle is specified by its absolute path in the classpath of the WEB service. If the language is specified with the name of the bundle, it will be considered in place of the language of the current user in the underlying WEB session. For doing, the langage has to be indicated as expected with localized resource bundles. If the language isn't supported by Silverpeas, the default language will be taken. In order to work with some javascript plugins in charge of i18n texts, the method accepts also the particular wildcard $$ to specify explicitly the language of the current user.

Parameters:
bundle - the absolute path of the resource bundle in the classpath of Silverpeas.
Returns:
an HTTP response with the asked properties or an HTTP error.
Throws:
IOException - if an error occurs while accessing the resource bundle.
See Also:
ResourceBundle

getSettingsBundle

public javax.ws.rs.core.Response getSettingsBundle(String bundle)
                                            throws IOException
Asks for a settings bundle. The returned bundle is a merge of both the asked settings and the general Silverpeas settings. The resource bundle is specified by its absolute path in the classpath of the WEB service.

Parameters:
bundle - the absolute path of the resource bundle in the classpath of Silverpeas.
Returns:
an HTTP response with the asked properties or an HTTP error.
Throws:
IOException - if an error occurs while accessing the resource bundle.
See Also:
ResourceBundle


Copyright © 2016 Silverpeas. All Rights Reserved.