From 3d1706fcbe7f95830ff6fd23cf679ee55c6d0595 Mon Sep 17 00:00:00 2001 From: Instrumental Date: Wed, 7 Aug 2019 13:40:39 -0500 Subject: Remove Tabs, per Jococo Issue-ID: AAF-932 Change-Id: I3ab0ebcc082048d2d1424a58a90ea479fb005ee6 Signed-off-by: Instrumental --- .../src/main/java/org/onap/aaf/auth/cui/CUI.java | 10 +- .../main/java/org/onap/aaf/auth/gui/AAF_GUI.java | 40 +-- .../main/java/org/onap/aaf/auth/gui/Display.java | 18 +- .../src/main/java/org/onap/aaf/auth/gui/Page.java | 350 ++++++++++----------- .../org/onap/aaf/auth/gui/pages/ApprovalForm.java | 202 ++++++------ .../aaf/auth/gui/pages/CMArtiChangeAction.java | 66 ++-- .../java/org/onap/aaf/auth/gui/pages/Home.java | 4 +- .../aaf/auth/gui/pages/PendingRequestsShow.java | 88 +++--- .../org/onap/aaf/auth/gui/pages/RequestDetail.java | 24 +- .../org/onap/aaf/auth/gui/pages/RoleDetail.java | 6 +- .../org/onap/aaf/auth/gui/pages/WebCommand.java | 6 +- .../onap/aaf/auth/gui/table/TextToolTipCell.java | 2 +- .../java/org/onap/aaf/auth/gui/JU_FormTest.java | 38 +-- .../java/org/onap/aaf/auth/gui/JU_TableTest.java | 46 +-- .../org/onap/aaf/auth/gui/table/JU_UICellTest.java | 178 +++++------ 15 files changed, 539 insertions(+), 539 deletions(-) (limited to 'auth/auth-gui') diff --git a/auth/auth-gui/src/main/java/org/onap/aaf/auth/cui/CUI.java b/auth/auth-gui/src/main/java/org/onap/aaf/auth/cui/CUI.java index f2d7522e..cb44ab09 100644 --- a/auth/auth-gui/src/main/java/org/onap/aaf/auth/cui/CUI.java +++ b/auth/auth-gui/src/main/java/org/onap/aaf/auth/cui/CUI.java @@ -88,11 +88,11 @@ public class CUI extends HttpCode { try { aafcli.eval(cmdStr); if(userPerm.matcher(cmdStr).matches()) { - trans.clearCache(); - Cookie cookie = new Cookie(Page.AAF_THEME,trans.getProperty(Page.AAF_THEME)); - cookie.setMaxAge(-1); - cookie.setComment("Remove AAF GUI Theme"); - trans.hresp().addCookie(cookie); + trans.clearCache(); + Cookie cookie = new Cookie(Page.AAF_THEME,trans.getProperty(Page.AAF_THEME)); + cookie.setMaxAge(-1); + cookie.setComment("Remove AAF GUI Theme"); + trans.hresp().addCookie(cookie); } pw.flush(); } catch (Exception e) { diff --git a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/AAF_GUI.java b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/AAF_GUI.java index 17916c24..e1870e94 100644 --- a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/AAF_GUI.java +++ b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/AAF_GUI.java @@ -129,7 +129,7 @@ public class AAF_GUI extends AbsService implements State implements State(null, "Clear"){ - @Override - public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception { - trans.clearCache(); - Cookie cookies[] = req.getCookies(); - if(cookies!=null) { - for(Cookie c : cookies) { - if(c.getName().startsWith("aaf.gui.")) { - c.setMaxAge(0); - resp.addCookie(c); - } - } - } - resp.sendRedirect("/gui/home"); - } + @Override + public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception { + trans.clearCache(); + Cookie cookies[] = req.getCookies(); + if(cookies!=null) { + for(Cookie c : cookies) { + if(c.getName().startsWith("aaf.gui.")) { + c.setMaxAge(0); + resp.addCookie(c); + } + } + } + resp.sendRedirect("/gui/home"); + } }, "text/plain;charset=utf-8","*/*"); /////////////////////// @@ -287,11 +287,11 @@ public class AAF_GUI extends AbsService implements State( - new AAF_GUI(new AuthzEnv(propAccess)),true) - .start(); - } catch (Exception e) { - propAccess.log(e); - } + new AAF_GUI(new AuthzEnv(propAccess)),true) + .start(); + } catch (Exception e) { + propAccess.log(e); + } } catch (Exception e) { e.printStackTrace(); } diff --git a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/Display.java b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/Display.java index 877974bd..24262e8f 100644 --- a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/Display.java +++ b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/Display.java @@ -99,9 +99,9 @@ public class Display { for (int i=0; i { - private static final String AAF_GUI_THEME = "aaf.gui.theme"; - private static final String AAF_GUI_TITLE = "aaf_gui_title"; + 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; protected AuthzEnv env; private StaticSlot sTheme; - private static Map> themes; - private static Map themeProps; + private static Map> themes; + private static Map themeProps; public PageCode(AuthzEnv env, int backdots, final ContentCode[] content) { this.content = content; @@ -185,78 +185,78 @@ public class Page extends HTMLCacheGen { browserSlot = env.slot(BROWSER_TYPE); sTheme = env.staticSlot(AAF_GUI.AAF_GUI_THEME); this.env = env; - getThemeFiles(env,""); // + getThemeFiles(env,""); // } private static synchronized List getThemeFiles(Env env, String theme) { - if(themes==null) { - themes = new TreeMap<>(); + if(themes==null) { + themes = new TreeMap<>(); File themeD = new File("theme"); if(themeD.exists() && themeD.isDirectory()) { - for (File t : themeD.listFiles()) { - if(t.isDirectory()) { - List la = new ArrayList<>(); - for(File f : t.listFiles()) { - if(f.isFile()) { - if(f.getName().endsWith(".props")) { - Properties props; - if(themeProps == null) { - themeProps = new TreeMap<>(); - props = null; - } else { - props = themeProps.get(t.getName()); - } - if(props==null) { - props = new Properties(); - themeProps.put(t.getName(), props); - } - - try { - FileInputStream fis = new FileInputStream(f); - try { - props.load(fis); - } finally { - fis.close(); - } - } catch (IOException e) { - env.error().log(e); - } - } else { - la.add(f.getName()); - } - } - } - themes.put(t.getName(),la); - } - } + for (File t : themeD.listFiles()) { + if(t.isDirectory()) { + List la = new ArrayList<>(); + for(File f : t.listFiles()) { + if(f.isFile()) { + if(f.getName().endsWith(".props")) { + Properties props; + if(themeProps == null) { + themeProps = new TreeMap<>(); + props = null; + } else { + props = themeProps.get(t.getName()); + } + if(props==null) { + props = new Properties(); + themeProps.put(t.getName(), props); + } + + try { + FileInputStream fis = new FileInputStream(f); + try { + props.load(fis); + } finally { + fis.close(); + } + } catch (IOException e) { + env.error().log(e); + } + } else { + la.add(f.getName()); + } + } + } + themes.put(t.getName(),la); + } + } } - } - return themes.get(theme); + } + return themes.get(theme); } protected Imports getImports(Env env, String theme, int backdots, BROWSER browser) { - List ls = getThemeFiles(env,theme); - Imports imp = new Imports(backdots); - String prefix = "theme/" + theme + '/'; - for(String f : ls) { - if(f.endsWith(".js")) { - imp.js(prefix + f); - } else if(f.endsWith(".css")) { - if(f.endsWith("iPhone.css")) { - if(BROWSER.iPhone.equals(browser)) { - imp.css(prefix + f); - } - } else if (f.endsWith("Desktop.css")){ - if(!BROWSER.iPhone.equals(browser)) { - imp.css(prefix + f); - } - // Make Console specific to Console page - } else if (!"console.js".equals(f)) { - imp.css(prefix + f); - } - } - } - return imp; + List ls = getThemeFiles(env,theme); + Imports imp = new Imports(backdots); + String prefix = "theme/" + theme + '/'; + for(String f : ls) { + if(f.endsWith(".js")) { + imp.js(prefix + f); + } else if(f.endsWith(".css")) { + if(f.endsWith("iPhone.css")) { + if(BROWSER.iPhone.equals(browser)) { + imp.css(prefix + f); + } + } else if (f.endsWith("Desktop.css")){ + if(!BROWSER.iPhone.equals(browser)) { + imp.css(prefix + f); + } + // Make Console specific to Console page + } else if (!"console.js".equals(f)) { + imp.css(prefix + f); + } + } + } + return imp; } @Override @@ -284,36 +284,36 @@ public class Page extends HTMLCacheGen { cache.dynamic(hgen, new DynamicCode() { @Override public void code(AAF_GUI state, AuthzTrans trans, final Cache cache, final HTMLGen hgen) throws APIException, IOException { - BROWSER browser = browser(trans,browserSlot); - String theme = null; - Cookie[] cookies = trans.hreq().getCookies(); - if(cookies!=null) { - for(Cookie c : cookies) { - if(AAF_GUI_THEME.equals(c.getName())) { - theme=c.getValue(); - if(!(themes.containsKey(theme))) { - theme = defaultTheme; - } - break; - } - } - } - - if(theme==null) { - for(String t : themes.keySet()) { - if(!t.equals(defaultTheme) && trans.fish(new AAFPermission(null,trans.user()+":id", AAF_GUI_THEME, t))) { - theme=t; - break; - } - } - if(theme==null) { - theme = defaultTheme; - } - Cookie cookie = new Cookie(AAF_GUI_THEME,theme); - cookie.setMaxAge(604_800); // one week - trans.hresp().addCookie(cookie); - } - trans.setProperty(Page.AAF_THEME, theme); + BROWSER browser = browser(trans,browserSlot); + String theme = null; + Cookie[] cookies = trans.hreq().getCookies(); + if(cookies!=null) { + for(Cookie c : cookies) { + if(AAF_GUI_THEME.equals(c.getName())) { + theme=c.getValue(); + if(!(themes.containsKey(theme))) { + theme = defaultTheme; + } + break; + } + } + } + + if(theme==null) { + for(String t : themes.keySet()) { + if(!t.equals(defaultTheme) && trans.fish(new AAFPermission(null,trans.user()+":id", AAF_GUI_THEME, t))) { + theme=t; + break; + } + } + if(theme==null) { + theme = defaultTheme; + } + Cookie cookie = new Cookie(AAF_GUI_THEME,theme); + cookie.setMaxAge(604_800); // one week + trans.hresp().addCookie(cookie); + } + trans.setProperty(Page.AAF_THEME, theme); hgen.imports(getImports(env,theme,backdots,browser)); switch(browser) { @@ -404,17 +404,17 @@ public class Page extends HTMLCacheGen { cache.dynamic(hgen, new DynamicCode() { @Override public void code(AAF_GUI state, AuthzTrans trans,Cache cache, HTMLGen xgen) throws APIException, IOException { - String theme = trans.getProperty(Page.AAF_THEME); - Properties props; - if(theme==null) { - props = null; - } else { - props = themeProps==null?null:themeProps.get(theme); - } - - if(props!=null && "TRUE".equalsIgnoreCase(props.getProperty("enable_nav_btn"))) { - xgen.leaf("button", "id=navBtn").end(); - } + String theme = trans.getProperty(Page.AAF_THEME); + Properties props; + if(theme==null) { + props = null; + } else { + props = themeProps==null?null:themeProps.get(theme); + } + + if(props!=null && "TRUE".equalsIgnoreCase(props.getProperty("enable_nav_btn"))) { + xgen.leaf("button", "id=navBtn").end(); + } } }); // Adding "nav Hamburger button" @@ -423,64 +423,64 @@ public class Page extends HTMLCacheGen { cache.dynamic(hgen, new DynamicCode() { @Override public void code(AAF_GUI state, AuthzTrans trans,Cache cache, HTMLGen xgen) throws APIException, IOException { - String theme = trans.getProperty(Page.AAF_THEME); - Properties props; - if(theme==null) { - props = null; - } 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(); - Mark mark = new Mark(); - boolean selected = isSelected(trans.path(),Home.HREF); - //trans.path().endsWith("home"); - xgen.incr(mark,HTMLGen.UL) - .incr(HTMLGen.LI,selected?"class=selected":"") - .incr(HTMLGen.A, "href=home") - .text("Home") - .end(2); - boolean noSelection = !selected; - for(String[] mi : MENU_ITEMS) { - //selected = trans.path().endsWith(mi[0]); - if(noSelection) { - selected = isSelected(trans.path(),mi[2]); - noSelection = !selected; - } else { - selected = false; - } - xgen.incr(HTMLGen.LI,selected?"class=selected":"") - .incr(HTMLGen.A, "href="+mi[2]) - .text(mi[1]) - .end(2); - } - xgen.end(mark); - } - } + String theme = trans.getProperty(Page.AAF_THEME); + Properties props; + if(theme==null) { + props = null; + } 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(); + Mark mark = new Mark(); + boolean selected = isSelected(trans.path(),Home.HREF); + //trans.path().endsWith("home"); + xgen.incr(mark,HTMLGen.UL) + .incr(HTMLGen.LI,selected?"class=selected":"") + .incr(HTMLGen.A, "href=home") + .text("Home") + .end(2); + boolean noSelection = !selected; + for(String[] mi : MENU_ITEMS) { + //selected = trans.path().endsWith(mi[0]); + if(noSelection) { + selected = isSelected(trans.path(),mi[2]); + noSelection = !selected; + } else { + selected = false; + } + xgen.incr(HTMLGen.LI,selected?"class=selected":"") + .incr(HTMLGen.A, "href="+mi[2]) + .text(mi[1]) + .end(2); + } + xgen.end(mark); + } + } } - private boolean isSelected(String path, String item) { - if(item.equals(path)) { - return true; - } else { - for(ContentCode c : content) { - if(c instanceof BreadCrumbs) { - Page[] bc = ((BreadCrumbs)c).breadcrumbs; - if(bc!=null) { - for(int i = bc.length-1;i>0;--i) { - if(bc[i].url().equals(item)) { - return true; - } - } - return false; - } - } - } - } - return false; - } + private boolean isSelected(String path, String item) { + if(item.equals(path)) { + return true; + } else { + for(ContentCode c : content) { + if(c instanceof BreadCrumbs) { + Page[] bc = ((BreadCrumbs)c).breadcrumbs; + if(bc!=null) { + for(int i = bc.length-1;i>0;--i) { + if(bc[i].url().equals(item)) { + return true; + } + } + return false; + } + } + } + } + return false; + } }); hgen.incr("h2").text("Related Links").end(); hgen.incr(UL); diff --git a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/ApprovalForm.java b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/ApprovalForm.java index 332ecafe..cb868b16 100644 --- a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/ApprovalForm.java +++ b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/ApprovalForm.java @@ -121,7 +121,7 @@ public class ApprovalForm extends Page { private static final String[] headers = new String[] {"Identity","Request","Approve","Deny"}; private Slot sUser; private Slot sAsDelegate; - private Slot sAsUser; + private Slot sAsUser; public Model(AuthzEnv env) { sUser = env.slot(NAME+".user"); @@ -141,9 +141,9 @@ public class ApprovalForm extends Page { final String asDelegate = trans.get(sAsDelegate, null); final String approver; if(asDelegate==null) { - approver = trans.get(sAsUser,trans.user()); + approver = trans.get(sAsUser,trans.user()); } else { - approver = asDelegate; + approver = asDelegate; } ArrayList rv = new ArrayList<>(); @@ -207,107 +207,107 @@ public class ApprovalForm extends Page { Identity iapprover = trans.org().getIdentity(trans,currApproverList.get(0).getApprover()); if(iapprover==null) { - rv.add(new AbsCell[] { - new TextCell(currApproverList.get(0).getApprover() + " is not part of Organization", + rv.add(new AbsCell[] { + new TextCell(currApproverList.get(0).getApprover() + " is not part of Organization", new String[] {"colspan=4", "class=head"}) - }); + }); } else { - if (!iapprover.fullID().equals(trans.user())) { - - AbsCell[] approverHeader; - // if (domainOfUser.equals(domainOfApprover)) { - // approverHeader = new AbsCell[] { - // new TextAndRefCell("Approvals Delegated to Me by ", currApproverFull, - // TODO_ILM_INFO + currApproverShort, - // true, - // new String[] {"colspan=4", "class=head"}) - // }; - // } else { - approverHeader = new AbsCell[] { - new TextCell("Approvals Delegated to Me by " + iapprover.fullName() - + '(' + iapprover.id() + ')', - new String[] {"colspan=4", "class=head"}) - }; - // } - rv.add(approverHeader); - } - - // Sort by User Requesting - Collections.sort(currApproverList, new Comparator() { - @Override - public int compare(Approval a1, Approval a2) { - return a1.getUser().compareTo(a2.getUser()); - } - }); - - String prevUser = null; - boolean userOK=true; - for (Approval appr : currApproverList) { - if (++line() { + @Override + public int compare(Approval a1, Approval a2) { + return a1.getUser().compareTo(a2.getUser()); + } + }); + + String prevUser = null; + boolean userOK=true; + for (Approval appr : currApproverList) { + if (++line0) { - msg = "After these, there will be " + numLeft + " approvals left to process"; - } - if (rv.isEmpty()) { - if (numLeft>0) { - msg = "No Approvals to process at this time for user " + userParam +". You have " - + numLeft + " other approvals to process."; - } else { - msg = "No Approvals to process at this time"; - } - } + } else { + ++numLeft; + } + } + } + if (numLeft>0) { + msg = "After these, there will be " + numLeft + " approvals left to process"; + } + if (rv.isEmpty()) { + if (numLeft>0) { + msg = "No Approvals to process at this time for user " + userParam +". You have " + + numLeft + " other approvals to process."; + } else { + msg = "No Approvals to process at this time"; + } + } } } catch (Exception e) { trans.error().log(e); diff --git a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/CMArtiChangeAction.java b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/CMArtiChangeAction.java index f67f6d5c..c6821199 100644 --- a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/CMArtiChangeAction.java +++ b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/CMArtiChangeAction.java @@ -73,7 +73,7 @@ public class CMArtiChangeAction extends Page { cache.dynamic(hgen, new DynamicCode() { @Override public void code(final AAF_GUI gui, final AuthzTrans trans,final Cache cache, final HTMLGen hgen) throws APIException, IOException { - trans.info().log("Step 1"); + trans.info().log("Step 1"); final Artifact arti = new Artifact(); final String machine = trans.get(sMachine,null); final String ca = trans.get(sCA, null); @@ -86,26 +86,26 @@ public class CMArtiChangeAction extends Page { // These checks to not apply to deletions if(!CMArtiChangeForm.DELETE.equals(trans.get(sCmd, ""))) { - // Disallow IP entries, except by special Permission - if (!trans.fish(getPerm(ca,"ip"))) { - boolean ok=true; - if (IPValidator.ip(machine)) { - ok=false; - } - if (ok) { - for (String s: arti.getSans()) { - if (IPValidator.ip(s)) { - ok=false; - break; - } - } - } - if (!ok) { - hgen.p("Policy Failure: IPs in certificates are only allowed by Exception."); - return; - } - } - + // Disallow IP entries, except by special Permission + if (!trans.fish(getPerm(ca,"ip"))) { + boolean ok=true; + if (IPValidator.ip(machine)) { + ok=false; + } + if (ok) { + for (String s: arti.getSans()) { + if (IPValidator.ip(s)) { + ok=false; + break; + } + } + } + if (!ok) { + hgen.p("Policy Failure: IPs in certificates are only allowed by Exception."); + return; + } + } + } arti.setMechid((String)trans.get(sID,null)); @@ -192,18 +192,18 @@ public class CMArtiChangeAction extends Page { if(f.body().contains("%") ) { hgen.p(Vars.convert(err.getText(),err.getVariables())); } else { - int colon = err.getText().indexOf(':'); - if(colon>0) { - hgen.p(err.getMessageId() + ": " + err.getText().substring(0, colon)); - Mark bq = new Mark(); - hgen.incr(bq,"blockquote"); - for(String em : Split.splitTrim('\n', err.getText().substring(colon+1))) { - hgen.p(em); - } - hgen.end(bq); - } else { - hgen.p(err.getMessageId() + ": " + err.getText()); - } + int colon = err.getText().indexOf(':'); + if(colon>0) { + hgen.p(err.getMessageId() + ": " + err.getText().substring(0, colon)); + Mark bq = new Mark(); + hgen.incr(bq,"blockquote"); + for(String em : Split.splitTrim('\n', err.getText().substring(colon+1))) { + hgen.p(em); + } + hgen.end(bq); + } else { + hgen.p(err.getMessageId() + ": " + err.getText()); + } } } else { hgen.p(arti.getMechid() + " on " + arti.getMachine() + ": " + f.body()); diff --git a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/Home.java b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/Home.java index 73e118a2..3553da2b 100644 --- a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/Home.java +++ b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/Home.java @@ -38,7 +38,7 @@ import org.onap.aaf.misc.xgen.html.HTMLGen; public class Home extends Page { public static final String HREF = "/gui/home"; - public Home(final AAF_GUI gui) throws APIException, IOException { + public Home(final AAF_GUI gui) throws APIException, IOException { super(gui.env,"Home",HREF, NO_FIELDS, new NamedCode(false,"content") { @Override public void code(final Cache cache, final HTMLGen htmlGen) throws APIException, IOException { @@ -57,7 +57,7 @@ public class Home extends Page { final Mark pages = htmlGen.divID("Pages"); htmlGen.leaf(H3).text("Choose from the following:").end(); for(String[] mi : MENU_ITEMS) { - htmlGen.leaf(A,"href="+mi[0]).text(mi[1]).end(); + htmlGen.leaf(A,"href="+mi[0]).text(mi[1]).end(); } htmlGen.end(pages); } diff --git a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/PendingRequestsShow.java b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/PendingRequestsShow.java index ae5fe375..585a75ae 100644 --- a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/PendingRequestsShow.java +++ b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/PendingRequestsShow.java @@ -72,53 +72,53 @@ public class PendingRequestsShow extends Page { } private static final class TopOfPage extends NamedCode { - private Slot sAsUser; + private Slot sAsUser; - private TopOfPage(AuthzEnv env, boolean no_cache, String name) { - super(no_cache, name); - sAsUser = env.slot(AS_USER); - } + private TopOfPage(AuthzEnv env, boolean no_cache, String name) { + super(no_cache, name); + sAsUser = env.slot(AS_USER); + } - @Override - public void code(final Cache cache, final HTMLGen hgen) throws APIException, IOException { - cache.dynamic(hgen, new DynamicCode() { - @Override - public void code(final AAF_GUI gui, final AuthzTrans trans, final Cache cache, final HTMLGen hgen) throws APIException, IOException { - String user = trans.get(sAsUser,null); - if(user==null) { - user=trans.user(); - } else { - hgen.incr(HTMLGen.H3,"class=center").text("Displaying for " + user).end(); - } + @Override + public void code(final Cache cache, final HTMLGen hgen) throws APIException, IOException { + cache.dynamic(hgen, new DynamicCode() { + @Override + public void code(final AAF_GUI gui, final AuthzTrans trans, final Cache cache, final HTMLGen hgen) throws APIException, IOException { + String user = trans.get(sAsUser,null); + if(user==null) { + user=trans.user(); + } else { + hgen.incr(HTMLGen.H3,"class=center").text("Displaying for " + user).end(); + } - hgen - .leaf(HTMLGen.P, "class=expedite_request").text("These are your submitted Requests that are awaiting Approval. ") - .br() - .text("To Expedite a Request: ") - .leaf("a","href=#expedite_directions","onclick=divVisibility('expedite_directions');") - .text("Click Here").end() - .divID("expedite_directions", "style=display:none"); - - hgen - .incr(HTMLGen.OL) - .incr(HTMLGen.LI) - .leaf("a","href="+ApprovalForm.HREF+"?user="+user, "id=userApprove") - .text("Copy This Link") - .end() - .end() - .incr(HTMLGen.LI) - .text("Send it to the Approver Listed") - .end() - .end() - .text("NOTE: Using this link, the Approver will only see your requests. You only need to send this link once!") - .end() - .end(); - } - }); + hgen + .leaf(HTMLGen.P, "class=expedite_request").text("These are your submitted Requests that are awaiting Approval. ") + .br() + .text("To Expedite a Request: ") + .leaf("a","href=#expedite_directions","onclick=divVisibility('expedite_directions');") + .text("Click Here").end() + .divID("expedite_directions", "style=display:none"); + + hgen + .incr(HTMLGen.OL) + .incr(HTMLGen.LI) + .leaf("a","href="+ApprovalForm.HREF+"?user="+user, "id=userApprove") + .text("Copy This Link") + .end() + .end() + .incr(HTMLGen.LI) + .text("Send it to the Approver Listed") + .end() + .end() + .text("NOTE: Using this link, the Approver will only see your requests. You only need to send this link once!") + .end() + .end(); + } + }); } - } + } - /** + /** * Implement the Table Content for Requests by User * * @author Jeremiah @@ -126,7 +126,7 @@ public class PendingRequestsShow extends Page { */ private static class Model extends TableData { final long NUM_100NS_INTERVALS_SINCE_UUID_EPOCH = 0x01b21dd213814000L; - private final Slot sAsUser; + private final Slot sAsUser; private static final String[] headers = new String[] {"Request Date","Status","Memo","Approver"}; public Model(AuthzEnv env) { @@ -145,7 +145,7 @@ public class PendingRequestsShow extends Page { gui.clientAsUser(trans.getUserPrincipal(), new Retryable() { @Override public Void code(Rcli client)throws CadiException, ConnectException, APIException { - final String user = trans.get(sAsUser,trans.user()); + final String user = trans.get(sAsUser,trans.user()); TimeTaken tt = trans.start("AAF Get Approvals by User",Env.REMOTE); try { diff --git a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/RequestDetail.java b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/RequestDetail.java index 8628d4be..8b6c1376 100644 --- a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/RequestDetail.java +++ b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/RequestDetail.java @@ -97,18 +97,18 @@ public class RequestDetail extends Page { ); if (fa.get(AAF_GUI.TIMEOUT)) { - Approval app = fa.value.getApprovals().get(0); - if(app==null) { - return Cells.EMPTY; - } else { - if (!(trans.user().equals(app.getUser()) || - trans.user().equals(app.getApprover()))) { - HttpServletRequest req = trans.get(gui.slot_httpServletRequest,null); - if(req==null || !req.isUserInRole(Define.ROOT_NS()+"|access|*|*")) { - return Cells.EMPTY; - } - } - } + Approval app = fa.value.getApprovals().get(0); + if(app==null) { + return Cells.EMPTY; + } else { + if (!(trans.user().equals(app.getUser()) || + trans.user().equals(app.getApprover()))) { + HttpServletRequest req = trans.get(gui.slot_httpServletRequest,null); + if(req==null || !req.isUserInRole(Define.ROOT_NS()+"|access|*|*")) { + return Cells.EMPTY; + } + } + } tt.done(); tt = trans.start("Load Data", Env.SUB); boolean first = true; diff --git a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/RoleDetail.java b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/RoleDetail.java index 6588de54..dcf0f928 100644 --- a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/RoleDetail.java +++ b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/RoleDetail.java @@ -107,9 +107,9 @@ public class RoleDetail extends Page { final String pRole = trans.get(sRoleName, null); Validator v = new Validator(); if(!v.isNull("Role",pRole).err()) { - if(!pRole.startsWith(trans.user())) { - v.role(pRole); - } + if(!pRole.startsWith(trans.user())) { + v.role(pRole); + } } if (v.err()) { trans.warn().printf("Error in PermDetail Request: %s", v.errs()); diff --git a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/WebCommand.java b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/WebCommand.java index d0e834a5..73f4981c 100644 --- a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/WebCommand.java +++ b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/WebCommand.java @@ -43,8 +43,8 @@ public class WebCommand extends Page { super(gui.env, "Web Command Client",HREF, NO_FIELDS, new BreadCrumbs(breadcrumbs), new NamedCode(true, "content") { - StaticSlot sThemeWebPath = gui.env.staticSlot(CachingFileAccess.CFA_WEB_PATH); - StaticSlot sTheme = gui.env.staticSlot(AAF_GUI.AAF_GUI_THEME); + StaticSlot sThemeWebPath = gui.env.staticSlot(CachingFileAccess.CFA_WEB_PATH); + StaticSlot sTheme = gui.env.staticSlot(AAF_GUI.AAF_GUI_THEME); @Override public void code(final Cache cache, final HTMLGen hgen) throws APIException, IOException { hgen.leaf("p","id=help_msg") @@ -64,7 +64,7 @@ public class WebCommand extends Page { @Override public void code(AAF_GUI state, AuthzTrans trans, Cache cache, HTMLGen xgen) throws APIException, IOException { - String image_root = "src=../../"+state.env.get(sThemeWebPath).toString() + '/' + state.env.get(sTheme) + "/images/icons"; + String image_root = "src=../../"+state.env.get(sThemeWebPath).toString() + '/' + state.env.get(sTheme) + "/images/icons"; hgen.img(image_root + "/options_down.png", "onclick=handleDivHiding('options',this);", "id=options_img", "alt=Options", "title=Options") .end(); //options_link diff --git a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/table/TextToolTipCell.java b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/table/TextToolTipCell.java index 986b8245..5eaa69d1 100644 --- a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/table/TextToolTipCell.java +++ b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/table/TextToolTipCell.java @@ -31,7 +31,7 @@ import org.onap.aaf.misc.xgen.html.HTMLGen; public class TextToolTipCell extends AbsCell { public final String name; private final String[] attrs; - private final String tooltip; + private final String tooltip; public TextToolTipCell(String name, String tooltip, String... attributes) { attrs = attributes; diff --git a/auth/auth-gui/src/test/java/org/onap/aaf/auth/gui/JU_FormTest.java b/auth/auth-gui/src/test/java/org/onap/aaf/auth/gui/JU_FormTest.java index 0f348f39..fa95bc25 100644 --- a/auth/auth-gui/src/test/java/org/onap/aaf/auth/gui/JU_FormTest.java +++ b/auth/auth-gui/src/test/java/org/onap/aaf/auth/gui/JU_FormTest.java @@ -33,31 +33,31 @@ import org.onap.aaf.misc.xgen.html.HTMLGen; public class JU_FormTest { - @Mock - private Cache cache; + @Mock + private Cache cache; - @Mock - private HTMLGen hgen; + @Mock + private HTMLGen hgen; - @Before - public void setUp() throws Exception { - initMocks(this); - } + @Before + public void setUp() throws Exception { + initMocks(this); + } - @Test - public void test() throws Exception { - when(hgen.incr("p", "class=preamble")).thenReturn(hgen); - when(hgen.text("preamable")).thenReturn(hgen); - when(hgen.tagOnly("input", "type=submit", "value=Submit")).thenReturn(hgen); - when(hgen.tagOnly("input", "type=reset", "value=Reset")).thenReturn(hgen); + @Test + public void test() throws Exception { + when(hgen.incr("p", "class=preamble")).thenReturn(hgen); + when(hgen.text("preamable")).thenReturn(hgen); + when(hgen.tagOnly("input", "type=submit", "value=Submit")).thenReturn(hgen); + when(hgen.tagOnly("input", "type=reset", "value=Reset")).thenReturn(hgen); - Form form = new Form(false, new BreadCrumbs(null)); + Form form = new Form(false, new BreadCrumbs(null)); - assertThat(form.idattrs(), equalTo(new String[] { "breadcrumbs" })); + assertThat(form.idattrs(), equalTo(new String[] { "breadcrumbs" })); - assertThat(form.preamble("preamable"), equalTo(form)); + assertThat(form.preamble("preamable"), equalTo(form)); - form.code(cache, hgen); - } + form.code(cache, hgen); + } } diff --git a/auth/auth-gui/src/test/java/org/onap/aaf/auth/gui/JU_TableTest.java b/auth/auth-gui/src/test/java/org/onap/aaf/auth/gui/JU_TableTest.java index b13f6d30..ec39916b 100644 --- a/auth/auth-gui/src/test/java/org/onap/aaf/auth/gui/JU_TableTest.java +++ b/auth/auth-gui/src/test/java/org/onap/aaf/auth/gui/JU_TableTest.java @@ -39,33 +39,33 @@ import org.onap.aaf.misc.xgen.html.HTMLGen; public class JU_TableTest { - @Mock - private TransStore trans; - private Code other; - @Mock - private Data data; - @Mock - private Cache cache; - @Mock - private HTMLGen hgen; + @Mock + private TransStore trans; + private Code other; + @Mock + private Data data; + @Mock + private Cache cache; + @Mock + private HTMLGen hgen; - @Before - public void setUp() throws Exception { - initMocks(this); - } + @Before + public void setUp() throws Exception { + initMocks(this); + } - @Test - public void test() throws APIException, IOException { - when(hgen.leaf("caption", "class=title")).thenReturn(hgen); - when(hgen.text("title")).thenReturn(hgen); - when(data.headers()).thenReturn(new String[0]); + @Test + public void test() throws APIException, IOException { + when(hgen.leaf("caption", "class=title")).thenReturn(hgen); + when(hgen.text("title")).thenReturn(hgen); + when(data.headers()).thenReturn(new String[0]); - Table table = new Table("title", trans, data, other, "name", "attr1", "attr1"); - Table.Cells cells = new Table.Cells(new ArrayList(), ""); + Table table = new Table("title", trans, data, other, "name", "attr1", "attr1"); + Table.Cells cells = new Table.Cells(new ArrayList(), ""); - table.code(cache, hgen); + table.code(cache, hgen); - verify(hgen).end(); - } + verify(hgen).end(); + } } diff --git a/auth/auth-gui/src/test/java/org/onap/aaf/auth/gui/table/JU_UICellTest.java b/auth/auth-gui/src/test/java/org/onap/aaf/auth/gui/table/JU_UICellTest.java index c6b92f7c..3cf6b723 100644 --- a/auth/auth-gui/src/test/java/org/onap/aaf/auth/gui/table/JU_UICellTest.java +++ b/auth/auth-gui/src/test/java/org/onap/aaf/auth/gui/table/JU_UICellTest.java @@ -34,137 +34,137 @@ import org.onap.aaf.auth.gui.table.CheckBoxCell.ALIGN; import org.onap.aaf.misc.xgen.html.HTMLGen; public class JU_UICellTest { - @Mock - private HTMLGen hgen; + @Mock + private HTMLGen hgen; - @Before - public void setUp() throws Exception { - initMocks(this); - } + @Before + public void setUp() throws Exception { + initMocks(this); + } - @Test - public void testButtonCell() { - String[] attrs = { "type=button", "value=null", "attribute1", "attribute2" }; - ButtonCell cell = new ButtonCell(null, "attribute1", "attribute2"); + @Test + public void testButtonCell() { + String[] attrs = { "type=button", "value=null", "attribute1", "attribute2" }; + ButtonCell cell = new ButtonCell(null, "attribute1", "attribute2"); - when(hgen.incr("input", true, attrs)).thenReturn(hgen); + when(hgen.incr("input", true, attrs)).thenReturn(hgen); - cell.write(hgen); + cell.write(hgen); - AbsCell.Null.write(hgen); + AbsCell.Null.write(hgen); - assertThat(AbsCell.Null.attrs(), equalTo(new String[0])); + assertThat(AbsCell.Null.attrs(), equalTo(new String[0])); - assertThat(cell.attrs(), equalTo(AbsCell.CENTER)); + assertThat(cell.attrs(), equalTo(AbsCell.CENTER)); - verify(hgen).end(); - } + verify(hgen).end(); + } - @Test - public void testCheckBoxCellWithoutAlign() { - String[] attrs = { "type=checkbox", "name=name", "value=attribute1", "attribute2" }; - CheckBoxCell cell = new CheckBoxCell("name", "attribute1", "attribute2"); + @Test + public void testCheckBoxCellWithoutAlign() { + String[] attrs = { "type=checkbox", "name=name", "value=attribute1", "attribute2" }; + CheckBoxCell cell = new CheckBoxCell("name", "attribute1", "attribute2"); - cell.write(hgen); + cell.write(hgen); - assertThat(cell.attrs(), equalTo(AbsCell.CENTER)); + assertThat(cell.attrs(), equalTo(AbsCell.CENTER)); - verify(hgen).tagOnly("input", attrs); - } + verify(hgen).tagOnly("input", attrs); + } - @Test - public void testCheckBoxCellWithLeftAlign() { - String[] attrs = { "type=checkbox", "name=name", "value=attribute1", "attribute2" }; - CheckBoxCell cell = new CheckBoxCell("name", ALIGN.left, "attribute1", "attribute2"); + @Test + public void testCheckBoxCellWithLeftAlign() { + String[] attrs = { "type=checkbox", "name=name", "value=attribute1", "attribute2" }; + CheckBoxCell cell = new CheckBoxCell("name", ALIGN.left, "attribute1", "attribute2"); - cell.write(hgen); + cell.write(hgen); - assertThat(cell.attrs(), equalTo(AbsCell.LEFT)); + assertThat(cell.attrs(), equalTo(AbsCell.LEFT)); - verify(hgen).tagOnly("input", attrs); - } + verify(hgen).tagOnly("input", attrs); + } - @Test - public void testCheckBoxCellWithRightAlign() { - String[] attrs = { "type=checkbox", "name=name", "value=attribute1", "attribute2" }; - CheckBoxCell cell = new CheckBoxCell("name", ALIGN.right, "attribute1", "attribute2"); + @Test + public void testCheckBoxCellWithRightAlign() { + String[] attrs = { "type=checkbox", "name=name", "value=attribute1", "attribute2" }; + CheckBoxCell cell = new CheckBoxCell("name", ALIGN.right, "attribute1", "attribute2"); - cell.write(hgen); + cell.write(hgen); - assertThat(cell.attrs(), equalTo(AbsCell.RIGHT)); + assertThat(cell.attrs(), equalTo(AbsCell.RIGHT)); - verify(hgen).tagOnly("input", attrs); - } + verify(hgen).tagOnly("input", attrs); + } - @Test - public void testRadioCell() { - String[] attrs = { "type=radio", "name=name", "class=attribute1", "value=attribute2" }; - RadioCell cell = new RadioCell("name", "attribute1", "attribute2"); + @Test + public void testRadioCell() { + String[] attrs = { "type=radio", "name=name", "class=attribute1", "value=attribute2" }; + RadioCell cell = new RadioCell("name", "attribute1", "attribute2"); - cell.write(hgen); + cell.write(hgen); - assertThat(cell.attrs(), equalTo(AbsCell.CENTER)); + assertThat(cell.attrs(), equalTo(AbsCell.CENTER)); - verify(hgen).tagOnly("input", attrs); - } + verify(hgen).tagOnly("input", attrs); + } - @Test - public void testRefCellWithNewWindow() { - String[] attrs = { "href=attribute1", "attribute2", null }; - RefCell cell = new RefCell("name", "attribute1", true, "attribute2"); + @Test + public void testRefCellWithNewWindow() { + String[] attrs = { "href=attribute1", "attribute2", null }; + RefCell cell = new RefCell("name", "attribute1", true, "attribute2"); - when(hgen.leaf(HTMLGen.A, attrs)).thenReturn(hgen); + when(hgen.leaf(HTMLGen.A, attrs)).thenReturn(hgen); - cell.write(hgen); + cell.write(hgen); - assertThat(cell.attrs(), equalTo(new String[0])); - } + assertThat(cell.attrs(), equalTo(new String[0])); + } - @Test - public void testRefCellWithoutNewWindow() { - String[] attrs = { "href=attribute1", "attribute2" }; - RefCell cell = new RefCell("name", "attribute1", false, "attribute2"); + @Test + public void testRefCellWithoutNewWindow() { + String[] attrs = { "href=attribute1", "attribute2" }; + RefCell cell = new RefCell("name", "attribute1", false, "attribute2"); - when(hgen.leaf(HTMLGen.A, attrs)).thenReturn(hgen); + when(hgen.leaf(HTMLGen.A, attrs)).thenReturn(hgen); - cell.write(hgen); + cell.write(hgen); - assertThat(cell.attrs(), equalTo(new String[0])); + assertThat(cell.attrs(), equalTo(new String[0])); - } + } - @Test - public void testTextAndRefCell() { - String[] attrs = { "href=href", "attribute1", null }; - String[] attributes = { "attribute1" }; - TextAndRefCell cell = new TextAndRefCell("text", "name", "href", true, attributes); + @Test + public void testTextAndRefCell() { + String[] attrs = { "href=href", "attribute1", null }; + String[] attributes = { "attribute1" }; + TextAndRefCell cell = new TextAndRefCell("text", "name", "href", true, attributes); - when(hgen.leaf(HTMLGen.A, attrs)).thenReturn(hgen); + when(hgen.leaf(HTMLGen.A, attrs)).thenReturn(hgen); - cell.write(hgen); + cell.write(hgen); - verify(hgen).text("text"); - } + verify(hgen).text("text"); + } - @Test - public void testTextCell() { - String[] attrs = { "href" }; - TextCell cell = new TextCell("name", "href"); + @Test + public void testTextCell() { + String[] attrs = { "href" }; + TextCell cell = new TextCell("name", "href"); - cell.write(hgen); + cell.write(hgen); - assertThat(cell.attrs(), equalTo(attrs)); + assertThat(cell.attrs(), equalTo(attrs)); - verify(hgen).text("name"); - } + verify(hgen).text("name"); + } - @Test - public void testTextInputCell() { - String[] attrs = { "href" }; - TextInputCell cell = new TextInputCell("name", "textClass", "value"); + @Test + public void testTextInputCell() { + String[] attrs = { "href" }; + TextInputCell cell = new TextInputCell("name", "textClass", "value"); - cell.write(hgen); + cell.write(hgen); - assertThat(cell.attrs(), equalTo(new String[0])); - } + assertThat(cell.attrs(), equalTo(new String[0])); + } } -- cgit 1.2.3-korg