|
0
|
1 package de.mpiwg.monographs.servlet;
|
|
|
2
|
|
|
3 import java.io.IOException;
|
|
|
4 import java.util.List;
|
|
|
5
|
|
|
6 import javax.inject.Inject;
|
|
|
7 import javax.servlet.ServletException;
|
|
|
8 import javax.servlet.http.HttpServletRequest;
|
|
|
9 import javax.servlet.http.HttpServletResponse;
|
|
|
10
|
|
|
11 import org.codehaus.jettison.json.JSONArray;
|
|
|
12 import org.codehaus.jettison.json.JSONException;
|
|
|
13 import org.codehaus.jettison.json.JSONObject;
|
|
|
14
|
|
|
15 import edu.harvard.iq.dvn.api.datadeposit.SwordAuth;
|
|
|
16 import edu.harvard.iq.dvn.core.admin.VDCUser;
|
|
|
17
|
|
|
18 public class GetAllUsers extends AbstractMonographServlet{
|
|
|
19
|
|
|
20 @Inject
|
|
|
21 private SwordAuth swordAuth;
|
|
|
22
|
|
|
23 public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
|
|
24 // Set response content type
|
|
|
25 response.setContentType("application/json");
|
|
|
26 JSONObject jsonResponse = new JSONObject();
|
|
|
27
|
|
|
28 List<VDCUser> userList = swordAuth.getAllUsers();
|
|
|
29 JSONArray array = new JSONArray();
|
|
|
30 for(VDCUser user : userList){
|
|
|
31 JSONObject json = MonographUtils.jsonVDCUser(user);
|
|
|
32 array.put(json);
|
|
|
33 }
|
|
|
34
|
|
|
35 try {
|
|
|
36 jsonResponse.put("state", "ok");
|
|
|
37 jsonResponse.put("users", array);
|
|
|
38 } catch (JSONException e) {
|
|
|
39 // TODO Auto-generated catch block
|
|
|
40 e.printStackTrace();
|
|
|
41 }
|
|
|
42
|
|
|
43
|
|
|
44
|
|
|
45 java.io.PrintWriter out = response.getWriter();
|
|
|
46 out.print(jsonResponse);
|
|
|
47 out.flush();
|
|
|
48 }
|
|
|
49
|
|
|
50 }
|