Return-Path:
X-Original-To: apmail-incubator-isis-commits-archive@minotaur.apache.org
Delivered-To: apmail-incubator-isis-commits-archive@minotaur.apache.org
Received: from mail.apache.org (hermes.apache.org [140.211.11.3])
by minotaur.apache.org (Postfix) with SMTP id ECFA0792A
for ;
Sat, 3 Dec 2011 11:31:10 +0000 (UTC)
Received: (qmail 70983 invoked by uid 500); 3 Dec 2011 11:31:10 -0000
Delivered-To: apmail-incubator-isis-commits-archive@incubator.apache.org
Received: (qmail 70968 invoked by uid 500); 3 Dec 2011 11:31:10 -0000
Mailing-List: contact isis-commits-help@incubator.apache.org; run by ezmlm
Precedence: bulk
List-Help:
List-Unsubscribe:
List-Post:
List-Id:
Reply-To: isis-dev@incubator.apache.org
Delivered-To: mailing list isis-commits@incubator.apache.org
Received: (qmail 70961 invoked by uid 99); 3 Dec 2011 11:31:10 -0000
Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136)
by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 03 Dec 2011 11:31:10 +0000
X-ASF-Spam-Status: No, hits=-2000.0 required=5.0
tests=ALL_TRUSTED
X-Spam-Check-By: apache.org
Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4)
by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 03 Dec 2011 11:31:09 +0000
Received: from eris.apache.org (localhost [127.0.0.1])
by eris.apache.org (Postfix) with ESMTP id 038E923889E0;
Sat, 3 Dec 2011 11:30:48 +0000 (UTC)
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
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 -0000
To: isis-commits@incubator.apache.org
From: danhaywood@apache.org
X-Mailer: svnmailer-1.0.8-patched
Message-Id: <20111203113048.038E923889E0@eris.apache.org>
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 @@
RedirectToDocsFilter
- /
+ *
@@ -182,19 +182,6 @@
- Forward
- org.apache.isis.core.webapp.routing.ForwardingServlet
-
- forwardTo
- logon.htmlviewer
-
-
-
- Forward
- /htmlviewer
-
-
-
Controller
org.apache.isis.viewer.html.servlet.ControllerServlet
@@ -241,5 +228,9 @@
*.html
+
+
+ /
+
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 Isis' programming model, you can also view the source code and browse the javadoc.
To access the webapp, browse to htmlviewer; this redirects in turn to the logon
- page:
Apache Isis dynamically (at runtime)
+ generates a fully-functional webapp just from the domain model classes. This
+ is implemented by Isis' html-viewer.
To access this webapp,
+ just browse to the logon page:
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):
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.
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 Isis 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 Isis' json-viewer.
In
+ fact the REST API provided by Isis is formally documented as the Restful Objects specification. This
aims to provide a cross-platform standard for exposing domain object models
- via REST. The Isis viewer that implements the spec is called the
- json-viewer.
(Provided that you access it using an Accept
- header of application/json, the REST API can be accessed at the root 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
- 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 REST
- Console, but there are similar extensions for Firefox.
If you
- want, you can still access the REST API directly from a web browser. Even
- here there are useful extensions; for example the JSONView extension
- for Chrome will render the returned JSON in a color-coded collapsible
- display. One caveat: browse to the services resource
- instead (because the browser sets an Accept header of
- text/html, browsing to root will redirect you to this documentation
- instead).
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
for Chrome (there are similar extensions for other browsers).
+ Provided that you access set the Accept header for requests to
+ application/json, the REST API can be accessed at the root of the webapp.
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
+ services resource instead (browsing to root will
+ redirect you to this documentation instead). Even here we recommend you use
+ the JSONView
+ extension for Chrome; this will render the returned JSON in a color-coded
+ collapsible display.
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:
Press Basic Auth, and enter username and password.
(The json-viewer provides no mechanism to register users, so these will need