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

Public Member Functions

 Application ()
 
ApplicationContext getContext ()
 
boolean hasAnyRoleKey (String role)
 
boolean isInRole (String role)
 
boolean isInRole (String role, String redirect) throws IOException
 
IContact checkUser (boolean doLogin) throws IOException
 
Object getPreference (String key)
 
void putPreference (String key, Object value)
 
IConstructor getConstructor ()
 
void invalidateSession ()
 
HttpSession getHttpSession (boolean create)
 
IImplementation getImplementation (String name)
 
List getImplementationNamesByType (String type)
 
abstract HttpServletRequest getHttpServletRequest ()
 
abstract HttpServletResponse getHttpServletResponse ()
 
abstract void sendRedirect (String uri)
 
abstract void navigateBack ()
 
String getServerBase ()
 
String getServerUrl ()
 

Static Public Member Functions

static Application getApplication ()
 
static Application getFromConstructor (IConstructor constructor)
 
static boolean loadResources (String path)
 
static void resetSettings ()
 
static void resetSchemes ()
 
static IContact getUser ()
 
static Cookie getCookie (String name)
 
static String getCookieValue (String name)
 
static void setCookie (String name, String value, String path, int age)
 
static void encryptCookie (String name, String value, String path, int age)
 
static String decryptCookieValue (String name)
 
static void deleteCookie (String name, String path)
 
static Locale getUsedLocale ()
 
static Map getStringMap ()
 
static Map getStringMap (Locale locale, String configured)
 
static String getString (String key)
 
static String getString (String key, String locale)
 
static String getString (String key, Locale locale)
 
static List< String > getAllLocales (String key)
 
static ResourceBundle getBundle (String bundle, Locale locale, String configured)
 
static HttpServletRequest getResolverRequest ()
 
static HttpServletResponse getResolverResponse ()
 
static HttpSession getResolverSession (boolean create)
 

Static Public Attributes

static final String[] BUNDLES
 
static final String REGEXP_NO_RESOURCES = "(\\/zkau.*|\\/app.*)"
 

Protected Member Functions

abstract IConstructor doConstructor ()
 

Protected Attributes

UserPreferences preferences
 
HttpServletRequest request
 
HttpServletResponse response
 

Static Protected Attributes

static ThreadLocal< Applicationapp = new ThreadLocal<>()
 

Detailed Description

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

Definition at line 49 of file Application.java.

Constructor & Destructor Documentation

◆ Application()

org.turro.elephant.context.Application.Application ( )

Definition at line 120 of file Application.java.

120  {
121  // move request and response here
122  /*if(app.get() == null)*/
123  if(!(this instanceof HeadlessApplication)) {
124  app.set(this);
125  }
126  }
static ThreadLocal< Application > app
Here is the caller graph for this function:

Member Function Documentation

◆ checkUser()

IContact org.turro.elephant.context.Application.checkUser ( boolean  doLogin) throws IOException

Definition at line 168 of file Application.java.

