Examples of GatewayException


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

    HttpServletRequest req = exchange.getIn().getBody(HttpServletRequest.class);
    X509Certificate[] cert = (X509Certificate[]) req.getAttribute("javax.servlet.request.X509Certificate");
   
    if ((cert == null) || (cert.length == 0)) {
      // we don't have a client certificate => stop the request
      throw new GatewayException(GatewayExceptionCode.AUTHORIZATION, "Missing certificate");         
    }
  }
View Full Code Here

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

    if(allowedHttpMethods==null || allowedHttpMethods.isEmpty())
      return;

    Object methodheader = exchange.getIn().getHeader(Exchange.HTTP_METHOD);
    if(methodheader == null){
      throw new GatewayException(GatewayExceptionCode.HTTP_METHOD, "No HTTP Method");
    }
   
    for(String m : allowedHttpMethods){
      if(m.equals(methodheader.toString().toLowerCase())){
        return;
      }
    }
   
    throw new GatewayException(GatewayExceptionCode.HTTP_METHOD, "Method "+methodheader.toString()+" not allowed");
  }
View Full Code Here

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

      }
      success = this.alternativeLoadBalancer.process(exchange);
    }
   
    if(!success) {
      GatewayException exception = new GatewayException(GatewayExceptionCode.LOAD_BALANCER, "Issue to call the target host");
      throw exception;
    }
  }
View Full Code Here

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

  @Override
  public void process(Exchange exchange) throws Exception {

    if (rateManager == null) {
      throw new GatewayException(GatewayExceptionCode.RATEORQUOTA, "Rate Manager is null");
    }

    /*
     * TODO extract data required by the rate manager to compute the rate limits from the parameters inside exchange   
     */
    Object property = exchange.getProperty(ExchangeConstantKeys.E3_AUTH_IDENTITY.toString());
    if (property == null || ! (property instanceof AuthIdentity)) {
      throw new GatewayException(GatewayExceptionCode.RATEORQUOTA, "The property " + ExchangeConstantKeys.E3_AUTH_IDENTITY.toString() + " is required to check the rate limits.");
    }

    boolean isTDREnabled = exchange.getProperty(ExchangeConstantKeys.E3_TDR_ENABLED.toString(), boolean.class);
    AuthIdentity authIdentity = (AuthIdentity) property;
    LimitCheckResult limitCheckResult = rateManager.isAllowed(authIdentity, isTDREnabled);

    if(isTDREnabled){
      /**
       * Put some TDR data into into service
       */
      TDRDataService.addTxTDRProperty(exchange, TDRConstant.OVER_QUOTA, limitCheckResult.isOverQuota());
      TDRDataService.addTxTDRProperty(exchange, TDRConstant.OVER_QUOTA_SEC, limitCheckResult.isOverSecond());
      TDRDataService.addTxTDRProperty(exchange, TDRConstant.OVER_QUOTA_MIN, limitCheckResult.isOverMinute());
      TDRDataService.addTxTDRProperty(exchange, TDRConstant.OVER_QUOTA_DAY, limitCheckResult.isOverDay());
      TDRDataService.addTxTDRProperty(exchange, TDRConstant.OVER_QUOTA_WEEK, limitCheckResult.isOverWeek());
      TDRDataService.addTxTDRProperty(exchange, TDRConstant.OVER_QUOTA_MONTH, limitCheckResult.isOverMonth());

      for(String tdrName : limitCheckResult.getTdrValues().keySet()){
        List<TdrGenerationRule> genRules = limitCheckResult.getTdrValues().get(tdrName);
        for(TdrGenerationRule genRule : genRules){
          TDRDataService.addNewTdrGenerationRule(exchange, genRule, tdrName);
        }
      }
    }


    // Route allowed if null - no action error defined
    if (limitCheckResult != null && limitCheckResult.getActionType() != null) {
      if(isTDREnabled) {
        exchange.setProperty(ExchangeConstantKeys.E3_RATELIMIT_ACTION.toString(), limitCheckResult.getActionType().toString());
        TDRDataService.addTxTDRProperty(exchange, TDRConstant.OVER_QUOTA_ACTION, limitCheckResult.getActionType().toString());
      }

      // Log - Will be based on the Logging Framework developed internally
      //log.debug("Route rate limit for API " + (authIdentity.getApi()==null ? "(no API)" : authIdentity.getApi().getId()) + " exeeded" + ((authIdentity.getAuth()==null) ? "": "by " + authIdentity.getAuth().getId()));
      // TDR Notification - not yet implemented
      // HTTP Status Code 429 - to be return by the error processor of the route

      if(limitCheckResult.getActionType().equals(ActionType.REJECT)) {
        throw new GatewayException(GatewayExceptionCode.RATEORQUOTA, "Rate limit exceeded. " + limitCheckResult.getActionTypeMessage(), limitCheckResult.getActionType().toString());
      }
    }

  }
