1 /*******************************************************************************
2 * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved.
3 *******************************************************************************/
4 package com.att.authz.actions;
6 import java.io.IOException;
10 import com.att.authz.env.AuthzTrans;
11 import com.att.authz.layer.Result;
12 import com.att.dao.aaf.cass.CredDAO;
13 import org.onap.aaf.inno.env.APIException;
14 import org.onap.aaf.inno.env.util.Chrono;
15 import com.datastax.driver.core.Cluster;
17 public class CredPunt extends ActionPuntDAO<CredDAO.Data,Void> {
19 public CredPunt(AuthzTrans trans, Cluster cluster, int months, int range) throws IOException, APIException {
20 super(trans,cluster,months,range);
23 public CredPunt(AuthzTrans trans, ActionDAO<?,?> adao, int months, int range) throws IOException {
24 super(trans, adao, months,range);
27 public Result<Void> exec(AuthzTrans trans, CredDAO.Data cdd) {
28 Result<Void> rv = null;
29 Result<List<CredDAO.Data>> read = q.credDAO.read(trans, cdd);
30 if(read.isOKhasData()) {
31 for(CredDAO.Data data : read.value) {
32 Date from = data.expires;
33 data.expires = puntDate();
34 if(data.expires.before(from)) {
35 trans.error().printf("Error: %s is before %s", Chrono.dateOnlyStamp(data.expires), Chrono.dateOnlyStamp(from));
37 rv = q.credDAO.update(trans, data);
38 trans.info().log("Updated Cred",cdd.id, CredPrint.type(cdd.type), "from",Chrono.dateOnlyStamp(from),"to",Chrono.dateOnlyStamp(data.expires));