http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/f4812b7c/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerBuilder.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerBuilder.java b/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerBuilder.java index 3716d23..0d3a773 100644 --- a/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerBuilder.java +++ b/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerBuilder.java @@ -902,8 +902,8 @@ public class SerializerBuilder extends CoreObjectBuilder { } @Override /* CoreObjectBuilder */ - public SerializerBuilder debug(boolean value) { - super.debug(value); + public SerializerBuilder debug() { + super.debug(); return this; }
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/f4812b7c/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerGroupBuilder.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerGroupBuilder.java b/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerGroupBuilder.java index 74f923a..65c188d 100644 --- a/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerGroupBuilder.java +++ b/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerGroupBuilder.java @@ -1017,14 +1017,13 @@ public class SerializerGroupBuilder { } /** - * Sets the {@link BeanContext#BEAN_debug} property on all serializers in this group. + * Sets the {@link BeanContext#BEAN_debug} property to <jk>true</jk> on all serializers in this group. * - * @param value The new value for this property. * @return This object (for method chaining). * @see BeanContext#BEAN_debug */ - public SerializerGroupBuilder debug(boolean value) { - return property(BEAN_debug, value); + public SerializerGroupBuilder debug() { + return property(BEAN_debug, true); } /** http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/f4812b7c/juneau-core/src/main/java/org/apache/juneau/soap/SoapXmlSerializer.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/soap/SoapXmlSerializer.java b/juneau-core/src/main/java/org/apache/juneau/soap/SoapXmlSerializer.java index 81580f2..580a799 100644 --- a/juneau-core/src/main/java/org/apache/juneau/soap/SoapXmlSerializer.java +++ b/juneau-core/src/main/java/org/apache/juneau/soap/SoapXmlSerializer.java @@ -68,14 +68,14 @@ public final class SoapXmlSerializer extends XmlSerializer { .attr("xmlns", "soap", s.getProperty(SOAPXML_SOAPAction, "http://www.w3.org/2003/05/soap-envelope")) .appendln(">"); w.sTag(1, "soap", "Body").nl(); - super.serialize(s, o); + super.doSerialize(s, o); w.eTag(1, "soap", "Body").nl(); w.eTag("soap", "Envelope").nl(); } @Override /* Serializer */ public ObjectMap getResponseHeaders(ObjectMap properties) { - return super.getResponseHeaders(properties) + return new ObjectMap(super.getResponseHeaders(properties)) .append("SOAPAction", properties.getString(SOAPXML_SOAPAction, "http://www.w3.org/2003/05/soap-envelope")); } } http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/f4812b7c/juneau-core/src/main/java/org/apache/juneau/soap/SoapXmlSerializerBuilder.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/soap/SoapXmlSerializerBuilder.java b/juneau-core/src/main/java/org/apache/juneau/soap/SoapXmlSerializerBuilder.java index ad67be4..c95c349 100644 --- a/juneau-core/src/main/java/org/apache/juneau/soap/SoapXmlSerializerBuilder.java +++ b/juneau-core/src/main/java/org/apache/juneau/soap/SoapXmlSerializerBuilder.java @@ -555,8 +555,8 @@ public class SoapXmlSerializerBuilder extends XmlSerializerBuilder { } @Override /* CoreObjectBuilder */ - public SoapXmlSerializerBuilder debug(boolean value) { - super.debug(value); + public SoapXmlSerializerBuilder debug() { + super.debug(); return this; } http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/f4812b7c/juneau-core/src/main/java/org/apache/juneau/uon/UonParserBuilder.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/uon/UonParserBuilder.java b/juneau-core/src/main/java/org/apache/juneau/uon/UonParserBuilder.java index 4d1f576..e4eccd1 100644 --- a/juneau-core/src/main/java/org/apache/juneau/uon/UonParserBuilder.java +++ b/juneau-core/src/main/java/org/apache/juneau/uon/UonParserBuilder.java @@ -447,8 +447,8 @@ public class UonParserBuilder extends ParserBuilder { } @Override /* CoreObjectBuilder */ - public UonParserBuilder debug(boolean value) { - super.debug(value); + public UonParserBuilder debug() { + super.debug(); return this; } http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/f4812b7c/juneau-core/src/main/java/org/apache/juneau/uon/UonSerializerBuilder.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/uon/UonSerializerBuilder.java b/juneau-core/src/main/java/org/apache/juneau/uon/UonSerializerBuilder.java index b64350e..d031a9b 100644 --- a/juneau-core/src/main/java/org/apache/juneau/uon/UonSerializerBuilder.java +++ b/juneau-core/src/main/java/org/apache/juneau/uon/UonSerializerBuilder.java @@ -535,8 +535,8 @@ public class UonSerializerBuilder extends SerializerBuilder { } @Override /* CoreObjectBuilder */ - public UonSerializerBuilder debug(boolean value) { - super.debug(value); + public UonSerializerBuilder debug() { + super.debug(); return this; } http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/f4812b7c/juneau-core/src/main/java/org/apache/juneau/uon/package.html ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/uon/package.html b/juneau-core/src/main/java/org/apache/juneau/uon/package.html index 440f5b2..0050e8a 100644 --- a/juneau-core/src/main/java/org/apache/juneau/uon/package.html +++ b/juneau-core/src/main/java/org/apache/juneau/uon/package.html @@ -988,7 +988,9 @@ messages=<js>"nls/AddressBookResource"</js>, title=<js>"$L{title}"</js>, description=<js>"$L{description}"</js>, - pageLinks=<js>"{options:'?method=OPTIONS',doc:'doc'}"</js>, + htmldoc=<ja>@HtmlDoc</ja>( + links=<js>"{options:'?method=OPTIONS'}"</js> + ), properties={ <ja>@Property</ja>(name=SerializerContext.<jsf>SERIALIZER_useWhitespace</jsf>, value=<js>"true"</js>) }, http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/f4812b7c/juneau-core/src/main/java/org/apache/juneau/urlencoding/UrlEncodingParserBuilder.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/urlencoding/UrlEncodingParserBuilder.java b/juneau-core/src/main/java/org/apache/juneau/urlencoding/UrlEncodingParserBuilder.java index 56b8448..731ea51 100644 --- a/juneau-core/src/main/java/org/apache/juneau/urlencoding/UrlEncodingParserBuilder.java +++ b/juneau-core/src/main/java/org/apache/juneau/urlencoding/UrlEncodingParserBuilder.java @@ -466,8 +466,8 @@ public class UrlEncodingParserBuilder extends UonParserBuilder { } @Override /* CoreObjectBuilder */ - public UrlEncodingParserBuilder debug(boolean value) { - super.debug(value); + public UrlEncodingParserBuilder debug() { + super.debug(); return this; } http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/f4812b7c/juneau-core/src/main/java/org/apache/juneau/urlencoding/UrlEncodingSerializerBuilder.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/urlencoding/UrlEncodingSerializerBuilder.java b/juneau-core/src/main/java/org/apache/juneau/urlencoding/UrlEncodingSerializerBuilder.java index 5fee28f..4c307b5 100644 --- a/juneau-core/src/main/java/org/apache/juneau/urlencoding/UrlEncodingSerializerBuilder.java +++ b/juneau-core/src/main/java/org/apache/juneau/urlencoding/UrlEncodingSerializerBuilder.java @@ -598,8 +598,8 @@ public class UrlEncodingSerializerBuilder extends UonSerializerBuilder { } @Override /* CoreObjectBuilder */ - public UrlEncodingSerializerBuilder debug(boolean value) { - super.debug(value); + public UrlEncodingSerializerBuilder debug() { + super.debug(); return this; } http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/f4812b7c/juneau-core/src/main/java/org/apache/juneau/urlencoding/package.html ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/urlencoding/package.html b/juneau-core/src/main/java/org/apache/juneau/urlencoding/package.html index 88349fc..445bcc6 100644 --- a/juneau-core/src/main/java/org/apache/juneau/urlencoding/package.html +++ b/juneau-core/src/main/java/org/apache/juneau/urlencoding/package.html @@ -988,7 +988,9 @@ messages=<js>"nls/AddressBookResource"</js>, title=<js>"$L{title}"</js>, description=<js>"$L{description}"</js>, - pageLinks=<js>"{options:'?method=OPTIONS',doc:'doc'}"</js>, + htmldoc=<ja>@HtmlDoc</ja>( + links=<js>"{options:'?method=OPTIONS'}"</js> + ), properties={ <ja>@Property</ja>(name=SerializerContext.<jsf>SERIALIZER_useWhitespace</jsf>, value=<js>"true"</js>) }, http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/f4812b7c/juneau-core/src/main/java/org/apache/juneau/xml/XmlParserBuilder.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/xml/XmlParserBuilder.java b/juneau-core/src/main/java/org/apache/juneau/xml/XmlParserBuilder.java index fcde50e..eaf97f8 100644 --- a/juneau-core/src/main/java/org/apache/juneau/xml/XmlParserBuilder.java +++ b/juneau-core/src/main/java/org/apache/juneau/xml/XmlParserBuilder.java @@ -568,8 +568,8 @@ public class XmlParserBuilder extends ParserBuilder { } @Override /* CoreObjectBuilder */ - public XmlParserBuilder debug(boolean value) { - super.debug(value); + public XmlParserBuilder debug() { + super.debug(); return this; } http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/f4812b7c/juneau-core/src/main/java/org/apache/juneau/xml/XmlSchemaSerializerBuilder.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/xml/XmlSchemaSerializerBuilder.java b/juneau-core/src/main/java/org/apache/juneau/xml/XmlSchemaSerializerBuilder.java index 37e7061..7fba517 100644 --- a/juneau-core/src/main/java/org/apache/juneau/xml/XmlSchemaSerializerBuilder.java +++ b/juneau-core/src/main/java/org/apache/juneau/xml/XmlSchemaSerializerBuilder.java @@ -535,8 +535,8 @@ public class XmlSchemaSerializerBuilder extends XmlSerializerBuilder { } @Override /* CoreObjectBuilder */ - public XmlSchemaSerializerBuilder debug(boolean value) { - super.debug(value); + public XmlSchemaSerializerBuilder debug() { + super.debug(); return this; } http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/f4812b7c/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializerBuilder.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializerBuilder.java b/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializerBuilder.java index 339904b..a4db76c 100644 --- a/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializerBuilder.java +++ b/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializerBuilder.java @@ -681,8 +681,8 @@ public class XmlSerializerBuilder extends SerializerBuilder { } @Override /* CoreObjectBuilder */ - public XmlSerializerBuilder debug(boolean value) { - super.debug(value); + public XmlSerializerBuilder debug() { + super.debug(); return this; } http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/f4812b7c/juneau-core/src/main/java/org/apache/juneau/xml/package.html ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/xml/package.html b/juneau-core/src/main/java/org/apache/juneau/xml/package.html index 4b293da..672ca2f 100644 --- a/juneau-core/src/main/java/org/apache/juneau/xml/package.html +++ b/juneau-core/src/main/java/org/apache/juneau/xml/package.html @@ -2922,7 +2922,9 @@ messages=<js>"nls/AddressBookResource"</js>, title=<js>"$L{title}"</js>, description=<js>"$L{description}"</js>, - pageLinks=<js>"{options:'?method=OPTIONS',doc:'doc'}"</js>, + htmldoc=<ja>@HtmlDoc</ja>( + links=<js>"{options:'?method=OPTIONS'}"</js> + ), properties={ <ja>@Property</ja>(name=SerializerContext.<jsf>SERIALIZER_quoteChar</jsf>, value=<js>"'"</js>), <ja>@Property</ja>(name=HtmlSerializerContext.<jsf>HTML_uriAnchorText</jsf>, value=<jsf>TO_STRING</jsf>) http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/f4812b7c/juneau-core/src/main/javadoc/doc-files/NewExamplesPage.png ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/javadoc/doc-files/NewExamplesPage.png b/juneau-core/src/main/javadoc/doc-files/NewExamplesPage.png new file mode 100644 index 0000000..265e727 Binary files /dev/null and b/juneau-core/src/main/javadoc/doc-files/NewExamplesPage.png differ http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/f4812b7c/juneau-core/src/main/javadoc/overview.html ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/javadoc/overview.html b/juneau-core/src/main/javadoc/overview.html index 9488d20..bc56b1e 100644 --- a/juneau-core/src/main/javadoc/overview.html +++ b/juneau-core/src/main/javadoc/overview.html @@ -2196,7 +2196,9 @@ <jc>// Links on the HTML rendition page. // "request:/..." URIs are relative to the request URI. // "servlet:/..." URIs are relative to the servlet URI.</jc> - pageLinks=<js>"{up:'request:/..',options:'servlet:/?method=OPTIONS'}"</js>, + htmldoc=<ja>@HtmlDoc</ja>( + links=<js>"{up:'request:/..',options:'servlet:/?method=OPTIONS'}"</js> + ), <jc>// Properties that get applied to all serializers and parsers.</jc> properties={ @@ -2211,12 +2213,14 @@ encoders=GzipEncoder.<jk>class</jk>, <jc>// Swagger info.</jc> - contact=<js>"{name:'John Smith',email:'[email protected]'}"</js>, - license=<js>"{name:'Apache 2.0',url:'http://www.apache.org/licenses/LICENSE-2.0.html'}"</js>, - version=<js>"2.0"</js>, - termsOfService=<js>"You're on your own."</js>, - tags=<js>"[{name:'Java',description:'Java utility',externalDocs:{description:'Home page',url:'http://juneau.apache.org'}}]"</js>, - externalDocs=<js>"{description:'Home page',url:'http://juneau.apache.org'}"</js> + swagger=<ja>@ResourceSwagger</ja>( + contact=<js>"{name:'John Smith',email:'[email protected]'}"</js>, + license=<js>"{name:'Apache 2.0',url:'http://www.apache.org/licenses/LICENSE-2.0.html'}"</js>, + version=<js>"2.0"</js>, + termsOfService=<js>"You're on your own."</js>, + tags=<js>"[{name:'Java',description:'Java utility',externalDocs:{description:'Home page',url:'http://juneau.apache.org'}}]"</js>, + externalDocs=<js>"{description:'Home page',url:'http://juneau.apache.org'}"</js> + ) ) <jk>public class</jk> SystemPropertiesResource <jk>extends</jk> RestServletDefault { @@ -3000,7 +3004,9 @@ <ja>@RestResource</ja>( path=<js>"/"</js>, messages=<js>"nls/RootResources"</js>, - pageLinks=<js>"{options:'?method=OPTIONS'}"</js>, + htmldoc=<ja>@HtmlDoc</ja>( + links=<js>"{options:'?method=OPTIONS'}"</js> + ), children={ HelloWorldResource.<jk>class</jk>, MethodExampleResource.<jk>class</jk>, @@ -3093,7 +3099,9 @@ <ja>@RestResource</ja>( messages=<js>"nls/HelloWorldResource"</js>, path=<js>"/helloWorld"</js>, - pageLinks=<js>"{up:'request:/..',options:'servlet:/?method=OPTIONS'}"</js> + htmldoc=<ja>@HtmlDoc</ja>( + links=<js>"{up:'request:/..',options:'servlet:/?method=OPTIONS'}"</js> + ) ) <jk>public class</jk> HelloWorldResource <jk>extends</jk> Resource { <jk>private static final long</jk> <jsf>serialVersionUID</jsf> = 1L; @@ -3168,7 +3176,9 @@ <ja>@RestResource</ja>( path=<js>"/methodExample"</js>, messages=<js>"nls/MethodExampleResource"</js>, - pageLinks=<js>"{up:'request:/..',options:'servlet:/?method=OPTIONS'}"</js> + htmldoc=<ja>@HtmlDoc</ja>( + links=<js>"{up:'request:/..',options:'servlet:/?method=OPTIONS'}"</js> + ) ) <jk>public class</jk> MethodExampleResource <jk>extends</jk> Resource { <jk>private static final long</jk> <jsf>serialVersionUID</jsf> = 1L; @@ -3372,7 +3382,9 @@ </p> <p class='bcode'> <ja>@RestResource</ja>( - pageLinks=<js>"{options:'?method=OPTIONS'}"</js> + htmldoc=<ja>@HtmlDoc</ja>( + links=<js>"{options:'?method=OPTIONS'}"</js> + ) ) </p> <p> @@ -3637,7 +3649,9 @@ <ja>@RestResource</ja>( path=<js>"/echo"</js>, messages=<js>"nls/RequestEchoResource"</js>, - pageLinks=<js>"{up:'request:/..',options:'servlet:/?method=OPTIONS'}"</js>, + htmldoc=<ja>@HtmlDoc</ja>( + links=<js>"{up:'request:/..',options:'servlet:/?method=OPTIONS'}"</js>, + ), properties={ <ja>@Property</ja>(name=<jsf>SERIALIZER_maxDepth</jsf>, value=<js>"10"</js>), <ja>@Property</ja>(name=<jsf>SERIALIZER_detectRecursions</jsf>, value=<js>"true"</js>) @@ -4098,7 +4112,9 @@ // "request:/..." URIs are relative to the request URI. // "servlet:/..." URIs are relative to the servlet URI. // "$C{...}" variables are pulled from the config file.</jc> - pageLinks=<js>"{up:'request:/..', options:'servlet:/?method=OPTIONS', source:'$C{Source/gitHub}/org/apache/juneau/examples/rest/addressbook/AddressBookResource.java'}"</js>, + 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> + ), <jc>// Properties that get applied to all serializers and parsers.</jc> properties={ @@ -4766,7 +4782,9 @@ messages=<js>"nls/SampleRemoteableServlet"</js>, title=<js>"Remoteable Service Proxy API"</js>, description=<js>"Sample class showing how to use remoteable proxies. The list below are exposed services that can be retrieved using RestClient.getProxyInterface(Class)."</js>, - pageLinks=<js>"{up:'request:/..',options:'servlet:/?method=OPTIONS'}"</js>, + htmldoc=<ja>@HtmlDoc</ja>( + links=<js>"{up:'request:/..',options:'servlet:/?method=OPTIONS'}"</js> + ), properties={ <jc>// Allow us to use method=POST from a browser.</jc> <ja>@Property</ja>(name=<jsf>REST_allowMethodParam</jsf>, value=<js>"*"</js>) @@ -4870,7 +4888,9 @@ <ja>@RestResource</ja>( path=<js>"/tempDir"</js>, messages=<js>"nls/TempDirResource"</js>, - pageLinks=<js>"{up:'request:/..', options:'servlet:/?method=OPTIONS', upload:'servlet:/upload'}"</js>, + htmldoc=<ja>@HtmlDoc</ja>( + links=<js>"{up:'request:/..', options:'servlet:/?method=OPTIONS', upload:'servlet:/upload'}"</js> + ), properties={ <ja>@Property</ja>(name=<js>"DirectoryResource.rootDir"</js>, value=<js>"$S{java.io.tmpdir}"</js>), <ja>@Property</ja>(name=<js>"DirectoryResource.allowViews"</js>, value=<js>"true"</js>), @@ -4988,7 +5008,9 @@ <ja>@RestResource</ja>( path=<js>"/atom"</js>, messages=<js>"nls/AtomFeedResource"</js>, - pageLinks=<js>"{up:'request:/..',options:'servlet:/?method=OPTIONS'}"</js>, + htmldoc=<ja>@HtmlDoc</ja>( + links=<js>"{up:'request:/..',options:'servlet:/?method=OPTIONS'}"</js> + ), properties={ <ja>@Property</ja>(name=<jsf>SERIALIZER_quoteChar</jsf>, value=<js>"'"</js>), <ja>@Property</ja>(name=<jsf>RDF_rdfxml_tab</jsf>, value=<js>"5"</js>), @@ -5096,7 +5118,9 @@ <ja>@RestResource</ja>( path=<js>"/docker"</js>, title=<js>"Sample Docker resource"</js>, - pageLinks=<js>"{up:'request:/..',options:'servlet:/?method=OPTIONS'}"</js> + htmldoc=<ja>@HtmlDoc</ja>( + links=<js>"{up:'request:/..',options:'servlet:/?method=OPTIONS'}"</js> + ) ) <jk>public class</jk> DockerRegistryResource <jk>extends</jk> Resource { <jk>private static final long</jk> <jsf>serialVersionUID</jsf> = 1L; @@ -5177,7 +5201,9 @@ messages=<js>"nls/TumblrParserResource"</js>, title=<js>"Tumblr parser service"</js>, description=<js>"Specify a URL to a Tumblr blog and parse the results."</js>, - pageLinks=<js>"{up:'request:/..',options:'servlet:/?method=OPTIONS'}"</js> + htmldoc=<ja>@HtmlDoc</ja>( + links=<js>"{up:'request:/..',options:'servlet:/?method=OPTIONS'}"</js> + ) ) <jk>public class</jk> TumblrParserResource <jk>extends</jk> Resource { <jk>private static final long</jk> <jsf>serialVersionUID</jsf> = 1L; @@ -5259,7 +5285,9 @@ messages=<js>"nls/PhotosResource"</js>, title=<js>"Photo REST service"</js>, description=<js>"Use a tool like Poster to upload and retrieve jpeg and png images."</js>, - pageLinks=<js>"{options:'?method=OPTIONS'}"</js> + htmldoc=<ja>@HtmlDoc</ja>( + links=<js>"{options:'?method=OPTIONS'}"</js> + ) ) <jk>public class</jk> PhotosResource <jk>extends</jk> RestServletDefault { @@ -5398,7 +5426,9 @@ path=<js>"/jsonSchema"</js>, messages=<js>"nls/JsonSchemaResource"</js>, title=<js>"Sample JSON-Schema document"</js>, - pageLinks=<js>"{up:'request:/..',options:'servlet:/?method=OPTIONS'}"</js> + htmldoc=<ja>@HtmlDoc</ja>( + links=<js>"{up:'request:/..',options:'servlet:/?method=OPTIONS'}"</js> + ) ) <jk>public class</jk> JsonSchemaResource <jk>extends</jk> ResourceJena { <jk>private static final long</jk> <jsf>serialVersionUID</jsf> = 1L; @@ -5479,7 +5509,9 @@ messages=<js>"nls/SqlQueryResource"</js>, title=<js>"SQL query service"</js>, description=<js>"Executes queries against the local derby '$C{SqlQueryResource/connectionUrl}' database"</js>, - pageLinks=<js>"{up:'request:/..',options:'servlet:/?method=OPTIONS'}"</js> + htmldoc=<ja>@HtmlDoc</ja>( + links=<js>"{up:'request:/..',options:'servlet:/?method=OPTIONS'}"</js> + ) ) <jk>public class</jk> SqlQueryResource <jk>extends</jk> Resource { <jk>private static final long</jk> <jsf>serialVersionUID</jsf> = 1L; @@ -5666,7 +5698,9 @@ path=<js>"/config"</js>, title=<js>"Configuration"</js>, description=<js>"Contents of configuration file."</js>, - pageLinks=<js>"{up:'request:/..', options:'servlet:/?method=OPTIONS', edit:'servlet:/edit'}"</js> + htmldoc=<ja>@HtmlDoc</ja>( + links=<js>"{up:'request:/..', options:'servlet:/?method=OPTIONS', edit:'servlet:/edit'}"</js> + ) ) <jk>public class</jk> ConfigResource <jk>extends</jk> Resource { <jk>private static final long</jk> <jsf>serialVersionUID</jsf> = 1L; @@ -6166,9 +6200,6 @@ <li>{@link org.apache.juneau.ini.ConfigFile#getObjectWithDefault(String,Object,Class) getObjectWithDefault(String,Object,Class)} </ul> <li>New ability to interact with config file sections with proxy interfaces with new method {@link org.apache.juneau.ini.ConfigFile#getSectionAsInterface(String,Class)}. - <li>New {@link org.apache.juneau.html.annotation.Html#render() @Html.render()} annotation and {@link org.apache.juneau.html.HtmlRender} class that allows you - to customize the HTML output and CSS style on bean properties:<br> - <img class='bordered' src='doc-files/HtmlRender_1.png'> <li>{@link org.apache.juneau.annotation.BeanProperty @BeanProperty} annotation can now be applied to getters and setters defined on interfaces. <li>New methods on {@link org.apache.juneau.serializer.SerializerSession} and {@link org.apache.juneau.parser.ParserSession} @@ -6203,11 +6234,11 @@ </ul> For example, currently we define HTML page links using variables and servlet-relative URIs... <p class='bcode'> - pageLinks=<js>"{up:'$R{requestParentURI}', options:'?method=OPTIONS', upload:'upload'}"</js> + pages=<js>"{up:'$R{requestParentURI}', options:'?method=OPTIONS', upload:'upload'}"</js> </p> With these new protocols, we can define them like so: <p class='bcode'> - pageLinks=<js>"{top:'context:/', up:'request:/..' ,options:'servlet:/?method=OPTIONS', upload:'servlet:/upload'}"</js> + links=<js>"{top:'context:/', up:'request:/..' ,options:'servlet:/?method=OPTIONS', upload:'servlet:/upload'}"</js> </p> The old method of using variables and servlet-relative URIs will still be supported, but using these new protocols should (hopefully) be easier to understand. @@ -6252,10 +6283,35 @@ <li>The {@link org.apache.juneau.BeanContext#BEAN_debug} flag will now capture parser input and make it available through the {@link org.apache.juneau.parser.ParserSession#getInputAsString()} method so that it can be used in the listeners. + <li>Significant new functionality introduced to the HTML serializer. + <br>Lots of new options for customizing the HTML output. + <ul> + <li>New {@link org.apache.juneau.html.annotation.Html#render() @Html.render()} annotation and {@link org.apache.juneau.html.HtmlRender} class that allows you + to customize the HTML output and CSS style on bean properties: + <br><img class='bordered' src='doc-files/HtmlRender_1.png'> + <br>Annotation can be applied to POJO classes and bean properties. + <li>Several new properties for customizing parts of the HTML page: + <ul> + <li>{@link org.apache.juneau.html.HtmlDocSerializerContext#HTMLDOC_title} + <li>{@link org.apache.juneau.html.HtmlDocSerializerContext#HTMLDOC_description} + <li>{@link org.apache.juneau.html.HtmlDocSerializerContext#HTMLDOC_header} + <li>{@link org.apache.juneau.html.HtmlDocSerializerContext#HTMLDOC_nav} + <li>{@link org.apache.juneau.html.HtmlDocSerializerContext#HTMLDOC_aside} + <li>{@link org.apache.juneau.html.HtmlDocSerializerContext#HTMLDOC_footer} + <li>{@link org.apache.juneau.html.HtmlDocSerializerContext#HTMLDOC_noResultsMessage} + <li>{@link org.apache.juneau.html.HtmlDocSerializerContext#HTMLDOC_cssUrl} + <li>{@link org.apache.juneau.html.HtmlDocSerializerContext#HTMLDOC_css} + <li>{@link org.apache.juneau.html.HtmlDocSerializerContext#HTMLDOC_template} + </ul> + <li>New interface {@link org.apache.juneau.html.HtmlDocTemplate} that allows full control over rendering + of HTML produced by {@link org.apache.juneau.html.HtmlDocSerializer}. + + </ul> </ul> <h6 class='topic'>org.apache.juneau.rest</h6> <ul class='spaced-list'> + <li>MAJOR enhancements made to the REST API. <li>The {@link org.apache.juneau.rest.RestRequest} class functionality has been broken up into the following functional pieces to reduce its complexity: <ul> @@ -6374,7 +6430,67 @@ <li>{@link org.apache.juneau.rest.annotation.Header#def @Header.def()} - Default header value. <li>{@link org.apache.juneau.rest.annotation.Query#def @Query.def()} - Default query parameter value. <li>{@link org.apache.juneau.rest.annotation.FormData#def @FormData.def()} - Default form data parameter value. - </ul> + </ul> + <li>New attributes on {@link org.apache.juneau.rest.annotation.RestResource @RestResource}: + <ul> + <li>{@link org.apache.juneau.rest.annotation.RestResource#serializerListener() serializerListener()} + <li>{@link org.apache.juneau.rest.annotation.RestResource#parserListener() parserListener()} + <li>{@link org.apache.juneau.rest.annotation.RestResource#widgets() widgets()} + <li>{@link org.apache.juneau.rest.annotation.RestResource#swagger() swagger()} + <li>{@link org.apache.juneau.rest.annotation.RestResource#htmldoc() htmldoc()} + </ul> + <li>New attributes on {@link org.apache.juneau.rest.annotation.RestMethod @RestMethod}: + <ul> + <li>{@link org.apache.juneau.rest.annotation.RestMethod#widgets() widgets()} + <li>{@link org.apache.juneau.rest.annotation.RestMethod#swagger() swagger()} + <li>{@link org.apache.juneau.rest.annotation.RestMethod#htmldoc() htmldoc()} + </ul> + <li>New string vars: + <ul> + <li>{@link org.apache.juneau.rest.vars.UrlVar} - Resolve <js>"$U{...}"</js> variables to URLs. + <li>{@link org.apache.juneau.rest.vars.WidgetVar} - Resolve <js>"$W{...}"</js> variables to widget contents. + </ul> + <li>New methods on {@link org.apache.juneau.rest.RestConfig}: + <ul> + <li>{@link org.apache.juneau.rest.RestConfig#setHtmlTitle(String) setHtmlTitle(String)} + <li>{@link org.apache.juneau.rest.RestConfig#setHtmlDescription(String) setHtmlDescription(String)} + <li>{@link org.apache.juneau.rest.RestConfig#setHtmlHeader(String) setHtmlHeader(String)} + <li>{@link org.apache.juneau.rest.RestConfig#setHtmlLinks(String) setHtmlLinks(String)} + <li>{@link org.apache.juneau.rest.RestConfig#setHtmlNav(String) setHtmlNav(String)} + <li>{@link org.apache.juneau.rest.RestConfig#setHtmlAside(String) setHtmlAside(String)} + <li>{@link org.apache.juneau.rest.RestConfig#setHtmlFooter(String) setHtmlFooter(String)} + <li>{@link org.apache.juneau.rest.RestConfig#setHtmlCss(String) setHtmlCss(String)} + <li>{@link org.apache.juneau.rest.RestConfig#setHtmlCssUrl(String) setHtmlCssUrl(String)} + <li>{@link org.apache.juneau.rest.RestConfig#setHtmlNoWrap(boolean) setHtmlNoWrap(boolean)} + <li>{@link org.apache.juneau.rest.RestConfig#setHtmlNoResultsMessage(String) setHtmlNoResultsMessage(String)} + <li>{@link org.apache.juneau.rest.RestConfig#setHtmlTemplate(Class) setHtmlTemplate(Class)} + <li>{@link org.apache.juneau.rest.RestConfig#setHtmlTemplate(HtmlDocTemplate) setHtmlTemplate(HtmlDocTemplate)} + <li>{@link org.apache.juneau.rest.RestConfig#addWidget(Class) addWidget(Class)} + </ul> + <li>New methods on {@link org.apache.juneau.rest.RestResponse}: + <ul> + <li>{@link org.apache.juneau.rest.RestResponse#setHtmlTitle(Object) setHtmlTitle(Object)} + <li>{@link org.apache.juneau.rest.RestResponse#setHtmlDescription(Object) setHtmlDescription(Object)} + <li>{@link org.apache.juneau.rest.RestResponse#setHtmlHeader(Object) setHtmlHeader(Object)} + <li>{@link org.apache.juneau.rest.RestResponse#setHtmlLinks(Object) setHtmlLinks(Object)} + <li>{@link org.apache.juneau.rest.RestResponse#setHtmlNav(Object) setHtmlNav(Object)} + <li>{@link org.apache.juneau.rest.RestResponse#setHtmlAside(Object) setHtmlAside(Object)} + <li>{@link org.apache.juneau.rest.RestResponse#setHtmlFooter(Object) setHtmlFooter(Object)} + <li>{@link org.apache.juneau.rest.RestResponse#setHtmlCss(Object) setHtmlCss(Object)} + <li>{@link org.apache.juneau.rest.RestResponse#setHtmlCssUrl(Object) setHtmlCssUrl(Object)} + <li>{@link org.apache.juneau.rest.RestResponse#setHtmlNoWrap(boolean) setHtmlNoWrap(boolean)} + <li>{@link org.apache.juneau.rest.RestResponse#setHtmlNoResultsMessage(Object) setHtmlNoResultsMessage(Object)} + <li>{@link org.apache.juneau.rest.RestResponse#setHtmlTemplate(Class) setHtmlTemplate(Class)} + <li>{@link org.apache.juneau.rest.RestResponse#setHtmlTemplate(HtmlDocTemplate) setHtmlTemplate(HtmlDocTemplate)} + </ul> + <li><code>&plainText=true</code> parameter now works on byte-based serializers by converting the output to hex. + <li>New classes for widget support: + <ul> + <li>{@link org.apache.juneau.rest.widget.Widget} + <li>{@link org.apache.juneau.rest.widget.PoweredByJuneauWidget} + <li>{@link org.apache.juneau.rest.widget.ContentTypeLinksWidget} + </ul> + <li><code>devops.css</code> cleaned up. </ul> <h6 class='topic'>org.apache.juneau.rest.client</h6> @@ -6392,6 +6508,13 @@ <h6 class='topic'>org.apache.juneau.microservice</h6> <ul class='spaced-list'> </ul> + + <h6 class='topic'>org.apache.juneau.examples.rest</h6> + <ul class='spaced-list'> + <li>Many code enhancements make to examples to reflect new functionality. + <li>All pages now render aside comments to help explain what feature they're trying to explain. + <br><img class='bordered' src='doc-files/NewExamplesPage.png'> + </ul> </div> <!-- ======================================================================================================== --> @@ -6538,12 +6661,12 @@ <li>New annotations added to {@link org.apache.juneau.rest.annotation.RestResource @RestResource} and {@link org.apache.juneau.rest.annotation.RestMethod @RestMethod} to simplify defining page title, text, and links on HTML views: <ul> - <li>{@link org.apache.juneau.rest.annotation.RestResource#pageTitle() @RestResource.pageTitle()} - <li>{@link org.apache.juneau.rest.annotation.RestMethod#pageTitle() @RestMethod.pageTitle()} - <li>{@link org.apache.juneau.rest.annotation.RestResource#pageText() @RestResource.pageText()} - <li>{@link org.apache.juneau.rest.annotation.RestMethod#pageText() @RestMethod.pageText()} - <li>{@link org.apache.juneau.rest.annotation.RestResource#pageLinks() @RestResource.pageLinks()} - <li>{@link org.apache.juneau.rest.annotation.RestMethod#pageLinks() @RestMethod.pageLinks()} + <li><code><del>@RestResource.pageTitle()</del></code> + <li><code><del>@RestMethod.pageTitle()</del></code> + <li><code><del>@RestResource.pageText()</del></code> + <li><code><del>@RestMethod.pageText()</del></code> + <li><code><del>@RestResource.pageLinks()</del></code> + <li><code><del>@RestMethod.pageLinks()</del></code> </ul> <p class='bcode'> <jc>// Old method</jc> @@ -6650,7 +6773,7 @@ <li>{@link org.apache.juneau.rest.client.RestClientBuilder#noTrace() noTrace()} - Adds a <code>No-Trace: true</code> header on all requests to prevent the servlet from logging errors. <br>Useful for testing scenarios when you don't want the console to end up showing errors done on purpose. - <li>{@link org.apache.juneau.rest.client.RestClientBuilder#debug(boolean) debug(boolean)} now adds a <code>Debug: true</code> header on all requests. + <li>{@link org.apache.juneau.rest.client.RestClientBuilder#debug() debug()} now adds a <code>Debug: true</code> header on all requests. </ul> <li>New methods added/updated to {@link org.apache.juneau.rest.client.RestCall}: <ul> @@ -7065,19 +7188,19 @@ <ul> <li>{@link org.apache.juneau.rest.annotation.RestResource#title() @RestResource.title()} / {@link org.apache.juneau.rest.RestInfoProvider#getTitle(RestRequest)} <li>{@link org.apache.juneau.rest.annotation.RestResource#description() @RestResource.description()} / {@link org.apache.juneau.rest.RestInfoProvider#getDescription(RestRequest)} - <li>{@link org.apache.juneau.rest.annotation.RestResource#termsOfService() @RestResource.termsOfService()} / {@link org.apache.juneau.rest.RestInfoProvider#getTermsOfService(RestRequest)} - <li>{@link org.apache.juneau.rest.annotation.RestResource#contact() @RestResource.contact()} / {@link org.apache.juneau.rest.RestInfoProvider#getContact(RestRequest)} - <li>{@link org.apache.juneau.rest.annotation.RestResource#license() @RestResource.license()} / {@link org.apache.juneau.rest.RestInfoProvider#getLicense(RestRequest)} - <li>{@link org.apache.juneau.rest.annotation.RestResource#version() @RestResource.version()} / {@link org.apache.juneau.rest.RestInfoProvider#getVersion(RestRequest)} - <li>{@link org.apache.juneau.rest.annotation.RestResource#tags() @RestResource.tags()} / {@link org.apache.juneau.rest.RestInfoProvider#getTags(RestRequest)} - <li>{@link org.apache.juneau.rest.annotation.RestResource#externalDocs() @RestResource.externalDocs()} / {@link org.apache.juneau.rest.RestInfoProvider#getExternalDocs(RestRequest)} + <li><code><del>@RestResource.termsOfService()</del></code> / {@link org.apache.juneau.rest.RestInfoProvider#getTermsOfService(RestRequest)} + <li><code><del>@RestResource.contact()</del></code> / {@link org.apache.juneau.rest.RestInfoProvider#getContact(RestRequest)} + <li><code><del>@RestResource.license()</del></code> / {@link org.apache.juneau.rest.RestInfoProvider#getLicense(RestRequest)} + <li><code><del>@RestResource.version()</del></code> / {@link org.apache.juneau.rest.RestInfoProvider#getVersion(RestRequest)} + <li><code><del>@RestResource.tags()</del></code> / {@link org.apache.juneau.rest.RestInfoProvider#getTags(RestRequest)} + <li><code><del>@RestResource.externalDocs()</del></code> / {@link org.apache.juneau.rest.RestInfoProvider#getExternalDocs(RestRequest)} <li>{@link org.apache.juneau.rest.annotation.RestMethod#summary() @RestMethod.summary()} / {@link org.apache.juneau.rest.RestInfoProvider#getMethodSummary(String,RestRequest)} <li>{@link org.apache.juneau.rest.annotation.RestMethod#description() @RestMethod.description()} / {@link org.apache.juneau.rest.RestInfoProvider#getMethodDescription(String,RestRequest)} - <li>{@link org.apache.juneau.rest.annotation.RestMethod#externalDocs() @RestMethod.externalDocs()} - <li>{@link org.apache.juneau.rest.annotation.RestMethod#tags() @RestMethod.tags()} - <li>{@link org.apache.juneau.rest.annotation.RestMethod#deprecated() @RestMethod.deprecated()} - <li>{@link org.apache.juneau.rest.annotation.RestMethod#parameters() @RestMethod.parameters()} - <li>{@link org.apache.juneau.rest.annotation.RestMethod#responses() @RestMethod.responses()} + <li><code><del>@RestMethod.externalDocs()</del></code> + <li><code><del>@RestMethod.tags()</del></code> + <li><code><del>@RestMethod.deprecated()</del></code> + <li><code><del>@RestMethod.parameters()</del></code> + <li><code><del>@RestMethod.responses()</del></code> </ul> </li> </ul> @@ -7747,7 +7870,7 @@ <ul class='spaced-list'> <li>Fixed bug where localized strings weren't resolving when using chained resource bundles. <li>Servlet and method labels and descriptions can now contain embedded string variables. - <li>New <del><code>RestMethod.input()</code></del> and org.apache.juneau.rest.annotation.RestMethod#responses()} + <li>New <del><code>RestMethod.input()</code></del> and <code><del>RestMethod.responses()</del></code> annotations. These replace the various <code>description</code> annotations added 2 days ago with a simpler design. <li>New methods on {@link org.apache.juneau.rest.RestServlet}: @@ -7861,7 +7984,7 @@ <li><del><code>RestResource.label()</code></del> <li>{@link org.apache.juneau.rest.annotation.RestResource#description()} <li>{@link org.apache.juneau.rest.annotation.RestMethod#description()} - <li>{@link org.apache.juneau.rest.annotation.RestMethod#responses()} + <li><del><code>RestMethod#responses()</code></del> <li><del><code>Attr.description()</code></del> <li><del><code>Content.description()</code></del> <li><del><code>HasParam.description()</code></del> @@ -7901,7 +8024,7 @@ </ul> <li>New {@link org.apache.juneau.dto.jsonschema.JsonType#ANY} enum. <li>New {@link org.apache.juneau.html.annotation.Html#asPlainText @Html.asPlainText()} annotation. - <li>New {@link org.apache.juneau.html.HtmlDocSerializerContext#HTMLDOC_cssImports} property. + <li>New <code><del>HtmlDocSerializerContext.HTMLDOC_cssImports</del></code> property. <li>Signifant changes to RDF support. <ul> <li>New {@link org.apache.juneau.jena.annotation.Rdf @Rdf} and {@link org.apache.juneau.jena.annotation.RdfSchema @RdfSchema} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/f4812b7c/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/AtomFeedResource.java ---------------------------------------------------------------------- diff --git a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/AtomFeedResource.java b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/AtomFeedResource.java index 49fc847..fcfe9b9 100644 --- a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/AtomFeedResource.java +++ b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/AtomFeedResource.java @@ -23,6 +23,7 @@ import org.apache.juneau.dto.atom.*; import org.apache.juneau.encoders.*; import org.apache.juneau.microservice.*; import org.apache.juneau.rest.annotation.*; +import org.apache.juneau.rest.widget.*; /** * Sample resource that shows how to generate ATOM feeds. @@ -31,12 +32,23 @@ import org.apache.juneau.rest.annotation.*; path="/atom", title="Sample ATOM feed resource", description="Sample resource that shows how to render ATOM feeds", - pageLinks="{up:'request:/..',options:'servlet:/?method=OPTIONS',source:'$C{Source/gitHub}/org/apache/juneau/examples/rest/AtomFeedResource.java'}", + htmldoc=@HtmlDoc( + links="{up:'request:/..',options:'servlet:/?method=OPTIONS',source:'$C{Source/gitHub}/org/apache/juneau/examples/rest/AtomFeedResource.java'}", + aside="" + + "<div style='min-width:200px' class='text'>" + + " <p>Shows how to produce ATOM feeds in a variety of languages.</p>" + + " <p>$W{contentTypeLinks}</p>" + + "</div>", + css="aside {display:table-caption;}" + ), properties={ @Property(name=SERIALIZER_quoteChar, value="'"), @Property(name=RDF_rdfxml_tab, value="5"), @Property(name=RDF_addRootProperty, value="true") }, + widgets={ + ContentTypeLinksWidget.class + }, encoders=GzipEncoder.class ) public class AtomFeedResource extends ResourceJena { http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/f4812b7c/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/CodeFormatterResource.java ---------------------------------------------------------------------- diff --git a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/CodeFormatterResource.java b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/CodeFormatterResource.java index 10a0b07..ed66794 100644 --- a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/CodeFormatterResource.java +++ b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/CodeFormatterResource.java @@ -12,8 +12,9 @@ // *************************************************************************************************************************** package org.apache.juneau.examples.rest; -import java.io.*; +import static org.apache.juneau.dto.html5.HtmlBuilder.*; +import org.apache.juneau.dto.html5.*; import org.apache.juneau.microservice.*; import org.apache.juneau.rest.*; import org.apache.juneau.rest.annotation.*; @@ -27,15 +28,63 @@ import org.apache.juneau.rest.annotation.*; messages="nls/CodeFormatterResource", title="Code Formatter", description="Utility for generating HTML code-formatted source code", - pageLinks="{options:'?method=OPTIONS',source:'$C{Source/gitHub}/org/apache/juneau/examples/rest/CodeFormatterResource.java'}" + htmldoc=@HtmlDoc( + links="{up:'servlet:/..',options:'servlet:/?method=OPTIONS',source:'$C{Source/gitHub}/org/apache/juneau/examples/rest/CodeFormatterResource.java'}", + aside="" + + "<div style='min-width:200px' class='text'>" + + " <p>Utility for adding code syntax tags to Java and XML/HTML code.</p>" + + " <p>It's by no means perfect, but provides a good starting point.</p>" + + "</div>", + css="aside {display:table-caption;}" + ) ) @SuppressWarnings({"serial"}) public class CodeFormatterResource extends Resource { /** [GET /] - Display query entry page. */ @RestMethod(name="GET", path="/") - public ReaderResource getQueryEntryPage(RestRequest req) throws IOException { - return req.getReaderResource("CodeFormatterResource.html", true); + public Div getQueryEntryPage(RestRequest req) { + return div( + script("text/javascript", + "\n // Quick and dirty function to allow tabs in textarea." + +"\n function checkTab(e) {" + +"\n if (e.keyCode == 9) {" + +"\n var t = e.target;" + +"\n var ss = t.selectionStart, se = t.selectionEnd;" + +"\n t.value = t.value.slice(0,ss).concat('\\t').concat(t.value.slice(ss,t.value.length));" + +"\n e.preventDefault();" + +"\n }" + +"\n }" + +"\n // Load results from IFrame into this document." + +"\n function loadResults(b) {" + +"\n var doc = b.contentDocument || b.contentWindow.document;" + +"\n var data = doc.getElementById('data') || doc.getElementsByTagName('body')[0];" + +"\n document.getElementById('results').innerHTML = data.innerHTML;" + +"\n }" + ), + form("form").action("codeFormatter").method("POST").target("buff").children( + table( + tr( + th("Language: "), + td( + select().name("lang").children( + option("java","Java"), + option("xml", "XML") + ) + ), + td(button("submit", "Submit"), button("reset", "Reset")) + ), + tr( + td().colspan(3).children( + textarea().name("code").style("min-width:800px;min-height:400px;font-family:Courier;font-size:9pt;").onkeydown("checkTab(event)") + ) + ) + ) + ), + br(), + div().id("results")._class("monospace"), + iframe().name("buff").style("display:none").onload("parent.loadResults(this)") + ); } /** [POST /] - Add syntax highlighting to input. */ http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/f4812b7c/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/DirectoryResource.java ---------------------------------------------------------------------- diff --git a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/DirectoryResource.java b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/DirectoryResource.java index 753fcf7..31a845c 100644 --- a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/DirectoryResource.java +++ b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/DirectoryResource.java @@ -35,7 +35,9 @@ import org.apache.juneau.utils.*; */ @RestResource( messages="nls/DirectoryResource", - pageLinks="{up:'request:/..',options:'servlet:/?method=OPTIONS',source:'$C{Source/gitHub}/org/apache/juneau/examples/rest/DirectoryResource.java'}", + htmldoc=@HtmlDoc( + links="{up:'request:/..',options:'servlet:/?method=OPTIONS',source:'$C{Source/gitHub}/org/apache/juneau/examples/rest/DirectoryResource.java'}" + ), properties={ @Property(name=HTML_uriAnchorText, value=PROPERTY_NAME), @Property(name=REST_allowMethodParam, value="*"), http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/f4812b7c/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/DockerRegistryResource.java ---------------------------------------------------------------------- diff --git a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/DockerRegistryResource.java b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/DockerRegistryResource.java index 1b021f0..ae3f18b 100644 --- a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/DockerRegistryResource.java +++ b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/DockerRegistryResource.java @@ -27,7 +27,14 @@ import org.apache.juneau.rest.labels.*; @RestResource( path="/docker", title="Sample Docker resource", - pageLinks="{up:'request:/..',options:'servlet:/?method=OPTIONS',source:'$C{Source/gitHub}/org/apache/juneau/examples/rest/DockerRegistryResource.java'}" + htmldoc=@HtmlDoc( + links="{up:'request:/..',options:'servlet:/?method=OPTIONS',source:'$C{Source/gitHub}/org/apache/juneau/examples/rest/DockerRegistryResource.java'}", + aside="" + + "<div style='min-width:200px' class='text'>" + + " <p>REST API for searching Docker registries.</p>" + + " <p>To use, you must first specify the Docker registry URL in the <code>[Docker]</code> section of the config file.</p>" + + "</div>" + ) ) public class DockerRegistryResource extends Resource { private static final long serialVersionUID = 1L; http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/f4812b7c/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/FileSpaceResource.java ---------------------------------------------------------------------- diff --git a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/FileSpaceResource.java b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/FileSpaceResource.java index 6a32824..8cd48ce 100644 --- a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/FileSpaceResource.java +++ b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/FileSpaceResource.java @@ -32,7 +32,13 @@ import org.apache.juneau.serializer.*; path="/fileSpace", title="Available file space resource", description="Shows how to use HtmlRender class to customize HTML output.", - pageLinks="{up:'request:/..',options:'servlet:/?method=OPTIONS',source:'$C{Source/gitHub}/org/apache/juneau/examples/rest/EnhancedHtmlResource.java'}" + htmldoc=@HtmlDoc( + links="{up:'request:/..',options:'servlet:/?method=OPTIONS',source:'$C{Source/gitHub}/org/apache/juneau/examples/rest/EnhancedHtmlResource.java'}", + aside="" + + "<div style='min-width:200px' class='text'>" + + " <p>Shows how you can use <code>HtmlRender</code> class to customize the output generated by the HTML serializer.</p>" + + "</div>" + ) ) public class FileSpaceResource extends Resource { private static final long serialVersionUID = 1L; http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/f4812b7c/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/HelloWorldResource.java ---------------------------------------------------------------------- diff --git a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/HelloWorldResource.java b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/HelloWorldResource.java index 49e9a06..d062eda 100644 --- a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/HelloWorldResource.java +++ b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/HelloWorldResource.java @@ -20,10 +20,17 @@ import org.apache.juneau.rest.annotation.*; */ @RestResource( messages="nls/HelloWorldResource", - title="Hello World sample resource", - description="Simplest possible resource", + title="Hello World", + description="An example of the simplest-possible resource", path="/helloWorld", - pageLinks="{up:'request:/..',options:'servlet:/?method=OPTIONS',source:'$C{Source/gitHub}/org/apache/juneau/examples/rest/HelloWorldResource.java'}" + htmldoc=@HtmlDoc( + links="{up:'request:/..',options:'servlet:/?method=OPTIONS',source:'$C{Source/gitHub}/org/apache/juneau/examples/rest/HelloWorldResource.java'}", + aside="" + + "<div style='max-width:400px' class='text'>" + + " <p>This page shows a resource that simply response with a 'Hello world!' message</p>" + + " <p>The POJO serialized is a simple String.</p>" + + "</div>" + ) ) public class HelloWorldResource extends Resource { private static final long serialVersionUID = 1L; http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/f4812b7c/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/JsonSchemaResource.java ---------------------------------------------------------------------- diff --git a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/JsonSchemaResource.java b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/JsonSchemaResource.java index 9e71264..6b1fffb 100644 --- a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/JsonSchemaResource.java +++ b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/JsonSchemaResource.java @@ -15,6 +15,7 @@ package org.apache.juneau.examples.rest; import org.apache.juneau.dto.jsonschema.*; import org.apache.juneau.microservice.*; import org.apache.juneau.rest.annotation.*; +import org.apache.juneau.rest.widget.*; /** * Sample resource that shows how to serialize JSON-Schema documents. @@ -24,7 +25,17 @@ import org.apache.juneau.rest.annotation.*; messages="nls/JsonSchemaResource", title="Sample JSON-Schema document", description="Sample resource that shows how to generate JSON-Schema documents", - pageLinks="{up:'request:/..',options:'servlet:/?method=OPTIONS',source:'$C{Source/gitHub}/org/apache/juneau/examples/rest/JsonSchemaResource.java'}" + htmldoc=@HtmlDoc( + links="{up:'request:/..',options:'servlet:/?method=OPTIONS',source:'$C{Source/gitHub}/org/apache/juneau/examples/rest/JsonSchemaResource.java'}", + aside="" + + "<div style='min-width:200px' class='text'>" + + " <p>Shows how to produce JSON-Schema documents in a variety of languages using the JSON-Schema DTOs.</p>" + + " <p>$W{contentTypeLinks}</p>" + + "</div>" + ), + widgets={ + ContentTypeLinksWidget.class + } ) public class JsonSchemaResource extends ResourceJena { private static final long serialVersionUID = 1L; http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/f4812b7c/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/MethodExampleResource.java ---------------------------------------------------------------------- diff --git a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/MethodExampleResource.java b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/MethodExampleResource.java index f396cd8..3c8c789 100644 --- a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/MethodExampleResource.java +++ b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/MethodExampleResource.java @@ -26,7 +26,14 @@ import org.apache.juneau.rest.annotation.Method; @RestResource( path="/methodExample", messages="nls/MethodExampleResource", - pageLinks="{up:'servlet:/..',options:'servlet:/?method=OPTIONS',source:'$C{Source/gitHub}/org/apache/juneau/examples/rest/MethodExampleResource.java'}" + htmldoc=@HtmlDoc( + links="{up:'servlet:/..',options:'servlet:/?method=OPTIONS',source:'$C{Source/gitHub}/org/apache/juneau/examples/rest/MethodExampleResource.java'}", + aside="" + + "<div style='max-width:400px' class='text'>" + + " <p>Shows the different methods for retrieving HTTP query/form-data parameters, headers, and path variables.</p>" + + " <p>The top-level path simply redirects to the first example method and spits out the results as a string.</p>" + + "</div>" + ) ) public class MethodExampleResource extends Resource { private static final long serialVersionUID = 1L; http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/f4812b7c/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/PhotosResource.java ---------------------------------------------------------------------- diff --git a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/PhotosResource.java b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/PhotosResource.java index f8875ff..0121c84 100644 --- a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/PhotosResource.java +++ b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/PhotosResource.java @@ -13,6 +13,7 @@ package org.apache.juneau.examples.rest; import static javax.servlet.http.HttpServletResponse.*; +import static org.apache.juneau.html.HtmlSerializerContext.*; import java.awt.image.*; import java.io.*; @@ -38,13 +39,24 @@ import org.apache.juneau.serializer.*; messages="nls/PhotosResource", title="Photo REST service", description="Sample resource that allows images to be uploaded and retrieved.", - pageLinks="{up:'request:/..',options:'servlet:/?method=OPTIONS',source:'$C{Source/gitHub}/org/apache/juneau/examples/rest/PhotosResource.java'}" + htmldoc=@HtmlDoc( + links="{up:'request:/..',options:'servlet:/?method=OPTIONS',source:'$C{Source/gitHub}/org/apache/juneau/examples/rest/PhotosResource.java'}", + aside="" + + "<div style='max-width:400px;min-width:200px' class='text'>" + + " <p>Shows an example of using custom serializers and parsers to create REST interfaces over binary resources.</p>" + + " <p>In this case, our resources are marshalled jpeg and png binary streams and are stored in an in-memory 'database' (also known as a <code>TreeMap</code>).</p>" + + "</div>" + ), + properties={ + // Make the anchor text on URLs be just the path relative to the servlet. + @Property(name=HTML_uriAnchorText, value="SERVLET_RELATIVE") + } ) public class PhotosResource extends Resource { private static final long serialVersionUID = 1L; // Our cache of photos - private Map<Integer,Photo> photos = new TreeMap<Integer,Photo>(); + private Map<String,Photo> photos = new TreeMap<String,Photo>(); @Override /* Servlet */ public void init() { @@ -52,7 +64,7 @@ public class PhotosResource extends Resource { // Preload an image. InputStream is = getClass().getResourceAsStream("averycutecat.jpg"); BufferedImage image = ImageIO.read(is); - Photo photo = new Photo(0, image); + Photo photo = new Photo("cat", image); photos.put(photo.id, photo); } catch (IOException e) { throw new RuntimeException(e); @@ -61,16 +73,16 @@ public class PhotosResource extends Resource { /** Our bean class for storing photos */ public static class Photo { - int id; + String id; BufferedImage image; - Photo(int id, BufferedImage image) { + Photo(String id, BufferedImage image) { this.id = id; this.image = image; } public URI getURI() throws URISyntaxException { - return new URI(""+id); + return new URI("servlet:/" + id); } } @@ -82,7 +94,7 @@ public class PhotosResource extends Resource { /** GET request handler for single photo */ @RestMethod(name="GET", path="/{id}", serializers=ImageSerializer.class, summary="Get a photo by ID") - public BufferedImage getPhoto(@Path int id) throws Exception { + public BufferedImage getPhoto(@Path String id) throws Exception { Photo p = photos.get(id); if (p == null) throw new RestException(SC_NOT_FOUND, "Photo not found"); @@ -90,24 +102,23 @@ public class PhotosResource extends Resource { } /** PUT request handler */ - @RestMethod(name="PUT", path="/{id}", parsers=ImageParser.class, summary="Add a photo") - public String addPhoto(@Path int id, @Body BufferedImage image) throws Exception { + @RestMethod(name="PUT", path="/{id}", parsers=ImageParser.class, summary="Add or overwrite a photo") + public String addPhoto(@Path String id, @Body BufferedImage image) throws Exception { photos.put(id, new Photo(id, image)); return "OK"; } - + /** POST request handler */ - @RestMethod(name="POST", path="/", parsers=ImageParser.class, summary="Overwrite a photo by ID") + @RestMethod(name="POST", path="/", parsers=ImageParser.class, summary="Add a photo") public Photo setPhoto(@Body BufferedImage image) throws Exception { - int id = photos.size(); - Photo p = new Photo(id, image); - photos.put(id, p); + Photo p = new Photo(UUID.randomUUID().toString(), image); + photos.put(p.id, p); return p; } /** DELETE request handler */ @RestMethod(name="DELETE", path="/{id}", summary="Delete a photo by ID") - public String deletePhoto(@Path int id) throws Exception { + public String deletePhoto(@Path String id) throws Exception { Photo p = photos.remove(id); if (p == null) throw new RestException(SC_NOT_FOUND, "Photo not found"); http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/f4812b7c/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/RequestEchoResource.java ---------------------------------------------------------------------- diff --git a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/RequestEchoResource.java b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/RequestEchoResource.java index 84c7d7a..e17458a 100644 --- a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/RequestEchoResource.java +++ b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/RequestEchoResource.java @@ -31,7 +31,15 @@ import org.apache.juneau.transforms.*; path="/echo", title="Request echo service", description="Echos the current HttpServletRequest object back to the browser.", - pageLinks="{up:'request:/..',options:'servlet:/?method=OPTIONS',source:'$C{Source/gitHub}/org/apache/juneau/examples/rest/RequestEchoResource.java'}", + htmldoc=@HtmlDoc( + links="{up:'request:/..',options:'servlet:/?method=OPTIONS',source:'$C{Source/gitHub}/org/apache/juneau/examples/rest/RequestEchoResource.java'}", + aside="" + + "<div style='max-width:400px;min-width:200px' class='text'>" + + " <p>Shows how even arbitrary POJOs such as <code>HttpServletRequest</code> can be serialized by the framework.</p>" + + " <p>Also shows how to specify serializer properties, filters, and swaps at the servlet level to control how POJOs are serialized.</p>" + + " <p>Also provides an example of how to use the Traversable and Queryable APIs.</p>" + + "</div>" + ), properties={ @Property(name=SERIALIZER_maxDepth, value="5"), @Property(name=SERIALIZER_detectRecursions, value="true") @@ -52,7 +60,7 @@ public class RequestEchoResource extends Resource { @RestMethod(name="*", path="/*", converters={Traversable.class,Queryable.class}, summary="Serializes the incoming HttpServletRequest object.") public HttpServletRequest doGet(RestRequest req, RestResponse res, @Properties ObjectMap properties) { // Set the HtmlDocSerializer title programmatically. - res.setPageTitle("Contents of HttpServletRequest object"); + res.setHtmlTitle("Contents of HttpServletRequest object"); // Just echo the request back as the response. return req; http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/f4812b7c/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/RootResources.java ---------------------------------------------------------------------- diff --git a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/RootResources.java b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/RootResources.java index 726ae3b..2637411 100644 --- a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/RootResources.java +++ b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/RootResources.java @@ -16,6 +16,7 @@ import org.apache.juneau.examples.rest.addressbook.*; import org.apache.juneau.microservice.*; import org.apache.juneau.microservice.resources.*; import org.apache.juneau.rest.annotation.*; +import org.apache.juneau.rest.widget.*; /** * Sample REST resource showing how to implement a "router" resource page. @@ -23,8 +24,24 @@ import org.apache.juneau.rest.annotation.*; @RestResource( path="/", title="Root resources", - description="This is an example of a router resource that is used to access other resources.", - pageLinks="{options:'?method=OPTIONS',source:'$C{Source/gitHub}/org/apache/juneau/examples/rest/RootResources.java'}", + description="Example of a router resource page.", + htmldoc=@HtmlDoc( + links="{options:'?method=OPTIONS',source:'$C{Source/gitHub}/org/apache/juneau/examples/rest/RootResources.java'}", + aside="" + + "<div style='max-width:400px' class='text'>" + + " <p>This is an example of a 'router' page that serves as a jumping-off point to child resources.</p>" + + " <p>Resources can be nested arbitrarily deep through router pages.</p>" + + " <p>Note the <span class='link'>OPTIONS</span> link provided that lets you see the generated swagger doc for this page.</p>" + + " <p>Also note the <span class='link'>SOURCE</span> link on these pages to view the source code for the page.</p>" + + " <p>All content on pages in the UI are serialized POJOs. In this case, it's a serialized array of beans with 2 properties.</p>" + + " <p>Other features (such as this aside) are added through annotations.</p>" + + "</div>", + footer="$W{poweredByJuneau}" + ), + widgets={ + PoweredByJuneauWidget.class, + ContentTypeLinksWidget.class + }, children={ HelloWorldResource.class, SystemPropertiesResource.class, http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/f4812b7c/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/SampleRemoteableServlet.java ---------------------------------------------------------------------- diff --git a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/SampleRemoteableServlet.java b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/SampleRemoteableServlet.java index dd8da66..9451692 100644 --- a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/SampleRemoteableServlet.java +++ b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/SampleRemoteableServlet.java @@ -28,8 +28,17 @@ import org.apache.juneau.rest.remoteable.*; path="/remoteable", messages="nls/SampleRemoteableServlet", title="Remoteable Service Proxy API", - description="Sample class showing how to use remoteable proxies. The list below are exposed services that can be retrieved using RestClient.getProxyInterface(Class).", - pageLinks="{up:'request:/..',options:'servlet:/?method=OPTIONS',source:'$C{Source/gitHub}/org/apache/juneau/examples/rest/SampleRemoteableServlet.java'}", + description="Sample class showing how to use remoteable proxies.", + htmldoc=@HtmlDoc( + links="{up:'request:/..',options:'servlet:/?method=OPTIONS',source:'$C{Source/gitHub}/org/apache/juneau/examples/rest/SampleRemoteableServlet.java'}", + aside="" + + "<div style='max-width:400px;min-width:200px' class='text'>" + + " <p>Shows how to use the <code>RemoteableServlet</code> class to define RPC-style remoteable interfaces using REST as a protocol.</p>" + + " <p>Remoteable proxies are retrieved on the client side using <code>RestClient.getInterfaceProxy(Class)</code>.</p>" + + " <p>Methods are invoked using POSTs of serialized arrays of objects and the returned value is marshalled back as a response.</p>" + + " <p>GET requests (as shown here) show the available methods on the interface.</p>" + + "</div>" + ), properties={ // Allow us to use method=POST from a browser. @Property(name=REST_allowMethodParam, value="*") http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/f4812b7c/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/SqlQueryResource.java ---------------------------------------------------------------------- diff --git a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/SqlQueryResource.java b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/SqlQueryResource.java index ea7c661..54a5415 100644 --- a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/SqlQueryResource.java +++ b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/SqlQueryResource.java @@ -35,7 +35,14 @@ import org.apache.juneau.rest.annotation.Body; messages="nls/SqlQueryResource", title="SQL query service", description="Executes queries against the local derby '$C{SqlQueryResource/connectionUrl}' database", - pageLinks="{up:'request:/..',options:'servlet:/..',source:'$C{Source/gitHub}/org/apache/juneau/examples/rest/SqlQueryResource.java'}" + htmldoc=@HtmlDoc( + links="{up:'request:/..',options:'servlet:/..',source:'$C{Source/gitHub}/org/apache/juneau/examples/rest/SqlQueryResource.java'}", + aside="" + + "<div style='min-width:200px' class='text'>" + + " <p>An example of a REST interface over a relational database.</p>" + + " <p><a class='link' href='?sql=select+*+from sys.systables'>try me</a></p>" + + "</div>" + ) ) public class SqlQueryResource extends Resource { private static final long serialVersionUID = 1L; @@ -63,7 +70,7 @@ public class SqlQueryResource extends Resource { /** GET request handler - Display the query entry page. */ @RestMethod(name="GET", path="/", summary="Display the query entry page") - public Div doGet(RestRequest req) { + public Div doGet(RestRequest req, @Query("sql") String sql) { return div( script("text/javascript", "\n // Quick and dirty function to allow tabs in textarea." @@ -93,7 +100,7 @@ public class SqlQueryResource extends Resource { ), tr( td().colspan(5).children( - textarea().name("sql").style("width:100%;height:200px;font-family:Courier;font-size:9pt;").onkeydown("checkTab(event)") + textarea().name("sql").text(sql == null ? " " : sql).style("width:100%;height:200px;font-family:Courier;font-size:9pt;").onkeydown("checkTab(event)") ) ) ) @@ -114,8 +121,6 @@ public class SqlQueryResource extends Resource { if (isEmpty(in.sql)) return results; - System.err.println("SQL=["+in.sql+"]"); - if (in.pos < 1 || in.pos > 10000) throw new RestException(SC_BAD_REQUEST, "Invalid value for position. Must be between 1-10000"); if (in.limit < 1 || in.limit > 10000) http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/f4812b7c/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/SystemPropertiesResource.java ---------------------------------------------------------------------- diff --git a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/SystemPropertiesResource.java b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/SystemPropertiesResource.java index 4b494ac..8cb01e5 100644 --- a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/SystemPropertiesResource.java +++ b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/SystemPropertiesResource.java @@ -19,7 +19,6 @@ import java.util.*; import java.util.Map; import org.apache.juneau.dto.html5.*; -import org.apache.juneau.dto.swagger.*; import org.apache.juneau.encoders.*; import org.apache.juneau.microservice.*; import org.apache.juneau.rest.*; @@ -38,7 +37,14 @@ import org.apache.juneau.rest.annotation.Body; // "request:/..." URIs are relative to the request URI. // "servlet:/..." URIs are relative to the servlet URI. // "$C{...}" variables are pulled from the config file. - pageLinks="{up:'request:/..',options:'servlet:/?method=OPTIONS',form:'servlet:/formPage',source:'$C{Source/gitHub}/org/apache/juneau/examples/rest/SystemPropertiesResource.java'}", + htmldoc=@HtmlDoc( + links="{up:'request:/..',options:'servlet:/?method=OPTIONS',form:'servlet:/formPage',source:'$C{Source/gitHub}/org/apache/juneau/examples/rest/SystemPropertiesResource.java'}", + aside="" + + "<div style='max-width:800px' class='text'>" + + " <p>Shows standard GET/PUT/POST/DELETE operations and use of Swagger annotations.</p>" + + "</div>", + css="aside {display:table-caption;}" + ), // Properties that get applied to all serializers and parsers. properties={ @@ -52,12 +58,14 @@ import org.apache.juneau.rest.annotation.Body; // Support GZIP encoding on Accept-Encoding header. encoders=GzipEncoder.class, - contact="{name:'John Smith',email:'[email protected]'}", - license="{name:'Apache 2.0',url:'http://www.apache.org/licenses/LICENSE-2.0.html'}", - version="2.0", - termsOfService="You're on your own.", - tags="[{name:'Java',description:'Java utility',externalDocs:{description:'Home page',url:'http://juneau.apache.org'}}]", - externalDocs="{description:'Home page',url:'http://juneau.apache.org'}" + swagger=@ResourceSwagger( + contact="{name:'John Smith',email:'[email protected]'}", + license="{name:'Apache 2.0',url:'http://www.apache.org/licenses/LICENSE-2.0.html'}", + version="2.0", + termsOfService="You're on your own.", + tags="[{name:'Java',description:'Java utility',externalDocs:{description:'Home page',url:'http://juneau.apache.org'}}]", + externalDocs="{description:'Home page',url:'http://juneau.apache.org'}" + ) ) public class SystemPropertiesResource extends Resource { private static final long serialVersionUID = 1L; @@ -66,12 +74,14 @@ public class SystemPropertiesResource extends Resource { name="GET", path="/", summary="Show all system properties", description="Returns all system properties defined in the JVM.", - parameters={ - @Parameter(in="query", name="sort", description="Sort results alphabetically.", _default="false") - }, - responses={ - @Response(value=200, description="Returns a map of key/value pairs.") - } + swagger=@MethodSwagger( + parameters={ + @Parameter(in="query", name="sort", description="Sort results alphabetically.", _default="false") + }, + responses={ + @Response(value=200, description="Returns a map of key/value pairs.") + } + ) ) @SuppressWarnings({"rawtypes", "unchecked"}) public Map getSystemProperties(@Query("sort") boolean sort) throws Throwable { @@ -84,12 +94,14 @@ public class SystemPropertiesResource extends Resource { name="GET", path="/{propertyName}", summary="Get system property", description="Returns the value of the specified system property.", - parameters={ - @Parameter(in="path", name="propertyName", description="The system property name.") - }, - responses={ - @Response(value=200, description="The system property value, or null if not found.") - } + swagger=@MethodSwagger( + parameters={ + @Parameter(in="path", name="propertyName", description="The system property name.") + }, + responses={ + @Response(value=200, description="The system property value, or null if not found.") + } + ) ) public String getSystemProperty(@Path String propertyName) throws Throwable { return System.getProperty(propertyName); @@ -100,22 +112,24 @@ public class SystemPropertiesResource extends Resource { summary="Replace system property", description="Sets a new value for the specified system property.", guards=AdminGuard.class, - parameters={ - @Parameter(in="path", name="propertyName", description="The system property name."), - @Parameter(in="body", description="The new system property value."), - }, - responses={ - @Response(value=302, - headers={ - @Parameter(name="Location", description="The root URL of this resource.") - } - ), - @Response(value=403, description="User is not an admin.") - } + swagger=@MethodSwagger( + parameters={ + @Parameter(in="path", name="propertyName", description="The system property name."), + @Parameter(in="body", description="The new system property value."), + }, + responses={ + @Response(value=302, + headers={ + @Parameter(name="Location", description="The root URL of this resource.") + } + ), + @Response(value=403, description="User is not an admin.") + } + ) ) public Redirect setSystemProperty(@Path String propertyName, @Body String value) { System.setProperty(propertyName, value); - return new Redirect(); + return new Redirect("servlet:/"); } @RestMethod( @@ -123,22 +137,24 @@ public class SystemPropertiesResource extends Resource { summary="Add an entire set of system properties", description="Takes in a map of key/value pairs and creates a set of new system properties.", guards=AdminGuard.class, - parameters={ - @Parameter(in="path", name="propertyName", description="The system property key."), - @Parameter(in="body", description="The new system property values.", schema="{example:{key1:'val1',key2:123}}"), - }, - responses={ - @Response(value=302, - headers={ - @Parameter(name="Location", description="The root URL of this resource.") - } - ), - @Response(value=403, description="Unauthorized: User is not an admin.") - } + swagger=@MethodSwagger( + parameters={ + @Parameter(in="path", name="propertyName", description="The system property key."), + @Parameter(in="body", description="The new system property values.", schema="{example:{key1:'val1',key2:123}}"), + }, + responses={ + @Response(value=302, + headers={ + @Parameter(name="Location", description="The root URL of this resource.") + } + ), + @Response(value=403, description="Unauthorized: User is not an admin.") + } + ) ) public Redirect setSystemProperties(@Body java.util.Properties newProperties) { System.setProperties(newProperties); - return new Redirect(); + return new Redirect("servlet:/"); } @RestMethod( @@ -146,38 +162,37 @@ public class SystemPropertiesResource extends Resource { summary="Delete system property", description="Deletes the specified system property.", guards=AdminGuard.class, - parameters={ - @Parameter(in="path", name="propertyName", description="The system property name."), - }, - responses={ - @Response(value=302, - headers={ - @Parameter(name="Location", description="The root URL of this resource.") - } - ), - @Response(value=403, description="Unauthorized: User is not an admin") - } + swagger=@MethodSwagger( + parameters={ + @Parameter(in="path", name="propertyName", description="The system property name."), + }, + responses={ + @Response(value=302, + headers={ + @Parameter(name="Location", description="The root URL of this resource.") + } + ), + @Response(value=403, description="Unauthorized: User is not an admin") + } + ) ) public Redirect deleteSystemProperty(@Path String propertyName) { System.clearProperty(propertyName); - return new Redirect(); + return new Redirect("servlet:/"); } - @Override - @RestMethod( - name="OPTIONS", path="/*", - summary="Show resource options", - description="Show resource options as a Swagger doc" - ) - public Swagger getOptions(RestRequest req) { - return req.getSwagger(); - } - @RestMethod( name="GET", path="/formPage", summary="Form entry page", description="A form post page for setting a single system property value", - guards=AdminGuard.class + guards=AdminGuard.class, + htmldoc=@HtmlDoc( + aside="" + + "<div style='max-width:400px' class='text'>" + + " <p>Shows how HTML5 beans can be used to quickly create arbitrary HTML.</p>" + + "</div>", + css="aside {display:table-cell;}" + ) ) public Form getFormPage() { return form().method("POST").action("formPagePost").children( @@ -195,6 +210,6 @@ public class SystemPropertiesResource extends Resource { ) public Redirect formPagePost(@FormData("name") String name, @FormData("value") String value) { System.setProperty(name, value); - return new Redirect(); + return new Redirect("servlet:/"); } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/f4812b7c/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/TempDirResource.java ---------------------------------------------------------------------- diff --git a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/TempDirResource.java b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/TempDirResource.java index e3ac5bd..f6f949d 100644 --- a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/TempDirResource.java +++ b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/TempDirResource.java @@ -30,7 +30,14 @@ import org.apache.juneau.utils.*; path="/tempDir", title="Temp Directory View Service", description="View and download files in the '$S{java.io.tmpdir}' directory.", - pageLinks="{up:'request:/..',options:'servlet:/?method=OPTIONS',upload:'servlet:/upload',source:'$C{Source/gitHub}/org/apache/juneau/examples/rest/TempDirResource.java'}", + htmldoc=@HtmlDoc( + links="{up:'request:/..',options:'servlet:/?method=OPTIONS',upload:'servlet:/upload',source:'$C{Source/gitHub}/org/apache/juneau/examples/rest/TempDirResource.java'}", + aside="" + + "<div style='max-width:400px' class='text'>" + + " <p>Shows how to use the predefined DirectoryResource class.</p>" + + " <p>Also shows how to use HTML5 beans to create a form entry page.</p>" + + "</div>" + ), properties={ @Property(name="rootDir", value="$S{java.io.tmpdir}"), @Property(name="allowViews", value="true"), http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/f4812b7c/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/TumblrParserResource.java ---------------------------------------------------------------------- diff --git a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/TumblrParserResource.java b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/TumblrParserResource.java index 62920fb..2e98fdf 100644 --- a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/TumblrParserResource.java +++ b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/TumblrParserResource.java @@ -24,14 +24,23 @@ import org.apache.juneau.rest.client.*; messages="nls/TumblrParserResource", title="Tumblr parser service", description="Specify a URL to a Tumblr blog and parse the results.", - pageLinks="{up:'request:/..',options:'servlet:/?method=OPTIONS',source:'$C{Source/gitHub}/org/apache/juneau/examples/rest/TumblrParserResource.java'}" + htmldoc=@HtmlDoc( + links="{up:'request:/..',options:'servlet:/?method=OPTIONS',source:'$C{Source/gitHub}/org/apache/juneau/examples/rest/TumblrParserResource.java'}", + aside="" + + "<div style='min-width:200px' class='text'>" + + " <p>An example of a REST interface that retrieves data from another REST interface.</p>" + + " <p><a class='link' href='$U{servlet:/ibmblr}'>try me</a></p>" + + "</div>" + ) ) public class TumblrParserResource extends Resource { private static final long serialVersionUID = 1L; + + private static final int MAX_POSTS = 100; @RestMethod(name="GET", path="/", summary="Get the instructions page") public String getInstructions() throws Exception { - return "Append the Tumblr blog name to the URL above (e.g. /juneau/sample/tumblrParser/mytumblrblog)"; + return "Append the Tumblr blog name to the URL above (e.g. /tumblrParser/mytumblrblog)"; } @RestMethod(name="GET", path="/{blogName}", summary="Parse the specified blog") @@ -41,7 +50,7 @@ public class TumblrParserResource extends Resource { try { String site = "http://" + blogName + ".tumblr.com/api/read/json"; ObjectMap m = rc.doGet(site).getResponse(ObjectMap.class); - int postsTotal = m.getInt("posts-total"); + int postsTotal = Math.min(m.getInt("posts-total"), MAX_POSTS); for (int i = 0; i < postsTotal; i += 20) { m = rc.doGet(site + "?start=" + i + "&num=20&filter=text").getResponse(ObjectMap.class); ObjectList ol = m.getObjectList("posts"); http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/f4812b7c/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/UrlEncodedFormResource.java ---------------------------------------------------------------------- diff --git a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/UrlEncodedFormResource.java b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/UrlEncodedFormResource.java index 06541ab..95b2198 100644 --- a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/UrlEncodedFormResource.java +++ b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/UrlEncodedFormResource.java @@ -32,7 +32,14 @@ import org.apache.juneau.transforms.*; messages="nls/UrlEncodedFormResource", title="Tumblr parser service", description="Specify a URL to a Tumblr blog and parse the results.", - pageLinks="{up:'request:/..',source:'$C{Source/gitHub}/org/apache/juneau/examples/rest/UrlEncodedFormResource.java'}" + htmldoc=@HtmlDoc( + links="{up:'request:/..',source:'$C{Source/gitHub}/org/apache/juneau/examples/rest/UrlEncodedFormResource.java'}", + aside="" + + "<div style='min-width:200px' class='text'>" + + " <p>Shows how to process a FORM POST body into a bean using the <code>@Body</code> annotation.</p>" + + " <p>Submitting the form post will simply echo the bean back on the response.</p>" + + "</div>" + ) ) public class UrlEncodedFormResource extends Resource { private static final long serialVersionUID = 1L; http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/f4812b7c/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/addressbook/AddressBookResource.java ---------------------------------------------------------------------- diff --git a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/addressbook/AddressBookResource.java b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/addressbook/AddressBookResource.java index d228173..6677c29 100644 --- a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/addressbook/AddressBookResource.java +++ b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/addressbook/AddressBookResource.java @@ -23,7 +23,6 @@ import java.util.*; import org.apache.juneau.*; import org.apache.juneau.dto.*; import org.apache.juneau.dto.cognos.*; -import org.apache.juneau.dto.swagger.*; import org.apache.juneau.encoders.*; import org.apache.juneau.examples.addressbook.*; import org.apache.juneau.examples.rest.*; @@ -31,6 +30,7 @@ import org.apache.juneau.microservice.*; import org.apache.juneau.rest.*; import org.apache.juneau.rest.annotation.*; import org.apache.juneau.rest.converters.*; +import org.apache.juneau.rest.widget.*; import org.apache.juneau.transform.*; import org.apache.juneau.utils.*; @@ -47,7 +47,28 @@ import org.apache.juneau.utils.*; // "request:/..." URIs are relative to the request URI. // "servlet:/..." URIs are relative to the servlet URI. // "$C{...}" variables are pulled from the config file. - pageLinks="{up:'request:/..',options:'servlet:/?method=OPTIONS',source:'$C{Source/gitHub}/org/apache/juneau/examples/rest/addressbook/AddressBookResource.java'}", + htmldoc=@HtmlDoc( + links="{up:'request:/..',options:'servlet:/?method=OPTIONS',source:'$C{Source/gitHub}/org/apache/juneau/examples/rest/addressbook/AddressBookResource.java'}", + aside="" + + "<div style='max-width:400px;min-width:200px'>" + + " <p>Proof-of-concept resource that shows off the capabilities of working with POJO resources.</p>" + + " <p>Provides examples of: </p>" + + " <ul>" + + " <li>XML and RDF namespaces" + + " <li>Swagger documentation" + + " <li>Widgets" + + " </ul>" + + " <p style='text-weight:bold;text-decoration:underline;'>Available Content Types</p>" + + " $W{contentTypeLinks}" + + "</div>", + footer="$W{poweredByJuneau}" + ), + + // Widgets for $W variables above. + widgets={ + PoweredByJuneauWidget.class, + ContentTypeLinksWidget.class + }, // Properties that get applied to all serializers and parsers. properties={ @@ -78,12 +99,14 @@ import org.apache.juneau.utils.*; encoders=GzipEncoder.class, // Swagger info. - contact="{name:'John Smith',email:'[email protected]'}", - license="{name:'Apache 2.0',url:'http://www.apache.org/licenses/LICENSE-2.0.html'}", - version="2.0", - termsOfService="You're on your own.", - tags="[{name:'Java',description:'Java utility',externalDocs:{description:'Home page',url:'http://juneau.apache.org'}}]", - externalDocs="{description:'Home page',url:'http://juneau.apache.org'}" + swagger=@ResourceSwagger( + contact="{name:'John Smith',email:'[email protected]'}", + license="{name:'Apache 2.0',url:'http://www.apache.org/licenses/LICENSE-2.0.html'}", + version="2.0", + termsOfService="You're on your own.", + tags="[{name:'Java',description:'Java utility',externalDocs:{description:'Home page',url:'http://juneau.apache.org'}}]", + externalDocs="{description:'Home page',url:'http://juneau.apache.org'}" + ) ) public class AddressBookResource extends ResourceJena { private static final long serialVersionUID = 1L; @@ -307,16 +330,6 @@ public class AddressBookResource extends ResourceJena { return addressBook; } - /** - * [OPTIONS /*] - * View resource options - */ - @Override /* RestServletJenaDefault */ - @RestMethod(name="OPTIONS", path="/*") - public Swagger getOptions(RestRequest req) { - return req.getSwagger(); - } - /** Convenience method - Find a person by ID */ private Person findPerson(int id) throws RestException { Person p = addressBook.findPerson(id);
