Repository: incubator-juneau Updated Branches: refs/heads/master fac3eb92f -> ffda0552d
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/ffda0552/juneau-rest/src/main/java/org/apache/juneau/rest/CallMethod.java ---------------------------------------------------------------------- diff --git a/juneau-rest/src/main/java/org/apache/juneau/rest/CallMethod.java b/juneau-rest/src/main/java/org/apache/juneau/rest/CallMethod.java index 2d3774c..4fab1b1 100644 --- a/juneau-rest/src/main/java/org/apache/juneau/rest/CallMethod.java +++ b/juneau-rest/src/main/java/org/apache/juneau/rest/CallMethod.java @@ -68,8 +68,9 @@ class CallMethod implements Comparable<CallMethod> { private final Response[] responses; private final RestContext context; private final BeanContext beanContext; - private final String htmlTitle, htmlDescription, htmlBranding, htmlHeader, htmlLinks, htmlNav, htmlAside, + private final String htmlTitle, htmlDescription, htmlBranding, htmlHeader, htmlNav, htmlAside, htmlFooter, htmlStyle, htmlStylesheet, htmlScript, htmlNoResultsMessage; + private final String[] htmlLinks; private final boolean htmlNoWrap; private final HtmlDocTemplate htmlTemplate; private final Map<String,Widget> widgets; @@ -123,7 +124,8 @@ class CallMethod implements Comparable<CallMethod> { private static class Builder { private String httpMethod, defaultCharset, description, tags, summary, externalDocs, htmlTitle, htmlDescription, - htmlBranding, htmlLinks, htmlNav, htmlAside, htmlFooter, htmlStyle, htmlStylesheet, htmlScript, htmlHeader, htmlNoResultsMessage; + htmlBranding, htmlNav, htmlAside, htmlFooter, htmlStyle, htmlStylesheet, htmlScript, htmlHeader, htmlNoResultsMessage; + private String[] htmlLinks; private boolean htmlNoWrap; private HtmlDocTemplate htmlTemplate; private UrlPathPattern pathPattern; @@ -183,17 +185,17 @@ class CallMethod implements Comparable<CallMethod> { HtmlDoc hd = m.htmldoc(); htmlTitle = hd.title().isEmpty() ? context.getHtmlTitle() : hd.title(); htmlDescription = hd.description().isEmpty() ? context.getHtmlDescription() : hd.description(); - htmlBranding = hd.branding().isEmpty() ? context.getHtmlBranding() : hd.branding(); - htmlHeader = hd.header().isEmpty() ? context.getHtmlHeader() : hd.header(); - htmlLinks = hd.links().isEmpty() ? context.getHtmlLinks() : hd.links(); - htmlNav = hd.nav().isEmpty() ? context.getHtmlNav() : hd.nav(); - htmlAside = hd.aside().isEmpty() ? context.getHtmlAside() : hd.aside(); - htmlFooter = hd.footer().isEmpty() ? context.getHtmlFooter() : hd.footer(); - htmlStyle = hd.style().isEmpty() ? context.getHtmlStyle() : hd.style(); + htmlBranding = hd.branding().length == 0 ? context.getHtmlBranding() : join(hd.branding(), '\n'); + htmlHeader = hd.header().length == 0 ? context.getHtmlHeader() : join(hd.header(), '\n'); + htmlLinks = hd.links().length == 0 ? context.getHtmlLinks() : hd.links(); + htmlNav = hd.nav().length == 0 ? context.getHtmlNav() : join(hd.nav(), '\n'); + htmlAside = hd.aside().length == 0 ? context.getHtmlAside() : join(hd.aside(), '\n'); + htmlFooter = hd.footer().length == 0 ? context.getHtmlFooter() : join(hd.footer(), '\n'); + htmlStyle = hd.style().length == 0 ? context.getHtmlStyle() : join(hd.style(), '\n'); htmlStylesheet = hd.stylesheet().isEmpty() ? context.getHtmlStylesheet() : hd.stylesheet(); - htmlScript = hd.script().isEmpty() ? context.getHtmlScript() : hd.script(); + htmlScript = hd.script().length == 0 ? context.getHtmlScript() : join(hd.script(), '\n'); htmlNoWrap = hd.nowrap() ? hd.nowrap() : context.getHtmlNoWrap(); - htmlNoResultsMessage = hd.noResultsMessage().isEmpty() ? context.getHtmlNoResultsMessage() : hd.header(); + htmlNoResultsMessage = hd.noResultsMessage().isEmpty() ? context.getHtmlNoResultsMessage() : hd.noResultsMessage(); htmlTemplate = hd.template() == HtmlDocTemplate.class ? context.getHtmlTemplate() @@ -920,13 +922,21 @@ class CallMethod implements Comparable<CallMethod> { if (k.equals(HTMLDOC_branding)) return htmlBranding == null ? null : req.resolveVars(htmlBranding); if (k.equals(HTMLDOC_links)) { - if (htmlLinks == null) + if (htmlLinks == null || htmlLinks.length == 0) return null; try { - ObjectMap m = new ObjectMap(htmlLinks), m2 = new ObjectMap(); - for (Map.Entry<String,Object> e : m.entrySet()) - m2.put(req.resolveVars(e.getKey()), req.resolveVars(StringUtils.toString(e.getValue()))); - return m2; + List<String> la = new ArrayList<String>(); + for (String l : htmlLinks) { + // Temporary backwards compatibility with JSON object format. + if (l.startsWith("{")) { + ObjectMap m = new ObjectMap(l); + for (Map.Entry<String,Object> e : m.entrySet()) + la.add(req.resolveVars(e.getKey()) + ":" + req.resolveVars(StringUtils.toString(e.getValue()))); + } else { + la.add(req.resolveVars(l)); + } + } + return la; } catch (ParseException e) { throw new RuntimeException(e); } http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/ffda0552/juneau-rest/src/main/java/org/apache/juneau/rest/RestConfig.java ---------------------------------------------------------------------- diff --git a/juneau-rest/src/main/java/org/apache/juneau/rest/RestConfig.java b/juneau-rest/src/main/java/org/apache/juneau/rest/RestConfig.java index 6d10d6a..0ad162b 100644 --- a/juneau-rest/src/main/java/org/apache/juneau/rest/RestConfig.java +++ b/juneau-rest/src/main/java/org/apache/juneau/rest/RestConfig.java @@ -112,8 +112,9 @@ public class RestConfig implements ServletConfig { Object favIcon; List<Object> staticFiles; RestContext parentContext; - String path, htmlTitle, htmlDescription, htmlBranding, htmlLinks, htmlHeader, htmlNav, htmlAside, htmlFooter, + String path, htmlTitle, htmlDescription, htmlBranding, htmlHeader, htmlNav, htmlAside, htmlFooter, htmlStyle, htmlStylesheet, htmlScript, htmlNoResultsMessage; + String[] htmlLinks; String clientVersionHeader = "X-Client-Version"; Object resourceResolver = RestResourceResolver.class; @@ -227,20 +228,22 @@ public class RestConfig implements ServletConfig { setHtmlTitle(hd.title()); if (! hd.description().isEmpty()) setHtmlDescription(hd.description()); - if (! hd.branding().isEmpty()) - setHtmlBranding(hd.branding()); - if (! hd.header().isEmpty()) - setHtmlHeader(hd.header()); - if (! hd.links().isEmpty()) + if (hd.branding().length > 0) + setHtmlBranding(join(hd.branding(), '\n')); + if (hd.header().length > 0) + setHtmlHeader(join(hd.header(), '\n')); + if (hd.links().length != 0) setHtmlLinks(hd.links()); - if (! hd.nav().isEmpty()) - setHtmlNav(hd.nav()); - if (! hd.aside().isEmpty()) - setHtmlAside(hd.aside()); - if (! hd.footer().isEmpty()) - setHtmlFooter(hd.footer()); - if (! hd.style().isEmpty()) - setHtmlStyle(hd.style()); + if (hd.nav().length > 0) + setHtmlNav(join(hd.nav(), '\n')); + if (hd.aside().length > 0) + setHtmlAside(join(hd.aside(), '\n')); + if (hd.footer().length > 0) + setHtmlFooter(join(hd.footer(), '\n')); + if (hd.style().length > 0) + setHtmlStyle(join(hd.style(), '\n')); + if (hd.script().length > 0) + setHtmlScript(join(hd.script(), '\n')); if (! hd.stylesheet().isEmpty()) setHtmlStylesheet(hd.stylesheet()); if (! hd.noResultsMessage().isEmpty()) @@ -1270,7 +1273,7 @@ public class RestConfig implements ServletConfig { * @param value The HTML nav section links links. * @return This object (for method chaining). */ - public RestConfig setHtmlLinks(String value) { + public RestConfig setHtmlLinks(String[] value) { this.htmlLinks = value; return this; } @@ -1288,7 +1291,7 @@ public class RestConfig implements ServletConfig { * The format of this value is HTML. * * <p> - * When a value is specified, the {@link #setHtmlLinks(String)} value will be ignored. + * When a value is specified, the {@link #setHtmlLinks(String[])} value will be ignored. * * <p> * This field can contain variables (e.g. <js>"$L{my.localized.variable}"</js>). http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/ffda0552/juneau-rest/src/main/java/org/apache/juneau/rest/RestContext.java ---------------------------------------------------------------------- diff --git a/juneau-rest/src/main/java/org/apache/juneau/rest/RestContext.java b/juneau-rest/src/main/java/org/apache/juneau/rest/RestContext.java index 10bbc6a..51d10f2 100644 --- a/juneau-rest/src/main/java/org/apache/juneau/rest/RestContext.java +++ b/juneau-rest/src/main/java/org/apache/juneau/rest/RestContext.java @@ -354,7 +354,6 @@ public final class RestContext extends Context { htmlDescription, htmlBranding, htmlHeader, - htmlLinks, htmlNav, htmlAside, htmlStyle, @@ -362,6 +361,8 @@ public final class RestContext extends Context { htmlScript, htmlFooter, htmlNoResultsMessage; + private final String[] + htmlLinks; private final boolean htmlNoWrap; private final HtmlDocTemplate htmlTemplate; private final Map<String,Widget> widgets; @@ -653,7 +654,8 @@ public final class RestContext extends Context { UrlEncodingParser urlEncodingParser; EncoderGroup encoders; String clientVersionHeader = "", defaultCharset, paramFormat, htmlTitle, htmlDescription, htmlBranding, - htmlHeader, htmlLinks, htmlNav, htmlAside, htmlStyle, htmlStylesheet, htmlScript, htmlFooter, htmlNoResultsMessage; + htmlHeader, htmlNav, htmlAside, htmlStyle, htmlStylesheet, htmlScript, htmlFooter, htmlNoResultsMessage; + String[] htmlLinks; boolean htmlNoWrap; HtmlDocTemplate htmlTemplate; @@ -1052,11 +1054,11 @@ public final class RestContext extends Context { * The HTML page nav section links. * * <p> - * Defined by the {@link HtmlDoc#links()} annotation or {@link RestConfig#setHtmlLinks(String)} method. + * Defined by the {@link HtmlDoc#links()} annotation or {@link RestConfig#setHtmlLinks(String[])} method. * * @return The HTML page nav section links. */ - public String getHtmlLinks() { + public String[] getHtmlLinks() { return htmlLinks; } http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/ffda0552/juneau-rest/src/main/java/org/apache/juneau/rest/RestRequest.java ---------------------------------------------------------------------- diff --git a/juneau-rest/src/main/java/org/apache/juneau/rest/RestRequest.java b/juneau-rest/src/main/java/org/apache/juneau/rest/RestRequest.java index 937a429..07a73aa 100644 --- a/juneau-rest/src/main/java/org/apache/juneau/rest/RestRequest.java +++ b/juneau-rest/src/main/java/org/apache/juneau/rest/RestRequest.java @@ -546,7 +546,7 @@ public final class RestRequest extends HttpServletRequestWrapper { * Returns the URI for this request. * * <p> - * Similar to {@link #getRequestURL()} but returns the value as a {@link URI}. + * Similar to {@link #getRequestURI()} but returns the value as a {@link URI}. * It also gives you the capability to override the query parameters (e.g. add new query parameters to the existing * URI). * @@ -555,17 +555,19 @@ public final class RestRequest extends HttpServletRequestWrapper { * @return A new URI. */ public URI getUri(boolean includeQuery, Map<String,?> addQueryParams) { - StringBuffer sb = getRequestURL(); + String uri = getRequestURI(); if (includeQuery || addQueryParams != null) { + StringBuilder sb = new StringBuilder(uri); RequestQuery rq = this.queryParams.copy(); if (addQueryParams != null) for (Map.Entry<String,?> e : addQueryParams.entrySet()) rq.put(e.getKey(), e.getValue()); if (! rq.isEmpty()) sb.append('?').append(rq.toQueryString()); + uri = sb.toString(); } try { - return new URI(sb.toString()); + return new URI(uri); } catch (URISyntaxException e) { // Shouldn't happen. throw new RuntimeException(e); http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/ffda0552/juneau-rest/src/main/java/org/apache/juneau/rest/RestResponse.java ---------------------------------------------------------------------- diff --git a/juneau-rest/src/main/java/org/apache/juneau/rest/RestResponse.java b/juneau-rest/src/main/java/org/apache/juneau/rest/RestResponse.java index 464e92d..958707a 100644 --- a/juneau-rest/src/main/java/org/apache/juneau/rest/RestResponse.java +++ b/juneau-rest/src/main/java/org/apache/juneau/rest/RestResponse.java @@ -632,7 +632,6 @@ public final class RestResponse extends HttpServletResponseWrapper { * * @param value * The HTML nav section links links. - * Object will be converted to a string using {@link Object#toString()}. * <p> * <ul class='doctree'> * <li class='info'> @@ -641,7 +640,7 @@ public final class RestResponse extends HttpServletResponseWrapper { * </ul> * @return This object (for method chaining). */ - public RestResponse setHtmlLinks(Object value) { + public RestResponse setHtmlLinks(String[] value) { properties.put(HtmlDocSerializerContext.HTMLDOC_links, value); return this; } @@ -659,7 +658,7 @@ public final class RestResponse extends HttpServletResponseWrapper { * The format of this value is HTML. * * <p> - * When a value is specified, the {@link #setHtmlLinks(Object)} value will be ignored. + * When a value is specified, the {@link #setHtmlLinks(String[])} value will be ignored. * * <p> * This field can contain variables (e.g. <js>"$L{my.localized.variable}"</js>). http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/ffda0552/juneau-rest/src/main/java/org/apache/juneau/rest/RestServletDefault.java ---------------------------------------------------------------------- diff --git a/juneau-rest/src/main/java/org/apache/juneau/rest/RestServletDefault.java b/juneau-rest/src/main/java/org/apache/juneau/rest/RestServletDefault.java index 0cbb5aa..d158783 100644 --- a/juneau-rest/src/main/java/org/apache/juneau/rest/RestServletDefault.java +++ b/juneau-rest/src/main/java/org/apache/juneau/rest/RestServletDefault.java @@ -211,7 +211,10 @@ public abstract class RestServletDefault extends RestServlet { */ @RestMethod(name="OPTIONS", path="/*", htmldoc=@HtmlDoc( - links="{back:'servlet:/',json:'servlet:/?method=OPTIONS&Accept=text/json&plainText=true'}", + links={ + "back: servlet:/,", + "json: servlet:/?method=OPTIONS&Accept=text/json&plainText=true" + }, description="Swagger documentation", aside="NONE" ), http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/ffda0552/juneau-rest/src/main/java/org/apache/juneau/rest/annotation/HtmlDoc.java ---------------------------------------------------------------------- diff --git a/juneau-rest/src/main/java/org/apache/juneau/rest/annotation/HtmlDoc.java b/juneau-rest/src/main/java/org/apache/juneau/rest/annotation/HtmlDoc.java index 50d6d00..eef9227 100644 --- a/juneau-rest/src/main/java/org/apache/juneau/rest/annotation/HtmlDoc.java +++ b/juneau-rest/src/main/java/org/apache/juneau/rest/annotation/HtmlDoc.java @@ -181,10 +181,13 @@ public @interface HtmlDoc { * A value of <js>"NONE"</js> can be used to force no value. * * <p> + * Multiple values are combined with newlines into a single string. + * + * <p> * The programmatic equivalent to this annotation are the * {@link RestConfig#setHtmlBranding(String)}/{@link RestResponse#setHtmlBranding(Object)} methods. */ - String branding() default ""; + String[] branding() default {}; /** * Sets the HTML header section contents. @@ -200,7 +203,9 @@ public @interface HtmlDoc { * <p class='bcode'> * <ja>@RestResource</ja>( * htmldoc=<ja>@HtmlDoc</ja>( - * header=<js>"<p>This is my REST interface</p>"</js> + * header={ + * <js>"<p>This is my REST interface</p>"</js> + * } * ) * ) * </p> @@ -215,17 +220,24 @@ public @interface HtmlDoc { * This field can contain variables (e.g. <js>"$L{my.localized.variable}"</js>). * * <p> + * Multiple values are combined with newlines into a single string. + * + * <p> * The programmatic equivalent to this annotation are the * {@link RestConfig#setHtmlHeader(String)}/{@link RestResponse#setHtmlHeader(Object)} methods. */ - String header() default ""; + String[] header() default {}; /** * Sets the links in the HTML nav section. * * <p> - * The format of this value is a lax-JSON map of key/value pairs where the keys are the link text and the values are - * relative (to the servlet) or absolute URLs. + * The value is an array of strings with two possible values: + * <ul> + * <li>A key-value pair representing a hyperlink label and href: + * <br><js>"google: http://google.com"</js> + * <li>Arbitrary HTML. + * </ul> * * <p> * The page links are positioned immediately under the title and text. @@ -234,7 +246,10 @@ public @interface HtmlDoc { * <p class='bcode'> * <ja>@RestResource</ja>( * htmldoc=<ja>@HtmlDoc</ja>( - * links=<js>"{up:'request:/..',options:'servlet:/?method=OPTIONS'}"</js> + * links={ + * <js>"up: request:/.."</js>, + * <js>"options: servlet:/?method=OPTIONS"</js> + * } * ) * ) * </p> @@ -250,9 +265,9 @@ public @interface HtmlDoc { * * <p> * The programmatic equivalent to this annotation are the - * {@link RestConfig#setHtmlLinks(String)}/{@link RestResponse#setHtmlLinks(Object)} methods. + * {@link RestConfig#setHtmlLinks(String[])}/{@link RestResponse#setHtmlLinks(String[])} methods. */ - String links() default ""; + String[] links() default {}; /** * Sets the HTML nav section contents. @@ -270,7 +285,9 @@ public @interface HtmlDoc { * <p class='bcode'> * <ja>@RestResource</ja>( * htmldoc=<ja>@HtmlDoc</ja>( - * nav=<js>"<p>Custom nav content</p>"</js> + * nav={ + * <js>"<p>Custom nav content</p>"</js> + * } * ) * ) * </p> @@ -285,10 +302,13 @@ public @interface HtmlDoc { * A value of <js>"NONE"</js> can be used to force no value. * * <p> + * Multiple values are combined with newlines into a single string. + * + * <p> * The programmatic equivalent to this annotation are the * {@link RestConfig#setHtmlNav(String)}/{@link RestResponse#setHtmlNav(Object)} methods. */ - String nav() default ""; + String[] nav() default {}; /** * Sets the HTML aside section contents. @@ -303,7 +323,9 @@ public @interface HtmlDoc { * <p class='bcode'> * <ja>@RestResource</ja>( * htmldoc=<ja>@HtmlDoc</ja>( - * aside=<js>"<p>Custom aside content</p>"</js> + * aside={ + * <js>"<p>Custom aside content</p>"</js> + * } * ) * ) * </p> @@ -315,10 +337,13 @@ public @interface HtmlDoc { * A value of <js>"NONE"</js> can be used to force no value. * * <p> + * Multiple values are combined with newlines into a single string. + * + * <p> * The programmatic equivalent to this annotation are the * {@link RestConfig#setHtmlAside(String)}/{@link RestResponse#setHtmlAside(Object)} methods. */ - String aside() default ""; + String[] aside() default {}; /** * Sets the HTML footer section contents. @@ -333,7 +358,9 @@ public @interface HtmlDoc { * <p class='bcode'> * <ja>@RestResource</ja>( * htmldoc=<ja>@HtmlDoc</ja>( - * footer=<js>"<p>Custom footer content</p>"</js> + * footer={ + * <js>"<p>Custom footer content</p>"</js> + * } * ) * ) * </p> @@ -345,10 +372,13 @@ public @interface HtmlDoc { * A value of <js>"NONE"</js> can be used to force no value. * * <p> + * Multiple values are combined with newlines into a single string. + * + * <p> * The programmatic equivalent to this annotation are the * {@link RestConfig#setHtmlFooter(String)}/{@link RestResponse#setHtmlFooter(Object)} methods. */ - String footer() default ""; + String[] footer() default {}; /** * Sets the HTML CSS style section contents. @@ -360,7 +390,10 @@ public @interface HtmlDoc { * <p class='bcode'> * <ja>@RestResource</ja>( * htmldoc=<ja>@HtmlDoc</ja>( - * style=<js>".red{color:red;}\n.blue{color:blue}"</js> + * style={ + * <js>".red{color:red;}"</js>, + * <js>".blue{color:blue;}"</js> + * } * ) * ) * </p> @@ -372,10 +405,13 @@ public @interface HtmlDoc { * A value of <js>"NONE"</js> can be used to force no value. * * <p> + * Multiple values are combined with newlines into a single string. + * + * <p> * The programmatic equivalent to this annotation are the * {@link RestConfig#setHtmlStyle(String)}/{@link RestResponse#setHtmlStyle(Object)} methods. */ - String style() default ""; + String[] style() default {}; /** * Sets the CSS URL in the HTML CSS style section. @@ -418,7 +454,9 @@ public @interface HtmlDoc { * <p class='bcode'> * <ja>@RestResource</ja>( * htmldoc=<ja>@HtmlDoc</ja>( - * script=<js>"alert('Hello!')"</js> + * script={ + * <js>"alert('Hello!')"</js> + * } * ) * ) * </p> @@ -430,10 +468,13 @@ public @interface HtmlDoc { * A value of <js>"NONE"</js> can be used to force no value. * * <p> + * Multiple values are combined with newlines into a single string. + * + * <p> * The programmatic equivalent to this annotation are the * {@link RestConfig#setHtmlScript(String)}/{@link RestResponse#setHtmlScript(Object)} methods. */ - String script() default ""; + String[] script() default {}; /** * Shorthand method for forcing the rendered HTML content to be no-wrap. http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/ffda0552/juneau-rest/src/main/java/org/apache/juneau/rest/annotation/RestResource.java ---------------------------------------------------------------------- diff --git a/juneau-rest/src/main/java/org/apache/juneau/rest/annotation/RestResource.java b/juneau-rest/src/main/java/org/apache/juneau/rest/annotation/RestResource.java index 9c82c3e..98e3788 100644 --- a/juneau-rest/src/main/java/org/apache/juneau/rest/annotation/RestResource.java +++ b/juneau-rest/src/main/java/org/apache/juneau/rest/annotation/RestResource.java @@ -700,19 +700,24 @@ public @interface RestResource { * // "servlet:/..." URIs are relative to the servlet URI. * // "$C{...}" variables are pulled from the config file.</jc> * htmldoc=<ja>@HtmlDoc</ja>( - * links=<js>"{up:'request:/..',options:'servlet:/?method=OPTIONS',source:'$C{Source/gitHub}/org/apache/juneau/examples/rest/addressbook/AddressBookResource.java'}"</js>, - * aside=<js>""</js> - * + <js>"<div style='max-width:400px;min-width:200px'>"</js> - * + <js>" <p>Proof-of-concept resource that shows off the capabilities of working with POJO resources.</p>"</js> - * + <js>" <p>Provides examples of: </p>"</js> - * + <js>" <ul>"</js> - * + <js>" <li>XML and RDF namespaces"</js> - * + <js>" <li>Swagger documentation"</js> - * + <js>" <li>Widgets"</js> - * + <js>" </ul>"</js> - * + <js>" <p style='text-weight:bold;text-decoration:underline;'>Available Content Types</p>"</js> - * + <js>" $W{contentTypeLinks}"</js> - * + <js>"</div>"</js>, + * links={ + * <js>"up: request:/.."</js>, + * <js>"options: servlet:/?method=OPTIONS"</js>, + * <js>"source: $C{Source/gitHub}/org/apache/juneau/examples/rest/addressbook/AddressBookResource.java"</js>, + * }, + * aside={ + * <js>"<div style='max-width:400px;min-width:200px'>"</js>, + * <js>" <p>Proof-of-concept resource that shows off the capabilities of working with POJO resources.</p>"</js>, + * <js>" <p>Provides examples of: </p>"</js>, + * <js>" <ul>"</js>, + * <js>" <li>XML and RDF namespaces"</js>, + * <js>" <li>Swagger documentation"</js>, + * <js>" <li>Widgets"</js>, + * <js>" </ul>"</js>, + * <js>" <p style='text-weight:bold;text-decoration:underline;'>Available Content Types</p>"</js>, + * <js>" $W{contentTypeLinks}"</js>, + * <js>"</div>"</js> + * }, * footer=<js>"$W{poweredByJuneau}"</js> * ), * http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/ffda0552/juneau-rest/src/main/java/org/apache/juneau/rest/jena/RestServletJenaDefault.java ---------------------------------------------------------------------- diff --git a/juneau-rest/src/main/java/org/apache/juneau/rest/jena/RestServletJenaDefault.java b/juneau-rest/src/main/java/org/apache/juneau/rest/jena/RestServletJenaDefault.java index 4b8984a..beb0231 100644 --- a/juneau-rest/src/main/java/org/apache/juneau/rest/jena/RestServletJenaDefault.java +++ b/juneau-rest/src/main/java/org/apache/juneau/rest/jena/RestServletJenaDefault.java @@ -262,7 +262,10 @@ public abstract class RestServletJenaDefault extends RestServlet { */ @RestMethod(name="OPTIONS", path="/*", htmldoc=@HtmlDoc( - links="{back:'servlet:/',json:'servlet:/?method=OPTIONS&Accept=text/json&plainText=true'}", + links={ + "back: servlet:/", + "json: servlet:/?method=OPTIONS&Accept=text/json&plainText=true" + }, description="Swagger documentation", aside="NONE" ), http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/ffda0552/juneau-rest/src/main/java/org/apache/juneau/rest/package.html ---------------------------------------------------------------------- diff --git a/juneau-rest/src/main/java/org/apache/juneau/rest/package.html b/juneau-rest/src/main/java/org/apache/juneau/rest/package.html index 00a4497..8097a17 100644 --- a/juneau-rest/src/main/java/org/apache/juneau/rest/package.html +++ b/juneau-rest/src/main/java/org/apache/juneau/rest/package.html @@ -242,7 +242,10 @@ <ja>@RestResource</ja>( messages=<js>"nls/HelloWorldResource"</js>, htmldoc=<ja>@HtmlDoc</ja>( - links=<js>"{up:'request:/..',options:'servlet:/?method=OPTIONS'}"</js> + links={ + <js>"up: request:/.."</js>, + <js>"options: servlet:/?method=OPTIONS"</js> + } ) ) <jk>public class</jk> HelloWorldResource <jk>extends</jk> Resource { @@ -1186,7 +1189,10 @@ <ja>@RestMethod</ja>(name=<js>"OPTIONS"</js>, path=<js>"/*"</js>, summary=<js>"Resource options"</js>, htmldoc=<ja>@HtmlDoc</ja>( - links=<js>"{back:'$R{servletURI}'}"</js> + links={ + <js>"back: servlet:/,"</js>, + <js>"json: servlet:/?method=OPTIONS&Accept=text/json&plainText=true"</js> + } ) ) <jk>public</jk> Swagger getOptions(RestRequest req) { @@ -2368,7 +2374,10 @@ title=<js>"URL-encoded Form Post Resource"</js>, description=<js>"Shows how form posts are converted into beans."</js>, htmldoc=<ja>@HtmlDoc</ja>( - links=<js>"{up:'request:/..',options:'servlet:/?method=OPTIONS'}"</js> + links={ + <js>"up: request:/.."</js>, + <js>"options: servlet:/?method=OPTIONS"</js> + } ) ) <jk>public class</jk> UrlEncodedFormResource <jk>extends</jk> Resource { @@ -3127,7 +3136,9 @@ title=<js>"Photo REST service"</js>, description=<js>"Use a tool like Poster to upload and retrieve jpeg and png images."</js>, htmldoc=<ja>@HtmlDoc</ja>( - links=<js>"{options:'?method=OPTIONS'}"</js> + links={ + <js>"options: ?method=OPTIONS"</js> + } ) ) <jk>public class</jk> PhotosResource <jk>extends</jk> RestServletDefault { @@ -3437,8 +3448,12 @@ // "servlet:/..." URIs are relative to the servlet URI. // "$C{...}" variables are pulled from the config file.</jc> htmldoc=<ja>@HtmlDoc</ja>( - links=<js>"{up:'request:/..', options:'servlet:/?method=OPTIONS', source:'$C{Source/gitHub}/org/apache/juneau/examples/rest/addressbook/AddressBookResource.java'}"</js> - + links={ + <js>"up: request:/.."</js>, + <js>"options: servlet:/?method=OPTIONS"</js>, + <js>"source: $C{Source/gitHub}/org/apache/juneau/examples/rest/addressbook/AddressBookResource.java"</js> + }, + <jc>// Our stylesheet for the HTML rendition.</jc> stylesheet=<js>"servlet:/styles/devops.css"</js>, ), http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/ffda0552/juneau-rest/src/main/java/org/apache/juneau/rest/widget/ContentTypeMenuItem.java ---------------------------------------------------------------------- diff --git a/juneau-rest/src/main/java/org/apache/juneau/rest/widget/ContentTypeMenuItem.java b/juneau-rest/src/main/java/org/apache/juneau/rest/widget/ContentTypeMenuItem.java index c8fd158..b1bf483 100644 --- a/juneau-rest/src/main/java/org/apache/juneau/rest/widget/ContentTypeMenuItem.java +++ b/juneau-rest/src/main/java/org/apache/juneau/rest/widget/ContentTypeMenuItem.java @@ -36,7 +36,14 @@ import org.apache.juneau.utils.*; * ContentTypeMenuItem.<jk>class</jk>, * }, * htmldoc=<ja>@HtmlDoc</ja>( - * links=<js>"{up:'...',options:'...',query:'...',contentTypes:'$W{contentTypeMenuItem}',source:'...'}"</js> + * links={ + * <js>"up: ..."</js>, + * <js>"options: ..."</js>, + * <js>"$W{queryMenuItem}"</js>, + * <js>"$W{contentTypeMenuItem}"</js>, + * <js>"$W{styleMenuItem}"</js>, + * <js>"source: ..."</js> + * } * ) * ) * <jk>public</jk> Collection<Pet> getPets() { http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/ffda0552/juneau-rest/src/main/java/org/apache/juneau/rest/widget/QueryMenuItem.java ---------------------------------------------------------------------- diff --git a/juneau-rest/src/main/java/org/apache/juneau/rest/widget/QueryMenuItem.java b/juneau-rest/src/main/java/org/apache/juneau/rest/widget/QueryMenuItem.java index cadc7dc..341cd0f 100644 --- a/juneau-rest/src/main/java/org/apache/juneau/rest/widget/QueryMenuItem.java +++ b/juneau-rest/src/main/java/org/apache/juneau/rest/widget/QueryMenuItem.java @@ -37,7 +37,14 @@ import org.apache.juneau.rest.converters.*; * QueryMenuItem.<jk>class</jk>, * }, * htmldoc=<ja>@HtmlDoc</ja>( - * links=<js>"{up:'...',options:'...',query:'$W{queryMenuItem}',contentTypes:'...',source:'...'}"</js> + * links={ + * <js>"up: ..."</js>, + * <js>"options: ..."</js>, + * <js>"$W{queryMenuItem}"</js>, + * <js>"$W{contentTypeMenuItem}"</js>, + * <js>"$W{styleMenuItem}"</js>, + * <js>"source: ..."</js> + * } * ), * converters=Queryable.<jk>class</jk> * ) @@ -82,6 +89,6 @@ public class QueryMenuItem extends MenuItemWidget { */ @Override /* Widget */ public String getHtml(RestRequest req) throws Exception { - return getResourceAsString("QueryMenuItem.html"); + return loadHtml("QueryMenuItem.html"); } } http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/ffda0552/juneau-rest/src/main/java/org/apache/juneau/rest/widget/StyleMenuItem.java ---------------------------------------------------------------------- diff --git a/juneau-rest/src/main/java/org/apache/juneau/rest/widget/StyleMenuItem.java b/juneau-rest/src/main/java/org/apache/juneau/rest/widget/StyleMenuItem.java index ce7d52f..1afaee0 100644 --- a/juneau-rest/src/main/java/org/apache/juneau/rest/widget/StyleMenuItem.java +++ b/juneau-rest/src/main/java/org/apache/juneau/rest/widget/StyleMenuItem.java @@ -32,7 +32,14 @@ import org.apache.juneau.utils.*; * StyleMenuItem.<jk>class</jk>, * }, * htmldoc=<ja>@HtmlDoc</ja>( - * links=<js>"{up:'...',options:'...',query:'...',contentTypes:'...',style='$W{styleMenuItem}',source:'...'}"</js> + * links={ + * <js>"up: ..."</js>, + * <js>"options: ..."</js>, + * <js>"$W{queryMenuItem}"</js>, + * <js>"$W{contentTypeMenuItem}"</js>, + * <js>"$W{styleMenuItem}"</js>, + * <js>"source: ..."</js> + * } * ) * ) * <jk>public</jk> Collection<Pet> getPets() { http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/ffda0552/juneau-rest/src/main/java/org/apache/juneau/rest/widget/Widget.java ---------------------------------------------------------------------- diff --git a/juneau-rest/src/main/java/org/apache/juneau/rest/widget/Widget.java b/juneau-rest/src/main/java/org/apache/juneau/rest/widget/Widget.java index 5783c50..0d81e19 100644 --- a/juneau-rest/src/main/java/org/apache/juneau/rest/widget/Widget.java +++ b/juneau-rest/src/main/java/org/apache/juneau/rest/widget/Widget.java @@ -49,8 +49,12 @@ import org.apache.juneau.utils.*; * MyWidget.<jk>class</jk> * } * htmldoc=<ja>@HtmlDoc</ja>( - * links=<js>"{mylink:'$W{myWidget}'}"</js>, - * aside=<js>"Check out this widget: $W{myWidget}"</js> + * links={ + * <js>"$W{myWidget}"</js> + * }, + * aside={ + * <js>"Check out this widget: $W{myWidget}"</js> + * } * ) * ) * </p> http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/ffda0552/juneau-rest/src/main/resources/org/apache/juneau/rest/styles/devops.css ---------------------------------------------------------------------- diff --git a/juneau-rest/src/main/resources/org/apache/juneau/rest/styles/devops.css b/juneau-rest/src/main/resources/org/apache/juneau/rest/styles/devops.css index 26b82fa..ee9a94a 100644 --- a/juneau-rest/src/main/resources/org/apache/juneau/rest/styles/devops.css +++ b/juneau-rest/src/main/resources/org/apache/juneau/rest/styles/devops.css @@ -83,7 +83,7 @@ nav li { } nav li:not(:first-child):before { - content: " - "; + content: " - "; } nav a { @@ -166,10 +166,10 @@ article a:hover { article iframe { background-color: #F6F7F9; - border: 1px solid gray; - padding: 0px; - overflow: hidden; - width: 100%; + border: 1px solid gray; + padding: 0px; + overflow: hidden; + width: 100%; min-height: 400px; } http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/ffda0552/juneau-rest/src/main/resources/org/apache/juneau/rest/styles/light.css ---------------------------------------------------------------------- diff --git a/juneau-rest/src/main/resources/org/apache/juneau/rest/styles/light.css b/juneau-rest/src/main/resources/org/apache/juneau/rest/styles/light.css index 6c443bb..0a43064 100644 --- a/juneau-rest/src/main/resources/org/apache/juneau/rest/styles/light.css +++ b/juneau-rest/src/main/resources/org/apache/juneau/rest/styles/light.css @@ -68,15 +68,15 @@ header h2 { /**********************************************************************************************************************/ nav { - margin: 10px; - padding: 5px; - box-shadow: 5px 5px 2px #999999; - background-color: #eef3f7; + margin: 10px; + padding: 5px; + box-shadow: 5px 5px 2px #999999; + background-color: #eef3f7; } nav * { - font-size: 12px; - font-weight: lighter; + font-size: 12px; + font-weight: lighter; } nav ol { @@ -90,7 +90,7 @@ nav li { } nav li:not(:first-child):before { - content: " - "; + content: " - "; } nav a { @@ -157,10 +157,10 @@ article a { article iframe { background-color: #F6F7F9; - border: 1px solid gray; - padding: 0px; - overflow: hidden; - width: 100%; + border: 1px solid gray; + padding: 0px; + overflow: hidden; + width: 100%; min-height: 400px; } http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/ffda0552/juneau-rest/src/main/resources/org/apache/juneau/rest/widget/MenuItemWidget.css ---------------------------------------------------------------------- diff --git a/juneau-rest/src/main/resources/org/apache/juneau/rest/widget/MenuItemWidget.css b/juneau-rest/src/main/resources/org/apache/juneau/rest/widget/MenuItemWidget.css index 430df88..5b24e83 100644 --- a/juneau-rest/src/main/resources/org/apache/juneau/rest/widget/MenuItemWidget.css +++ b/juneau-rest/src/main/resources/org/apache/juneau/rest/widget/MenuItemWidget.css @@ -14,4 +14,4 @@ .menu-item { position: relative; display: inline-block; -} +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/ffda0552/juneau-rest/src/main/resources/org/apache/juneau/rest/widget/MenuItemWidget.js ---------------------------------------------------------------------- diff --git a/juneau-rest/src/main/resources/org/apache/juneau/rest/widget/MenuItemWidget.js b/juneau-rest/src/main/resources/org/apache/juneau/rest/widget/MenuItemWidget.js index 9d322c6..afc9000 100644 --- a/juneau-rest/src/main/resources/org/apache/juneau/rest/widget/MenuItemWidget.js +++ b/juneau-rest/src/main/resources/org/apache/juneau/rest/widget/MenuItemWidget.js @@ -29,5 +29,4 @@ window.onclick = function(event) { if (popupItem != null && popupItem != event.target && ! popupItem.nextElementSibling.contains(event.target)) { closePopup(); } -}; - +}; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/ffda0552/juneau-rest/src/main/resources/org/apache/juneau/rest/widget/QueryMenuItem.css ---------------------------------------------------------------------- diff --git a/juneau-rest/src/main/resources/org/apache/juneau/rest/widget/QueryMenuItem.css b/juneau-rest/src/main/resources/org/apache/juneau/rest/widget/QueryMenuItem.css index 8db9049..a1903e6 100644 --- a/juneau-rest/src/main/resources/org/apache/juneau/rest/widget/QueryMenuItem.css +++ b/juneau-rest/src/main/resources/org/apache/juneau/rest/widget/QueryMenuItem.css @@ -12,34 +12,34 @@ * ***************************************************************************************************************************/ .tooltip { - position: relative; - display: inline-block; + position: relative; + display: inline-block; } .tooltip .tooltiptext { - visibility: hidden; - background-color: #FEF9E7; - color: black; - padding: 5px; - border-radius: 6px; - position: absolute; - z-index: 1; - top: 0; - left: 0; - margin-left: 30px; + visibility: hidden; + background-color: #FEF9E7; + color: black; + padding: 5px; + border-radius: 6px; + position: absolute; + z-index: 1; + top: 0; + left: 0; + margin-left: 30px; box-shadow: 2px 3px 3px 0px rgba(0, 0, 0, 0.5); - opacity: 0; - transition: opacity 0.5s; - font-weight: normal; + opacity: 0; + transition: opacity 0.5s; + font-weight: normal; } .tooltip:hover .tooltiptext { - visibility: visible; - opacity: 1; + visibility: visible; + opacity: 1; } .tooltiptext { white-space: nowrap; float: left; border: 1px solid black; -} +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/ffda0552/juneau-rest/src/main/resources/org/apache/juneau/rest/widget/QueryMenuItem.html ---------------------------------------------------------------------- diff --git a/juneau-rest/src/main/resources/org/apache/juneau/rest/widget/QueryMenuItem.html b/juneau-rest/src/main/resources/org/apache/juneau/rest/widget/QueryMenuItem.html index f378edb..6d5bcdb 100644 --- a/juneau-rest/src/main/resources/org/apache/juneau/rest/widget/QueryMenuItem.html +++ b/juneau-rest/src/main/resources/org/apache/juneau/rest/widget/QueryMenuItem.html @@ -123,5 +123,4 @@ </table> </form> </div> -</div> - +</div> \ No newline at end of file
