Package loxia.exception

Examples of loxia.exception.BusinessException


   
    Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
   
    if(needCredential && authentication == null){
      logger.error("Session timeout.");
      throw new BusinessException(PreserveErrorCode.SESSION_TIMEOUT);
    }
   
    if(needCheck){
      BaseProfileAction act = (BaseProfileAction)action;
                 
      LoxiaUserDetails userDetails = (LoxiaUserDetails)authentication.getPrincipal();
      logger.debug("Current Principal:" + userDetails);
      String entryAcl = act.getAcl();
      if(entryAcl != null){
        userDetails.setCurrentOu(null);
        logger.debug("Function Entrance... Organization need to repick");
       
        for(GrantedAuthority auth: userDetails.getAuthorities()){
          LoxiaGrantedAuthority lauth = (LoxiaGrantedAuthority)auth;
          if(lauth.getAuthority().equals(entryAcl)){
            userDetails.setCurrentAuthority(lauth);
            break;
          }
        }
        if(userDetails.getCurrentAuthority() == null ||
            userDetails.getCurrentAuthority().getOuIds().size() == 0){
          logger.error("No sufficicent privilege.");
          throw new BusinessException(PreserveErrorCode.NO_SUFFICICENT_PRIVILEGE);
        }else{
          if(userDetails.getCurrentAuthority().
              getOuIds().size() == 1){
            userDetails.setCurrentOu(operatingUnitDao.getByPrimaryKey(
                userDetails.getCurrentAuthority().getOuIds().iterator().next()));
          }else{
            logger.debug("Redirect Invocation");
           
            String url = request.getRequestURI();
            Enumeration<String> paramNames = request.getParameterNames();
            StringBuffer paramsSb = new StringBuffer();
            while (paramNames.hasMoreElements()) {
              String name = (String) paramNames.nextElement();
              if (!"acl".equalsIgnoreCase(name)){
                paramsSb.append(name + "=" + request.getParameter(name) + "&");
              }
            }
            if (paramsSb.length() > 0){
              paramsSb.deleteCharAt(paramsSb.length()-1);
              url = url + "?" + paramsSb.toString();
            }
            request.getSession().setAttribute(BaseAction.FOLLOWING_URL_AFTER_OPERATING_UNIT_PICKUP, url);
            response.sendRedirect(request.getContextPath() + "/operatingunitpickup.do");
            return null;
          }
        }
      }else{
        if(act.getSelectedOuId() != null){
          //set Current OperatingUint in up
          userDetails.setCurrentOu(operatingUnitDao.getByPrimaryKey(act.getSelectedOuId()));
        }else{
          if(!userDetails.checkAuthority(acl.value())){
            logger.error("No sufficicent privilege.");
            throw new BusinessException(PreserveErrorCode.NO_SUFFICICENT_PRIVILEGE);
          }
        }         
      }
           
    }
View Full Code Here


    }
    }

  private List<String> getBusiExceptionMessage(ActionInvocation invocation, BusinessException e){   
    List<String> errors = new ArrayList<String>();
    BusinessException be = e;
    while(be != null){
      String msgKey = "business_exception_" + be.getErrorCode();
      errors.add(getMessage(invocation, msgKey, be.getArgs()));
      be = be.getLinkedException();
    }

    return errors;
  }
View Full Code Here

 
  @Override
  protected ModelAndView getModelAndView(String viewName, Exception ex,
      HttpServletRequest request) {
    if(ex instanceof BusinessException){
      BusinessException bex = (BusinessException)ex;
      ex = encode(bex);
    }
    if(((HttpServletRequest)request).getHeader("X-Requested-With") != null){
      return getModelAndView("json", ex);
    }else   
View Full Code Here

      return super.getModelAndView(viewName, ex, request);
  }

  private BusinessException encode(BusinessException ex){
    String key = BUSINESS_EXCEPTION_PREFIX + ex.getErrorCode();
    BusinessException result = new BusinessException(ex.getErrorCode(),
        context.getMessage(key, ex.getArgs(),key, LocaleContextHolder.getLocale()));
    result.setArgs(ex.getArgs());
    if(ex.getLinkedException() != null){
      result.setLinkedException(encode(ex.getLinkedException()));
    }
    return result;
  }
View Full Code Here

      logger.debug("Current ou isn't changed.");
    }
   
    if(controller.getCurrentOperatingUnit() == null){
      logger.warn("Current ou is null.");
      throw new BusinessException(PreserveErrorCode.NO_SUFFICICENT_PRIVILEGE);
    }
    if(controller.checkPrivilege(acl.value())){
      logger.debug("User pass the authorization.");
      return pjp.proceed(pjp.getArgs());
    }else{
      throw new BusinessException(PreserveErrorCode.NO_SUFFICICENT_PRIVILEGE);
    }
  }
View Full Code Here

TOP

Related Classes of loxia.exception.BusinessException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.