BrightSide Workbench Full Report + Source Code
org.turro.calendar.ical.CalendarExport Class Reference
Inheritance diagram for org.turro.calendar.ical.CalendarExport:
Collaboration diagram for org.turro.calendar.ical.CalendarExport:

Public Member Functions

boolean itsMe (String id)
 
boolean myTurn (HttpServletRequest request)
 
void execute (ServletContext context, HttpServletRequest request, HttpServletResponse response)
 
String resolveLink (String type, Path path, String email)
 

Static Public Member Functions

static String getIdentifier ()
 

Detailed Description

Author
Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g

Definition at line 54 of file CalendarExport.java.

Member Function Documentation

◆ execute()

void org.turro.calendar.ical.CalendarExport.execute ( ServletContext  context,
HttpServletRequest  request,
HttpServletResponse  response 
)

Implements org.turro.elephant.direct.IDirectContent.

Definition at line 71 of file CalendarExport.java.

71  {
72  String contactId = request.getParameter("ses");
73  IContact contact = Contacts.getContactById(Strings.reveal(contactId));
74  if(contact.isValid()) {
75  Application app = ElephantApplication.getCurrent(request, response);
76  Date now = new Date();
77  Collection events = CalendarPlugin.getCalendarFor(
78  contact,
79  new CheckDate(now).addMonths(-3).getDate(),
80  new CheckDate(now).addMonths(1).getDate());
81  Calendar cal = new Calendar(contact.getName());
82  for(Object o : events) {
83  if(o instanceof ICalendarEvent) {
84  ICalendarEvent event = (ICalendarEvent) o;
85  String content = addLinks(event.getContent(), new Path(event.getPath()), contact.getConnector(IUser.CONNECTOR_EMAIL));
86  cal.addEvent(event.getBeginDate(), event.getEndDate(),
87  event.getTitle(),
88  content);
89  if(event.isDone()) {
90  cal.setCompleted();
91  } else if(event.isCancelled()) {
92  cal.setCompleted();
93  cal.setCancelled();
94  }
95  IContact organizer = event.getOrganizer() == null ? contact : event.getOrganizer();
96  if(organizer != null) {
97  cal.setOrganizer(organizer.getName(), organizer.getConnector(IUser.CONNECTOR_EMAIL));
98  }
99  for(IContact c : event.getAttendees()) {
100  cal.addAttendee(c.getName(), c.getConnector(IUser.CONNECTOR_EMAIL));
101  }
102  cal.addLocation(event.getAddress());
103  }
104  }
105  if(!events.isEmpty()) {
106  try {
107  response.setContentType("text/calendar");
108  response.setCharacterEncoding("UTF-8");
109  cal.output(response.getOutputStream());
110  } catch (IOException ex) {
111  Logger.getLogger(CalendarExport.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
112  }
113  }
114  }
115  }
Here is the call graph for this function:

◆ getIdentifier()

static String org.turro.calendar.ical.CalendarExport.getIdentifier ( )
static

Definition at line 56 of file CalendarExport.java.

56  {
57  return CalendarExport.class.getAnnotation(DirectContent.class).identifier();
58  }

◆ itsMe()

boolean org.turro.calendar.ical.CalendarExport.itsMe ( String  id)

Implements org.turro.elephant.direct.IDirectContent.

Definition at line 61 of file CalendarExport.java.

61  {
62  return getIdentifier().equals(id);
63  }

◆ myTurn()

boolean org.turro.calendar.ical.CalendarExport.myTurn ( HttpServletRequest  request)

Implements org.turro.elephant.direct.IDirectContent.

Definition at line 66 of file CalendarExport.java.

66  {
67  return DirectContents.isYourTurn(request, getIdentifier());
68  }
Here is the call graph for this function:

◆ resolveLink()

String org.turro.calendar.ical.CalendarExport.resolveLink ( String  type,
Path  path,
String  email 
)

Definition at line 135 of file CalendarExport.java.

135  {
136  LinkType link = LinkType.valueOf(type);
137  if(path.isRoot()) {
138  if(LinkType.INTERNAL.equals(link)) {
139  try {
140  return ElephantContext.getServerUrl("http") + "?" +
141  Actions.createAction(email,
142  "/app/frame?" + Interceptors.parameters(path.getRoot()).raw());
143  } catch (Exception ex) {
144  Logger.getLogger(CalendarExport.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
145  }
146  } else if(LinkType.WEB_INTERNAL.equals(link)) {
147  try {
148  return ElephantContext.getServerUrl("http") + "?" +
149  Actions.createAction(email,
150  "/user/" + path.getRoot());
151  } catch (Exception ex) {
152  Logger.getLogger(CalendarExport.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
153  }
154  } else if(LinkType.WEB.equals(link)) {
155  String context = ElephantContext.getEntityWebContext(path);
156  return !Strings.isBlank(context) ? ElephantContext.getServerUrl("http") +
157  context : null;
158  }
159  } else {
160  if(LinkType.INTERNAL.equals(link)) {
161  try {
162  return ElephantContext.getServerUrl("http") + "?" +
163  Actions.createAction(email,
164  "/app/frame?" + Interceptors.parameters(path.getRoot(), path.getNode(1)).raw());
165  } catch (Exception ex) {
166  Logger.getLogger(CalendarExport.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
167  }
168  } else if(LinkType.WEB_INTERNAL.equals(link)) {
169  try {
170  return ElephantContext.getServerUrl("http") + "?" +
171  Actions.createAction(email,
172  "/user/my" + path.getRoot() + "s?item=" + path.getNode(1));
173  } catch (Exception ex) {
174  Logger.getLogger(CalendarExport.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
175  }
176  } else if(LinkType.WEB.equals(link)) {
177  String context = ElephantContext.getEntityWebContext(path);
178  return !Strings.isBlank(context) ? ElephantContext.getServerUrl("http") +
179  context + "?item=" + path.getNode(1) : null;
180  }
181  }
182  return null;
183  }
Here is the call graph for this function:

The documentation for this class was generated from the following file: