This is an automated email from the ASF dual-hosted git repository.

jamesbognar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/juneau.git


The following commit(s) were added to refs/heads/master by this push:
     new 2ccd72d  Clean up examples.
2ccd72d is described below

commit 2ccd72dd6b301954d3d30474c99dedb5d849e2bc
Author: JamesBognar <[email protected]>
AuthorDate: Sun Apr 15 14:39:18 2018 -0400

    Clean up examples.
---
 juneau-doc/src/main/javadoc/overview.html          | 113 ++-------------------
 .../rest/{RootResources.java => DtoExamples.java}  |  42 ++------
 .../apache/juneau/examples/rest/RootResources.java |   7 +-
 .../juneau/examples/rest/TumblrParserResource.java | 102 -------------------
 4 files changed, 15 insertions(+), 249 deletions(-)

diff --git a/juneau-doc/src/main/javadoc/overview.html 
b/juneau-doc/src/main/javadoc/overview.html
index 0264198..edd958a 100644
--- a/juneau-doc/src/main/javadoc/overview.html
+++ b/juneau-doc/src/main/javadoc/overview.html
@@ -400,7 +400,6 @@
                <li><p><a class='doclink' 
href='#juneau-examples-rest.TempDirResource'>TempDirResource</a></p>
                <li><p><a class='doclink' 
href='#juneau-examples-rest.AtomFeedResource'>AtomFeedResource</a></p>
                <li><p><a class='doclink' 
href='#juneau-examples-rest.DockerRegistryResource'>DockerRegistryResource</a></p>
-               <li><p><a class='doclink' 
href='#juneau-examples-rest.TumblrParserResource'>TumblrParserResource</a></p>
                <li><p><a class='doclink' 
href='#juneau-examples-rest.PhotosResource'>PhotosResource</a></p>
                <li><p><a class='doclink' 
href='#juneau-examples-rest.JsonSchemaResource'>JsonSchemaResource</a></p>
                <li><p><a class='doclink' 
href='#juneau-examples-rest.SqlQueryResource'>SqlQueryResource</a></p>
@@ -11097,7 +11096,6 @@
                        AtomFeedResource.<jk>class</jk>,
                        JsonSchemaResource.<jk>class</jk>,
                        SqlQueryResource.<jk>class</jk>,
-                       TumblrParserResource.<jk>class</jk>,
                        CodeFormatterResource.<jk>class</jk>,
                        UrlEncodedFormResource.<jk>class</jk>,
                        SourceResource.<jk>class</jk>,
@@ -17476,7 +17474,6 @@
                        AtomFeedResource.<jk>class</jk>,
                        JsonSchemaResource.<jk>class</jk>,
                        SqlQueryResource.<jk>class</jk>,
-                       TumblrParserResource.<jk>class</jk>,
                        CodeFormatterResource.<jk>class</jk>,
                        UrlEncodedFormResource.<jk>class</jk>,
                        ConfigResource.<jk>class</jk>,
@@ -20019,106 +20016,8 @@
        </div>  
 
        <!-- 
=======================================================================================================
 -->
