BrightSide Workbench Full Report + Source Code
org.turro.action.Actions Class Reference

Static Public Member Functions

static boolean executeAction (IConstructor constructor)
 
static String createActionFromElephant (String email, String redir)
 
static String createAction (String email, String redir)
 
static String createAction (Map< String, String > values, int daysValid, boolean ajax)
 
static String createAction (Map< String, String > values, boolean ajax)
 
static String createAction (Map< String, String > values)
 
static String createParameter (String email, String redir)
 
static String createParameter (Map< String, String > values, int daysValid, boolean ajax)
 
static String createParameter (Map< String, String > values, boolean ajax)
 
static String createParameter (Map< String, String > values)
 
static String createParameter (String action)
 
static Charset getCharset ()
 
static boolean prepareActions (IConstructor constructor, KeyValueMap values)
 
static boolean checkEnding (IConstructor constructor, KeyValueMap values) throws IOException
 
static boolean executeExternalActions (IConstructor constructor, KeyValueMap values)
 
static KeyValueMap getAction (IConstructor constructor)
 
static boolean isRightNowAction (IConstructor constructor)
 
static String createPars (String values, int days)
 
static String createPars (Map< String, String > values, int days)
 
static Map< String, String > addEmailAndDays (Map< String, String > values, String email, int days)
 
static String createRightNowAction (String values)
 
static String createRightNowAction (Map< String, String > values)
 
static String createRightNowParameter (String values)
 
static String createRightNowParameter (Map< String, String > values)
 
static KeyValueMap getRightNowAction (IConstructor constructor)
 

Static Public Attributes

static final String USER_PAR = "user"
 

Detailed Description

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

Definition at line 55 of file Actions.java.

Member Function Documentation

◆ addEmailAndDays()

static Map<String, String> org.turro.action.Actions.addEmailAndDays ( Map< String, String >  values,
String  email,
int  days 
)
static

Definition at line 306 of file Actions.java.

306  {
307  values.put(DVALID_PAR, ObjectString.formatObject(new CheckDate().addDays(days).getDate(), ObjectString.COMPRESSED_DATE_PATTERN, false));
308  values.put(USER_PAR, email);
309  return values;
310  }
static final String USER_PAR
Definition: Actions.java:66

◆ checkEnding()

static boolean org.turro.action.Actions.checkEnding ( IConstructor  constructor,
KeyValueMap  values 
) throws IOException
static

Definition at line 205 of file Actions.java.

205  {
206  String redir = values.get(REDIR_PAR);
207  if(!Strings.isBlank(redir)) {
208  HttpServletResponse response = constructor.getResponse();
209  response.setCharacterEncoding(charset.name());
210  response.sendRedirect(ElephantContext.getRootWebPath() +
211  encodePars(URLDecoder.decode(redir, charset.name()), charset.name() + addParameters(values)));
212  return true;
213  }
214  String ajax = values.get(AJAX_PAR);
215  if("true".equals(ajax)) {
216  return true;
217  }
218  return false;
219  }
Here is the caller graph for this function:

◆ createAction() [1/4]

static String org.turro.action.Actions.createAction ( Map< String, String >  values)
static

Definition at line 114 of file Actions.java.

114  {
115  String exacton = createParameter(values);
116  if(exacton != null) {
117  return ACTION_PAR + "=" + exacton;
118  }
119  return null;
120  }
static String createParameter(String email, String redir)
Definition: Actions.java:122

◆ createAction() [2/4]

static String org.turro.action.Actions.createAction ( Map< String, String >  values,
boolean  ajax 
)
static

Definition at line 106 of file Actions.java.

106  {
107  String exacton = createParameter(values, ajax);
108  if(exacton != null) {
109  return ACTION_PAR + "=" + exacton;
110  }
111  return null;
112  }

◆ createAction() [3/4]

static String org.turro.action.Actions.createAction ( Map< String, String >  values,
int  daysValid,
boolean  ajax 
)
static

Definition at line 98 of file Actions.java.

98  {
99  String exacton = createParameter(values, daysValid, ajax);
100  if(exacton != null) {
101  return ACTION_PAR + "=" + exacton;
102  }
103  return null;
104  }

◆ createAction() [4/4]

static String org.turro.action.Actions.createAction ( String  email,
String  redir 
)
static

Definition at line 90 of file Actions.java.

