summaryrefslogtreecommitdiffstats
path: root/auth/auth-gui
diff options
context:
space:
mode:
Diffstat (limited to 'auth/auth-gui')
-rw-r--r--auth/auth-gui/src/main/java/org/onap/aaf/auth/cui/CUI.java10
-rw-r--r--auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/AAF_GUI.java40
-rw-r--r--auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/Display.java18
-rw-r--r--auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/Page.java350
-rw-r--r--auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/ApprovalForm.java202
-rw-r--r--auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/CMArtiChangeAction.java66
-rw-r--r--auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/Home.java4
-rw-r--r--auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/PendingRequestsShow.java88
-rw-r--r--auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/RequestDetail.java24
-rw-r--r--auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/RoleDetail.java6
-rw-r--r--auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/WebCommand.java6
-rw-r--r--auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/table/TextToolTipCell.java2
-rw-r--r--auth/auth-gui/src/test/java/org/onap/aaf/auth/gui/JU_FormTest.java38
-rw-r--r--auth/auth-gui/src/test/java/org/onap/aaf/auth/gui/JU_TableTest.java46
-rw-r--r--auth/auth-gui/src/test/java/org/onap/aaf/auth/gui/table/JU_UICellTest.java178
15 files changed, 539 insertions, 539 deletions
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<AuthzTrans, Void> {
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<AuthzEnv, AuthzTrans> implements State<E
sThemeWebPath = env.staticSlot(CachingFileAccess.CFA_WEB_PATH);
if(env.get(sThemeWebPath)==null) {
- env.put(sThemeWebPath,"theme");
+ env.put(sThemeWebPath,"theme");
}
slot_httpServletRequest = env.slot(HTTP_SERVLET_REQUEST);
@@ -211,20 +211,20 @@ public class AAF_GUI extends AbsService<AuthzEnv, AuthzTrans> implements State<E
route(env, PUT, "/gui/cui", new CUI(this),"text/plain;charset=utf-8","*/*");
route(env, GET, "/gui/clear", new HttpCode<AuthzTrans, Void>(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<AuthzEnv, AuthzTrans> implements State<E
try {
new JettyServiceStarter<AuthzEnv,AuthzTrans>(
- 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<slots.length;++i) {
int idx = fields[i].indexOf("[]");
if (idx<0) { // single value
- if(asUser(trans, req,fields[i])) {
- trans.put(slots[i], req.getParameter(fields[i]));
- }
+ if(asUser(trans, req,fields[i])) {
+ trans.put(slots[i], req.getParameter(fields[i]));
+ }
} else { // multi value
String[] array = new String[30];
String field=fields[i].substring(0, idx);
@@ -132,13 +132,13 @@ public class Display {
* When the field is "as_user", make sure permission is granted
*/
private boolean asUser(AuthzTrans trans, HttpServletRequest req, String field) {
- if("as_user".equals(field)) {
- return req.isUserInRole(Define.ROOT_NS()+"|access|*|*");
- }
- return true;
- }
+ if("as_user".equals(field)) {
+ return req.isUserInRole(Define.ROOT_NS()+"|access|*|*");
+ }
+ return true;
+ }
- @Override
+ @Override
public boolean no_cache() {
return no_cache;
}
diff --git a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/Page.java b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/Page.java
index 9abd5ee0..96c0fc48 100644
--- a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/Page.java
+++ b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/Page.java
@@ -97,17 +97,17 @@ public class Page extends HTMLCacheGen {
* Relative path, Menu Name, Full Path
*/
protected static final String[][] MENU_ITEMS = new String[][] {
- {"myperms","My Permissions","/gui/myperms"},
- {"myroles","My Roles","/gui/myroles"},
- {"ns","My Namespaces","/gui/ns"},
- {"approve","My Approvals","/gui/approve"},
- {"myrequests","My Pending Requests","/gui/myrequests"},
- // Enable later
- // {"onboard","Onboarding"},
- {"passwd","Password Management","/gui/passwd"},
- {"cui","Command Prompt","/gui/cui"},
- {"api","AAF API","/gui/api"},
- {"clear","Clear Preferences","/gui/clear"}
+ {"myperms","My Permissions","/gui/myperms"},
+ {"myroles","My Roles","/gui/myroles"},
+ {"ns","My Namespaces","/gui/ns"},
+ {"approve","My Approvals","/gui/approve"},
+ {"myrequests","My Pending Requests","/gui/myrequests"},
+ // Enable later
+ // {"onboard","Onboarding"},
+ {"passwd","Password Management","/gui/passwd"},
+ {"cui","Command Prompt","/gui/cui"},
+ {"api","AAF API","/gui/api"},
+ {"clear","Clear Preferences","/gui/clear"}
};
public String name() {
@@ -168,16 +168,16 @@ public class Page extends HTMLCacheGen {
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 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<String,List<String>> themes;
- private static Map<String,Properties> themeProps;
+ private static Map<String,List<String>> themes;
+ private static Map<String,Properties> 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<String> 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<String> 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<String> 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<String> 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<String> 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<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);
- 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<HTMLGen,AAF_GUI,AuthzTrans>() {
@Override
public void code(AAF_GUI state, AuthzTrans trans,Cache<HTMLGen> 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<HTMLGen,AAF_GUI,AuthzTrans>() {
@Override
public void code(AAF_GUI state, AuthzTrans trans,Cache<HTMLGen> 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<AbsCell[]> 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<Approval>() {
- @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<MAX_LINE) { // limit number displayed at one time.
- AbsCell userCell;
- String user = appr.getUser();
-
- if (user.equals(prevUser)) {
- userCell = AbsCell.Null;
- } else if (user.endsWith(trans.org().getRealm())){
- userOK=true;
- String title;
- Organization org = OrganizationFactory.obtain(trans.env(), user);
- if (org==null) {
- title="";
- userCell = new TextCell(user);
- } else {
- Identity au = org.getIdentity(trans, user);
- if (au!=null) {
- if(au.isPerson()) {
- userCell = new TextToolTipCell(au.fullName(),"Identity: " + au.id());
- } else {
- Identity managedBy = au.responsibleTo();
- if (managedBy==null) {
- title ="Identity: " + au.type();
- } else {
- title="Sponsor: " + managedBy.fullName();
- }
- userCell = new TextToolTipCell(au.fullID(),title);
- }
- } else {
- userOK=false;
- title="Not a User at " + org.getName();
- userCell = new TextToolTipCell(user,title);
- }
- }
- // userCell = new RefCell(prevUser,
- // TODO_ILM_INFO+user.substring(0, user.length()-domainOfApprover.length()),
- // true,
- // title);
-
- } else {
- userCell = new TextCell(user);
- }
- AbsCell[] sa = new AbsCell[] {
- userCell,
- new TextCell(appr.getMemo()),
- userOK?new RadioCell("line."+ line,"approve", "approved|"+appr.getTicket()):new TextCell(""),
- new RadioCell("line."+ line,"deny", "denied|"+appr.getTicket())
- };
- rv.add(sa);
+ 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<Approval>() {
+ @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<MAX_LINE) { // limit number displayed at one time.
+ AbsCell userCell;
+ String user = appr.getUser();
+
+ if (user.equals(prevUser)) {
+ userCell = AbsCell.Null;
+ } else if (user.endsWith(trans.org().getRealm())){
+ userOK=true;
+ String title;
+ Organization org = OrganizationFactory.obtain(trans.env(), user);
+ if (org==null) {
+ title="";
+ userCell = new TextCell(user);
+ } else {
+ Identity au = org.getIdentity(trans, user);
+ if (au!=null) {
+ if(au.isPerson()) {
+ userCell = new TextToolTipCell(au.fullName(),"Identity: " + au.id());
+ } else {
+ Identity managedBy = au.responsibleTo();
+ if (managedBy==null) {
+ title ="Identity: " + au.type();
+ } else {
+ title="Sponsor: " + managedBy.fullName();
+ }
+ userCell = new TextToolTipCell(au.fullID(),title);
+ }
+ } else {
+ userOK=false;
+ title="Not a User at " + org.getName();
+ userCell = new TextToolTipCell(user,title);
+ }
+ }
+ // userCell = new RefCell(prevUser,
+ // TODO_ILM_INFO+user.substring(0, user.length()-domainOfApprover.length()),
+ // true,
+ // title);
+
+ } else {
+ userCell = new TextCell(user);
+ }
+ AbsCell[] sa = new AbsCell[] {
+ userCell,
+ new TextCell(appr.getMemo()),
+ userOK?new RadioCell("line."+ line,"approve", "approved|"+appr.getTicket()):new TextCell(""),
+ new RadioCell("line."+ line,"deny", "denied|"+appr.getTicket())
+ };
+ rv.add(sa);
prevUser=user;
- } 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";
- }
- }
+ } 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<HTMLGen,AAF_GUI, AuthzTrans>() {
@Override
public void code(final AAF_GUI gui, final AuthzTrans trans,final Cache<HTMLGen> 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<HTMLGen> 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<HTMLGen> cache, final HTMLGen hgen) throws APIException, IOException {
- cache.dynamic(hgen, new DynamicCode<HTMLGen, AAF_GUI, AuthzTrans>() {
- @Override
- public void code(final AAF_GUI gui, final AuthzTrans trans, final Cache<HTMLGen> 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<HTMLGen> cache, final HTMLGen hgen) throws APIException, IOException {
+ cache.dynamic(hgen, new DynamicCode<HTMLGen, AAF_GUI, AuthzTrans>() {
+ @Override
+ public void code(final AAF_GUI gui, final AuthzTrans trans, final Cache<HTMLGen> 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<AAF_GUI,AuthzTrans> {
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<Void>() {
@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<HTMLGen> 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<HTMLGen> 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<HTMLGen> cache;
+ @Mock
+ private Cache<HTMLGen> 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<HTMLGen> other;
- @Mock
- private Data data;
- @Mock
- private Cache cache;
- @Mock
- private HTMLGen hgen;
+ @Mock
+ private TransStore trans;
+ private Code<HTMLGen> 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]));
+ }
}