View Full Code Here

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

      }
      authErrorCode = GatewayExceptionCode.AUTHORIZATION;
      authErrorMessage = "Not Authorized";
    }

    Exception exception = new GatewayException(authErrorCode, authErrorMessage);
    exchange.setException(exception);
  }
View Full Code Here

Examples of org.elasticsearch.gateway.GatewayException

    @Override public MetaData read() throws GatewayException {
        try {
            this.currentIndex = findLatestIndex();
        } catch (IOException e) {
            throw new GatewayException("Failed to find latest metadata to read from", e);
        }
        if (currentIndex == -1)
            return null;
        String metaData = "metadata-" + currentIndex;

        try {
            return readMetaData(metaDataBlobContainer.readBlobFully(metaData));
        } catch (GatewayException e) {
            throw e;
        } catch (Exception e) {
            throw new GatewayException("Failed to read metadata [" + metaData + "] from gateway", e);
        }
    }
View Full Code Here

Examples of org.elasticsearch.gateway.GatewayException

            MetaData.Builder.toXContent(metaData, builder, ToXContent.EMPTY_PARAMS);
            builder.endObject();
            builder.close();
            metaDataBlobContainer.writeBlob(newMetaData, new ByteArrayInputStream(out.unsafeByteArray(), 0, out.size()), out.size());
        } catch (IOException e) {
            throw new GatewayException("Failed to write metadata [" + newMetaData + "]", e);
        }

        currentIndex++;

        try {
View Full Code Here

Examples of org.smslib.GatewayException

    // Return a new generated message
    this.counter++;
    if ((this.failCycle > 0) && (this.counter >= this.failCycle))
    {
      this.counter = 0;
      throw new GatewayException("*** READ ERROR ***");
    }
    return generateIncomingMessage();
  }
View Full Code Here

Examples of org.smslib.GatewayException

        getModemDriver().write("AT+CMGS=\"_1_\"\r".replaceAll("\"_1_\"", "" + size));
        Thread.sleep(Service.getInstance().getSettings().AT_WAIT_CGMS);
        while (!getModemDriver().dataAvailable())
        {
          responseRetries++;
          if (responseRetries == Service.getInstance().getSettings().OUTBOUND_RETRIES) throw new GatewayException("Gateway is not responding, max number of retries reached.");
          Logger.getInstance().logWarn("ATHandler().SendMessage(): Still waiting for response (I) (" + responseRetries + ")...", null, getGateway().getGatewayId());
          Thread.sleep(Service.getInstance().getSettings().OUTBOUND_RETRY_WAIT);
        }
        responseRetries = 0;
        getModemDriver().clearBuffer();
        getModemDriver().write(pdu);
        getModemDriver().write((char) 26);
        response = getModemDriver().getResponse();
        while (response.length() == 0)
        {
          responseRetries++;
          if (responseRetries == Service.getInstance().getSettings().OUTBOUND_RETRIES) throw new GatewayException("Gateway is not responding, max number of retries reached.");
          Logger.getInstance().logWarn("ATHandler().SendMessage(): Still waiting for response (II) (" + responseRetries + ")...", null, getGateway().getGatewayId());
          Thread.sleep(Service.getInstance().getSettings().OUTBOUND_RETRY_WAIT);
          response = getModemDriver().getResponse();
        }
        if (getModemDriver().getLastError() == 0)
