* @param hidePass
* @return
*/
public Object getInvitationByHashCode(String hashCode, boolean hidePass) {
try {
Invitation invitation = invitationDao.getInvitationByHashCode(hashCode, hidePass);
if (invitation == null) {
// already deleted or does not exist
return new Long(-31);
} else {
switch (invitation.getValid()) {
case OneTime:
// do this only if the user tries to get the Invitation, not
// while checking the PWD
if (hidePass) {
// one-time invitation
if (invitation.isUsed()) {
// Invitation is of type *only-one-time* and was
// already used
return new Long(-32);
} else {
// set to true if this is the first time / a normal
// getInvitation-Query
invitation.setUsed(true);
invitationDao.update(invitation);
// invitation.setInvitationpass(null);
invitation.setAllowEntry(true);
}
} else {
invitation.setAllowEntry(true);
}
break;
case Period:
TimeZone tz = timezoneUtil.getTimeZone(invitation.getInvitee());
Calendar now = Calendar.getInstance(tz);
Calendar start = Calendar.getInstance(tz);
start.setTime(invitation.getValidFrom());
Calendar end = Calendar.getInstance(tz);
end.setTime(invitation.getValidTo());
if (now.after(start) && now.before(end)) {
invitationDao.update(invitation);
// invitation.setInvitationpass(null);
invitation.setAllowEntry(true);
} else {
// Invitation is of type *period* and is not valid
// anymore, this is an extra hook to display the time
// correctly
// in the method where it shows that the hash code does
// not work anymore
invitation.setAllowEntry(false);
}
break;
case Endless:
default:
invitationDao.update(invitation);
invitation.setAllowEntry(true);
// invitation.setInvitationpass(null);
break;
}
return invitation;
}