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

Public Member Functions

 DefaultContext ()
 
boolean equals (Object obj)
 
int hashCode ()
 
String getId ()
 
String getType ()
 
IContext getContext ()
 
String getName ()
 
String getName (String lang)
 
String getExactName (String lang)
 
void setName (String lang, String newName)
 
String getTitle ()
 
String getIcon ()
 
void setIcon (String icon)
 
String getRedirection ()
 
String getTarget ()
 
IElement getDefaultElement ()
 
IElement getDefaultElement (String type)
 
Set< String > getDefaultLocales ()
 
void setConstructor (IConstructor constructor, String path)
 
String getFullPath ()
 
String getWebPath ()
 
String getPath ()
 
int getLevel ()
 
File getFile ()
 
void startConstruction () throws ServletException, IOException
 
IContext getParent ()
 
IContext[] getAncestors ()
 
IContext[] getChildren ()
 
IContext[] getSiblings ()
 
String[] getBaseNames ()
 
String[] getLocaleResources (String preferredLocale)
 
IConstructor getConstructor ()
 
String getTypeName ()
 
AttributeSupport getAttributes ()
 
void applyChanges ()
 
void populateFromParent ()
 
String[] getLocaleSufixes (String preferredLocale)
 
Repository getRepository ()
 
boolean inPath (IContext context)
 
int compareTo (Object o)
 
boolean canDisplay ()
 
boolean isSelectable ()
 
boolean isInRole ()
 
boolean canPrint ()
 
FoundList search (String value, boolean ignoreCase)
 

Static Public Member Functions

static String locateRealContext (IConstructor constructor, String path)
 
static String extractPath (String path)
 

Static Public Attributes

static final String CONTEXT_FILE = "/_internal/context.xml"
 

Protected Attributes

IConstructor constructor
 
String path
 
File file
 
IElement usedElement = null
 
Element conf
 
IContext[] children
 
IContext parent
 
String[] defaultLocales
 
AttributeSupport attrSupport
 

Detailed Description

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

Definition at line 60 of file DefaultContext.java.

Constructor & Destructor Documentation

◆ DefaultContext()

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

Creates a new instance of DefaultContext

Definition at line 77 of file DefaultContext.java.

77  {
78  attrSupport = new AttributeSupport();
79  }
Here is the caller graph for this function:

Member Function Documentation

◆ applyChanges()

void org.turro.elephant.impl.context.DefaultContext.applyChanges ( )

Implements org.turro.elephant.layout.IManageable.

Definition at line 606 of file DefaultContext.java.

606  {
607  List attrs = conf.getAttributes();
608  Iterator it = attrs.iterator();
609  Attribute a;
610  while(it.hasNext()) {
611  a = (Attribute) it.next();
612  if(attrSupport.getAttribute(a.getName()) == null) {
613  it.remove();
614  }
615  }
616  it = attrSupport.keySet().iterator();
617  AttributeItem ai;
618  while(it.hasNext()) {
619  ai = (AttributeItem) attrSupport.getAttribute((String) it.next());
620  if(ai.getValue() != null) {
621  conf.setAttribute(ai.name, ai.getValue());
622  }
623  }
624  saveConfiguration();
625  WebContext.removeFrom(Path.of(path));
626  ElContextMap.reset();
627  }
Here is the call graph for this function:

◆ canDisplay()

boolean org.turro.elephant.impl.context.DefaultContext.canDisplay ( )

This method is queried within startConstruction().

Returns
True is element can display.

Implements org.turro.elephant.security.IDefendable.

Definition at line 763 of file DefaultContext.java.

763  {
764  boolean showAlways = attrSupport.getAttributeBooleanValue("showAlways", false);
765  return isSelectable() && (showAlways || isInRole());
766  }
boolean getAttributeBooleanValue(String name, boolean defaultValue)
Here is the call graph for this function:

◆ canPrint()

boolean org.turro.elephant.impl.context.DefaultContext.canPrint ( )

This method is queried when a print version is being called.

Returns
True is element can print.

Implements org.turro.elephant.security.IDefendable.

Definition at line 784 of file DefaultContext.java.

