BrightSide Workbench Full Report + Source Code
org.turro.elephant.direct.AbstractDirectContentCtrl Class Referenceabstract
Inheritance diagram for org.turro.elephant.direct.AbstractDirectContentCtrl:
Collaboration diagram for org.turro.elephant.direct.AbstractDirectContentCtrl:

Public Member Functions

 AbstractDirectContentCtrl (String tmplRoot)
 
String createFormAction ()
 
String createPOST (String values)
 
String getAjaxSubmitUrl (String containerId)
 
String getAjaxUrl (String containerId, String values)
 
String getAjaxUrl (String containerId, KeyValueMap values)
 
String getAjaxEvalUrl (KeyValueMap values)
 
String createRightNowURL (String values)
 
String createRightNowURL (KeyValueMap values)
 
String createLinkTo (String link, KeyValueMap values)
 
String createURL ()
 
String createURL (IConstructor constructor, String values)
 
String createURL (IConstructor constructor, String values, int daysValid)
 
String createURL (IConstructor constructor, String values, int daysValid, boolean withDomain)
 
String createURL (IConstructor constructor, IContact recipe, String values, int daysValid, boolean withDomain)
 
String createURL (IConstructor constructor, IContact recipe, KeyValueMap values, int daysValid, boolean withDomain)
 
void setTemplate (String template)
 
void render (IConstructor constructor)
 
String parse (IConstructor constructor)
 
boolean itsMe (String id)
 
boolean myTurn (HttpServletRequest request)
 
void execute (ServletContext context, HttpServletRequest request, HttpServletResponse response)
 
void execute (IConstructor constructor)
 

Protected Member Functions

String getRedirContext (IConstructor constructor, boolean withDomain)
 
ElephantMarker getMarker (IConstructor constructor)
 
ElephantMarker getCleanMarkerFrom (IConstructor constructor)
 
void addContainerId (ElephantMarker marker, boolean container)
 
String getTmplRoot ()
 
String getTemplate ()
 
void writeMarkerToResponse (IConstructor constructor, KeyValueMap map)
 
void writeMarkerToResponse (IConstructor constructor, KeyValueMap map, Map extra)
 
void setNeedsUser (boolean needsUser)
 
abstract String getIdentifier ()
 
abstract void prepareMarker (ElephantMarker marker)
 
abstract void prepareCleanMarker (ElephantMarker marker, KeyValueMap map)
 
abstract void doExecute (IConstructor constructor, KeyValueMap map)
 

Protected Attributes

String template = "full"
 

Detailed Description

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

Definition at line 44 of file AbstractDirectContentCtrl.java.

Constructor & Destructor Documentation

◆ AbstractDirectContentCtrl()

org.turro.elephant.direct.AbstractDirectContentCtrl.AbstractDirectContentCtrl ( String  tmplRoot)

Definition at line 50 of file AbstractDirectContentCtrl.java.

50  {
51  this.tmplRoot = tmplRoot;
52  }

Member Function Documentation

◆ addContainerId()

void org.turro.elephant.direct.AbstractDirectContentCtrl.addContainerId ( ElephantMarker  marker,
boolean  container 
)
protected

Definition at line 219 of file AbstractDirectContentCtrl.java.

