+ ps.setString(3, AssuranceType.FACE_TO_FACE.getDescription());
+ ps.setInt(4, LIMIT_DAYS_VERIFICATION);
+ GigiResultSet rs = ps.executeQuery();
+ return !rs.next();
+ }
+ }
+
+ public static final Group ASSURER_BLOCKED = Group.getByString("blockedassurer");
+
+ public static final Group ASSUREE_BLOCKED = Group.getByString("blockedassuree");
+
+ /**
+ * This method assures another user.
+ *
+ * @see User#canAssure() (for assurer)
+ * @see #checkAssuranceIsPossible(User, User) (for assurer or assuree)
+ * @param assurer
+ * the person that wants to assure
+ * @param assuree
+ * the person that should be assured
+ * @param assureeName
+ * the Name that was personally verified
+ * @param dob
+ * the Date of birth that the assurer verified
+ * @param awarded
+ * the points that should be awarded in total
+ * @param location
+ * the location where the assurance took place
+ * @param date
+ * the date when the assurance took place
+ * @throws GigiApiException
+ * if the assurance fails (for various reasons)
+ */
+ public synchronized static void assure(User assurer, User assuree, Name assureeName, DayDate dob, int awarded, String location, String date, AssuranceType type) throws GigiApiException {
+ may(assurer, assuree, AssuranceType.FACE_TO_FACE);
+ GigiApiException gae = new GigiApiException();
+ if ( !gae.isEmpty()) {
+ throw gae;
+ }
+ if (date == null || date.equals("")) {
+ gae.mergeInto(new GigiApiException("You must enter the date when you met the assuree."));
+ } else {
+ try {
+ Date d = DateSelector.getDateFormat().parse(date);
+ Calendar gc = GregorianCalendar.getInstance();
+ gc.setTimeInMillis(System.currentTimeMillis());
+ gc.add(Calendar.HOUR_OF_DAY, 12);
+ if (d.getTime() > gc.getTimeInMillis()) {
+ gae.mergeInto(new GigiApiException("You must not enter a date in the future."));
+ }
+ gc.setTimeInMillis(System.currentTimeMillis());
+ gc.add(Calendar.MONTH, -LIMIT_MAX_MONTHS_VERIFICATION);
+ if (d.getTime() < gc.getTimeInMillis()) {
+ gae.mergeInto(new GigiApiException(SprintfCommand.createSimple("Verifications older than {0} months are not accepted.", LIMIT_MAX_MONTHS_VERIFICATION)));
+ }
+ } catch (ParseException e) {
+ gae.mergeInto(new GigiApiException("You must enter the date in this format: YYYY-MM-DD."));
+ }
+ }
+ // check location, min 3 characters
+ if (location == null || location.equals("")) {
+ gae.mergeInto(new GigiApiException("You failed to enter a location of your meeting."));
+ } else if (location.length() <= 2) {
+ gae.mergeInto(new GigiApiException("You must enter a location with at least 3 characters eg town and country."));
+ }
+ synchronized (assuree) {
+ if (assurer.getId() == assuree.getId()) {
+ throw new GigiApiException("You cannot verify yourself.");
+ }
+ if (assureeName.getOwner() != assuree) {
+ throw new GigiApiException("Internal error, name does not belong to applicant.");