From: gmungoc Date: Wed, 6 May 2015 09:57:34 +0000 (+0100) Subject: JAL-1725 fix for redirect of POST to GET, debug output removed X-Git-Tag: Jalview_2_9~33 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=ab97cf4af61bd67f20676c686601522d0ba0875d;p=jalview.git JAL-1725 fix for redirect of POST to GET, debug output removed --- diff --git a/src/jalview/ext/rbvi/chimera/ChimeraListener.java b/src/jalview/ext/rbvi/chimera/ChimeraListener.java index 8b48cd2..2479a1b 100644 --- a/src/jalview/ext/rbvi/chimera/ChimeraListener.java +++ b/src/jalview/ext/rbvi/chimera/ChimeraListener.java @@ -17,8 +17,12 @@ import jalview.structure.SelectionSource; *
  • Start the Chimera process
  • *
  • Start the REST service on Chimera, get the port number it is listening on *
  • - *
  • Start the ChimeraListener, get the port number it is listening on
  • + *
  • Start the ChimeraListener, get the URL it is listening on
  • + *
  • The first listener started will start the singleton HttpServer
  • *
  • Send a 'listen' command to Chimera with the URL of the listener
  • + *
  • When Jalview's Chimera window is closed, shut down the ChimeraListener
  • + *
  • Multiple linked Chimera instances will each have a separate listener (but + * share one Http server)
  • * * * @author gmcarstairs @@ -27,6 +31,12 @@ import jalview.structure.SelectionSource; public class ChimeraListener extends AbstractRequestHandler implements SelectionSource { + private static final String CHIMERA_NOTIFICATION = "chimeraNotification"; + + private static final String MODEL_CHANGED = "ModelChanged: "; + + private static final String SELECTION_CHANGED = "SelectionChanged: selection changed\n"; + /* * A static counter so each listener can be associated with a distinct context * root (/chimera0,1,2,3...). This is needed so we can fetch selections from @@ -90,20 +100,32 @@ public class ChimeraListener extends AbstractRequestHandler implements HttpServletResponse response) { // dumpRequest(request); - String message = request.getParameter("chimeraNotification"); - if ("selection changed".equals(message)) + String message = request.getParameter(CHIMERA_NOTIFICATION); + if (SELECTION_CHANGED.equals(message)) { this.chimeraBinding.highlightChimeraSelection(); } + else if (message != null && message.startsWith(MODEL_CHANGED)) + { + processModelChanged(message.substring(MODEL_CHANGED.length())); + } else { System.err.println("Unexpected chimeraNotification: " + message); - // do it anyway for now! - this.chimeraBinding.highlightChimeraSelection(); } } /** + * Handler a ModelChanged notification from Chimera + * + * @param substring + */ + protected void processModelChanged(String message) + { + System.out.println(message + " (not implemented in Jalview)"); + } + + /** * Deregister this listener and close it down * * @throws Exception diff --git a/src/jalview/httpserver/AbstractRequestHandler.java b/src/jalview/httpserver/AbstractRequestHandler.java index f48ba49..45064e7 100644 --- a/src/jalview/httpserver/AbstractRequestHandler.java +++ b/src/jalview/httpserver/AbstractRequestHandler.java @@ -72,6 +72,7 @@ public abstract class AbstractRequestHandler extends AbstractHandler protected void dumpRequest(HttpServletRequest request) { System.out.println(request.getMethod()); + System.out.println(request.getRequestURL()); for (String hdr : Collections.list(request.getHeaderNames())) { for (String val : Collections.list(request.getHeaders(hdr))) diff --git a/src/jalview/httpserver/HttpServer.java b/src/jalview/httpserver/HttpServer.java index d39ada1..6f4aa75 100644 --- a/src/jalview/httpserver/HttpServer.java +++ b/src/jalview/httpserver/HttpServer.java @@ -196,6 +196,7 @@ public class HttpServer { // http://stackoverflow.com/questions/20043097/jetty-9-embedded-adding-handlers-during-runtime ContextHandler ch = new ContextHandler(); + ch.setAllowNullPathInfo(true); ch.setContextPath("/" + path); ch.setResourceBase("."); ch.setClassLoader(Thread.currentThread()