@@ -11,12 +11,12 @@ |
*/ |
package csip; |
|
-import csip.Registry; |
import csip.utils.JSONUtils; |
import csip.utils.Services; |
import csip.utils.SimpleCache; |
import java.util.logging.Level; |
import java.util.logging.Logger; |
+import javax.servlet.http.HttpServletRequest; |
|
import javax.ws.rs.*; |
import javax.ws.rs.core.Context; |
@@ -40,20 +40,22 @@ |
|
@GET |
@Produces(MediaType.TEXT_PLAIN) |
- public String getTextCatalog(@Context UriInfo uriInfo) { |
- return getJSONCatalog(uriInfo); |
+ public String getTextCatalog(@Context UriInfo uriInfo, @Context HttpServletRequest httpReq) { |
+ return getJSONCatalog(uriInfo, httpReq); |
} |
|
|
@GET |
@Produces(MediaType.APPLICATION_JSON) |
- public String getJSONCatalog(@Context UriInfo uriInfo) { |
- LOG.log(Level.INFO, "HTTP/GET {0}", uriInfo.getRequestUri().toString()); |
+ public String getJSONCatalog(@Context UriInfo uriInfo, @Context HttpServletRequest httpReq) { |
+// LOG.log(Level.INFO, "HTTP/GET {0}", uriInfo.getRequestUri().toString()); |
+ LOG.log(Level.INFO, "HTTP/GET {0}", httpReq.getRequestURL().toString()); |
|
return cat.get(Config.getRegistry(), (Registry r) -> { |
JSONArray o = new JSONArray(); |
try { |
- String host = Services.toPublicURL(uriInfo.getRequestUri()).toString(); |
+// String host = Services.toPublicURL(uriInfo.getRequestUri()).toString(); |
+ String host = Services.toPublicURL(httpReq.getRequestURL().toString()).toString(); |
if (!host.endsWith("/")) { |
host += "/"; |
} |
@@ -270,6 +270,24 @@ |
} |
|
|
+ public static URI toPublicURL(String u) { |
+ UriBuilder b = UriBuilder.fromUri(u); |
+ String s = Config.getString("csip.public.scheme"); |
+ if (s != null) { |
+ b = b.scheme(s); |
+ } |
+ s = Config.getString("csip.public.host"); |
+ if (s != null) { |
+ b = b.host(s); |
+ } |
+ s = Config.getString("csip.public.port"); |
+ if (s != null) { |
+ b = b.port(Integer.parseInt(s)); |
+ } |
+ return b.build(); |
+ } |
+ |
+ |
public static URI toPublicURL(URI u) { |
UriBuilder b = UriBuilder.fromUri(u); |
String s = Config.getString("csip.public.scheme"); |