Class BundleResource

  • All Implemented Interfaces:
    ProtectedWebResource, WebAuthenticationValidation, WebAuthorizationValidation, SilverpeasWebResource

    @RequestScoped
    @Path("bundles")
    @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 referred 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 explicitly 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 preferred language of the current user in the session). This parameter isn't taken into account with the settings bundles.
    • Constructor Detail

      • BundleResource

        public BundleResource()
    • Method Detail

      • getComponentId

        public String getComponentId()
        Description copied from interface: SilverpeasWebResource
        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​(UserPrivilegeValidation validation)
        User authentication is not necessary for this WEB Service. The authentication processing is used here to identify the user behind the call if possible.
        Parameters:
        validation - the validation instance to use.
        See Also:
        UserPrivilegeValidator
      • getLocalizedBundle

        @GET
        @Path("just/{bundle: org/silverpeas/[a-zA-Z0-9/._$]+}")
        @Produces("text/plain")
        public javax.ws.rs.core.Response getLocalizedBundle​(@PathParam("bundle")
                                                            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 does not provide 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
      • getLocalizedBundle

        @GET
        @Path("{bundle: org/silverpeas/[a-zA-Z0-9/._$]+}")
        @Produces("text/plain")
        public javax.ws.rs.core.Response getLocalizedBundle​(@PathParam("bundle")
                                                            String bundle,
                                                            @QueryParam("withoutGeneral")
                                                            boolean withoutGeneral)
                                                     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.
        withoutGeneral - true if the general bundle must not be merged into response.
        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

        @GET
        @Path("settings/{bundle: org/silverpeas/[a-zA-Z0-9/._$]+}")
        @Produces("text/plain")
        public javax.ws.rs.core.Response getSettingsBundle​(@PathParam("bundle")
                                                           String bundle,
                                                           @QueryParam("withGeneral")
                                                           boolean withGeneral)
                                                    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.
        withGeneral - true if the general settings must be added into response.
        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