90  {
91  String exacton = createParameter(email, redir);
92  if(exacton != null) {
93  return ACTION_PAR + "=" + exacton;
94  }
95  return null;
96  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ createActionFromElephant()

static String org.turro.action.Actions.createActionFromElephant ( String  email,
String  redir 
)
static

Definition at line 86 of file Actions.java.

86  {
87  return createAction(email, Strings.convert(redir, charset(redir), Actions.getCharset().name()));
88  }
static String createAction(String email, String redir)
Definition: Actions.java:90
Here is the call graph for this function:
Here is the caller graph for this function:

◆ createParameter() [1/5]

static String org.turro.action.Actions.createParameter ( Map< String, String >  values)
static

Definition at line 146 of file Actions.java.

146  {
147  String action = KeyValueMap.format(values);
148  if(action != null) {
149  try {
150  return URLEncoder.encode(ElephantContext.encrypt(action), charset.name());
151  } catch (UnsupportedEncodingException ex) {
152  Logger.getLogger(Actions.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
153  }
154  }
155  return null;
156  }

◆ createParameter() [2/5]

static String org.turro.action.Actions.createParameter ( Map< String, String >  values,
boolean  ajax 
)
static

Definition at line 139 of file Actions.java.

139  {
140  if(ajax) {
141  values.put(AJAX_PAR, "true");
142  }
143  return createParameter(values);
144  }

◆ createParameter() [3/5]

static String org.turro.action.Actions.createParameter ( Map< String, String >  values,
int  daysValid,
boolean  ajax 
)
static

Definition at line 134 of file Actions.java.

134  {
135  values.put(DVALID_PAR, ObjectString.formatObject(new CheckDate().addDays(daysValid).getDate(), ObjectString.COMPRESSED_DATE_PATTERN, false));
136  return createParameter(values, ajax);
137  }

◆ createParameter() [4/5]

static String org.turro.action.Actions.createParameter ( String  action)
static

Definition at line 158 of file Actions.java.

158  {
159  if(action != null) {
160  try {
161  return URLEncoder.encode(ElephantContext.encrypt(action), charset.name());
162  } catch (UnsupportedEncodingException ex) {
163  Logger.getLogger(Actions.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
164  }
165  }
166  return null;
167  }
Here is the call graph for this function:

◆ createParameter() [5/5]

static String org.turro.action.Actions.createParameter ( String  email,
String  redir 
)
static

Definition at line 122 of file Actions.java.

122  {
123  try {
124  HashMap<String, String> values = new HashMap<>();
125  values.put(Actions.USER_PAR, email);
126  values.put(Actions.REDIR_PAR, URLEncoder.encode(redir, charset.name()));
127  return Actions.createParameter(values, 8, false);
128  } catch (UnsupportedEncodingException ex) {
129  Logger.getLogger(Actions.class.getName()).log(Level.SEVERE, null, ex);
130  }
131  return null;
132  }
Here is the caller graph for this function:

◆ createPars() [1/2]

static String org.turro.action.Actions.createPars ( Map< String, String >  values,
int  days 
)
static

Definition at line 301 of file Actions.java.

301  {
302  values.put(DVALID_PAR, ObjectString.formatObject(new CheckDate().addDays(days).getDate(), ObjectString.COMPRESSED_DATE_PATTERN, false));
303  return createParameter(values);
304  }

◆ createPars() [2/2]

static String org.turro.action.Actions.createPars ( String  values,
int  days 
)
static

Definition at line 292 of file Actions.java.

292  {
293  try {
294  return createRightNowParameter(new KeyValueMap(values));
295  } catch (ParserException ex) {
296  Logger.getLogger(Actions.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
297  }
298  return null;
299  }
static String createRightNowParameter(String values)
Definition: Actions.java:333
Here is the caller graph for this function:

◆ createRightNowAction() [1/2]

static String org.turro.action.Actions.createRightNowAction ( Map< String, String >  values)
static

Definition at line 321 of file Actions.java.

321  {
322  String exrino = createRightNowParameter(values);
323  if(exrino != null) {
324  try {
325  return RIGHTNOW_PAR + "=" + URLEncoder.encode(exrino, charset.name());
326  } catch (UnsupportedEncodingException ex) {
327  Logger.getLogger(Actions.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
328  }
329  }
330  return null;
331  }

◆ createRightNowAction() [2/2]

static String org.turro.action.Actions.createRightNowAction ( String  values)
static

Definition at line 312 of file Actions.java.

312  {
313  try {
314  return createRightNowAction(new KeyValueMap(values));
315  } catch (ParserException ex) {
316  Logger.getLogger(Actions.class.getName()).log(Level.SEVERE, null, ex);
317  }
318  return null;
319  }
static String createRightNowAction(String values)
Definition: Actions.java:312
Here is the caller graph for this function:

◆ createRightNowParameter() [1/2]

static String org.turro.action.Actions.createRightNowParameter ( Map< String, String >  values)
static

Definition at line 337 of file Actions.java.

337  {
338  return createPars(values, 1);
339  }
static String createPars(String values, int days)
Definition: Actions.java:292

◆ createRightNowParameter() [2/2]

static String org.turro.action.Actions.createRightNowParameter ( String  values)
static

Definition at line 333 of file Actions.java.

333  {
334  return createPars(values, 1);
335  }
Here is the caller graph for this function:

◆ executeAction()

static boolean org.turro.action.Actions.executeAction ( IConstructor  constructor)
static

Definition at line 70 of file Actions.java.

70  {
71  String exacton = constructor.getParameter(ACTION_PAR);
72  if(!Strings.isBlank(exacton)) {
73  try {
74  KeyValueMap kvm = new KeyValueMap(ElephantContext.decrypt(exacton));
75  if(prepareActions(constructor, kvm)) {
76  executeExternalActions(constructor, kvm);
77  return checkEnding(constructor, kvm);
78  }
79  } catch (IOException | ParserException ex) {
80  Logger.getLogger(Actions.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
81  }
82  }
83  return false;
84  }
static boolean executeExternalActions(IConstructor constructor, KeyValueMap values)
Definition: Actions.java:244
static boolean checkEnding(IConstructor constructor, KeyValueMap values)
Definition: Actions.java:205
static boolean prepareActions(IConstructor constructor, KeyValueMap values)
Definition: Actions.java:173
Here is the call graph for this function:
Here is the caller graph for this function:

◆ executeExternalActions()

static boolean org.turro.action.Actions.executeExternalActions ( IConstructor  constructor,
KeyValueMap  values 
)
static

Definition at line 244 of file Actions.java.

244  {
245  if (Instances.cached().byAnnotation(ExternalAction.class, IAction.class)
246  .stream().anyMatch((iAction) -> (iAction.execute(constructor, values)))) {
247  return true;
248  }
249  return false;
250  }
Here is the caller graph for this function:

◆ getAction()

static KeyValueMap org.turro.action.Actions.getAction ( IConstructor  constructor)
static

Definition at line 252 of file Actions.java.

252  {
253  String exacton = constructor.getParameter(ACTION_PAR, false);
254  if(!Strings.isBlank(exacton)) {
255  try {
256  KeyValueMap values = new KeyValueMap(ElephantContext.decrypt(exacton));
257  Date valid = (Date) ObjectString.parseString(values.get(DVALID_PAR), ObjectString.COMPRESSED_DATE_PATTERN, Date.class, false);
258  if(valid != null) {
259  if(valid.before(new Date())) {
260  return null;
261  }
262  } else {
263  return null;
264  }
265  return values;
266  } catch (ParserException ex) {
267  Logger.getLogger(Actions.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
268  }
269  }
270  return null;
271  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getCharset()

static Charset org.turro.action.Actions.getCharset ( )
static

Definition at line 169 of file Actions.java.

169  {
170  return charset;
171  }
Here is the caller graph for this function:

◆ getRightNowAction()

static KeyValueMap org.turro.action.Actions.getRightNowAction ( IConstructor  constructor)
static

Definition at line 341 of file Actions.java.

341  {
342  String exrino = constructor.getParameter(RIGHTNOW_PAR, true);
343  if(!Strings.isBlank(exrino)) {
344  try {
345  KeyValueMap values = new KeyValueMap(ElephantContext.decrypt(exrino));
346  Date valid = (Date) ObjectString.parseString(values.get(DVALID_PAR), ObjectString.COMPRESSED_DATE_PATTERN, Date.class, false);
347  if(valid != null) {
348  if(valid.before(new Date())) {
349  return null;
350  }
351  } else {
352  return null;
353  }
354  return values;
355  } catch (ParserException ex) {
356  Logger.getLogger(Actions.class.getName()).log(Level.SEVERE, null, ex);
357  }
358  }
359  return null;
360  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isRightNowAction()

static boolean org.turro.action.Actions.isRightNowAction ( IConstructor  constructor)
static

Definition at line 288 of file Actions.java.

288  {
289  return !Strings.isBlank(constructor.getParameter(RIGHTNOW_PAR, true));
290  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ prepareActions()

static boolean org.turro.action.Actions.prepareActions ( IConstructor  constructor,
KeyValueMap  values 
)
static

Definition at line 173 of file Actions.java.

173  {
174  boolean authenticated = false;
175  IUser logged = constructor.getUser();
176  String email = values.get(USER_PAR);
177  if(!Strings.isBlank(email) && logged != null) {
178  authenticated = CompareUtil.compare(email, logged.getProperty(IUser.CONNECTOR_EMAIL)) == 0;
179  }
180  if(!authenticated && (isReminder(values) || ElephantContext.getLiveLinks())) {
181  Date valid = (Date) ObjectString.parseString(values.get(DVALID_PAR), ObjectString.COMPRESSED_DATE_PATTERN, Date.class, false);
182  if(valid != null) {
183  if(valid.before(new Date())) {
184  return false;
185  }
186  }
187  if(!Strings.isBlank(email)) {
188  IContact user = Contacts.getEmpty();
189  if(!user.impersonateByEmail(email)) {
190  return false;
191  }
192  constructor.setSessionAttribute(IUser.INTERNAL_SIGNIN, Boolean.TRUE);
193  constructor.setSessionAttribute(IUser.LOGGED_USER, user);
194  constructor.setSessionAttribute(Contacts.LOGGED_ICONTACT, Contacts.getLoggedIContact(Application.getApplication()));
195  SystemLogger.getInstance().doLog(SystemLogType.LOG_INFO, "/log/in", "Live Link", values.toString());
196  if(SSO.hasSSO()) {
197  SSO.getSSO().createAssertion(constructor.getRequest(), constructor.getResponse(),
198  (IContact) constructor.getSessionAttribute(Contacts.LOGGED_ICONTACT));
199  }
200  }
201  }
202  return true;
203  }
Here is the caller graph for this function:

Member Data Documentation

◆ USER_PAR

final String org.turro.action.Actions.USER_PAR = "user"
static

Definition at line 66 of file Actions.java.


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