Examples of GatewayException


Examples of br.com.flexait.gateway.exception.GatewayException

     
      UrlEncodedFormEntity urlEncoded = new UrlEncodedFormEntity(httpParameters);
      httpPost.setEntity(urlEncoded);
     
    } catch (Exception e) {
      throw new GatewayException("Não foi possível encodar os parametros", e);
    }
  }
View Full Code Here

Examples of br.com.flexait.gateway.exception.GatewayException

     
      boolean isValid = validateParams(params);
      if(!isValid) {
        String erros = "Erros de validação: " + validator.getErros();
        log.debug(erros);
        throw new GatewayException(erros, new IllegalArgumentException(erros));
      }
   
      httpClient = configScheme(httpClient);
     
      if(log.isDebugEnabled())
        log.debug("Post com os parametros:\n\t" + IOUtils.toString(httpPost.getEntity().getContent()));
     
      HttpResponse response = httpClient.execute(httpPost);
     
      InputStream content = response.getEntity().getContent();
     
      Retorno retorno = Parser.of(content).getRetorno();
     
      retorno.setOperacao(params.getOperacao());
     
      return retorno;
     
    } catch (ConversionException e) {
      log.error(e);
      throw new GatewayException("Ocorreu um erro ao executar o post: " + e.getMessage());
    }
    catch (Exception e) {
      log.error(e);
      throw new GatewayException("Ocorreu um problema ao executar o post", e);
    }
  }
View Full Code Here

Examples of br.com.flexait.gateway.exception.GatewayException

  PropertiesUtil(String file) throws Exception  {
    super();
    try {
      InputStream inStream = getClass().getResourceAsStream(file);
      if(inStream == null) {
        throw new GatewayException(
          "Não foi possível carregar o arquivo " + file + ". Ele deve estar na pasta src do projeto"
        );
      }
      this.load(inStream);
    } catch (IOException e) {
      throw new GatewayException(
        "Não foi possível carregar o arquivo " + file + ". Ocorreu um erro de I/O",
        e
      );
    }
  }
View Full Code Here

Examples of br.com.flexait.gateway.exception.GatewayException

      erro = (Erro) object;
    }
    else {
      String erroSerializacao = "Não é possível deserializar o xml";
      GatewayService.log.error(erroSerializacao);
      throw new GatewayException(erroSerializacao);
    }
   
    return Retorno.of(transacao, erro);
  }
View Full Code Here

Examples of br.com.flexait.gateway.exception.GatewayException

     
      UrlEncodedFormEntity urlEncoded = new UrlEncodedFormEntity(httpParameters);
      httpPost.setEntity(urlEncoded);
     
    } catch (Exception e) {
      throw new GatewayException("Não foi possível encodar os parametros", e);
    }
  }
View Full Code Here

Examples of br.com.flexait.gateway.exception.GatewayException

     
      boolean isValid = validateParams(params);
      if(!isValid) {
        String erros = "Erros de validação: " + validator.getErros();
        log.debug(erros);
        throw new GatewayException(erros, new IllegalArgumentException(erros));
      }
   
      httpClient = configScheme(httpClient);
     
      if(log.isDebugEnabled())
        log.debug("Post com os parametros:\n\t" + IOUtils.toString(httpPost.getEntity().getContent()));
     
      HttpResponse response = httpClient.execute(httpPost);
     
      InputStream content = response.getEntity().getContent();
     
      Retorno retorno = Parser.of(content).getRetorno();
     
      retorno.setOperacao(params.getOperacao());
     
      return retorno;
     
    } catch (ConversionException e) {
      log.error(e);
      throw new GatewayException("Ocorreu um erro ao executar o post: " + e.getMessage());
    }
    catch (Exception e) {
      log.error(e);
      throw new GatewayException("Ocorreu um problema ao executar o post", e);
    }
  }
View Full Code Here