-       <a id='juneau-examples-rest.TumblrParserResource'></a>
-       <h4 class='topic' onclick='toggle(this)'>12.12 - 
TumblrParserResource</h4>
-       <div class='topic'>
-               <p>
-                       <b>Note:</b>  As of March 2018, this resource is known 
to not work against the Tumblr API.
-               </p>
-               <p>     
-                       The <l>TumblrParserResource</l> class shows examples of 
the following:
-               </p>
-               <ul class='spaced-list'>
-                       <li>
-                               Using {@link 
org.apache.juneau.rest.client.RestClient} to retrieve information from other 
REST resources.
-                       <li>
-                               Using {@link org.apache.juneau.ObjectMap} and 
{@link org.apache.juneau.ObjectList} to produce
-                               generalized POJO models.
-               </ul>
-               <p>
-                       Pointing a browser at a Tumblr blog name, such as 
<l>ibmblr</l> causes a REST call to be make to the Tumblr
-                       blog and the results to be parsed:
-               </p>
-               <p class='bcode w800'>
-       http://localhost:10000/tumblrParser/ibmblr
-               </p>                    
-               <img class='bordered w800' 
src='doc-files/juneau-examples-rest.TumblrParserResource.1.png'>
-               
-               <h5 class='figure'>TumblrParserResource.java</h5>
-               <p class='bcode w800'>
-       <ja>@RestResource</ja>( 
-               path=<js>"/tumblrParser"</js>,
-               messages=<js>"nls/TumblrParserResource"</js>,
-               title=<js>"Tumblr parser service"</js>,
-               description=<js>"Specify a URL to a Tumblr blog and parse the 
results."</js>,
-               htmldoc=<ja>@HtmlDoc</ja>(
-                       navlinks={
-                               <js>"up: request:/.."</js>,
-                               <js>"options: servlet:/?method=OPTIONS"</js>,
-                               <js>"source: 
$C{Source/gitHub}/org/apache/juneau/examples/rest/$R{servletClassSimple}.java"</js>
-                       },
-                       aside={
-                               <js>"&lt;div style='min-width:200px' 
class='text'&gt;"</js>,
-                               <js>"   &lt;p&gt;An example of a REST interface 
that retrieves data from another REST interface.&lt;/p&gt;"</js>,
-                               <js>"   &lt;p&gt;&lt;a class='link' 
href='$U{servlet:/ibmblr}'&gt;try me&lt;/a&gt;&lt;/p&gt;"</js>,
-                               <js>"&lt;/div&gt;"</js>
-                       }
-               )
-       ) 
-       <jk>public class</jk> TumblrParserResource <jk>extends</jk> 
BasicRestServlet { 
-               <jk>private static final long</jk> <jsf>serialVersionUID</jsf> 
= 1L; 
-       
-               <ja>@RestMethod</ja>(name=<jsf>GET</jsf>, path=<js>"/"</js>) 
-               <jk>public</jk> String getInstructions() <jk>throws</jk> 
Exception { 
-                       <jk>return</jk> <js>"Append the Tumblr blog name to the 
URL above (e.g. /tumblrParser/mytumblrblog)"</js>; 
-               } 
-               
-               <ja>@RestMethod</ja>(name=<jsf>GET</jsf>, 
path=<js>"/{blogName}"</js>) 
-               <jk>public</jk> ObjectList parseBlog(<ja>@Path</ja> String 
blogName) <jk>throws</jk> Exception { 
-                       ObjectList l = <jk>new</jk> ObjectList(); 
-                       RestClient rc = RestClient.<jsm>create</jsm>().build(); 
-                       String site = <js>"http:<jc>//"</js> + blogName + 
<js>".tumblr.com/api/read/json"</js>;</jc> 
-                       ObjectMap m = 
rc.doGet(site).getResponse(ObjectMap.<jk>class</jk>); 
-                       <jk>int</jk> postsTotal = 
m.getInt(<js>"posts-total"</js>); 
-                       <jk>for</jk> (<jk>int</jk> i = 0; i &lt; postsTotal; i 
+= 20) { 
-                               m = rc.doGet(site + <js>"?start="</js> + i + 
<js>"&amp;num=20&amp;transform=text"</js>).getResponse(ObjectMap.<jk>class</jk>);
 
-                               ObjectList ol = 
m.getObjectList(<js>"posts"</js>); 
-                               <jk>for</jk> (<jk>int</jk> j = 0; j &lt; 
ol.size(); j++) { 
-                                       ObjectMap om = ol.getObjectMap(j); 
-                                       String type = 
om.getString(<js>"type"</js>); 
-                                       Entry e = <jk>new</jk> Entry(); 
-                                       e.date = om.getString(<js>"date"</js>); 
-                                       <jk>if</jk> 
(type.equals(<js>"link"</js>)) 
-                                               e.entry = <jk>new</jk> 
Link(om.getString(<js>"link-text"</js>), om.getString(<js>"link-url"</js>)); 
-                                       <jk>else if</jk> 
(type.equals(<js>"audio"</js>)) 
-                                               e.entry = <jk>new</jk> 
ObjectMap().append(<js>"type"</js>,<js>"audio"</js>).append(<js>"audio-caption"</js>,
 om.getString(<js>"audio-caption"</js>)); 
-                                       <jk>else if</jk> 
(type.equals(<js>"video"</js>)) 
-                                               e.entry = <jk>new</jk> 
ObjectMap().append(<js>"type"</js>,<js>"video"</js>).append(<js>"video-caption"</js>,
 om.getString(<js>"video-caption"</js>)); 
-                                       <jk>else if</jk> 
(type.equals(<js>"quote"</js>)) 
-                                               e.entry = <jk>new</jk> 
ObjectMap().append(<js>"type"</js>,<js>"quote"</js>).append(<js>"quote-source"</js>,
 om.getString(<js>"quote-source"</js>)).append(<js>"quote-text"</js>, 
om.getString(<js>"quote-text"</js>)); 
-                                       <jk>else if</jk> 
(type.equals(<js>"regular"</js>)) 
-                                               e.entry = 
om.getString(<js>"regular-body"</js>); 
-                                       <jk>else if</jk> 
(type.equals(<js>"photo"</js>)) 
-                                               e.entry = <jk>new</jk> 
Img(om.getString(<js>"photo-url-250"</js>)); 
-                                       <jk>else</jk> 
-                                               e.entry = <jk>new</jk> 
ObjectMap().append(<js>"type"</js>, type); 
-                                       l.add(e); 
-                               } 
-                       } 
-                       <jk>return</jk> l; 
-               } 
-               
-               <jk>public static class</jk> Entry { 
-                       <jk>public</jk> String <jf>date</jf>; 
-                       <jk>public</jk> Object <jf>entry</jf>; 
-               } 
-       }               
-               </p>
-       </div>  
-
-       <!-- 
=======================================================================================================
 -->
        <a id='juneau-examples-rest.PhotosResource'></a>
