public Invitation getInvitation(Invitation _invitation, User inveetee, Room room
, boolean isPasswordProtected, String invitationpass, Valid valid,
User createdBy, String baseUrl, Long language_id, Date gmtTimeStart, Date gmtTimeEnd
, Appointment appointment) {
Invitation invitation = _invitation;
if (null == _invitation) {
invitation = new Invitation();
String hashRaw = "HASH" + (System.currentTimeMillis());
try {
invitation.setHash(MD5.do_checksum(hashRaw));
} catch (NoSuchAlgorithmException e) {
log.error("Unexpected error while creating invitation", e);
throw new RuntimeException(e);
}
}
invitation.setPasswordProtected(isPasswordProtected);
if (isPasswordProtected) {
invitation.setPassword(ManageCryptStyle.getInstanceOfCrypt().createPassPhrase(invitationpass));
}
invitation.setUsed(false);
log.debug(baseUrl);
if (baseUrl != null) {
invitation.setBaseUrl(baseUrl);
}
invitation.setValid(valid);
// valid period of Invitation
switch (valid) {
case Period:
invitation.setValidFrom(new Date(gmtTimeStart.getTime() - (5 * 60 * 1000)));
invitation.setValidTo(gmtTimeEnd);
break;
case Endless:
case OneTime:
default:
break;
}
invitation.setDeleted(false);
invitation.setInvitedBy(createdBy);
invitation.setInvitee(inveetee);
if (language_id != null && Type.contact == invitation.getInvitee().getType()) {
invitation.getInvitee().setLanguage_id(language_id);
}
invitation.setRoom(room);
invitation.setInserted(new Date());
invitation.setAppointment(appointment);
return invitation;
}