BrightSide Workbench Full Report + Source Code
org.turro.contacts.action.ContactAction Class Reference
Inheritance diagram for org.turro.contacts.action.ContactAction:
Collaboration diagram for org.turro.contacts.action.ContactAction:

Public Member Functions

 ContactAction ()
 
int execute () throws Exception
 
- Public Member Functions inherited from org.turro.elephant.impl.abstracts.AbstractAction
 AbstractAction ()
 
void setConstructor (IConstructor constructor)
 
IConstructor getConstructor ()
 
String getContextParameter ()
 
String getIdelParameter ()
 
String getActionParameter ()
 
String getParameter (String param)
 
String getParameter (String param, boolean encode)
 
String getStringParameter (String param)
 
String getValueParameter (String param)
 
boolean getBooleanParameter (String param)
 
int getIntParameter (String param, int defaultValue)
 
double getDoubleParameter (String param, double defaultValue)
 
Date getDateParameter (String param, Date defaultValue)
 

Additional Inherited Members

- Static Public Member Functions inherited from org.turro.elephant.impl.abstracts.AbstractAction
static String makeDateParameter (Date date)
 
static String makeDateParameter (Timestamp date)
 
static String getValuePortion (String key, String value)
 
- Static Public Attributes inherited from org.turro.elephant.context.IAction
static final int DONE = 0
 
static final int NO_DATA = 1
 
static final int ERROR = 2
 
- Protected Attributes inherited from org.turro.elephant.impl.abstracts.AbstractAction
IConstructor constructor
 

Detailed Description

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

Definition at line 42 of file ContactAction.java.

Constructor & Destructor Documentation

◆ ContactAction()

org.turro.contacts.action.ContactAction.ContactAction ( )

Creates a new instance of ContactAction

Definition at line 45 of file ContactAction.java.

45  {
46  }

Member Function Documentation

◆ execute()

int org.turro.contacts.action.ContactAction.execute ( ) throws Exception

Called by constructor in request for one action.

Exceptions
java.lang.Exception
Returns
Action's result.

Implements org.turro.elephant.context.IAction.

Definition at line 49 of file ContactAction.java.

49  {
50  String ctx = getParameter("context"),
51  action = getActionParameter();
52 
53  boolean isAJAX = false;
54 
55  if ("vote-it".equals(action)) {
56  isAJAX = true;
57  IContact contact = Authentication.getIContact();
58  constructor.getResponse().setContentType("text/html");
59  constructor.getResponse().setCharacterEncoding(ElephantContext.getEncoding());
60  String path = getParameter("path");
61  String allowedString = getParameter("allowed");
62  int vote = getIntParameter("vote", 0);
63  VoteItUtil.addVote(path, vote, contact);
64  VoteItCtrl vic = new VoteItCtrl(constructor);
65  vic.setEntityPath(path);
66  vic.setForbiden(false);
67  vic.setAllowedString(allowedString == null ? null : allowedString.replaceAll("-", "'"));
68  vic.renderVotes(false);
69  } else if ("star-it".equals(action)) {
70  isAJAX = true;
71  IContact contact = Authentication.getIContact();
72  constructor.getResponse().setContentType("text/html");
73  constructor.getResponse().setCharacterEncoding(ElephantContext.getEncoding());
74  String path = getParameter("path");
75  int stars = getIntParameter("stars", 0);
76  SoftContact scontact = new SoftContact();
77  scontact.contact = contact;
78  scontact.author_ip = constructor.getRequest().getRemoteAddr();
79  StarItUtil.addStars(path, stars, scontact);
80  StarItCtrl sic = new StarItCtrl(constructor);
81  sic.setEntityPath(path);
82  sic.renderStars(false);
83  } else if ("comment-it".equals(action)) {
84  isAJAX = true;
85  IContact contact = Authentication.getIContact();
86  constructor.getResponse().setContentType("text/html");
87  constructor.getResponse().setCharacterEncoding(ElephantContext.getEncoding());
88  String path = getParameter("path"),
89  body = getParameter("body"),
90  remove = getParameter("remove");
91  if("true".equals(remove)) {
92  CommentItUtil.remove(getParameter("id"));
93  } else if(!Strings.isBlank(body)) {
94  SoftContact scontact = new SoftContact();
95  scontact.contact = contact;
96  scontact.author = getParameter("author");
97  scontact.author_email = getParameter("author_email");
98  scontact.author_web = getParameter("author_web");
99  scontact.author_ip = constructor.getRequest().getRemoteAddr();
100  if(scontact.isValid()) {
101  CommentItUtil.addComment(path, body, scontact);
102  }
103  CommentItCtrl sic = new CommentItCtrl(constructor);
104  sic.setEntityPath(path);
105  sic.renderComments(false);
106  }
107  } else if ("confirm".equals(action)) {
108  isAJAX = true;
109  constructor.getResponse().setContentType("text/html");
110  constructor.getResponse().setCharacterEncoding(ElephantContext.getEncoding());
111  PrintWriter out = constructor.getOut();
112  SignUp su = RegisterControl.confirmEmail(getParameter("id"));
113  RegisterControl.writeResultConfirmAction(constructor, su);
114  }
115 
116  if (!isAJAX) {
117  constructor.redirect(ctx);
118  }
119 
120  return IAction.DONE;
121  }
String getParameter(String param)
Here is the call graph for this function:

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