@Override
	public JSONObject main(Map<String, String> params, Session session)
			throws Exception {
		JSONObject rtn = new JSONObject();
		long apptId = Long.parseLong(params.get("id"));
		Appointment appt = Appointment.findById(apptId);
		if(appt == null) {
			rtn.put("rtnCode", this.getRtnCode(405));
			return rtn;
		}
		if(appt.initiatorId != session.getActiveUserId()) {
			rtn.put("rtnCode", this.getRtnCode(406));
			return rtn;
		}
		
		// cannot delete event in the past
		long startTime = appt.startTime;
		if(startTime < TimeMachine.getNow().getTime()) {
			rtn.put("rtnCode", this.getRtnCode(407));
			return rtn;
		}
		
		appt.delete();
		rtn.put("rtnCode", this.getRtnCode(200));
		return rtn;
	}