BrightSide Workbench Full Report + Source Code
org.turro.elephant.web.ElContext Class Reference
Inheritance diagram for org.turro.elephant.web.ElContext:
Collaboration diagram for org.turro.elephant.web.ElContext:

Public Member Functions

 ElContext ()
 
String getId ()
 
String getName ()
 
String getFullPath ()
 
String getWebPath ()
 
String getPath ()
 
boolean inPath (ElContext context)
 
int getLevel ()
 
File getFile ()
 
String getVerbosePath ()
 
String getVerbosePath (ElContext root)
 
String getTarget ()
 
boolean isPublic ()
 
boolean canShowTo (IContact contact)
 
boolean canDisplay ()
 
boolean hasRestrictions ()
 
boolean isSelectable ()
 
boolean isInRole ()
 
boolean canPrint ()
 
ElContext getParent ()
 
boolean isIndexable ()
 
boolean isFollowable ()
 
TreeSet< ElContextgetChildren ()
 
TreeSet< ElContextgetStaticChildren ()
 
TreeSet< ElContextgetVisibleChildren ()
 
TreeSet< ElContextgetSiblings ()
 
TreeSet< ElContextgetVisibleSiblings ()
 
TreeSet< ElContextgetAncestors ()
 
ElContext getPrevious ()
 
ElContext getNext (boolean doChildren)
 
IContext getContext ()
 
String getRepositoryPath ()
 
Repository getRepository ()
 
WebResources getResources ()
 
Set< String > getDefaultLocales ()
 
WebContext getWebContext ()
 
void construct (IConstructor constructor) throws ServletException, IOException
 
void setTitle (String title)
 
String getTitle ()
 
IElement getElement ()
 
void generateCategoriesChildren (Tree tree, Function< Item, String > onParam)
 
SocialImage getSocialImage ()
 
String getTemplateRoot ()
 
String getTemplate ()
 
FoundList search (String value, boolean ignoreCase)
 
void resetDefaultLocales ()
 
int compareTo (ElContext o)
 
int hashCode ()
 
boolean equals (Object obj)
 

Static Public Member Functions

static boolean isInternal (File file)
 
static String extractPath (String path)
 

Static Public Attributes

static final String CONTEXT_FOLDER = "/_internal"
 

Protected Member Functions

 ElContext (String path, File folder, ElContext parent)
 
 ElContext (String path, String params, File folder, ElContext parent)
 
final void init ()
 

Protected Attributes

File folder
 
String title
 
int level
 
Set< String > defaultLocales
 
ElContext parent
 
TreeSet< ElContextchildren
 
WebContext webContext
 

Detailed Description

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

Definition at line 61 of file ElContext.java.

Constructor & Destructor Documentation

◆ ElContext() [1/3]

org.turro.elephant.web.ElContext.ElContext ( )

Definition at line 77 of file ElContext.java.