168  {
169  IConstructor constructor = getConstructor();
170  IContact user = constructor.getUser();
171  if(user == null && doLogin) {
172  ElephantLogin.redirectToLogin(constructor);
173  }
174  return user;
175  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ decryptCookieValue()

static String org.turro.elephant.context.Application.decryptCookieValue ( String  name)
static

Definition at line 271 of file Application.java.

271  {
272  try {
273  Cookie cookie = getCookie(name);
274  if(cookie != null) {
275  byte[] v = CookieUtil.decryptCookieValue(cookie);
276  if(v != null) return new String(ElephantContext.decrypt(v));
277  }
278  } catch (Exception ex) {
279  Logger.getLogger(Application.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
280  }
281  return null;
282  }
static Cookie getCookie(String name)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ deleteCookie()

static void org.turro.elephant.context.Application.deleteCookie ( String  name,
String  path 
)
static

Definition at line 284 of file Application.java.

284  {
285  CookieUtil.deleteCookie(getApplication().getHttpServletResponse(), name, path);
286  }
abstract HttpServletResponse getHttpServletResponse()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ doConstructor()

abstract IConstructor org.turro.elephant.context.Application.doConstructor ( )
abstractprotected

◆ encryptCookie()

static void org.turro.elephant.context.Application.encryptCookie ( String  name,
String  value,
String  path,
int  age 
)
static

Definition at line 262 of file Application.java.

262  {
263  try {
264  byte[] b = ElephantContext.encrypt(value.getBytes());
265  CookieUtil.encryptCookie(getApplication().getHttpServletResponse(), name, b, path, age);
266  } catch (Exception ex) {
267  Logger.getLogger(Application.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
268  }
269  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getAllLocales()

static List<String> org.turro.elephant.context.Application.getAllLocales ( String  key)
static

Definition at line 314 of file Application.java.

314  {
315  return I_.compatibility().getInLocales(key);
316  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getApplication()

static Application org.turro.elephant.context.Application.getApplication ( )
static

Definition at line 71 of file Application.java.

71  {
72  Application application = app.get();
73  try {
74  if(application == null) {
75  HttpServletRequest request = getResolverRequest();
76  if(request != null) {
77  if(application == null) {
78  application = (Application) request.getAttribute("el_app");
79  }
80  if(application == null) {
81  application = new ElephantApplication(request, getResolverResponse());
82  request.setAttribute("el_app", application);
83  }
84  }
85  }
86  if(application != null) {
87  app.set(application);
88  return application;
89  } else {
90  return HeadlessApplication.getInstance();
91  }
92  } catch(Exception ex) {
93  return HeadlessApplication.getInstance();
94  }
95  }
static HttpServletRequest getResolverRequest()
static HttpServletResponse getResolverResponse()
Here is the call graph for this function:

◆ getBundle()

static ResourceBundle org.turro.elephant.context.Application.getBundle ( String  bundle,
Locale  locale,
String  configured 
)
static

Definition at line 318 of file Application.java.

318  {
319  return I_.compatibilityMap(locale).asBundle();
320  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getConstructor()

IConstructor org.turro.elephant.context.Application.getConstructor ( )

Reimplemented in org.turro.elephant.context.HeadlessApplication.

Definition at line 206 of file Application.java.

206  {
207  IConstructor elcons = null;
208  if(getHttpServletRequest() != null) {
209  elcons = (IConstructor) getHttpServletRequest().getAttribute("el_cons");
210  }
211  if(elcons == null) {
212  elcons = doConstructor();
213  }
214  return elcons;
215  }
abstract IConstructor doConstructor()
abstract HttpServletRequest getHttpServletRequest()
Here is the call graph for this function:

◆ getContext()

ApplicationContext org.turro.elephant.context.Application.getContext ( )

Definition at line 128 of file Application.java.

128  {
129  return new ApplicationContext(
132  }
Here is the call graph for this function:

◆ getCookie()

static Cookie org.turro.elephant.context.Application.getCookie ( String  name)
static

Definition at line 249 of file Application.java.

249  {
250  return CookieUtil.getCookie(getApplication().getHttpServletRequest(), name);
251  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getCookieValue()

static String org.turro.elephant.context.Application.getCookieValue ( String  name)
static

Definition at line 253 of file Application.java.

253  {
254  Cookie c = getCookie(name);
255  return c != null ? c.getValue() : null;
256  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getFromConstructor()

static Application org.turro.elephant.context.Application.getFromConstructor ( IConstructor  constructor)
static

Definition at line 97 of file Application.java.

97  {
98  return (Application) constructor.getRequest().getAttribute("el_app");
99  }
Here is the call graph for this function:

◆ getHttpServletRequest()

abstract HttpServletRequest org.turro.elephant.context.Application.getHttpServletRequest ( )
abstract

◆ getHttpServletResponse()

abstract HttpServletResponse org.turro.elephant.context.Application.getHttpServletResponse ( )
abstract

◆ getHttpSession()

HttpSession org.turro.elephant.context.Application.getHttpSession ( boolean  create)

Reimplemented in org.turro.elephant.zkoss.ZkossElephant.

Definition at line 226 of file Application.java.

226  {
227  if(getHttpServletRequest() != null) {
228  return getHttpServletRequest().getSession(create);
229  }
230  return null;
231  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getImplementation()

IImplementation org.turro.elephant.context.Application.getImplementation ( String  name)

Definition at line 233 of file Application.java.

233  {
234  return (IImplementation) ContextFactory.getImplementation(getConstructor(), name);
235  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getImplementationNamesByType()

List org.turro.elephant.context.Application.getImplementationNamesByType ( String  type)

Definition at line 237 of file Application.java.

237  {
238  return ContextFactory.getImplementationNamesByType(type);
239  }
Here is the call graph for this function:

◆ getPreference()

Object org.turro.elephant.context.Application.getPreference ( String  key)

Definition at line 177 of file Application.java.

177  {
178  try {
179  IContact user = checkUser(false);
180  if (user != null) {
181  if (preferences == null || !preferences.isEqual(user.getId())) {
182  preferences = UserPreferences.getInstance(user.getId());
183  }
184  return preferences.get(key);
185  }
186  } catch (IOException ex) {
187  Logger.getLogger(Application.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
188  }
189  return null;
190  }
IContact checkUser(boolean doLogin)
static UserPreferences getInstance(String id)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getResolverRequest()

static HttpServletRequest org.turro.elephant.context.Application.getResolverRequest ( )
static

Definition at line 334 of file Application.java.

334  {
335  for(ISessionResolver iSessionResolver : Instances.cached().byAnnotation(ElephantSessionResolver.class, ISessionResolver.class)) {
336  HttpServletRequest request = iSessionResolver.getRequest();
337  if(request != null) {
338  return request;
339  }
340  }
341  return null;
342  }
Here is the caller graph for this function:

◆ getResolverResponse()

static HttpServletResponse org.turro.elephant.context.Application.getResolverResponse ( )
static

Definition at line 344 of file Application.java.

344  {
345  for(ISessionResolver iSessionResolver : Instances.cached().byAnnotation(ElephantSessionResolver.class, ISessionResolver.class)) {
346  HttpServletResponse response = iSessionResolver.getResponse();
347  if(response != null) {
348  return response;
349  }
350  }
351  return null;
352  }
Here is the caller graph for this function:

◆ getResolverSession()

static HttpSession org.turro.elephant.context.Application.getResolverSession ( boolean  create)
static

Definition at line 354 of file Application.java.

354  {
355  for(ISessionResolver iSessionResolver : Instances.cached().byAnnotation(ElephantSessionResolver.class, ISessionResolver.class)) {
356  HttpSession session = iSessionResolver.getSession(create);
357  if(session != null) {
358  return session;
359  }
360  }
361  return null;
362  }
Here is the caller graph for this function:

◆ getServerBase()

String org.turro.elephant.context.Application.getServerBase ( )

Definition at line 324 of file Application.java.

324  {
325  return ElephantContext.getServerBase("http");
326  }
Here is the call graph for this function:

◆ getServerUrl()

String org.turro.elephant.context.Application.getServerUrl ( )

Definition at line 328 of file Application.java.

328  {
329  return ElephantContext.getServerUrl("http");
330  }
Here is the call graph for this function:

◆ getString() [1/3]

static String org.turro.elephant.context.Application.getString ( String  key)
static

Definition at line 302 of file Application.java.

302  {
303  return I_.compatibility().get(key);
304  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getString() [2/3]

static String org.turro.elephant.context.Application.getString ( String  key,
Locale  locale 
)
static

Definition at line 310 of file Application.java.

310  {
311  return I_.compatibility().get(locale, key);
312  }
Here is the call graph for this function:

◆ getString() [3/3]

static String org.turro.elephant.context.Application.getString ( String  key,
String  locale 
)
static

Definition at line 306 of file Application.java.

306  {
307  return I_.compatibility().get(I18nLocales.createLocale(locale), key);
308  }
Here is the call graph for this function:

◆ getStringMap() [1/2]

static Map org.turro.elephant.context.Application.getStringMap ( )
static

Definition at line 294 of file Application.java.

294  {
295  return I_.compatibilityMap();
296  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getStringMap() [2/2]

static Map org.turro.elephant.context.Application.getStringMap ( Locale  locale,
String  configured 
)
static

Definition at line 298 of file Application.java.

298  {
299  return I_.compatibilityMap(locale);
300  }
Here is the call graph for this function:

◆ getUsedLocale()

static Locale org.turro.elephant.context.Application.getUsedLocale ( )
static

Definition at line 290 of file Application.java.

290  {
291  return I_.api().used();
292  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getUser()

static IContact org.turro.elephant.context.Application.getUser ( )
static

Definition at line 164 of file Application.java.

164  {
166  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ hasAnyRoleKey()

boolean org.turro.elephant.context.Application.hasAnyRoleKey ( String  role)

Definition at line 134 of file Application.java.

134  {
135  IConstructor constructor = getConstructor();
136  return constructor.hasAnyRoleKey(role);
137  }
Here is the call graph for this function:

◆ invalidateSession()

void org.turro.elephant.context.Application.invalidateSession ( )

Definition at line 217 of file Application.java.

217  {
218  // check why Application.get() request has no session
219  try {
220  getHttpSession(false).invalidate();
221  } catch(Exception ex) {
222  getResolverSession(true).invalidate();
223  }
224  }
static HttpSession getResolverSession(boolean create)
HttpSession getHttpSession(boolean create)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isInRole() [1/2]

boolean org.turro.elephant.context.Application.isInRole ( String  role)

Definition at line 139 of file Application.java.

139  {
140  try {
141  return isInRole(role, null);
142  } catch (IOException ex) {
143  Logger.getLogger(Application.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
144  }
145  return false;
146  }
Here is the call graph for this function:

◆ isInRole() [2/2]

boolean org.turro.elephant.context.Application.isInRole ( String  role,
String  redirect 
) throws IOException

Definition at line 148 of file Application.java.

148  {
149  IConstructor constructor = getConstructor();
150  boolean result, isWebAdministering = constructor.isWebAdministering();
151  if(!isWebAdministering) {
152  constructor.setWebAdministering(true);
153  }
154  result = constructor.isInRole(role);
155  if(!isWebAdministering) {
156  constructor.setWebAdministering(false);
157  }
158  if(!result && redirect != null) {
159  constructor.redirect(redirect);
160  }
161  return result;
162  }
Here is the call graph for this function:

◆ loadResources()

static boolean org.turro.elephant.context.Application.loadResources ( String  path)
static

Definition at line 101 of file Application.java.

101  {
102  return !Strings.isBlank(path) && !path.matches(REGEXP_NO_RESOURCES);
103  }
Here is the caller graph for this function:

◆ navigateBack()

abstract void org.turro.elephant.context.Application.navigateBack ( )
abstract

◆ putPreference()

void org.turro.elephant.context.Application.putPreference ( String  key,
Object  value 
)

Definition at line 192 of file Application.java.

192  {
193  try {
194  IContact user = checkUser(false);
195  if (user != null) {
196  if (preferences == null || !preferences.isEqual(user.getId())) {
197  preferences = UserPreferences.getInstance(user.getId());
198  }
199  preferences.put(key, value);
200  }
201  } catch (IOException ex) {
202  Logger.getLogger(Application.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
203  }
204  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ resetSchemes()

static void org.turro.elephant.context.Application.resetSchemes ( )
static

Definition at line 116 of file Application.java.

116  {
117  ElephantContext.resetSchemes();
118  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ resetSettings()

static void org.turro.elephant.context.Application.resetSettings ( )
static

Definition at line 105 of file Application.java.

105  {
106  SecurityGroups.reset();
107  ContextFactory.resetImplementationsStartingWith("IMail");
108  ElephantContext.resetSite();
109  ElephantProperties.resetProperties();
110  Labels.resetMaps();
111  I_.resetMaps();
112  ElContextMap.reset();
113  SitemapGenerator.generateSitemap();
114  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sendRedirect()

abstract void org.turro.elephant.context.Application.sendRedirect ( String  uri)
abstract

◆ setCookie()

static void org.turro.elephant.context.Application.setCookie ( String  name,
String  value,
String  path,
int  age 
)
static

Definition at line 258 of file Application.java.

258  {
259  CookieUtil.setCookie(getApplication().getHttpServletResponse(), name, value, path, age);
260  }
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ app

ThreadLocal<Application> org.turro.elephant.context.Application.app = new ThreadLocal<>()
staticprotected

Definition at line 65 of file Application.java.

◆ BUNDLES

final String [] org.turro.elephant.context.Application.BUNDLES
static
Initial value:
= {
"lang",
"elephant",
"labels",
"documentation",
"label-site"
}

Definition at line 51 of file Application.java.

◆ preferences

UserPreferences org.turro.elephant.context.Application.preferences
protected

Definition at line 67 of file Application.java.

◆ REGEXP_NO_RESOURCES

final String org.turro.elephant.context.Application.REGEXP_NO_RESOURCES = "(\\/zkau.*|\\/app.*)"
static

Definition at line 58 of file Application.java.

◆ request

HttpServletRequest org.turro.elephant.context.Application.request
protected

Definition at line 68 of file Application.java.

◆ response

HttpServletResponse org.turro.elephant.context.Application.response
protected

Definition at line 69 of file Application.java.


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