X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=auth%2Fauth-gui%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Faaf%2Fauth%2Fgui%2Fpages%2FRequestDetail.java;h=0d0d03ad72dd74282080858338679ff5c0e24456;hb=refs%2Fchanges%2F75%2F65275%2F1;hp=3e959ef5fba5368d2813716cb7daa0179766c8d8;hpb=824dc7b5fc0e1ccdf7f460479aff344727f0f01e;p=aaf%2Fauthz.git 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 3e959ef5..0d0d03ad 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 @@ -51,124 +51,124 @@ import aaf.v2_0.Approval; import aaf.v2_0.Approvals; public class RequestDetail extends Page { - public static final String HREF = "/gui/requestdetail"; - public static final String NAME = "RequestDetail"; - private static final String DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss"; - public static final String[] FIELDS = {"ticket"}; + public static final String HREF = "/gui/requestdetail"; + public static final String NAME = "RequestDetail"; + private static final String DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss"; + public static final String[] FIELDS = {"ticket"}; - public RequestDetail(final AAF_GUI gui, Page ... breadcrumbs) throws APIException, IOException { - super(gui.env, NAME, HREF, FIELDS, - new BreadCrumbs(breadcrumbs), - new Table("Request Details",gui.env.newTransNoAvg(),new Model(gui.env),"class=detail") - ); - } + public RequestDetail(final AAF_GUI gui, Page ... breadcrumbs) throws APIException, IOException { + super(gui.env, NAME, HREF, FIELDS, + new BreadCrumbs(breadcrumbs), + new Table("Request Details",gui.env.newTransNoAvg(),new Model(gui.env),"class=detail") + ); + } - /** - * Implement the table content for Request Detail - * - * @author Jeremiah - * - */ - private static class Model extends TableData { - final long NUM_100NS_INTERVALS_SINCE_UUID_EPOCH = 0x01b21dd213814000L; - private Slot sTicket; - public Model(AuthzEnv env) { - sTicket = env.slot(NAME+".ticket"); - } + /** + * Implement the table content for Request Detail + * + * @author Jeremiah + * + */ + private static class Model extends TableData { + final long NUM_100NS_INTERVALS_SINCE_UUID_EPOCH = 0x01b21dd213814000L; + private Slot sTicket; + public Model(AuthzEnv env) { + sTicket = env.slot(NAME+".ticket"); + } - @Override - public Cells get(final AuthzTrans trans, final AAF_GUI gui) { - Cells rv=Cells.EMPTY; - final String ticket = trans.get(sTicket, null); - if(ticket!=null) { - try { - rv = gui.clientAsUser(trans.getUserPrincipal(), new Retryable() { - @Override - public Cells code(Rcli client) throws CadiException, ConnectException, APIException { - TimeTaken tt = trans.start("AAF Approval Details",Env.REMOTE); - ArrayList rv = new ArrayList<>(); - try { - Future fa = client.read( - "/authz/approval/ticket/"+ticket, - gui.getDF(Approvals.class) - ); - - if(fa.get(AAF_GUI.TIMEOUT)) { - if (!trans.user().equals(fa.value.getApprovals().get(0).getUser())) { - return Cells.EMPTY; - } - tt.done(); - tt = trans.start("Load Data", Env.SUB); - boolean first = true; - for ( Approval approval : fa.value.getApprovals()) { - AbsCell[] approverLine = new AbsCell[4]; - // only print common elements once - if (first) { - DateFormat createdDF = new SimpleDateFormat(DATE_TIME_FORMAT); - UUID id = UUID.fromString(approval.getId()); - - rv.add(new AbsCell[]{new TextCell("Ticket ID:"),new TextCell(approval.getTicket(),"colspan=3")}); - rv.add(new AbsCell[]{new TextCell("Memo:"),new TextCell(approval.getMemo(),"colspan=3")}); - rv.add(new AbsCell[]{new TextCell("Requested On:"), - new TextCell(createdDF.format((id.timestamp() - NUM_100NS_INTERVALS_SINCE_UUID_EPOCH)/10000),"colspan=3") - }); - rv.add(new AbsCell[]{new TextCell("Operation:"),new TextCell(decodeOp(approval.getOperation()),"colspan=3")}); - String user = approval.getUser(); - rv.add(new AbsCell[]{new TextCell("User:"),new TextCell(user,"colspan=3")}); - - // headers for listing each approver - rv.add(new AbsCell[]{new TextCell(" ","colspan=4","class=blank_line")}); - rv.add(new AbsCell[]{AbsCell.Null, - new TextCell("Approver","class=bold"), - new TextCell("Type","class=bold"), - new TextCell("Status","class=bold")}); - approverLine[0] = new TextCell("Approvals:"); - - first = false; - } else { - approverLine[0] = AbsCell.Null; - } - - approverLine[1] = new TextCell(approval.getApprover()); - String type = approval.getType(); - if ("owner".equalsIgnoreCase(type)) { - type = "resource owner"; - } - - approverLine[2] = new TextCell(type); - approverLine[3] = new TextCell(approval.getStatus()); - rv.add(approverLine); - - } - } else { - rv.add(new AbsCell[] {new TextCell("*** Data Unavailable ***")}); - } - } finally { - tt.done(); - } - return new Cells(rv,null); - } - }); - } catch (Exception e) { - trans.error().log(e); - } - } - return rv; - } + @Override + public Cells get(final AuthzTrans trans, final AAF_GUI gui) { + Cells rv=Cells.EMPTY; + final String ticket = trans.get(sTicket, null); + if(ticket!=null) { + try { + rv = gui.clientAsUser(trans.getUserPrincipal(), new Retryable() { + @Override + public Cells code(Rcli client) throws CadiException, ConnectException, APIException { + TimeTaken tt = trans.start("AAF Approval Details",Env.REMOTE); + ArrayList rv = new ArrayList<>(); + try { + Future fa = client.read( + "/authz/approval/ticket/"+ticket, + gui.getDF(Approvals.class) + ); + + if(fa.get(AAF_GUI.TIMEOUT)) { + if (!trans.user().equals(fa.value.getApprovals().get(0).getUser())) { + return Cells.EMPTY; + } + tt.done(); + tt = trans.start("Load Data", Env.SUB); + boolean first = true; + for ( Approval approval : fa.value.getApprovals()) { + AbsCell[] approverLine = new AbsCell[4]; + // only print common elements once + if (first) { + DateFormat createdDF = new SimpleDateFormat(DATE_TIME_FORMAT); + UUID id = UUID.fromString(approval.getId()); + + rv.add(new AbsCell[]{new TextCell("Ticket ID:"),new TextCell(approval.getTicket(),"colspan=3")}); + rv.add(new AbsCell[]{new TextCell("Memo:"),new TextCell(approval.getMemo(),"colspan=3")}); + rv.add(new AbsCell[]{new TextCell("Requested On:"), + new TextCell(createdDF.format((id.timestamp() - NUM_100NS_INTERVALS_SINCE_UUID_EPOCH)/10000),"colspan=3") + }); + rv.add(new AbsCell[]{new TextCell("Operation:"),new TextCell(decodeOp(approval.getOperation()),"colspan=3")}); + String user = approval.getUser(); + rv.add(new AbsCell[]{new TextCell("User:"),new TextCell(user,"colspan=3")}); + + // headers for listing each approver + rv.add(new AbsCell[]{new TextCell(" ","colspan=4","class=blank_line")}); + rv.add(new AbsCell[]{AbsCell.Null, + new TextCell("Approver","class=bold"), + new TextCell("Type","class=bold"), + new TextCell("Status","class=bold")}); + approverLine[0] = new TextCell("Approvals:"); + + first = false; + } else { + approverLine[0] = AbsCell.Null; + } + + approverLine[1] = new TextCell(approval.getApprover()); + String type = approval.getType(); + if ("owner".equalsIgnoreCase(type)) { + type = "resource owner"; + } + + approverLine[2] = new TextCell(type); + approverLine[3] = new TextCell(approval.getStatus()); + rv.add(approverLine); + + } + } else { + rv.add(new AbsCell[] {new TextCell("*** Data Unavailable ***")}); + } + } finally { + tt.done(); + } + return new Cells(rv,null); + } + }); + } catch (Exception e) { + trans.error().log(e); + } + } + return rv; + } - private String decodeOp(String operation) { - if ("C".equalsIgnoreCase(operation)) { - return "Create"; - } else if ("D".equalsIgnoreCase(operation)) { - return "Delete"; - } else if ("U".equalsIgnoreCase(operation)) { - return "Update"; - } else if ("G".equalsIgnoreCase(operation)) { - return "Grant"; - } else if ("UG".equalsIgnoreCase(operation)) { - return "Un-Grant"; - } - return operation; - } - } + private String decodeOp(String operation) { + if ("C".equalsIgnoreCase(operation)) { + return "Create"; + } else if ("D".equalsIgnoreCase(operation)) { + return "Delete"; + } else if ("U".equalsIgnoreCase(operation)) { + return "Update"; + } else if ("G".equalsIgnoreCase(operation)) { + return "Grant"; + } else if ("UG".equalsIgnoreCase(operation)) { + return "Un-Grant"; + } + return operation; + } + } }