incubator-isis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danhayw...@apache.org
Subject svn commit: r1209891 - in /incubator/isis/trunk/examples/onlinedemo/webapp/src/main: java/org/apache/isis/examples/onlinedemo/filters/RedirectToDocsFilter.java webapp/WEB-INF/web.xml webapp/doc/index.html
Date Sat, 03 Dec 2011 11:30:47 GMT
Author: danhaywood
Date: Sat Dec  3 11:30:47 2011
New Revision: 1209891

URL: http://svn.apache.org/viewvc?rev=1209891&view=rev
Log:
ISIS-130: fixes for onlinedemo docs and redirecting

Modified:
    incubator/isis/trunk/examples/onlinedemo/webapp/src/main/java/org/apache/isis/examples/onlinedemo/filters/RedirectToDocsFilter.java
    incubator/isis/trunk/examples/onlinedemo/webapp/src/main/webapp/WEB-INF/web.xml
    incubator/isis/trunk/examples/onlinedemo/webapp/src/main/webapp/doc/index.html

Modified: incubator/isis/trunk/examples/onlinedemo/webapp/src/main/java/org/apache/isis/examples/onlinedemo/filters/RedirectToDocsFilter.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/examples/onlinedemo/webapp/src/main/java/org/apache/isis/examples/onlinedemo/filters/RedirectToDocsFilter.java?rev=1209891&r1=1209890&r2=1209891&view=diff
==============================================================================
--- incubator/isis/trunk/examples/onlinedemo/webapp/src/main/java/org/apache/isis/examples/onlinedemo/filters/RedirectToDocsFilter.java
(original)
+++ incubator/isis/trunk/examples/onlinedemo/webapp/src/main/java/org/apache/isis/examples/onlinedemo/filters/RedirectToDocsFilter.java
Sat Dec  3 11:30:47 2011
@@ -11,6 +11,8 @@ import javax.servlet.ServletResponse;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.apache.log4j.Logger;
+
 /**
  * This filter attempts to ensure that would-be users of the framework are
  * directed to the bundled documentation, rather than just hitting the
@@ -27,6 +29,8 @@ import javax.servlet.http.HttpServletRes
  * to continue through.
  */
 public class RedirectToDocsFilter implements Filter {
+
+    private static final Logger LOG = Logger.getLogger(RedirectToDocsFilter.class);
     
     private static final String REDIRECT_TO_KEY = "redirectTo";
     private static final String REDIRECT_TO_DEFAULT = "/index.html";
@@ -42,15 +46,26 @@ public class RedirectToDocsFilter implem
         if(redirectTo == null) {
             redirectTo = REDIRECT_TO_DEFAULT;
         }
+        System.out.println("redirectToDocsFilter: redirectTo=" + redirectTo);
+        LOG.info("redirectToDocsFilter: redirectTo=" + redirectTo);
     }
 
     @Override
+    public void destroy() {
+    }
+
+    
+    @Override
     public void doFilter(final ServletRequest request, final ServletResponse response, FilterChain
chain) throws IOException, ServletException {
         final HttpServletRequest httpServletRequest = (HttpServletRequest) request;
         final HttpServletResponse httpServletResponse = (HttpServletResponse) response;
         
-        // do nothing if not mapped to "/"
-        if(!"/".equals(httpServletRequest.getServletPath())) {
+        // do nothing if not requesting "/"
+        final String servletPath = httpServletRequest.getServletPath();
+        System.out.println("redirectToDocsFilter: servletPath: " + servletPath);
+        LOG.info("redirectToDocsFilter: servletPath: " + servletPath);
+        
+        if(!"/".equals(servletPath)) {
             chain.doFilter(request, response);
             return;
         }
@@ -63,11 +78,21 @@ public class RedirectToDocsFilter implem
         }
         
         // otherwise redirect
-        httpServletResponse.sendRedirect(redirectTo);
+        final String redirect = combine(httpServletRequest.getContextPath(), redirectTo);
+        System.out.println("redirectToDocsFilter: redirecting to: " + redirect);
+        LOG.info("redirectToDocsFilter: redirecting to: " + redirect);
+        
+        httpServletResponse.sendRedirect(redirect);
     }
 