-       <h4 class='topic' onclick='toggle(this)'>12.13 - PhotosResource</h4>
+       <h4 class='topic' onclick='toggle(this)'>12.12 - PhotosResource</h4>
        <div class='topic'>
                <p>     
                        The <l>PhotosResource</l> class shows examples of the 
following:
@@ -20295,7 +20194,7 @@
 
        <!-- 
=======================================================================================================
 -->
        <a id='juneau-examples-rest.JsonSchemaResource'></a>
-       <h4 class='topic' onclick='toggle(this)'>12.14 - JsonSchemaResource</h4>
+       <h4 class='topic' onclick='toggle(this)'>12.13 - JsonSchemaResource</h4>
        <div class='topic'>
                <p>     
                        The <l>JsonSchemaResource</l> class shows examples of 
the following:
@@ -20398,7 +20297,7 @@
 
        <!-- 
=======================================================================================================
 -->
        <a id='juneau-examples-rest.SqlQueryResource'></a>
-       <h4 class='topic' onclick='toggle(this)'>12.15 - SqlQueryResource</h4>
+       <h4 class='topic' onclick='toggle(this)'>12.14 - SqlQueryResource</h4>
        <div class='topic'>
                <p>     
                        The <l>SqlQueryResource</l> class shows examples of the 
following:
@@ -20608,7 +20507,7 @@
 
        <!-- 
=======================================================================================================
 -->
        <a id='juneau-examples-rest.ConfigResource'></a>
-       <h4 class='topic' onclick='toggle(this)'>12.16 - ConfigResource</h4>
+       <h4 class='topic' onclick='toggle(this)'>12.15 - ConfigResource</h4>
        <div class='topic'>
                <p>
                        The {@link 
org.apache.juneau.microservice.resources.ConfigResource} class is a predefined 
reusable resource.
@@ -20763,7 +20662,7 @@
 
        <!-- 
=======================================================================================================
 -->
        <a id='juneau-examples-rest.LogsResource'></a>
-       <h4 class='topic' onclick='toggle(this)'>12.17 - LogsResource</h4>
+       <h4 class='topic' onclick='toggle(this)'>12.16 - LogsResource</h4>
        <div class='topic'>
                <p>
                        The {@link 
org.apache.juneau.microservice.resources.LogsResource} class is a reusable 
predefined resource.
@@ -20780,7 +20679,7 @@
 
        <!-- 
=======================================================================================================
 -->
        <a id='juneau-examples-rest.PetStoreResource'></a>
-       <h4 class='topic' onclick='toggle(this)'>12.18 - PetStoreResource</h4>
+       <h4 class='topic' onclick='toggle(this)'>12.17 - PetStoreResource</h4>
        <div class='topic'>
                <p>
                        The <code>PetStoreResource</code> class provides 
examples of the following: 
diff --git 
a/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/RootResources.java
 
b/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/DtoExamples.java
similarity index 58%
copy from 
juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/RootResources.java
copy to 
juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/DtoExamples.java
index 8d5290b..c35be95 100644
--- 
a/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/RootResources.java
+++ 
b/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/DtoExamples.java
@@ -14,25 +14,24 @@ package org.apache.juneau.examples.rest;
 
 import static org.apache.juneau.serializer.WriterSerializer.*;
 
