use of org.apache.openmeetings.db.entity.user.User in project openmeetings by apache.
the class IcalUtils method addVEventPropertiestoAppointment.
/**
* Add properties from the Given VEvent Component to the Appointment
*
* @param a Appointment to which the properties are to be added
* @param event VEvent to parse properties from.
* @return Updated Appointment
*/
private Appointment addVEventPropertiestoAppointment(Appointment a, CalendarComponent event) {
DateProperty dtstart = (DateProperty) event.getProperty(Property.DTSTART), dtend = (DateProperty) event.getProperty(Property.DTEND), dtstamp = (DateProperty) event.getProperty(Property.DTSTAMP), lastmod = (DateProperty) event.getProperty(Property.LAST_MODIFIED);
Property uid = event.getProperty(Property.UID), description = event.getProperty(Property.DESCRIPTION), summary = event.getProperty(Property.SUMMARY), location = event.getProperty(Property.LOCATION), organizer = event.getProperty(Property.ORGANIZER), recur = event.getProperty(Property.RRULE);
PropertyList<Attendee> attendees = event.getProperties(Property.ATTENDEE);
if (uid != null) {
a.setIcalId(uid.getValue());
}
Date d = dtstart.getDate();
a.setStart(d);
if (dtend == null) {
a.setEnd(addTimetoDate(d, java.util.Calendar.HOUR_OF_DAY, 1));
} else {
a.setEnd(dtend.getDate());
}
a.setInserted(dtstamp.getDate());
if (lastmod != null) {
a.setUpdated(lastmod.getDate());
}
if (description != null) {
a.setDescription(description.getValue());
}
if (summary != null) {
a.setTitle(summary.getValue());
}
if (location != null) {
a.setLocation(location.getValue());
}
if (recur != null) {
Parameter freq = recur.getParameter("FREQ");
if (freq != null) {
if (freq.getValue().equals(Recur.DAILY)) {
a.setIsDaily(true);
} else if (freq.getValue().equals(Recur.WEEKLY)) {
a.setIsWeekly(true);
} else if (freq.getValue().equals(Recur.MONTHLY)) {
a.setIsMonthly(true);
} else if (freq.getValue().equals(Recur.YEARLY)) {
a.setIsYearly(true);
}
}
}
List<MeetingMember> attList = a.getMeetingMembers() == null ? new ArrayList<>() : a.getMeetingMembers();
// Note this value can be repeated in attendees as well.
if (organizer != null) {
URI uri = URI.create(organizer.getValue());
// If the value of the organizer is an email
if ("mailto".equals(uri.getScheme())) {
String email = uri.getSchemeSpecificPart();
// Contact or exist and owner
User org = userDao.getByEmail(email);
if (org == null) {
org = userDao.getContact(email, a.getOwner());
attList.add(createMeetingMember(a, org));
} else if (!org.getId().equals(a.getOwner().getId())) {
attList.add(createMeetingMember(a, org));
}
}
}
if (attendees != null && !attendees.isEmpty()) {
for (Property attendee : attendees) {
URI uri = URI.create(attendee.getValue());
if ("mailto".equals(uri.getScheme())) {
String email = uri.getSchemeSpecificPart();
User u = userDao.getByEmail(email);
if (u == null) {
u = userDao.getContact(email, a.getOwner());
}
attList.add(createMeetingMember(a, u));
}
}
}
a.setMeetingMembers(attList.isEmpty() ? null : attList);
return a;
}
use of org.apache.openmeetings.db.entity.user.User in project openmeetings by apache.
the class InvitationManager method sendInvitationLink.
@Override
public void sendInvitationLink(Invitation i, MessageType type, String subject, String message, boolean ical) throws Exception {
String invitationLink = null;
if (type != MessageType.Cancel) {
IApplication app = ensureApplication(1L);
invitationLink = app.getOmInvitationLink(i);
}
User owner = i.getInvitedBy();
String invitorName = owner.getFirstname() + " " + owner.getLastname();
String template = InvitationTemplate.getEmail(i.getInvitee(), invitorName, message, invitationLink);
String email = i.getInvitee().getAddress().getEmail();
String replyToEmail = owner.getAddress().getEmail();
if (ical) {
String username = i.getInvitee().getLogin();
boolean isOwner = owner.getId().equals(i.getInvitee().getId());
IcalHandler handler = new IcalHandler(MessageType.Cancel == type ? IcalHandler.ICAL_METHOD_CANCEL : IcalHandler.ICAL_METHOD_REQUEST);
Map<String, String> attendeeList = handler.getAttendeeData(email, username, isOwner);
List<Map<String, String>> atts = new ArrayList<>();
atts.add(attendeeList);
// Defining Organizer
Map<String, String> organizerAttendee = handler.getAttendeeData(replyToEmail, owner.getLogin(), isOwner);
Appointment a = i.getAppointment();
// Create ICal Message
String meetingId = handler.addNewMeeting(a.getStart(), a.getEnd(), a.getTitle(), atts, invitationLink, organizerAttendee, a.getIcalId(), getTimeZone(owner).getID());
// Writing back meetingUid
if (Strings.isEmpty(a.getIcalId())) {
a.setIcalId(meetingId);
}
log.debug(handler.getICalDataAsString());
mailHandler.send(new MailMessage(email, replyToEmail, subject, template, handler.getIcalAsByteArray()));
} else {
mailHandler.send(email, replyToEmail, subject, template);
}
}
use of org.apache.openmeetings.db.entity.user.User in project openmeetings by apache.
the class InvitationManager method sendInvitionLink.
/**
* @author vasya
*
* @param a - appointment this link is related to
* @param mm - attendee being processed
* @param type - type of the message
* @param ical - should iCal appoinment be attached to message
* @throws Exception in case of error happens during sending
*/
private void sendInvitionLink(Appointment a, MeetingMember mm, MessageType type, boolean ical) throws Exception {
User owner = a.getOwner();
String invitorName = owner.getFirstname() + " " + owner.getLastname();
TimeZone tz = getTimeZone(mm.getUser());
SubjectEmailTemplate t;
switch(type) {
case Cancel:
t = CanceledAppointmentTemplate.get(mm.getUser(), a, tz, invitorName);
break;
case Create:
t = CreatedAppointmentTemplate.get(mm.getUser(), a, tz, invitorName);
break;
case Update:
default:
t = UpdatedAppointmentTemplate.get(mm.getUser(), a, tz, invitorName);
break;
}
sendInvitationLink(mm.getInvitation(), type, t.getSubject(), t.getEmail(), ical);
}
use of org.apache.openmeetings.db.entity.user.User in project openmeetings by apache.
the class UserManager method loginOAuth.
@Override
public User loginOAuth(OAuthUser user, long serverId) throws IOException, NoSuchAlgorithmException {
if (!userDao.validLogin(user.getUid())) {
log.error("Invalid login, please check parameters");
return null;
}
User u = userDao.getByLogin(user.getUid(), Type.oauth, serverId);
if (!userDao.checkEmail(user.getEmail(), Type.oauth, serverId, u == null ? null : u.getId())) {
log.error("Another user with the same email exists");
return null;
}
// generate random password
SecureRandom rnd = new SecureRandom();
byte[] rawPass = new byte[25];
rnd.nextBytes(rawPass);
String pass = Base64.encodeBase64String(rawPass);
// check if the user already exists and register new one if it's needed
if (u == null) {
u = userDao.getNewUserInstance(null);
u.setType(Type.oauth);
u.getRights().remove(Right.Login);
u.setDomainId(serverId);
u.getGroupUsers().add(new GroupUser(groupDao.get(cfgDao.getLong(CONFIG_DEFAULT_GROUP_ID, null)), u));
u.setLogin(user.getUid());
u.setShowContactDataToContacts(true);
u.setLastname(user.getLastName());
u.setFirstname(user.getFirstName());
u.getAddress().setEmail(user.getEmail());
String picture = user.getPicture();
if (picture != null) {
u.setPictureuri(picture);
}
String locale = user.getLocale();
if (locale != null) {
Locale loc = Locale.forLanguageTag(locale);
if (loc != null) {
u.setLanguageId(getLanguage(loc));
u.getAddress().setCountry(loc.getCountry());
}
}
}
u.setLastlogin(new Date());
u = userDao.update(u, pass, Long.valueOf(-1));
return u;
}
use of org.apache.openmeetings.db.entity.user.User in project openmeetings by apache.
the class ImageConverter method convertImageUserProfile.
public ProcessResultList convertImageUserProfile(File file, Long userId, boolean skipConvertion) throws Exception {
ProcessResultList returnMap = new ProcessResultList();
// User Profile Update
File[] files = getUploadProfilesUserDir(userId).listFiles(fi -> fi.getName().endsWith(EXTENSION_JPG));
if (files != null) {
for (File f : files) {
FileUtils.deleteQuietly(f);
}
}
File destinationFile = OmFileHelper.getNewFile(getUploadProfilesUserDir(userId), PROFILE_FILE_NAME, EXTENSION_JPG);
if (!skipConvertion) {
returnMap.add(convertSingleJpg(file, destinationFile));
} else {
FileUtils.copyFile(file, destinationFile);
}
if (!skipConvertion) {
// Delete old one
file.delete();
}
String pictureuri = destinationFile.getName();
User us = userDao.get(userId);
us.setUpdated(new java.util.Date());
us.setPictureuri(pictureuri);
userDao.update(us, userId);
return returnMap;
}
Aggregations