* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
import org.onap.aaf.misc.xgen.html.Imports;
/**
- * A Base "Mobile First" Page
- *
+ * A Base "Mobile First" Page
+ *
* @author Jonathan
*
*/
// Note: Only access is synchronized in "getPerm"
private final static Map<String,Map<String,Permission>> perms = new HashMap<>();
-
+
/*
* Relative path, Menu Name, Full Path
*/
public String name() {
return bcName;
}
-
+
public String url() {
return bcUrl;
}
-
+
public String[] fields() {
return fields;
}
-
+
public Page(AuthzEnv env, String name, String url, Enum<?>[] en, final NamedCode ...content) throws APIException, IOException {
super(CacheGen.PRETTY, new PageCode(env, 1, content));
fields = new String[en.length];
// Mark which fields must be "no_cache"
boolean no_cacheTemp=false;
for (NamedCode nc : content) {
- if (nc.no_cache()) {
+ if (nc.no_cache()) {
no_cacheTemp=true;
break;
}
public Page(AuthzEnv env, String name, String url, String [] fields, final NamedCode ... content) throws APIException,IOException {
this(env,name,url,1,fields,content);
}
-
+
public Page(AuthzEnv env, String name, String url, int backdots, String [] fields, final NamedCode ... content) throws APIException,IOException {
super(CacheGen.PRETTY, new PageCode(env, backdots, content));
if (fields==null) {
// Mark which fields must be "no_cache"
boolean no_cacheTemp=false;
for (NamedCode nc : content) {
- if (nc.no_cache()) {
+ if (nc.no_cache()) {
no_cacheTemp=true;
break;
}
}
no_cache=no_cacheTemp;
}
-
-
+
+
private static class PageCode implements Code<HTMLGen> {
private static final String AAF_GUI_THEME = "aaf.gui.theme";
private static final String AAF_GUI_TITLE = "aaf_gui_title";
-
+
private final ContentCode[] content;
private final Slot browserSlot;
private final int backdots;
props = new Properties();
themeProps.put(t.getName(), props);
}
-
+
try {
FileInputStream fis = new FileInputStream(f);
try {
}
return themes.get(theme);
}
-
+
protected Imports getImports(Env env, String theme, int backdots, BROWSER browser) {
List<String> ls = getThemeFiles(env,theme);
Imports imp = new Imports(backdots);
}
return imp;
}
-
+
@Override
public void code(final Cache<HTMLGen> cache, final HTMLGen hgen) throws APIException, IOException {
- // Note: I found that App Storage saves everything about the page, or not. Thus, if you declare the page uncacheable, none of the
+ // Note: I found that App Storage saves everything about the page, or not. Thus, if you declare the page uncacheable, none of the
// Artifacts, like JPGs are stored, which makes this feature useless for Server driven elements
cache.dynamic(hgen, new DynamicCode<HTMLGen,AAF_GUI,AuthzTrans>() {
@Override
});
hgen.html();
final String title = env.getProperty(AAF_GUI_TITLE,"Authentication/Authorization Framework");
- final String defaultTheme = env.get(sTheme,"onap");
-
+ final String defaultTheme = env.get(sTheme,"onap");
+
Mark head = hgen.head();
hgen.leaf(TITLE).text(title).end();
cache.dynamic(hgen, new DynamicCode<HTMLGen,AAF_GUI,AuthzTrans>() {
@Override
public void code(AAF_GUI state, AuthzTrans trans, final Cache<HTMLGen> cache, final HTMLGen hgen) throws APIException, IOException {
- BROWSER browser = browser(trans,browserSlot);
+ BROWSER browser = browser(trans,browserSlot);
String theme = null;
Cookie[] cookies = trans.hreq().getCookies();
if(cookies!=null) {
}
}
}
-
+
if(theme==null) {
for(String t : themes.keySet()) {
if(!t.equals(defaultTheme) && trans.fish(new AAFPermission(null,trans.user()+":id", AAF_GUI_THEME, t))) {
}
List<String> ls = getThemeFiles(trans, theme);
if(ls==null) {
- throw new APIException("Theme " + theme + " does not exist.");
+ throw new APIException("Theme " + theme + " does not exist.");
}
Cookie cookie = new Cookie(AAF_GUI_THEME,theme);
cookie.setMaxAge(604_800); // one week
break;
default:
}
-
+
}
});
hgen.end(head);
-
+
Mark body = hgen.body();
Mark header = hgen.header();
cache.dynamic(hgen, new DynamicCode<HTMLGen,AAF_GUI,AuthzTrans>() {
String env = trans.getProperty(Config.AAF_ENV,"N/A");
xgen.leaf(H1).text(title + " on " + env).end();
xgen.leaf("p","id=version").text("AAF Version: " + state.deployedVersion).end();
-
+
// Obtain User Info, and print
TaggedPrincipal p = trans.getUserPrincipal();
String user,secured;
.text("<sup>")
.text(secured)
.text("</sup>").end();
-
+
switch(browser(trans,browserSlot)) {
case ieOld:
case ie:
- xgen.incr("h5").text("This app is Mobile First HTML5. Internet Explorer "
+ xgen.incr("h5").text("This app is Mobile First HTML5. Internet Explorer "
+ " does not support all HTML5 standards. Old, non TSS-Standard versions may not function correctly.").br()
.text(" For best results, use a highly compliant HTML5 browser like Firefox.")
.end();
}
}
});
-
+
hgen.hr();
-
+
int cIdx;
ContentCode nc;
// If BreadCrumbs, put here
} else {
cIdx = 0;
}
-
+
hgen.end(header);
hgen.divID("pageContent");
hgen.end(ctnt);
}
- hgen.end(inner);
+ hgen.end(inner);
+
-
cache.dynamic(hgen, new DynamicCode<HTMLGen,AAF_GUI,AuthzTrans>() {
@Override
public void code(AAF_GUI state, AuthzTrans trans,Cache<HTMLGen> cache, HTMLGen xgen) throws APIException, IOException {
} else {
props = themeProps==null?null:themeProps.get(theme);
}
-
+
if(props!=null && "TRUE".equalsIgnoreCase(props.getProperty("enable_nav_btn"))) {
xgen.leaf("button", "id=navBtn").end();
}
} else {
props = themeProps==null?null:themeProps.get(theme);
}
-
+
if(props!=null) {
if("TRUE".equalsIgnoreCase(props.getProperty("main_menu_in_nav"))) {
xgen.incr("h2").text("Navigation").end();
hgen.end();
}
hgen.end();
-
+
hgen.hr();
-
+
hgen.end(nav);
// Footer - Using older Footer to work with decrepit IE versions
Mark footer = hgen.divID("footer");
hgen.textCR(1, env.getProperty(AAF_GUI.AAF_GUI_COPYRIGHT))
.end(footer);
-
+
hgen.end(body);
hgen.endAll();
}
public static String getBrowserType() {
return BROWSER_TYPE;
}
-
+
/**
* It's IE if int >=0
- *
+ *
* Use int found in "ieVersion"
- *
+ *
* Official IE 7
- * Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322;
+ * Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322;
* .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)
* Official IE 8
- * Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2;
+ * Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2;
* .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; ATT)
- *
+ *
* IE 11 Compatibility
- * Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; SLCC2; .NET CLR 2.0.50727;
+ * Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; SLCC2; .NET CLR 2.0.50727;
* .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET CLR 1.1.4322; .NET4.0C; .NET4.0E; InfoPath.3; HVD; ATT)
- *
+ *
* IE 11 (not Compatiblity)
- * Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727;
+ * Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727;
* .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET CLR 1.1.4322; .NET4.0C; .NET4.0E; InfoPath.3; HVD; ATT)
- *
+ *
* @param trans
* @return
*/
BROWSER br = trans.get(slot, null);
if (br==null) {
String agent = trans.agent();
- int msie;
+ int msie;
if (agent.contains("iPhone") /* other phones? */) {
br=BROWSER.iPhone;
} else if ((msie = agent.indexOf("MSIE"))>=0) {
}
return br;
}
-
+
/*
* Get, rather than create each time, permissions for validations
*/