19 package org.turro.polls;
21 import java.io.IOException;
22 import java.io.UnsupportedEncodingException;
23 import java.net.URLDecoder;
24 import java.net.URLEncoder;
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.ObjectString;
32 import org.turro.action.Actions;
33 import org.turro.collections.KeyValueMap;
34 import org.turro.elephant.context.ElephantContext;
35 import org.turro.elephant.context.IConstructor;
36 import org.turro.elephant.direct.DirectContent;
37 import org.turro.elephant.direct.DirectContents;
38 import org.turro.elephant.direct.IDirectContent;
39 import org.turro.elephant.entities.db.PollOption;
40 import org.turro.elephant.security.IUser;
41 import org.turro.plugin.contacts.IContact;
47 @DirectContent(identifier=
"poll-action")
51 HashMap<String, String> values =
new HashMap<>();
54 values.put(
"pollId", ObjectString.formatNativeObject(option.getIdPoll(),
false));
55 values.put(
"pollData", option.getPollData());
56 values.put(
"contactId", contact.getId());
57 values.put(
"vote", ObjectString.formatNativeObject(Integer.valueOf(vote),
false));
68 public boolean itsMe(String
id) {
69 return getIdentifier().equals(
id);
73 public boolean myTurn(HttpServletRequest request) {
78 public void execute(ServletContext context, HttpServletRequest request, HttpServletResponse response) {
85 (Long) ObjectString.parseNativeString(map.get(
"pollId"), Long.class,
true),
86 (String) map.get(
"pollData"),
87 (Integer) ObjectString.parseNativeString(map.get(
"vote"), Integer.class,
true));
88 response.sendRedirect(URLDecoder.decode(map.get(
Actions.REDIR_PAR),
"UTF-8"));
90 }
catch (IOException ex) {
static String createAction(String email, String redir)
static final String USER_PAR
static KeyValueMap getAction(IConstructor constructor)
static boolean prepareActions(IConstructor constructor, KeyValueMap values)
static IConstructor getConstructor(HttpServletRequest request, HttpServletResponse response)
static String getRootWebPath()
static String logMsg(String msg)
static boolean isYourTurn(HttpServletRequest request, String path)
static final String DIRECT_CONTENT_PATH
static String createURL(PollOption option, IContact contact, int vote)
static String getIdentifier()
void execute(ServletContext context, HttpServletRequest request, HttpServletResponse response)
boolean myTurn(HttpServletRequest request)
boolean vote(Long pollId, String pollData, Integer vote)
static final String CONNECTOR_EMAIL