+ } else if (req.getParameter("makeAgent") != null) {
+ User userByEmail = User.getByEmail(req.getParameter("agentEmail"));
+ if (userByEmail == null) {
+ resp.getWriter().println("User not found, or found user is not allowed to verify.");
+ } else {
+ if (userByEmail.getVerificationPoints() < 100) {
+ addVerificationPoints(100, userByEmail);
+ }
+ if ( !userByEmail.hasPassedCATS()) {
+ passCATS(userByEmail, CATSType.AGENT_CHALLENGE);
+ }
+ if ( !Contract.hasSignedContract(userByEmail, Contract.ContractType.RA_AGENT_CONTRACT)) {
+ try {
+ new Contract(userByEmail, Contract.ContractType.RA_AGENT_CONTRACT);
+ } catch (GigiApiException e) {
+ throw new Error(e);
+ }
+ }
+ resp.getWriter().println("User has all requirements to be an RA Agent");
+ }
+ }
+ resp.getWriter().println("<br/><a href='" + PATH + "'>Go back</a>");
+ }
+
+ private int addVerificationPoints(int vp, User byEmail) throws Error {
+ int agentNumber = 0;
+
+ try {
+ if (vp > 100) { // only allow max 100 Verification points
+ vp = 100;
+ }
+
+ while (vp > 0) {
+ int currentVP = 10;
+ if (vp < 10) {
+ currentVP = vp;
+ }
+ Notary.verify(getAgent(agentNumber), byEmail, byEmail.getPreferredName(), byEmail.getDoB(), currentVP, "Testmanager Verify up code", validVerificationDateString(), VerificationType.FACE_TO_FACE, getRandomCountry());
+ agentNumber += 1;
+ vp -= currentVP;
+ }
+
+ } catch (GigiApiException e) {
+ throw new Error(e);