1
|
1 package de.mpiwg.itgroup.diva.rest;
|
|
2
|
|
3 import java.util.ArrayList;
|
|
4 import java.util.HashMap;
|
|
5 import java.util.List;
|
|
6
|
|
7 import javax.servlet.http.HttpServletRequest;
|
|
8 import javax.servlet.http.HttpServletResponse;
|
|
9 import javax.ws.rs.GET;
|
|
10 import javax.ws.rs.Path;
|
|
11 import javax.ws.rs.Produces;
|
|
12 import javax.ws.rs.QueryParam;
|
|
13 import javax.ws.rs.core.Context;
|
|
14 import javax.ws.rs.core.MediaType;
|
|
15 import javax.ws.rs.core.Response;
|
|
16
|
|
17 import org.json.JSONException;
|
|
18 import org.json.JSONObject;
|
|
19 import org.mpi.openmind.repository.bo.Entity;
|
|
20
|
|
21 import de.mpiwg.itgroup.diva.utils.JSONArrayParam;
|
|
22 import de.mpiwg.itgroup.diva.utils.JSONEntity;
|
|
23 import de.mpiwg.itgroup.diva.utils.JSONParam;
|
|
24
|
|
25 @Path("/entity")
|
|
26 public class RestEntity extends RestInterface{
|
|
27
|
|
28
|
|
29 public RestEntity(){
|
119
|
30 //System.out.println("%%%%%%%%%%%%%% RestWitness %%%%%%%%%%%%%%%%%%%%");
|
1
|
31 }
|
|
32
|
|
33 /*
|
|
34 @GET
|
|
35 @Path("/get")
|
|
36 @Produces(MediaType.APPLICATION_JSON)
|
|
37 public Track getTrackInJSON() {
|
|
38
|
|
39 Track track = new Track();
|
|
40 track.setTitle("Enter Sandman");
|
|
41 track.setSinger("Metallica");
|
|
42
|
|
43 return track;
|
|
44
|
|
45 }*/
|
|
46
|
|
47 @GET
|
|
48 @Path("/update")
|
|
49 @Produces(MediaType.APPLICATION_JSON)
|
|
50 public Response
|
|
51 saveWitnessPagesIndexing(
|
|
52 @Context HttpServletRequest request,
|
|
53 @Context HttpServletResponse response,
|
|
54 @QueryParam("data") JSONParam jsonParam) throws Exception{
|
|
55
|
|
56
|
|
57 JSONObject json = jsonParam.getObj();
|
119
|
58 //System.out.println(json.toString());
|
1
|
59
|
|
60 List<JSONEntity> entityList = JSONEntity.json2EntityList(json);
|
|
61
|
|
62
|
|
63 List<Entity> toSave = new ArrayList<Entity>();
|
|
64 for(JSONEntity jsonEnt : entityList){
|
|
65 Entity ent = getWrapper(request, response).getEntityByIdWithContent(jsonEnt.id);
|
|
66 ent = jsonEnt.updateEntity(ent);
|
|
67 toSave.add(ent);
|
|
68 //getWrapper(request, response).saveEntity(ent, "jojojo");
|
|
69
|
|
70 }
|
|
71
|
|
72 getWrapper(request, response).saveEntityList(toSave, "test");
|
|
73
|
|
74
|
119
|
75 //System.out.println(getSessionBean(request, response).getUsername());
|
|
76 //System.out.println(getSessionBean(request, response).getUser());
|
1
|
77 /*
|
|
78 if(userCanEdit(request, response)){
|
|
79
|
|
80 }else{
|
|
81
|
|
82 }*/
|
|
83
|
|
84 String json0 = "{}";
|
|
85 return Response.ok(json0, MediaType.APPLICATION_JSON).build();
|
|
86 }
|
|
87
|
|
88
|
|
89 }
|