Remove Tabs, per Jococo
[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.helpers.LastNotified;
26 import org.onap.aaf.auth.batch.reports.Notify;
27 import org.onap.aaf.auth.env.AuthzTrans;
28 import org.onap.aaf.cadi.Access;
29
30 public class NotifyPendingApprBody extends NotifyBody {
31
32     public NotifyPendingApprBody(Access access) {
33         super(access,"appr","PendingApproval");
34     }
35
36     @Override
37     public boolean body(AuthzTrans trans, StringBuilder sb, int indent, Notify n, String id) {
38         boolean rv = false;
39         for(List<String> row : rows.get(id)) {
40             String qty = row.get(2);
41             if("1".equals(qty)) {
42                 printf(sb,indent,"You have an Approval in the AAF %s Environment awaiting your decision.\n",row.get(3));
43             } else {
44                 printf(sb,indent,"You have %s Approvals in the AAF %s Environment awaiting your decision.\n",qty,row.get(3));
45             }
46             printf(sb,indent,"<br><br><b>ACTION:</b> <i>Click on</i> <a href=\"%s/approve\">AAF Approval Page</a>",n.guiURL);
47             rv = true;
48             break; // only one
49         }
50         
51         return rv;
52     }
53
54     @Override
55     public String user(List<String> row) {
56         if( (row != null) && row.size()>1) {
57             return row.get(1);
58         }
59         return null;
60     }
61
62     @Override
63     public String subject() {
64         return String.format("AAF Pending Approval Notification (ENV: %s)",env);
65     }
66
67     
68     @Override
69     public void record(AuthzTrans trans, StringBuilder query, String id, List<String> notified, LastNotified lastN) {
70         for(String n : notified) {
71             // No special key for Pending Requests.
72             lastN.update(query,n,"pending","");
73         }
74     }
75     
76     /* (non-Javadoc)
77      * @see org.onap.aaf.auth.batch.reports.bodies.NotifyBody#store(java.util.List)
78      */
79     @Override
80     public void store(List<String> row) {
81         // Notify Pending is setup for 1 Notification at a time
82         super.rows.clear();
83         super.store(row);
84     }
85
86 }