Examples of com.alu.e3.gateway.common.camel.exception.GatewayException

    CanonicalizedIpAddress ip = new CanonicalizedIpAddress(remoteAddr);
    if(this.dataManager.isIpAllowed(api, ip.getIp())) {
      exchange.setProperty(ExchangeConstantKeys.E3_API.toString(), api);   
    }
    else {
      Exception exception = new GatewayException(GatewayExceptionCode.AUTHORIZATION, "Not Authorized from this IP address");
      exchange.setException(exception);     
    }   
  }
View Full Code Here

Examples of com.alu.e3.gateway.common.camel.exception.GatewayException

    Exception exception = exchange.getProperty(Exchange.EXCEPTION_CAUGHT, Exception.class);

    if (exception instanceof GatewayException) {

      GatewayException gatewayException = (GatewayException) exception;

      if (gatewayException.getCode() == GatewayExceptionCode.AUTHORIZATION) {
        String body = "Issue: " + gatewayException.getMessage();
        createHttpErrorResponse(exchange, 401, body);
        isNoteSpecialized = false;

      } else if(gatewayException.getCode() == GatewayExceptionCode.AUTHORIZATION_BASIC) {
        exchange.getOut().setHeader("WWW-Authenticate", "Basic realm=\"Secure Service\"");
        String body = "Issue: " + gatewayException.getMessage();
        createHttpErrorResponse(exchange, 401, body);
        isNoteSpecialized = false;
       
      } else if(gatewayException.getCode() == GatewayExceptionCode.API_NOT_ACTIVATED) {       
        String body = "Issue: " + gatewayException.getMessage();
        createHttpErrorResponse(exchange, 403, body);
        isNoteSpecialized = false;   
       
      } else if(gatewayException.getCode() == GatewayExceptionCode.VALIDATION) {
        String body = "Issue: " + gatewayException.getMessage();
        createHttpErrorResponse(exchange, 400, body);
        isNoteSpecialized = false;
     
      if (gatewayException.getCode() == GatewayExceptionCode.RATEORQUOTA) {
        String body = "Issue: " + gatewayException.getMessage();
        // Based on draft "Additional HTTP Status Codes; draft-nottingham-http-new-status-02"
        // http://tools.ietf.org/html/draft-nottingham-http-new-status-02#page-4
        createHttpErrorResponse(exchange, 429, "Too Many Requests", body);
        isNoteSpecialized = false;
      }
      if (gatewayException.getCode() == GatewayExceptionCode.HTTP_METHOD) {
        String body = "Issue: " + gatewayException.getMessage();
        createHttpErrorResponse(exchange, 405, body);
        isNoteSpecialized = false;
      }
    }
View Full Code Here

Examples of com.alu.e3.gateway.common.camel.exception.GatewayException

    // Get subscriber matching CallDescriptors
    Auth auth;
    try {
      auth = dataManager.getAuthById(subscriberId);
    } catch (InvalidIDException e) {
      throw new GatewayException(GatewayExceptionCode.AUTHORIZATION, e.getMessage() );
    }

    if (auth == null || !auth.getStatus().isActive()) {
      throw new GatewayException(GatewayExceptionCode.AUTHORIZATION, "Authorization status is invalid");
    }

    return   dataManager.getMatchingPolicies(authIdentity.getApi(), auth);

  }
View Full Code Here

Examples of com.alu.e3.gateway.common.camel.exception.GatewayException

  public abstract void process(Exchange exchange) throws Exception;
 
  protected void injectUriAndQueryString(String notifyUrl, Exchange exchange) throws GatewayException {
    String[] parts = CommonTools.splitUrl(notifyUrl);
    if(parts == null)
      throw new GatewayException(GatewayExceptionCode.NOTIFY_URL, "Notification URL is invalid");
     
    exchange.getIn().setHeader(Exchange.HTTP_URI, parts[0]);
    exchange.getIn().setHeader(Exchange.HTTP_QUERY, parts[1]);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.