Implemented: Continue the common-theme upload (OFBIZ-9138 Create a common theme)

Four step load the visualTheme in user session, freemarker, screen, groovy and service context
Add util to resolve easily a visualTheme

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1806134 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Nicolas Malin
2017-08-25 08:18:35 +00:00
parent ddf43d864d
commit 10fa4452b7
15 changed files with 122 additions and 28 deletions
@@ -56,6 +56,7 @@ import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.ssl.SSLContexts;
import org.apache.ofbiz.widget.renderer.VisualTheme;
import org.apache.oro.text.regex.MalformedPatternException;
import org.apache.oro.text.regex.Pattern;
import org.apache.oro.text.regex.PatternMatcher;
@@ -78,6 +79,7 @@ public final class UtilHttp {
private static final int COMPOSITE_DELIMITER_LENGTH = COMPOSITE_DELIMITER.length();
private static final String SESSION_KEY_TIMEZONE = "timeZone";
private static final String SESSION_KEY_THEME = "visualTheme";
private UtilHttp () {}
@@ -725,6 +727,21 @@ public final class UtilHttp {
return timeZone;
}
/**
* Return the VisualTheme object from the user session
* @param request
* @return
*/
public static VisualTheme getVisualTheme(HttpServletRequest request) {
return (VisualTheme) request.getSession().getAttribute(SESSION_KEY_THEME);
}
public static void setVisualTheme(HttpServletRequest request, VisualTheme visualTheme) {
setVisualTheme(request.getSession(), visualTheme);
}
public static void setVisualTheme(HttpSession session, VisualTheme visualTheme) {
session.setAttribute(SESSION_KEY_THEME, visualTheme);
}
/**
* Get the currency string from the session.
* @param session HttpSession object to use for lookup