Repository: incubator-juneau
Updated Branches:
  refs/heads/master 81ee8b2cc -> ffab95631


Replace RuntimeException with FormattedRuntimeException where needed.

Project: http://git-wip-us.apache.org/repos/asf/incubator-juneau/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-juneau/commit/ffab9563
Tree: http://git-wip-us.apache.org/repos/asf/incubator-juneau/tree/ffab9563
Diff: http://git-wip-us.apache.org/repos/asf/incubator-juneau/diff/ffab9563

Branch: refs/heads/master
Commit: ffab9563100ed90b2a8e9e5eef3a01a201485bfa
Parents: 81ee8b2
Author: JamesBognar <[email protected]>
Authored: Mon Jul 3 14:17:12 2017 -0400
Committer: JamesBognar <[email protected]>
Committed: Mon Jul 3 14:17:12 2017 -0400

----------------------------------------------------------------------
 .../juneau/jena/RdfSerializerSession.java       |  2 +-
 .../java/org/apache/juneau/BeanContext.java     |  4 +-
 .../apache/juneau/dto/swagger/HeaderInfo.java   | 16 +++---
 .../org/apache/juneau/dto/swagger/Items.java    |  8 +--
 .../juneau/dto/swagger/ParameterInfo.java       | 21 +++++---
 .../juneau/dto/swagger/SecurityScheme.java      |  9 ++--
 .../juneau/html/HtmlDocTemplateBasic.java       | 10 ++--
 .../apache/juneau/ini/ConfigFileBuilder.java    |  6 ++-
 .../org/apache/juneau/internal/ClassUtils.java  |  4 +-
 .../org/apache/juneau/internal/FileUtils.java   | 12 +++--
 .../main/java/org/apache/juneau/utils/Args.java |  2 +-
 .../java/org/apache/juneau/utils/PojoQuery.java |  7 +--
 .../org/apache/juneau/utils/SearchArgs.java     |  3 +-
 .../org/apache/juneau/xml/NamespaceFactory.java |  4 +-
 .../org/apache/juneau/xml/XmlParserSession.java |  2 +-
 .../apache/juneau/xml/XmlSchemaSerializer.java  |  2 +-
 juneau-core/src/main/javadoc/overview.html      |  2 +-
 .../juneau/examples/rest/PetStoreResource.java  | 29 ++++++-----
 .../juneau/examples/rest/RootResources.java     |  6 ++-
 .../examples/rest/SystemPropertiesResource.java | 18 +++++--
 .../java/org/apache/juneau/rest/RestUtils.java  |  3 +-
 .../juneau/rest/widget/MenuItemWidget.java      |  4 +-
 .../juneau/rest/widget/QueryMenuItem.java       |  4 +-
 .../org/apache/juneau/rest/widget/Widget.java   | 54 ++++++++++++++++++++
 24 files changed, 163 insertions(+), 69 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/ffab9563/juneau-core-rdf/src/main/java/org/apache/juneau/jena/RdfSerializerSession.java
----------------------------------------------------------------------
diff --git 
a/juneau-core-rdf/src/main/java/org/apache/juneau/jena/RdfSerializerSession.java
 