-    @Override
-    public void destroy() {
+    private static String combine(String str1, String str2) {
+        final StringBuilder buf = new StringBuilder(str1);
+        if(!str2.startsWith("/")) {
+            buf.append("/");
+        }
+        buf.append(str2);
+        return buf.toString();
     }
+
     
 }

Modified: incubator/isis/trunk/examples/onlinedemo/webapp/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/examples/onlinedemo/webapp/src/main/webapp/WEB-INF/web.xml?rev=1209891&r1=1209890&r2=1209891&view=diff
==============================================================================
--- incubator/isis/trunk/examples/onlinedemo/webapp/src/main/webapp/WEB-INF/web.xml (original)
+++ incubator/isis/trunk/examples/onlinedemo/webapp/src/main/webapp/WEB-INF/web.xml Sat Dec
 3 11:30:47 2011
@@ -62,7 +62,7 @@
     </filter>
     <filter-mapping>
         <filter-name>RedirectToDocsFilter</filter-name>
-        <url-pattern>/</url-pattern>
+        <url-pattern>*</url-pattern>
     </filter-mapping>
 
     <filter>
@@ -182,19 +182,6 @@
     </servlet-mapping>
 
     <servlet>
-        <servlet-name>Forward</servlet-name>
-        <servlet-class>org.apache.isis.core.webapp.routing.ForwardingServlet</servlet-class>
-        <init-param>
-            <param-name>forwardTo</param-name>
-            <param-value>logon.htmlviewer</param-value>
-        </init-param>
-    </servlet>
-    <servlet-mapping>
-        <servlet-name>Forward</servlet-name>
-        <url-pattern>/htmlviewer</url-pattern>
-    </servlet-mapping>
-
-    <servlet>
         <servlet-name>Controller</servlet-name>
         <servlet-class>org.apache.isis.viewer.html.servlet.ControllerServlet</servlet-class>
     </servlet>
@@ -241,5 +228,9 @@
         <url-pattern>*.html</url-pattern>
     </servlet-mapping>
 	
+	<welcome-file-list>
+	   <!-- override Tomcat's default -->
+	   <welcome-file>/</welcome-file>
+	</welcome-file-list>
 	
 </web-app>

Modified: incubator/isis/trunk/examples/onlinedemo/webapp/src/main/webapp/doc/index.html
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/examples/onlinedemo/webapp/src/main/webapp/doc/index.html?rev=1209891&r1=1209890&r2=1209891&view=diff
==============================================================================
--- incubator/isis/trunk/examples/onlinedemo/webapp/src/main/webapp/doc/index.html (original)
+++ incubator/isis/trunk/examples/onlinedemo/webapp/src/main/webapp/doc/index.html Sat Dec
 3 11:30:47 2011
@@ -47,9 +47,11 @@
   better idea of <i>Isis</i>' programming model, you can also view the <a
   href="xref/index.html">source code</a> and browse the <a
   href="apidocs/index.html">javadoc</a>. </p><h2><a name="webapp">HTML
-  WebApp</a></h2><p>To access the webapp, browse to <a
-  href="../htmlviewer">htmlviewer</a>; this redirects in turn to the logon
-  page:</p><p><img alt="Logon Page" src="htmlviewer-logon.png"
+  WebApp</a></h2><p><i><a>Apache Isis</a></i> dynamically
(at runtime)
+  generates a fully-functional webapp just from the domain model classes. This
+  is implemented by <i>Isis</i>' html-viewer.</p><p>To access this
webapp,
+  just browse to the <a href="../logon.htmlviewer">logon page</a>:</p><p><img
+  alt="Logon Page" src="htmlviewer-logon.png"
   style="width: 600px" /></p><p>Click on the register link and choose a user
   name and password (nb: the demo runs under http so don't use a valuable
   password):</p><p><img alt="Register Page" src="htmlviewer-register.png"
