protected void preSaveUpdateOperation(CommonEntityInterface entity)
     throws SpartanConstraintViolationException, SpartanIncorrectDataException {
   entity.setEntityAudit(1, runtimeLogInfoHelper.getRuntimeLogInfo().getUserId());
   /* validates the entity */
   if (!entity.isEntityValidated()) {
     validateEntity(entity);
   }
 }
 private boolean validateEntity(CommonEntityInterface entity)
     throws SpartanConstraintViolationException, SpartanIncorrectDataException {
   boolean isValidEntity = true;
   /* set entity validator */
   entity.setEntityValidator(this.entityValidator);
   /* validates the entity */
   isValidEntity = entity.isValid();
   return isValidEntity;
 }
 private void preSaveUpdateOperation(CommonEntityInterface entity)
     throws SpartanConstraintViolationException, SpartanIncorrectDataException {
   entity.setEntityAudit(1, runtimeLogInfoHelper.getRuntimeLogInfo().getUserId());
 }
 private void prepareEntityAuditInfo(CommonEntityInterface entity) {
   HttpServletRequest request =
       ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
   String userId = loggedInUserId(request);
   entity.setEntityAudit(1, userId);
 }
 @Around(value = "updateOperation()||athenaAndSpartanUpdateServiceOperation()")
 @Order(2)
 public Object aroundAdvice2Update(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
   System.out.println(
       "In aroundAdvice Order 2 Update: Calling method : "
           + proceedingJoinPoint.getSignature().getName());
   boolean isValidEntity = true;
   Object returnObject = new Object();
   if (proceedingJoinPoint.getArgs().length > 0) {
     Object methodInputParam = proceedingJoinPoint.getArgs()[0];
     if (methodInputParam != null && methodInputParam instanceof CommonEntityInterface) {
       CommonEntityInterface entity = (CommonEntityInterface) methodInputParam;
       try {
         preSaveUpdateOperation(entity);
         entity.setSystemTxnCode(51000);
       } catch (SpartanConstraintViolationException e) {
         isValidEntity = false;
         sprinkler.logger.log(runtimeLogInfoHelper.getRuntimeLogInfo(), 2008, e);
         ResponseBean exceptionbean =
             e.prepareExceptionBean(
                 sprinkler,
                 runtimeLogInfoHelper.getRuntimeLogInfo(),
                 "Constraints violated by input " + methodInputParam.getClass().getSimpleName());
         return new ResponseEntity<ResponseBean>(exceptionbean, e.getHttpStatus());
       }
     } else if (methodInputParam != null && methodInputParam instanceof List) {
       List listOfEntities = (List) methodInputParam;
       if (listOfEntities.size() > 0) {
         /*
          * Checking 0th element type. So no need to check type for
          * each element in the loop.
          */
         if (listOfEntities.get(0) instanceof CommonEntityInterface) {
           for (Object object : listOfEntities) {
             CommonEntityInterface entity = (CommonEntityInterface) object;
             try {
               preSaveUpdateOperation(entity);
               entity.setSystemTxnCode(51000);
             } catch (SpartanConstraintViolationException e) {
               isValidEntity = false;
               sprinkler.logger.log(runtimeLogInfoHelper.getRuntimeLogInfo(), 2008, e);
               ResponseBean exceptionbean =
                   e.prepareExceptionBean(
                       sprinkler,
                       runtimeLogInfoHelper.getRuntimeLogInfo(),
                       "Constraints violated by input "
                           + methodInputParam.getClass().getSimpleName());
               return new ResponseEntity<ResponseBean>(exceptionbean, e.getHttpStatus());
             }
           }
         }
       }
     }
   }
   if (isValidEntity) {
     sprinkler.logger.log(
         runtimeLogInfoHelper.getRuntimeLogInfo(),
         1000,
         proceedingJoinPoint.getSignature().getDeclaringTypeName(),
         proceedingJoinPoint.getSignature().getName(),
         proceedingJoinPoint.getArgs()[0].getClass().getSimpleName(),
         proceedingJoinPoint.getArgs()[0].toString());
     returnObject = proceedingJoinPoint.proceed();
     sprinkler.logger.log(
         runtimeLogInfoHelper.getRuntimeLogInfo(),
         1001,
         proceedingJoinPoint.getSignature().getDeclaringTypeName(),
         proceedingJoinPoint.getSignature().getName(),
         proceedingJoinPoint.getArgs()[0].toString());
     return returnObject;
   }
   return returnObject;
 }
Example #6
0
 private void prepareEntityAuditInfo(CommonEntityInterface entity, RECORD_TYPE recordType) {
   HttpServletRequest request =
       ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
   String userId = ""; // loggedInUserId(request);
   entity.setEntityAudit(1, userId, recordType);
 }