784  {
785  boolean canPrint = attrSupport.getAttributeBooleanValue("printContext", true);
786  return (canPrint && isInRole());
787  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ compareTo()

int org.turro.elephant.impl.context.DefaultContext.compareTo ( Object  o)

Definition at line 744 of file DefaultContext.java.

744  {
746  int result = 0;
747 // if(conf != null && dc.conf != null) {
748 // result = CompareUtil.compare(getAttributes().getAttributeValue("order", ""),
749 // dc.getAttributes().getAttributeValue("order", ""));
750 //
751 // }
752  result = CompareUtil.compare(getOrder(), dc.getOrder());
753  if(result == 0) {
754  result = CompareUtil.compare(getName(), dc.getName());
755  }
756  if(result == 0) {
757  result = CompareUtil.compare(getId(), dc.getId());
758  }
759  return result;
760  }
Here is the call graph for this function:

◆ equals()

boolean org.turro.elephant.impl.context.DefaultContext.equals ( Object  obj)

Definition at line 82 of file DefaultContext.java.

82  {
83  return (
84  (obj instanceof IContext) &&
85  ((IContext)obj).getFullPath().equals(getFullPath())
86  );
87  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ extractPath()

static String org.turro.elephant.impl.context.DefaultContext.extractPath ( String  path)
static

Definition at line 827 of file DefaultContext.java.

827  {
828  if(path == null) {
829  path = "/";
830  } else {
831  int p = path.indexOf("?");
832  if(p > -1) {
833  path = path.substring(0, p);
834  }
835  }
836  return path;
837  }
Here is the caller graph for this function:

◆ getAncestors()

IContext [] org.turro.elephant.impl.context.DefaultContext.getAncestors ( )

The returning array for this method has as the first element, the root context, and the last, the calling context.

Returns
An array with context ancestors.

Implements org.turro.elephant.context.IContext.

Definition at line 454 of file DefaultContext.java.

454  {
455  if(ancestors == null) {
456  ArrayList v = new ArrayList();
457  ElContext elContext = getElContext();
458  if(elContext != null && !elContext.getAncestors().isEmpty()) {
459  for(ElContext child : elContext.getAncestors()) {
460  v.add(child.getContext());
461  }
462  }
463 // IContext tmp = this;
464 // v.add(this);
465 // while((tmp = tmp.getParent()) != null) {
466 // v.add(0, tmp);
467 // }
468  ancestors = (IContext[]) v.toArray(new IContext[0]);
469  }
470  return ancestors;
471  }
Here is the call graph for this function:

◆ getAttributes()

AttributeSupport org.turro.elephant.impl.context.DefaultContext.getAttributes ( )
Returns
The attributes of this element.

Implements org.turro.elephant.layout.IManageable.

Definition at line 601 of file DefaultContext.java.

601  {
602  return attrSupport;
603  }

◆ getBaseNames()

String [] org.turro.elephant.impl.context.DefaultContext.getBaseNames ( )

Definition at line 536 of file DefaultContext.java.

536  {
537  TreeSet set = new TreeSet();
538  String name;
539  if(file.isDirectory()) {
540  File[] children = file.listFiles();
541  for(int i = 0; i < children.length; i++)
542  if(children[i].isFile()) {
543  name = FileUtil.baseName(children[i].getName());
544  if(name != null) {
545  set.add(name);
546  }
547  }
548  }
549  return (String[])set.toArray(new String[0]);
550  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getChildren()

IContext [] org.turro.elephant.impl.context.DefaultContext.getChildren ( )
Returns
An array with context's children.

Implements org.turro.elephant.context.IContext.

Definition at line 474 of file DefaultContext.java.

474  {
475  if(children == null) {
476  ArrayList v = new ArrayList();
477  ElContext elContext = getElContext();
478  if(elContext != null && !elContext.getChildren().isEmpty()) {
479  for(ElContext child : elContext.getChildren()) {
480  v.add(child.getContext());
481  }
482  }
483 // IContext ctmp;
484 // if(file.isDirectory()) {
485 // File[] children = file.listFiles();
486 // for(int i = 0; i < children.length; i++)
487 // if(children[i].isDirectory())
488 // if(!constructor.isFileInternal(children[i])) {
489 // ctmp = ContextFactory.getContext(constructor, path + "/" + children[i].getName());
490 // v.add(ctmp);
491 // }
492 // }
493  children = (IContext[]) v.toArray(new IContext[0]);
494  }
495  return children;
496  }
Here is the call graph for this function:

◆ getConstructor()

IConstructor org.turro.elephant.impl.context.DefaultContext.getConstructor ( )
Returns
Returns current IConstructor.

Implements org.turro.elephant.context.IContext.

Definition at line 591 of file DefaultContext.java.

591  {
592  return constructor;
593  }

◆ getContext()

IContext org.turro.elephant.impl.context.DefaultContext.getContext ( )

Allows mixing IElement and IContext and get a reference to context.

Returns
Itself.

Implements org.turro.elephant.context.IContext.

Definition at line 107 of file DefaultContext.java.

107  {
108  return this;
109  }
Here is the caller graph for this function:

◆ getDefaultElement() [1/2]

IElement org.turro.elephant.impl.context.DefaultContext.getDefaultElement ( )
Returns
The IElement that will render in context space.

Implements org.turro.elephant.context.IContext.

Definition at line 222 of file DefaultContext.java.

222  {
223  if(usedElement == null) {
224  ElContext elContext = getElContext();
225  if(elContext != null) {
226  usedElement = getElContext().getWebContext().getElementInstance(); //getElements(null)[0];
228  }
229  }
230  return usedElement;
231  }
void setConfiguration(IConstructor constructor, ElContext context)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getDefaultElement() [2/2]

IElement org.turro.elephant.impl.context.DefaultContext.getDefaultElement ( String  type)
Parameters
typeElement's type.
Returns
The IElement that will render in context space by type.

Implements org.turro.elephant.context.IContext.

Definition at line 234 of file DefaultContext.java.

234  {
235 // IElement[] iels = getElements(type);
236 // if(iels.length > 0) return iels[0];
237  return null;
238  }

◆ getDefaultLocales()

Set<String> org.turro.elephant.impl.context.DefaultContext.getDefaultLocales ( )
Returns
An array of locales, starting with current context and traversing upp the ancestors tree.

Implements org.turro.elephant.context.IContext.

Definition at line 261 of file DefaultContext.java.

261  {
262  return getElContext().getDefaultLocales();
263 // if(defaultLocales == null) {
264 // getAncestors();
265 // String value = null;
266 // for(int i = ancestors.length - 1; i >= 0 && value == null; i--) {
267 // value = ((IManageable)ancestors[i]).getAttributes().getAttributeValue("lang", null);
268 // }
269 // if(value != null) {
270 // defaultLocales = value.split(" *, *");
271 // }
272 // else {
273 // defaultLocales = new String[0];
274 // }
275 // }
276 // return defaultLocales;
277  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getExactName()

String org.turro.elephant.impl.context.DefaultContext.getExactName ( String  lang)

Implements org.turro.elephant.context.IContext.

Definition at line 149 of file DefaultContext.java.

149  {
150  return getElContext().getWebContext().getNames().get(lang);
151 // if(conf != null) {
152 // Element i18n = conf.getChild("i18n");
153 // if(i18n != null) {
154 // Element name = i18n.getChild("name");
155 // if(name != null) {
156 // Element elang = name.getChild(lang);
157 // if(elang != null) {
158 // return elang.getValue();
159 // }
160 // }
161 // }
162 // }
163 // return getId();
164  }
Here is the call graph for this function:

◆ getFile()

File org.turro.elephant.impl.context.DefaultContext.getFile ( )
Returns
Verbose path for this context.
The file representing this context.

Implements org.turro.elephant.context.IContext.

Definition at line 383 of file DefaultContext.java.

383  {
384  return file;
385  }

◆ getFullPath()

String org.turro.elephant.impl.context.DefaultContext.getFullPath ( )

Full path intention is to provide an easy way for creating absolute links, starting with a slash.

Returns
Full path for this context, including web application's context.

Implements org.turro.elephant.context.IContext.

Definition at line 352 of file DefaultContext.java.

352  {
353  // prepend application context
354  String tmp = ElephantContext.getRootWebPath() + path;
355  return (tmp.length() == 0 ? "/" : tmp);
356  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getIcon()

String org.turro.elephant.impl.context.DefaultContext.getIcon ( )

Returns the image representing this context.

Returns
URL to icon

Implements org.turro.elephant.context.IContext.

Definition at line 201 of file DefaultContext.java.

201  {
202  return getElContext().getWebContext().getImage();
203  }
Here is the call graph for this function:

◆ getId()

String org.turro.elephant.impl.context.DefaultContext.getId ( )

Identifier is a unique value within Elephant web application.

Returns
Unique identifier.

Implements org.turro.elephant.context.IContext.

Definition at line 97 of file DefaultContext.java.

97  {
98  return file.getName();
99  }
Here is the caller graph for this function:

◆ getLevel()

int org.turro.elephant.impl.context.DefaultContext.getLevel ( )
Returns
Context level, starting from 0 when root.

Implements org.turro.elephant.context.IContext.

Definition at line 378 of file DefaultContext.java.

378  {
379  return path == null ? 0 : path.split("\\/").length - 1;
380  }

◆ getLocaleResources()

String [] org.turro.elephant.impl.context.DefaultContext.getLocaleResources ( String  preferredLocale)

Definition at line 552 of file DefaultContext.java.

552  {
553  String[] baseName = getBaseNames(),
554  prefixes = getLocaleSufixes(preferredLocale);
555  TreeSet set = new TreeSet();
556  String name;
557  File resource;
558  if(file.isDirectory()) {
559  for(int b = 0; b < baseName.length; b++) {
560  for(int p = 0; p < prefixes.length; p++) {
561  resource = new File(
562  file.getAbsolutePath() + "/" +
563  baseName[b].replaceAll(FileUtil.VALID_EXT_REGEXP + "$", prefixes[p] + ".$1")
564  );
565  if(resource.exists()) {
566  set.add(resource.getName());
567  break;
568  }
569  }
570  }
571  }
572  return (String[])set.toArray(new String[0]);
573  }
String[] getLocaleSufixes(String preferredLocale)
Here is the call graph for this function:

◆ getLocaleSufixes()

String [] org.turro.elephant.impl.context.DefaultContext.getLocaleSufixes ( String  preferredLocale)

Locale sufixes is a combination of locales in a single request. It's composed by user selection (the cookie 'lang'), navigator preferences and context preferences. Default context's language, first place in getDefaultLocales(), is included as an empty string.

Parameters
preferredLocaleLocale that will take first place.
Returns
An array of locale sufixes.

Implements org.turro.elephant.context.IContext.

Definition at line 644 of file DefaultContext.java.

644  {
645  ArrayList v = new ArrayList();
646  String defaultLocale = null;
647  Set<String> defLocale = getDefaultLocales();
648  Locale[] locale = new Locale[] {I_.api().used()}; //getLocales().getPreferred().toArray(new Locale[0]);
649  if(!defLocale.isEmpty()) {
650  defaultLocale = defLocale.iterator().next();
651  }
652  // check preferredLocale
653  if(preferredLocale != null) {
654  v.add(preferredLocale);
655  if(preferredLocale.equals(defaultLocale))
656  if(!v.contains("")) v.add("");
657  }
658  // visitor preferences
659  String language, country, variant, curr;
660  int languageLength, countryLength, variantLength;
661  for(int l = 0; l < locale.length; l++) {
662  language = locale[l].getLanguage();
663  languageLength = language.length();
664  country = locale[l].getCountry();
665  countryLength = country.length();
666  variant = locale[l].getVariant();
667  variantLength = variant.length();
668  if(languageLength > 0 && countryLength > 0 && variantLength > 0) {
669  curr = "_" + language + "_" + country + "_" + variant;
670  if(!v.contains(curr)) v.add(curr);
671  if(curr.equals(defaultLocale))
672  if(!v.contains("")) v.add("");
673  }
674  if(languageLength > 0 && countryLength > 0) {
675  curr = "_" + language + "_" + country;
676  if(!v.contains(curr)) v.add(curr);
677  if(curr.equals(defaultLocale))
678  if(!v.contains("")) v.add("");
679  }
680  if(languageLength > 0) {
681  curr = "_" + language;
682  if(!v.contains(curr)) v.add(curr);
683  if(curr.equals(defaultLocale))
684  if(!v.contains("")) v.add("");
685  }
686  }
687  // and finally context preferences
688 // for(int l = 0; l < defLocale.length; l++) {
689 // if(!v.contains(defLocale[l])) v.add(defLocale[l]);
690 // if(defLocale[l].equals(defaultLocale))
691 // if(!v.contains("")) v.add("");
692 // }
693  for(String dl : defLocale) {
694  if(!v.contains(dl)) v.add(dl);
695  if(dl.equals(defaultLocale))
696  if(!v.contains("")) v.add("");
697  }
698  return (String[]) v.toArray(new String[0]);
699  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getName() [1/2]

String org.turro.elephant.impl.context.DefaultContext.getName ( )

Context name is the text that shows in navigators. This method returns the same value than calling getName(null).

Returns
Display name for the context.

Implements org.turro.elephant.context.IContext.

Definition at line 112 of file DefaultContext.java.

112  {
113  ElContext elContext = getElContext();
114  if(elContext != null) {
115  return getElContext().getWebContext().getName();
116  } else {
117  return getId();
118  }
119  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getName() [2/2]

String org.turro.elephant.impl.context.DefaultContext.getName ( String  lang)

Context name is the text that shows in navigators.

Parameters
langSpecific locale
Returns
Display name for the context in lang locale.

Implements org.turro.elephant.context.IContext.

Definition at line 122 of file DefaultContext.java.

122  {
123  ElContext elContext = getElContext();
124  if(elContext != null) {
125  return elContext.getWebContext().getNames().get(lang);
126  } else {
127  return getId();
128  }
129 // if(conf != null) {
130 // Element i18n = conf.getChild("i18n");
131 // if(i18n != null) {
132 // Element name = i18n.getChild("name");
133 // if(name != null) {
134 // String[] pref = getLocaleSufixes(lang);
135 // Element tmp;
136 // for(int i = 0; i < pref.length; i++) {
137 // tmp = name.getChild(pref[i]);
138 // if(tmp != null) {
139 // return tmp.getValue();
140 // }
141 // }
142 // }
143 // }
144 // }
145 // return getId();
146  }
Here is the call graph for this function:

◆ getParent()

IContext org.turro.elephant.impl.context.DefaultContext.getParent ( )
Returns
Context's parent, null for root context.

Implements org.turro.elephant.context.IContext.

Definition at line 440 of file DefaultContext.java.

440  {
441  if(parent == null) {
442  ElContext elContext = getElContext();
443  if(elContext != null && elContext.getParent() != null) {
444  parent = elContext.getParent().getContext();
445  }
446 // if(!"/".equals(path) && path.indexOf("/") != -1) {
447 // parent = ContextFactory.getContext(constructor, path.substring(0, path.lastIndexOf("/")));
448 // }
449  }
450  return parent;
451  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getPath()

String org.turro.elephant.impl.context.DefaultContext.getPath ( )
Returns
Relative path for this context. Empty string for root.

Implements org.turro.elephant.context.IContext.

Definition at line 373 of file DefaultContext.java.

373  {
374  return path;
375  }
Here is the caller graph for this function:

◆ getRedirection()

String org.turro.elephant.impl.context.DefaultContext.getRedirection ( )

When a context has a redirection it never gets selected, instead browser receives a redirection response.

Returns
Redirection for this context.

Implements org.turro.elephant.context.IContext.

Definition at line 210 of file DefaultContext.java.

210  {
211  return getElContext().getWebContext().getRedirect();
212 // return attrSupport.getAttributeValue("redirect", null);
213  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getRepository()

Repository org.turro.elephant.impl.context.DefaultContext.getRepository ( )

Definition at line 701 of file DefaultContext.java.

701  {
702  return null;// new Repository(this);
703  }

◆ getSiblings()

IContext [] org.turro.elephant.impl.context.DefaultContext.getSiblings ( )
Returns
An array with context's siblings, including itself.

Implements org.turro.elephant.context.IContext.

Definition at line 499 of file DefaultContext.java.

499  {
500  ElContext elContext = getElContext();
501  ArrayList v = new ArrayList();
502  if(elContext != null) {
503  for(ElContext child : elContext.getSiblings()) {
504  v.add(child.getContext());
505  }
506  }
507  return (IContext[]) v.toArray(new IContext[0]);
508 // IContext parent = getParent();
509 // if(parent == null) {
510 // return new IContext[] { this };
511 // }
512 // else {
513 // return parent.getChildren();
514 // }
515  }
Here is the call graph for this function:

◆ getTarget()

String org.turro.elephant.impl.context.DefaultContext.getTarget ( )

Implements org.turro.elephant.context.IContext.

Definition at line 216 of file DefaultContext.java.

216  {
217  return getElContext().getWebContext().getRedirect();
218 // return attrSupport.getAttributeValue("target", null);
219  }
Here is the call graph for this function:

◆ getTitle()

String org.turro.elephant.impl.context.DefaultContext.getTitle ( )

Context title defaults to context name. Elements can override this value.

Returns
Display name for the context.

Implements org.turro.elephant.context.IContext.

Definition at line 192 of file DefaultContext.java.

192  {
193  String title = null;
194  if(usedElement != null) {
195  title = usedElement.getTitle();
196  }
197  return Strings.isBlank(title) ? getName() : title;
198  }
Here is the call graph for this function:

◆ getType()

String org.turro.elephant.impl.context.DefaultContext.getType ( )
Returns
Context's type.

Implements org.turro.elephant.context.IContext.

Definition at line 102 of file DefaultContext.java.

102  {
103  return "context";
104  }
Here is the caller graph for this function:

◆ getTypeName()

String org.turro.elephant.impl.context.DefaultContext.getTypeName ( )
Returns
Element type name.

Implements org.turro.elephant.layout.IManageable.

Definition at line 596 of file DefaultContext.java.

596  {
597  return I_.get("element." + getType());
598  }
Here is the call graph for this function:

◆ getWebPath()

String org.turro.elephant.impl.context.DefaultContext.getWebPath ( )

Works as getFullPath method but takes into account redirections

Returns
Full path for this context, including web application's context and/or redirections.

Implements org.turro.elephant.context.IContext.

Definition at line 359 of file DefaultContext.java.

359  {
360  String redirection = getRedirection();
361  if(Strings.isBlank(redirection)) {
362  return getFullPath();
363  } else if(redirection.startsWith("/")) {
364  return ElephantContext.getRootWebPath() + redirection;
365  } else if(redirection.contains("://")) {
366  return redirection;
367  } else {
368  return getFullPath() + "/" + redirection;
369  }
370  }
Here is the call graph for this function:

◆ hashCode()

int org.turro.elephant.impl.context.DefaultContext.hashCode ( )

Definition at line 90 of file DefaultContext.java.

90  {
91  int hash = 7;
92  hash = 79 * hash + (this.path != null ? this.path.hashCode() : 0);
93  return hash;
94  }

◆ inPath()

boolean org.turro.elephant.impl.context.DefaultContext.inPath ( IContext  context)

This method is used by navigators in order to check whether a context exists in currently selected context. Therefore a call like context.inPath(current) must return true if context is one of current ancestors.

Parameters
contextA context to check its path with.
Returns
True if calling context is in context parameter path.

Implements org.turro.elephant.context.IContext.

Definition at line 737 of file DefaultContext.java.

737  {
738  return context.getFullPath().matches(getFullPath() + "(\\/.*)?");
739  }
Here is the call graph for this function:

◆ isInRole()

boolean org.turro.elephant.impl.context.DefaultContext.isInRole ( )

This method points to an specific role, know at configuration time. To achieve more control on roles use constructor's, which takes a parameter with a role.

Returns
True when the element is in role.

Implements org.turro.elephant.security.IDefendable.

Definition at line 774 of file DefaultContext.java.

774  {
775  if(!UserMenus.isInRole(path)) return false;
776  IDefendable parent = (IDefendable) getParent();
777  if(parent != null && !parent.isInRole()) return false;
778  String contextRole = attrSupport.getAttributeValue("contextRole", null);
779  if(contextRole == null) return true;
780  return constructor.isInRole(contextRole);
781  }
String getAttributeValue(String name, String defaultValue)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isSelectable()

boolean org.turro.elephant.impl.context.DefaultContext.isSelectable ( )

Selectable elements may respond to user input.

Returns
True when the element is selectable.

Implements org.turro.elephant.security.IDefendable.

Definition at line 769 of file DefaultContext.java.

769  {
770  return getElContext().getWebContext().isShowInNavigators(); //attrSupport.getAttributeBooleanValue("showInNavigators", false);
771  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ locateRealContext()

static String org.turro.elephant.impl.context.DefaultContext.locateRealContext ( IConstructor  constructor,
String  path 
)
static

Definition at line 812 of file DefaultContext.java.

812  {
813  if(path == null) {
814  if(constructor.getRequest() == null) {
815  path = "/";
816  } else {
817  path = extractPath(constructor.getRequest().getServletPath());
818  }
819  } else {
820  path = path.replaceAll("[^\\/a-zA-Z0-9\\-\\_\\.]", "_");
821  }
822  if(!constructor.isWebAdministering() && !Files.exists(path)) path = Files.toExisting(path);
823  if(path.endsWith("/")) path = path.substring(0, path.length() - 1);
824  return path;
825  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ populateFromParent()

void org.turro.elephant.impl.context.DefaultContext.populateFromParent ( )

Implements org.turro.elephant.layout.IManageable.

Definition at line 630 of file DefaultContext.java.

630  {
631  if(getParent() == null) return;
632 
633  IManageable mgb = (IManageable)parent;
634 
635  attrSupport.getAttribute("contextRole").setValue(mgb.getAttributes().getAttributeValue("contextRole", null));
636  attrSupport.getAttribute("noindex").setBooleanValue(mgb.getAttributes().getAttributeBooleanValue("noindex", false));
637  attrSupport.getAttribute("nofollow").setBooleanValue(mgb.getAttributes().getAttributeBooleanValue("nofollow", false));
638  attrSupport.getAttribute("print-version").setBooleanValue(mgb.getAttributes().getAttributeBooleanValue("print-version", false));
639  attrSupport.getAttribute("control-version").setBooleanValue(mgb.getAttributes().getAttributeBooleanValue("control-version", false));
640  attrSupport.getAttribute("traversalNavigation").setBooleanValue(mgb.getAttributes().getAttributeBooleanValue("traversalNavigation", false));
641  }
Here is the call graph for this function:

◆ search()

FoundList org.turro.elephant.impl.context.DefaultContext.search ( String  value,
boolean  ignoreCase 
)

This method is called by Elephant search implementation.

Parameters
valueValue to search.
ignoreCaseWhether to ignore case.
Returns
A list of coincidences.

Implements org.turro.elephant.search.ISearchable.

Definition at line 790 of file DefaultContext.java.

790  {
791  FoundList fl = new FoundList();
792  SearchFormatter sf = new SearchFormatter(value, ignoreCase);
793  sf.processLine(getName());
794  if(sf.wasFound()) {
795  fl.addItem(
796  getId() == null ? "" : getId(),
797  (getPath().length() == 0 ? "/" : getPath()),
798  "<img src='" + ElephantContext.getRootResourcePath() + "/_internal/system/images/context.gif'/>",
799  getName(),
800  sf.getResult(),
801  (double)sf.getFound(),
802  value
803  );
804  }
805  return fl;
806  }
Here is the call graph for this function:

◆ setConstructor()

void org.turro.elephant.impl.context.DefaultContext.setConstructor ( IConstructor  constructor,
String  path 
)

This method gets authomatically called from ContextFactory. Its intention is to set constructor and context path.

Parameters
constructorConstructor that generated context creation.
pathContext's relative path, starting with a slash or empty for root context.

Implements org.turro.elephant.context.IContext.

Definition at line 280 of file DefaultContext.java.

280  {
281  this.constructor = constructor;
282 // if(path == null) {
283 // if(constructor.getRequest() == null) {
284 // this.path = "/";
285 // } else {
286 // this.path = constructor.getRequest().getServletPath();
287 // if(this.path == null) {
288 // this.path = "/";
289 // } else {
290 // int p = this.path.indexOf("?");
291 // if(p > -1) {
292 // this.path = this.path.substring(0, p);
293 // }
294 // }
295 // }
296 // }
297 // else {
298 // this.path = path.replaceAll("[^\\/a-zA-Z0-9\\-\\_\\.]", "_");
299 // }
300 // if(this.path.endsWith("/")) this.path = this.path.substring(0, this.path.length() - 1);
302  file = new File(ElephantContext.getRealPath(this.path));
303  ElContext elContext = getElContext();
304  if(elContext != null) {
305  attrSupport.addAttribute(new AttributeItem("order", elContext.getWebContext().getOrder(), AttributeItem.STRING_ATTR, "000"));
306  attrSupport.addAttribute(new AttributeItem("showInNavigators", elContext.getWebContext().isShowInNavigators(), true));
307  attrSupport.addAttribute(new AttributeItem("showAlways", elContext.getWebContext().isShowAlways(), false));
308  attrSupport.addAttribute(new AttributeItem("printContext", elContext.getWebContext().isPrintContext(), true));
309  attrSupport.addAttribute(new AttributeItem("contextRole", elContext.getWebContext().getRole(), AttributeItem.STRING_ATTR, null));
310  attrSupport.addAttribute(new AttributeItem("redirect", elContext.getWebContext().getRedirect(), AttributeItem.STRING_ATTR, null));
311  attrSupport.addAttribute(new AttributeItem("target", elContext.getWebContext().getTarget(), AttributeItem.STRING_ATTR, null));
312  attrSupport.addAttribute(new AttributeItem("noindex", elContext.getWebContext().isNoIndex(), false));
313  attrSupport.addAttribute(new AttributeItem("nofollow", elContext.getWebContext().isNoFollow(), false));
314  attrSupport.addAttribute(new AttributeItem("print-version", elContext.getWebContext().isPrintVersion(), true));
315  attrSupport.addAttribute(new AttributeItem("control-version", elContext.getWebContext().isControlVersion(), true));
316  attrSupport.addAttribute(new AttributeItem("traversalNavigation", elContext.getWebContext().isTraversalNavigation(), false));
317  }
318 // readConfiguration();
319 // attrSupport.addAttribute(new AttributeItem("order",
320 // (conf != null ? conf.getAttributeValue("order") : null), AttributeItem.STRING_ATTR, "000"));
321 // attrSupport.addAttribute(new AttributeItem("lang",
322 // (conf != null ? conf.getAttributeValue("lang") : null), AttributeItem.STRING_ATTR, null));
323 // attrSupport.addAttribute(new AttributeItem("showInNavigators",
324 // (conf != null ? conf.getAttributeValue("showInNavigators") : null), AttributeItem.BOOLEAN_ATTR, "true"));
325 // attrSupport.addAttribute(new AttributeItem("showAlways",
326 // (conf != null ? conf.getAttributeValue("showAlways") : null), AttributeItem.BOOLEAN_ATTR, "false"));
327 // attrSupport.addAttribute(new AttributeItem("printContext",
328 // (conf != null ? conf.getAttributeValue("printContext") : null), AttributeItem.BOOLEAN_ATTR, "true"));
329 // attrSupport.addAttribute(new AttributeItem("contextRole",
330 // (conf != null ? conf.getAttributeValue("contextRole") : null), AttributeItem.STRING_ATTR, null));
331 // attrSupport.addAttribute(new AttributeItem("redirect",
332 // (conf != null ? conf.getAttributeValue("redirect") : null), AttributeItem.STRING_ATTR, null));
333 // attrSupport.addAttribute(new AttributeItem("target",
334 // (conf != null ? conf.getAttributeValue("target") : null), AttributeItem.STRING_ATTR, null));
335 // attrSupport.addAttribute(new AttributeItem("noindex",
336 // (conf != null ? conf.getAttributeValue("noindex") : null), AttributeItem.BOOLEAN_ATTR, "false"));
337 // attrSupport.addAttribute(new AttributeItem("nofollow",
338 // (conf != null ? conf.getAttributeValue("nofollow") : null), AttributeItem.BOOLEAN_ATTR, "false"));
339 // attrSupport.addAttribute(new AttributeItem("print-version",
340 // (conf != null ? conf.getAttributeValue("print-version") : null), AttributeItem.BOOLEAN_ATTR, "true"));
341 // attrSupport.addAttribute(new AttributeItem("control-version",
342 // (conf != null ? conf.getAttributeValue("control-version") : null), AttributeItem.BOOLEAN_ATTR, "true"));
343 // attrSupport.addAttribute(new AttributeItem("traversalNavigation",
344 // (conf != null ? conf.getAttributeValue("traversalNavigation") : null), AttributeItem.BOOLEAN_ATTR, "false"));
345 // attrSupport.addAttribute(new AttributeItem("onTop",
346 // (conf != null ? conf.getAttributeValue("onTop") : null), AttributeItem.STRING_ATTR, null));
347 // attrSupport.addAttribute(new AttributeItem("onBottom",
348 // (conf != null ? conf.getAttributeValue("onBottom") : null), AttributeItem.STRING_ATTR, null));
349  }
static String locateRealContext(IConstructor constructor, String path)
Here is the call graph for this function:

◆ setIcon()

void org.turro.elephant.impl.context.DefaultContext.setIcon ( String  icon)

Sets the image that represents this context.

Parameters
iconURL to icon.

Implements org.turro.elephant.context.IContext.

Definition at line 206 of file DefaultContext.java.

206  {
207  }

◆ setName()

void org.turro.elephant.impl.context.DefaultContext.setName ( String  lang,
String  name 
)

Sets context's name in the given locale.

Parameters
langSpecific locale.
nameContext name.

Implements org.turro.elephant.context.IContext.

Definition at line 167 of file DefaultContext.java.

167  {
168  getElContext().getWebContext().getNames().put(lang, newName);
169 // if(conf == null) {
170 // Document doc = new Document(new Element("elephant-context"));
171 // conf = doc.getRootElement();
172 // }
173 // Element i18n = conf.getChild("i18n");
174 // if(i18n == null) {
175 // i18n = new Element("i18n");
176 // conf.addContent(i18n);
177 // }
178 // Element name = i18n.getChild("name");
179 // if(name == null) {
180 // name = new Element("name");
181 // i18n.addContent(name);
182 // }
183 // Element tmp = name.getChild(lang);
184 // if(tmp == null) {
185 // tmp = new Element(lang);
186 // name.addContent(tmp);
187 // }
188 // tmp.setText(newName);
189  }
Here is the call graph for this function:

◆ startConstruction()

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

Start construction should be aware of which layout is being used, in order to give an initialization code. This is done automatically by ILayoutManager, returned by ContextFactory.

Exceptions
javax.servlet.ServletException
java.io.IOException

Implements org.turro.elephant.context.IContext.

Definition at line 407 of file DefaultContext.java.

407  {
408  final IElement element = getDefaultElement();
409 
410  ElContext elContext = ElContextMap.getContext(path);
411  String template = elContext.getTemplate();
412  WebContext webContext = elContext.getWebContext();
413 
414  ElephantMarker em = new ElephantMarker(constructor);
415  if(webContext.isControlVersion() ||
416  constructor.isInRole("control-version:admin") ||
418  em.put("fileVersion", new FileVersionWrapper(element, 20, 3));
419  }
420  // Desactivat fins no tenir les plantilles carregades
421  if(webContext.isPrintVersion() && canPrint()) {
422  String printPath = ElephantContext.getRootWebPath() + "/print_" + getContext().getPath();
423  em.put("printPath", printPath);
424  em.put("printVersion", "<div id='print-version'><a class='newwindow' target='_blank' rel='nofollow' href='" + printPath + "'>" +
425  I_.get("Printer version") +
426  "</a></div>");
427  }
428  Navigator navigator = new Navigator(elContext);
429  navigator.setDynamicLoad("dynamic".equals(ElephantContext.getContextLoad()));
430  em.put("nav", navigator);
431  em.put("traversal", webContext.isTraversalNavigation());
432  em.put("body", element);
433  em.put("webmap", new WebMap(constructor));
434  element.loadData();
436  em.process("layout", template);
437  }
Here is the call graph for this function:

Member Data Documentation

◆ attrSupport

AttributeSupport org.turro.elephant.impl.context.DefaultContext.attrSupport
protected

Definition at line 74 of file DefaultContext.java.

◆ children

IContext [] org.turro.elephant.impl.context.DefaultContext.children
protected

Definition at line 71 of file DefaultContext.java.

◆ conf

Element org.turro.elephant.impl.context.DefaultContext.conf
protected

Definition at line 69 of file DefaultContext.java.

◆ constructor

IConstructor org.turro.elephant.impl.context.DefaultContext.constructor
protected

Definition at line 65 of file DefaultContext.java.

◆ CONTEXT_FILE

final String org.turro.elephant.impl.context.DefaultContext.CONTEXT_FILE = "/_internal/context.xml"
static

Definition at line 64 of file DefaultContext.java.

◆ defaultLocales

String [] org.turro.elephant.impl.context.DefaultContext.defaultLocales
protected

Definition at line 73 of file DefaultContext.java.

◆ file

File org.turro.elephant.impl.context.DefaultContext.file
protected

Definition at line 67 of file DefaultContext.java.

◆ parent

IContext org.turro.elephant.impl.context.DefaultContext.parent
protected

Definition at line 72 of file DefaultContext.java.

◆ path

String org.turro.elephant.impl.context.DefaultContext.path
protected

Definition at line 66 of file DefaultContext.java.

◆ usedElement

IElement org.turro.elephant.impl.context.DefaultContext.usedElement = null
protected

Definition at line 68 of file DefaultContext.java.


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