@@ -95,8 +95,8 @@ private Map<String, Object> appInfo() {
95
95
SETTINGS .format (
96
96
I18n .get (SETTINGS .getProperties ().get (AvailableAppSettings .APPLICATION_COPYRIGHT ))));
97
97
map .put ("theme" , SETTINGS .get (AvailableAppSettings .APPLICATION_THEME , null ));
98
- map .put ("logo" , getLogo ());
99
- map .put ("icon" , getIcon ());
98
+ map .put ("logo" , getLogoLink ());
99
+ map .put ("icon" , getIconLink ());
100
100
map .put ("lang" , AppFilter .getLocale ().toLanguageTag ());
101
101
102
102
final Map <String , Object > signIn = signInInfo ();
@@ -224,7 +224,7 @@ private Map<String, Object> userInfo() {
224
224
map .put ("lang" , AppFilter .getLocale ().toLanguageTag ());
225
225
226
226
if (user .getImage () != null ) {
227
- map .put ("image" , getLink (user , null ));
227
+ map .put ("image" , getLink (user ));
228
228
}
229
229
230
230
map .put ("action" , user .getHomeAction ());
@@ -316,45 +316,64 @@ private Object featuresInfo() {
316
316
/**
317
317
* Gets user specific application logo, or falls back to default application logo.
318
318
*
319
- * @return user specific logo link
319
+ * <p>The returned image can be a resource path string, a URL string or a MetaFile
320
+ *
321
+ * @return user specific logo
320
322
*/
321
- public String getLogo () {
323
+ public Object getLogo () {
322
324
final String logo = SETTINGS .get (AvailableAppSettings .APPLICATION_LOGO , "img/axelor.png" );
323
325
if (SETTINGS .get (AvailableAppSettings .CONTEXT_APP_LOGO ) != null ) {
324
326
final ScriptBindings bindings = new ScriptBindings (new HashMap <>());
325
327
final ScriptHelper helper = new CompositeScriptHelper (bindings );
326
328
try {
327
- return getLink (helper .eval ("__config__.appLogo" ), logo );
329
+ return Optional . ofNullable (helper .eval ("__config__.appLogo" )). orElse ( logo );
328
330
} catch (Exception e ) {
329
331
// Ignore
330
332
}
331
333
}
332
334
return logo ;
333
335
}
334
336
337
+ /**
338
+ * Gets user specific application logo link, or falls back to default application logo.
339
+ *
340
+ * @return user specific logo link
341
+ */
342
+ public String getLogoLink () {
343
+ return getLink (getLogo ());
344
+ }
345
+
335
346
/**
336
347
* Gets user specific application icon, or falls back to default application icon.
337
348
*
349
+ * <p>The returned image can be a resource path string, a URL string or a MetaFile
350
+ *
338
351
* @return user specific application icon
339
352
*/
340
- public String getIcon () {
353
+ public Object getIcon () {
341
354
final String icon = SETTINGS .get (AvailableAppSettings .APPLICATION_ICON , "ico/favicon.ico" );
342
355
if (SETTINGS .get (AvailableAppSettings .CONTEXT_APP_ICON ) != null ) {
343
356
final ScriptBindings bindings = new ScriptBindings (new HashMap <>());
344
357
final ScriptHelper helper = new CompositeScriptHelper (bindings );
345
358
try {
346
- return getLink (helper .eval ("__config__.appIcon" ), icon );
359
+ return Optional . ofNullable (helper .eval ("__config__.appIcon" )). orElse ( icon );
347
360
} catch (Exception e ) {
348
361
// Ignore
349
362
}
350
363
}
351
364
return icon ;
352
365
}
353
366
354
- public String getLink (Object value , String defaultValue ) {
355
- if (value == null ) {
356
- return defaultValue ;
357
- }
367
+ /**
368
+ * Gets user specific application icon link, or falls back to default application icon.
369
+ *
370
+ * @return user specific application icon link
371
+ */
372
+ public String getIconLink () {
373
+ return getLink (getIcon ());
374
+ }
375
+
376
+ public String getLink (Object value ) {
358
377
if (value instanceof String ) {
359
378
return (String ) value ;
360
379
}
@@ -374,6 +393,6 @@ public String getLink(Object value, String defaultValue) {
374
393
+ "/image/download?image=true&v="
375
394
+ ((User ) value ).getVersion ();
376
395
}
377
- return defaultValue ;
396
+ return null ;
378
397
}
379
398
}
0 commit comments