@@ -67,31 +69,35 @@
   style="width:600px;" /><p>The webapp is entirely generated from the domain
   object. Compare the app with the source code to see how the metadata is used
   by the framework.</p><h2><a name="rest">REST API</a></h2><p>As
well as the
-  webapp representation, Isis also represents the domain object model through
-  a REST API. The representations returned are in JSON format; with resource
-  URLs mapping to objects, properties, collections and actions. In fact the
-  REST API implemented by Isis is formally documented as the <a
+  human-usable webapp representation of the domain model, <i>Isis</i> also
+  allows access to the domain object model through a REST API. The
+  representations returned are in JSON format; with resource URLs mapping to
+  objects, properties, collections and actions. Again, these representations
+  are generated dynamically at runtime, by <i>Isis</i>' json-viewer.</p><p>In
+  fact the REST API provided by <i>Isis</i> is formally documented as the <a
   href="http://restfulobjects.org">Restful Objects</a> specification. This
   aims to provide a cross-platform standard for exposing domain object models
-  via REST. The <i>Isis</i> viewer that implements the spec is called the
-  json-viewer.</p><p>(Provided that you access it using an <tt>Accept</tt>
-  header of <tt>application/json</tt>, the REST API can be accessed at the <a
-  href="/">root</a> of the webapp. For this we recommend that you use a
-  browser extension; this will also let you interact with the domain rather
-  than merely browse it read-only. A particularly good extension for Chrome is
-  <a
+  via REST. Most developers will write their own custom clients, eg using
+  jqMobile or some other client-side technology. But we expect a variety of
+  generic clients will also emerge to consume this API. </p><p>It is possible
+  though to interact with the REST API directly from the browser, though we
+  recommend that you use a browser extension such as the <a
   href="https://chrome.google.com/webstore/detail/cokgbflfommojglbmbpenpphppikmonn">REST
-  Console</a>, but there are similar extensions for Firefox.</p><p>If you
-  want, you can still access the REST API directly from a web browser. Even
-  here there are useful extensions; for example the <a>JSONView</a> extension
-  for Chrome will render the returned JSON in a color-coded collapsible
-  display. One caveat: browse to the <a href="services/">services</a> resource
-  instead (because the browser sets an <tt>Accept</tt> header of
-  <tt>text/html</tt>, browsing to root will redirect you to this documentation
-  instead).</p><p>Whichever way you access the REST API, you'll find that the
-  online demo also protects the json-viewer resources using HTTP Basic Auth
-  (the mechanism used is pluggable). So the first step is set up security.
-  Assuming you are using REST Console, browse to the authorization
+  Console</a> for Chrome (there are similar extensions for other browsers).
+  Provided that you access set the <tt>Accept</tt> header for requests to
+  <tt>application/json</tt>, the REST API can be accessed at the <a
+  href="..">root</a> of the webapp.</p><p>If you only want to browse
the JSON
+  and don't want to bother setting the Accept header, you can still access the
+  REST API directly from a web browser, though you will need to browse to the
+  <a href="../services/">services</a> resource instead (browsing to root will
+  redirect you to this documentation instead). Even here we recommend you use
+  the <a
+  href="https://chrome.google.com/webstore/detail/chklaanhfefbnpoihckbnefhakgolnmc">JSONView</a>
+  extension for Chrome; this will render the returned JSON in a color-coded
+  collapsible display.</p><p>Whichever way you access the REST API, you'll
+  find that the online demo also protects the json-viewer resources using HTTP
+  Basic Auth (the mechanism used is pluggable). So the first step is set up
+  security. Assuming you are using REST Console, browse to the authorization
   section:</p><img alt="Authorization" src="restconsole-basicauth-1.png"
   style="width:600px;" /><p>Press Basic Auth, and enter username and password.
   (The json-viewer provides no mechanism to register users, so these will need



Mime
View raw message