Summary Table
Categories |
Total Count |
PII |
0 |
URL |
0 |
DNS |
0 |
EKL |
0 |
IP |
0 |
PORT |
0 |
VsID |
0 |
CF |
0 |
AI |
0 |
VPD |
0 |
PL |
0 |
Other |
0 |
File Content
/*
* ChangeLogAspect.java
* Copyright (c) 2017 Veterans Affairs.
*/
package gov.va.oneconsult.seoc.api.aspect;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import gov.va.oneconsult.seoc.api.json.SeocCreateResponse;
import gov.va.oneconsult.seoc.api.json.SeocGenericResponse;
import gov.va.oneconsult.seoc.api.service.LogService;
import gov.va.oneconsult.seoc.api.util.Constants;
/**
* Description: Aspect to update ChangeLog table for each of the following
* changes to the SEOC object. Save - Save draft SEOC (new or revised) from VA
* Community Care: SEOC Administrator Delete - Delete draft SEOC from VA
* Community Care: SEOC Administrator Activate - Activate draft SEOC (new or
* revised) from VA Community Care: SEOC Administrator Discontinue - Discontinue
* active SEOC from VA Community Care: SEOC Administrator
*
* @author AbleVets
*
*/
@Aspect
@Configuration
public class ChangeLogAspect
{
private Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired
private LogService logServiceImpl;
/**
* Description: This method will run after returning from saveSeoc method in the
* SeocServiceImpl. It logs the activity performed on the SEOC with User and
* Event details.
*
* @param joinPoint - Details of JoinPoint
* @param result - Result from the operation performed
*/
@AfterReturning(value = "execution(* gov.va.oneconsult.seoc.api.service.impl.SeocServiceImpl.saveSeoc(*))", returning = "result")
public void logChangesAfterSaveSeoc(JoinPoint joinPoint, Object result)
{
logger.info("{} returned with value {}", joinPoint, result);
if (result instanceof SeocCreateResponse)
{
SeocCreateResponse seocResponse = (SeocCreateResponse) result;
if (seocResponse.getStatus().equals(Constants.CREATED)
|| seocResponse.getStatus().equals(Constants.UPDATED))
{
logger.info("Calling method to log seoc changes *** ");
logServiceImpl.logSeocChanges(seocResponse.getUniqueId(), seocResponse.getSeocKey(),
seocResponse.getAction(), seocResponse.getComments());
}
}
}
/**
* Description: This method will run after returning from activateSeoc method in
* the SeocServiceImpl. It logs the activity performed on the SEOC with User and
* Event details.
*
* @param joinPoint - Details of JoinPoint
* @param result - Result from the operation performed
*/
@AfterReturning(value = "execution(* gov.va.oneconsult.seoc.api.service.impl.SeocServiceImpl.activateSeoc(*))", returning = "result")
public void logChangesAfterActivateSeoc(JoinPoint joinPoint, Object result)
{
logger.info("{} returned with value {}", joinPoint, result);
if (result instanceof SeocGenericResponse)
{
SeocGenericResponse seocResponse = (SeocGenericResponse) result;
if (seocResponse.getStatus().equals(Constants.SUCCESS))
{
logger.info("Calling method to log seoc changes *** ");
logServiceImpl.logSeocChanges(seocResponse.getSeocId(), seocResponse.getSeocKey(),
Constants.EVENT_ACTION_ACTIVATE, null);
}
}
}
/**
* Description: This method will run after returning from deleteSeoc method in
* the SeocServiceImpl. It logs the activity performed on the SEOC with User and
* Event details.
*
* @param joinPoint - Details of JoinPoint
* @param result - Result from the operation performed
*/
@AfterReturning(value = "execution(* gov.va.oneconsult.seoc.api.service.impl.SeocServiceImpl.deleteSeoc(*))", returning = "result")
public void logChangesAfterDeleteSeoc(JoinPoint joinPoint, Object result)
{
logger.info("{} returned with value {}", joinPoint, result);
if (result instanceof SeocGenericResponse)
{
SeocGenericResponse seocResponse = (SeocGenericResponse) result;
if (seocResponse.getStatus().equals(Constants.SUCCESS))
{
logger.info("Calling method to log seoc changes *** ");
logServiceImpl.logSeocChanges(seocResponse.getSeocId(), seocResponse.getSeocKey(),
Constants.EVENT_ACTION_DELETE, null);
}
}
}
/**
* Description: This method will run after returning from discontinueSeoc method
* in
*
* the SeocServiceImpl. It logs the activity performed on the SEOC with User and
* Event details.
*
* @param joinPoint - Details of JoinPoint
* @param result - Result from the operation performed
*/
@AfterReturning(value = "execution(* gov.va.oneconsult.seoc.api.service.impl.SeocServiceImpl.discontinueSeoc(*))", returning = "result")
public void logChangesAfterDiscontinuingSeoc(JoinPoint joinPoint, Object result)
{
logger.info("{} returned with value {}", joinPoint, result);
if (result instanceof SeocGenericResponse)
{
SeocGenericResponse seocResponse = (SeocGenericResponse) result;
if (seocResponse.getStatus().equals(Constants.SUCCESS))
{
logger.info("Calling method to log seoc changes *** ");
logServiceImpl.logSeocChanges(seocResponse.getSeocId(), seocResponse.getSeocKey(),
Constants.EVENT_ACTION_DISCONTINUE, null);
}
}
}
/**
* Description: This method will run after returning from reverseSeoc method
* in the SeocServiceImpl. It logs the activity performed on the SEOC with User and
* Event details.
*
* @param joinPoint - Details of JoinPoint
* @param result - Result from the operation performed
*/
@AfterReturning(value = "execution(* gov.va.oneconsult.seoc.api.service.impl.SeocServiceImpl.reverseSeoc(*))", returning = "result")
public void logChangesAfterReversingSeoc(JoinPoint joinPoint, Object result)
{
logger.info("{} returned with value {}", joinPoint, result);
if (result instanceof SeocGenericResponse)
{
SeocGenericResponse seocResponse = (SeocGenericResponse) result;
if (seocResponse.getStatus().equals(Constants.SUCCESS))
{
logger.info("Calling method to log seoc changes *** ");
logServiceImpl.logSeocChanges(seocResponse.getSeocId(), seocResponse.getSeocKey(),
Constants.EVENT_ACTION_REVERSE, null);
}
}
}
}