1 package org.cacert.gigi.api;
3 import java.io.IOException;
6 import javax.servlet.http.HttpServletRequest;
7 import javax.servlet.http.HttpServletResponse;
9 import org.cacert.gigi.dbObjects.CATS;
10 import org.cacert.gigi.dbObjects.CertificateOwner;
11 import org.cacert.gigi.dbObjects.Organisation;
12 import org.cacert.gigi.dbObjects.User;
14 public class CATSImport extends APIPoint {
16 public static final String PATH = "/cats/import";
19 public void process(HttpServletRequest req, HttpServletResponse resp, CertificateOwner u) throws IOException {
20 if ( !(u instanceof Organisation)) {
21 resp.sendError(500, "Error, invalid cert");
24 if ( !((Organisation) u).isSelfOrganisation()) {
25 resp.sendError(500, "Error, invalid cert");
29 String target = req.getParameter("mid");
30 String testType = req.getParameter("variant");
31 String date = req.getParameter("date");
32 if (target == null || testType == null || date == null) {
33 resp.sendError(500, "Error, requires mid, variant and date");
38 id = Integer.parseInt(target);
39 } catch (NumberFormatException e) {
40 resp.sendError(500, "Error, requires mid to be integer.");
43 CertificateOwner o = CertificateOwner.getById(id);
44 if ( !(o instanceof User)) {
45 resp.sendError(500, "Error, requires valid userid");
48 System.out.println("CATS: " + target + ": " + testType);
49 User targetUser = (User) o;
50 System.out.println(targetUser.getId());
51 CATS.enterResult(targetUser, testType, new Date(Long.parseLong(date)));