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====================================================
22 package org.onap.aaf.auth.batch.actions;
24 import java.io.IOException;
25 import java.util.ArrayList;
26 import java.util.List;
28 import org.onap.aaf.auth.batch.helpers.Approval;
29 import org.onap.aaf.auth.batch.helpers.Future;
30 import org.onap.aaf.auth.batch.helpers.UserRole;
31 import org.onap.aaf.auth.dao.cass.ApprovalDAO;
32 import org.onap.aaf.auth.dao.cass.UserRoleDAO;
33 import org.onap.aaf.auth.dao.hl.Function.FUTURE_OP;
34 import org.onap.aaf.auth.dao.hl.Function.OP_STATUS;
35 import org.onap.aaf.auth.env.AuthzTrans;
36 import org.onap.aaf.auth.layer.Result;
37 import org.onap.aaf.misc.env.APIException;
39 import com.datastax.driver.core.Cluster;
41 public class URFutureApproveExec extends ActionDAO<List<Approval>, OP_STATUS, Future> {
43 public URFutureApproveExec(AuthzTrans trans, Cluster cluster, boolean dryRun) throws APIException, IOException {
44 super(trans,cluster, dryRun);
47 public URFutureApproveExec(AuthzTrans trans, ActionDAO<?,?,?> adao) {
52 public Result<OP_STATUS> exec(AuthzTrans trans, List<Approval> app, Future future) {
54 return Result.err(Result.ERR_ActionNotCompleted,"Not Executed");
57 final List<ApprovalDAO.Data> apprs = new ArrayList<>();
58 final List<UserRoleDAO.Data> urs = new ArrayList<>();
59 for (Approval a : app) {
61 UserRole ur = UserRole.get(a.add.user, future.role);
66 Result<OP_STATUS> rv = f.performFutureOp(trans, FUTURE_OP.A, future.fdd,
67 (trans1, noop) -> apprs,
69 List<UserRole> lur = UserRole.getByUser().get(keys[0]);
71 for (UserRole ur : lur) {
72 if (ur.role().equals(keys[1])) {
82 trans.info().printf("Denied %s on %s", future.memo(),future.fdd.target);
85 trans.info().printf("Completed %s on %s", future.memo(),future.fdd.target);
88 trans.info().printf("Future %s on %s has lapsed", future.memo(),future.fdd.target);
93 trans.error().log("Error completing",future.memo(),rv.errorString());