BrightSide Workbench Full Report + Source Code
org.turro.elephant.impl.context.DefaultConstructor Class Reference
Inheritance diagram for org.turro.elephant.impl.context.DefaultConstructor:
Collaboration diagram for org.turro.elephant.impl.context.DefaultConstructor:

Public Member Functions

 DefaultConstructor ()
 
boolean isHeadless ()
 
void setRequest (ServletRequest request)
 
void setResponse (ServletResponse response)
 
HttpServletRequest getRequest ()
 
HttpServletResponse getResponse ()
 
ElContext getCurrentContext ()
 
ElContext getRenderingContext ()
 
void setRenderingContext (ElContext context)
 
void forceIsAContext (ElContext context)
 
boolean isOriginal ()
 
boolean isFileInternal (File file)
 
Object findAttribute (String key)
 
Object getApplicationAttribute (String key)
 
Object getSessionAttribute (String key)
 
Map< String, Object > getSessionAttributeMap (String prefix)
 
Object getRequestAttribute (String key)
 
void setApplicationAttribute (String key, Object value)
 
void setSessionAttribute (String key, Object value)
 
void setRequestAttribute (String key, Object value)
 
void removeApplicationAttribute (String key)
 
void removeSessionAttribute (String key)
 
void removeRequestAttribute (String key)
 
void startConstruction () throws IOException, ServletException
 
void setStopper (String stopper)
 
boolean fileExists (String filePath)
 
void startBody ()
 
void endBody ()
 
void includeContent (String path) throws ServletException, IOException
 
void renderContext (String path, String stopper) throws ServletException, IOException
 
void redirect (String path) throws IOException
 
void navigateBack () throws IOException
 
void reload () throws IOException
 
PrintWriter getOut () throws IOException
 
void setOut (PrintWriter out)
 
void closeOut () throws IOException
 
void setPageRendering (boolean value)
 
void setNullOutput (boolean value)
 
void setOutputToString ()
 
String getOutputString ()
 
void processOutput (String text) throws ServletException, IOException
 
void processOutput (PrintWriter newOut, String text) throws ServletException, IOException
 
String encodeURL (String url)
 
String decodeURL (String url)
 
String getParameter (String param)
 
String getParameter (String param, boolean decode)
 
String[] getParameterValues (String param)
 
Parameters getParameters ()
 
String getActionParameter ()
 
String getContextParameter ()
 
String getIdelParameter ()
 
String getValidUrl (String name)
 
String getValidFileName (String name)
 
Localizer getLocalizer ()
 
IContact getUser ()
 
boolean isOutsider ()
 
String getUniqueId ()
 
boolean isInRole (String role)
 
boolean hasAnyRoleKey (String role)
 
void setLastReferringContext (String context)
 
String getLastReferringContext ()
 
void addHeader (String header)
 
void addCSS (String cssFile)
 
void addJavaScript (String jsFile)
 
void addMeta (String meta)
 
String urlToFile (String file)
 
void addOnLoadedJavaScript (String script)
 
void addRobots (ElContext context)
 
void invalidateSession ()
 
void setMaxInactiveInterval (int interval)
 
void changeCssHeaders (String from, String to)
 
boolean canWebAdminister ()
 
boolean isWebAdministering ()
 
void setWebAdministering (boolean value)
 
String getTemplateRoot ()
 
Map getString ()
 

Protected Attributes

HttpServletRequest request
 
HttpServletResponse response
 
ElContext rendering = null
 
Properties bundle = null
 
PrintWriter out = null
 
StringWriter stringOutput = null
 
ArrayList metas = new ArrayList()
 
boolean isAContext = false
 
String stopper
 
boolean hasMootools = false
 

Static Protected Attributes

static final String BUNDLE_LOCATION = "/WEB-INF/classes/elephant.properties"
 

Additional Inherited Members

- Static Public Member Functions inherited from org.turro.elephant.context.IConstructor
static String currentRepository (IConstructor constructor)
 
static String globalRepository ()
 

Detailed Description

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

Definition at line 63 of file DefaultConstructor.java.

Constructor & Destructor Documentation

◆ DefaultConstructor()

org.turro.elephant.impl.context.DefaultConstructor.DefaultConstructor ( )

Creates a new instance of DefaultConstructor

Definition at line 81 of file DefaultConstructor.java.

