Class BundleResource
- java.lang.Object
-
- org.silverpeas.core.web.rs.RESTWebService
-
- org.silverpeas.core.webapi.bundle.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.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.silverpeas.core.web.rs.RESTWebService
RESTWebService.WebProcess<R>, RESTWebService.WebTreatment<R>
-
-
Field Summary
-
Fields inherited from class org.silverpeas.core.web.rs.RESTWebService
RESPONSE_HEADER_ARRAYSIZE
-
Fields inherited from interface org.silverpeas.core.web.SilverpeasWebResource
BASE_PATH
-
-
Constructor Summary
Constructors Constructor Description BundleResource()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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
getLocalizedBundle(String bundle, boolean withoutGeneral)
Asks for an i18n resource bundle either in the language of the current user in the session or in the specified language.protected String
getResourceBasePath()
Gets the base path of the web resource relative to the root path of all the web resources in Silverpeas as given bySilverpeasWebResource.getBasePath()
.javax.ws.rs.core.Response
getSettingsBundle(String bundle, boolean withGeneral)
Asks for a settings bundle.void
validateUserAuthentication(UserPrivilegeValidation validation)
User authentication is not necessary for this WEB Service.-
Methods inherited from class org.silverpeas.core.web.rs.RESTWebService
createWebResourceUri, fromPage, getBundle, getBundleLocation, getHighestUserRole, getHttpRequest, getHttpServletRequest, getHttpServletResponse, getOrganisationController, getSilverpeasContext, getUri, getUser, getUserPreferences, getUserRoles, identifiedBy, identifiedBy, initContext, initWebResourceUri, isUserDefined, process
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.silverpeas.core.web.rs.ProtectedWebResource
validateUserAuthorization
-
-
-
-
Method Detail
-
getResourceBasePath
protected String getResourceBasePath()
Description copied from class:RESTWebService
Gets the base path of the web resource relative to the root path of all the web resources in Silverpeas as given bySilverpeasWebResource.getBasePath()
.- Specified by:
getResourceBasePath
in classRESTWebService
- Returns:
- the relative path that identifies this REST web service among all other REST web services.
-
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
-
-