19 package org.turro.elephant.calendar;
21 import com.google.gson.GsonBuilder;
22 import java.io.IOException;
23 import java.util.ArrayList;
24 import java.util.Date;
25 import java.util.HashMap;
26 import java.util.logging.Level;
27 import java.util.logging.Logger;
28 import javax.servlet.ServletContext;
29 import javax.servlet.http.HttpServletRequest;
30 import javax.servlet.http.HttpServletResponse;
31 import org.turro.string.Strings;
32 import org.turro.action.Events;
33 import org.turro.elephant.context.ElephantContext;
34 import org.turro.elephant.direct.DirectContent;
35 import org.turro.elephant.direct.DirectContents;
36 import org.turro.elephant.direct.IDirectContent;
37 import org.turro.plugin.calendar.ICalendarEvent;
43 @DirectContent(identifier=
"full-calendar")
51 public boolean itsMe(String
id) {
52 return getIdentifier().equals(
id);
56 public boolean myTurn(HttpServletRequest request) {
61 public void execute(ServletContext context, HttpServletRequest request, HttpServletResponse response) {
63 String pstart = request.getParameter(
"start"),
64 pend = request.getParameter(
"end");
65 if(!Strings.isBlank(pstart) && !Strings.isBlank(pend)) {
68 HashMap<String, String> args =
new HashMap<>();
69 if(!Strings.isBlank(request.getParameter(
"webInfo"))) {
70 args.put(
"webInfo", request.getParameter(
"webInfo"));
72 if(!Strings.isBlank(request.getParameter(
"pubCats"))) {
73 args.put(
"publicationCategories", request.getParameter(
"pubCats"));
75 if(!Strings.isBlank(request.getParameter(
"pubGroups"))) {
76 args.put(
"publicationGroups", request.getParameter(
"pubGroups"));
78 if(!Strings.isBlank(request.getParameter(
"dosCats"))) {
79 args.put(
"dossierCategories", request.getParameter(
"dosCats"));
81 if(!Strings.isBlank(request.getParameter(
"convPaths"))) {
82 args.put(
"convocationPaths", request.getParameter(
"convPaths"));
84 if(!Strings.isBlank(request.getParameter(
"servTypes"))) {
85 args.put(
"serviceTypes", request.getParameter(
"servTypes"));
87 if(!Strings.isBlank(request.getParameter(
"required"))) {
88 args.put(
"required", request.getParameter(
"required"));
90 if(!Strings.isBlank(request.getParameter(
"target"))) {
91 args.put(
"target", request.getParameter(
"target"));
93 response.setContentType(
"application/json");
94 response.getWriter().write(getPublicEvents(start, end, args));
96 }
catch (IOException ex) {
101 public static String
getPublicEvents(Date start, Date end, HashMap<String, String> args) {
102 String url = args.get(
"webInfo");
103 ArrayList<FullCalendarEvent> fevents =
new ArrayList<>();
106 fce.
start = evt.getBeginDate();
107 fce.
end = evt.getEndDate();
108 fce.
title = evt.getTitle();
110 fce.
motive = evt.getMotive();
111 fce.
url = Strings.isBlank(url) ? evt.getPath() : url +
"?webInfo=" + evt.getPath();
114 return new GsonBuilder().setDateFormat(
"yyyy-MM-dd'T'HH:mm:ssX").create().toJson(fevents);
static Collection< ICalendarEvent > getPublicEvents(Date start, Date end, HashMap< String, String > args)
static String getPublicEvents(Date start, Date end, HashMap< String, String > args)
boolean myTurn(HttpServletRequest request)
static String getIdentifier()
void execute(ServletContext context, HttpServletRequest request, HttpServletResponse response)
static String logMsg(String msg)
static boolean isYourTurn(HttpServletRequest request, String path)