-import org.apache.juneau.examples.rest.addressbook.*;
 import org.apache.juneau.microservice.*;
-import org.apache.juneau.microservice.resources.*;
 import org.apache.juneau.rest.annotation.*;
 import org.apache.juneau.rest.widget.*;
 
 /**
- * Sample REST resource showing how to implement a "router" resource page.
+ * Sample REST resource showing how to implement a nested "router" resource 
page.
  */
 @RestResource(
-       path="/",
-       title="Root resources",
-       description="Example of a router resource page.",
+       path="/dto",
+       title="DTO examples",
+       description="Example serialization of predefined Data Transfer 
Objects.",
        htmldoc=@HtmlDoc(
                widgets={
                        ContentTypeMenuItem.class,
                        ThemeMenuItem.class
                },
                navlinks={
+                       "up: request:/..",
                        "options: ?method=OPTIONS",
                        "$W{ContentTypeMenuItem}",
                        "$W{ThemeMenuItem}",
@@ -40,12 +39,7 @@ import org.apache.juneau.rest.widget.*;
                },
                aside={
                        "<div style='max-width:400px' class='text'>",
-                       "       <p>This is an example of a 'router' page that 
serves as a jumping-off point to child resources.</p>",
-                       "       <p>Resources can be nested arbitrarily deep 
through router pages.</p>",
-                       "       <p>Note the <span class='link'>options</span> 
link provided that lets you see the generated swagger doc for this page.</p>",
-                       "       <p>Also note the <span 
class='link'>sources</span> link on these pages to view the source code for the 
page.</p>",
-                       "       <p>All content on pages in the UI are 
serialized POJOs.  In this case, it's a serialized array of beans with 2 
properties, 'name' and 'description'.</p>",
-                       "       <p>Other features (such as this aside) are 
added through annotations.</p>",
+                       "       <p>This is an example of a nested 'router' page 
that serves as a jumping-off point to other child resources.</p>",
                        "</div>"
                }
        ),
@@ -56,33 +50,11 @@ import org.apache.juneau.rest.widget.*;
                @Property(name=WSERIALIZER_quoteChar, value="'")
        },
        children={
-               HelloWorldResource.class,
-               PetStoreResource.class,
-               org.apache.juneau.examples.rest.petstore.PetStoreResource.class,
-               SystemPropertiesResource.class,
-               MethodExampleResource.class,
-               RequestEchoResource.class,
-               TempDirResource.class,
-               AddressBookResource.class,
-               SampleRemoteableServlet.class,
-               PhotosResource.class,
                AtomFeedResource.class,
                JsonSchemaResource.class,
-               SqlQueryResource.class,
-               TumblrParserResource.class,
-               CodeFormatterResource.class,
-               UrlEncodedFormResource.class,
-               ConfigResource.class,
-               LogsResource.class,
-               DockerRegistryResource.class,
                PredefinedLabelsResource.class,
-               DebugResource.class,
-               ShutdownResource.class
        }
 )
-public class RootResources extends BasicRestServletJenaGroup {
-       // IMPORTANT!  If you don't need RDF support, change the parent class 
to ResourceGroup.
-       // It allows you to remove the Jena prerequisite.
-
+public class DtoExamples extends BasicRestServletJenaGroup {
        private static final long serialVersionUID = 1L;
 }
diff --git 
a/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/RootResources.java
 
b/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/RootResources.java
index 8d5290b..fc35343 100644
--- 
a/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/RootResources.java
+++ 
b/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/RootResources.java
@@ -62,20 +62,17 @@ import org.apache.juneau.rest.widget.*;
                SystemPropertiesResource.class,
                MethodExampleResource.class,
                RequestEchoResource.class,
-               TempDirResource.class,
                AddressBookResource.class,
                SampleRemoteableServlet.class,
+               DtoExamples.class,
                PhotosResource.class,
-               AtomFeedResource.class,
-               JsonSchemaResource.class,
                SqlQueryResource.class,
-               TumblrParserResource.class,
                CodeFormatterResource.class,
                UrlEncodedFormResource.class,
+               TempDirResource.class,
                ConfigResource.class,
                LogsResource.class,
                DockerRegistryResource.class,
-               PredefinedLabelsResource.class,
                DebugResource.class,
                ShutdownResource.class
        }
diff --git 
a/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/TumblrParserResource.java
 
