Repository: juneau
Updated Branches:
refs/heads/master 4f9c8f6cc -> 172a2e553
Fix bug where $R{servletDescription} shows up on examples pages.
Project: http://git-wip-us.apache.org/repos/asf/juneau/repo
Commit: http://git-wip-us.apache.org/repos/asf/juneau/commit/172a2e55
Tree: http://git-wip-us.apache.org/repos/asf/juneau/tree/172a2e55
Diff: http://git-wip-us.apache.org/repos/asf/juneau/diff/172a2e55
Branch: refs/heads/master
Commit: 172a2e553d2d4531353407dc0025d32cd5fda0cf
Parents: 4f9c8f6
Author: JamesBognar <[email protected]>
Authored: Sun Dec 24 15:35:24 2017 -0500
Committer: JamesBognar <[email protected]>
Committed: Sun Dec 24 15:35:24 2017 -0500
----------------------------------------------------------------------
juneau-core/juneau-marshall/TODO.txt | 3 +-
.../juneau/svl/MultipartResolvingVar.java | 52 ++++++++
.../juneau/svl/vars/CoalesceAndRecurseVar.java | 44 +++++++
.../org/apache/juneau/svl/vars/CoalesceVar.java | 54 +++++++++
juneau-doc/src/main/javadoc/overview.html | 25 +++-
.../org/apache/juneau/microservice/package.html | 32 ++---
.../resources/DirectoryResource.java | 2 +-
.../org/apache/juneau/rest/RestContext.java | 11 +-
.../org/apache/juneau/rest/RestRequest.java | 121 -------------------
.../apache/juneau/rest/RestServletDefault.java | 2 +-
.../java/org/apache/juneau/rest/package.html | 64 ++++++++--
.../juneau/rest/vars/RequestAttributeVar.java | 69 +++++++++++
.../juneau/rest/vars/RequestFormDataVar.java | 66 ++++++++++
.../juneau/rest/vars/RequestHeaderVar.java | 70 +++++++++++
.../apache/juneau/rest/vars/RequestPathVar.java | 66 ++++++++++
.../juneau/rest/vars/RequestQueryVar.java | 66 ++++++++++
.../org/apache/juneau/rest/vars/RequestVar.java | 75 +++++++-----
.../juneau/rest/widget/QueryMenuItem.html | 10 +-
18 files changed, 629 insertions(+), 203 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/juneau/blob/172a2e55/juneau-core/juneau-marshall/TODO.txt
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/TODO.txt
b/juneau-core/juneau-marshall/TODO.txt
index f314bd6..4beb978 100644
--- a/juneau-core/juneau-marshall/TODO.txt
+++ b/juneau-core/juneau-marshall/TODO.txt
@@ -14,4 +14,5 @@
Create tests that ensure serializers don't close output but parsers do close
input.
$R{servletDescription} tags showing up in REST examples.
-Examples should use dark LAF.
\ No newline at end of file
+Examples should use dark LAF.
+Content tests on examples rest.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/juneau/blob/172a2e55/juneau-core/juneau-svl/src/main/java/org/apache/juneau/svl/MultipartResolvingVar.java
----------------------------------------------------------------------
diff --git
a/juneau-core/juneau-svl/src/main/java/org/apache/juneau/svl/MultipartResolvingVar.java
b/juneau-core/juneau-svl/src/main/java/org/apache/juneau/svl/MultipartResolvingVar.java
new file mode 100644
index 0000000..b4c8d9b
--- /dev/null
+++
b/juneau-core/juneau-svl/src/main/java/org/apache/juneau/svl/MultipartResolvingVar.java
@@ -0,0 +1,52 @@
+//
***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright
ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance *
+// * with the License. You may obtain a copy of the License at
*
+// *
*
+// * http://www.apache.org/licenses/LICENSE-2.0
*
+// *
*
+// * Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express or implied. See the License for the *
+// * specific language governing permissions and limitations under the
License. *
+//
***************************************************************************************************************************
+package org.apache.juneau.svl;
+
+import static org.apache.juneau.internal.StringUtils.*;
+
+/**
+ * Interface for the resolution of vars that can have one or more keys where
the first non-null resolution is returned.
+ *
+ * <p>
+ * For example, to resolve the system property <js>"myProperty"</js> but then
resolve <js>"myProperty2"</js> if the
+ * property doesn't exist: <js>"$S{myProperty1,myProperty2}"</js>
+ *
+ * <p>
+ * Subclasses must implement the {@link #resolve(VarResolverSession, String)}
method.
+ *
+ * @see org.apache.juneau.svl
+ */
+public abstract class MultipartResolvingVar extends SimpleVar {
+
+ /**
+ * Constructor.
+ *
+ * @param name The name of this variable.
+ */
+ public MultipartResolvingVar(String name) {
+ super(name);
+ }
+
+ @Override /* Var*/
+ public String doResolve(VarResolverSession session, String s) throws
Exception {
+ int i = s.indexOf(',');
+ if (i == -1)
+ return resolve(session, s.trim());
+ for (String s2 : split(s)) {
+ String v = resolve(session, s2);
+ if (v != null)
+ return v;
+ }
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/juneau/blob/172a2e55/juneau-core/juneau-svl/src/main/java/org/apache/juneau/svl/vars/CoalesceAndRecurseVar.java
----------------------------------------------------------------------
diff --git
a/juneau-core/juneau-svl/src/main/java/org/apache/juneau/svl/vars/CoalesceAndRecurseVar.java
b/juneau-core/juneau-svl/src/main/java/org/apache/juneau/svl/vars/CoalesceAndRecurseVar.java
new file mode 100644
index 0000000..bcfda2c
--- /dev/null
+++
b/juneau-core/juneau-svl/src/main/java/org/apache/juneau/svl/vars/CoalesceAndRecurseVar.java
@@ -0,0 +1,44 @@
+//
***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright
ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance *
+// * with the License. You may obtain a copy of the License at
*
+// *
*
+// * http://www.apache.org/licenses/LICENSE-2.0
*
+// *
*
+// * Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express or implied. See the License for the *
+// * specific language governing permissions and limitations under the
License. *
+//
***************************************************************************************************************************
+package org.apache.juneau.svl.vars;
+
+import org.apache.juneau.svl.*;
+
+/**
+ * A basic variable resolver that returns the first non-null value.
+ *
+ * <p>
+ * The format for this var is <js>"$CR{arg1[,arg2...]}"</js>.
+ *
+ * <p>
+ * The difference between {@link CoalesceVar} and {@link
CoalesceAndRecurseVar} is that the first will not resolve
+ * inner variables nor recursively resolve variables, and the second will.
+ * Use {@link CoalesceVar} when resolving user-input.
+ */
+public class CoalesceAndRecurseVar extends MultipartResolvingVar {
+
+ /** The name of this variable. */
+ public static final String NAME = "CR";
+
+ /**
+ * Constructor.
+ */
+ public CoalesceAndRecurseVar() {
+ super(NAME);
+ }
+
+ @Override
+ public String resolve(VarResolverSession session, String arg) throws
Exception {
+ return arg;
+ }
+}
http://git-wip-us.apache.org/repos/asf/juneau/blob/172a2e55/juneau-core/juneau-svl/src/main/java/org/apache/juneau/svl/vars/CoalesceVar.java
----------------------------------------------------------------------
diff --git
a/juneau-core/juneau-svl/src/main/java/org/apache/juneau/svl/vars/CoalesceVar.java
b/juneau-core/juneau-svl/src/main/java/org/apache/juneau/svl/vars/CoalesceVar.java
new file mode 100644
index 0000000..cbc198a
--- /dev/null
+++
b/juneau-core/juneau-svl/src/main/java/org/apache/juneau/svl/vars/CoalesceVar.java
@@ -0,0 +1,54 @@
+//
***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright
ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance *
+// * with the License. You may obtain a copy of the License at
*
+// *
*
+// * http://www.apache.org/licenses/LICENSE-2.0
*
+// *
*
+// * Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express or implied. See the License for the *
+// * specific language governing permissions and limitations under the
License. *
+//
***************************************************************************************************************************
+package org.apache.juneau.svl.vars;
+
+import org.apache.juneau.svl.*;
+
+/**
+ * A basic variable resolver that returns the first non-null value.
+ *
+ * <p>
+ * The format for this var is <js>"$CO{arg1[,arg2...]}"</js>.
+ *
+ * <p>
+ * The difference between {@link CoalesceVar} and {@link
CoalesceAndRecurseVar} is that the first will not resolve
+ * inner variables nor recursively resolve variables, and the second will.
+ * Use {@link CoalesceVar} when resolving user-input.
+ */
+public class CoalesceVar extends MultipartResolvingVar {
+
+ /** The name of this variable. */
+ public static final String NAME = "CO";
+
+ /**
+ * Constructor.
+ */
+ public CoalesceVar() {
+ super(NAME);
+ }
+
+ @Override
+ public String resolve(VarResolverSession session, String arg) throws
Exception {
+ return arg;
+ }
+
+ @Override /* Var */
+ protected boolean allowNested() {
+ return false;
+ }
+
+ @Override /* Var */
+ protected boolean allowRecurse() {
+ return false;
+ }
+}
http://git-wip-us.apache.org/repos/asf/juneau/blob/172a2e55/juneau-doc/src/main/javadoc/overview.html
----------------------------------------------------------------------
diff --git a/juneau-doc/src/main/javadoc/overview.html
b/juneau-doc/src/main/javadoc/overview.html
index c8df5ea..ec2825e 100644
--- a/juneau-doc/src/main/javadoc/overview.html
+++ b/juneau-doc/src/main/javadoc/overview.html
@@ -7493,7 +7493,7 @@
<p class='bcode'>
<jk>public</jk> String doUnsafeGet(RestRequest req) {
<jc>// Security hole!</jc>
- <jk>return</jk>
req.getVarResolver().resolve(<js>"$R{Query.foo}"</js>);
+ <jk>return</jk>
req.getVarResolver().resolve(<js>"$RQ{foo}"</js>);
}
</p>
<p>
@@ -7550,7 +7550,7 @@
<h5 class='toc'>What's new in each release</h5>
<ul class='toc'>
<li><p><a class='doclink' href='#7.0.1'>7.0.2 (TBD)</a></p>
- <li><p><a class='doclink' href='#7.0.1'>7.0.1 (TBD)</a></p>
+ <li><p><a class='doclink' href='#7.0.1'>7.0.1 (Dec 24,
2017)</a></p>
<li><p><a class='doclink' href='#7.0.0'>7.0.0 (Oct 25,
2017)</a></p>
<li><p><a class='doclink' href='#6.4.0'>6.4.0 (Oct 5,
2017)</a></p>
<li><p><a class='doclink' href='#6.3.1'>6.3.1 (Aug 1,
2017)</a></p>
@@ -7700,7 +7700,14 @@
class.
<br>The previous
<code>PropertyStore</code> class was overly-complicated with many read/write
locks to ensure thread-safety.
- <br>The new design shifts to a
builder-based model with read-only <code>PropertyStore</code> objects.
+ <br>The new design shifts to a
builder-based model with read-only <code>PropertyStore</code> objects
+ that can be used as hash keys.
+ </ul>
+ <li>
+ New SVL variables:
+ <ul>
+ <li>{@link
org.apache.juneau.svl.vars.CoalesceVar}
+ <li>{@link
org.apache.juneau.svl.vars.CoalesceAndRecurseVar}
</ul>
</ul>
@@ -7714,6 +7721,16 @@
<h6 class='topic'>juneau-rest-server</h6>
<ul class='spaced-list'>
+ <li>
+ The <js>"$R{...}"</js> variable has been split
into the following:
+ <ul>
+ <li><js>"$RA{key1[,key2...]}"</js> -
{@link org.apache.juneau.rest.vars.RequestAttributeVar}
+ <li><js>"$RF{key1[,key2...]}"</js> -
{@link org.apache.juneau.rest.vars.RequestFormDataVar}
+ <li><js>"$RH{key1[,key2...]}"</js> -
{@link org.apache.juneau.rest.vars.RequestHeaderVar}
+ <li><js>"$RP{key1[,key2...]}"</js> -
{@link org.apache.juneau.rest.vars.RequestPathVar}
+ <li><js>"$RQ{key1[,key2...]}"</js> -
{@link org.apache.juneau.rest.vars.RequestQueryVar}
+ <li><js>"$R{key1[,key2...]}"</js> -
{@link org.apache.juneau.rest.vars.RequestVar}
+ </ul>
</ul>
<h6 class='topic'>juneau-microservice-server</h6>
@@ -8571,7 +8588,7 @@
htmldoc=<ja>@HtmlDoc</ja>(
header={
<js>"<h1>$R{servletTitle}</h1>"</js>,
-
<js>"<h2>$R{methodSummary,$R{servletDescription}}</h2>"</js>,
+
<js>"<h2>$R{methodSummary,servletDescription}</h2>"</js>,
<js>"<a href='http://juneau.apache.org'><img
src='$U{servlet:/htdocs/juneau.png}'
style='position:absolute;top:5;right:5;background-color:transparent;height:30px'/></a>"</js>
}
)
http://git-wip-us.apache.org/repos/asf/juneau/blob/172a2e55/juneau-microservice/juneau-microservice-server/src/main/java/org/apache/juneau/microservice/package.html
----------------------------------------------------------------------
diff --git
a/juneau-microservice/juneau-microservice-server/src/main/java/org/apache/juneau/microservice/package.html
b/juneau-microservice/juneau-microservice-server/src/main/java/org/apache/juneau/microservice/package.html
index 628b6eb..6aef83c 100755
---
a/juneau-microservice/juneau-microservice-server/src/main/java/org/apache/juneau/microservice/package.html
+++
b/juneau-microservice/juneau-microservice-server/src/main/java/org/apache/juneau/microservice/package.html
@@ -702,26 +702,12 @@
<ul>
<li><l>$L{key}, $L{key,args}</l> -
Localized variables pulled from
{@link
org.apache.juneau.rest.RestRequest#getMessage(String, Object...)}.
- <li><l>$R{key}</l> - Request variables.
- <ul>
- <li><l>$R{attribute.X}</l> -
Value returned by {@link
org.apache.juneau.rest.RestRequest#getAttribute(String)} converted to a string.
- <li><l>$R{contextPath}</l> -
Value returned by {@link org.apache.juneau.rest.RestRequest#getContextPath()}.
- <li><l>$R{formData.X}</l> -
Value returned by {@link
org.apache.juneau.rest.RequestFormData#getString(String)}.
- <li><l>$R{header.X}</l> - Value
returned by {@link org.apache.juneau.rest.RequestHeaders#getString(String)}.
- <li><l>$R{method}</l> - Value
returned by {@link org.apache.juneau.rest.RestRequest#getMethod()}.
- <li><l>$R{methodSummary}</l> -
Value returned by {@link org.apache.juneau.rest.RestRequest#getMethodSummary()}.
-
<li><l>$R{methodDescription}</l> - Value returned by {@link
org.apache.juneau.rest.RestRequest#getMethodDescription()}.
- <li><l>$R{path.X}</l> - Value
returned by {@link org.apache.juneau.rest.RequestPathMatch#get(Object)}.
- <li><l>$R{pathInfo}</l> - Value
returned by {@link org.apache.juneau.rest.RestRequest#getPathInfo()}.
- <li><l>$R{query.X}</l> - Value
returned by {@link org.apache.juneau.rest.RequestQuery#getString(String)}.
- <li><l>$R{requestParentURI}</l>
- Value returned by {@link
org.apache.juneau.UriContext#getRootRelativePathInfoParent()}.
- <li><l>$R{requestURI}</l> -
Value returned by {@link org.apache.juneau.rest.RestRequest#getRequestURI()}.
-
<li><l>$R{servletDescription}</l> - Value returned by {@link
org.apache.juneau.rest.RestRequest#getServletDescription()}.
- <li><l>$R{servletTitle}</l> -
Value returned by {@link org.apache.juneau.rest.RestRequest#getServletTitle()}.
- <li><l>$R{servletParentURI}</l>
- Value returned by {@link
org.apache.juneau.UriContext#getRootRelativeServletPathParent()}.
- <li><l>$R{servletPath}</l> -
Value returned by {@link org.apache.juneau.rest.RestRequest#getServletPath()}.
- <li><l>$R{servletURI}</l> -
Value returned by {@link
org.apache.juneau.UriContext#getRootRelativeServletPath()}.
- </ul>
+ <li><l>$RA{key1,[key2...]}</l> -
Request attribute variables.
+ <li><l>$RF{key1,[key2...]}</l> -
Request form data variables.
+ <li><l>$RH{key1,[key2...]}</l> -
Request header variables.
+ <li><l>$RP{key1,[key2...]}</l> -
Request path variables.
+ <li><l>$RQ{key1,[key2...]}</l> -
Request query parameter variables.
+ <li><l>$R{key1,[key2...]}</l> - Other
request variables.
<li><l>$SA{key,mediaType}</l> - Object
returned by {@link org.apache.juneau.rest.RestRequest#getAttribute(String)}
converted to a string using the serializer registered to handle the specified
media type.
<li><l>$UE{...}</l> - URL-Encode the
specified value.
</ul>
@@ -732,8 +718,8 @@
<cc># Contents of microservice.cfg </cc>
<cc>#-----------------------------</cc>
<cs>[MyHelloResource]</cs>
- <ck>greeting</ck> = <cv>Hello $R{path.person}!</cv>
- <ck>localizedGreeting</ck> = <cv>$L{HelloMessage,$R{path.person}}</cv>
+ <ck>greeting</ck> = <cv>Hello $RP{person}!</cv>
+ <ck>localizedGreeting</ck> = <cv>$L{HelloMessage,$RP{person}}</cv>
</p>
<p class='bcode'>
<cc>#---------------------------------</cc>
@@ -782,7 +768,7 @@
The request attribute <l>person</l> gets
assigned the value <l>"Bob"</l>.
<li>
The call to
<l>req.getConfig().getString("MyHelloResource/localizedGreeting")</l>
- finds the value
<l>"$L{HelloMessage,$R{path.person}}"</l>.
+ finds the value
<l>"$L{HelloMessage,$RP{person}}"</l>.
<li>
The arguments in the <l>$L{}</l> variable get
resolved, resulting in <l>"$L{HelloMessage,Bob}"</l>.
<li>
http://git-wip-us.apache.org/repos/asf/juneau/blob/172a2e55/juneau-microservice/juneau-microservice-server/src/main/java/org/apache/juneau/microservice/resources/DirectoryResource.java
----------------------------------------------------------------------
diff --git
a/juneau-microservice/juneau-microservice-server/src/main/java/org/apache/juneau/microservice/resources/DirectoryResource.java
b/juneau-microservice/juneau-microservice-server/src/main/java/org/apache/juneau/microservice/resources/DirectoryResource.java
index e5a99cf..a4c3bf6 100755
---
a/juneau-microservice/juneau-microservice-server/src/main/java/org/apache/juneau/microservice/resources/DirectoryResource.java
+++
b/juneau-microservice/juneau-microservice-server/src/main/java/org/apache/juneau/microservice/resources/DirectoryResource.java
@@ -61,7 +61,7 @@ import org.apache.juneau.utils.*;
*/
@RestResource(
title="File System Explorer",
- description="Contents of $R{attribute.path}",
+ description="Contents of $RA{path}",
messages="nls/DirectoryResource",
htmldoc=@HtmlDoc(
navlinks={
http://git-wip-us.apache.org/repos/asf/juneau/blob/172a2e55/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java
----------------------------------------------------------------------
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java
index 6a23baf..50dc4e8 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java
@@ -650,7 +650,7 @@ public final class RestContext extends Context {
*
<ja>@Property</ja>(name=<js>"foo"</js>,value=<js>"bar"</js>),
*
<ja>@Property</ja>(name=<js>"bar"</js>,value=<js>"baz"</js>),
*
<ja>@Property</ja>(name=<js>"v1"</js>,value=<js>"$R{foo}"</js>), <jc>//
Request variable. value="bar"</jc>
- *
<ja>@Property</ja>(name=<js>"v2"</js>,value=<js>"$R{$R{foo}}"</js>) <jc>//
Nested request variable. value="baz"</jc>
+ *
<ja>@Property</ja>(name=<js>"v1"</js>,value=<js>"$R{foo,bar}"</js>), <jc>//
Request variable. value="bar"</jc>
* }
* )
* <jk>public class</jk> MyRestResource <jk>extends</jk>
RestServletDefault {
@@ -686,7 +686,12 @@ public final class RestContext extends Context {
* <li><code>$F{path[,defaultValue]}</code> - File resource. See
{@link FileVar}.
* <li><code>$I{name[,defaultValue]}</code> - Servlet init
parameter. See {@link ServletInitParamVar}.
* <li><code>$L{key[,args...]}</code> - Localized message. See
{@link LocalizationVar}.
- * <li><code>$R{key[,args...]}</code> - Request variable. See
{@link RequestVar}.
+ * <li><code>$RA{key1[,key2...]}</code> - Request attribute
variable. See {@link RequestAttributeVar}.
+ * <li><code>$RF{key1[,key2...]}</code> - Request form-data
variable. See {@link RequestFormDataVar}.
+ * <li><code>$RH{key1[,key2...]}</code> - Request header variable.
See {@link RequestHeaderVar}.
+ * <li><code>$RP{key1[,key2...]}</code> - Request path variable.
See {@link RequestPathVar}.
+ * <li><code>$RQ{key1[,key2...]}</code> - Request query parameter
variable. See {@link RequestQueryVar}.
+ * <li><code>$R{key1[,key2...]}</code> - Request object variable.
See {@link RequestVar}.
* <li><code>$S{systemProperty[,defaultValue]}</code> - System
property. See {@link SystemPropertiesVar}.
* <li><code>$SA{contentType,key[,defaultValue]}</code> -
Serialized request attribute. See {@link SerializedRequestAttrVar}.
* <li><code>$U{uri}</code> - URI resolver. See {@link UrlVar}.
@@ -697,6 +702,8 @@ public final class RestContext extends Context {
* <p>
* The following syntax variables are also provided:
* <ul>
+ * <li><code>$CO{string1[,string2...]}</code> - Coalesce variable.
See {@link CoalesceVar}.
+ * <li><code>$CR{string1[,string2...]}</code> -
Coalesce-and-recurse variable. See {@link CoalesceAndRecurseVar}.
* <li><code>$IF{booleanArg,thenValue[,elseValue]}</code> -
If/else variable. See {@link IfVar}.
*
<li><code>$SW{stringArg(,pattern,thenValue)+[,elseValue]}</code> - Switch
variable. See {@link SwitchVar}.
* </ul>
http://git-wip-us.apache.org/repos/asf/juneau/blob/172a2e55/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestRequest.java
----------------------------------------------------------------------
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestRequest.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestRequest.java
index 1d6ceb2..1f83d93 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestRequest.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestRequest.java
@@ -245,127 +245,6 @@ public final class RestRequest extends
HttpServletRequestWrapper {
}
- /**
- * Resolves the specified property.
- *
- * @param cm
- * The <code>CallMethod</code> object where the
<code>HtmlDocSerializer</code> settings are defined.
- * Optional value. If not specified, then won't resolve
<code>HtmlDocSerializer</code> properties.
- * @param category
- * The property category.
- * The possible values are:
- * <ul>
- * <li>
- * <js>"Attribute"</js> - Value returned by {@link
HttpServletRequest#getAttribute(String)}.
- * <li>
- * <js>"FormData"</js> - Value returned by {@link
RestRequest#getFormData(String)}.
- * <li>
- * <js>"Header"</js> - Value returned by {@link
RestRequest#getHeader(String)}.
- * <li>
- * <js>"HtmlDocSerializer"</js>
- * <br>Valid names:
- * <ul>
- * <li><js>"aside"</js> - See {@link
HtmlDocSerializer#HTMLDOC_aside}
- * <li><js>"footer"</js> - See {@link
HtmlDocSerializer#HTMLDOC_footer}
- * <li><js>"header"</js> - See {@link
HtmlDocSerializer#HTMLDOC_header}
- * <li><js>"navlinks.list"</js> - See
{@link HtmlDocSerializer#HTMLDOC_navlinks}
- * <li><js>"nav"</js> - See {@link
HtmlDocSerializer#HTMLDOC_nav}
- * <li><js>"noResultsMessage"</js> - See
{@link HtmlDocSerializer#HTMLDOC_noResultsMessage}
- * <li><js>"nowrap"</js> - See {@link
HtmlDocSerializer#HTMLDOC_nowrap}
- * <li><js>"script.list"</js> - See {@link
HtmlDocSerializer#HTMLDOC_script}
- * <li><js>"style.list"</js> - See {@link
HtmlDocSerializer#HTMLDOC_style}
- * <li><js>"stylesheet"</js> - See {@link
HtmlDocSerializer#HTMLDOC_stylesheet}
- * <li><js>"template"</js> - See {@link
HtmlDocSerializer#HTMLDOC_template}
- * </ul>
- * <li>
- * <js>"Path"</js> - Value returned by {@link
RestRequest#getPath(String)}.
- * <li>
- * <js>"Query"</js> = Value returned by {@link
RestRequest#getQuery(String)}.
- * <li>
- * <js>"Request"</js>
- * <br>Valid names:
- * <ul>
- * <li><js>"contextPath"</js> - Value
returned by {@link RestRequest#getContextPath()}
- * <li><js>"method"</js> - Value returned
by {@link RestRequest#getMethod()}
- * <li><js>"methodDescription"</js> -
Value returned by {@link RestRequest#getMethodDescription()}
- * <li><js>"methodSummary"</js> - Value
returned by {@link RestRequest#getMethodSummary()}
- * <li><js>"pathInfo"</js> - Value
returned by {@link RestRequest#getPathInfo()}
- * <li><js>"requestParentURI"</js> - Value
returned by {@link UriContext#getRootRelativePathInfoParent()}
- * <li><js>"requestURI"</js> - Value
returned by {@link RestRequest#getRequestURI()}
- * <li><js>"servletClass"</js> - The class
name of the servlet
- * <li><js>"servletClassSimple"</js> - The
simple class name of the servlet.
- * <li><js>"servletDescription"</js> -
Value returned by {@link RestRequest#getServletDescription()}
- * <li><js>"servletParentURI"</js> - Value
returned by {@link UriContext#getRootRelativeServletPathParent()}
- * <li><js>"servletPath"</js> - See {@link
RestRequest#getServletPath()}
- * <li><js>"servletTitle"</js> - See
{@link RestRequest#getServletTitle()}
- * <li><js>"servletURI"</js> - See {@link
UriContext#getRootRelativeServletPath()}
- * <li><js>"siteName"</js> - See {@link
RestRequest#getSiteName()}
- * </ul>
- * </ul>
- * @param name The property name.
- * @return The resolve property, or <jk>null</jk> if it wasn't found.
- */
- public Object resolveProperty(CallMethod cm, String category, String
name) {
- char c = category.charAt(0);
- if (c == 'A') {
- if ("Attribute".equals(category))
- return getAttribute(name);
- } else if (c == 'F') {
- if ("FormData".equals(category))
- return getFormData(name);
- } else if (c == 'H') {
- if ("Header".equals(category))
- return getHeader(name);
- } else if (c == 'P') {
- if ("Path".equals(category))
- return getPath(name);
- } else if (c == 'Q') {
- if ("Query".equals(category))
- return getQuery(name);
- } else if (c == 'R') {
- if ("Request".equals(category)) {
- char c2 = StringUtils.charAt(name, 0);
- if (c2 == 'c') {
- if ("contextPath".equals(name))
- return getContextPath();
- } else if (c2 == 'm') {
- if ("method".equals(name))
- return getMethod();
- if ("methodDescription".equals(name))
- return getMethodDescription();
- if ("methodSummary".equals(name))
- return getMethodSummary();
- } else if (c2 == 'p') {
- if ("pathInfo".equals(name))
- return getPathInfo();
- } else if (c2 == 'r') {
- if ("requestParentURI".equals(name))
- return
getUriContext().getRootRelativePathInfoParent();
- if ("requestURI".equals(name))
- return getRequestURI();
- } else if (c2 == 's') {
- if ("servletClass".equals(name))
- return
getContext().getResource().getClass().getName();
- if ("servletClassSimple".equals(name))
- return
getContext().getResource().getClass().getSimpleName();
- if ("servletDescription".equals(name))
- return getServletDescription();
- if ("servletParentURI".equals(name))
- return
getUriContext().getRootRelativeServletPathParent();
- if ("servletPath".equals(name))
- return getServletPath();
- if ("servletTitle".equals(name))
- return getServletTitle();
- if ("servletURI".equals(name))
- return
getUriContext().getRootRelativeServletPath();
- if ("siteName".equals(name))
- return getSiteName();
- }
- }
- }
- return null;
- }
-
//--------------------------------------------------------------------------------
// Properties
//--------------------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/juneau/blob/172a2e55/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestServletDefault.java
----------------------------------------------------------------------
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestServletDefault.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestServletDefault.java
index 4e06f7b..72740c1 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestServletDefault.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestServletDefault.java
@@ -191,7 +191,7 @@ import org.apache.juneau.xml.*;
htmldoc=@HtmlDoc(
header={
"<h1>$R{servletTitle}</h1>",
- "<h2>$R{methodSummary,$R{servletDescription}}</h2>",
+ "<h2>$R{methodSummary,servletDescription}</h2>",
"<a href='http://juneau.apache.org'><img
src='$U{servlet:/htdocs/juneau.png}'
style='position:absolute;top:5;right:5;background-color:transparent;height:30px'/></a>"
},
stylesheet="servlet:/styles/light.css",
http://git-wip-us.apache.org/repos/asf/juneau/blob/172a2e55/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/package.html
----------------------------------------------------------------------
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/package.html
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/package.html
index 6392f48..470684b 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/package.html
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/package.html
@@ -2330,21 +2330,63 @@
</td>
</tr>
<tr>
- <td><ck>$R{key}</ck></td>
+ <td><ck>$RA{key1[,key2]}</ck></td>
<td>
- Request-specific variables.
+ Request attribute variables.
+ <br>Value returned by {@link
org.apache.juneau.rest.RestRequest#getAttribute(String)} converted to a string.
+ <br>First non-null value is returned.
+ <br>For security reasons, embedded or
returned variables are not recursively resolved.
+ </td>
+ </tr>
+ <tr>
+ <td><ck>$RF{key1[,key2]}</ck></td>
+ <td>
+ Request form-data variables.
+ <br>Value returned by {@link
org.apache.juneau.rest.RestRequest#getFormData(String)} converted to a string.
+ <br>First non-null value is returned.
+ <br>For security reasons, embedded or
returned variables are not recursively resolved.
+ </td>
+ </tr>
+ <tr>
+ <td><ck>$RH{key1[,key2]}</ck></td>
+ <td>
+ Request header variables.
+ <br>Value returned by {@link
org.apache.juneau.rest.RestRequest#getHeader(String)} converted to a string.
+ <br>First non-null value is returned.
+ <br>For security reasons, embedded or
returned variables are not recursively resolved.
+ </td>
+ </tr>
+ <tr>
+ <td><ck>$RP{key1[,key2]}</ck></td>
+ <td>
+ Request path variables.
+ <br>Value returned by {@link
org.apache.juneau.rest.RestRequest#getPath(String)} converted to a string.
+ <br>First non-null value is returned.
+ <br>For security reasons, embedded or
returned variables are not recursively resolved.
+ </td>
+ </tr>
+ <tr>
+ <td><ck>$RQ{key1[,key2]}</ck></td>
+ <td>
+ Request query parameter variables.
+ <br>Value returned by {@link
org.apache.juneau.rest.RestRequest#getQuery(String)} converted to a string.
+ <br>First non-null value is returned.
+ <br>For security reasons, embedded or
returned variables are not recursively resolved.
+ </td>
+ </tr>
+ <tr>
+ <td><ck>$RQ{key1[,key2]}</ck></td>
+ <td>
+ Request object variables.
+ <br>This variable allows access to
values found on the {@link org.apache.junuea.rest.RestRequest} object.
+ <br>First non-null value is returned.
+ <br>For security reasons, embedded or
returned variables are not recursively resolved.
<br>Possible values:
<ul>
- <li><ck>$R{attribute.X}</ck> -
Value returned by {@link
org.apache.juneau.rest.RestRequest#getAttribute(String)} converted to a string.
- <li><ck>$R{contextPath}</ck> -
Value returned by {@link org.apache.juneau.rest.RestRequest#getContextPath()}.
- <li><ck>$R{formData.X}</ck> -
Value returned by {@link
org.apache.juneau.rest.RequestFormData#getString(String)}.
- <li><ck>$R{header.X}</ck> -
Value returned by {@link
org.apache.juneau.rest.RequestHeaders#getString(String)}.
<li><ck>$R{method}</ck> - Value
returned by {@link org.apache.juneau.rest.RestRequest#getMethod()}.
<li><ck>$R{methodSummary}</ck>
- Value returned by {@link
org.apache.juneau.rest.RestRequest#getMethodSummary()}.
<li><ck>$R{methodDescription}</ck> - Value returned by {@link
org.apache.juneau.rest.RestRequest#getMethodDescription()}.
- <li><ck>$R{path.X}</ck> - Value
returned by {@link org.apache.juneau.rest.RequestPathMatch#get(Object)}.
<li><ck>$R{pathInfo}</ck> -
Value returned by {@link org.apache.juneau.rest.RestRequest#getPathInfo()}.
- <li><ck>$R{query.X}</ck> -
Value returned by {@link org.apache.juneau.rest.RequestQuery#getString(String)}.
<li><ck>$R{requestParentURI}</ck> - Value returned by {@link
org.apache.juneau.UriContext#getRootRelativePathInfoParent()}.
<li><ck>$R{requestURI}</ck> -
Value returned by {@link org.apache.juneau.rest.RestRequest#getRequestURI()}.
<li><ck>$R{servletDescription}</ck> - Value returned by {@link
org.apache.juneau.rest.RestRequest#getServletDescription()}.
@@ -2776,8 +2818,7 @@
<cc># Contents of config_dir/myconfig.cfg </cc>
<cc>#-------------------------------------</cc>
<cs>[HelloWorldResource]</cs>
- <ck>defaultPerson</ck> = you
- <ck>message</ck> = <cv>Hello
$R{query.person,$C{HelloWorldResource/defaultPerson}}!</cv>
+ <ck>message</ck> = <cv>Hello $RQ{person}!</cv>
</p>
<p class='bcode'>
<jd>/**
@@ -2807,8 +2848,7 @@
<cc># Contents of config_dir/myconfig.cfg </cc>
<cc>#-------------------------------------</cc>
<cs>[HelloWorldResource]</cs>
- <ck>defaultPerson</ck> = you
- <ck>message</ck> =
<cv>$L{localizedMessage,$R{query.person,$C{HelloWorldResource/defaultPerson}}}</cv>
+ <ck>message</ck> = <cv>$L{localizedMessage,$RQ{person}}</cv>
</p>
<p class='bcode'>
<cc>#-------------------------------------------</cc>
http://git-wip-us.apache.org/repos/asf/juneau/blob/172a2e55/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/vars/RequestAttributeVar.java
----------------------------------------------------------------------
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/vars/RequestAttributeVar.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/vars/RequestAttributeVar.java
new file mode 100644
index 0000000..2d8567e
--- /dev/null
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/vars/RequestAttributeVar.java
@@ -0,0 +1,69 @@
+//
***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright
ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance *
+// * with the License. You may obtain a copy of the License at
*
+// *
*
+// * http://www.apache.org/licenses/LICENSE-2.0
*
+// *
*
+// * Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express or implied. See the License for the *
+// * specific language governing permissions and limitations under the
License. *
+//
***************************************************************************************************************************
+package org.apache.juneau.rest.vars;
+
+import javax.servlet.http.*;
+
+import org.apache.juneau.internal.*;
+import org.apache.juneau.rest.*;
+import org.apache.juneau.svl.*;
+
+/**
+ * Request attribute variable resolver.
+ *
+ * <p>
+ * The format for this var is <js>"$RA{key1[,key2...]}"</js>.
+ *
+ * <p>
+ * Used to resolve values returned by {@link
HttpServletRequest#getAttribute(String)}.
+ *
+ * <p>
+ * This variable resolver requires that a {@link RestRequest} object be set as
a context object on the resolver or a
+ * session object on the resolver session.
+ *
+ * @see org.apache.juneau.svl
+ */
+public class RequestAttributeVar extends MultipartResolvingVar {
+
+ /**
+ * The name of the session or context object that identifies the {@link
RestRequest} object.
+ */
+ public static final String SESSION_req = "req";
+
+
+ /** The name of this variable. */
+ public static final String NAME = "RA";
+
+ /**
+ * Constructor.
+ */
+ public RequestAttributeVar() {
+ super(NAME);
+ }
+
+ @Override /* Var */
+ protected boolean allowNested() {
+ return false;
+ }
+
+ @Override /* Var */
+ protected boolean allowRecurse() {
+ return false;
+ }
+
+ @Override /* Parameter */
+ public String resolve(VarResolverSession session, String key) {
+ RestRequest req = session.getSessionObject(RestRequest.class,
SESSION_req);
+ return StringUtils.toString(req.getAttribute(key));
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/juneau/blob/172a2e55/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/vars/RequestFormDataVar.java
----------------------------------------------------------------------
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/vars/RequestFormDataVar.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/vars/RequestFormDataVar.java
new file mode 100644
index 0000000..7d4b7f1
--- /dev/null
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/vars/RequestFormDataVar.java
@@ -0,0 +1,66 @@
+//
***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright
ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance *
+// * with the License. You may obtain a copy of the License at
*
+// *
*
+// * http://www.apache.org/licenses/LICENSE-2.0
*
+// *
*
+// * Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express or implied. See the License for the *
+// * specific language governing permissions and limitations under the
License. *
+//
***************************************************************************************************************************
+package org.apache.juneau.rest.vars;
+
+import org.apache.juneau.rest.*;
+import org.apache.juneau.svl.*;
+
+/**
+ * Request form data variable resolver.
+ *
+ * <p>
+ * The format for this var is <js>"$RF{key1[,key2...]}"</js>.
+ *
+ * <p>
+ * Used to resolve values returned by {@link RestRequest#getFormData(String)}.
+ *
+ * <p>
+ * This variable resolver requires that a {@link RestRequest} object be set as
a context object on the resolver or a
+ * session object on the resolver session.
+ *
+ * @see org.apache.juneau.svl
+ */
+public class RequestFormDataVar extends MultipartResolvingVar {
+
+ /**
+ * The name of the session or context object that identifies the {@link
RestRequest} object.
+ */
+ public static final String SESSION_req = "req";
+
+
+ /** The name of this variable. */
+ public static final String NAME = "RF";
+
+ /**
+ * Constructor.
+ */
+ public RequestFormDataVar() {
+ super(NAME);
+ }
+
+ @Override /* Var */
+ protected boolean allowNested() {
+ return false;
+ }
+
+ @Override /* Var */
+ protected boolean allowRecurse() {
+ return false;
+ }
+
+ @Override /* Parameter */
+ public String resolve(VarResolverSession session, String key) {
+ RestRequest req = session.getSessionObject(RestRequest.class,
SESSION_req);
+ return req.getFormData(key);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/juneau/blob/172a2e55/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/vars/RequestHeaderVar.java
----------------------------------------------------------------------
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/vars/RequestHeaderVar.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/vars/RequestHeaderVar.java
new file mode 100644
index 0000000..56d5c65
--- /dev/null
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/vars/RequestHeaderVar.java
@@ -0,0 +1,70 @@
+//
***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright
ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance *
+// * with the License. You may obtain a copy of the License at
*
+// *
*
+// * http://www.apache.org/licenses/LICENSE-2.0
*
+// *
*
+// * Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express or implied. See the License for the *
+// * specific language governing permissions and limitations under the
License. *
+//
***************************************************************************************************************************
+package org.apache.juneau.rest.vars;
+
+import org.apache.juneau.rest.*;
+import org.apache.juneau.svl.*;
+
+/**
+ * Request header variable resolver.
+ *
+ * <p>
+ * The format for this var is <js>"$RH{key1[,key2...]}"</js>.
+ *
+ * <p>
+ * Used to resolve values returned by {@link RestRequest#getHeader(String)}.
+ *
+ * <p>
+ * This variable resolver requires that a {@link RestRequest} object be set as
a context object on the resolver or a
+ * session object on the resolver session.
+ *
+ * <p>
+ * Since this is a {@link SimpleVar}, any variables contained in the result
will be recursively resolved.
+ * Likewise, if the arguments contain any variables, those will be resolved
before they are passed to this var.
+ *
+ * @see org.apache.juneau.svl
+ */
+public class RequestHeaderVar extends MultipartResolvingVar {
+
+ /**
+ * The name of the session or context object that identifies the {@link
RestRequest} object.
+ */
+ public static final String SESSION_req = "req";
+
+
+ /** The name of this variable. */
+ public static final String NAME = "RH";
+
+ /**
+ * Constructor.
+ */
+ public RequestHeaderVar() {
+ super(NAME);
+ }
+
+ @Override /* Var */
+ protected boolean allowNested() {
+ return false;
+ }
+
+ @Override /* Var */
+ protected boolean allowRecurse() {
+ return false;
+ }
+
+ @Override /* Parameter */
+ public String resolve(VarResolverSession session, String key) {
+ RestRequest req = session.getSessionObject(RestRequest.class,
SESSION_req);
+ return req.getHeader(key);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/juneau/blob/172a2e55/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/vars/RequestPathVar.java
----------------------------------------------------------------------
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/vars/RequestPathVar.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/vars/RequestPathVar.java
new file mode 100644
index 0000000..6acee6b
--- /dev/null
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/vars/RequestPathVar.java
@@ -0,0 +1,66 @@
+//
***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright
ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance *
+// * with the License. You may obtain a copy of the License at
*
+// *
*
+// * http://www.apache.org/licenses/LICENSE-2.0
*
+// *
*
+// * Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express or implied. See the License for the *
+// * specific language governing permissions and limitations under the
License. *
+//
***************************************************************************************************************************
+package org.apache.juneau.rest.vars;
+
+import org.apache.juneau.rest.*;
+import org.apache.juneau.svl.*;
+
+/**
+ * Request path variable resolver.
+ *
+ * <p>
+ * The format for this var is <js>"$RP{key1[,key2...]}"</js>.
+ *
+ * <p>
+ * Used to resolve values returned by {@link RestRequest#getPath(String)}.
+ *
+ * <p>
+ * This variable resolver requires that a {@link RestRequest} object be set as
a context object on the resolver or a
+ * session object on the resolver session.
+ *
+ * @see org.apache.juneau.svl
+ */
+public class RequestPathVar extends MultipartResolvingVar {
+
+ /**
+ * The name of the session or context object that identifies the {@link
RestRequest} object.
+ */
+ public static final String SESSION_req = "req";
+
+
+ /** The name of this variable. */
+ public static final String NAME = "RP";
+
+ /**
+ * Constructor.
+ */
+ public RequestPathVar() {
+ super(NAME);
+ }
+
+ @Override /* Var */
+ protected boolean allowNested() {
+ return false;
+ }
+
+ @Override /* Var */
+ protected boolean allowRecurse() {
+ return false;
+ }
+
+ @Override /* Parameter */
+ public String resolve(VarResolverSession session, String key) {
+ RestRequest req = session.getSessionObject(RestRequest.class,
SESSION_req);
+ return req.getPath(key);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/juneau/blob/172a2e55/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/vars/RequestQueryVar.java
----------------------------------------------------------------------
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/vars/RequestQueryVar.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/vars/RequestQueryVar.java
new file mode 100644
index 0000000..4a03241
--- /dev/null
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/vars/RequestQueryVar.java
@@ -0,0 +1,66 @@
+//
***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright
ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance *
+// * with the License. You may obtain a copy of the License at
*
+// *
*
+// * http://www.apache.org/licenses/LICENSE-2.0
*
+// *
*
+// * Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express or implied. See the License for the *
+// * specific language governing permissions and limitations under the
License. *
+//
***************************************************************************************************************************
+package org.apache.juneau.rest.vars;
+
+import org.apache.juneau.rest.*;
+import org.apache.juneau.svl.*;
+
+/**
+ * Request query variable resolver.
+ *
+ * <p>
+ * The format for this var is <js>"$RQ{key1[,key2...]}"</js>.
+ *
+ * <p>
+ * Used to resolve values returned by {@link RestRequest#getQuery(String)}.
+ *
+ * <p>
+ * This variable resolver requires that a {@link RestRequest} object be set as
a context object on the resolver or a
+ * session object on the resolver session.
+ *
+ * @see org.apache.juneau.svl
+ */
+public class RequestQueryVar extends MultipartResolvingVar {
+
+ /**
+ * The name of the session or context object that identifies the {@link
RestRequest} object.
+ */
+ public static final String SESSION_req = "req";
+
+
+ /** The name of this variable. */
+ public static final String NAME = "RQ";
+
+ /**
+ * Constructor.
+ */
+ public RequestQueryVar() {
+ super(NAME);
+ }
+
+ @Override /* Var */
+ protected boolean allowNested() {
+ return false;
+ }
+
+ @Override /* Var */
+ protected boolean allowRecurse() {
+ return false;
+ }
+
+ @Override /* Parameter */
+ public String resolve(VarResolverSession session, String key) {
+ RestRequest req = session.getSessionObject(RestRequest.class,
SESSION_req);
+ return req.getQuery(key);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/juneau/blob/172a2e55/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/vars/RequestVar.java
----------------------------------------------------------------------
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/vars/RequestVar.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/vars/RequestVar.java
index 878bcad..5c68d6f 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/vars/RequestVar.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/vars/RequestVar.java
@@ -12,9 +12,8 @@
//
***************************************************************************************************************************
package org.apache.juneau.rest.vars;
-import javax.servlet.http.*;
-
import org.apache.juneau.*;
+import org.apache.juneau.internal.*;
import org.apache.juneau.rest.*;
import org.apache.juneau.svl.*;
@@ -22,7 +21,7 @@ import org.apache.juneau.svl.*;
* Request attribute variable resolver.
*
* <p>
- * The format for this var is <js>"$R{key[,defaultValue]}"</js>.
+ * The format for this var is <js>"$R{key1[,key2...]}"</js>.
*
* <p>
* The possible values are:
@@ -40,23 +39,15 @@ import org.apache.juneau.svl.*;
* <li><js>"servletTitle"</js> - See {@link RestRequest#getServletTitle()}
* <li><js>"servletURI"</js> - See {@link
UriContext#getRootRelativeServletPath()}
* <li><js>"siteName"</js> - See {@link RestRequest#getSiteName()}
- * <li><js>"Attribute.x"</js> - Value returned by {@link
HttpServletRequest#getAttribute(String)}.
- * <li><js>"FormData.x"</js> - Value returned by {@link
RestRequest#getFormData(String)}.
- * <li><js>"Header.x"</js> - Value returned by {@link
RestRequest#getHeader(String)}.
- * <li><js>"Path.x"</js> - Value returned by {@link
RestRequest#getPath(String)}.
- * <li><js>"Query.x"</js> = Value returned by {@link
RestRequest#getQuery(String)}.
* </ul>
+ *
* <p>
* This variable resolver requires that a {@link RestRequest} object be set as
a context object on the resolver or a
* session object on the resolver session.
*
- * <p>
- * Since this is a {@link SimpleVar}, any variables contained in the result
will be recursively resolved.
- * Likewise, if the arguments contain any variables, those will be resolved
before they are passed to this var.
- *
* @see org.apache.juneau.svl
*/
-public class RequestVar extends DefaultingVar {
+public class RequestVar extends MultipartResolvingVar {
/**
* The name of the session or context object that identifies the {@link
RestRequest} object.
@@ -87,25 +78,43 @@ public class RequestVar extends DefaultingVar {
@Override /* Parameter */
public String resolve(VarResolverSession session, String key) {
RestRequest req = session.getSessionObject(RestRequest.class,
SESSION_req);
- if (key.length() > 0) {
- String k = key.toString();
- int i = k.indexOf('.');
- if (i != -1) {
- String prefix = k.substring(0, i);
- String remainder = k.substring(i+1);
- Object o = req.resolveProperty(null,
prefix, remainder);
- if (o != null)
- return o.toString();
- } else {
- Object o = req.resolveProperty(null,
"Request", key);
- if (o != null)
- return o.toString();
- }
- Object o = req.getProperties().get(key);
- if (o != null)
- return o.toString();
- return req.getPathMatch().get(key);
- }
- return null;
+ char c = StringUtils.charAt(key, 0);
+ if (c == 'c') {
+ if ("contextPath".equals(key))
+ return req.getContextPath();
+ } else if (c == 'm') {
+ if ("method".equals(key))
+ return req.getMethod();
+ if ("methodDescription".equals(key))
+ return req.getMethodDescription();
+ if ("methodSummary".equals(key))
+ return req.getMethodSummary();
+ } else if (c == 'p') {
+ if ("pathInfo".equals(key))
+ return req.getPathInfo();
+ } else if (c == 'r') {
+ if ("requestParentURI".equals(key))
+ return
req.getUriContext().getRootRelativePathInfoParent();
+ if ("requestURI".equals(key))
+ return req.getRequestURI();
+ } else if (c == 's') {
+ if ("servletClass".equals(key))
+ return
req.getContext().getResource().getClass().getName();
+ if ("servletClassSimple".equals(key))
+ return
req.getContext().getResource().getClass().getSimpleName();
+ if ("servletDescription".equals(key))
+ return req.getServletDescription();
+ if ("servletParentURI".equals(key))
+ return
req.getUriContext().getRootRelativeServletPathParent();
+ if ("servletPath".equals(key))
+ return req.getServletPath();
+ if ("servletTitle".equals(key))
+ return req.getServletTitle();
+ if ("servletURI".equals(key))
+ return
req.getUriContext().getRootRelativeServletPath();
+ if ("siteName".equals(key))
+ return req.getSiteName();
+ }
+ return req.getProperties().getString(key);
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/juneau/blob/172a2e55/juneau-rest/juneau-rest-server/src/main/resources/org/apache/juneau/rest/widget/QueryMenuItem.html
----------------------------------------------------------------------
diff --git
a/juneau-rest/juneau-rest-server/src/main/resources/org/apache/juneau/rest/widget/QueryMenuItem.html
b/juneau-rest/juneau-rest-server/src/main/resources/org/apache/juneau/rest/widget/QueryMenuItem.html
index f4be41c..9e8c6a6 100644
---
a/juneau-rest/juneau-rest-server/src/main/resources/org/apache/juneau/rest/widget/QueryMenuItem.html
+++
b/juneau-rest/juneau-rest-server/src/main/resources/org/apache/juneau/rest/widget/QueryMenuItem.html
@@ -18,7 +18,7 @@
<tr>
<th>Search:</th>
<td>
- <input name="s" size="50" value='$R{query.s}'>
+ <input name="s" size="50" value='$RQ{s}'>
</td>
<td>
<div class="tooltip">
@@ -65,7 +65,7 @@
<tr>
<th>View:</th>
<td>
- <input name="v" size="50" value='$R{query.v}'>
+ <input name="v" size="50" value='$RQ{v}'>
</td>
<td>
<div class="tooltip">
@@ -81,7 +81,7 @@
<tr>
<th>Sort:</th>
<td>
- <input name="o" size="50" value='$R{query.o}'>
+ <input name="o" size="50" value='$RQ{o}'>
</td>
<td>
<div class="tooltip">
@@ -101,8 +101,8 @@
<tr>
<th>Page:</th>
<td>
- Position: <input name='p' type='number'
style='width:50px' step=20 min=0 value='$R{query.p}'>
- Limit: <input name='l' type='number'
style='width:50px' step=20 min=0 value='$R{query.l}'>
+ Position: <input name='p' type='number'
style='width:50px' step=20 min=0 value='$RQ{p}'>
+ Limit: <input name='l' type='number'
style='width:50px' step=20 min=0 value='$RQ{l}'>
<span style='float:right'>Ignore-case: <input
name='i' type='checkbox' value='true'></span>
</td>
<td>