Package com.alu.e3.data.model

Examples of com.alu.e3.data.model.LogLevel


  public void process(Exchange exchange) throws Exception {
    Api api = this.dataManager.getApiById(apiId, false);
    HttpServletRequest request = (HttpServletRequest) exchange.getIn().getHeader(Exchange.HTTP_SERVLET_REQUEST);
    //retrieve the real IP adress from the request
    String remoteAddr = CommonTools.remoteAddr(request);
    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


    this.apiId = apiId;
  }
 
  @Override
  public void process(Exchange exchange) throws Exception {
    Api api = this.dataManager.getApiById(apiId, false);
    HttpServletRequest request = (HttpServletRequest) exchange.getIn().getHeader(Exchange.HTTP_SERVLET_REQUEST);
    //retrieve the real IP adress from the request
    String remoteAddr = CommonTools.remoteAddr(request);
    CanonicalizedIpAddress ip = new CanonicalizedIpAddress(remoteAddr);
    if(this.dataManager.isIpAllowed(api, ip.getIp())) {
View Full Code Here


  protected List<CallDescriptor> checkSubscriberIdAuth(String subscriberId, AuthIdentity authIdentity) throws 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

    Map<String, String> props = new HashMap<String,String>();

    props.putAll(identity.getApi().getProperties());
    Iterator<CallDescriptor> it = identity.getCallDescriptors().iterator();
    while(it.hasNext()){
      CallDescriptor cd = it.next();
      Policy policy = cd.getPolicy();
      if(policy != null){
        props.putAll(policy.getProperties());
      }
    }
View Full Code Here

   *
   * @param event  A LogLevel-specific event from the DataManager
   */
  private void handleLogLevelEvent(DataEntryEvent<String, LogLevel> event) {
    String eventKey = event.getKey();
    LogLevel logLevel = event.getValue();
    if ((eventKey == null) || (logLevel == null)) {
      return;
    }
    // TODO:
    // The logLevelParameter idea is not yet implemented, but will be the way we will
    // distinguish instance-specific set-level and get-level events
    // (To be implemented when the concept of InstanceIDs is sorted out)
    String[] keyAndParam = eventKey.split(":", 2);
    String key = keyAndParam.length > 0 ? keyAndParam[0] : "";
    String param = keyAndParam.length > 1 ? keyAndParam[1] : "";
    logger.debug("Parsed cached log-level event key: '{}' and param: '{}'", key, param);
    if (key.equals(LogLevel.logLevelKey)) {
      logger.debug("New java log-level notification: ({}, {})", eventKey, event.getValue());
      logger.debug("Setting local java log-level to new (global) value: {}", logLevel.toString());
      try {
        LoggingUtil.setLocalLogLevel(LogFileSource.JAVA, logLevel);
      } catch (Exception ex) {
        logger.error("Unable to set logLevel from cache: {}", logLevel.toString());
      }
    } else if (key.equals(LogLevel.smxlogLevelKey)) {
      logger.debug("New smxlog-level notification: ({}, {})", eventKey, event.getValue());
      logger.debug("Setting local smxlog-level to new (global) value: {}", logLevel.toString());
      try {
        LoggingUtil.setLocalLogLevel(LogFileSource.SMX, logLevel);
      } catch (Exception ex) {
        logger.error("Unable to set smxlogLevel from cache: {}", logLevel.toString());
      }
    } else if (key.equals(LogLevel.syslogLevelKey)) {
      logger.debug("New syslog-level notification: ({}, {})", eventKey, event.getValue());
      String syslogLevel = logLevel.getSyslogLevel().name();
      logger.debug("Setting local syslog-level to new (global) value: {}", syslogLevel);
      try {
        NonJavaLogger.setLogLevel(syslogLevel);
      } catch (Exception ex) {
        logger.error("Unable to set syslogLevel from cache: {}", syslogLevel);
      }
    } else {
      // Check if this is a logging-category specification
      Category category = Category.fromString(key);
      if (category != null) {
        logger.debug("New category-enabled notification: ({}, {})", eventKey, event.getValue());
        // If the log-level value is log4j OFF, then the category is disabled; else, category is enabled
        if (logLevel.getLevel().equals(Level.OFF)) {
          logger.debug("Disabling logging category: {}", category);
          Category.enableCategory(category, false);
        } else {
          logger.debug("Enabling logging category: {}", category);
          Category.enableCategory(category, true);
View Full Code Here

  }

  public void setCachedLoggingCategory(Category category, boolean enabled) {
    // Use log4j level OFF to indicated disabled category, ALL for enabled
    Level level = enabled ? Level.ALL : Level.OFF;
    cachingTableLogLevel.set(category.toString(), new LogLevel(level));
  }
View Full Code Here

  public void clearCachedLoggingCategory(Category category) {
    cachingTableLogLevel.remove(category.toString());
  }

  public boolean getCachedLoggingCategory(Category category) {
    LogLevel level = cachingTableLogLevel.get(category.toString());
    if ((level != null) && level.equals(Level.OFF)) {
      return false;
    }
    return true;
  }
View Full Code Here

  @Produces({ MediaType.APPLICATION_XML })
  @Consumes({ MediaType.WILDCARD })
  @Description(value = "REST API to retrieve the global java log level.")
    public Response restGetLogLevel()
    {
      LogLevel logLevel = null;
      if(logger.isDebugEnabled()) {
        logger.debug("rest-api call to getLogLevel");
      }
      try {
      // The parameterless (no instanceId) version could get either the
View Full Code Here

  @Produces({ MediaType.APPLICATION_XML })
  @Consumes({ MediaType.WILDCARD })
  @Description(value = "REST API to retrieve the java log level for an instance (1 for localhost, 0 for global).")
    public Response restGetInstanceLogLevel(@PathParam("instanceId") String instanceId)
    {
      LogLevel logLevel = null;
      if(logger.isDebugEnabled()) {
        logger.debug("rest-api call to getInstanceLogLevel with instanceId: {}", (instanceId == null ? "(null)" : instanceId));
      }
      try {
        logLevel = isGlobalInstanceId(instanceId) ? getGlobalLogLevel() : getLocalLogLevel();   
View Full Code Here

    public Response restSetLogLevel(String level)
    {
      if(logger.isDebugEnabled()) {
        logger.debug("rest-api call to setLogLevel with level = {}", level != null ? level : "(null)");
      }
      LogLevel logLevel = null;
      try {
        if (LogLevel.isValidLogLevel(level)) {
          logLevel = new LogLevel(level);
          // The parameterless (no instanceId) version could set either the
          // local or the global log level.
          // For now, it sets the global level.
          setGlobalLogLevel(logLevel);
        } else {
View Full Code Here

TOP

Related Classes of com.alu.e3.data.model.LogLevel

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.