b/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/TumblrParserResource.java
deleted file mode 100644
index a39bef7..0000000
--- 
a/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/TumblrParserResource.java
+++ /dev/null
@@ -1,102 +0,0 @@
-// 
***************************************************************************************************************************
-// * 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.examples.rest;
-
-import static org.apache.juneau.http.HttpMethodName.*;
-
-import org.apache.juneau.*;
-import org.apache.juneau.dto.*;
-import org.apache.juneau.dto.html5.*;
-import org.apache.juneau.rest.*;
-import org.apache.juneau.rest.annotation.*;
-import org.apache.juneau.rest.client.*;
-
-@RestResource(
-       path="/tumblrParser",
-       messages="nls/TumblrParserResource",
-       title="Tumblr parser service",
-       description="Specify a URL to a Tumblr blog and parse the results.",
-       htmldoc=@HtmlDoc(
-               navlinks={
-                       "up: request:/..",
-                       "options: servlet:/?method=OPTIONS",
-                       "source: 
$C{Source/gitHub}/org/apache/juneau/examples/rest/$R{servletClassSimple}.java"
-               },
-               aside={
-                       "<div style='min-width:200px' class='text'>",
-                       "       <p>An example of a REST interface that 
retrieves data from another REST interface.</p>",
-                       "       <p><a class='link' 
href='$U{servlet:/ibmblr}'>try me</a></p>",
-                       "</div>"
-               }
-       ),
-       swagger={
-               "info: {",
-                       "contact:{name:'Juneau 
Developer',email:'[email protected]'},",
-                       "license:{name:'Apache 
2.0',url:'http://www.apache.org/licenses/LICENSE-2.0.html'},",
-                       "version:'2.0',",
-                       "termsOfService:'You are on your own.'",
-               "},",
-               "externalDocs:{description:'Apache 
Juneau',url:'http://juneau.apache.org'}"
-       }
-)
-public class TumblrParserResource extends BasicRestServlet {
-       private static final long serialVersionUID = 1L;
-
-       private static final int MAX_POSTS = 100;
-
-       @RestMethod(name=GET, path="/", summary="Get the instructions page")
-       public String getInstructions() throws Exception {
-               return "Append the Tumblr blog name to the URL above (e.g. 
/tumblrParser/mytumblrblog)";
-       }
-
-       @RestMethod(name=GET, path="/{blogName}", summary="Parse the specified 
blog")
-       public ObjectList parseBlog(@Path String blogName) throws Exception {
-               ObjectList l = new ObjectList();
-               try (RestClient rc = RestClient.create().build()) {
-                       String site = "http://"; + blogName + 
".tumblr.com/api/read/json";
-                       ObjectMap m = 
rc.doGet(site).getResponse(ObjectMap.class);
-                       int postsTotal = Math.min(m.getInt("posts-total"), 
MAX_POSTS);
-                       for (int i = 0; i < postsTotal; i += 20) {
-                               m = rc.doGet(site + "?start=" + i + 
"&num=20&filter=text").getResponse(ObjectMap.class);
-                               ObjectList ol = m.getObjectList("posts");
-                               for (int j = 0; j < ol.size(); j++) {
-                                       ObjectMap om = ol.getObjectMap(j);
-                                       String type = om.getString("type");
-                                       Entry e = new Entry();
-                                       e.date = om.getString("date");
-                                       if (type.equals("link"))
-                                               e.entry = new 
LinkString(om.getString("link-text"), om.getString("link-url"));
-                                       else if (type.equals("audio"))
-                                               e.entry = new 
ObjectMap().append("type","audio").append("audio-caption", 
om.getString("audio-caption"));
-                                       else if (type.equals("video"))
-                                               e.entry = new 
ObjectMap().append("type","video").append("video-caption", 
om.getString("video-caption"));
-                                       else if (type.equals("quote"))
-                                               e.entry = new 
ObjectMap().append("type","quote").append("quote-source", 
om.getString("quote-source")).append("quote-text", om.getString("quote-text"));
-                                       else if (type.equals("regular"))
-                                               e.entry = 
om.getString("regular-body");
-                                       else if (type.equals("photo"))
-                                               e.entry = new 
Img().src(om.getString("photo-url-250"));
-                                       else
-                                               e.entry = new 
ObjectMap().append("type", type);
-                                       l.add(e);
-                               }
-                       }
-               }
-               return l;
-       }
-
-       public static class Entry {
-               public String date;
-               public Object entry;
-       }
-}

-- 
To stop receiving notification emails like this one, please contact
[email protected].

Reply via email to