19 package org.turro.calendar.ical;
21 import java.io.IOException;
22 import java.util.Collection;
23 import java.util.Date;
24 import java.util.logging.Level;
25 import java.util.logging.Logger;
26 import javax.servlet.ServletContext;
27 import javax.servlet.http.HttpServletRequest;
28 import javax.servlet.http.HttpServletResponse;
29 import org.amic.util.date.CheckDate;
30 import org.turro.string.Strings;
31 import org.turro.action.Actions;
32 import org.turro.action.Contacts;
33 import org.turro.action.Interceptors;
34 import org.turro.action.LinkType;
35 import org.turro.elephant.context.Application;
36 import org.turro.elephant.context.ElephantApplication;
37 import org.turro.elephant.context.ElephantContext;
38 import org.turro.elephant.direct.DirectContent;
39 import org.turro.elephant.direct.DirectContents;
40 import org.turro.elephant.direct.IDirectContent;
41 import org.turro.elephant.security.IUser;
42 import org.turro.i18n.I_;
43 import org.turro.ical.Calendar;
44 import org.turro.path.Path;
45 import org.turro.plugin.calendar.ICalendarEvent;
46 import org.turro.plugin.command.CalendarPlugin;
47 import org.turro.plugin.contacts.IContact;
61 public boolean itsMe(String
id) {
62 return getIdentifier().equals(
id);
66 public boolean myTurn(HttpServletRequest request) {
71 public void execute(ServletContext context, HttpServletRequest request, HttpServletResponse response) {
72 String contactId = request.getParameter(
"ses");
76 Date now =
new Date();
79 new CheckDate(now).addMonths(-3).getDate(),
80 new CheckDate(now).addMonths(1).getDate());
82 for(Object o : events) {
86 cal.
addEvent(event.getBeginDate(), event.getEndDate(),
91 }
else if(event.isCancelled()) {
95 IContact organizer =
event.getOrganizer() ==
null ? contact :
event.getOrganizer();
96 if(organizer !=
null) {
99 for(
IContact c : event.getAttendees()) {
105 if(!events.isEmpty()) {
107 response.setContentType(
"text/calendar");
108 response.setCharacterEncoding(
"UTF-8");
109 cal.
output(response.getOutputStream());
110 }
catch (IOException ex) {
117 private String addLinks(String content, Path path, String email) {
120 url = resolveLink(
"WEB", path, email);
122 content +=
"\n" +
I_.
get(
"See on the web") +
" - " + url;
124 url = resolveLink(
"WEB_INTERNAL", path, email);
126 content +=
"\n" +
I_.
get(
"See on member area") +
" - " + url;
128 url = resolveLink(
"INTERNAL", path, email);
130 content +=
"\n" + I_.get(
"See on the application") +
" - " + url;
143 }
catch (Exception ex) {
150 "/user/" + path.getRoot());
151 }
catch (Exception ex) {
165 }
catch (Exception ex) {
172 "/user/my" + path.getRoot() +
"s?item=" + path.getNode(1));
173 }
catch (Exception ex) {
179 context +
"?item=" + path.getNode(1) :
null;
static String createAction(String email, String redir)
static Parameters parameters(String root)
void execute(ServletContext context, HttpServletRequest request, HttpServletResponse response)
boolean myTurn(HttpServletRequest request)
static String getIdentifier()
String resolveLink(String type, Path path, String email)
static Application getCurrent(HttpServletRequest request, HttpServletResponse response)
static String getServerUrl(String scheme)
static String logMsg(String msg)
static String getEntityWebContext(String path)
static boolean isYourTurn(HttpServletRequest request, String path)
static String get(String msg)
void addEvent(Date start, Date end, String name, String description)
void addLocation(String address)
void output(OutputStream out)
void addAttendee(String name, String email)
void setOrganizer(String name, String email)
static Collection< Object > getCalendarFor(IContact contact, Date from, Date to)
static final String CONNECTOR_EMAIL