BrightSide Workbench Full Report + Source Code
DefaultConstructor.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2011 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 package org.turro.elephant.impl.context;
19 
20 import java.io.*;
21 import java.net.URLDecoder;
22 import java.net.URLEncoder;
23 import java.util.*;
24 import java.util.logging.Level;
25 import java.util.logging.Logger;
26 import javax.servlet.ServletException;
27 import javax.servlet.ServletRequest;
28 import javax.servlet.ServletResponse;
29 import javax.servlet.http.HttpServletRequest;
30 import javax.servlet.http.HttpServletResponse;
31 import javax.servlet.http.HttpSession;
32 import org.turro.string.Strings;
33 import org.jdom.Element;
34 import org.turro.action.Actions;
35 import org.turro.action.Parameters;
36 import org.turro.action.Secrets;
37 import org.turro.annotation.ElephantConstructor;
38 import org.turro.elephant.context.Application;
39 import org.turro.elephant.context.ElephantContext;
40 import org.turro.elephant.context.ElephantLogin;
41 import org.turro.elephant.context.History;
42 import org.turro.elephant.context.IAction;
43 import org.turro.elephant.context.IConstructor;
44 import org.turro.elephant.context.MetaList;
45 import org.turro.elephant.impl.util.CookieUtil;
46 import org.turro.elephant.impl.util.FileUtil;
47 import org.turro.elephant.impl.util.Localizer;
48 import org.turro.elephant.impl.util.Parser;
49 import org.turro.elephant.security.IUser;
50 import org.turro.elephant.web.ElContext;
51 import org.turro.elephant.web.ElContextMap;
52 import org.turro.html.HtmlContent;
53 import org.turro.i18n.I_;
54 import org.turro.marker.ElephantMarker;
55 import org.turro.plugin.contacts.IContact;
56 import org.turro.util.IdGenerator;
57 
62 @ElephantConstructor
63 public class DefaultConstructor implements IConstructor {
64 
65  protected final static String
66  BUNDLE_LOCATION = "/WEB-INF/classes/elephant.properties";
67  protected HttpServletRequest request;
68  protected HttpServletResponse response;
69  protected ElContext rendering = null, currentContext = null;
70  protected Properties bundle = null;
71  protected PrintWriter out = null;
72  protected StringWriter stringOutput = null;
73  protected ArrayList metas = new ArrayList(), headers = new ArrayList(), footers = new ArrayList();
74  protected boolean isAContext = false, pageRendering = true, nullOutput = false;
75  protected String stopper;
76  protected boolean hasMootools = false, hasPrototype = false;
77 
78  private int uniqueSuffix = 0;
79 
81  public DefaultConstructor() {
83  }
84 
85  @Override
86  public boolean isHeadless() {
87  return request == null;
88  }
89 
90  @Override
91  public void setRequest(ServletRequest request) {
92  this.request = (HttpServletRequest)request;
93  if(this.request != null) {
94  this.request.setAttribute("el_cons", this);
95  if(Application.loadResources(((HttpServletRequest) request).getServletPath())) {
96  this.request.setAttribute("el_label", I_.compatibilityMap());
97  this.request.setAttribute("i_", I_.api());
98  this.request.setAttribute("i", I_.map());
99  this.request.setAttribute("k", I_.byKeyMap());
100  }
101  }
102  }
103 
104  @Override
105  public void setResponse(ServletResponse response) {
106  this.response = (HttpServletResponse)response;
107  if(this.response != null)
108  CookieUtil.setCookie((HttpServletResponse) response, "webroot", request.getContextPath(), "/", 30*24*60*60);
109  }
110 
111  @Override
112  public HttpServletRequest getRequest() {
113  return request;
114  }
115 
116  @Override
117  public HttpServletResponse getResponse() {
118  return response;
119  }
120 
121  @Override
123  if(currentContext == null)
124  currentContext = ElContextMap.getContext(this);
125  return currentContext;
126  }
127 
128  @Override
130  if(rendering == null) return getCurrentContext();
131  return rendering;
132  }
133 
134  @Override
135  public void setRenderingContext(ElContext context) {
136  rendering = context;
137  }
138 
139  @Override
140  public void forceIsAContext(ElContext context) {
141  currentContext = context;
142  isAContext = true;
143  }
144 
145  @Override
146  public boolean isOriginal() {
148  }
149 
150  @Override
151  public boolean isFileInternal(File file) {
152  if(file == null) return true;
153  String fileName = file.isFile() ? file.getName() : file.getAbsolutePath();
154  String internals = ElephantContext.getSiteInternalFiles();
155  if(internals != null) {
156  String tmp[] = internals.split(",");
157  for(String s : tmp) {
158  if(fileName.matches(Strings.convertToRegEx(s))) return true;
159  }
160  }
161  return (fileName.matches("google.*\\.html")) ||
162  (fileName.matches("site.*\\.xml")) ||
163  (fileName.matches("robots\\.txt")) ||
164  (fileName.contains("_internal")) ||
165  (fileName.contains("_zul")) ||
166  (fileName.contains("resources")) ||
167  (fileName.contains("WEB-INF")) ||
168  (fileName.contains("META-INF"));
169  }
170 
171  @Override
172  public Object findAttribute(String key) {
173  Object value = getRequestAttribute(key);
174  if(value == null) value = getSessionAttribute(key);
175  if(value == null) value = getApplicationAttribute(key);
176  return value;
177  }
178 
179  @Override
180  public Object getApplicationAttribute(String key) {
181  return ElephantContext.getAttribute(key);
182  }
183 
184  @Override
185  public Object getSessionAttribute(String key) {
186  try {
187  if(request != null && request.getSession(false) != null) {
188  return request.getSession().getAttribute(key);
189  }
190  } catch(Exception ex) {
191  Logger.getLogger(DefaultConstructor.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
192  }
193  return null;
194  }
195 
196  @Override
197  public Map<String, Object> getSessionAttributeMap(String prefix) {
198  HashMap<String, Object> map = new HashMap<>();
199  try {
200  if(request != null && request.getSession(false) != null) {
201  HttpSession session = request.getSession();
202  Iterator<String> it = session.getAttributeNames().asIterator();
203  while(it.hasNext()) {
204  String key = it.next();
205  if(Strings.isBlank(prefix) || key.startsWith(prefix)) {
206  map.put(Strings.killPrefix(key, prefix), session.getAttribute(key));
207  }
208  }
209  }
210  } catch(Exception ex) {
211  Logger.getLogger(DefaultConstructor.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
212  }
213  return map;
214  }
215 
216  @Override
217  public Object getRequestAttribute(String key) {
218  return request != null ? request.getAttribute(key) : null;
219  }
220 
221  @Override
222  public void setApplicationAttribute(String key, Object value) {
223  ElephantContext.setAttribute(key, value);
224  }
225 
226  @Override
227  public void setSessionAttribute(String key, Object value) {
228  try {
229  if(request != null && request.getSession() != null) request.getSession().setAttribute(key, value);
230  } catch(Exception ex) {
231  Logger.getLogger(DefaultConstructor.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
232  }
233  }
234 
235  @Override
236  public void setRequestAttribute(String key, Object value) {
237  try {
238  if(request != null && request.getRequestURI() != null) request.setAttribute(key, value);
239  } catch(Exception ex) {
240  Logger.getLogger(DefaultConstructor.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
241  }
242  }
243 
244  @Override
245  public void removeApplicationAttribute(String key) {
247  }
248 
249  @Override
250  public void removeSessionAttribute(String key) {
251  try {
252  if(request != null && request.getSession(false) != null) request.getSession().removeAttribute(key);
253  } catch(Exception ex) {
254  Logger.getLogger(DefaultConstructor.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
255  }
256  }
257 
258  @Override
259  public void removeRequestAttribute(String key) {
260  try {
261  if(request != null) request.removeAttribute(key);
262  } catch(Exception ex) {
263  Logger.getLogger(DefaultConstructor.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
264  }
265  }
266 
267  @Override
268  public void startConstruction() throws IOException, ServletException {
269  boolean include = request.getServletPath().startsWith("/xp"),
270  action = request.getServletPath().startsWith("/xpaction");
271 
272  if(Actions.executeAction(this)) return;
273 
274  Element incNode = null;
275  //if(checkRedirections()) return;
276  if(include) {
277  incNode = ContextFactory.getInclude(this);
278  }
279  if(action) {
280  //TODO: check permissions
281  request.setAttribute("el_cons", this);
282  IAction exec = ContextFactory.getAction(this);
283  try {
284  exec.execute();
285  } catch (Exception ex) {
286  throw new ServletException(ex);
287  }
288  } else {
289  request.setAttribute("el_cons", this);
290  if(incNode != null) {
291  Iterator heads = incNode.getChildren("header").iterator();
292  Element tmp;
293  while(heads.hasNext()) {
294  tmp = (Element) heads.next();
295  switch (tmp.getAttributeValue("type")) {
296  case "css":
297  addCSS(tmp.getAttributeValue("content"));
298  break;
299  case "javascript":
300  addJavaScript(tmp.getAttributeValue("content"));
301  break;
302  }
303  }
304  }
305  if(incNode != null) {
306  //TODO: check permissions
307  includeContent(incNode.getAttributeValue("content"));
308  } else {
309  if(getCurrentContext() == null || !getCurrentContext().getFile().exists()) {
310  redirect("/");
311  return;
312  } else {
313  if(!Strings.isBlank(getCurrentContext().getWebContext().getRedirect())) {
314  if(getCurrentContext().isInRole()) {
316  redirect(getCurrentContext().getWebContext().getRedirect());
317  return;
318  } else if(getUser() == null) {
320  return;
321  } else {
323  return;
324  }
325  } else {
326  if(getCurrentContext().isInRole()) {
328  isAContext = true;
329  addOnLoadedJavaScript("webRoot = '" + ElephantContext.getRootWebPath() + "';");
330  addOnLoadedJavaScript("webPort = " + getRequest().getServerPort() + ";");
331  addOnLoadedJavaScript("pushPK = '" + Secrets.getSecret("key=push;pair=pk") + "';");
332  IUser iuser = getUser();
333  if(iuser != null) {
334  addOnLoadedJavaScript("currentMail = '" + iuser.getProperty(IUser.CONNECTOR_EMAIL) + "';");
335  } else {
336  addOnLoadedJavaScript("currentMail = null;");
337  }
338  Boolean internalSignIn = (Boolean) getSessionAttribute(IUser.INTERNAL_SIGNIN);
339  if(internalSignIn != null && internalSignIn) {
340  addOnLoadedJavaScript("internalSignIn = true;");
341  }
343  } else if(getUser() == null) {
345  return;
346  } else {
347  redirect("/");
348  return;
349  }
350  }
351  }
352  }
353  endBody();
354  closeOut();
355  }
356  }
357 
358  @Override
359  public void setStopper(String stopper) {
360  this.stopper = stopper;
361  }
362 
363  @Override
364  public boolean fileExists(String filePath) {
365  File file = new File(ElephantContext.getRealPath(filePath));
366  return file.exists();
367  }
368 
369  @Override
370  public void startBody() {
371  response.setContentType("text/html;charset=" + ElephantContext.getEncoding());
372  addCSS("https://fonts.googleapis.com/css?family=${site_fonts}");
373  MetaList confMetas = new MetaList(ElephantContext.getMetas());
374  confMetas.add("<meta http-equiv=\"content-type\" content=\"text/html; charset=" + ElephantContext.getEncoding() + "\">");
375  confMetas.addAll(metas);
376  if(getCurrentContext() != null) {
378  ElephantMarker marker = new ElephantMarker(this);
379  marker.put("lang", I_.api().used().getLanguage());
380  marker.put("title", HtmlContent.plain(getCurrentContext().getTitle() + " | " + ElephantContext.getSiteName(), 255));
381  marker.put("metas", confMetas);
382  marker.put("description", ElephantContext.getSiteDescription());
383  marker.put("keywords", ElephantContext.getSiteKeywords());
384  marker.put("icon", ElephantContext.getSiteIcon());
385  marker.put("headers", headers);
386  marker.put("isContext", isAContext);
387  marker.process("elephant", "startHtml");
388  }
389  }
390 
391  @Override
392  public void endBody() {
393  if(getCurrentContext() != null) {
394  ElephantMarker marker = new ElephantMarker(this);
395  marker.put("footers", footers);
396  marker.process("elephant", "endHtml");
397  }
398  }
399 
400  @Override
401  public void includeContent(String path) throws ServletException, IOException {
402  getOut();
403  if(path.matches(".*\\.(htm|html)")) {
404  includeFile(out, ElephantContext.getRealPath(path));
405  } else if(path.matches(".*\\.(txt)")) {
406  out.println("<pre>");
407  includeFile(out, ElephantContext.getRealPath(path));
408  out.println("</pre>");
409  } else {
410  ElephantContext.getCurrent().getRequestDispatcher(path).include(request, response);
411  }
412  }
413 
414  @Override
415  public void renderContext(String path, String stopper) throws ServletException, IOException {
416  ElContext ctx;
417  if((ctx = ElContextMap.getContext(path)) != null) {
418  ElContext tmpCtx = this.rendering;
419  String tmpStop = this.stopper;
420  setRenderingContext(ctx);
421  setStopper("true".equals(stopper) ? "<end/>" : null);
422  ctx.getElement().startConstruction();
423  setRenderingContext(tmpCtx);
424  setStopper(tmpStop);
425  }
426  }
427 
428  @Override
429  public void redirect(String path) throws IOException {
430  if(Strings.isBlank(path)) path = "/";
431  if(path.equals("*")) {
433  path = ctx != null ? ctx.getPath() : "/";
434  }
435  if(path.startsWith("http:") || path.startsWith("https:") || !path.startsWith("/") ||
436  (!Strings.isBlank(request.getContextPath()) && path.startsWith(request.getContextPath() + "/"))) {
437  response.sendRedirect(path);
438  } else {
439  response.sendRedirect(request.getContextPath() + path);
440  }
441  }
442 
443  @Override
444  public void navigateBack() throws IOException {
445  redirect(Strings.isBlank(History.back(this), "/"));
446  }
447 
448  @Override
449  public void reload() throws IOException {
450  ElContext elctx = getCurrentContext();
451  if(elctx != null) {
452  redirect(elctx.getPath());
453  }
454  }
455 
456  @Override
457  public PrintWriter getOut() throws IOException {
458  if(out == null && !nullOutput) {
459  out = response.getWriter();
460  if(response.getContentType() == null && pageRendering) {
461  startBody();
462  }
463  }
464  return out;
465  }
466 
467  @Override
468  public void setOut(PrintWriter out) {
469  this.out = out;
470  }
471 
472  @Override
473  public void closeOut() throws IOException {
474  if(out != null) out.close();
475  }
476 
477  @Override
478  public void setPageRendering(boolean value) {
479  pageRendering = value;
480  }
481 
482  @Override
483  public void setNullOutput(boolean value) {
484  nullOutput = value;
485  }
486 
487  @Override
488  public void setOutputToString() {
489  stringOutput = new StringWriter();
490  setOut(new PrintWriter(stringOutput));
491  }
492 
493  @Override
494  public String getOutputString() {
495  if(stringOutput != null) {
496  return stringOutput.toString();
497  }
498  return null;
499  }
500 
501  @Override
502  public void processOutput(String text) throws ServletException, IOException {
503  processOutput(out, text);
504  }
505 
506  @Override
507  public void processOutput(PrintWriter newOut, String text) throws ServletException, IOException {
508  Parser.processMacros(this, newOut, text);
509  }
510 
511  @Override
512  public String encodeURL(String url) {
513  try {
514  return URLEncoder.encode(url, "UTF-8");
515  } catch (UnsupportedEncodingException ex) {
516  Logger.getLogger(DefaultConstructor.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
517  }
518  return url;
519  }
520 
521  @Override
522  public String decodeURL(String url) {
523  try {
524  if(url != null) return URLDecoder.decode(new String(url.getBytes(ElephantContext.getEncoding()), "UTF-8"), "UTF-8");
525  } catch (UnsupportedEncodingException ex) {
526  Logger.getLogger(DefaultConstructor.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
527  }
528  return url;
529  }
530 
531  @Override
532  public String getParameter(String param) {
533  return getParameter(param, false);
534  }
535 
536  @Override
537  public String getParameter(String param, boolean decode) {
538  if(decode) {
539  return decodeURL(request.getParameter(param));
540  }
541  return request.getParameter(param);
542  }
543 
544  @Override
545  public String[] getParameterValues(String param) {
546  return request.getParameterValues(param);
547  }
548 
549  @Override
551  return Parameters.from(request.getParameterMap());
552  }
553 
554  @Override
555  public String getActionParameter() {
556  String value = getParameter("action");
557  if(value == null) {
558  String name;
559  Enumeration pn = getRequest().getParameterNames();
560  while(pn.hasMoreElements()) {
561  name = (String) pn.nextElement();
562  if(name.startsWith("action_") && getParameter(name) != null) {
563  value = name.substring(7);
564  break;
565  }
566  }
567  }
568  return value;
569  }
570 
571  @Override
572  public String getContextParameter() {
573  return getParameter("context");
574  }
575 
576  @Override
577  public String getIdelParameter() {
578  return getParameter("idel");
579  }
580 
581  private void includeFile(PrintWriter out, String file) throws IOException, ServletException {
582  if(FileUtil.existsFile(file)) {
583  try (BufferedReader br = FileUtil.getBufferedFile(file)) {
584  String str;
585  while((str = br.readLine()) != null) {
586  if(stopper != null && str.contains(stopper)) {
587  processOutput(out, str.substring(0, str.indexOf(stopper)) + "\n");
588  break;
589  }
590  processOutput(out, str + "\n");
591  }
592  }
593  }
594  }
595 
596  @Override
597  public String getValidUrl(String name) {
598  return name.replaceAll("[^a-zA-Z0-9\\.\\-\\/]", "_");
599  }
600 
601  @Override
602  public String getValidFileName(String name) {
603  return name.replaceAll("[^a-zA-Z0-9\\.\\-]", "_");
604  }
605 
606  @Override
608  return new Localizer(this);
609  }
610 
611  private String transformString(String string, int mode) {
612  if(string != null) {
613  if(mode == 0) {
614  return string;
615  } else if(mode == 1) {
616  return string.substring(0, 1).toUpperCase() + string.substring(1);
617  } else if(mode == 2) {
618  return string.toUpperCase();
619  } else if(mode == 3) {
620  return string.toLowerCase();
621  }
622  }
623  return string;
624  }
625 
626  @Override
627  public IContact getUser() {
629  }
630 
631  @Override
632  public boolean isOutsider() {
633  IContact user = getUser();
634  if(user != null && user.isValid()) {
635  return user.isOutsider();
636  }
637  return false;
638  }
639 
640  @Override
641  public String getUniqueId() {
642  return "cid_" + IdGenerator.generate() + uniqueSuffix++;
643  }
644 
645  @Override
646  public boolean isInRole(String role) {
647  if(("lang:_" + I_.api().used().getLanguage()).equals(role)) {
648  return true;
649  }
650  IUser user = getUser();
651  if(user != null) {
652  if("user:in".equals(role)) return true;
653  if(isWebAdminRole(role) && !isWebAdministering()) return false;
654  return user.isInRole(role);
655  } else {
656  return false;
657  }
658  }
659 
660  @Override
661  public boolean hasAnyRoleKey(String role) {
662  IUser user = getUser();
663  if(user != null) {
664  return user.hasAnyRoleKey(role);
665  } else {
666  return false;
667  }
668  }
669 
670  @Override
671  public void setLastReferringContext(String context) {
672  History.add(this, context);
673  //setSessionAttribute("xp_ref_ctx", context);
674  }
675 
676  @Override
677  public String getLastReferringContext() {
678  return Strings.isBlank(History.peek(this), "/");
679  }
680 
681  @Override
682  public void addHeader(String header) {
683  header = header.replaceAll("\\{webRoot\\}", ElephantContext.getRootWebPath());
684  headers.add(header);
685  }
686 
687  @Override
688  public void addCSS(String cssFile) {
689  if(cssFile.contains("${site_fonts}")) {
690  if(ElephantContext.getSiteFonts() != null) {
691  String fonts[] = ElephantContext.getSiteFonts().split(",");
692  for(String font : fonts) {
693  String result =
694  "<link rel=\"stylesheet\" type=\"text/css\" href=\"" +
695  urlToFile(cssFile.replaceFirst("\\$\\{site\\_fonts\\}", font)) +
696  "\">";
697  if(!headers.contains(result)) {
698  headers.add(result);
699  }
700  }
701  }
702  } else {
703  String result =
704  "<link rel=\"stylesheet\" type=\"text/css\" href=\"" +
705  urlToFile(cssFile) +
706  "\">";
707  if(!headers.contains(result)) {
708  headers.add(result);
709  }
710  }
711  }
712 
713  @Override
714  public void addJavaScript(String jsFile) {
715  String result =
716  "<script type=\"text/javascript\" src=\"" +
717  urlToFile(jsFile) +
718  "\"></script>";
719  if(!headers.contains(result)) {
720  headers.add(result);
721  }
722  }
723 
724  @Override
725  public void addMeta(String meta) {
726  metas.add(meta);
727  }
728 
729  public String urlToFile(String file) {
730  if(file.startsWith("http:") || file.startsWith("https:")) {
731  return file;
732  }
733  return ElephantContext.getRootWebPath() + file;
734  }
735 
736  @Override
737  public void addOnLoadedJavaScript(String script) {
738  if(!footers.contains(script)) {
739  footers.add(script);
740  }
741  }
742 
743  public void addRobots(ElContext context) {
744  boolean noIndex = context.getWebContext().isNoIndex(),
745  noFollow = context.getWebContext().isNoFollow();
746  String content = noIndex ? "NOINDEX" : "";
747  content = content + (content.length() > 0 && noFollow ? "," : "");
748  content = content + (noFollow ? "NOFOLLOW" : "");
749  content = (content.length() == 0 ? "ALL" : content);
750  String result = "<META NAME=\"ROBOTS\" CONTENT=\"" + content + "\">";
751  if(!headers.contains(result)) {
752  headers.add(result);
753  }
754  }
755 
756  @Override
757  public void invalidateSession() {
758  request.getSession().invalidate();
759  }
760 
761  @Override
762  public void setMaxInactiveInterval(int interval) {
763  HttpSession session = request.getSession();
764  if(session != null) {
765  session.setMaxInactiveInterval(interval);
766  }
767  }
768 
769  @Override
770  public void changeCssHeaders(String from, String to) {
771  int count = 0;
772  for(String s : (List<String>) headers) {
773  headers.set(count, s.replace(from, to));
774  count++;
775  }
776  }
777 
778  @Override
779  public boolean canWebAdminister() {
780  IUser user = getUser();
781  return user == null ? false :
782  (user.isInRole("context:list") ||
783  user.isInRole("default:edit"));
784  }
785 
786  @Override
787  public boolean isWebAdministering() {
788  return "true".equals(getSessionAttribute("xp_webAdministering"));
789  }
790 
791  @Override
792  public void setWebAdministering(boolean value) {
793  setSessionAttribute("xp_webAdministering", Boolean.toString(value));
794  }
795 
796  private boolean isWebAdminRole(String role) {
797  return role.startsWith("context") ||
798  role.startsWith("default") ||
799  role.startsWith("control-version") ||
800  role.startsWith("maillist");
801  }
802 
803  /* Template */
804 
805  private String templateRoot = null;
806 
807  @Override
808  public String getTemplateRoot() {
809  if(templateRoot == null) {
810  if(getCurrentContext() != null) {
811  templateRoot = getCurrentContext().getTemplateRoot();
812  } else {
813  templateRoot = ElephantContext.getTemplatesRoot();
814  }
815  }
816  return templateRoot;
817  }
818 
819  // i18n migration el_cons
820 
821  public Map getString() {
822  return I_.compatibilityMap();
823  }
824 
825 }
static boolean executeAction(IConstructor constructor)
Definition: Actions.java:70
static Parameters from(Map< String, String[]> parameterMap)
static String getSecret(String keys)
Definition: Secrets.java:37
static boolean loadResources(String path)
static void setAttribute(String key, Object value)
static void redirectToLogin(IConstructor constructor)
static String peek(IConstructor constructor)
Definition: History.java:42
static String back(IConstructor constructor)
Definition: History.java:46
static void add(IConstructor constructor, String path)
Definition: History.java:34
boolean addAll(Collection<? extends String > c)
Definition: MetaList.java:37
static Element getInclude(IConstructor constructor)
static IAction getAction(IConstructor constructor)
Map< String, Object > getSessionAttributeMap(String prefix)
void processOutput(PrintWriter newOut, String text)
String getParameter(String param, boolean decode)
static void setCookie(HttpServletResponse response, String name, String value, String path, int age)
Definition: CookieUtil.java:45
static boolean existsFile(String requestURI)
Definition: FileUtil.java:306
static BufferedReader getBufferedFile(String folder, String file)
Definition: FileUtil.java:146
static void processMacros(IConstructor constructor, PrintWriter out, String text)
Definition: Parser.java:200
static ElContext getContext(IConstructor constructor)
boolean equals(Object obj)
Definition: ElContext.java:621
void construct(IConstructor constructor)
Definition: ElContext.java:355
static I18nByKey byKeyMap()
Definition: I_.java:91
static I18nApiWrapper api()
Definition: I_.java:65
static I18nMapWrapper map()
Definition: I_.java:69
static I18nCompatibilityMap compatibilityMap()
Definition: I_.java:117
void process(String rootTmpl, String tmpl)
Object put(Object key, Object value)
static final String INTERNAL_SIGNIN
Definition: IUser.java:33
static final String CONNECTOR_EMAIL
Definition: IUser.java:27
boolean isInRole(String role)
String getProperty(String key)
static final String LOGGED_USER
Definition: IUser.java:32
boolean hasAnyRoleKey(String role)