BrightSide Workbench Full Report + Source Code
org.turro.polls.PollAction Class Reference
Inheritance diagram for org.turro.polls.PollAction:
Collaboration diagram for org.turro.polls.PollAction:

Public Member Functions

boolean itsMe (String id)
 
boolean myTurn (HttpServletRequest request)
 
void execute (ServletContext context, HttpServletRequest request, HttpServletResponse response)
 

Static Public Member Functions

static String createURL (PollOption option, IContact contact, int vote) throws UnsupportedEncodingException, Exception
 
static String getIdentifier ()
 

Detailed Description

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

Definition at line 48 of file PollAction.java.

Member Function Documentation

◆ createURL()

static String org.turro.polls.PollAction.createURL ( PollOption  option,
IContact  contact,
int  vote 
) throws UnsupportedEncodingException, Exception
static

Definition at line 50 of file PollAction.java.

50  {
51  HashMap<String, String> values = new HashMap<>();
52  values.put(Actions.USER_PAR, contact.getConnector(IUser.CONNECTOR_EMAIL));
53  values.put(Actions.REDIR_PAR, URLEncoder.encode(ElephantContext.getRootWebPath() + "/user/mypolls?item=" + option.getIdPoll(), "UTF-8"));
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));
58  return ElephantContext.getRootWebPath() +
59  DirectContents.DIRECT_CONTENT_PATH + getIdentifier() +
60  "?" + Actions.createAction(values, 7, false);
61  }
static String getIdentifier()
Definition: PollAction.java:63
Here is the caller graph for this function:

◆ execute()

void org.turro.polls.PollAction.execute ( ServletContext  context,
HttpServletRequest  request,
HttpServletResponse  response 
)

Implements org.turro.elephant.direct.IDirectContent.

Definition at line 78 of file PollAction.java.

78  {
79  try {
80  IConstructor constructor = ElephantContext.getConstructor(request, response);
81  KeyValueMap map = Actions.getAction(constructor);
82  if(Actions.prepareActions(constructor, map)) {
83  PollsUtil polls = new PollsUtil(map.get("contactId"));
84  polls.vote(
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"));
89  }
90  } catch (IOException ex) {
91  Logger.getLogger(PollAction.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
92  }
93  }
Here is the call graph for this function:

◆ getIdentifier()

static String org.turro.polls.PollAction.getIdentifier ( )
static

Definition at line 63 of file PollAction.java.

63  {
64  return PollAction.class.getAnnotation(DirectContent.class).identifier();
65  }

◆ itsMe()

boolean org.turro.polls.PollAction.itsMe ( String  id)

Implements org.turro.elephant.direct.IDirectContent.

Definition at line 68 of file PollAction.java.

68  {
69  return getIdentifier().equals(id);
70  }

◆ myTurn()

boolean org.turro.polls.PollAction.myTurn ( HttpServletRequest  request)

Implements org.turro.elephant.direct.IDirectContent.

Definition at line 73 of file PollAction.java.

73  {
74  return DirectContents.isYourTurn(request, getIdentifier());
75  }
Here is the call graph for this function:

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