219  {
220  marker.put("container", container);
221  String domid = (String) marker.get("domid");
222  if(Strings.isBlank(domid)) domid = marker.getConstructor().getParameter("domid");
223  marker.put("containerId", container ? "cic_" + IdGenerator.generate() : domid);
224  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ createFormAction()

String org.turro.elephant.direct.AbstractDirectContentCtrl.createFormAction ( )

Definition at line 54 of file AbstractDirectContentCtrl.java.

54  {
55  return DirectContents.createRelativeURL(getIdentifier());
56  }
Here is the call graph for this function:

◆ createLinkTo()

String org.turro.elephant.direct.AbstractDirectContentCtrl.createLinkTo ( String  link,
KeyValueMap  values 
)

Definition at line 133 of file AbstractDirectContentCtrl.java.

133  {
134  return ElephantContext.getRootWebPath() +
135  link + "?" + Actions.createAction(values);
136  }

◆ createPOST()

String org.turro.elephant.direct.AbstractDirectContentCtrl.createPOST ( String  values)

Definition at line 58 of file AbstractDirectContentCtrl.java.

58  {
59  return "$.post('" + ElephantContext.getRootWebPath() + DirectContents.DIRECT_CONTENT_PATH + getIdentifier() + "'," +
60  "{ exrino : '" + Actions.createRightNowParameter(values) + "' })";
61  }

◆ createRightNowURL() [1/2]

String org.turro.elephant.direct.AbstractDirectContentCtrl.createRightNowURL ( KeyValueMap  values)

Definition at line 127 of file AbstractDirectContentCtrl.java.

127  {
128  return ElephantContext.getRootWebPath() +
129  DirectContents.DIRECT_CONTENT_PATH + getIdentifier() +
130  "?" + Actions.createRightNowAction(values);
131  }

◆ createRightNowURL() [2/2]

String org.turro.elephant.direct.AbstractDirectContentCtrl.createRightNowURL ( String  values)

Definition at line 118 of file AbstractDirectContentCtrl.java.

118  {
119  try {
120  return createRightNowURL(new KeyValueMap(values));
121  } catch (ParserException ex) {
122  Logger.getLogger(AbstractDirectContentCtrl.class.getName()).log(Level.SEVERE, null, ex);
123  }
124  return null;
125  }
Here is the caller graph for this function:

◆ createURL() [1/6]

String org.turro.elephant.direct.AbstractDirectContentCtrl.createURL ( )

Definition at line 138 of file AbstractDirectContentCtrl.java.

138  {
139  return ElephantContext.getRootWebPath() +
140  DirectContents.DIRECT_CONTENT_PATH + getIdentifier();
141  }
Here is the call graph for this function:

◆ createURL() [2/6]

String org.turro.elephant.direct.AbstractDirectContentCtrl.createURL ( IConstructor  constructor,
IContact  recipe,
KeyValueMap  values,
int  daysValid,
boolean  withDomain 
)

Definition at line 190 of file AbstractDirectContentCtrl.java.

190  {
191  values.put(Actions.USER_PAR, recipe.getConnector(IUser.CONNECTOR_EMAIL));
192  values.put(Actions.REDIR_PAR, getRedirContext(constructor, withDomain));
193  return (withDomain ? ElephantContext.getServerBase("http") : "") +
194  ElephantContext.getRootWebPath() +
195  DirectContents.DIRECT_CONTENT_PATH + getIdentifier() +
196  "?" + Actions.createAction(values, daysValid, false);
197  }
String getRedirContext(IConstructor constructor, boolean withDomain)

◆ createURL() [3/6]

String org.turro.elephant.direct.AbstractDirectContentCtrl.createURL ( IConstructor  constructor,
IContact  recipe,
String  values,
int  daysValid,
boolean  withDomain 
)

Definition at line 168 of file AbstractDirectContentCtrl.java.

168  {
169  try {
170  return createURL(constructor, recipe, new KeyValueMap(values), daysValid, withDomain);
171  } catch (ParserException ex) {
172  Logger.getLogger(AbstractDirectContentCtrl.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
173  }
174  return null;
175 // String exrino = null;
176 // try {
177 // KeyValueMap kvm =
178 // kvm.put(Actions.USER_PAR, recipe.getConnector(IUser.CONNECTOR_EMAIL));
179 // kvm.put(Actions.REDIR_PAR, getRedirContext(withDomain));
180 // exrino = Actions.createAction(kvm, daysValid, false);
181 // } catch (ParserException ex) {
182 // Logger.getLogger(AbstractDirectContentCtrl.class.getName()).log(Level.SEVERE, null, ex);
183 // }
184 // return (withDomain ? ElephantContext.getServerBase("http") : "") +
185 // ElephantContext.getRootWebPath() +
186 // DirectContents.DIRECT_CONTENT_PATH + getIdentifier() +
187 // "?" + exrino;
188  }

◆ createURL() [4/6]

String org.turro.elephant.direct.AbstractDirectContentCtrl.createURL ( IConstructor  constructor,
String  values 
)

Definition at line 143 of file AbstractDirectContentCtrl.java.

143  {
144  return createURL(constructor, values, 7, false);
145  }

◆ createURL() [5/6]

String org.turro.elephant.direct.AbstractDirectContentCtrl.createURL ( IConstructor  constructor,
String  values,
int  daysValid 
)

Definition at line 147 of file AbstractDirectContentCtrl.java.

147  {
148  return createURL(constructor, values, daysValid, false);
149  }

◆ createURL() [6/6]

String org.turro.elephant.direct.AbstractDirectContentCtrl.createURL ( IConstructor  constructor,
String  values,
int  daysValid,
boolean  withDomain 
)

Definition at line 151 of file AbstractDirectContentCtrl.java.

151  {
152  return createURL(constructor, (IContact) constructor.getUser(), values, daysValid, withDomain);
153 // String exrino = null;
154 // try {
155 // KeyValueMap kvm = new KeyValueMap(values);
156 // kvm.put(Actions.USER_PAR, ((IContact) constructor.getUser()).getConnector(IUser.CONNECTOR_EMAIL));
157 // kvm.put(Actions.REDIR_PAR, getRedirContext(withDomain));
158 // exrino = Actions.createAction(kvm, daysValid, false);
159 // } catch (ParserException ex) {
160 // Logger.getLogger(AbstractDirectContentCtrl.class.getName()).log(Level.SEVERE, null, ex);
161 // }
162 // return (withDomain ? ElephantContext.getServerBase("http") : "") +
163 // ElephantContext.getRootWebPath() +
164 // DirectContents.DIRECT_CONTENT_PATH + getIdentifier() +
165 // "?" + exrino;
166  }

◆ doExecute()

◆ execute() [1/2]

void org.turro.elephant.direct.AbstractDirectContentCtrl.execute ( IConstructor  constructor)

Definition at line 294 of file AbstractDirectContentCtrl.java.

294  {
295  KeyValueMap map = Actions.isRightNowAction(constructor) ?
296  Actions.getRightNowAction(constructor) :
297  Actions.getAction(constructor);
298  if(map == null && "POST".equals(constructor.getRequest().getMethod())) {
299  map = new KeyValueMap(Collections.EMPTY_MAP);
300  for(String key : constructor.getRequest().getParameterMap().keySet()) {
301  map.put(key, constructor.getRequest().getParameter(key));
302  }
303  }
304  if(map != null) {
305  doExecute(constructor, map);
306  String redirect = map.get(Actions.REDIR_PAR);
307  if(!Strings.isBlank(redirect)) {
308  try {
309  constructor.redirect(redirect);
310  } catch (IOException ex) {
311  Logger.getLogger(AbstractDirectContentCtrl.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
312  }
313  }
314  }
315  }
abstract void doExecute(IConstructor constructor, KeyValueMap map)
Here is the call graph for this function:

◆ execute() [2/2]

void org.turro.elephant.direct.AbstractDirectContentCtrl.execute ( ServletContext  context,
HttpServletRequest  request,
HttpServletResponse  response 
)

Implements org.turro.elephant.direct.IDirectContent.

Definition at line 290 of file AbstractDirectContentCtrl.java.

290  {
291  execute(ElephantContext.getConstructor(request, response));
292  }
void execute(ServletContext context, HttpServletRequest request, HttpServletResponse response)
Here is the call graph for this function:

◆ getAjaxEvalUrl()

String org.turro.elephant.direct.AbstractDirectContentCtrl.getAjaxEvalUrl ( KeyValueMap  values)

Definition at line 112 of file AbstractDirectContentCtrl.java.

112  {
113  return "$.post('" + ElephantContext.getRootWebPath() + DirectContents.DIRECT_CONTENT_PATH + getIdentifier() + "'," +
114  "{ exrino : '" + Actions.createRightNowParameter(values) + "' })" +
115  ".done(function(data) { eval(data); });";
116  }

◆ getAjaxSubmitUrl()

String org.turro.elephant.direct.AbstractDirectContentCtrl.getAjaxSubmitUrl ( String  containerId)

FORM with id = 'form_containerId'. Must have a hidden input with domid = containerId, to resolve the container when is false while rendering and a hidden input with type value, to differentiate the action to process. A container with id = containerId must exist

Parameters
containerIdidentifier created when render container is true
Returns
The URL to use in the submit button

Definition at line 73 of file AbstractDirectContentCtrl.java.

73  {
74  return "$.post('" + ElephantContext.getRootWebPath() + DirectContents.DIRECT_CONTENT_PATH + getIdentifier() + "'," +
75  "$('#form_" + containerId + "').serialize())" +
76  ".done(function(data) { $('#" + containerId + "').html(data); });" +
77  "return false;";
78  }
Here is the call graph for this function:

◆ getAjaxUrl() [1/2]

String org.turro.elephant.direct.AbstractDirectContentCtrl.getAjaxUrl ( String  containerId,
KeyValueMap  values 
)

Ajax action with values passed in the URL. Includes domid = containerId, to resolve the container when is false while rendering.

Parameters
containerIdidentifier created when render container is true
valuesMap values to encrypt
Returns
The URL to use in the onclick event

Definition at line 105 of file AbstractDirectContentCtrl.java.

105  {
106  values.put("domid", containerId);
107  return "$.post('" + ElephantContext.getRootWebPath() + DirectContents.DIRECT_CONTENT_PATH + getIdentifier() + "'," +
108  "{ exrino : '" + Actions.createRightNowParameter(values) + "' })" +
109  ".done(function(data) { $('#" + containerId + "').html(data); });";
110  }

◆ getAjaxUrl() [2/2]

String org.turro.elephant.direct.AbstractDirectContentCtrl.getAjaxUrl ( String  containerId,
String  values 
)

Ajax action with values passed in the URL. Includes domid = containerId, to resolve the container when is false while rendering.

Parameters
containerIdidentifier created when render container is true
valuesValues in format name=value separated by semicolon
Returns
The URL to use in the onclick event

Definition at line 88 of file AbstractDirectContentCtrl.java.

88  {
89  try {
90  return getAjaxUrl(containerId, new KeyValueMap(values));
91  } catch (ParserException ex) {
92  Logger.getLogger(AbstractDirectContentCtrl.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(values), ex);
93  }
94  return "";
95  }
String getAjaxUrl(String containerId, String values)

◆ getCleanMarkerFrom()

ElephantMarker org.turro.elephant.direct.AbstractDirectContentCtrl.getCleanMarkerFrom ( IConstructor  constructor)
protected

Definition at line 213 of file AbstractDirectContentCtrl.java.

213  {
214  ElephantMarker marker = new ElephantMarker(constructor);
215  marker.put("actions", this);
216  return marker;
217  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getIdentifier()

◆ getMarker()

ElephantMarker org.turro.elephant.direct.AbstractDirectContentCtrl.getMarker ( IConstructor  constructor)
protected

Reimplemented in org.turro.elephant.direct.AbstractDirectEntityCtrl.

Definition at line 207 of file AbstractDirectContentCtrl.java.

207  {
208  ElephantMarker marker = getCleanMarkerFrom(constructor);
209  prepareMarker(marker);
210  return marker;
211  }
ElephantMarker getCleanMarkerFrom(IConstructor constructor)
abstract void prepareMarker(ElephantMarker marker)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getRedirContext()

String org.turro.elephant.direct.AbstractDirectContentCtrl.getRedirContext ( IConstructor  constructor,
boolean  withDomain 
)
protected

Definition at line 199 of file AbstractDirectContentCtrl.java.

199  {
200  if(withDomain) {
201  return ElephantContext.getServerBase("http") + constructor.getCurrentContext().getWebPath();
202  } else {
203  return constructor.getCurrentContext().getPath();
204  }
205  }
Here is the call graph for this function:

◆ getTemplate()

String org.turro.elephant.direct.AbstractDirectContentCtrl.getTemplate ( )
protected

Definition at line 230 of file AbstractDirectContentCtrl.java.

230  {
231  return template;
232  }
Here is the caller graph for this function:

◆ getTmplRoot()

String org.turro.elephant.direct.AbstractDirectContentCtrl.getTmplRoot ( )
protected

Definition at line 226 of file AbstractDirectContentCtrl.java.

226  {
227  return tmplRoot;
228  }
Here is the caller graph for this function:

◆ itsMe()

boolean org.turro.elephant.direct.AbstractDirectContentCtrl.itsMe ( String  id)

Implements org.turro.elephant.direct.IDirectContent.

Definition at line 280 of file AbstractDirectContentCtrl.java.

280  {
281  return getIdentifier().equals(id);
282  }
Here is the call graph for this function:

◆ myTurn()

boolean org.turro.elephant.direct.AbstractDirectContentCtrl.myTurn ( HttpServletRequest  request)

Implements org.turro.elephant.direct.IDirectContent.

Definition at line 285 of file AbstractDirectContentCtrl.java.

285  {
286  return DirectContents.isYourTurn(request, getIdentifier());
287  }
Here is the call graph for this function:

◆ parse()

String org.turro.elephant.direct.AbstractDirectContentCtrl.parse ( IConstructor  constructor)

Definition at line 266 of file AbstractDirectContentCtrl.java.

266  {
267  if(!needsUser || hasUser(constructor)) {
268  return getMarker(constructor).parse(tmplRoot, template);
269  }
270  return "";
271  }
String parse(String rootTmpl, String tmpl)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ prepareCleanMarker()

◆ prepareMarker()

◆ render()

void org.turro.elephant.direct.AbstractDirectContentCtrl.render ( IConstructor  constructor)

Reimplemented in org.turro.timetracker.TimeTrackerCtrl.

Definition at line 260 of file AbstractDirectContentCtrl.java.

260  {
261  if(!needsUser || hasUser(constructor)) {
262  getMarker(constructor).process(tmplRoot, template);
263  }
264  }
void process(String rootTmpl, String tmpl)
Here is the call graph for this function:

◆ setNeedsUser()

void org.turro.elephant.direct.AbstractDirectContentCtrl.setNeedsUser ( boolean  needsUser)
protected

Definition at line 252 of file AbstractDirectContentCtrl.java.

252  {
253  this.needsUser = needsUser;
254  }
Here is the caller graph for this function:

◆ setTemplate()

void org.turro.elephant.direct.AbstractDirectContentCtrl.setTemplate ( String  template)

Definition at line 256 of file AbstractDirectContentCtrl.java.

256  {
257  if(template != null) this.template = template;
258  }
Here is the caller graph for this function:

◆ writeMarkerToResponse() [1/2]

void org.turro.elephant.direct.AbstractDirectContentCtrl.writeMarkerToResponse ( IConstructor  constructor,
KeyValueMap  map 
)
protected

Definition at line 234 of file AbstractDirectContentCtrl.java.

234  {
235  writeMarkerToResponse(constructor, map, null);
236  }
void writeMarkerToResponse(IConstructor constructor, KeyValueMap map)

◆ writeMarkerToResponse() [2/2]

void org.turro.elephant.direct.AbstractDirectContentCtrl.writeMarkerToResponse ( IConstructor  constructor,
KeyValueMap  map,
Map  extra 
)
protected

Definition at line 238 of file AbstractDirectContentCtrl.java.

238  {
239  ElephantMarker marker = getCleanMarkerFrom(constructor);
240  prepareCleanMarker(marker, map);
241  addContainerId(marker, false);
242  if(extra != null) marker.putAll(extra);
243  try {
244  constructor.getResponse().setContentType("text/html");
245  constructor.getResponse().setCharacterEncoding(ElephantContext.getEncoding());
246  marker.process(getTmplRoot(), getTemplate(), constructor.getResponse().getWriter());
247  } catch (IOException ex) {
248  Logger.getLogger(AbstractDirectContentCtrl.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
249  }
250  }
abstract void prepareCleanMarker(ElephantMarker marker, KeyValueMap map)
void addContainerId(ElephantMarker marker, boolean container)
Here is the call graph for this function:

Member Data Documentation

◆ template

String org.turro.elephant.direct.AbstractDirectContentCtrl.template = "full"
protected

Definition at line 48 of file AbstractDirectContentCtrl.java.


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