@Around(
     "saveOperation()||deleteOperation()||updateOperation()||findOperation()||getOperation()||allOperation()")
 public Object aroundfindAll(ProceedingJoinPoint joinPoint) throws Throwable {
   MethodCallDetails methodCallDetails =
       new MethodCallDetails(
           requestDetails.getRequestId(),
           requestDetails.getCallSequence(),
           HealthConstants.CLASS_TYPE.REPOSITORY,
           runtimeLogInfoHelper.getRuntimeLogInfo().getUserIpAddress(),
           "",
           joinPoint.getTarget().getClass().toString(),
           joinPoint.getSignature().getName(),
           runtimeLogInfoHelper.getRuntimeLogInfo().getUserId(),
           requestDetails.getAppSessionId());
   Object object = null;
   repositoryLogic(joinPoint);
   try {
     object = handleRepositoryCall(joinPoint, runtimeLogInfoHelper.getRuntimeLogInfo());
     methodCallDetails.setPostCallDetails(HealthConstants.METHOD_NORMAL_EXECUTION);
   } catch (SpartanPersistenceException e) {
     methodCallDetails.setPostCallDetails(HealthConstants.METHOD_EXCEPTION, e.getExceptionId());
     e.printStackTrace();
     throw e;
   } catch (Exception e) {
     methodCallDetails.setPostCallDetails(
         HealthConstants.METHOD_EXCEPTION, HealthConstants.DEFAULT_EXCEPTION_ID);
     e.printStackTrace();
     throw e;
   } finally {
     requestDetails.addMethodCallDetails(methodCallDetails);
   }
   return object;
 }
 @Around(
     value =
         "saveOperation()||deleteOperation()||updateOperation()||findOperation()||getOperation()||allOperation()")
 public Object aroundfindAll(ProceedingJoinPoint joinPoint) throws Throwable {
   System.out.println("In around repository aspect");
   MethodCallDetails methodCallDetails =
       new MethodCallDetails(
           requestDetails.getRequestId(),
           HealthConstants.CLASS_TYPE.REPOSITORY,
           runtimeLogInfoHelper.getRuntimeLogInfo().getUserIpAddress(),
           "",
           joinPoint.getTarget().getClass().toString(),
           joinPoint.getSignature().getName(),
           runtimeLogInfoHelper.getRuntimeLogInfo().getUserId(),
           "");
   setCustomerIdInEntityManager();
   Object object = null;
   if (joinPoint.getArgs().length > 0) {
     Object methodInputParam = joinPoint.getArgs()[0];
     if (methodInputParam != null && methodInputParam instanceof CommonEntityInterface) {
       CommonEntityInterface entity = (CommonEntityInterface) methodInputParam;
       preSaveUpdateOperation(entity);
     } 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 object1 : listOfEntities) {
             CommonEntityInterface entity = (CommonEntityInterface) object1;
             preSaveUpdateOperation(entity);
           }
         }
       }
     }
   }
   try {
     object = handleRepositoryCall(joinPoint, runtimeLogInfoHelper.getRuntimeLogInfo());
     methodCallDetails.setPostCallDetails(HealthConstants.METHOD_NORMAL_EXECUTION);
   } catch (SpartanPersistenceException e) {
     methodCallDetails.setPostCallDetails(HealthConstants.METHOD_EXCEPTION, e.getExceptionId());
     e.printStackTrace();
     throw e;
   } catch (Exception e) {
     methodCallDetails.setPostCallDetails(
         HealthConstants.METHOD_EXCEPTION, HealthConstants.DEFAULT_EXCEPTION_ID);
     e.printStackTrace();
     throw e;
   } finally {
     requestDetails.addRepositoryMethodCallDetails(methodCallDetails);
   }
   return object;
 }
 @Around("findOperation()||getOperation()")
 public Object aroundfindAll(ProceedingJoinPoint joinPoint) throws Throwable {
   MethodCallDetails methodCallDetails =
       new MethodCallDetails(
           requestDetails.getRequestId(),
           requestDetails.getCallSequence(),
           HealthConstants.CLASS_TYPE.REPOSITORY,
           runtimeLogInfoHelper.getRuntimeLogInfo().getUserIPAddress(),
           "",
           joinPoint.getTarget().getClass().toString(),
           joinPoint.getSignature().getName(),
           runtimeLogInfoHelper.getRuntimeLogInfo().getUserId(),
           requestDetails.getAppSessionId());
   Object object = null;
   setCustomerIdInEntityManager();
   try {
     Log.out.println(
         "ABSAA314900100",
         runtimeLogInfoHelper.getRequestHeaderBean(),
         joinPoint.getSignature().getDeclaringTypeName(),
         joinPoint.getSignature().getName(),
         joinPoint.getSignature().getDeclaringTypeName()
             + ":"
             + joinPoint.getSignature().getName());
     object = joinPoint.proceed();
     methodCallDetails.setPostCallDetails(HealthConstants.METHOD_NORMAL_EXECUTION);
     Log.out.println(
         "ABSAA347900100",
         runtimeLogInfoHelper.getRequestHeaderBean(),
         joinPoint.getSignature().getDeclaringTypeName(),
         joinPoint.getSignature().getName(),
         joinPoint.getSignature().getDeclaringTypeName(),
         methodCallDetails.getExecution_Time());
   } catch (Exception e) {
     AppAlarm appAlarm = Log.getExceptionAlarm("ABS", "AA", e.getClass().getName());
     Log.out.println(
         appAlarm.getAlarmID(),
         runtimeLogInfoHelper.getRequestHeaderBean(),
         joinPoint.getSignature().getDeclaringTypeName(),
         joinPoint.getSignature().getName(),
         e.getMessage(),
         e);
     throw e;
   } finally {
     requestDetails.addMethodCallDetails(methodCallDetails);
   }
   return object;
 }
 @Around(value = "allOperation()||athenaServiceOperation()||spartanServiceOperation()")
 @Order(1)
 public Object aroundAdvice1(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
   System.out.println(
       "In aroundAdvice Order 1 : Calling method : "
           + proceedingJoinPoint.getSignature().getName());
   HttpServletRequest request =
       ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
   ServletWebRequest servletWebRequest = new ServletWebRequest(request);
   HttpServletResponse response = servletWebRequest.getResponse();
   HttpSession session = request.getSession();
   long nextAutoNum = autoRequestId.getAndIncrement();
   methodCallStack.setRequestId(UUID.randomUUID().toString().toUpperCase());
   MethodCallDetails methodCallDetails =
       new MethodCallDetails(
           methodCallStack.getRequestId(),
           HealthConstants.CLASS_TYPE.SERVICE,
           request.getRemoteHost(),
           request.getMethod(),
           proceedingJoinPoint.getTarget().getClass().toString(),
           proceedingJoinPoint.getSignature().getName(),
           loggedInUserId(request),
           getSessionId(request));
   String entityName =
       incrementUricounter(
           proceedingJoinPoint.getSignature().getDeclaringType().getSimpleName(),
           proceedingJoinPoint.getSignature().getName());
   ResponseEntity<ResponseBean> responseEntity = new ResponseEntity<>(HttpStatus.OK);
   /*
    * Needs to get user id from request header and pass it to entityAudit
    * and RuntimeLogInfo
    */
   /* create logging info object (Needs to call from login service only */
   runtimeLogInfoHelper.setCustomerId(getCustomerId(request));
   runtimeLogInfoHelper.createRuntimeLogUserInfo(
       1, loggedInUserId(request), request.getRemoteHost());
   /* validate request */
   try {
     if (request.getHeader("Job-Execution") == null) {
       if (request.getHeader("isBeforeSession") == null) {
         validateRequest(session, request, response);
         if (!sessionValidation.checkIgnoreURL(request)) {
           /** Sets user's last access time in table */
           java.sql.Timestamp currentTime = new java.sql.Timestamp(System.currentTimeMillis());
           loginSessionRepo.updateLastAccessTime(
               loggedInUserId(request), session.getAttribute("usidHash").toString(), currentTime);
           runtimeLogInfoHelper.setUserAccessCode(
               Integer.parseInt(session.getAttribute("userAccessCode").toString()));
         }
       }
     }
     Object obj = proceedingJoinPoint.proceed();
     responseEntity = (ResponseEntity<ResponseBean>) obj;
     httpStatusCode = responseEntity.getStatusCode();
     methodCallDetails.setPostCallDetails(
         HealthConstants.METHOD_NORMAL_EXECUTION, responseEntity.getStatusCode().name());
   } catch (SpartanAccessDeniedException e) {
     sprinkler.logger.log(
         runtimeLogInfoHelper.getRuntimeLogInfo(),
         4005,
         proceedingJoinPoint.getSignature().getDeclaringTypeName(),
         proceedingJoinPoint.getSignature().getName(),
         request.getRemoteHost(),
         e);
     ResponseBean exceptionbean =
         e.prepareExceptionBean(
             sprinkler,
             runtimeLogInfoHelper.getRuntimeLogInfo(),
             " Access Denied " + e.getMessage());
     methodCallDetails.setPostCallDetails(
         HealthConstants.METHOD_EXCEPTION,
         e.getExceptionId(),
         responseEntity.getStatusCode().name());
     return new ResponseEntity<ResponseBean>(exceptionbean, responseEntity.getStatusCode());
   } catch (SpartanPersistenceException e) {
     sprinkler.logger.log(
         runtimeLogInfoHelper.getRuntimeLogInfo(),
         e.getExceptionId(),
         proceedingJoinPoint.getSignature().getDeclaringTypeName(),
         proceedingJoinPoint.getSignature().getName(),
         request.getRemoteHost(),
         e);
     ResponseBean exceptionbean =
         e.prepareExceptionBean(
             sprinkler,
             runtimeLogInfoHelper.getRuntimeLogInfo(),
             " Can not perform Operation on entity:" + e.getMessage());
     methodCallDetails.setPostCallDetails(
         HealthConstants.METHOD_EXCEPTION,
         e.getExceptionId(),
         responseEntity.getStatusCode().name());
     return new ResponseEntity<ResponseBean>(exceptionbean, responseEntity.getStatusCode());
   } catch (SpartanTransactionException e) {
     sprinkler.logger.log(
         runtimeLogInfoHelper.getRuntimeLogInfo(),
         e.getExceptionId(),
         proceedingJoinPoint.getSignature().getDeclaringTypeName(),
         proceedingJoinPoint.getSignature().getName(),
         request.getRemoteHost(),
         e);
     ResponseBean exceptionbean =
         e.prepareExceptionBean(
             sprinkler, runtimeLogInfoHelper.getRuntimeLogInfo(), e.getMessage());
     methodCallDetails.setPostCallDetails(
         HealthConstants.METHOD_EXCEPTION,
         e.getExceptionId(),
         responseEntity.getStatusCode().name());
     return new ResponseEntity<ResponseBean>(exceptionbean, responseEntity.getStatusCode());
   } catch (SpartanDataNotFoundException e) {
     sprinkler.logger.log(
         runtimeLogInfoHelper.getRuntimeLogInfo(),
         e.getExceptionId(),
         proceedingJoinPoint.getSignature().getDeclaringTypeName(),
         proceedingJoinPoint.getSignature().getName(),
         request.getRemoteHost(),
         e);
     ResponseBean exceptionbean =
         e.prepareExceptionBean(sprinkler, runtimeLogInfoHelper.getRuntimeLogInfo());
     methodCallDetails.setPostCallDetails(
         HealthConstants.METHOD_EXCEPTION,
         e.getExceptionId(),
         responseEntity.getStatusCode().name());
     return new ResponseEntity<ResponseBean>(exceptionbean, responseEntity.getStatusCode());
   } catch (com.athena.framework.server.exception.biz.SpartanBusinessValidationFailedException e) {
     sprinkler.logger.log(
         runtimeLogInfoHelper.getRuntimeLogInfo(),
         e.getExceptionId(),
         proceedingJoinPoint.getSignature().getDeclaringTypeName(),
         proceedingJoinPoint.getSignature().getName(),
         request.getRemoteHost(),
         e);
     ResponseBean exceptionbean =
         e.prepareExceptionBean(sprinkler, runtimeLogInfoHelper.getRuntimeLogInfo());
     methodCallDetails.setPostCallDetails(
         HealthConstants.METHOD_EXCEPTION,
         e.getExceptionId(),
         responseEntity.getStatusCode().name());
     return new ResponseEntity<ResponseBean>(exceptionbean, responseEntity.getStatusCode());
   } catch (Exception e) {
     sprinkler.logger.log(
         runtimeLogInfoHelper.getRuntimeLogInfo(),
         4005,
         proceedingJoinPoint.getSignature().getDeclaringTypeName(),
         proceedingJoinPoint.getSignature().getName(),
         request.getRemoteHost(),
         e);
     ResponseBean responseBean = new ResponseBean();
     responseBean.add("success", false);
     responseBean.add("message", " Access Denied:" + e.getMessage());
     methodCallDetails.setPostCallDetails(
         HealthConstants.METHOD_EXCEPTION,
         HealthConstants.DEFAULT_EXCEPTION_ID,
         responseEntity.getStatusCode().name());
     return new ResponseEntity<ResponseBean>(responseBean, responseEntity.getStatusCode());
   } finally {
     /** Sets user's last access time in table */
     /*if (request.getHeader("Job-Execution") == null) {
     if (request.getHeader("isBeforeSession") == null) {
     java.sql.Timestamp currentTime = new java.sql.Timestamp(System.currentTimeMillis());
     loginSessionRepo.updateLastAccessTime(loggedInUserId(request), session.getAttribute("usidHash").toString(), currentTime);
     }
     }*/
     methodCallStack.addServiceMethodCallDetails(methodCallDetails);
     healthmeter.apphealth.writeHealthLog((ArtMethodCallStack) methodCallStack.clone());
     Integer existingValue = 0;
     Metric metric = repository.findOne("gauge." + "total.Time " + entityName + "");
     if (metric != null) {
       existingValue = metric.getValue().intValue();
     }
     gaugeservice.submit(
         "total.Time " + entityName + "", executionTimer.getSystemTime + existingValue);
   }
   return responseEntity;
 }
 @Around("allOperation()")
 @Order(1)
 public Object aroundAdvice1(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
   HttpServletRequest request =
       ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
   ServletWebRequest servletWebRequest = new ServletWebRequest(request);
   HttpServletResponse response = servletWebRequest.getResponse();
   HttpSession session = request.getSession();
   long nextAutoNum = autoRequestId.getAndIncrement();
   methodCallStack.setRequestId(UUID.randomUUID().toString().toUpperCase());
   methodCallStack.setAppSessionId(getSessionId(request));
   MethodCallDetails methodCallDetails =
       new MethodCallDetails(
           methodCallStack.getRequestId(),
           methodCallStack.getCallSequence(),
           HealthConstants.CLASS_TYPE.SERVICE,
           request.getRemoteHost(),
           request.getMethod(),
           proceedingJoinPoint.getTarget().getClass().toString(),
           proceedingJoinPoint.getSignature().getName(),
           loggedInUserId(request),
           getSessionId(request));
   String entityName =
       incrementUricounter(
           proceedingJoinPoint.getSignature().getDeclaringType().getSimpleName(),
           proceedingJoinPoint.getSignature().getName());
   ResponseEntity<ResponseBean> responseEntity = new ResponseEntity<>(HttpStatus.OK);
   try {
     serviceLogic(session, request, response);
     Object obj = proceedingJoinPoint.proceed();
     responseEntity = (ResponseEntity<ResponseBean>) obj;
     httpStatusCode = responseEntity.getStatusCode();
     methodCallDetails.setPostCallDetails(
         HealthConstants.METHOD_NORMAL_EXECUTION, responseEntity.getStatusCode().name());
   } catch (SpartanAccessDeniedException e) {
     sprinkler.logger.log(
         runtimeLogInfoHelper.getRuntimeLogInfo(),
         4005,
         proceedingJoinPoint.getSignature().getDeclaringTypeName(),
         proceedingJoinPoint.getSignature().getName(),
         request.getRemoteHost(),
         e);
     ResponseBean exceptionbean =
         e.prepareExceptionBean(
             sprinkler,
             runtimeLogInfoHelper.getRuntimeLogInfo(),
             "Access Denied" + e.getMessage());
     methodCallDetails.setPostCallDetails(
         HealthConstants.METHOD_EXCEPTION,
         e.getExceptionId(),
         responseEntity.getStatusCode().name());
     return new ResponseEntity<ResponseBean>(exceptionbean, responseEntity.getStatusCode());
   } catch (SpartanPersistenceException e) {
     sprinkler.logger.log(
         runtimeLogInfoHelper.getRuntimeLogInfo(),
         e.getExceptionId(),
         proceedingJoinPoint.getSignature().getDeclaringTypeName(),
         proceedingJoinPoint.getSignature().getName(),
         request.getRemoteHost(),
         e);
     ResponseBean exceptionbean =
         e.prepareExceptionBean(
             sprinkler,
             runtimeLogInfoHelper.getRuntimeLogInfo(),
             "Can not perform Operation on entity:" + e.getMessage());
     methodCallDetails.setPostCallDetails(
         HealthConstants.METHOD_EXCEPTION,
         e.getExceptionId(),
         responseEntity.getStatusCode().name());
     return new ResponseEntity<ResponseBean>(exceptionbean, responseEntity.getStatusCode());
   } catch (SpartanTransactionException e) {
     sprinkler.logger.log(
         runtimeLogInfoHelper.getRuntimeLogInfo(),
         e.getExceptionId(),
         proceedingJoinPoint.getSignature().getDeclaringTypeName(),
         proceedingJoinPoint.getSignature().getName(),
         request.getRemoteHost(),
         e);
     ResponseBean exceptionbean =
         e.prepareExceptionBean(sprinkler, runtimeLogInfoHelper.getRuntimeLogInfo());
     methodCallDetails.setPostCallDetails(
         HealthConstants.METHOD_EXCEPTION,
         e.getExceptionId(),
         responseEntity.getStatusCode().name());
     return new ResponseEntity<ResponseBean>(exceptionbean, responseEntity.getStatusCode());
   } catch (SpartanDataNotFoundException e) {
     sprinkler.logger.log(
         runtimeLogInfoHelper.getRuntimeLogInfo(),
         e.getExceptionId(),
         proceedingJoinPoint.getSignature().getDeclaringTypeName(),
         proceedingJoinPoint.getSignature().getName(),
         request.getRemoteHost(),
         e);
     ResponseBean exceptionbean =
         e.prepareExceptionBean(sprinkler, runtimeLogInfoHelper.getRuntimeLogInfo());
     methodCallDetails.setPostCallDetails(
         HealthConstants.METHOD_EXCEPTION,
         e.getExceptionId(),
         responseEntity.getStatusCode().name());
     return new ResponseEntity<ResponseBean>(exceptionbean, responseEntity.getStatusCode());
   } catch (com.athena.framework.server.exception.biz.SpartanBusinessValidationFailedException e) {
     sprinkler.logger.log(
         runtimeLogInfoHelper.getRuntimeLogInfo(),
         e.getExceptionId(),
         proceedingJoinPoint.getSignature().getDeclaringTypeName(),
         proceedingJoinPoint.getSignature().getName(),
         request.getRemoteHost(),
         e);
     ResponseBean exceptionbean =
         e.prepareExceptionBean(sprinkler, runtimeLogInfoHelper.getRuntimeLogInfo());
     methodCallDetails.setPostCallDetails(
         HealthConstants.METHOD_EXCEPTION,
         e.getExceptionId(),
         responseEntity.getStatusCode().name());
     return new ResponseEntity<ResponseBean>(exceptionbean, responseEntity.getStatusCode());
   } catch (com.athena.framework.server.exception.biz.SpartanConstraintViolationException e) {
     sprinkler.logger.log(
         runtimeLogInfoHelper.getRuntimeLogInfo(),
         e.getExceptionId(),
         proceedingJoinPoint.getSignature().getDeclaringTypeName(),
         proceedingJoinPoint.getSignature().getName(),
         request.getRemoteHost(),
         e);
     ResponseBean exceptionbean =
         e.prepareExceptionBean(sprinkler, runtimeLogInfoHelper.getRuntimeLogInfo());
     methodCallDetails.setPostCallDetails(
         HealthConstants.METHOD_EXCEPTION,
         e.getExceptionId(),
         responseEntity.getStatusCode().name());
     httpStatusCode = HttpStatus.PRECONDITION_FAILED;
     return new ResponseEntity<ResponseBean>(exceptionbean, responseEntity.getStatusCode());
   } catch (Exception e) {
     sprinkler.logger.log(
         runtimeLogInfoHelper.getRuntimeLogInfo(),
         4005,
         proceedingJoinPoint.getSignature().getDeclaringTypeName(),
         proceedingJoinPoint.getSignature().getName(),
         request.getRemoteHost(),
         e);
     ResponseBean responseBean = new ResponseBean();
     responseBean.add("success", false);
     responseBean.add("message", "Access Denied:" + e.getMessage());
     methodCallDetails.setPostCallDetails(
         HealthConstants.METHOD_EXCEPTION,
         HealthConstants.DEFAULT_EXCEPTION_ID,
         responseEntity.getStatusCode().name());
     return new ResponseEntity<ResponseBean>(responseBean, responseEntity.getStatusCode());
   } finally {
     methodCallStack.addMethodCallDetails(methodCallDetails);
     healthmeter.apphealth.writeHealthLog((ArtMethodCallStack) methodCallStack.clone());
     Integer existingValue = 0;
     Metric metric = repository.findOne("gauge." + "total.Time" + entityName + "");
     if (metric != null) {
       existingValue = metric.getValue().intValue();
     }
     gaugeservice.submit(
         "total.Time" + entityName + "", executionTimer.getSystemTime + existingValue);
   }
   return responseEntity;
 }