use of org.apache.openmeetings.db.entity.calendar.Appointment in project openmeetings by apache.
the class IcalUtils method parseCalendartoAppointment.
/**
* Parses the Calendar from the CalDAV server, to a new Appointment.
*
* @param calendar iCalendar Representation.
* @param href Location of the Calendar on the server
* @param etag ETag of the calendar.
* @param omCalendar The Parent OmCalendar, to which the Appointment belongs.
* @return Appointment after parsing.
*/
public Appointment parseCalendartoAppointment(Calendar calendar, String href, String etag, OmCalendar omCalendar) {
// Note: By RFC 4791 only one event can be stored in one href.
Appointment a = new Appointment();
a.setId(null);
a.setDeleted(false);
a.setHref(href);
a.setCalendar(omCalendar);
a.setOwner(omCalendar.getOwner());
a.setRoom(createDefaultRoom());
a.setReminder(Appointment.Reminder.none);
return this.parseCalendartoAppointment(a, calendar, etag);
}
use of org.apache.openmeetings.db.entity.calendar.Appointment in project openmeetings by apache.
the class IcalUtils method parseAppointmentstoCalendar.
/**
* Parses a List of Appointments into a VCALENDAR component.
*
* @param appointments List of Appointments for the Calendar
* @param ownerId Owner of the Appointments
* @return VCALENDAR representation of the Appointments
*/
public Calendar parseAppointmentstoCalendar(List<Appointment> appointments, Long ownerId) {
String tzid = parseTimeZone(null, userDao.get(ownerId)).getID();
TimeZoneRegistry registry = TimeZoneRegistryFactory.getInstance().createRegistry();
net.fortuna.ical4j.model.TimeZone timeZone = registry.getTimeZone(tzid);
if (timeZone == null) {
throw new NoSuchElementException("Unable to get time zone by id provided: " + tzid);
}
Calendar icsCalendar = new Calendar();
icsCalendar.getProperties().add(new ProdId(PROD_ID));
icsCalendar.getProperties().add(Version.VERSION_2_0);
icsCalendar.getProperties().add(CalScale.GREGORIAN);
icsCalendar.getComponents().add(timeZone.getVTimeZone());
for (Appointment appointment : appointments) {
DateTime start = new DateTime(appointment.getStart()), end = new DateTime(appointment.getEnd());
VEvent meeting = new VEvent(start, end, appointment.getTitle());
meeting = addVEventpropsfromAppointment(appointment, meeting);
icsCalendar.getComponents().add(meeting);
}
return icsCalendar;
}
use of org.apache.openmeetings.db.entity.calendar.Appointment in project openmeetings by apache.
the class IcalUtils method parseCalendartoAppointments.
/**
* Parses a Calendar with multiple VEvents into Appointments
*
* @param calendar Calendar to Parse
* @param ownerId Owner of the Appointments
* @return <code>List</code> of Appointments
*/
public List<Appointment> parseCalendartoAppointments(Calendar calendar, Long ownerId) {
List<Appointment> appointments = new ArrayList<>();
ComponentList<CalendarComponent> events = calendar.getComponents(Component.VEVENT);
User owner = userDao.get(ownerId);
for (CalendarComponent event : events) {
Appointment a = new Appointment();
a.setOwner(owner);
a.setDeleted(false);
a.setRoom(createDefaultRoom());
a.setReminder(Appointment.Reminder.none);
a = addVEventPropertiestoAppointment(a, event);
appointments.add(a);
}
return appointments;
}
use of org.apache.openmeetings.db.entity.calendar.Appointment in project openmeetings by apache.
the class WebDAVSyncHandler method internalSyncItems.
@Override
DavMethodBase internalSyncItems() throws IOException, DavException {
boolean additionalSyncNeeded = false;
DavPropertyNameSet properties = new DavPropertyNameSet();
properties.add(DavPropertyName.GETETAG);
// Create report to get
SyncReportInfo reportInfo = new SyncReportInfo(calendar.getToken(), properties, SyncReportInfo.SYNC_LEVEL_1);
SyncMethod method = new SyncMethod(path, reportInfo);
client.executeMethod(method);
if (method.succeeded()) {
List<String> currenthrefs = new ArrayList<>();
// Map of Href and the Appointments, belonging to it.
Map<String, Appointment> map = listToMap(appointmentDao.getHrefsbyCalendar(calendar.getId()), appointmentDao.getbyCalendar(calendar.getId()));
for (MultiStatusResponse response : method.getResponseBodyAsMultiStatus().getResponses()) {
int status = response.getStatus()[0].getStatusCode();
if (status == SC_OK) {
Appointment a = map.get(response.getHref());
if (a != null) {
// Old Event to get
String origetag = a.getEtag(), currentetag = CalendarDataProperty.getEtagfromResponse(response);
// If event modified, only then get it.
if (!currentetag.equals(origetag)) {
currenthrefs.add(response.getHref());
}
} else {
// New Event, to get
currenthrefs.add(response.getHref());
}
} else if (status == SC_NOT_FOUND) {
// Delete the Appointments not found on the server.
Appointment a = map.get(response.getHref());
// Only if the event exists on the database, delete it.
if (a != null) {
appointmentDao.delete(a, calendar.getOwner().getId());
}
} else if (status == SC_INSUFFICIENT_SPACE_ON_RESOURCE) {
additionalSyncNeeded = true;
}
}
MultigetHandler multigetHandler = new MultigetHandler(currenthrefs, path, calendar, client, appointmentDao, utils);
multigetHandler.syncItems();
// Set the new token
calendar.setToken(method.getResponseSynctoken());
} else if (method.getStatusCode() == SC_FORBIDDEN || method.getStatusCode() == SC_PRECONDITION_FAILED) {
// Specific case where a server might sometimes forget the sync token
// Thus requiring a full sync needed to be done.
log.info("Sync Token not accepted by server. Doing a full sync again.");
calendar.setToken(null);
additionalSyncNeeded = true;
} else {
log.error("Error in Sync Method Response with status code {}", method.getStatusCode());
}
if (additionalSyncNeeded) {
releaseConnection(method);
return internalSyncItems();
}
return method;
}
use of org.apache.openmeetings.db.entity.calendar.Appointment in project openmeetings by apache.
the class RoomPanel method onInitialize.
@Override
protected void onInitialize() {
super.onInitialize();
// let's refresh user in client
cm.update(getClient().updateUser(userDao));
Component accessDenied = new WebMarkupContainer(ACCESS_DENIED_ID).setVisible(false);
room.add(AttributeModifier.append(ATTR_CLASS, r.getType().name()));
room.add(menu = new RoomMenuPanel("menu", this));
room.add(AttributeModifier.append("data-room-id", r.getId()));
if (interview) {
room.add(new WebMarkupContainer("wb-area").add(wb));
} else {
Droppable<BaseFileItem> wbArea = new Droppable<BaseFileItem>("wb-area") {
private static final long serialVersionUID = 1L;
@Override
public void onConfigure(JQueryBehavior behavior) {
super.onConfigure(behavior);
behavior.setOption("hoverClass", Options.asString("ui-state-hover"));
behavior.setOption("accept", Options.asString(".recorditem, .fileitem, .readonlyitem"));
}
@Override
public void onDrop(AjaxRequestTarget target, Component component) {
Object o = component.getDefaultModelObject();
if (wb.isVisible() && o instanceof BaseFileItem) {
BaseFileItem f = (BaseFileItem) o;
if (sidebar.getFilesPanel().isSelected(f)) {
for (Entry<String, BaseFileItem> e : sidebar.getFilesPanel().getSelected().entrySet()) {
wb.sendFileToWb(e.getValue(), false);
}
} else {
wb.sendFileToWb(f, false);
}
}
}
};
room.add(wbArea.add(wb));
}
room.add(roomEnter);
room.add(sidebar = new RoomSidebar("sidebar", this));
add(roomClosed = new RedirectMessageDialog("room-closed", "1098", r.isClosed(), r.getRedirectURL()));
if (r.isClosed()) {
room.setVisible(false);
} else if (cm.listByRoom(r.getId()).size() >= r.getCapacity()) {
accessDenied = new ExpiredMessageDialog(ACCESS_DENIED_ID, getString("99"), menu);
room.setVisible(false);
} else if (r.getId().equals(WebSession.get().getRoomId())) {
// secureHash/invitationHash, already checked
} else {
boolean allowed = false;
String deniedMessage = null;
if (r.isAppointment()) {
Appointment a = apptDao.getByRoom(r.getId());
if (a != null && !a.isDeleted()) {
boolean isOwner = a.getOwner().getId().equals(getUserId());
allowed = isOwner;
log.debug("appointed room, isOwner ? {}", isOwner);
if (!allowed) {
for (MeetingMember mm : a.getMeetingMembers()) {
if (getUserId().equals(mm.getUser().getId())) {
allowed = true;
break;
}
}
}
if (allowed) {
Calendar c = WebSession.getCalendar();
if (isOwner || c.getTime().after(a.getStart()) && c.getTime().before(a.getEnd())) {
eventDetail = new EventDetailDialog(EVENT_DETAILS_ID, a);
} else {
allowed = false;
deniedMessage = String.format("%s %s - %s", getString("error.hash.period"), getDateFormat().format(a.getStart()), getDateFormat().format(a.getEnd()));
}
}
}
} else {
allowed = r.getIspublic() || (r.getOwnerId() != null && r.getOwnerId().equals(getUserId()));
log.debug("public ? " + r.getIspublic() + ", ownedId ? " + r.getOwnerId() + " " + allowed);
if (!allowed) {
User u = getClient().getUser();
for (RoomGroup ro : r.getGroups()) {
for (GroupUser ou : u.getGroupUsers()) {
if (ro.getGroup().getId().equals(ou.getGroup().getId())) {
allowed = true;
break;
}
}
if (allowed) {
break;
}
}
}
}
if (!allowed) {
if (deniedMessage == null) {
deniedMessage = getString("1599");
}
accessDenied = new ExpiredMessageDialog(ACCESS_DENIED_ID, deniedMessage, menu);
room.setVisible(false);
}
}
waitForModerator = new MessageDialog("wait-for-moderator", getString("204"), getString("696"), DialogButtons.OK, DialogIcon.LIGHT) {
private static final long serialVersionUID = 1L;
@Override
public void onClose(IPartialPageRequestHandler handler, DialogButton button) {
// no-op
}
};
waitApplyModeration = new MessageDialog("wait-apply-moderation", getString("204"), getString(r.isModerated() ? "641" : "498"), DialogButtons.OK, DialogIcon.LIGHT) {
private static final long serialVersionUID = 1L;
@Override
public void onClose(IPartialPageRequestHandler handler, DialogButton button) {
// no-op
}
};
add(room, accessDenied, eventDetail, waitForModerator, waitApplyModeration);
if (r.isWaitForRecording()) {
add(new MessageDialog("wait-for-recording", getString("1316"), getString("1315"), DialogButtons.OK, DialogIcon.LIGHT) {
private static final long serialVersionUID = 1L;
@Override
public void onConfigure(JQueryBehavior behavior) {
super.onConfigure(behavior);
behavior.setOption("autoOpen", true);
behavior.setOption("resizable", false);
}
@Override
public void onClose(IPartialPageRequestHandler handler, DialogButton button) {
// no-op
}
});
} else {
add(new WebMarkupContainer("wait-for-recording").setVisible(false));
}
if (room.isVisible()) {
add(new NicknameDialog("nickname", this));
add(download);
add(new BaseWebSocketBehavior("media"));
} else {
add(new WebMarkupContainer("nickname").setVisible(false));
}
add(clientKicked = new MessageDialog("client-kicked", getString("797"), getString("606"), DialogButtons.OK, DialogIcon.ERROR) {
private static final long serialVersionUID = 1L;
@Override
public void onClose(IPartialPageRequestHandler handler, DialogButton button) {
menu.exit(handler);
}
});
}
Aggregations