/** * Same as {@link #findFirstString(String...)}, but uses the specified locale. * * @param locale The locale of the resource bundle to retrieve message from. * @param keys The list of possible keys. * @return The resolved value, or <jk>null</jk> if no value is found or the resource bundle is missing. */ public String findFirstString(Locale locale, String...keys) { MessageBundle srb = getBundle(locale); return srb.findFirstString(keys); }
/** * Same as {@link #findFirstString(String...)}, but uses the specified locale. * * @param locale The locale of the resource bundle to retrieve message from. * @param keys The list of possible keys. * @return The resolved value, or <jk>null</jk> if no value is found or the resource bundle is missing. */ public String findFirstString(Locale locale, String...keys) { MessageBundle srb = getBundle(locale); return srb.findFirstString(keys); }
/** * Same as {@link #findFirstString(String...)}, but uses the specified locale. * * @param locale The locale of the resource bundle to retrieve message from. * @param keys The list of possible keys. * @return The resolved value, or <jk>null</jk> if no value is found or the resource bundle is missing. */ public String findFirstString(Locale locale, String...keys) { MessageBundle srb = getBundle(locale); return srb.findFirstString(keys); }
private String getDescription(RestRequest req) { VarResolverSession vr = req.getVarResolverSession(); if (description != null) return vr.resolve(description); String description = msgs.findFirstString(req.getLocale(), method.getName() + ".description"); if (description != null) return vr.resolve(description); Operation o = getSwaggerOperationFromFile(req); if (o != null) return o.getDescription(); return null; }
private String getSummary(RestRequest req) { VarResolverSession vr = req.getVarResolverSession(); if (summary != null) return vr.resolve(summary); String summary = msgs.findFirstString(req.getLocale(), method.getName() + ".summary"); if (summary != null) return vr.resolve(summary); Operation o = getSwaggerOperationFromFile(req); if (o != null) return o.getSummary(); return null; }
@SuppressWarnings("unchecked") private List<String> getTags(RestRequest req) { VarResolverSession vr = req.getVarResolverSession(); JsonParser jp = JsonParser.DEFAULT; try { if (tags != null) return jp.parseCollection(vr.resolve(tags), ArrayList.class, String.class); String tags = msgs.findFirstString(req.getLocale(), method.getName() + ".tags"); if (tags != null) return jp.parseCollection(vr.resolve(tags), ArrayList.class, String.class); Operation o = getSwaggerOperationFromFile(req); if (o != null) return o.getTags(); return null; } catch (Exception e) { throw new RestException(SC_INTERNAL_SERVER_ERROR, e); } }
private ExternalDocumentation getExternalDocs(RestRequest req) { VarResolverSession vr = req.getVarResolverSession(); JsonParser jp = JsonParser.DEFAULT; try { if (externalDocs != null) return jp.parse(vr.resolve(externalDocs), ExternalDocumentation.class); String externalDocs = msgs.findFirstString(req.getLocale(), method.getName() + ".externalDocs"); if (externalDocs != null) return jp.parse(vr.resolve(externalDocs), ExternalDocumentation.class); Operation o = getSwaggerOperationFromFile(req); if (o != null) return o.getExternalDocs(); return null; } catch (Exception e) { throw new RestException(SC_INTERNAL_SERVER_ERROR, e); } }
if (siteName != null) return vr.resolve(siteName); String siteName = context.getMessages().findFirstString(req.getLocale(), "siteName"); if (siteName != null) return vr.resolve(siteName);
if (title != null) return vr.resolve(title); String title = context.getMessages().findFirstString(req.getLocale(), "title"); if (title != null) return vr.resolve(title);
if (siteName != null) return vr.resolve(siteName); String siteName = context.getMessages().findFirstString(req.getLocale(), "siteName"); if (siteName != null) return vr.resolve(siteName);
if (description != null) return vr.resolve(description); String description = context.getMessages().findFirstString(req.getLocale(), "description"); if (description != null) return vr.resolve(description);
if (siteName != null) return vr.resolve(siteName); String siteName = context.getMessages().findFirstString(req.getLocale(), "siteName"); if (siteName != null) return vr.resolve(siteName);
/** * Returns the version information of this REST resource. * <p> * Subclasses can override this method to provide their own version information. * <p> * The default implementation returns the version information from the following locations (whichever matches first): * <ol> * <li>{@link RestResource#version() @RestResource.version()} annotation on this class, and then any parent classes. * <li><ck>[ClassName].version</ck> property in resource bundle identified by {@link RestResource#messages() @RestResource.messages()} * annotation for this class, then any parent classes. * <li><ck>version</ck> property in resource bundle identified by {@link RestResource#messages() @RestResource.messages()} * annotation for this class, then any parent classes. * <li><ck>/info/version</ck> entry in swagger file. * </ol> * * @param req The current request. * @return The localized contact information of this REST resource, or <jk>null</jk> if no contact information was found. */ public String getVersion(RestRequest req) { VarResolverSession vr = req.getVarResolverSession(); if (version != null) return vr.resolve(version); String version = msgs.findFirstString(req.getLocale(), "version"); if (version != null) return vr.resolve(version); Swagger s = req.getSwaggerFromFile(); if (s != null && s.getInfo() != null) return s.getInfo().getVersion(); return null; }
/** * Returns the localized description of this REST resource. * <p> * Subclasses can override this method to provide their own description. * <p> * The default implementation returns the description from the following locations (whichever matches first): * <ol> * <li>{@link RestResource#description() @RestResource.description()} annotation on this class, and then any parent classes. * <li><ck>[ClassName].description</ck> property in resource bundle identified by {@link RestResource#messages() @RestResource.messages()} * annotation for this class, then any parent classes. * <li><ck>description</ck> property in resource bundle identified by {@link RestResource#messages() @RestResource.messages()} * annotation for this class, then any parent classes. * <li><ck>/info/description</ck> entry in swagger file. * </ol> * * @param req The current request. * @return The localized description of this REST resource, or <jk>null</jk> if no resource description was found. */ public String getDescription(RestRequest req) { VarResolverSession vr = req.getVarResolverSession(); if (description != null) return vr.resolve(description); String description = msgs.findFirstString(req.getLocale(), "description"); if (description != null) return vr.resolve(description); Swagger s = req.getSwaggerFromFile(); if (s != null && s.getInfo() != null) return s.getInfo().getDescription(); return null; }
/** * Returns the terms-of-service information of this REST resource. * <p> * Subclasses can override this method to provide their own terms-of-service information. * <p> * The default implementation returns the terms-of-service information from the following locations (whichever matches first): * <ol> * <li>{@link RestResource#termsOfService() @RestResource.termsOfService()} annotation on this class, and then any parent classes. * <li><ck>[ClassName].termsOfService</ck> property in resource bundle identified by {@link RestResource#messages() @RestResource.messages()} * annotation for this class, then any parent classes. * <li><ck>termsOfService</ck> property in resource bundle identified by {@link RestResource#messages() @RestResource.messages()} * annotation for this class, then any parent classes. * <li><ck>/info/termsOfService</ck> entry in swagger file. * </ol> * * @param req The current request. * @return The localized contact information of this REST resource, or <jk>null</jk> if no contact information was found. */ public String getTermsOfService(RestRequest req) { VarResolverSession vr = req.getVarResolverSession(); if (termsOfService != null) return vr.resolve(termsOfService); String termsOfService = msgs.findFirstString(req.getLocale(), "termsOfService"); if (termsOfService != null) return vr.resolve(termsOfService); Swagger s = req.getSwaggerFromFile(); if (s != null && s.getInfo() != null) return s.getInfo().getTermsOfService(); return null; }
if (title != null) return vr.resolve(title); String title = msgs.findFirstString(req.getLocale(), "title"); if (title != null) return vr.resolve(title);
if (tags != null) return jp.parseCollection(vr.resolve(tags), ArrayList.class, Tag.class); String tags = msgs.findFirstString(req.getLocale(), "tags"); if (tags != null) return jp.parseCollection(vr.resolve(tags), ArrayList.class, Tag.class);
if (externalDocs != null) return jp.parse(vr.resolve(externalDocs), ExternalDocumentation.class); String externalDocs = msgs.findFirstString(req.getLocale(), "externalDocs"); if (externalDocs != null) return jp.parse(vr.resolve(externalDocs), ExternalDocumentation.class);
if (license != null) return jp.parse(vr.resolve(license), License.class); String license = msgs.findFirstString(req.getLocale(), "license"); if (license != null) return jp.parse(vr.resolve(license), License.class);
if (contact != null) return jp.parse(vr.resolve(contact), Contact.class); String contact = msgs.findFirstString(req.getLocale(), "contact"); if (contact != null) return jp.parse(vr.resolve(contact), Contact.class);