77  {
78  this("", null, new File(ElephantContext.getRealPath("/")), null);
79  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ElContext() [2/3]

org.turro.elephant.web.ElContext.ElContext ( String  path,
File  folder,
ElContext  parent 
)
protected

Definition at line 81 of file ElContext.java.

81  {
82  this(path, null, folder, parent);
83  }

◆ ElContext() [3/3]

org.turro.elephant.web.ElContext.ElContext ( String  path,
String  params,
File  folder,
ElContext  parent 
)
protected

Definition at line 85 of file ElContext.java.

85  {
86  this.path = path;
87  this.params = params;
88  this.folder = folder;
89  this.parent = parent;
90  init();
91  }
Here is the call graph for this function:

Member Function Documentation

◆ canDisplay()

boolean org.turro.elephant.web.ElContext.canDisplay ( )

Definition at line 161 of file ElContext.java.

Here is the call graph for this function:

◆ canPrint()

boolean org.turro.elephant.web.ElContext.canPrint ( )

Definition at line 179 of file ElContext.java.

179  {
180  return (webContext.isPrintContext() && isInRole());
181  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ canShowTo()

boolean org.turro.elephant.web.ElContext.canShowTo ( IContact  contact)

Definition at line 156 of file ElContext.java.

156  {
157  if(isPublic()) return true;
158  return contact.getPermissions().isInRole(webContext.getRole());
159  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ compareTo()

int org.turro.elephant.web.ElContext.compareTo ( ElContext  o)

Definition at line 593 of file ElContext.java.

593  {
594  int result = 0;
595  result = CompareUtil.compare(level, o.level);
596  if(result == 0) {
597  result = CompareUtil.compare(webContext.getOrder(), o.webContext.getOrder());
598  }
599  if(result == 0) {
600  result = CompareUtil.compare(getName(), o.getName());
601  }
602  if(result == 0) {
603  result = CompareUtil.compare(getId(), o.getId());
604  }
605  if(result == 0) {
606  result = CompareUtil.compare(path, o.path);
607  }
608  return result;
609  }
Here is the call graph for this function:

◆ construct()

void org.turro.elephant.web.ElContext.construct ( IConstructor  constructor) throws ServletException, IOException

Definition at line 355 of file ElContext.java.

355  {
356  new ContextConstructor(constructor, this).start();
357  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ equals()

boolean org.turro.elephant.web.ElContext.equals ( Object  obj)

Definition at line 621 of file ElContext.java.

621  {
622  if (this == obj) {
623  return true;
624  }
625  if (obj == null) {
626  return false;
627  }
628  if (getClass() != obj.getClass()) {
629  return false;
630  }
631  final ElContext other = (ElContext) obj;
632  if (!Objects.equals(this.path, other.path)) {
633  return false;
634  }
635  return true;
636  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ extractPath()

static String org.turro.elephant.web.ElContext.extractPath ( String  path)
static

Definition at line 574 of file ElContext.java.

574  {
575  if(path == null) {
576  path = "/";
577  } else {
578  int p = path.indexOf("?");
579  if(p > -1) {
580  path = path.substring(0, p);
581  }
582  }
583  return path;
584  }
Here is the caller graph for this function:

◆ generateCategoriesChildren()

void org.turro.elephant.web.ElContext.generateCategoriesChildren ( Tree  tree,
Function< Item, String >  onParam 
)

Definition at line 491 of file ElContext.java.

491  {
492  for(Item item : (List<Item>) tree.getItems()) {
493  addCategoriesChildren(getPath(), item, onParam);
494  }
495  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getAncestors()

TreeSet<ElContext> org.turro.elephant.web.ElContext.getAncestors ( )

Definition at line 235 of file ElContext.java.

235  {
236  TreeSet<ElContext> ancestors = new TreeSet<>();
237  ElContext ctx = this;
238  while(ctx != null) {
239  ancestors.add(ctx);
240  ctx = ctx.parent;
241  }
242  return ancestors;
243  }
Here is the caller graph for this function:

◆ getChildren()

TreeSet<ElContext> org.turro.elephant.web.ElContext.getChildren ( )

Definition at line 196 of file ElContext.java.

196  {
197  generateDynamic();
198  return children;
199  }
TreeSet< ElContext > children
Definition: ElContext.java:73
Here is the caller graph for this function:

◆ getContext()

IContext org.turro.elephant.web.ElContext.getContext ( )

Definition at line 280 of file ElContext.java.

280  {
281  return ContextFactory.getContext(Application.getApplication().getConstructor(), path);
282  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getDefaultLocales()

Set<String> org.turro.elephant.web.ElContext.getDefaultLocales ( )

Definition at line 318 of file ElContext.java.

318  {
319  if(defaultLocales == null) {
320  ElContext ctx = this;
321  while(ctx != null && ctx.webContext.getLangs().isEmpty()) {
322  ctx = ctx.parent;
323  }
324  defaultLocales = ctx.webContext.getLangs();
325  }
326  return defaultLocales;
327  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getElement()

IElement org.turro.elephant.web.ElContext.getElement ( )

Definition at line 447 of file ElContext.java.

447  {
448  IElement iel = webContext.getElementInstance();
449  iel.setConfiguration(Application.getApplication().getConstructor(), this);
450  return iel;
451  }
void setConfiguration(IConstructor constructor, ElContext context)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getFile()

File org.turro.elephant.web.ElContext.getFile ( )

Definition at line 130 of file ElContext.java.

130  {
131  return folder;
132  }
Here is the caller graph for this function:

◆ getFullPath()

String org.turro.elephant.web.ElContext.getFullPath ( )

Definition at line 101 of file ElContext.java.

101  {
102  String tmp = ElephantContext.getRootWebPath() + path;
103  return (Strings.isBlank(tmp) ? "/" : tmp + (Strings.isBlank(params) ? "" : params));
104  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getId()

String org.turro.elephant.web.ElContext.getId ( )

Definition at line 93 of file ElContext.java.

93  {
94  return folder.getName();
95  }
Here is the caller graph for this function:

◆ getLevel()

int org.turro.elephant.web.ElContext.getLevel ( )

Definition at line 126 of file ElContext.java.

126  {
127  return path == null ? 0 : path.split("\\/").length - 1;
128  }
Here is the caller graph for this function:

◆ getName()

String org.turro.elephant.web.ElContext.getName ( )

Definition at line 97 of file ElContext.java.

97  {
98  return Optional.ofNullable(webContext.getName()).orElse(getId());
99  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getNext()

ElContext org.turro.elephant.web.ElContext.getNext ( boolean  doChildren)

Definition at line 265 of file ElContext.java.

265  {
266  if(doChildren) {
267  TreeSet<ElContext> set = getVisibleChildren();
268  if(!set.isEmpty()) return set.first();
269  }
270  if(getParent() != null) {
271  boolean found = false;
272  for (ElContext sibling : getVisibleSiblings()) {
273  if(found && sibling.canDisplay()) return sibling;
274  if(sibling.equals(this)) found = true;
275  }
276  }
277  return parent.getNext(false);
278  }
TreeSet< ElContext > getVisibleSiblings()
Definition: ElContext.java:227
ElContext getNext(boolean doChildren)
Definition: ElContext.java:265
TreeSet< ElContext > getVisibleChildren()
Definition: ElContext.java:209
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getParent()

ElContext org.turro.elephant.web.ElContext.getParent ( )

Definition at line 183 of file ElContext.java.

183  {
184  return parent;
185  }
Here is the caller graph for this function:

◆ getPath()

String org.turro.elephant.web.ElContext.getPath ( )

Definition at line 118 of file ElContext.java.

118  {
119  return path;
120  }
Here is the caller graph for this function:

◆ getPrevious()

ElContext org.turro.elephant.web.ElContext.getPrevious ( )

Definition at line 245 of file ElContext.java.

245  {
246  if(getParent() != null) {
247  boolean found = false;
248  for (ElContext sibling : getVisibleSiblings().descendingSet()) {
249  if(found && sibling.canDisplay()) return getLastChildren(sibling);
250  if(sibling.equals(this)) found = true;
251  }
252  return getParent();
253  }
254  return null;
255  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getRepository()

Repository org.turro.elephant.web.ElContext.getRepository ( )

Definition at line 288 of file ElContext.java.

288  {
289  return new Repository(Application.getApplication().getConstructor(), WebContext.repository(Path.of(path)).toString());
290  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getRepositoryPath()

String org.turro.elephant.web.ElContext.getRepositoryPath ( )

Definition at line 284 of file ElContext.java.

284  {
285  return WebContext.repository(Path.of(path)).toString();
286  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getResources()

WebResources org.turro.elephant.web.ElContext.getResources ( )

Definition at line 292 of file ElContext.java.

292  {
293  return folder != null ? new WebResources(folder.toPath()) : null;
294  }
Here is the caller graph for this function:

◆ getSiblings()

TreeSet<ElContext> org.turro.elephant.web.ElContext.getSiblings ( )

Definition at line 217 of file ElContext.java.

217  {
218  if(parent == null) {
219  TreeSet<ElContext> set = new TreeSet<>();
220  set.add(this);
221  return set;
222  } else {
223  return parent.getChildren();
224  }
225  }
TreeSet< ElContext > getChildren()
Definition: ElContext.java:196
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getSocialImage()

SocialImage org.turro.elephant.web.ElContext.getSocialImage ( )

Definition at line 519 of file ElContext.java.

519  {
520  return SocialImageMap.getImage(getFullPath());
521  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getStaticChildren()

TreeSet<ElContext> org.turro.elephant.web.ElContext.getStaticChildren ( )

Definition at line 201 of file ElContext.java.

201  {
202  TreeSet<ElContext> statics = new TreeSet<>();
203  for(ElContext ctx : children) {
204  if(!ctx.getWebContext().isDynamic()) statics.add(ctx);
205  }
206  return statics;
207  }
Here is the caller graph for this function:

◆ getTarget()

String org.turro.elephant.web.ElContext.getTarget ( )

Definition at line 148 of file ElContext.java.

148  {
149  return webContext.getTarget();
150  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getTemplate()

String org.turro.elephant.web.ElContext.getTemplate ( )

Definition at line 537 of file ElContext.java.

537  {
538  if(!Strings.isBlank(webContext.getLayout().getLocal())) {
539  return webContext.getLayout().getLocal();
540  }
541  return findTemplate(this);
542  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getTemplateRoot()

String org.turro.elephant.web.ElContext.getTemplateRoot ( )

Definition at line 525 of file ElContext.java.

525  {
526  return findRoot(this);
527  }
Here is the caller graph for this function:

◆ getTitle()

String org.turro.elephant.web.ElContext.getTitle ( )

Definition at line 363 of file ElContext.java.

363  {
364  return Strings.isBlank(title) ? getName() : title;
365  }
Here is the call graph for this function:

◆ getVerbosePath() [1/2]

String org.turro.elephant.web.ElContext.getVerbosePath ( )

Definition at line 134 of file ElContext.java.

134  {
135  return getVerbosePath(null);
136  }

◆ getVerbosePath() [2/2]

String org.turro.elephant.web.ElContext.getVerbosePath ( ElContext  root)

Definition at line 138 of file ElContext.java.

138  {
139  String result = getName();
140  ElContext ctx = parent;
141  while(ctx != null && !ctx.equals(root)) {
142  result = ctx.getName() + " " + result;
143  ctx = ctx.parent;
144  }
145  return result;
146  }
Here is the call graph for this function:

◆ getVisibleChildren()

TreeSet<ElContext> org.turro.elephant.web.ElContext.getVisibleChildren ( )

Definition at line 209 of file ElContext.java.

209  {
210  TreeSet<ElContext> visible = new TreeSet<>();
211  for(ElContext ctx : children) {
212  if(ctx.canDisplay()) visible.add(ctx);
213  }
214  return visible;
215  }
Here is the caller graph for this function:

◆ getVisibleSiblings()

TreeSet<ElContext> org.turro.elephant.web.ElContext.getVisibleSiblings ( )

Definition at line 227 of file ElContext.java.

227  {
228  TreeSet<ElContext> visible = new TreeSet<>();
229  for(ElContext ctx : getSiblings()) {
230  if(ctx.canDisplay()) visible.add(ctx);
231  }
232  return visible;
233  }
TreeSet< ElContext > getSiblings()
Definition: ElContext.java:217
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getWebContext()

WebContext org.turro.elephant.web.ElContext.getWebContext ( )

Definition at line 329 of file ElContext.java.

329  {
330  return webContext;
331  }
Here is the caller graph for this function:

◆ getWebPath()

String org.turro.elephant.web.ElContext.getWebPath ( )

Definition at line 106 of file ElContext.java.

106  {
107  if(Strings.isBlank(webContext.getRedirect())) {
108  return getFullPath();
109  } else if(webContext.getRedirect().startsWith("/")) {
110  return ElephantContext.getRootWebPath() + webContext.getRedirect();
111  } else if(webContext.getRedirect().contains("://")) {
112  return webContext.getRedirect();
113  } else {
114  return getFullPath() + "/" + webContext.getRedirect();
115  }
116  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ hashCode()

int org.turro.elephant.web.ElContext.hashCode ( )

Definition at line 614 of file ElContext.java.

614  {
615  int hash = 7;
616  hash = 89 * hash + Objects.hashCode(this.path);
617  return hash;
618  }

◆ hasRestrictions()

boolean org.turro.elephant.web.ElContext.hasRestrictions ( )

Definition at line 165 of file ElContext.java.

165  {
166  return !(webContext.isShowInNavigators() && (webContext.isShowAlways() || Strings.isEmpty(webContext.getRole())));
167  }
Here is the call graph for this function:

◆ init()

final void org.turro.elephant.web.ElContext.init ( )
protected

Definition at line 296 of file ElContext.java.

296  {
297  readConfiguration();
298  level = path == null ? 0 : path.split("\\/").length - 1;
299  ElContextMap.addContext(this);
300  if(children == null) {
301  children = new TreeSet<>();
302  if(folder.isDirectory()) {
303  File[] subfolders = folder.listFiles();
304  for(File subfolder: subfolders) {
305  if(subfolder.isDirectory() && !subfolder.isHidden()) {
306  if(!isInternal(subfolder)) {
307  if(Files.exists(path + "/" + subfolder.getName() + CONTEXT_FILE) ||
308  WebContext.existsConf(Path.of(path))) {
309  children.add(new ElContext(path + "/" + subfolder.getName(), subfolder, this));
310  }
311  }
312  }
313  }
314  }
315  }
316  }
static boolean isInternal(File file)
Definition: ElContext.java:333
Here is the call graph for this function:
Here is the caller graph for this function:

◆ inPath()

boolean org.turro.elephant.web.ElContext.inPath ( ElContext  context)

Definition at line 122 of file ElContext.java.

122  {
123  return context.getFullPath().matches(getFullPath() + "(\\/.*)?");
124  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isFollowable()

boolean org.turro.elephant.web.ElContext.isFollowable ( )

Definition at line 192 of file ElContext.java.

192  {
193  return !webContext.isNoFollow();
194  }
Here is the call graph for this function:

◆ isIndexable()

boolean org.turro.elephant.web.ElContext.isIndexable ( )

Definition at line 187 of file ElContext.java.

187  {
188  return !webContext.isNoIndex() && Strings.isBlank(webContext.getRedirect()) &&
189  !getPath().startsWith("/user");
190  }
Here is the call graph for this function:

◆ isInRole()

boolean org.turro.elephant.web.ElContext.isInRole ( )

Definition at line 173 of file ElContext.java.

173  {
174  if(parent != null && !parent.isInRole()) return false;
175  if(Strings.isBlank(webContext.getRole())) return true;
176  return UserMenus.isInRole(path) && Application.getApplication().isInRole(webContext.getRole());
177  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isInternal()

static boolean org.turro.elephant.web.ElContext.isInternal ( File  file)
static

Definition at line 333 of file ElContext.java.

333  {
334  if(file == null) return true;
335  String fileName = file.isFile() ? file.getName() : file.getAbsolutePath();
336  String internals = ElephantContext.getSiteInternalFiles();
337  if(internals != null) {
338  String tmp[] = internals.split(",");
339  for(String s : tmp) {
340  if(fileName.matches(Strings.convertToRegEx(s))) return true;
341  }
342  }
343  return (fileName.matches("google.*\\.html")) ||
344  (fileName.matches("site.*\\.xml")) ||
345  (fileName.matches("robots\\.txt")) ||
346  (fileName.contains("_internal")) ||
347  (fileName.contains("_zul")) ||
348  (fileName.contains("resources")) ||
349  (fileName.contains("WEB-INF")) ||
350  (fileName.contains("META-INF"));
351  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isPublic()

boolean org.turro.elephant.web.ElContext.isPublic ( )

Definition at line 152 of file ElContext.java.

152  {
153  return Strings.isBlank(webContext.getRole());
154  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isSelectable()

boolean org.turro.elephant.web.ElContext.isSelectable ( )

Definition at line 169 of file ElContext.java.

169  {
171  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ resetDefaultLocales()

void org.turro.elephant.web.ElContext.resetDefaultLocales ( )

Definition at line 586 of file ElContext.java.

586  {
587  defaultLocales = null;
588  }
Here is the caller graph for this function:

◆ search()

FoundList org.turro.elephant.web.ElContext.search ( String  value,
boolean  ignoreCase 
)

Definition at line 554 of file ElContext.java.

554  {
555  FoundList fl = new FoundList();
556  SearchFormatter sf = new SearchFormatter(value, ignoreCase);
557  sf.processLine(getName());
558  if(sf.wasFound()) {
559  fl.addItem(
560  getId() == null ? "" : getId(),
561  (getPath().length() == 0 ? "/" : getPath()),
562  "<img src='" + ElephantContext.getRootResourcePath() + "/_internal/system/images/context.gif'/>",
563  getName(),
564  sf.getResult(),
565  (double)sf.getFound(),
566  value
567  );
568  }
569  return fl;
570  }
Here is the call graph for this function:

◆ setTitle()

void org.turro.elephant.web.ElContext.setTitle ( String  title)

Definition at line 359 of file ElContext.java.

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

Member Data Documentation

◆ children

TreeSet<ElContext> org.turro.elephant.web.ElContext.children
protected

Definition at line 73 of file ElContext.java.

◆ CONTEXT_FOLDER

final String org.turro.elephant.web.ElContext.CONTEXT_FOLDER = "/_internal"
static

Definition at line 64 of file ElContext.java.

◆ defaultLocales

Set<String> org.turro.elephant.web.ElContext.defaultLocales
protected

Definition at line 71 of file ElContext.java.

◆ folder

File org.turro.elephant.web.ElContext.folder
protected

Definition at line 68 of file ElContext.java.

◆ level

int org.turro.elephant.web.ElContext.level
protected

Definition at line 70 of file ElContext.java.

◆ parent

ElContext org.turro.elephant.web.ElContext.parent
protected

Definition at line 72 of file ElContext.java.

◆ title

String org.turro.elephant.web.ElContext.title
protected

Definition at line 69 of file ElContext.java.

◆ webContext

WebContext org.turro.elephant.web.ElContext.webContext
protected

Definition at line 75 of file ElContext.java.


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