Long language_id, Boolean sendMail, Date gmtTimeStart,
Date gmtTimeEnd, Long appointmentId, String fromUserField, OmTimeZone omTimeZone) {
try {
if (authLevelUtil.checkUserLevel(user_level)) {
Invitations invitation = new Invitations();
invitation.setIsPasswordProtected(isPasswordProtected);
if (isPasswordProtected) {
invitation.setInvitationpass(manageCryptStyle
.getInstanceOfCrypt().createPassPhrase(
invitationpass));
}
invitation.setInvitationWasUsed(false);
log.debug(baseUrl);
invitation.setBaseUrl(baseUrl);
invitation.setOmTimeZone(omTimeZone);
// valid period of Invitation
if (valid == 1) {
// endless
invitation.setIsValidByTime(false);
invitation.setCanBeUsedOnlyOneTime(false);
} else if (valid == 2) {
// period
invitation.setIsValidByTime(true);
invitation.setCanBeUsedOnlyOneTime(false);
Date gmtTimeStartShifted = new Date(gmtTimeStart.getTime()
- (5 * 60 * 1000));
invitation.setValidFrom(gmtTimeStartShifted);
invitation.setValidTo(gmtTimeEnd);
// invitation.setValidFrom(validFrom);
// invitation.setValidTo(validTo);
} else {
// one-time
invitation.setIsValidByTime(false);
invitation.setCanBeUsedOnlyOneTime(true);
invitation.setInvitationWasUsed(false);
}
invitation.setDeleted(false);
User us = usersDao.get(createdBy);
String hashRaw = "HASH" + (System.currentTimeMillis());
invitation.setHash(MD5.do_checksum(hashRaw));
invitation.setInvitedBy(us);
invitation.setInvitedname(username);
invitation.setInvitedEMail(email);
invitation.setRoom(roomDao.get(rooms_id));
invitation.setConferencedomain(conferencedomain);
invitation.setStarttime(new Date());
invitation.setAppointmentId(appointmentId);
invitation = em.merge(invitation);
long invitationId = invitation.getInvitations_id();
invitation.setInvitations_id(invitationId);
if (invitationId > 0) {
if (sendMail) {
this.sendInvitionLink(us.getAdresses().getEmail(),
username, message, baseurl,
email, subject, invitation.getHash(),
validFrom, validTo, language_id, fromUserField);
}
return invitation;
}