Repository: incubator-juneau
Updated Branches:
  refs/heads/master a0580074c -> 703cadd2d


http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/703cadd2/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 2fb2560..8125cdc 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
@@ -31,6 +31,7 @@ import javax.servlet.http.*;
 import org.apache.juneau.*;
 import org.apache.juneau.dto.swagger.*;
 import org.apache.juneau.encoders.*;
+import org.apache.juneau.html.*;
 import org.apache.juneau.internal.*;
 import org.apache.juneau.json.*;
 import org.apache.juneau.parser.*;
@@ -67,6 +68,7 @@ class CallMethod implements Comparable<CallMethod>  {
        private final org.apache.juneau.rest.annotation.Parameter[] parameters;
        private final Response[] responses;
        private final RestContext context;
+       private final String pageTitle, pageText, pageLinks;
 
        CallMethod(Object servlet, java.lang.reflect.Method method, RestContext 
context) throws RestServletException {
                Builder b = new Builder(servlet, method, context);
@@ -95,10 +97,13 @@ class CallMethod implements Comparable<CallMethod>  {
                this.priority = b.priority;
                this.parameters = b.parameters;
                this.responses = b.responses;
+               this.pageTitle = b.pageTitle;
+               this.pageText = b.pageText;
+               this.pageLinks = b.pageLinks;
        }
 
        private static class Builder  {
-               private String httpMethod, defaultCharset, description, tags, 
summary, externalDocs;
+               private String httpMethod, defaultCharset, description, tags, 
summary, externalDocs, pageTitle, pageText, pageLinks;
                private UrlPathPattern pathPattern;
                private CallMethod.MethodParam[] params;
                private RestGuard[] guards;
@@ -141,6 +146,10 @@ class CallMethod implements Comparable<CallMethod>  {
                                encoders = context.getEncoders();
                                properties = context.getProperties();
 
+                               pageTitle = m.pageTitle().isEmpty() ? 
context.getPageTitle() : m.pageTitle();
+                               pageText = m.pageText().isEmpty() ? 
context.getPageText() : m.pageText();
+                               pageLinks = m.pageLinks().isEmpty() ? 
context.getPageLinks() : m.pageLinks();
+
                                List<Inherit> si = 
Arrays.asList(m.serializersInherit());
                                List<Inherit> pi = 
Arrays.asList(m.parsersInherit());
 
@@ -164,7 +173,7 @@ class CallMethod implements Comparable<CallMethod>  {
                                if (httpMethod.equals("") && 
method.getName().startsWith("do"))
                                        httpMethod = 
method.getName().substring(2).toUpperCase(Locale.ENGLISH);
                                if (httpMethod.equals(""))
-                                       throw new 
RestServletException("@RestMethod name not specified on method ''{0}.{1}''", 
method.getDeclaringClass().getName(), method.getName());
+                                       httpMethod = "GET";
                                if (httpMethod.equals("METHOD"))
                                        httpMethod = "*";
 
@@ -287,6 +296,8 @@ class CallMethod implements Comparable<CallMethod>  {
 
                                // Need this to access methods in anonymous 
inner classes.
                                method.setAccessible(true);
+                       } catch (RestServletException e) {
+                               throw e;
                        } catch (Exception e) {
                                throw new RestServletException("Exception 
occurred while initializing method ''{0}''", method.getName()).initCause(e);
                        }
@@ -808,8 +819,9 @@ class CallMethod implements Comparable<CallMethod>  {
                for (int i = 0; i < pathPattern.getVars().length; i++)
                        req.setPathParameter(pathPattern.getVars()[i], 
patternVals[i]);
 
-               req.init(method, remainder, createRequestProperties(properties, 
req), defaultRequestHeaders, defaultCharset, serializers, parsers, 
urlEncodingParser, encoders);
-               res.init(req.getProperties(), defaultCharset, serializers, 
urlEncodingSerializer, encoders);
+               ObjectMap requestProperties = 
createRequestProperties(properties, req);
+               req.init(method, remainder, requestProperties, 
defaultRequestHeaders, defaultCharset, serializers, parsers, urlEncodingParser, 
encoders, pageTitle, pageText, pageLinks);
+               res.init(requestProperties, defaultCharset, serializers, 
urlEncodingSerializer, encoders);
 
                // Class-level guards
                for (RestGuard guard : context.getGuards())
@@ -888,7 +900,7 @@ class CallMethod implements Comparable<CallMethod>  {
        /**
         * This method creates all the request-time properties.
         */
-       static ObjectMap createRequestProperties(final ObjectMap 
methodProperties, final RestRequest req) {
+       ObjectMap createRequestProperties(final ObjectMap methodProperties, 
final RestRequest req) {
                @SuppressWarnings("serial")
                ObjectMap m = new ObjectMap() {
                        @Override /* Map */
@@ -933,6 +945,12 @@ class CallMethod implements Comparable<CallMethod>  {
                                                return req.getMethodSummary();
                                        if (k.equals(REST_methodDescription))
                                                return 
req.getMethodDescription();
+                                       if 
(k.equals(HtmlDocSerializerContext.HTMLDOC_title))
+                                               return req.getPageTitle();
+                                       if 
(k.equals(HtmlDocSerializerContext.HTMLDOC_text))
+                                               return req.getPageText();
+                                       if 
(k.equals(HtmlDocSerializerContext.HTMLDOC_links))
+                                               return req.getPageLinks();
                                        o = req.getPathParameter(k);
                                        if (o == null)
                                                o = req.getHeader(k);

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/703cadd2/juneau-rest/src/main/java/org/apache/juneau/rest/ReaderResource.java
----------------------------------------------------------------------
diff --git 
a/juneau-rest/src/main/java/org/apache/juneau/rest/ReaderResource.java 
b/juneau-rest/src/main/java/org/apache/juneau/rest/ReaderResource.java
index 5fd0268..7556006 100644
--- a/juneau-rest/src/main/java/org/apache/juneau/rest/ReaderResource.java
+++ b/juneau-rest/src/main/java/org/apache/juneau/rest/ReaderResource.java
@@ -67,13 +67,13 @@ public class ReaderResource implements Writable {
         *      </ul>
         * @throws IOException
         */
-       public ReaderResource(MediaType mediaType, Map<String,Object> headers, 
VarResolverSession varSession, Object...contents) throws IOException {
+       public ReaderResource(MediaType mediaType, Map<String,String> headers, 
VarResolverSession varSession, Object...contents) throws IOException {
                this.mediaType = mediaType;
                this.varSession = varSession;
 
                Map<String,String> m = new LinkedHashMap<String,String>();
                if (headers != null)
-                       for (Map.Entry<String,Object> e : headers.entrySet())
+                       for (Map.Entry<String,String> e : headers.entrySet())
                                m.put(e.getKey(), 
StringUtils.toString(e.getValue()));
                this.headers = Collections.unmodifiableMap(m);
 

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/703cadd2/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 7eebe50..0197cbc 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
@@ -100,7 +100,7 @@ public class RestConfig implements ServletConfig {
        Object favIcon;
        List<Object> staticFiles;
        RestContext parentContext;
-       String path;
+       String path, pageTitle, pageText, pageLinks;
        String clientVersionHeader = "X-Client-Version";
 
        Object resourceResolver = RestResourceResolver.class;
@@ -193,6 +193,12 @@ public class RestConfig implements ServletConfig {
                                        setPath(r.path());
                                if (! r.clientVersionHeader().isEmpty())
                                        
setClientVersionHeader(r.clientVersionHeader());
+                               if (! r.pageTitle().isEmpty())
+                                       setPageTitle(r.pageTitle());
+                               if (! r.pageText().isEmpty())
+                                       setPageText(r.pageText());
+                               if (! r.pageLinks().isEmpty())
+                                       setPageLinks(r.pageLinks());
                                if (r.resourceResolver() != 
RestResourceResolver.class)
                                        
setResourceResolver(r.resourceResolver());
                                if (r.logger() != RestLogger.Normal.class)
@@ -969,6 +975,45 @@ public class RestConfig implements ServletConfig {
        }
 
        /**
+        * Sets the page title to use on HTML views of pages.
+        * <p>
+        * This is the programmatic equivalent to the {@link 
RestResource#pageTitle() @RestResource.pageTitle()} annotation.
+        *
+        * @param pageTitle The page title text.
+        * @return This object (for method chaining).
+        */
+       public RestConfig setPageTitle(String pageTitle) {
+               this.pageTitle = pageTitle;
+               return this;
+       }
+
+       /**
+        * Sets the page text to use on HTML views of pages.
+        * <p>
+        * This is the programmatic equivalent to the {@link 
RestResource#pageText() @RestResource.pageText()} annotation.
+        *
+        * @param pageText The page text.
+        * @return This object (for method chaining).
+        */
+       public RestConfig setPageText(String pageText) {
+               this.pageText = pageText;
+               return this;
+       }
+
+       /**
+        * Sets the page links to use on HTML views of pages.
+        * <p>
+        * This is the programmatic equivalent to the {@link 
RestResource#pageLinks() @RestResource.pageLinks()} annotation.
+        *
+        * @param pageLinks The page links.
+        * @return This object (for method chaining).
+        */
+       public RestConfig setPageLinks(String pageLinks) {
+               this.pageLinks = pageLinks;
+               return this;
+       }
+
+       /**
         * Overrides the logger for the resource.
         * <p>
         * This is the programmatic equivalent to the {@link 
RestResource#logger() @RestResource.logger()} annotation.

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/703cadd2/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 ae3aa22..2e39b74 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
@@ -277,6 +277,7 @@ public final class RestContext extends Context {
         */
        public static final String REST_methodDescription = 
"RestServlet.methodDescription";
 
+
        private final Object resource;
        private final RestConfig config;
        private final boolean
@@ -288,7 +289,8 @@ public final class RestContext extends Context {
                defaultCharset,
                paramFormat,
                clientVersionHeader,
-               fullPath;
+               fullPath,
+               pageTitle, pageText, pageLinks;
        private final Set<String> allowMethodParams;
 
        private final ObjectMap properties;
@@ -382,6 +384,9 @@ public final class RestContext extends Context {
                        this.childResources = Collections.synchronizedMap(new 
LinkedHashMap<String,RestContext>());  // Not unmodifiable on purpose so that 
children can be replaced.
                        this.logger = b.logger;
                        this.fullPath = b.fullPath;
+                       this.pageTitle = b.pageTitle;
+                       this.pageText = b.pageText;
+                       this.pageLinks = b.pageLinks;
 
                        
//----------------------------------------------------------------------------------------------------
                        // Initialize the child resources.
@@ -559,7 +564,7 @@ public final class RestContext extends Context {
                UrlEncodingSerializer urlEncodingSerializer;
                UrlEncodingParser urlEncodingParser;
                EncoderGroup encoders;
-               String clientVersionHeader = "", defaultCharset, paramFormat;
+               String clientVersionHeader = "", defaultCharset, paramFormat, 
pageTitle, pageText, pageLinks;
                List<MediaType> supportedContentTypes, supportedAcceptTypes;
                Map<String,String> defaultRequestHeaders = new 
TreeMap<String,String>(String.CASE_INSENSITIVE_ORDER);
                Map<String,Object> defaultResponseHeaders;
@@ -696,6 +701,10 @@ public final class RestContext extends Context {
                        logger = sc.logger == null ? new RestLogger.NoOp() : 
resolve(RestLogger.class, sc.logger);
 
                        fullPath = (sc.parentContext == null ? "" : 
(sc.parentContext.fullPath + '/')) + sc.path;
+
+                       pageTitle = sc.pageTitle;
+                       pageText = sc.pageText;
+                       pageLinks = sc.pageLinks;
                }
        }
 
@@ -728,7 +737,7 @@ public final class RestContext extends Context {
         *              properties={
         *                      <ja>@Property</ja>(
         *                              name=<jsf>HTMLDOC_links</jsf>,
-        *                              value=<js>"{up:'$R{requestParentURI}', 
options:'?method=OPTIONS', 
editLevel:'$R{servletURI}/editLevel?logger=$R{attribute.name}'}"</js>
+        *                              value=<js>"{up:'$R{requestParentURI}', 
options:'?method=OPTIONS', 
editLevel:'editLevel?logger=$R{attribute.name}'}"</js>
         *                      )
         *              }
         *      )
@@ -917,6 +926,33 @@ public final class RestContext extends Context {
        }
 
        /**
+        * Returns the page title as defined by the {@link 
RestResource#pageTitle()} annotation or {@link RestConfig#setPageTitle(String)} 
method.
+        *
+        * @return The page title.
+        */
+       public String getPageTitle() {
+               return pageTitle;
+       }
+
+       /**
+        * Returns the page text as defined by the {@link 
RestResource#pageText()} annotation or {@link RestConfig#setPageText(String)} 
method.
+        *
+        * @return The page text.
+        */
+       public String getPageText() {
+               return pageText;
+       }
+
+       /**
+        * Returns the page links as defined by the {@link 
RestResource#pageLinks()} annotation or {@link RestConfig#setPageLinks(String)} 
method.
+        *
+        * @return The page links.
+        */
+       public String getPageLinks() {
+               return pageLinks;
+       }
+
+       /**
         * Returns the logger to use for this resource.
         * <p>
         * The logger for a resource is defined via one of the following:

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/703cadd2/juneau-rest/src/main/java/org/apache/juneau/rest/RestLogger.java
----------------------------------------------------------------------
diff --git a/juneau-rest/src/main/java/org/apache/juneau/rest/RestLogger.java 
b/juneau-rest/src/main/java/org/apache/juneau/rest/RestLogger.java
index da266de..aa713b3 100644
--- a/juneau-rest/src/main/java/org/apache/juneau/rest/RestLogger.java
+++ b/juneau-rest/src/main/java/org/apache/juneau/rest/RestLogger.java
@@ -194,7 +194,7 @@ public abstract class RestLogger {
        }
 
        private static boolean isNoTrace(HttpServletRequest req) {
-               return "true".equals(req.getHeader("No-Trace")) || 
req.getQueryString().contains("noTrace=true");
+               return "true".equals(req.getHeader("No-Trace")) || 
(req.getQueryString() != null && req.getQueryString().contains("noTrace=true"));
        }
 
        private static boolean isDebug(HttpServletRequest req) {

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/703cadd2/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 e9d5936..28bfb2a 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
@@ -89,6 +89,7 @@ public final class RestRequest extends 
HttpServletRequestWrapper {
        private ObjectMap headers;
        private ConfigFile cf;
        private Swagger swagger, fileSwagger;
+       private String pageTitle, pageText, pageLinks;
 
        /**
         * Constructor.
@@ -141,7 +142,7 @@ public final class RestRequest extends 
HttpServletRequestWrapper {
         * Called from RestServlet after a match has been made but before the 
guard or method invocation.
         */
        @SuppressWarnings("hiding")
-       final void init(Method javaMethod, String pathRemainder, ObjectMap 
properties, Map<String,String> mDefaultRequestHeaders, String defaultCharset, 
SerializerGroup mSerializers, ParserGroup mParsers, UrlEncodingParser 
mUrlEncodingParser, EncoderGroup encoders) {
+       final void init(Method javaMethod, String pathRemainder, ObjectMap 
properties, Map<String,String> mDefaultRequestHeaders, String defaultCharset, 
SerializerGroup mSerializers, ParserGroup mParsers, UrlEncodingParser 
mUrlEncodingParser, EncoderGroup encoders, String pageTitle, String pageText, 
String pageLinks) {
                this.javaMethod = javaMethod;
                this.pathRemainder = pathRemainder;
                this.properties = properties;
@@ -152,6 +153,9 @@ public final class RestRequest extends 
HttpServletRequestWrapper {
                this.beanSession = 
urlEncodingParser.getBeanContext().createSession();
                this.defaultCharset = defaultCharset;
                this.encoders = encoders;
+               this.pageTitle = pageTitle;
+               this.pageText = pageText;
+               this.pageLinks = pageLinks;
 
                if (debug) {
                        String msg = ""
@@ -1621,6 +1625,56 @@ public final class RestRequest extends 
HttpServletRequestWrapper {
                return 
context.getInfoProvider().getMethodDescription(javaMethod.getName(), this);
        }
 
+       /**
+        * Returns the localized page title for HTML views.
+        *
+        * @return The localized page title for HTML views.
+        */
+       protected String getPageTitle() {
+               String s = pageTitle;
+               if (StringUtils.isEmpty(s))
+                       s = context.getMessages().findFirstString(getLocale(), 
javaMethod.getName() + ".pageTitle");
+               if (StringUtils.isEmpty(s))
+                       s = context.getMessages().findFirstString(getLocale(), 
"pageTitle");
+               if (! StringUtils.isEmpty(s))
+                       return resolveVars(s);
+               s = getServletTitle();
+               return s;
+       }
+
+       /**
+        * Returns the localized page text for HTML views.
+        *
+        * @return The localized page text for HTML views.
+        */
+       protected String getPageText() {
+               String s = pageText;
+               if (StringUtils.isEmpty(s))
+                       s = context.getMessages().findFirstString(getLocale(), 
javaMethod.getName() + ".pageText");
+               if (StringUtils.isEmpty(s))
+                       s = context.getMessages().findFirstString(getLocale(), 
"pageText");
+               if (! StringUtils.isEmpty(s))
+                       return resolveVars(s);
+               s = getMethodSummary();
+               if (StringUtils.isEmpty(s))
+                       s = getServletDescription();
+               return s;
+       }
+
+       /**
+        * Returns the localized page links for HTML views.
+        *
+        * @return The localized page links for HTML views.
+        */
+       protected String getPageLinks() {
+               String s = pageLinks;
+               if (StringUtils.isEmpty(s))
+                       s = context.getMessages().findFirstString(getLocale(), 
javaMethod.getName() + ".pageLinks");
+               if (StringUtils.isEmpty(s))
+                       s = context.getMessages().findFirstString(getLocale(), 
"pageLinks");
+               return resolveVars(s);
+       }
+
 
        
//--------------------------------------------------------------------------------
        // Other methods

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/703cadd2/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 637dc7e..2d50376 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
@@ -21,10 +21,13 @@ import javax.servlet.http.*;
 
 import org.apache.juneau.*;
 import org.apache.juneau.encoders.*;
+import org.apache.juneau.html.*;
 import org.apache.juneau.jena.*;
 import org.apache.juneau.json.*;
+import org.apache.juneau.rest.annotation.*;
 import org.apache.juneau.serializer.*;
 import org.apache.juneau.urlencoding.*;
+import org.apache.juneau.utils.*;
 import org.apache.juneau.xml.*;
 
 /**
@@ -40,7 +43,7 @@ import org.apache.juneau.xml.*;
  * <p class='bcode'>
  *     <ja>@RestMethod</ja>(name=<js>"GET"</js>)
  *     <jk>public void</jk> doGet(RestRequest req, RestResponse res) {
- *             res.setProperty(HtmlSerializerContext.<jsf>HTMLDOC_title</jsf>, 
<js>"My title"</js>)
+ *             res.setPageTitle(<js>"My title"</js>)
  *                     .setOutput(<js>"Simple string response"</js>);
  *     }
  * </p>
@@ -413,4 +416,63 @@ public final class RestResponse extends 
HttpServletResponseWrapper {
                else
                        super.setHeader(name, value);
        }
-}
+
+       /**
+        * Sets the page title for HTML views.
+        * <p>
+        * This is the programmatic equivalent to the {@link 
RestResource#pageTitle() @RestResource#pageTitle()}/
+        * {@link RestMethod#pageTitle() @RestMethod#pageTitle()} annotations.
+        * <p>
+        * This is a shortcut for calling 
<code>setProperty(<jsf>HTMLDOC_title</jsf>, title);</code>
+        * <p class='info'>
+        *      <b>Tip:</b>  Use {@link StringMessage} to generate a page title 
with delayed serialization so as not to
+        *      waste string concatenation cycles on non-HTML views.
+        * </p>
+        *
+        * @param title The localized page title to render on the page.
+        * Object will be converted to a string using {@link Object#toString()}.
+        * @return This object (for method chaining).
+        */
+       public RestResponse setPageTitle(Object title) {
+               return setProperty(HtmlDocSerializerContext.HTMLDOC_title, 
title);
+       }
+
+       /**
+        * Sets the page text for HTML views.
+        * <p>
+        * This is the programmatic equivalent to the {@link 
RestResource#pageText() @RestResource#pageText()}/
+        * {@link RestMethod#pageText() @RestMethod#pageText()} annotations.
+        * <p>
+        * This is a shortcut for calling 
<code>setProperty(<jsf>HTMLDOC_text</jsf>, text);</code>
+        * <p class='info'>
+        *      <b>Tip:</b>  Use {@link StringMessage} to generate page text 
with delayed serialization so as not to
+        *      waste string concatenation cycles on non-HTML views.
+        * </p>
+        *
+        * @param text The localized page text to render on the page.
+        * @return This object (for method chaining).
+        */
+       public RestResponse setPageText(Object text) {
+               return setProperty(HtmlDocSerializerContext.HTMLDOC_text, text);
+       }
+
+       /**
+        * Sets the page text for HTML views.
+        * <p>
+        * This is the programmatic equivalent to the {@link 
RestResource#pageLinks() @RestResource#pageLinks()}/
+        * {@link RestMethod#pageLinks() @RestMethod#pageLinks()} annotations.
+        * <p>
+        * This is a shortcut for calling 
<code>setProperty(<jsf>HTMLDOC_links</jsf>, links);</code>
+        * <p class='info'>
+        *      <b>Tip:</b>  Use {@link StringMessage} to generate page links 
with delayed serialization so as not to
+        *      waste string concatenation cycles on non-HTML views.
+        * </p>
+        *
+        * @param links The localized page links render on the page.
+        * @return This object (for method chaining).
+        */
+       public RestResponse setPageLinks(Object links) {
+               properties.put(HtmlDocSerializerContext.HTMLDOC_links, links);
+               return this;
+       }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/703cadd2/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 8117108..51252b2 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
@@ -12,7 +12,6 @@
 // 
***************************************************************************************************************************
 package org.apache.juneau.rest;
 
-import static org.apache.juneau.html.HtmlDocSerializerContext.*;
 import static org.apache.juneau.rest.RestContext.*;
 
 import org.apache.juneau.dto.swagger.*;
@@ -183,10 +182,6 @@ import org.apache.juneau.xml.*;
        properties={
                // Allow &method parameter on safe HTTP methods.
                @Property(name=REST_allowMethodParam, value="OPTIONS"),
-               // Provide a default title on HTML pages.
-               @Property(name=HTMLDOC_title, value="$R{servletTitle}"),
-               // Provide a default description on HTML pages.
-               @Property(name=HTMLDOC_description, 
value="$R{servletDescription}")
        },
        stylesheet="styles/juneau.css",
        favicon="juneau.png",
@@ -202,11 +197,9 @@ public abstract class RestServletDefault extends 
RestServlet {
         * @return A bean containing the contents for the OPTIONS page.
         */
        @RestMethod(name="OPTIONS", path="/*",
-               properties={
-                       @Property(name=HTMLDOC_links, 
value="{back:'$R{servletURI}'}"),
-                       @Property(name=HTMLDOC_description, value="Resource 
options")
-               },
-               description="Resource options"
+               pageLinks="{back:'$R{servletURI}'}",
+               summary="Resource options",
+               description="Description of this resource"
        )
        public Swagger getOptions(RestRequest req) {
                return req.getSwagger();

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/703cadd2/juneau-rest/src/main/java/org/apache/juneau/rest/annotation/RestMethod.java
----------------------------------------------------------------------
diff --git 
a/juneau-rest/src/main/java/org/apache/juneau/rest/annotation/RestMethod.java 
b/juneau-rest/src/main/java/org/apache/juneau/rest/annotation/RestMethod.java
index 4270a38..986aa74 100644
--- 
a/juneau-rest/src/main/java/org/apache/juneau/rest/annotation/RestMethod.java
+++ 
b/juneau-rest/src/main/java/org/apache/juneau/rest/annotation/RestMethod.java
@@ -50,6 +50,7 @@ public @interface RestMethod {
         *      <li><js>""</js> - Auto-detect.
         *              <br>The method name is determined based on the Java 
method name.
         *              <br>For example, if the method is 
<code>doPost(...)</code>, then the method name is automatically detected as 
<js>"POST"</js>.
+        *              <br>Otherwise, defaults to <js>"GET"</js>.
         *      <li><js>"PROXY"</js> - Remote-proxy interface.
         *              <br>This denotes a Java method that returns an object 
(usually an interface, often annotated with the {@link Remoteable @Remoteable} 
annotation)
         *              to be used as a remote proxy using 
<code>RestClient.getRemoteableProxy(Class<T> interfaceClass, String url)</code>.
@@ -518,7 +519,17 @@ public @interface RestMethod {
        String clientVersion() default "";
 
        /**
-        * TODO
+        * Overrides the HTML page title defined on the servlet via the {@link 
RestResource#pageTitle() @RestResource.pageTitle()} annotation.
         */
-       String[] links() default "";
+       String pageTitle() default "";
+
+       /**
+        * Overrides the HTML page text defined on the servlet via the {@link 
RestResource#pageText() @RestResource.pageText()} annotation.
+        */
+       String pageText() default "";
+
+       /**
+        * Overrides the HTML page links defined on the servlet via the {@link 
RestResource#pageLinks() @RestResource.pageLinks()} annotation.
+        */
+       String pageLinks() default "";
 }

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/703cadd2/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 b49bdd3..8492770 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
@@ -21,6 +21,7 @@ import javax.servlet.http.*;
 
 import org.apache.juneau.*;
 import org.apache.juneau.encoders.Encoder;
+import org.apache.juneau.html.*;
 import org.apache.juneau.ini.*;
 import org.apache.juneau.jena.*;
 import org.apache.juneau.json.*;
@@ -315,7 +316,7 @@ public @interface RestResource {
        /**
         * Optional servlet title.
         * <p>
-        * It is used to populate the Swagger title field and to display on 
HTML pages.
+        * It is used to populate the Swagger title field and as a default 
value for the {@link #pageTitle()} value.
         * This value can be retrieved programmatically through the {@link 
RestRequest#getServletTitle()} method.
         * <p>
         * The default value pulls the label from the <code>label</code> entry 
in the servlet resource bundle.
@@ -332,7 +333,7 @@ public @interface RestResource {
        /**
         * Optional servlet description.
         * <p>
-        * It is used to populate the Swagger description field and to display 
on HTML pages.
+        * It is used to populate the Swagger description field and as a 
default value for the {@link #pageText()} value.
         * This value can be retrieved programmatically through the {@link 
RestRequest#getServletDescription()} method.
         * <p>
         * The default value pulls the description from the 
<code>description</code> entry in the servlet resource bundle.
@@ -695,7 +696,103 @@ public @interface RestResource {
        Class<? extends RestInfoProvider> infoProvider() default 
RestInfoProvider.class;
 
        /**
-        * TODO
+        * Specifies the page title to use on the HTML view of all pages 
produced by this resource.
+        * <p>
+        * This annotation has no effect on any serializers other than {@link 
HtmlDocSerializer} and is a shorthand method
+        * for setting the {@link HtmlDocSerializerContext#HTMLDOC_title} 
property:
+        * <p class='bcode'>
+        *      <ja>@RestResource</ja>(
+        *              properties={
+        *                      
<ja>@Property</ja>(name=<jsf>HTMLDOC_title</jsf>, value=<js>"My Resource 
Page"</js>)
+        *              }
+        *      )
+        *      <jk>public class</jk> MyResource <jk>extends</jk> 
RestServletDefault {
+        * </p>
+        * <p>
+        * If not specified, the page title is pulled from one of the following 
locations:
+        * <ol>
+        *      <li><code>{servletClass}.{methodName}.pageTitle</code> resource 
bundle value.
+        *      <li><code>{servletClass}.pageTitle</code> resource bundle value.
+        *      <li><code><ja>@RestResource</ja>(title)</code> annotation.
+        *      <li><code>{servletClass}.title</code> resource bundle value.
+        *      <li><code>info/title</code> entry in swagger file.
+        * <ol>
+        * <p>
+        * This field can contain variables (e.g. 
<js>"$L{my.localized.variable}"</js>).
+        * <p>
+        * The programmatic equivalent to this annotation are the {@link 
RestConfig#setPageTitle(String)}/{@link RestResponse#setPageTitle(Object)} 
methods.
+        * <p class='info'>
+        *      In most cases, you'll simply want to use the 
<code>@RestResource(title)</code> annotation to specify the page title.
+        *      However, this annotation is provided in cases where you want 
the page title to be different that the one
+        *      shown in the swagger document.
+        * </p>
+        * <b>Note:</b> - In most cases, you can
+        */
+       String pageTitle() default "";
+
+       /**
+        * Specifies the page text to use on the HTML view of all pages 
produced by this resource.
+        * <p>
+        * The page text is portion of the page immediately under the title and 
above the links.
+        * <p>
+        * This annotation has no effect on any serializers other than {@link 
HtmlDocSerializer} and is a shorthand method
+        * for setting the {@link HtmlDocSerializerContext#HTMLDOC_text} 
property:
+        * <p class='bcode'>
+        *      <ja>@RestResource</ja>(
+        *              properties={
+        *                      
<ja>@Property</ja>(name=<jsf>HTMLDOC_text</jsf>, value=<js>"This is my awesome 
resource page"</js>)
+        *              }
+        *      )
+        *      <jk>public class</jk> MyResource <jk>extends</jk> 
RestServletDefault {
+        * </p>
+        * If not specified, the page title is pulled from one of the following 
locations:
+        * <ol>
+        *      <li><code>{servletClass}.{methodName}.pageText</code> resource 
bundle value.
+        *      <li><code>{servletClass}.pageText</code> resource bundle value.
+        *      <li><code><ja>@RestMethod</ja>(summary)</code> annotation.
+        *      <li><code>{servletClass}.{methodName}.summary</code> resource 
bundle value.
+        *      <li><code>summary</code> entry in swagger file for method.
+        *      <li><code>{servletClass}.description</code> resource bundle 
value.
+        *      <li><code>info/description</code> entry in swagger file.
+        * <ol>
+        * <p>
+        * This field can contain variables (e.g. 
<js>"$L{my.localized.variable}"</js>).
+        * <p>
+        * The programmatic equivalent to this annotation are the {@link 
RestConfig#setPageText(String)}/{@link RestResponse#setPageText(Object)} 
methods.
+        * <p class='info'>
+        *      In most cases, you'll simply want to use the 
<code>@RestResource(description)</code> or <code>@RestMethod(summary)</code> 
annotations to specify the page text.
+        *      However, this annotation is provided in cases where you want 
the text to be different that the values shown in the swagger document.
+        * </p>
+        */
+       String pageText() default "";
+
+       /**
+        * Specifies the page hyperlinks to use on the HTML view of all pages 
produced by this resource.
+        * <p>
+        * The page links is positioned immediately under the title and text.
+        * <p>
+        * This annotation has no effect on any serializers other than {@link 
HtmlDocSerializer} and is a shorthand method
+        * for setting the {@link HtmlDocSerializerContext#HTMLDOC_text} 
property:
+        * <p class='bcode'>
+        *      <ja>@RestResource</ja>(
+        *              properties={
+        *                      
<ja>@Property</ja>(name=<jsf>HTMLDOC_links</jsf>, 
value=<js>"{up:'$R{requestParentURI}',options:'?method=OPTIONS'}"</js>)
+        *              }
+        *      )
+        *      <jk>public class</jk> MyResource <jk>extends</jk> 
RestServletDefault {
+        * </p>
+        * <p>
+        * The format of this value is a lax-JSON string of key/value pairs 
where the keys are the link text and the values are relative (to the servlet) or
+        * absolute URLs.
+        * If not specified, the page title is pulled from one of the following 
locations:
+        * <ol>
+        *      <li><code>{servletClass}.{methodName}.pageLinks</code> resource 
bundle value.
+        *      <li><code>{servletClass}.pageLinks</code> resource bundle value.
+        * <ol>
+        * <p>
+        * This field can contain variables (e.g. 
<js>"$L{my.localized.variable}"</js>).
+        * <p>
+        * The programmatic equivalent to this annotation are the {@link 
RestConfig#setPageLinks(String)}/{@link RestResponse#setPageLinks(Object)} 
methods.
         */
-       String[] links() default "";
+       String pageLinks() default "";
 }

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/703cadd2/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 be489da..4b26bcb 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
@@ -12,7 +12,6 @@
 // 
***************************************************************************************************************************
 package org.apache.juneau.rest.jena;
 
-import static org.apache.juneau.html.HtmlDocSerializerContext.*;
 import static org.apache.juneau.rest.RestContext.*;
 
 import org.apache.juneau.dto.swagger.*;
@@ -223,11 +222,7 @@ import org.apache.juneau.xml.*;
        },
        properties={
                // Allow &method parameter on safe HTTP methods.
-               @Property(name=REST_allowMethodParam, value="OPTIONS"),
-               // Provide a default title on HTML pages.
-               @Property(name=HTMLDOC_title, value="$R{servletTitle}"),
-               // Provide a default description on HTML pages.
-               @Property(name=HTMLDOC_description, 
value="$R{servletDescription}")
+               @Property(name=REST_allowMethodParam, value="OPTIONS")
        },
        stylesheet="styles/juneau.css",
        favicon="juneau.ico",
@@ -243,10 +238,8 @@ public abstract class RestServletJenaDefault extends 
RestServlet {
         * @return The bean containing the contents of the OPTIONS page.
         */
        @RestMethod(name="OPTIONS", path="/*",
-               properties={
-                       @Property(name=HTMLDOC_links, 
value="{back:'$R{servletURI}'}"),
-                       @Property(name=HTMLDOC_description, value="Resource 
options")
-               },
+               summary="Resource options",
+               pageLinks="{back:'$R{servletURI}'}",
                description="Resource options"
        )
        public Swagger getOptions(RestRequest req) {

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/703cadd2/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 6b08a70..f6f9cb4 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
@@ -226,9 +226,7 @@
         */</jd>
        <ja>@RestResource</ja>(
                messages=<js>"nls/HelloWorldResource"</js>, 
-               properties={
-                       <ja>@Property</ja>(name=<jsf>HTMLDOC_links</jsf>, 
value=<js>"{up:'$R{requestParentURI}',options:'?method=OPTIONS'}"</js>)
-               }
+               
pageLinks=<js>"{up:'$R{requestParentURI}',options:'?method=OPTIONS'}"</js>
        )
        <jk>public class</jk> HelloWorldResource <jk>extends</jk> Resource {
        
@@ -1037,11 +1035,8 @@
         * <ja>@return</ja> A bean containing the contents for the OPTIONS page.
         */</jd>
        <ja>@RestMethod</ja>(name=<js>"OPTIONS"</js>, path=<js>"/*"</js>,
-               properties={
-                       <ja>@Property</ja>(name=<jsf>HTMLDOC_links</jsf>, 
value=<js>"{back:'$R{servletURI}'}"</js>),
-                       <ja>@Property</ja>(name=<jsf>HTMLDOC_description</jsf>, 
value=<js>"Resource options"</js>)
-               },
-               description=<js>"Resource options"</js>
+               summary=<js>"Resource options"</js>,
+               pageLinks=<js>"{back:'$R{servletURI}'}"</js>
        )
        <jk>public</jk> Swagger getOptions(RestRequest req) {
                <jk>return</jk> req.getSwagger();
@@ -1116,12 +1111,8 @@
                </p>
                <p class='bcode'>
        <ja>@RestResource</ja>(
-               properties={
-                       <jc>// Provide a default title on HTML pages.</jc>
-                       <ja>@Property</ja>(name=<jsf>HTMLDOC_title</jsf>, 
value=<js>"$R{servletTitle}"</js>),
-                       <jc>// Provide a default description on HTML pages.</jc>
-                       <ja>@Property</ja>(name=<jsf>HTMLDOC_description</jsf>, 
value=<js>"$R{servletDescription}"</js>)
-               }
+               pageTitle=<js>"The title for this page is 
$R{servletTitle}"</js>,
+               pageText=<js>"The description for this page is 
$R{servletDescription}"</js>
        )
        <jk>public abstract class</jk> RestServletDefault <jk>extends</jk> 
RestServlet {
                </p>
@@ -1430,6 +1421,7 @@
                                
value=<js>"{jp06:'http://jazz.net/xmlns/prod/jazz/process/0.6/',jp:'http://jazz.net/xmlns/prod/jazz/process/1.0/'}"</js>),
 
                        <jc>// Specify a default title for the HtmlSerializer 
serializer</jc>
+                       <jc>// This is equivalent to 
@RestResource(title/pageTitle)</jc>
                        <ja>@Property</ja>(name=<jsf>HTMLDOC_title</jsf>, 
value=<js>"My resource"</js>)
                }
        )
@@ -1457,6 +1449,7 @@
                                
value=<js>"{jp06:'http://jazz.net/xmlns/prod/jazz/process/0.6/',jp:'http://jazz.net/xmlns/prod/jazz/process/1.0/'}"</js>),
 
                        <jc>// Specify a default title for the HtmlSerializer 
serializer</jc>
+                       <jc>// This is equivalent to @RestMethod(pageTitle)</jc>
                        <ja>@Property</ja>(name=<jsf>HTMLDOC_title</jsf>, 
value=<js>"My resource"</js>)
                }
        <jk>public</jk> Object doGet() {
@@ -1753,10 +1746,6 @@
         */</jd>
        <ja>@RestResource</ja>(
                path=<js>"/"</js>,
-               messages=<js>"nls/RootResources"</js>,
-               properties={
-                       <ja>@Property</ja>(name=HTMLDOC_links, 
value=<js>"{options:'$R{servletURI}?method=OPTIONS',source:'$R{servletURI}/source?classes=(org.apache.juneau.rest.samples.RootResources)'}"</js>)
-               },
                children={
                        HelloWorldResource.<jk>class</jk>,
                        MethodExampleResource.<jk>class</jk>,
@@ -1905,9 +1894,6 @@
                <p class='bcode'>
        <ja>@RestResource</ja>(
                title=<js>"$L{my.label}"</js>
-               properties={
-                       <ja>@Property</ja>(name=<jsf>HTMLDOC_links</jsf>, 
value=<js>"{options:'$R{servletURI}?method=OPTIONS'"</js>)
-               }
     )
                </p>
                <p>
@@ -2136,11 +2122,9 @@
        <ja>@RestResource</ja>(
                path=<js>"/urlEncodedForm"</js>, 
                messages=<js>"nls/UrlEncodedFormResource"</js>, 
-               properties={
-                       <ja>@Property</ja>(name=HTMLDOC_title, 
value=<js>"URL-encoded Form Post Resource"</js>), 
-                       <ja>@Property</ja>(name=HTMLDOC_description, 
value=<js>"Shows how form posts are converted into beans."</js>), 
-                       <ja>@Property</ja>(name=HTMLDOC_links, 
value=<js>"{up:'$R{requestParentURI}',options:'?method=OPTIONS',source:'$R{servletParentURI}/source?classes=(org.apache.juneau.rest.samples.UrlEncodedFormResource)'}"</js>)
 
-               } 
+               title=<js>"URL-encoded Form Post Resource"</js>, 
+               description=<js>"Shows how form posts are converted into 
beans."</js>, 
+               
pageLinks=<js>"{up:'$R{requestParentURI}',options:'?method=OPTIONS'}"</js> 
        ) 
        <jk>public class</jk> UrlEncodedFormResource <jk>extends</jk> Resource 
{ 
                <jk>private static final long</jk> <jsf>serialVersionUID</jsf> 
= 1L; 
@@ -2893,11 +2877,9 @@
        <ja>@RestResource</ja>(
                path=<js>"/photos"</js>,
                messages=<js>"nls/PhotosResource"</js>,
-               properties={
-                       
<ja>@Property</ja>(name=HtmlDocSerializerContext.<jsf>HTMLDOC_links</jsf>, 
value=<js>"{options:'?method=OPTIONS'}"</js>),
-                       
<ja>@Property</ja>(name=HtmlDocSerializerContext.<jsf>HTMLDOC_title</jsf>, 
value=<js>"Photo REST service"</js>),
-                       
<ja>@Property</ja>(name=HtmlDocSerializerContext.<jsf>HTMLDOC_description</jsf>,
 value=<js>"Use a tool like Poster to upload and retrieve jpeg and png 
images."</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>
        )
        <jk>public class</jk> PhotosResource <jk>extends</jk> 
RestServletDefault {
        
@@ -2926,8 +2908,8 @@
                <jd>/** GET request handler for list of all photos */</jd>
                <ja>@RestMethod</ja>(name=<js>"GET"</js>, path=<js>"/"</js>)
                <jk>public</jk> Collection&lt;Photo&gt; 
getAllPhotos(RestRequest req, RestResponse res) <jk>throws</jk> Exception {
-                       
res.setProperty(HtmlDocSerializerContext.<jsf>HTMLDOC_title</jsf>, <js>"Photo 
REST service"</js>);
-                       
res.setProperty(HtmlDocSerializerContext.<jsf>HTMLDOC_description</jsf>, 
<js>"Use a tool like Poster to upload and retrieve jpeg and png images."</js>);
+                       res.setPageTitle(<js>"Photo REST service"</js>);
+                       res.setPageText(<js>"Use a tool like Poster to upload 
and retrieve jpeg and png images."</js>);
                        <jk>return</jk> photos.values();
                }
                
@@ -3187,13 +3169,13 @@
        <ja>@RestResource</ja>( 
                path=<js>"/addressBook"</js>, 
                messages=<js>"nls/AddressBookResource"</js>, 
+               
pageLinks=<js>"{up:'$R{requestParentURI}',options:'?method=OPTIONS'}"</js>, 
                properties={ 
                        
<ja>@Property</ja>(name=<jsf>REST_allowMethodParam</jsf>, value=<js>"*"</js>), 
                        <ja>@Property</ja>(name=<jsf>HTML_uriAnchorText</jsf>, 
value=<jsf>TO_STRING</jsf>), 
                        
<ja>@Property</ja>(name=<jsf>SERIALIZER_quoteChar</jsf>, value=<js>"'"</js>), 
                        <ja>@Property</ja>(name=<jsf>RDF_rdfxml_tab</jsf>, 
value=<js>"5"</js>), 
                        <ja>@Property</ja>(name=<jsf>RDF_addRootProperty</jsf>, 
value=<js>"true"</js>), 
-                       <ja>@Property</ja>(name=<jsf>HTMLDOC_links</jsf>, 
value=<js>"{up:'$R{requestParentURI}',options:'$R{servletURI}?method=OPTIONS',source:'$R{servletParentURI}/source?classes=(org.apache.juneau.rest.samples.addressbook.AddressBookResource,org.apache.juneau.examples.addressbook.Address,org.apache.juneau.examples.addressbook.AddressBook,org.apache.juneau.examples.addressbook.CreateAddress,org.apache.juneau.examples.addressbook.CreatePerson,org.apache.juneau.examples.addressbook.IAddressBook,org.apache.juneau.examples.addressbook.Person)'}"</js>),
 
                        <jc>// Resolve all relative URIs so that they're 
relative to this servlet!</jc> 
                        
<ja>@Property</ja>(name=<jsf>SERIALIZER_relativeUriBase</jsf>, 
value=<js>"$R{servletURI}"</js>), 
                }, 


Reply via email to