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%2FApprovalForm.java;h=a5337369cbd94510b8ae4ed5b144bfe7fb8e7320;hb=6dd9704640eb8cc8d6b4ccd266e40a3f6f589e75;hp=27fd5274acd6285dfbb8c69e1a00bde0a925cdef;hpb=7e966914050e66219689001ff4ab601a49eef0ac;p=aaf%2Fauthz.git
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 27fd5274..a5337369 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
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -40,13 +40,12 @@ import org.onap.aaf.auth.gui.Table.Cells;
import org.onap.aaf.auth.gui.table.AbsCell;
import org.onap.aaf.auth.gui.table.ButtonCell;
import org.onap.aaf.auth.gui.table.RadioCell;
-import org.onap.aaf.auth.gui.table.RefCell;
import org.onap.aaf.auth.gui.table.TableData;
-import org.onap.aaf.auth.gui.table.TextAndRefCell;
import org.onap.aaf.auth.gui.table.TextCell;
+import org.onap.aaf.auth.gui.table.TextToolTipCell;
import org.onap.aaf.auth.org.Organization;
-import org.onap.aaf.auth.org.OrganizationFactory;
import org.onap.aaf.auth.org.Organization.Identity;
+import org.onap.aaf.auth.org.OrganizationFactory;
import org.onap.aaf.cadi.CadiException;
import org.onap.aaf.cadi.client.Future;
import org.onap.aaf.cadi.client.Rcli;
@@ -67,9 +66,9 @@ public class ApprovalForm extends Page {
// Package on purpose
static final String NAME="Approvals";
static final String HREF = "/gui/approve";
- static final String[] FIELDS = new String[] {"line[]","user"};
-
-
+ static final String[] FIELDS = new String[] {"line[]","user","delegate_of","as_user"};
+
+
public ApprovalForm(final AAF_GUI gui, final Page ... breadcrumbs) throws APIException, IOException {
super(gui.env,NAME,HREF, FIELDS,
@@ -91,7 +90,7 @@ public class ApprovalForm extends Page {
}
},
new Form(true,new Table("Approval Requests", gui.env.newTransNoAvg(),new Model(gui.env),"class=stdform"))
- .preamble("The following requires your Approval to proceed in the AAF System.
Hover on Identity for Name; click for WebPhone; If Deny is the only option, User is no longer valid."),
+ .preamble("The following requires your Approval to proceed in the AAF System.
Hover on Name for Identity; If Deny is the only option, User is no longer valid."),
new NamedCode(false, "selectAlljs") {
@Override
public void code(final Cache cache, final HTMLGen hgen) throws APIException, IOException {
@@ -106,35 +105,47 @@ public class ApprovalForm extends Page {
hgen.end(jsStart);
}
});
-
}
-
+
/**
* Implement the Table Content for Approvals
- *
+ *
* @author Jonathan
*
*/
private static class Model extends TableData {
//TODO come up with a generic way to do ILM Info (people page)
- private static final String TODO_ILM_INFO = "TODO: ILM Info";
- private static final String DOMAIN_OF_USER = "@DOMAIN";
-
+// private static final String TODO_ILM_INFO = "TODO: ILM Info";
+
+
private static final String[] headers = new String[] {"Identity","Request","Approve","Deny"};
private Slot sUser;
-
+ private Slot sAsDelegate;
+ private Slot sAsUser;
+
public Model(AuthzEnv env) {
sUser = env.slot(NAME+".user");
+ sAsDelegate = env.slot(NAME+".delegate_of");
+ sAsUser = env.slot(NAME + ".as_user");
}
-
+
@Override
public String[] headers() {
return headers;
}
-
+
@Override
public Cells get(final AuthzTrans trans, final AAF_GUI gui) {
final String userParam = trans.get(sUser, null);
+
+ final String asDelegate = trans.get(sAsDelegate, null);
+ final String approver;
+ if(asDelegate==null) {
+ approver = trans.get(sAsUser,trans.user());
+ } else {
+ approver = asDelegate;
+ }
+
ArrayList rv = new ArrayList<>();
String msg = null;
TimeTaken tt = trans.start("AAF Get Approvals for Approver",Env.REMOTE);
@@ -144,10 +155,10 @@ public class ApprovalForm extends Page {
int numLeft = gui.clientAsUser(trans.getUserPrincipal(), new Retryable() {
@Override
public Integer code(Rcli> client) throws CadiException, ConnectException, APIException {
- Future fa = client.read("/authz/approval/approver/"+trans.user(),gui.getDF(Approvals.class));
+ Future fa = client.read("/authz/approval/approver/"+approver,gui.getDF(Approvals.class));
int numLeft = 0;
if (fa.get(AAF_GUI.TIMEOUT)) {
-
+
if (fa.value!=null) {
for (Approval appr : fa.value.getApprovals()) {
if ("pending".equals(appr.getStatus())) {
@@ -159,10 +170,10 @@ public class ApprovalForm extends Page {
}
}
}
-
+
String prevApprover = null;
int overallIndex = 0;
-
+
for (Approval appr : pendingApprovals) {
String currApprover = appr.getApprover();
if (!currApprover.equals(prevApprover)) {
@@ -175,7 +186,7 @@ public class ApprovalForm extends Page {
return numLeft;
}
});
-
+
if (!pendingApprovals.isEmpty()) {
// Only add select all links if we have approvals
AbsCell[] selectAllRow = new AbsCell[] {
@@ -186,105 +197,116 @@ public class ApprovalForm extends Page {
};
rv.add(selectAllRow);
}
-
+
int line=-1;
-
+
while (!beginIndicesPerApprover.isEmpty()) {
int beginIndex = beginIndicesPerApprover.remove(0);
int endIndex = (beginIndicesPerApprover.isEmpty()?pendingApprovals.size():beginIndicesPerApprover.get(0));
List currApproverList = pendingApprovals.subList(beginIndex, endIndex);
-
- String currApproverFull = currApproverList.get(0).getApprover();
- String currApproverShort = currApproverFull.substring(0,currApproverFull.indexOf('@'));
- String currApprover = (trans.user().indexOf('@')<0?currApproverShort:currApproverFull);
- if (!currApprover.equals(trans.user())) {
- AbsCell[] approverHeader;
- if (currApproverFull.substring(currApproverFull.indexOf('@')).equals(DOMAIN_OF_USER)) {
- approverHeader = new AbsCell[] {
- new TextAndRefCell("Approvals Delegated to Me by ", currApprover,
- TODO_ILM_INFO + currApproverShort,
- true,
- new String[] {"colspan=4", "class=head"})
- };
- } else {
- approverHeader = new AbsCell[] {
- new TextCell("Approvals Delegated to Me by " + currApprover,
- 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());
+
+ 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",
+ 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);
}
- });
-
- 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";
+ 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) {