diff --git a/src/main/java/com/metaweb/gridworks/browsing/facets/ScatterplotFacet.java b/src/main/java/com/metaweb/gridworks/browsing/facets/ScatterplotFacet.java index d1165a3fd..2ebd5736b 100644 --- a/src/main/java/com/metaweb/gridworks/browsing/facets/ScatterplotFacet.java +++ b/src/main/java/com/metaweb/gridworks/browsing/facets/ScatterplotFacet.java @@ -251,10 +251,7 @@ public class ScatterplotFacet implements Facet { protected boolean checkValues(double x, double y) { Point2D.Double p = new Point2D.Double(x,y); p = translateCoordinates(p, dim_x, dim_y, rotation, l, min_x, max_x, min_y, max_y); - - boolean value = p.x >= from_x && p.x < to_x && p.y >= from_y && p.y < to_y; - - return value; + return p.x >= from_x && p.x <= to_x && p.y >= from_y && p.y <= to_y; }; }; } else { diff --git a/src/main/java/com/metaweb/gridworks/commands/auth/AuthorizeCommand.java b/src/main/java/com/metaweb/gridworks/commands/auth/AuthorizeCommand.java index b31941fa1..2c1ea053e 100644 --- a/src/main/java/com/metaweb/gridworks/commands/auth/AuthorizeCommand.java +++ b/src/main/java/com/metaweb/gridworks/commands/auth/AuthorizeCommand.java @@ -32,7 +32,7 @@ public class AuthorizeCommand extends Command { // prepare the continuation URL that the OAuth provider will redirect the user to // (we need to make sure this URL points back to this code or the dance will never complete) - String callbackURL = Gridworks.getURL() + "/command/authorize/" + provider.getHost(); + String callbackURL = getBaseURL(request,provider); if (access_credentials == null) { // access credentials are not available so we need to check @@ -54,7 +54,7 @@ public class AuthorizeCommand extends Command { request_credentials = new Credentials(consumer.getToken(), consumer.getTokenSecret(), provider); // and set them to that we can retrieve them later in the second part of the dance - Credentials.setCredentials(response, request_credentials, Credentials.Type.REQUEST, 3600); + Credentials.setCredentials(request, response, request_credentials, Credentials.Type.REQUEST, 3600); // now redirect the user to the Authorize URL where she can authenticate against the // service provider and authorize us. @@ -88,7 +88,7 @@ public class AuthorizeCommand extends Command { response.sendRedirect(callbackURL); } else { - Credentials.setCredentials(response, access_credentials, Credentials.Type.ACCESS, 30 * 24 * 3600); + Credentials.setCredentials(request, response, access_credentials, Credentials.Type.ACCESS, 30 * 24 * 3600); } finish(response); @@ -121,4 +121,10 @@ public class AuthorizeCommand extends Command { ); writer.flush(); } + + private String getBaseURL(HttpServletRequest request, Provider provider) { + String host = request.getHeader("host"); + if (host == null) host = Gridworks.getFullHost(); + return "http://" + host + "/command/authorize/" + provider.getHost(); + } } diff --git a/src/main/java/com/metaweb/gridworks/oauth/Credentials.java b/src/main/java/com/metaweb/gridworks/oauth/Credentials.java index 9d65cb54b..64aa2c563 100644 --- a/src/main/java/com/metaweb/gridworks/oauth/Credentials.java +++ b/src/main/java/com/metaweb/gridworks/oauth/Credentials.java @@ -35,10 +35,10 @@ public class Credentials { return (cookie == null) ? null : makeCredentials(cookie.getValue(), provider); } - public static void setCredentials(HttpServletResponse response, Credentials credentials, Type type, int max_age) { + public static void setCredentials(HttpServletRequest request, HttpServletResponse response, Credentials credentials, Type type, int max_age) { String name = type.getCookieName(credentials.getProvider()); String value = credentials.toString(); - CookiesUtilities.setCookie(response, name, value, max_age); + CookiesUtilities.setCookie(request, response, name, value, max_age); } public static void deleteCredentials(HttpServletRequest request, HttpServletResponse response, Provider provider, Type type) { diff --git a/src/main/java/com/metaweb/gridworks/util/CookiesUtilities.java b/src/main/java/com/metaweb/gridworks/util/CookiesUtilities.java index 9fe3ba9de..4c2395f0b 100644 --- a/src/main/java/com/metaweb/gridworks/util/CookiesUtilities.java +++ b/src/main/java/com/metaweb/gridworks/util/CookiesUtilities.java @@ -23,9 +23,9 @@ public class CookiesUtilities { return cookie; } - public static void setCookie(HttpServletResponse response, String name, String value, int max_age) { + public static void setCookie(HttpServletRequest request, HttpServletResponse response, String name, String value, int max_age) { Cookie c = new Cookie(name, value); - c.setDomain(DOMAIN); + c.setDomain(getDomain(request)); c.setPath(PATH); c.setMaxAge(max_age); response.addCookie(c); @@ -33,10 +33,16 @@ public class CookiesUtilities { public static void deleteCookie(HttpServletRequest request, HttpServletResponse response, String name) { Cookie c = new Cookie(name, ""); - c.setDomain(DOMAIN); + c.setDomain(getDomain(request)); c.setPath(PATH); c.setMaxAge(0); response.addCookie(c); } + public static String getDomain(HttpServletRequest request) { + String host = request.getHeader("Host"); + if (host == null) return DOMAIN; + int index = host.indexOf(':'); + return (index > -1) ? host.substring(0,index) : host ; + } } diff --git a/src/main/webapp/scripts/dialogs/freebase-loading-dialog.js b/src/main/webapp/scripts/dialogs/freebase-loading-dialog.js index 841c0ba78..ab4611604 100644 --- a/src/main/webapp/scripts/dialogs/freebase-loading-dialog.js +++ b/src/main/webapp/scripts/dialogs/freebase-loading-dialog.js @@ -197,7 +197,7 @@ FreebaseLoadingDialog.prototype._load = function() { }, function(data) { var body = $(".dialog-body"); - if ("status" in data && "code" in data.status && data.status.code == 200) { + if ("status" in data && typeof data.status == "object" && "code" in data.status && data.status.code == 200) { body.html( '