Package org.sonar.api.utils

Examples of org.sonar.api.utils.SonarException


    try {
      ClassLoader parentClassLoader = JdbcDriverHolder.class.getClassLoader();
      classLoader = new JdbcDriverClassLoader(jdbcDriver.toURI().toURL(), parentClassLoader);

    } catch (MalformedURLException e) {
      throw new SonarException("Fail to get URL of : " + jdbcDriver.getAbsolutePath(), e);
    }

    // set as the current context classloader for hibernate, else it does not find the JDBC driver.
    Thread.currentThread().setContextClassLoader(classLoader);
    return classLoader;
View Full Code Here


      if (Strings.isNullOrEmpty(indexContent)) {
        return new String[] {};
      }
      return indexContent.split("\\|");
    } catch (Exception e) {
      throw new SonarException("Fail to download jdbc-driver index: " + url, e);
    }
  }
View Full Code Here

    File file = new File(path);
    if (!file.isAbsolute()) {
      try {
        file = new File(getBasedir(), path).getCanonicalFile();
      } catch (IOException e) {
        throw new SonarException("Unable to resolve path '" + path + "'", e);
      }
    }
    return file;
  }
View Full Code Here

  /**
   * @since 3.6
   */
  public Rule setStatus(String status) {
    if (!STATUS_LIST.contains(status)) {
      throw new SonarException("The status of a rule can only contain : " + Joiner.on(", ").join(STATUS_LIST));
    }
    this.status = status;
    return this;
  }
View Full Code Here

      List<User> users = userFinder.findByLogins(new ArrayList<String>(userLogins));
      writeUsers(json, users);
      json.endObject().close();

    } catch (IOException e) {
      throw new SonarException("Unable to write JSON report", e);
    }
  }
View Full Code Here

  public Measure addMeasure(Resource resource, Measure measure) {
    Bucket bucket = getBucket(resource);
    if (bucket != null) {
      Metric metric = metricFinder.findByKey(measure.getMetricKey());
      if (metric == null) {
        throw new SonarException("Unknown metric: " + measure.getMetricKey());
      }
      if (!isTechnicalProjectCopy(resource) && !measure.isFromCore() && DefaultSensorContext.INTERNAL_METRICS.contains(metric)) {
        LOG.debug("Metric " + metric.key() + " is an internal metric computed by SonarQube. Please update your plugin.");
        return measure;
      }
      measure.setMetric(metric);
      if (measureCache.contains(resource, measure)) {
        throw new SonarException("Can not add the same measure twice on " + resource + ": " + measure);
      }
      measureCache.put(resource, measure);
    }
    return measure;
  }
View Full Code Here

      } else {
        sourcePersister.saveSource(sonarFile, source, this.projectAnalysisDate);
      }

    } catch (Exception e) {
      throw new SonarException("Unable to read and import the source file : '" + inputFile.absolutePath() + "' with the charset : '"
        + fs.encoding() + "'.", e);
    }
  }
View Full Code Here

      return null;
    }

    String[] fields = StringUtils.splitPreserveAllTokens(line, ';');
    if (fields.length > THREE_FIELDS_PER_LINE) {
      throw new SonarException(CONFIG_FORMAT_ERROR_PREFIX + "The following line has more than 3 fields separated by comma: " + line);
    }

    IssuePattern pattern;
    if (fields.length == THREE_FIELDS_PER_LINE) {
      checkRegularLineConstraints(line, fields);
View Full Code Here

    return pattern;
  }

  static void checkRegularLineConstraints(String line, String[] fields) {
    if (!isResource(fields[0])) {
      throw new SonarException(CONFIG_FORMAT_ERROR_PREFIX + "The first field does not define a resource pattern: " + line);
    }
    if (!isRule(fields[1])) {
      throw new SonarException(CONFIG_FORMAT_ERROR_PREFIX + "The second field does not define a rule pattern: " + line);
    }
    if (!isLinesRange(fields[2])) {
      throw new SonarException(CONFIG_FORMAT_ERROR_PREFIX + "The third field does not define a range of lines: " + line);
    }
  }
View Full Code Here

    }
  }

  static void checkDoubleRegexpLineConstraints(String line, String[] fields) {
    if (!isRegexp(fields[0])) {
      throw new SonarException(CONFIG_FORMAT_ERROR_PREFIX + "The first field does not define a regular expression: " + line);
    }
    // As per configuration help, missing second field means: from start regexp to EOF
  }
View Full Code Here

TOP

Related Classes of org.sonar.api.utils.SonarException

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.