2 * ============LICENSE_START====================================================
4 * ===========================================================================
5 * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
6 * ===========================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END====================================================
21 package org.onap.aaf.auth.batch.reports.bodies;
23 import java.io.IOException;
24 import java.util.Date;
25 import java.util.List;
27 import org.onap.aaf.auth.batch.helpers.LastNotified;
28 import org.onap.aaf.auth.batch.reports.Notify;
29 import org.onap.aaf.auth.env.AuthzTrans;
30 import org.onap.aaf.auth.org.Organization.Identity;
31 import org.onap.aaf.auth.org.OrganizationException;
32 import org.onap.aaf.cadi.Access;
33 import org.onap.aaf.misc.env.util.Chrono;
35 public abstract class NotifyURBody extends NotifyBody {
37 private final String explanation;
38 public NotifyURBody(Access access, String name) throws IOException {
39 super(access,"ur",name);
42 explanation = "The Roles for the IDs associated with you will expire on the dates shown. "
43 + "If the role membership is allowed to expire, "
44 + "the ID will no longer have the permissions associated with that role.<br><br>"
45 + "It is the responsibility of the Designated Approvers to approve, but you can monitor "
46 + "their progress by clicking the ID Link.";
50 public boolean body(AuthzTrans trans, StringBuilder sb, int indent, Notify n, String id) {
51 String fullname = "n/a";
54 Identity identity = trans.org().getIdentity(trans, id);
56 trans.warn().printf("Cannot find %s in Organization",id);
58 fullname = identity.fullName();
59 if(!identity.isPerson()) {
60 if((identity = identity.responsibleTo())!=null) {
61 kind = "AppID Sponsor";
62 fullname = identity.fullName();
66 } catch (OrganizationException e) {
70 println(sb,indent,explanation);
71 println(sb,indent,"<br><br>");
72 println(sb,indent,"<table>");
74 println(sb,indent,"<tr>");
76 println(sb,indent,"<th>"+kind+"</th>");
77 println(sb,indent,"<th>Fully Qualified ID</th>");
78 println(sb,indent,"<th>Role</th>");
79 println(sb,indent,"<th>Expires</th>");
81 println(sb,indent,"</tr>");
85 for(List<String> row : rows.get(id)) {
86 println(sb,indent,"<tr>");
88 name = printCell(sb,indent,fullname,name);
89 String rid = row.get(1);
90 String fqiCell = "<a href=\"" + gui_url + "/myrequests\">" + rid + "</a>";
91 fqi = printCell(sb,indent,fqiCell,fqi);
92 printCell(sb,indent,row.get(2));
93 Date expires = new Date(Long.parseLong(row.get(6)));
94 printCell(sb,indent,Chrono.niceUTCStamp(expires));
96 println(sb,indent,"</tr>");
99 println(sb,indent,"</table>");
106 public void record(AuthzTrans trans, StringBuilder query, String id, List<String> notified, LastNotified ln) {
107 for(List<String> row : rows.get(id)) {
108 for(String n : notified) {
109 // Need to match LastNotified Key ... ur.user() + '|'+ur.role();
110 ln.update(query, n, row.get(0), row.get(1)+'|'+row.get(2));
116 public String user(List<String> row) {
117 if( (row != null) && row.size()>1) {