DataMigration, other Batch
[aaf/authz.git] / auth / auth-batch / src / main / java / org / onap / aaf / auth / batch / reports / bodies / NotifyPendingApprBody.java
1 /**
2  * ============LICENSE_START====================================================
3  * org.onap.aaf
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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====================================================
19  *
20  */
21 package org.onap.aaf.auth.batch.reports.bodies;
22
23 import java.util.List;
24
25 import org.onap.aaf.auth.batch.reports.Notify;
26 import org.onap.aaf.auth.env.AuthzTrans;
27 import org.onap.aaf.cadi.Access;
28
29 public class NotifyPendingApprBody extends NotifyBody {
30         private final String explanation;
31
32         public NotifyPendingApprBody(Access access) {
33                 super(access,"appr","PendingApproval");
34                 explanation = "The following Approvals are awaiting your action. ";
35         }
36
37         @Override
38         public boolean body(AuthzTrans trans, StringBuilder sb, int indent, Notify n, String id) {
39                 println(sb,indent,explanation);
40 /*              println(sb,indent,"<table>");
41                 indent+=2;
42                 println(sb,indent,"<tr>");
43                 indent+=2;
44                 println(sb,indent,"<th>Fully Qualified ID</th>");
45                 println(sb,indent,"<th>Unique ID</th>");
46                 println(sb,indent,"<th>Type</th>");
47                 println(sb,indent,"<th>Expires</th>");
48                 println(sb,indent,"<th>Warnings</th>");
49                 indent-=2;
50                 println(sb,indent,"</tr>");
51                 String theid, type, info, expires, warnings;
52                 GregorianCalendar gc = new GregorianCalendar();
53                 for(List<String> row : rows.get(id)) {
54                         theid=row.get(1);
55                         switch(row.get(3)) {
56                                 case "1":
57                                 case "2":
58                                         type = "Password";
59                                         break;
60                                 case "200":
61                                         type = "x509 (Certificate)";
62                                         break;
63                                 default:
64                                         type = "Unknown, see AAF GUI";
65                                         break;
66                         }
67                         theid = "<a href=\""+n.guiURL+"/creddetail?ns="+row.get(2)+"\">"+theid+"</a>";
68                         gc.setTimeInMillis(Long.parseLong(row.get(5)));
69                         expires = Chrono.niceUTCStamp(gc);
70                         info = row.get(6);
71                         //TODO get Warnings 
72                         warnings = "";
73                         
74                         println(sb,indent,"<tr>");
75                         indent+=2;
76                         printCell(sb,indent,theid);
77                         printCell(sb,indent,info);
78                         printCell(sb,indent,type);
79                         printCell(sb,indent,expires);
80                         printCell(sb,indent,warnings);
81                         indent-=2;
82                         println(sb,indent,"</tr>");
83                 }
84                 indent-=2;
85                 println(sb,indent,"</table>");
86                 */
87                 return true;
88         }
89
90         @Override
91         public String user(List<String> row) {
92                 if( (row != null) && row.size()>1) {
93                         return row.get(1);
94                 }
95                 return null;
96         }
97
98         @Override
99         public String subject() {
100                 return String.format("AAF Pending Approval Notification (ENV: %s)",env);
101         }
102
103 }