81  {
82  ElContextMap.init();
83  }
Here is the call graph for this function:

Member Function Documentation

◆ addCSS()

void org.turro.elephant.impl.context.DefaultConstructor.addCSS ( String  cssFile)
Parameters
cssFileCSS file path.

Implements org.turro.elephant.context.IConstructor.

Definition at line 688 of file DefaultConstructor.java.

688  {
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  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ addHeader()

void org.turro.elephant.impl.context.DefaultConstructor.addHeader ( String  header)
Parameters
header

Implements org.turro.elephant.context.IConstructor.

Definition at line 682 of file DefaultConstructor.java.

682  {
683  header = header.replaceAll("\\{webRoot\\}", ElephantContext.getRootWebPath());
684  headers.add(header);
685  }
Here is the call graph for this function:

◆ addJavaScript()

void org.turro.elephant.impl.context.DefaultConstructor.addJavaScript ( String  jsFile)
Parameters
jsFileJavaScript file path.

Implements org.turro.elephant.context.IConstructor.

Definition at line 714 of file DefaultConstructor.java.

714  {
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  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ addMeta()

void org.turro.elephant.impl.context.DefaultConstructor.addMeta ( String  meta)
Parameters
metastring

Implements org.turro.elephant.context.IConstructor.

Definition at line 725 of file DefaultConstructor.java.

725  {
726  metas.add(meta);
727  }

◆ addOnLoadedJavaScript()

void org.turro.elephant.impl.context.DefaultConstructor.addOnLoadedJavaScript ( String  script)

Implements org.turro.elephant.context.IConstructor.

Definition at line 737 of file DefaultConstructor.java.

737  {
738  if(!footers.contains(script)) {
739  footers.add(script);
740  }
741  }
Here is the caller graph for this function:

◆ addRobots()

void org.turro.elephant.impl.context.DefaultConstructor.addRobots ( ElContext  context)

Definition at line 743 of file DefaultConstructor.java.

743  {
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  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ canWebAdminister()

boolean org.turro.elephant.impl.context.DefaultConstructor.canWebAdminister ( )

Implements org.turro.elephant.context.IConstructor.

Definition at line 779 of file DefaultConstructor.java.

779  {
780  IUser user = getUser();
781  return user == null ? false :
782  (user.isInRole("context:list") ||
783  user.isInRole("default:edit"));
784  }
Here is the call graph for this function:

◆ changeCssHeaders()

void org.turro.elephant.impl.context.DefaultConstructor.changeCssHeaders ( String  from,
String  to 
)

Implements org.turro.elephant.context.IConstructor.

Definition at line 770 of file DefaultConstructor.java.

770  {
771  int count = 0;
772  for(String s : (List<String>) headers) {
773  headers.set(count, s.replace(from, to));
774  count++;
775  }
776  }

◆ closeOut()

void org.turro.elephant.impl.context.DefaultConstructor.closeOut ( ) throws IOException

Implements org.turro.elephant.context.IConstructor.

Definition at line 473 of file DefaultConstructor.java.

473  {
474  if(out != null) out.close();
475  }
Here is the caller graph for this function:

◆ decodeURL()

String org.turro.elephant.impl.context.DefaultConstructor.decodeURL ( String  url)
Parameters
urlURL to be decoded.
Returns
The decoded URL.

Implements org.turro.elephant.context.IConstructor.

Definition at line 522 of file DefaultConstructor.java.

522  {
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  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ encodeURL()

String org.turro.elephant.impl.context.DefaultConstructor.encodeURL ( String  url)
Parameters
urlURL to be encoded.
Returns
The encoded URL.

Implements org.turro.elephant.context.IConstructor.

Definition at line 512 of file DefaultConstructor.java.

512  {
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  }
Here is the call graph for this function:

◆ endBody()

void org.turro.elephant.impl.context.DefaultConstructor.endBody ( )

Implements org.turro.elephant.context.IConstructor.

Definition at line 392 of file DefaultConstructor.java.

392  {
393  if(getCurrentContext() != null) {
394  ElephantMarker marker = new ElephantMarker(this);
395  marker.put("footers", footers);
396  marker.process("elephant", "endHtml");
397  }
398  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ fileExists()

boolean org.turro.elephant.impl.context.DefaultConstructor.fileExists ( String  filePath)

Check if file exists within web context

Parameters
filePathRelative path to file

Implements org.turro.elephant.context.IConstructor.

Definition at line 364 of file DefaultConstructor.java.

364  {
365  File file = new File(ElephantContext.getRealPath(filePath));
366  return file.exists();
367  }
Here is the call graph for this function:

◆ findAttribute()

Object org.turro.elephant.impl.context.DefaultConstructor.findAttribute ( String  key)

findAttribute looks sequentially in request, session and application scopes.

Parameters
keyAttribute to find.
Returns
Attribute's value or null.

Implements org.turro.elephant.context.IConstructor.

Definition at line 172 of file DefaultConstructor.java.

172  {
173  Object value = getRequestAttribute(key);
174  if(value == null) value = getSessionAttribute(key);
175  if(value == null) value = getApplicationAttribute(key);
176  return value;
177  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ forceIsAContext()

void org.turro.elephant.impl.context.DefaultConstructor.forceIsAContext ( ElContext  context)

Implements org.turro.elephant.context.IConstructor.

Definition at line 140 of file DefaultConstructor.java.

140  {
141  currentContext = context;
142  isAContext = true;
143  }

◆ getActionParameter()

String org.turro.elephant.impl.context.DefaultConstructor.getActionParameter ( )

Implements org.turro.elephant.context.IConstructor.

Definition at line 555 of file DefaultConstructor.java.

555  {
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  }
Here is the call graph for this function:

◆ getApplicationAttribute()

Object org.turro.elephant.impl.context.DefaultConstructor.getApplicationAttribute ( String  key)

Applications attributes live as long as container lives.

Parameters
keyAttribute to find.
Returns
Application attribute's value.

Implements org.turro.elephant.context.IConstructor.

Definition at line 180 of file DefaultConstructor.java.

180  {
181  return ElephantContext.getAttribute(key);
182  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getContextParameter()

String org.turro.elephant.impl.context.DefaultConstructor.getContextParameter ( )

Implements org.turro.elephant.context.IConstructor.

Definition at line 572 of file DefaultConstructor.java.

572  {
573  return getParameter("context");
574  }
Here is the call graph for this function:

◆ getCurrentContext()

ElContext org.turro.elephant.impl.context.DefaultConstructor.getCurrentContext ( )
Returns
Current IContext.

Implements org.turro.elephant.context.IConstructor.

Definition at line 122 of file DefaultConstructor.java.

122  {
123  if(currentContext == null)
124  currentContext = ElContextMap.getContext(this);
125  return currentContext;
126  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getIdelParameter()

String org.turro.elephant.impl.context.DefaultConstructor.getIdelParameter ( )

Implements org.turro.elephant.context.IConstructor.

Definition at line 577 of file DefaultConstructor.java.

577  {
578  return getParameter("idel");
579  }
Here is the call graph for this function:

◆ getLastReferringContext()

String org.turro.elephant.impl.context.DefaultConstructor.getLastReferringContext ( )

Administration pages will use this value to know which context was selected before they were called. Here we understand that a context was selected if constructor rendered.

Returns
Last constructed context.

Implements org.turro.elephant.context.IConstructor.

Definition at line 677 of file DefaultConstructor.java.

677  {
678  return Strings.isBlank(History.peek(this), "/");
679  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getLocalizer()

Localizer org.turro.elephant.impl.context.DefaultConstructor.getLocalizer ( )
Returns
A Localizer for current locale.
See also
org.turro.elephant.impl.util.Localizer

Implements org.turro.elephant.context.IConstructor.

Definition at line 607 of file DefaultConstructor.java.

607  {
608  return new Localizer(this);
609  }

◆ getOut()

PrintWriter org.turro.elephant.impl.context.DefaultConstructor.getOut ( ) throws IOException
Returns
Current PrintWriter in use.
Exceptions
java.io.IOException

Implements org.turro.elephant.context.IConstructor.

Definition at line 457 of file DefaultConstructor.java.

457  {
458  if(out == null && !nullOutput) {
459  out = response.getWriter();
460  if(response.getContentType() == null && pageRendering) {
461  startBody();
462  }
463  }
464  return out;
465  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getOutputString()

String org.turro.elephant.impl.context.DefaultConstructor.getOutputString ( )

Implements org.turro.elephant.context.IConstructor.

Definition at line 494 of file DefaultConstructor.java.

494  {
495  if(stringOutput != null) {
496  return stringOutput.toString();
497  }
498  return null;
499  }

◆ getParameter() [1/2]

String org.turro.elephant.impl.context.DefaultConstructor.getParameter ( String  param)

Implements org.turro.elephant.context.IConstructor.

Definition at line 532 of file DefaultConstructor.java.

532  {
533  return getParameter(param, false);
534  }
Here is the caller graph for this function:

◆ getParameter() [2/2]

String org.turro.elephant.impl.context.DefaultConstructor.getParameter ( String  param,
boolean  decode 
)

Implements org.turro.elephant.context.IConstructor.

Definition at line 537 of file DefaultConstructor.java.

537  {
538  if(decode) {
539  return decodeURL(request.getParameter(param));
540  }
541  return request.getParameter(param);
542  }
Here is the call graph for this function:

◆ getParameters()

Parameters org.turro.elephant.impl.context.DefaultConstructor.getParameters ( )

Implements org.turro.elephant.context.IConstructor.

Definition at line 550 of file DefaultConstructor.java.

550  {
551  return Parameters.from(request.getParameterMap());
552  }
Here is the call graph for this function:

◆ getParameterValues()

String [] org.turro.elephant.impl.context.DefaultConstructor.getParameterValues ( String  param)

Implements org.turro.elephant.context.IConstructor.

Definition at line 545 of file DefaultConstructor.java.

545  {
546  return request.getParameterValues(param);
547  }

◆ getRenderingContext()

ElContext org.turro.elephant.impl.context.DefaultConstructor.getRenderingContext ( )

Implements org.turro.elephant.context.IConstructor.

Definition at line 129 of file DefaultConstructor.java.

129  {
130  if(rendering == null) return getCurrentContext();
131  return rendering;
132  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getRequest()

HttpServletRequest org.turro.elephant.impl.context.DefaultConstructor.getRequest ( )
Returns
Current HttpServletRequest.

Implements org.turro.elephant.context.IConstructor.

Definition at line 112 of file DefaultConstructor.java.

112  {
113  return request;
114  }
Here is the caller graph for this function:

◆ getRequestAttribute()

Object org.turro.elephant.impl.context.DefaultConstructor.getRequestAttribute ( String  key)

Request attributes are visible through a single request. Once the request has given the response they are removed.

Parameters
keyAttribute to find
Returns
Request attribute's value.

Implements org.turro.elephant.context.IConstructor.

Definition at line 217 of file DefaultConstructor.java.

217  {
218  return request != null ? request.getAttribute(key) : null;
219  }
Here is the caller graph for this function:

◆ getResponse()

HttpServletResponse org.turro.elephant.impl.context.DefaultConstructor.getResponse ( )
Returns
Current HttpServletResponse.

Implements org.turro.elephant.context.IConstructor.

Definition at line 117 of file DefaultConstructor.java.

117  {
118  return response;
119  }

◆ getSessionAttribute()

Object org.turro.elephant.impl.context.DefaultConstructor.getSessionAttribute ( String  key)

Session attributes are stored in visitor sessions, meaning that their value will be available only by current visitor.

Parameters
keyAttribute to find
Returns
Session attribute's value.

Implements org.turro.elephant.context.IConstructor.

Definition at line 185 of file DefaultConstructor.java.

185  {
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  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getSessionAttributeMap()

Map<String, Object> org.turro.elephant.impl.context.DefaultConstructor.getSessionAttributeMap ( String  prefix)

Implements org.turro.elephant.context.IConstructor.

Definition at line 197 of file DefaultConstructor.java.

197  {
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  }
Here is the call graph for this function:

◆ getString()

Map org.turro.elephant.impl.context.DefaultConstructor.getString ( )

Definition at line 821 of file DefaultConstructor.java.

821  {
822  return I_.compatibilityMap();
823  }
Here is the call graph for this function:

◆ getTemplateRoot()

String org.turro.elephant.impl.context.DefaultConstructor.getTemplateRoot ( )

Implements org.turro.elephant.context.IConstructor.

Definition at line 808 of file DefaultConstructor.java.

808  {
809  if(templateRoot == null) {
810  if(getCurrentContext() != null) {
811  templateRoot = getCurrentContext().getTemplateRoot();
812  } else {
813  templateRoot = ElephantContext.getTemplatesRoot();
814  }
815  }
816  return templateRoot;
817  }
Here is the call graph for this function:

◆ getUniqueId()

String org.turro.elephant.impl.context.DefaultConstructor.getUniqueId ( )

Implements org.turro.elephant.context.IConstructor.

Definition at line 641 of file DefaultConstructor.java.

641  {
642  return "cid_" + IdGenerator.generate() + uniqueSuffix++;
643  }

◆ getUser()

IContact org.turro.elephant.impl.context.DefaultConstructor.getUser ( )
Returns
A validated IUser or null if no user was validated.

Implements org.turro.elephant.context.IConstructor.

Definition at line 627 of file DefaultConstructor.java.

627  {
628  return (IContact)findAttribute(IUser.LOGGED_USER);
629  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getValidFileName()

String org.turro.elephant.impl.context.DefaultConstructor.getValidFileName ( String  name)

Convenience method for ensuring file names will contain valid characters and no spaces.

Parameters
nameFile name.
Returns
A valid file name.

Implements org.turro.elephant.context.IConstructor.

Definition at line 602 of file DefaultConstructor.java.

602  {
603  return name.replaceAll("[^a-zA-Z0-9\\.\\-]", "_");
604  }

◆ getValidUrl()

String org.turro.elephant.impl.context.DefaultConstructor.getValidUrl ( String  name)

Convenience method for ensuring paths will contain valid characters and no spaces.

Parameters
nameURL to be converted.
Returns
A valid URL.

Implements org.turro.elephant.context.IConstructor.

Definition at line 597 of file DefaultConstructor.java.

597  {
598  return name.replaceAll("[^a-zA-Z0-9\\.\\-\\/]", "_");
599  }

◆ hasAnyRoleKey()

boolean org.turro.elephant.impl.context.DefaultConstructor.hasAnyRoleKey ( String  role)

Implements org.turro.elephant.context.IConstructor.

Definition at line 661 of file DefaultConstructor.java.

661  {
662  IUser user = getUser();
663  if(user != null) {
664  return user.hasAnyRoleKey(role);
665  } else {
666  return false;
667  }
668  }
Here is the call graph for this function:

◆ includeContent()

void org.turro.elephant.impl.context.DefaultConstructor.includeContent ( String  path) throws ServletException, IOException

This method should act differently depending on which file is to be included:

HTML files. Read file content, process macros and write to output stream. Text files. Read file context and write to output enclosed with PRE tags. Rest of files. Call ServletContext.getRequestDispatcher().

Parameters
pathRelative path to file.
Exceptions
javax.servlet.ServletException
java.io.IOException

Implements org.turro.elephant.context.IConstructor.

Definition at line 401 of file DefaultConstructor.java.

401  {
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  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ invalidateSession()

void org.turro.elephant.impl.context.DefaultConstructor.invalidateSession ( )

Implements org.turro.elephant.context.IConstructor.

Definition at line 757 of file DefaultConstructor.java.

757  {
758  request.getSession().invalidate();
759  }

◆ isFileInternal()

boolean org.turro.elephant.impl.context.DefaultConstructor.isFileInternal ( File  file)

This method intends to protect internal files. Since almost everything allocated within web application context will be visible by root context, asking whether a file is internal may prevent showing some folders.

Parameters
fileFile to query.
Returns
returns True if file is stored in internal folder structures.

Implements org.turro.elephant.context.IConstructor.

Definition at line 151 of file DefaultConstructor.java.

151  {
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  }
Here is the call graph for this function:

◆ isHeadless()

boolean org.turro.elephant.impl.context.DefaultConstructor.isHeadless ( )

Implements org.turro.elephant.context.IConstructor.

Definition at line 86 of file DefaultConstructor.java.

86  {
87  return request == null;
88  }

◆ isInRole()

boolean org.turro.elephant.impl.context.DefaultConstructor.isInRole ( String  role)

IConstructor implementations should return true when the role string gets validated against current user.

Parameters
roleRole string.
Returns
True if current validated user is in role.

Implements org.turro.elephant.context.IConstructor.

Definition at line 646 of file DefaultConstructor.java.

646  {
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  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isOriginal()

boolean org.turro.elephant.impl.context.DefaultConstructor.isOriginal ( )

Implements org.turro.elephant.context.IConstructor.

Definition at line 146 of file DefaultConstructor.java.

Here is the call graph for this function:

◆ isOutsider()

boolean org.turro.elephant.impl.context.DefaultConstructor.isOutsider ( )

Implements org.turro.elephant.context.IConstructor.

Definition at line 632 of file DefaultConstructor.java.

632  {
633  IContact user = getUser();
634  if(user != null && user.isValid()) {
635  return user.isOutsider();
636  }
637  return false;
638  }
Here is the call graph for this function:

◆ isWebAdministering()

boolean org.turro.elephant.impl.context.DefaultConstructor.isWebAdministering ( )

Implements org.turro.elephant.context.IConstructor.

Definition at line 787 of file DefaultConstructor.java.

787  {
788  return "true".equals(getSessionAttribute("xp_webAdministering"));
789  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ navigateBack()

void org.turro.elephant.impl.context.DefaultConstructor.navigateBack ( ) throws IOException

Implements org.turro.elephant.context.IConstructor.

Definition at line 444 of file DefaultConstructor.java.

444  {
445  redirect(Strings.isBlank(History.back(this), "/"));
446  }
Here is the call graph for this function:

◆ processOutput() [1/2]

void org.turro.elephant.impl.context.DefaultConstructor.processOutput ( PrintWriter  newOut,
String  text 
) throws ServletException, IOException

Implements org.turro.elephant.context.IConstructor.

Definition at line 507 of file DefaultConstructor.java.

507  {
508  Parser.processMacros(this, newOut, text);
509  }
Here is the call graph for this function:

◆ processOutput() [2/2]

void org.turro.elephant.impl.context.DefaultConstructor.processOutput ( String  text) throws ServletException, IOException

Implements org.turro.elephant.context.IConstructor.

Definition at line 502 of file DefaultConstructor.java.

502  {
503  processOutput(out, text);
504  }

◆ redirect()

void org.turro.elephant.impl.context.DefaultConstructor.redirect ( String  path) throws IOException

Convenience method for redirections within the same context. IConstructor implementations should ensure a call to redirect("/") will redirect to current web application's root.

Parameters
pathRelative path.
Exceptions
java.io.IOException

Implements org.turro.elephant.context.IConstructor.

Definition at line 429 of file DefaultConstructor.java.

429  {
430  if(Strings.isBlank(path)) path = "/";
431  if(path.equals("*")) {
432  ElContext ctx = ElContextMap.getCurrent();
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  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ reload()

void org.turro.elephant.impl.context.DefaultConstructor.reload ( ) throws IOException

Implements org.turro.elephant.context.IConstructor.

Definition at line 449 of file DefaultConstructor.java.

449  {
450  ElContext elctx = getCurrentContext();
451  if(elctx != null) {
452  redirect(elctx.getPath());
453  }
454  }
Here is the call graph for this function:

◆ removeApplicationAttribute()

void org.turro.elephant.impl.context.DefaultConstructor.removeApplicationAttribute ( String  key)

Removes application attribute.

Parameters
key

Implements org.turro.elephant.context.IConstructor.

Definition at line 245 of file DefaultConstructor.java.

245  {
246  ElephantContext.removeAttribute(key);
247  }
Here is the call graph for this function:

◆ removeRequestAttribute()

void org.turro.elephant.impl.context.DefaultConstructor.removeRequestAttribute ( String  key)

Removes request attribute.

Parameters
key

Implements org.turro.elephant.context.IConstructor.

Definition at line 259 of file DefaultConstructor.java.

259  {
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  }
Here is the call graph for this function:

◆ removeSessionAttribute()

void org.turro.elephant.impl.context.DefaultConstructor.removeSessionAttribute ( String  key)

Removes session attribute.

Parameters
key

Implements org.turro.elephant.context.IConstructor.

Definition at line 250 of file DefaultConstructor.java.

250  {
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  }
Here is the call graph for this function:

◆ renderContext()

void org.turro.elephant.impl.context.DefaultConstructor.renderContext ( String  path,
String  stopper 
) throws ServletException, IOException

This method includes context's default element content. Instead of calling page construction, as does includeContent, includeContext only renders context content.

Parameters
pathRelative path to file.
stopperString stopper, defaults to "<end/>"
Exceptions
javax.servlet.ServletException
java.io.IOException

Implements org.turro.elephant.context.IConstructor.

Definition at line 415 of file DefaultConstructor.java.

415  {
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  }
Here is the call graph for this function:

◆ setApplicationAttribute()

void org.turro.elephant.impl.context.DefaultConstructor.setApplicationAttribute ( String  key,
Object  value 
)

Sets application attribute's value.

Parameters
key
value

Implements org.turro.elephant.context.IConstructor.

Definition at line 222 of file DefaultConstructor.java.

222  {
223  ElephantContext.setAttribute(key, value);
224  }
Here is the call graph for this function:

◆ setLastReferringContext()

void org.turro.elephant.impl.context.DefaultConstructor.setLastReferringContext ( String  context)

IConstructor implementations should set this value when starting a context construction. Context value refers to IContext's path.

Parameters
contextLast constructed context.

Implements org.turro.elephant.context.IConstructor.

Definition at line 671 of file DefaultConstructor.java.

671  {
672  History.add(this, context);
673  //setSessionAttribute("xp_ref_ctx", context);
674  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setMaxInactiveInterval()

void org.turro.elephant.impl.context.DefaultConstructor.setMaxInactiveInterval ( int  interval)

Implements org.turro.elephant.context.IConstructor.

Definition at line 762 of file DefaultConstructor.java.

762  {
763  HttpSession session = request.getSession();
764  if(session != null) {
765  session.setMaxInactiveInterval(interval);
766  }
767  }

◆ setNullOutput()

void org.turro.elephant.impl.context.DefaultConstructor.setNullOutput ( boolean  value)

Implements org.turro.elephant.context.IConstructor.

Definition at line 483 of file DefaultConstructor.java.

483  {
484  nullOutput = value;
485  }

◆ setOut()

void org.turro.elephant.impl.context.DefaultConstructor.setOut ( PrintWriter  out)

Implements org.turro.elephant.context.IConstructor.

Definition at line 468 of file DefaultConstructor.java.

468  {
469  this.out = out;
470  }
Here is the caller graph for this function:

◆ setOutputToString()

void org.turro.elephant.impl.context.DefaultConstructor.setOutputToString ( )

Implements org.turro.elephant.context.IConstructor.

Definition at line 488 of file DefaultConstructor.java.

488  {
489  stringOutput = new StringWriter();
490  setOut(new PrintWriter(stringOutput));
491  }
Here is the call graph for this function:

◆ setPageRendering()

void org.turro.elephant.impl.context.DefaultConstructor.setPageRendering ( boolean  value)

Implements org.turro.elephant.context.IConstructor.

Definition at line 478 of file DefaultConstructor.java.

478  {
479  pageRendering = value;
480  }

◆ setRenderingContext()

void org.turro.elephant.impl.context.DefaultConstructor.setRenderingContext ( ElContext  context)

Implements org.turro.elephant.context.IConstructor.

Definition at line 135 of file DefaultConstructor.java.

135  {
136  rendering = context;
137  }
Here is the caller graph for this function:

◆ setRequest()

void org.turro.elephant.impl.context.DefaultConstructor.setRequest ( ServletRequest  request)

Called by ContextFactory during initialization.

Parameters
requestCurrent HttpServletRequest.

Implements org.turro.elephant.context.IConstructor.

Definition at line 91 of file DefaultConstructor.java.

91  {
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  }
Here is the call graph for this function:

◆ setRequestAttribute()

void org.turro.elephant.impl.context.DefaultConstructor.setRequestAttribute ( String  key,
Object  value 
)

Sets request attribute's value.

Parameters
key
value

Implements org.turro.elephant.context.IConstructor.

Definition at line 236 of file DefaultConstructor.java.

236  {
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  }
Here is the call graph for this function:

◆ setResponse()

void org.turro.elephant.impl.context.DefaultConstructor.setResponse ( ServletResponse  response)

Called by ContextFactory during initialization.

Parameters
responseCurrent HttpServletResponse.

Implements org.turro.elephant.context.IConstructor.

Definition at line 105 of file DefaultConstructor.java.

105  {
106  this.response = (HttpServletResponse)response;
107  if(this.response != null)
108  CookieUtil.setCookie((HttpServletResponse) response, "webroot", request.getContextPath(), "/", 30*24*60*60);
109  }
Here is the call graph for this function:

◆ setSessionAttribute()

void org.turro.elephant.impl.context.DefaultConstructor.setSessionAttribute ( String  key,
Object  value 
)

Sets session attribute's value.

Parameters
key
value

Implements org.turro.elephant.context.IConstructor.

Definition at line 227 of file DefaultConstructor.java.

227  {
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  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setStopper()

void org.turro.elephant.impl.context.DefaultConstructor.setStopper ( String  stopper)

Implements org.turro.elephant.context.IConstructor.

Definition at line 359 of file DefaultConstructor.java.

359  {
360  this.stopper = stopper;
361  }
Here is the caller graph for this function:

◆ setWebAdministering()

void org.turro.elephant.impl.context.DefaultConstructor.setWebAdministering ( boolean  value)

Implements org.turro.elephant.context.IConstructor.

Definition at line 792 of file DefaultConstructor.java.

792  {
793  setSessionAttribute("xp_webAdministering", Boolean.toString(value));
794  }
Here is the call graph for this function:

◆ startBody()

void org.turro.elephant.impl.context.DefaultConstructor.startBody ( )

Implements org.turro.elephant.context.IConstructor.

Definition at line 370 of file DefaultConstructor.java.

370  {
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  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ startConstruction()

void org.turro.elephant.impl.context.DefaultConstructor.startConstruction ( ) throws IOException, ServletException

Starts a page construction. First will locate which headers, including encoding, CSS, JavaScript, etc., are to be inserted. Then will collect all the elements configured to render in current context, instantiate ILayoutManager, ILayout and start rendering.

Exceptions
javax.servlet.ServletException
java.io.IOException

Implements org.turro.elephant.context.IConstructor.

Definition at line 268 of file DefaultConstructor.java.

268  {
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) {
319  ElephantLogin.redirectToLogin(this);
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) {
344  ElephantLogin.redirectToLogin(this);
345  return;
346  } else {
347  redirect("/");
348  return;
349  }
350  }
351  }
352  }
353  endBody();
354  closeOut();
355  }
356  }
void construct(IConstructor constructor)
Definition: ElContext.java:355
Here is the call graph for this function:

◆ urlToFile()

String org.turro.elephant.impl.context.DefaultConstructor.urlToFile ( String  file)

Definition at line 729 of file DefaultConstructor.java.

729  {
730  if(file.startsWith("http:") || file.startsWith("https:")) {
731  return file;
732  }
733  return ElephantContext.getRootWebPath() + file;
734  }
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ bundle

Properties org.turro.elephant.impl.context.DefaultConstructor.bundle = null
protected

Definition at line 70 of file DefaultConstructor.java.

◆ BUNDLE_LOCATION

final String org.turro.elephant.impl.context.DefaultConstructor.BUNDLE_LOCATION = "/WEB-INF/classes/elephant.properties"
staticprotected

Definition at line 66 of file DefaultConstructor.java.

◆ hasMootools

boolean org.turro.elephant.impl.context.DefaultConstructor.hasMootools = false
protected

Definition at line 76 of file DefaultConstructor.java.

◆ isAContext

boolean org.turro.elephant.impl.context.DefaultConstructor.isAContext = false
protected

Definition at line 74 of file DefaultConstructor.java.

◆ metas

ArrayList org.turro.elephant.impl.context.DefaultConstructor.metas = new ArrayList()
protected

Definition at line 73 of file DefaultConstructor.java.

◆ out

PrintWriter org.turro.elephant.impl.context.DefaultConstructor.out = null
protected

Definition at line 71 of file DefaultConstructor.java.

◆ rendering

ElContext org.turro.elephant.impl.context.DefaultConstructor.rendering = null
protected

Definition at line 69 of file DefaultConstructor.java.

◆ request

HttpServletRequest org.turro.elephant.impl.context.DefaultConstructor.request
protected

Definition at line 67 of file DefaultConstructor.java.

◆ response

HttpServletResponse org.turro.elephant.impl.context.DefaultConstructor.response
protected

Definition at line 68 of file DefaultConstructor.java.

◆ stopper

String org.turro.elephant.impl.context.DefaultConstructor.stopper
protected

Definition at line 75 of file DefaultConstructor.java.

◆ stringOutput

StringWriter org.turro.elephant.impl.context.DefaultConstructor.stringOutput = null
protected

Definition at line 72 of file DefaultConstructor.java.


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