View Full Code Here

Examples of org.smslib.GatewayException

            response = getGateway().getATHandler().getSimStatus();
          }
          if (response.indexOf("SIM PIN2") >= 0)
          {
            Logger.getInstance().logDebug("SIM requesting PIN2.", null, getGateway().getGatewayId());
            if ((getGateway().getSimPin2() == null) || (getGateway().getSimPin2().length() == 0)) throw new GatewayException("The GSM modem requires SIM PIN2 to operate.");
            if (!getGateway().getATHandler().enterPin(getGateway().getSimPin2())) throw new GatewayException("SIM PIN2 provided is not accepted by the GSM modem.");
            Thread.sleep(Service.getInstance().getSettings().AT_WAIT_SIMPIN);
            continue;
          }
          else if (response.indexOf("SIM PIN") >= 0)
          {
            Logger.getInstance().logDebug("SIM requesting PIN.", null, getGateway().getGatewayId());
            if ((getGateway().getSimPin() == null) || (getGateway().getSimPin().length() == 0)) throw new GatewayException("The GSM modem requires SIM PIN to operate.");
            if (!getGateway().getATHandler().enterPin(getGateway().getSimPin())) throw new GatewayException("SIM PIN provided is not accepted by the GSM modem.");
            Thread.sleep(Service.getInstance().getSettings().AT_WAIT_SIMPIN);
            continue;
          }
          else if (response.indexOf("READY") >= 0) break;
          else if (response.indexOf("OK") >= 0) break;
          else if (response.indexOf("ERROR") >= 0)
          {
            Logger.getInstance().logWarn("Erroneous CPIN response, proceeding with defaults.", null, getGateway().getGatewayId());
            break;
          }
          Logger.getInstance().logWarn("Cannot understand SIMPIN response: " + response + ", will wait for a while...", null, getGateway().getGatewayId());
          Thread.sleep(Service.getInstance().getSettings().AT_WAIT_SIMPIN);
        }
        getGateway().getATHandler().echoOff();
        getGateway().getATHandler().init();
        getGateway().getATHandler().echoOff();
        if (!waitForNetworkRegistration()) Logger.getInstance().logWarn("Network Registration failed, proceeding with defaults.", null, getGateway().getGatewayId());
        getGateway().getATHandler().setVerboseErrors();
        if (getGateway().getATHandler().getStorageLocations().length() == 0)
        {
          try
          {
            getGateway().getATHandler().readStorageLocations();
            Logger.getInstance().logInfo("MEM: Storage Locations Found: " + getGateway().getATHandler().getStorageLocations(), null, getGateway().getGatewayId());
          }
          catch (Exception e)
          {
            getGateway().getATHandler().setStorageLocations("--");
            Logger.getInstance().logWarn("Storage locations could *not* be retrieved, will proceed with defaults.", e, getGateway().getGatewayId());
          }
        }
        if (!getGateway().getATHandler().setIndications())
        {
          Logger.getInstance().logWarn("Callback indications were *not* set succesfully!", null, getGateway().getGatewayId());
          getCnmiEmulationProcessor().enable();
        }
        else
        {
          if (getGateway().getATHandler().getIndications().getMode().equals("0")) getCnmiEmulationProcessor().enable();
        }
        if (getGateway().getProtocol() == Protocols.PDU)
        {
          if (!getGateway().getATHandler().setPduProtocol()) throw new GatewayException("The GSM modem does not support the PDU protocol.");
        }
        else if (getGateway().getProtocol() == Protocols.TEXT)
        {
          if (!getGateway().getATHandler().setTextProtocol()) throw new GatewayException("The GSM modem does not support the TEXT protocol.");
        }
      }
      catch (TimeoutException t)
      {
        try
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.