b/juneau-core-rdf/src/main/java/org/apache/juneau/jena/RdfSerializerSession.java
index bf229c9..6595801 100644
--- 
a/juneau-core-rdf/src/main/java/org/apache/juneau/jena/RdfSerializerSession.java
+++ 
b/juneau-core-rdf/src/main/java/org/apache/juneau/jena/RdfSerializerSession.java
@@ -125,7 +125,7 @@ public final class RdfSerializerSession extends 
SerializerSession {
                // Only apply properties with this prefix!
                String propPrefix = 
RdfCommonContext.LANG_PROP_MAP.get(rdfLanguage);
                if (propPrefix == null)
-                       throw new RuntimeException("Unknown RDF language 
encountered: '"+rdfLanguage+"'");
+                       throw new FormattedRuntimeException("Unknown RDF 
language encountered: ''{0}''", rdfLanguage);
 
                for (Map.Entry<String,Object> e : jenaSettings.entrySet())
                        if (e.getKey().startsWith(propPrefix))

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/ffab9563/juneau-core/src/main/java/org/apache/juneau/BeanContext.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/BeanContext.java 
b/juneau-core/src/main/java/org/apache/juneau/BeanContext.java
index 1e705bd..c96ac5e 100644
--- a/juneau-core/src/main/java/org/apache/juneau/BeanContext.java
+++ b/juneau-core/src/main/java/org/apache/juneau/BeanContext.java
@@ -1496,7 +1496,7 @@ public class BeanContext extends Context {
                        if (cm2.isMap()) {
                                Class<?>[] pParams = (p.params().length == 0 ? 
new Class[]{Object.class, Object.class} : p.params());
                                if (pParams.length != 2)
-                                       throw new RuntimeException("Invalid 
number of parameters specified for Map (must be 2): " + pParams.length);
+                                       throw new 
FormattedRuntimeException("Invalid number of parameters specified for Map (must 
be 2): {0}", pParams.length);
                                ClassMeta<?> keyType = resolveType(pParams[0], 
cm2.getKeyType(), cm.getKeyType());
                                ClassMeta<?> valueType = 
resolveType(pParams[1], cm2.getValueType(), cm.getValueType());
                                if (keyType.isObject() && valueType.isObject())
@@ -1507,7 +1507,7 @@ public class BeanContext extends Context {
                        if (cm2.isCollection()) {
                                Class<?>[] pParams = (p.params().length == 0 ? 
new Class[]{Object.class} : p.params());
                                if (pParams.length != 1)
-                                       throw new RuntimeException("Invalid 
number of parameters specified for Collection (must be 1): " + pParams.length);
+                                       throw new 
FormattedRuntimeException("Invalid number of parameters specified for 
Collection (must be 1): {0}", pParams.length);
                                ClassMeta<?> elementType = 
resolveType(pParams[0], cm2.getElementType(), cm.getElementType());
                                if (elementType.isObject())
                                        return cm2;

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/ffab9563/juneau-core/src/main/java/org/apache/juneau/dto/swagger/HeaderInfo.java
----------------------------------------------------------------------
diff --git 
a/juneau-core/src/main/java/org/apache/juneau/dto/swagger/HeaderInfo.java 
b/juneau-core/src/main/java/org/apache/juneau/dto/swagger/HeaderInfo.java
index fe97c08..1978253 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/swagger/HeaderInfo.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/swagger/HeaderInfo.java
@@ -16,8 +16,8 @@ import static org.apache.juneau.internal.ArrayUtils.*;
 
 import java.util.*;
 
+import org.apache.juneau.*;
 import org.apache.juneau.annotation.*;
-import org.apache.juneau.json.*;
 
 /**
  * Describes a single HTTP header.
@@ -141,9 +141,10 @@ public class HeaderInfo extends SwaggerElement {
         */
        public HeaderInfo setType(String type) {
                if (isStrict() && ! contains(type, VALID_TYPES))
-                       throw new RuntimeException(
-                               "Invalid value passed in to setType(String).  
Value='"+type+"', valid values="
-                       + JsonSerializer.DEFAULT_LAX.toString(VALID_TYPES));
+                       throw new FormattedRuntimeException(
+                               "Invalid value passed in to setType(String).  
Value=''{0}'', valid values={1}",
+                               type, VALID_TYPES
+                       );
                this.type = type;
                return this;
        }
@@ -284,9 +285,10 @@ public class HeaderInfo extends SwaggerElement {
         */
        public HeaderInfo setCollectionFormat(String collectionFormat) {
                if (isStrict() && ! contains(collectionFormat, 
VALID_COLLECTION_FORMATS))
-                       throw new RuntimeException(
-                               "Invalid value passed in to 
setCollectionFormat(String).  Value='"+collectionFormat+"', valid values="
-                       + 
JsonSerializer.DEFAULT_LAX.toString(VALID_COLLECTION_FORMATS));
+                       throw new FormattedRuntimeException(
+                               "Invalid value passed in to 
setCollectionFormat(String).  Value=''{0}'', valid values={1}",
+                               collectionFormat, VALID_COLLECTION_FORMATS
+                       );
                this.collectionFormat = collectionFormat;
                return this;
        }

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/ffab9563/juneau-core/src/main/java/org/apache/juneau/dto/swagger/Items.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/swagger/Items.java 
b/juneau-core/src/main/java/org/apache/juneau/dto/swagger/Items.java
index b367b87..a9b2d19 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/swagger/Items.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/swagger/Items.java
@@ -16,6 +16,7 @@ import static org.apache.juneau.internal.ArrayUtils.*;
 
 import java.util.*;
 
+import org.apache.juneau.*;
 import org.apache.juneau.annotation.*;
 import org.apache.juneau.json.*;
 
@@ -245,9 +246,10 @@ public class Items extends SwaggerElement {
         */
        public Items setCollectionFormat(String collectionFormat) {
                if (isStrict() && ! contains(collectionFormat, 
VALID_COLLECTION_FORMATS))
-                       throw new RuntimeException(
-                               "Invalid value passed in to 
setCollectionFormat(String).  Value='"+collectionFormat+"', valid values="
-                       + 
JsonSerializer.DEFAULT_LAX.toString(VALID_COLLECTION_FORMATS));
+                       throw new FormattedRuntimeException(
+                               "Invalid value passed in to 
setCollectionFormat(String).  Value=''{0}'', valid values={1}",
+                               collectionFormat, VALID_COLLECTION_FORMATS
+                       );
                this.collectionFormat = collectionFormat;
                return this;
        }

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/ffab9563/juneau-core/src/main/java/org/apache/juneau/dto/swagger/ParameterInfo.java
----------------------------------------------------------------------
diff --git 
a/juneau-core/src/main/java/org/apache/juneau/dto/swagger/ParameterInfo.java 
b/juneau-core/src/main/java/org/apache/juneau/dto/swagger/ParameterInfo.java
index 52ae75e..d9e9d53 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/swagger/ParameterInfo.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/swagger/ParameterInfo.java
@@ -16,8 +16,8 @@ import static org.apache.juneau.internal.ArrayUtils.*;
 
 import java.util.*;
 
+import org.apache.juneau.*;
 import org.apache.juneau.annotation.*;
-import org.apache.juneau.json.*;
 
 /**
  * Describes a single operation parameter.
@@ -200,9 +200,10 @@ public class ParameterInfo extends SwaggerElement {
         */
        public ParameterInfo setIn(String in) {
                if (isStrict() && ! contains(in, VALID_IN))
-                       throw new RuntimeException(
-                               "Invalid value passed in to setIn(String).  
Value='"+in+"', valid values="
-                                       + 
JsonSerializer.DEFAULT_LAX.toString(VALID_IN));
+                       throw new FormattedRuntimeException(
+                               "Invalid value passed in to setIn(String).  
Value=''{0}'', valid values={1}",
+                               in, VALID_IN
+                       );
                this.in = in;
                if ("path".equals(in))
                        required = true;
@@ -387,9 +388,10 @@ public class ParameterInfo extends SwaggerElement {
         */
        public ParameterInfo setType(String type) {
                if (isStrict() && ! contains(type, VALID_TYPES))
-                       throw new RuntimeException(
-                               "Invalid value passed in to setType(String).  
Value='"+type+"', valid values="
-                                       + 
JsonSerializer.DEFAULT_LAX.toString(VALID_TYPES));
+                       throw new FormattedRuntimeException(
+                               "Invalid value passed in to setType(String).  
Value=''{0}'', valid values={1}",
+                               type, VALID_TYPES
+                       );
                this.type = type;
                return this;
        }
@@ -592,7 +594,10 @@ public class ParameterInfo extends SwaggerElement {
         */
        public ParameterInfo setCollectionFormat(String collectionFormat) {
                if (isStrict() && ! contains(collectionFormat, 
VALID_COLLECTION_FORMATS))
-                       throw new RuntimeException("Invalid value passed in to 
setCollectionFormat(String).  Value='"+collectionFormat+"', valid values=" + 
JsonSerializer.DEFAULT_LAX.toString(VALID_COLLECTION_FORMATS));
+                       throw new FormattedRuntimeException(
+                               "Invalid value passed in to 
setCollectionFormat(String).  Value=''{0}'', valid values={1}",
+                               collectionFormat, VALID_COLLECTION_FORMATS
+                       );
                this.collectionFormat = collectionFormat;
                return this;
        }

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/ffab9563/juneau-core/src/main/java/org/apache/juneau/dto/swagger/SecurityScheme.java
----------------------------------------------------------------------
diff --git 
a/juneau-core/src/main/java/org/apache/juneau/dto/swagger/SecurityScheme.java 
b/juneau-core/src/main/java/org/apache/juneau/dto/swagger/SecurityScheme.java
index 62f0af5..547ac3c 100644
--- 
a/juneau-core/src/main/java/org/apache/juneau/dto/swagger/SecurityScheme.java
+++ 
b/juneau-core/src/main/java/org/apache/juneau/dto/swagger/SecurityScheme.java
@@ -16,8 +16,8 @@ import static org.apache.juneau.internal.ArrayUtils.*;
 
 import java.util.*;
 
+import org.apache.juneau.*;
 import org.apache.juneau.annotation.*;
-import org.apache.juneau.json.*;
 
 /**
  * Allows the definition of a security scheme that can be used by the 
operations.
@@ -117,9 +117,10 @@ public class SecurityScheme extends SwaggerElement {
         */
        public SecurityScheme setType(String type) {
                if (isStrict() && ! contains(type, VALID_TYPES))
-                       throw new RuntimeException(
-                               "Invalid value passed in to setType(String).  
Value='"+type+"', valid values="
-                               + 
JsonSerializer.DEFAULT_LAX.toString(VALID_TYPES));
+                       throw new FormattedRuntimeException(
+                               "Invalid value passed in to setType(String).  
Value=''{0}'', valid values={1}",
+                               type, VALID_TYPES
+                       );
                this.type = type;
                return this;
        }

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/ffab9563/juneau-core/src/main/java/org/apache/juneau/html/HtmlDocTemplateBasic.java
----------------------------------------------------------------------
diff --git 
a/juneau-core/src/main/java/org/apache/juneau/html/HtmlDocTemplateBasic.java 
b/juneau-core/src/main/java/org/apache/juneau/html/HtmlDocTemplateBasic.java
index 8e1441c..326973f 100644
--- a/juneau-core/src/main/java/org/apache/juneau/html/HtmlDocTemplateBasic.java
+++ b/juneau-core/src/main/java/org/apache/juneau/html/HtmlDocTemplateBasic.java
@@ -42,16 +42,16 @@ public class HtmlDocTemplateBasic implements 
HtmlDocTemplate {
        public void style(HtmlDocSerializerSession session, HtmlWriter w, 
HtmlDocSerializer s, Object o) throws Exception {
 
                String[] styleImport = session.getStyleImport();
-               if (! ArrayUtils.contains("NONE", styleImport)) 
+               if (! ArrayUtils.contains("NONE", styleImport))
                        for (String si : styleImport)
-                               w.append(2, "@import 
").q().append(session.resolveUri(si)).q().appendln(";");
+                               w.append(2, "@import 
").q().append(session.resolveUri(si)).q().appendln("; ");
 
                if (session.isNoWrap())
-                       w.appendln("\ndiv.data * {white-space:nowrap;}");
+                       w.appendln("div.data * {white-space:nowrap;} ");
 
                if (session.getStyle() != null)
                        for (String style : session.getStyle())
-                               w.appendln(style);
+                               w.append(style).appendln(" ");
        }
 
        @Override /* HtmlDocTemplate */
@@ -59,7 +59,7 @@ public class HtmlDocTemplateBasic implements HtmlDocTemplate {
 
                if (session.getScript() != null)
                        for (String script : session.getScript())
-                               w.appendln(script);
+                               w.append(script);
        }
 
        @Override /* HtmlDocTemplate */

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/ffab9563/juneau-core/src/main/java/org/apache/juneau/ini/ConfigFileBuilder.java
----------------------------------------------------------------------
diff --git 
a/juneau-core/src/main/java/org/apache/juneau/ini/ConfigFileBuilder.java 
b/juneau-core/src/main/java/org/apache/juneau/ini/ConfigFileBuilder.java
index 0abbd52..63c6b38 100644
--- a/juneau-core/src/main/java/org/apache/juneau/ini/ConfigFileBuilder.java
+++ b/juneau-core/src/main/java/org/apache/juneau/ini/ConfigFileBuilder.java
@@ -19,6 +19,7 @@ import java.io.*;
 import java.nio.charset.*;
 import java.util.*;
 
+import org.apache.juneau.*;
 import org.apache.juneau.json.*;
 import org.apache.juneau.parser.*;
 import org.apache.juneau.serializer.*;
@@ -286,7 +287,10 @@ public class ConfigFileBuilder {
                                        for (String val : vals) {
                                                String[] x = val.split("\\=");
                                                if (x.length != 2)
-                                                       throw new 
RuntimeException("Invalid format for value: '"+val+"'.  Must be in the format 
'key=value'");
+                                                       throw new 
FormattedRuntimeException(
+                                                               "Invalid format 
for value: ''{0}''.  Must be in the format 'key=value'",
+                                                               val
+                                                       );
                                                cf.put(x[0], x[1]);
                                        }
                                        cf.save();

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/ffab9563/juneau-core/src/main/java/org/apache/juneau/internal/ClassUtils.java
----------------------------------------------------------------------
diff --git 
a/juneau-core/src/main/java/org/apache/juneau/internal/ClassUtils.java 
b/juneau-core/src/main/java/org/apache/juneau/internal/ClassUtils.java
index ca39426..89b9648 100644
--- a/juneau-core/src/main/java/org/apache/juneau/internal/ClassUtils.java
+++ b/juneau-core/src/main/java/org/apache/juneau/internal/ClassUtils.java
@@ -493,9 +493,9 @@ public final class ClassUtils {
                                        throw new RuntimeException(e);
                                }
                        }
-                       throw new RuntimeException("Could not resolve type: " + 
actualType);
+                       throw new FormattedRuntimeException("Could not resolve 
type: {0}", actualType);
                } else {
-                       throw new RuntimeException("Invalid type found in 
resolveParameterType: " + actualType);
+                       throw new FormattedRuntimeException("Invalid type found 
in resolveParameterType: {0}", actualType);
                }
        }
 

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/ffab9563/juneau-core/src/main/java/org/apache/juneau/internal/FileUtils.java
----------------------------------------------------------------------
diff --git 
a/juneau-core/src/main/java/org/apache/juneau/internal/FileUtils.java 
b/juneau-core/src/main/java/org/apache/juneau/internal/FileUtils.java
index 67900e0..c18fd02 100644
--- a/juneau-core/src/main/java/org/apache/juneau/internal/FileUtils.java
+++ b/juneau-core/src/main/java/org/apache/juneau/internal/FileUtils.java
@@ -16,6 +16,8 @@ import static org.apache.juneau.internal.ThrowableUtils.*;
 
 import java.io.*;
 
+import org.apache.juneau.*;
+
 /**
  * File utilities.
  */
@@ -34,13 +36,13 @@ public class FileUtils {
                if (f.exists()) {
                        if (clean) {
                                if (! delete(f))
-                                       throw new RuntimeException("Could not 
clean directory '"+f.getAbsolutePath()+"'");
+                                       throw new 
FormattedRuntimeException("Could not clean directory ''{0}''", 
f.getAbsolutePath());
                        } else {
                                return f;
                        }
                }
                if (! f.mkdirs())
-                       throw new RuntimeException("Could not create directory 
'" + f.getAbsolutePath() + "'");
+                       throw new FormattedRuntimeException("Could not create 
directory ''{0}''", f.getAbsolutePath());
                return f;
        }
 
@@ -87,7 +89,7 @@ public class FileUtils {
                        return;
                try {
                        if (! f.createNewFile())
-                               throw new RuntimeException("Could not create 
file '"+f.getAbsolutePath()+"'");
+                               throw new FormattedRuntimeException("Could not 
create file ''{0}''", f.getAbsolutePath());
                } catch (IOException e) {
                        throw new RuntimeException(e);
                }
@@ -107,13 +109,13 @@ public class FileUtils {
                if (lm == l)
                        l++;
                if (! f.setLastModified(l))
-                       throw new RuntimeException("Could not modify timestamp 
on file '"+f.getAbsolutePath()+"'");
+                       throw new FormattedRuntimeException("Could not modify 
timestamp on file ''{0}''", f.getAbsolutePath());
 
                // Linux only gives 1s precision, so set the date 1s into the 
future.
                if (lm == f.lastModified()) {
                        l += 1000;
                        if (! f.setLastModified(l))
-                               throw new RuntimeException("Could not modify 
timestamp on file '"+f.getAbsolutePath()+"'");
+                               throw new FormattedRuntimeException("Could not 
modify timestamp on file ''{0}''", f.getAbsolutePath());
                }
        }
 

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/ffab9563/juneau-core/src/main/java/org/apache/juneau/utils/Args.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/utils/Args.java 
b/juneau-core/src/main/java/org/apache/juneau/utils/Args.java
index fd8c8ad..a8c5e7c 100644
--- a/juneau-core/src/main/java/org/apache/juneau/utils/Args.java
+++ b/juneau-core/src/main/java/org/apache/juneau/utils/Args.java
@@ -130,7 +130,7 @@ public final class Args extends ObjectMap {
                        if (startsWith(s, '-')) {
                                key = s.substring(1);
                                if (key.matches("\\d*"))
-                                       throw new RuntimeException("Invalid 
optional key name '"+key+"'");
+                                       throw new 
FormattedRuntimeException("Invalid optional key name ''{0}''", key);
                                if (! containsKey(key))
                                        put(key, new ObjectList());
                        } else {

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/ffab9563/juneau-core/src/main/java/org/apache/juneau/utils/PojoQuery.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/utils/PojoQuery.java 
b/juneau-core/src/main/java/org/apache/juneau/utils/PojoQuery.java
index d448a7c..14abfaf 100644
--- a/juneau-core/src/main/java/org/apache/juneau/utils/PojoQuery.java
+++ b/juneau-core/src/main/java/org/apache/juneau/utils/PojoQuery.java
@@ -227,7 +227,7 @@ public final class PojoQuery {
                        return null;
 
                if (! type.isCollectionOrArray())
-                       throw new RuntimeException("Cannot call 
filterCollection() on class type " + type);
+                       throw new FormattedRuntimeException("Cannot call 
filterCollection() on class type ''{0}''", type);
 
                // Create a new ObjectList
                ObjectList l = (ObjectList)replaceWithMutables(input);
@@ -551,7 +551,7 @@ public final class PojoQuery {
                                // If a non-numeric value was passed in for a 
numeric value, just set the value to '0'.
                                // (I think this might resolve a workaround in 
custom queries).
                                if (! m.matches())
-                                       throw new RuntimeException("Numeric 
value didn't match pattern:  ["+token+"]");
+                                       throw new 
FormattedRuntimeException("Numeric value didn't match pattern:  ''{0}''", 
token);
                                        //m = numericPattern.matcher("0");
 
                                String arg1 = m.group(1);
@@ -873,7 +873,8 @@ public final class PojoQuery {
                        }
                }
 
-               if (cal == null) throw new RuntimeException("Invalid date 
encountered:  ["+seg+"]");
+               if (cal == null)
+                       throw new FormattedRuntimeException("Invalid date 
encountered:  ''{0}''", seg);
 
                return cal;
        }

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/ffab9563/juneau-core/src/main/java/org/apache/juneau/utils/SearchArgs.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/utils/SearchArgs.java 
b/juneau-core/src/main/java/org/apache/juneau/utils/SearchArgs.java
index a252c97..c86ee4e 100644
--- a/juneau-core/src/main/java/org/apache/juneau/utils/SearchArgs.java
+++ b/juneau-core/src/main/java/org/apache/juneau/utils/SearchArgs.java
@@ -17,6 +17,7 @@ import static org.apache.juneau.internal.StringUtils.*;
 
 import java.util.*;
 
+import org.apache.juneau.*;
 import org.apache.juneau.internal.*;
 
 /**
@@ -86,7 +87,7 @@ public class SearchArgs {
                                for (String s : StringUtils.split(searchTerms)) 
{
                                        int i = StringUtils.indexOf(s, '=', 
'>', '<');
                                        if (i == -1)
-                                               throw new 
RuntimeException("Invalid search terms: '"+searchTerms+"'");
+                                               throw new 
FormattedRuntimeException("Invalid search terms: ''{0}''", searchTerms);
                                        char c = s.charAt(i);
                                        search(s.substring(0, i).trim(), 
s.substring(c == '=' ? i+1 : i).trim());
                                }

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/ffab9563/juneau-core/src/main/java/org/apache/juneau/xml/NamespaceFactory.java
----------------------------------------------------------------------
diff --git 
a/juneau-core/src/main/java/org/apache/juneau/xml/NamespaceFactory.java 
b/juneau-core/src/main/java/org/apache/juneau/xml/NamespaceFactory.java
index 214eff5..d026611 100644
--- a/juneau-core/src/main/java/org/apache/juneau/xml/NamespaceFactory.java
+++ b/juneau-core/src/main/java/org/apache/juneau/xml/NamespaceFactory.java
@@ -76,7 +76,7 @@ public final class NamespaceFactory {
                        if (m.size() == 0)
                                return null;
                        if (m.size() > 1)
-                               throw new RuntimeException("Too many namespaces 
specified.  Only one allowed. '"+o+"'");
+                               throw new FormattedRuntimeException("Too many 
namespaces specified.  Only one allowed. ''{0}''", o);
                        Map.Entry<?,?> e = m.entrySet().iterator().next();
                        return get(e.getKey().toString(), 
e.getValue().toString());
                } catch (ParseException e) {
@@ -121,7 +121,7 @@ public final class NamespaceFactory {
                                for (Map.Entry e : m.entrySet())
                                        n[i++] = get(e.getKey().toString(), 
e.getValue().toString());
                        } else {
-                               throw new RuntimeException("Invalid type passed 
to NamespaceFactory.listFromObject: '"+o+"'");
+                               throw new FormattedRuntimeException("Invalid 
type passed to NamespaceFactory.listFromObject: ''{0}''", o);
                        }
                        return n;
                } catch (ParseException e) {

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/ffab9563/juneau-core/src/main/java/org/apache/juneau/xml/XmlParserSession.java
----------------------------------------------------------------------
diff --git 
a/juneau-core/src/main/java/org/apache/juneau/xml/XmlParserSession.java 
b/juneau-core/src/main/java/org/apache/juneau/xml/XmlParserSession.java
index 5d3f2d9..8b0f7c7 100644
--- a/juneau-core/src/main/java/org/apache/juneau/xml/XmlParserSession.java
+++ b/juneau-core/src/main/java/org/apache/juneau/xml/XmlParserSession.java
@@ -263,7 +263,7 @@ public class XmlParserSession extends ParserSession {
        public final String getElementAsString(XMLStreamReader r) {
                int t = r.getEventType();
                if (t > 2)
-                       throw new RuntimeException("Invalid event type on 
stream reader for elementToString() method: " + XmlUtils.toReadableEvent(r));
+                       throw new FormattedRuntimeException("Invalid event type 
on stream reader for elementToString() method: ''{0}''", 
XmlUtils.toReadableEvent(r));
                sb.setLength(0);
                sb.append("<").append(t == 1 ? "" : 
"/").append(r.getLocalName());
                if (t == 1)

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/ffab9563/juneau-core/src/main/java/org/apache/juneau/xml/XmlSchemaSerializer.java
----------------------------------------------------------------------
diff --git 
a/juneau-core/src/main/java/org/apache/juneau/xml/XmlSchemaSerializer.java 
b/juneau-core/src/main/java/org/apache/juneau/xml/XmlSchemaSerializer.java
index b34c836..21769aa 100644
--- a/juneau-core/src/main/java/org/apache/juneau/xml/XmlSchemaSerializer.java
+++ b/juneau-core/src/main/java/org/apache/juneau/xml/XmlSchemaSerializer.java
@@ -191,7 +191,7 @@ public class XmlSchemaSerializer extends XmlSerializer {
                                ns = defaultNs;
                        Schema s = get(ns);
                        if (s == null)
-                               throw new RuntimeException("No schema defined 
for namespace '"+ns+"'");
+                               throw new FormattedRuntimeException("No schema 
defined for namespace ''{0}''", ns);
                        return s;
                }
 

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/ffab9563/juneau-core/src/main/javadoc/overview.html
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/javadoc/overview.html 
b/juneau-core/src/main/javadoc/overview.html
index 79d7f5c..a8acd02 100644
--- a/juneau-core/src/main/javadoc/overview.html
+++ b/juneau-core/src/main/javadoc/overview.html
@@ -6920,7 +6920,7 @@
        
        <!-- 
========================================================================================================
 -->
        <a id="6.3.0"></a>
-       <h3 class='topic' onclick='toggle(this)'>6.3.0 (TBD)</h3>
+       <h3 class='topic' onclick='toggle(this)'>6.3.0 (Jun 30, 2017)</h3>
        <div class='topic'>
                <p>
                        Juneau 6.3.0 is a major update with significant new 
functionality for defining proxy interfaces against

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/ffab9563/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/PetStoreResource.java
----------------------------------------------------------------------
diff --git 
a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/PetStoreResource.java
 
b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/PetStoreResource.java
index febc781..4144caf 100644
--- 
a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/PetStoreResource.java
+++ 
b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/PetStoreResource.java
@@ -49,7 +49,7 @@ import org.apache.juneau.transforms.*;
                        + "</div>"
        )
 )
-public class PetStoreResource extends Resource {
+public class PetStoreResource extends ResourceJena {
        private static final long serialVersionUID = 1L;
 
        // Our database.
@@ -69,14 +69,25 @@ public class PetStoreResource extends Resource {
                summary="The complete list of pets in the store",
                bpExcludes="{Pet:'breed,getsAlongWith'}",
                
-               // Add a 'query' menu item and queryable support.
+               // Add 'query' and 'content-types' menu items.
                widgets={
                        QueryMenuItem.class,
+                       ContentTypeMenuItem.class,
                },
+
+               // Add our converter for POJO query support.
+               converters=Queryable.class,
+               
+               // Add our menu items in the nav links.
                htmldoc=@HtmlDoc(
-                       
links="{up:'request:/..',options:'servlet:/?method=OPTIONS',query:'$W{queryMenuItem}',contentTypes:'$W{contentTypeMenuItem}',source:'$C{Source/gitHub}/org/apache/juneau/examples/rest/PetStoreResource.java'}"
-               ),
-               converters=Queryable.class
+                       links="{"
+                               + "up:'request:/..',"
+                               + "options:'servlet:/?method=OPTIONS',"
+                               + "query:'$W{queryMenuItem}',"
+                               + "contentTypes:'$W{contentTypeMenuItem}',"
+                               + 
"source:'$C{Source/gitHub}/org/apache/juneau/examples/rest/PetStoreResource.java'"
+                       + "}"
+               )
        )
        public Collection<Pet> getPets() {
                return petDB.values();
@@ -115,13 +126,7 @@ public class PetStoreResource extends Resource {
 
        @Html(render=KindRender.class)  // Render as an icon in HTML.
        public static enum Kind {
-               CAT,
-               DOG,
-               BIRD,
-               FISH,
-               MOUSE,
-               RABBIT,
-               SNAKE
+               CAT, DOG, BIRD, FISH, MOUSE, RABBIT, SNAKE
        }
 
        public static class KindRender extends HtmlRender<Kind> {

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/ffab9563/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/RootResources.java
----------------------------------------------------------------------
diff --git 
a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/RootResources.java
 
b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/RootResources.java
index 710368b..e16db4a 100644
--- 
a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/RootResources.java
+++ 
b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/RootResources.java
@@ -30,7 +30,11 @@ import org.apache.juneau.rest.widget.*;
                ContentTypeMenuItem.class
        },
        htmldoc=@HtmlDoc(
-               
links="{options:'?method=OPTIONS',contentTypes:'$W{contentTypeMenuItem}',source:'$C{Source/gitHub}/org/apache/juneau/examples/rest/RootResources.java'}",
+               links="{"
+                       + "options:'?method=OPTIONS',"
+                       + "contentTypes:'$W{contentTypeMenuItem}',"
+                       + 
"source:'$C{Source/gitHub}/org/apache/juneau/examples/rest/RootResources.java'"
+               + "}",
                aside=""
                        + "<div style='max-width:400px' class='text'>"
                        + "     <p>This is an example of a 'router' page that 
serves as a jumping-off point to child resources.</p>"

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/ffab9563/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/SystemPropertiesResource.java
----------------------------------------------------------------------
diff --git 
a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/SystemPropertiesResource.java
 
b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/SystemPropertiesResource.java
index d8f3864..e61ee9b 100644
--- 
a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/SystemPropertiesResource.java
+++ 
b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/SystemPropertiesResource.java
@@ -44,14 +44,26 @@ import org.apache.juneau.rest.widget.*;
        // "servlet:/..." URIs are relative to the servlet URI.
        // "$C{...}" variables are pulled from the config file.
        htmldoc=@HtmlDoc(
-               
links="{up:'request:/..',options:'servlet:/?method=OPTIONS',form:'servlet:/formPage',contentTypes:'$W{contentTypeMenuItem}',source:'$C{Source/gitHub}/org/apache/juneau/examples/rest/SystemPropertiesResource.java'}",
+               
+               // Custom navigation links.
+               links="{"
+                       + "up:'request:/..',"
+                       + "options:'servlet:/?method=OPTIONS',"
+                       + "form:'servlet:/formPage',"
+                       + "contentTypes:'$W{contentTypeMenuItem}',"
+                       + 
"source:'$C{Source/gitHub}/org/apache/juneau/examples/rest/SystemPropertiesResource.java'"
+                       +"}",
+
+               // Custom page text in aside section.
                aside=""
                        + "<div style='max-width:800px' class='text'>"
                        + "     <p>Shows standard GET/PUT/POST/DELETE 
operations and use of Swagger annotations.</p>"
                        + "</div>",
-               style="aside {display:table-caption;}"
+                       
+               // Custom CSS styles applied to HTML view.
+               style="aside {display:table-caption} aside p {margin: 0px 
20px;}"
        ),
-
+               
        // Properties that get applied to all serializers and parsers.
        properties={
                // Use single quotes.

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/ffab9563/juneau-rest/src/main/java/org/apache/juneau/rest/RestUtils.java
----------------------------------------------------------------------
diff --git a/juneau-rest/src/main/java/org/apache/juneau/rest/RestUtils.java 
b/juneau-rest/src/main/java/org/apache/juneau/rest/RestUtils.java
index 8c72906..41c363b 100644
--- a/juneau-rest/src/main/java/org/apache/juneau/rest/RestUtils.java
+++ b/juneau-rest/src/main/java/org/apache/juneau/rest/RestUtils.java
@@ -16,6 +16,7 @@ import java.util.*;
 
 import javax.servlet.http.*;
 
+import org.apache.juneau.*;
 import org.apache.juneau.utils.*;
 
 /**
@@ -152,7 +153,7 @@ public final class RestUtils {
                                return requestURI;
                        throw new Exception("case=6");
                } catch (Exception e) {
-                       throw new RuntimeException("Could not find servlet path 
in request URI.  URI=["+requestURI+"], servletPath=["+servletPath+"]", e);
+                       throw new FormattedRuntimeException(e, "Could not find 
servlet path in request URI.  URI=''{0}'', servletPath=''{1}''", requestURI, 
servletPath);
                }
        }
 

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/ffab9563/juneau-rest/src/main/java/org/apache/juneau/rest/widget/MenuItemWidget.java
----------------------------------------------------------------------
diff --git 
a/juneau-rest/src/main/java/org/apache/juneau/rest/widget/MenuItemWidget.java 
b/juneau-rest/src/main/java/org/apache/juneau/rest/widget/MenuItemWidget.java
index 67c89ae..666da8c 100644
--- 
a/juneau-rest/src/main/java/org/apache/juneau/rest/widget/MenuItemWidget.java
+++ 
b/juneau-rest/src/main/java/org/apache/juneau/rest/widget/MenuItemWidget.java
@@ -58,7 +58,7 @@ public abstract class MenuItemWidget extends Widget {
         */
        @Override
        public String getScript(RestRequest req) throws Exception {
-               return 
getResourceAsString("MenuItemWidget.js").replaceAll("(?s)\\/\\*{2}(.*?)\\/\\*\\s*",
 "");
+               return loadScript("MenuItemWidget.js");
        }
 
        /**
@@ -67,6 +67,6 @@ public abstract class MenuItemWidget extends Widget {
         */
        @Override
        public String getStyle(RestRequest req) throws Exception {
-               return 
getResourceAsString("MenuItemWidget.css").replaceAll("(?s)\\/\\*{2}(.*?)\\/\\*\\s*",
 "");
+               return loadStyle("MenuItemWidget.css");
        }
 }

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/ffab9563/juneau-rest/src/main/java/org/apache/juneau/rest/widget/QueryMenuItem.java
----------------------------------------------------------------------
diff --git 
a/juneau-rest/src/main/java/org/apache/juneau/rest/widget/QueryMenuItem.java 
b/juneau-rest/src/main/java/org/apache/juneau/rest/widget/QueryMenuItem.java
index fcef7ff..cadc7dc 100644
--- a/juneau-rest/src/main/java/org/apache/juneau/rest/widget/QueryMenuItem.java
+++ b/juneau-rest/src/main/java/org/apache/juneau/rest/widget/QueryMenuItem.java
@@ -74,7 +74,7 @@ public class QueryMenuItem extends MenuItemWidget {
        public String getStyle(RestRequest req) throws Exception {
                return super.getStyle(req)
                        + "\n"
-                       + 
getResourceAsString("QueryMenuItem.css").replaceFirst("(?s)\\/\\*{2}(.*?)\\/\\*\\s*",
 "");
+                       + loadStyle("QueryMenuItem.css");
        }
 
        /**
@@ -82,6 +82,6 @@ public class QueryMenuItem extends MenuItemWidget {
         */
        @Override /* Widget */
        public String getHtml(RestRequest req) throws Exception {
-               return 
getResourceAsString("QueryMenuItem.html").replaceFirst("(?s)<!--(.*?)-->\\s*", 
"");
+               return getResourceAsString("QueryMenuItem.html");
        }
 }

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/ffab9563/juneau-rest/src/main/java/org/apache/juneau/rest/widget/Widget.java
----------------------------------------------------------------------
diff --git 
a/juneau-rest/src/main/java/org/apache/juneau/rest/widget/Widget.java 
b/juneau-rest/src/main/java/org/apache/juneau/rest/widget/Widget.java
index 4df720e..5783c50 100644
--- a/juneau-rest/src/main/java/org/apache/juneau/rest/widget/Widget.java
+++ b/juneau-rest/src/main/java/org/apache/juneau/rest/widget/Widget.java
@@ -213,4 +213,58 @@ public abstract class Widget {
        protected String getResourceAsString(String name, Locale locale) throws 
IOException {
                return resourceFinder.getResourceAsString(name, locale);
        }
+
+       /**
+        * Convenience method for calling {@link #getResourceAsString(String)} 
except also strips Javascript comments from
+        * the file.
+        *
+        * <p>
+        * Comments are assumed to be Java-style block comments: <js>"/*"</js>.
+        *
+        * @param name Name of the desired resource.
+        * @return The resource converted to a string, or <jk>null</jk> if the 
resource could not be found.
+        * @throws IOException
+        */
+       protected String loadScript(String name) throws IOException {
+               String s = getResourceAsString(name);
+               if (s != null)
+                       s = s.replaceAll("(?s)\\/\\*(.*?)\\*\\/\\s*", "");
+               return s;
+       }
+
+       /**
+        * Convenience method for calling {@link #getResourceAsString(String)} 
except also strips CSS comments from
+        * the file.
+        *
+        * <p>
+        * Comments are assumed to be Java-style block comments: <js>"/*"</js>.
+        *
+        * @param name Name of the desired resource.
+        * @return The resource converted to a string, or <jk>null</jk> if the 
resource could not be found.
+        * @throws IOException
+        */
+       protected String loadStyle(String name) throws IOException {
+               String s = getResourceAsString(name);
+               if (s != null)
+                       s = s.replaceAll("(?s)\\/\\*(.*?)\\*\\/\\s*", "");
+               return s;
+       }
+
+       /**
+        * Convenience method for calling {@link #getResourceAsString(String)} 
except also strips HTML comments from the
+        * file.
+        *
+        * <p>
+        * Comment are assumed to be <js>"<!-- -->"</js> code blocks.
+        *
+        * @param name Name of the desired resource.
+        * @return The resource converted to a string, or <jk>null</jk> if the 
resource could not be found.
+        * @throws IOException
+        */
+       protected String loadHtml(String name) throws IOException {
+               String s = getResourceAsString(name);
+               if (s != null)
+                       s = s.replaceAll("(?s)<!--(.*?)-->\\s*", "");
+               return s;
+       }
 }


Reply via email to