Package juzu

Examples of juzu.Response$Error


    Error handleGenericException(Exception ex, HttpServletRequest request, HttpServletResponse response) {
        String errorId = LoggingUtil.generateErrorId();
        String errorMessage = generateLogErrorMessage(errorId) + " - Processing error";
        log.error(errorMessage, ex);

        Error error = new Error();
        error.setHttpStatusCode("500");
        error.setDeveloperMessage(messageSource.getMessage("api.genericException.developerMessage", null, request.getLocale()));
        error.setUserMessage(messageSource.getMessage("api.genericException.userMessage", null, request.getLocale()));
        error.setMoreInfo("support@knappsack.com");
        error.setErrorId(errorId);

        response.setStatus(500);

        return error;
    }
View Full Code Here


    Error handleEntityNotFoundException(Exception ex, HttpServletRequest request, HttpServletResponse response) {
        String errorId = LoggingUtil.generateErrorId();
        String errorMessage = generateLogErrorMessage(errorId) + " - No entity found";
        log.error(errorMessage, ex);

        Error error = new Error();
        error.setHttpStatusCode("400");
        error.setDeveloperMessage(messageSource.getMessage("api.entityNotFoundException.developerMessage=", null, request.getLocale()));
        error.setUserMessage(messageSource.getMessage("api.entityNotFoundException.userMessage", null, request.getLocale()));
        error.setMoreInfo("support@knappsack.com");
        error.setErrorId(errorId);

        response.setStatus(400);

        return error;
    }
View Full Code Here

    Error handleAccessDeniedException(AccessDeniedException ex, HttpServletRequest request, HttpServletResponse response) {
        String errorId = LoggingUtil.generateErrorId();
        String errorMessage = generateLogErrorMessage(errorId) + " - Access Denied";
        log.error(errorMessage, ex);

        Error error = new Error();
        error.setHttpStatusCode("403");
        error.setDeveloperMessage(messageSource.getMessage("api.accessDenied.developerMessage", null, request.getLocale()));
        error.setUserMessage(messageSource.getMessage("api.accessDenied.userMessage", null, request.getLocale()));
        error.setMoreInfo("support@knappsack.com");
        error.setErrorId(errorId);

        response.setStatus(403);

        return error;
    }
View Full Code Here

    this.rememberMeSupported = rememberMeSupported;
  }

  public Response doLogout(Stage.Handler request) {
    SecurityUtils.getSubject().logout();
    Response resp = request.invoke();
    if (rememberMeSupported) {
      RememberMeUtil.forgetIdentity();
    }
    return resp;
  }
View Full Code Here

    try {
      subject.login(new UsernamePasswordToken(username, password.toCharArray(), remember));

      //
      Response resp = stage.invoke();
      if (remember && rememberMeSupported) {
        RememberMeUtil.forgetIdentity();
        RememberMeUtil.rememberSerialized();
      }
      return resp;
    } catch (AuthenticationException e) {
      List<ControlParameter> parameters = request.getHandler().getParameters();
      for (ControlParameter parameter : parameters) {
        if (parameter instanceof ContextualParameter) {
          if (AuthenticationException.class.isAssignableFrom(parameter.getType())) {
            request.getContextualArguments().put((ContextualParameter)parameter, e);
            Response resp = stage.invoke();
            if (remember) {
              RememberMeUtil.forgetIdentity();
            }
            return resp;
          }
View Full Code Here

    //
    JSON methodsJSON = controllerJSON.getJSON("methods");
    JSON methodJSON;

    if (controllerJSON.get("require") != null) {
      Response resp = authorizer.isAuthorized(stage, controllerJSON);
      if (resp != null) {
        return resp;
      } else {
        if (methodsJSON == null) {
          return stage.invoke();
View Full Code Here

    return doInvoke(stage, methodJSON);
  }

  private Response doInvoke(Stage.Handler request, JSON json) {
    Response resp = authorizer.isAuthorized(request, json);
    if (resp != null) {
      return resp;
    } else {
      if ("login".equals(json.get("operator"))) {
        return authenticater.doLogin(request);
View Full Code Here

  public void beginRequest(RequestContext context) {
  }

  @Override
  public void endRequest(RequestContext context) {
      Response response = context.getResponse();
      if (response instanceof ValidationError) {
        ValidationError error = (ValidationError)response;
        String id = context.getParameters().get("id").getValue();
       
        Iterator<ConstraintViolation<Object>> v = error.getViolations().iterator();
View Full Code Here

  public void beginRequest(RequestContext context) {   
  }

  @Override
  public void endRequest(RequestContext context) {
      Response response = context.getResponse();
      if (response instanceof ValidationError) {
        ValidationError error = (ValidationError)response;       
        violation.add(Violation.REGISTER, error.getHtmlMessage());
       
        context.setResponse(Application_.register());
View Full Code Here

  }

  @Override
  public Response handle(Stage.Unmarshalling argument) {
    final Request request = argument.getRequest();
    Response result = argument.invoke();

    //
    if (request.getPhase() == Phase.VIEW) {
      if (result instanceof Response.Content) {
        Response.Status status = (Response.Status)result;
View Full Code Here

TOP

Related Classes of juzu.Response$Error

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.