Mercurial > hg > ismi-richfaces
annotate src/main/java/de/mpiwg/itgroup/diva/rest/DivaProxy.java @ 210:0aa8975784d9
add deprecation notes to interface.
author | casties |
---|---|
date | Mon, 02 Sep 2019 13:14:08 +0200 |
parents | f2c1e5be355c |
children |
rev | line source |
---|---|
1 | 1 package de.mpiwg.itgroup.diva.rest; |
2 | |
3 import javax.ws.rs.GET; | |
4 import javax.ws.rs.Path; | |
5 import javax.ws.rs.PathParam; | |
6 import javax.ws.rs.Produces; | |
7 import javax.ws.rs.QueryParam; | |
8 import javax.ws.rs.core.MediaType; | |
9 import javax.ws.rs.core.Response; | |
10 | |
11 import de.mpiwg.itgroup.ismi.utils.HTTPUtils; | |
12 import de.mpiwg.itgroup.ismi.utils.HTTPUtils.HttpResponse; | |
13 import de.mpiwg.itgroup.ismi.utils.HTTPUtils.HttpStringResponse; | |
14 | |
15 @Path("/diva/proxy") | |
16 public class DivaProxy { | |
155 | 17 // FIXME: is this still used? |
18 | |
154
84d20006521c
change McGill image server URL.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
1
diff
changeset
|
19 // was https://images.rasi.mcgill.ca/fcgi-bin/iipsrv.fcgi?FIF=/data7/srv/images/ |
155 | 20 private static String IMG_SERVER = "https://images.rasi.mcgill.ca/fcgi-bin/iipsrv.fcgi?FIF=/"; |
1 | 21 |
22 @GET | |
23 @Path("/image") | |
24 @Produces("image/jpeg") | |
25 public Response | |
26 image( | |
27 @QueryParam("f") String f, | |
28 @QueryParam("w") String w) throws Exception{ | |
29 | |
30 String dirName = getDirName(f); | |
31 | |
32 String url = IMG_SERVER + dirName + "/" + f + "&WID=" + w + "&CVT=JPG"; | |
33 | |
34 | |
35 HttpResponse resp = HTTPUtils.getHttpSSLResponse(url); | |
36 | |
37 if(resp.code == 200){ | |
38 return Response.ok(resp.content).build(); | |
39 } | |
40 | |
41 return Response.status(Response.Status.NOT_FOUND).build(); | |
42 } | |
43 | |
44 | |
45 @GET | |
46 @Path("/json/{file}") | |
47 @Produces(MediaType.APPLICATION_JSON) | |
48 public Response | |
49 json( | |
50 @PathParam("file") String file) throws Exception{ | |
51 | |
155 | 52 // was HTTPUtils.getHttpSSLStringResponse(https://images.rasi.mcgill.ca/data/ |
53 HttpStringResponse resp = HTTPUtils.getHttpStringResponse("https://images.rasi.mcgill.ca/data/" + file + ".json"); | |
1 | 54 if(resp.code == 200){ |
55 return Response.ok(resp.content).build(); | |
56 } | |
57 | |
58 return Response.status(Response.Status.NOT_FOUND).build(); | |
59 | |
60 } | |
61 | |
62 | |
63 | |
64 private String getDirName(String fileName){ | |
65 String[] array = fileName.split("_"); | |
66 return fileName.replace("_" + array[array.length-1], ""); | |
67 } | |
68 | |
69 | |
70 } |