Package org.sonar.api.utils

Examples of org.sonar.api.utils.SonarException


     * @return The executable.
     */
    private AbstractRule createExecutableFromRule(Rule rule) {
        RuleParam cypherParam = rule.getParam(RuleParameter.Cypher.getName());
        if (cypherParam == null) {
            throw new SonarException("Cannot determine cypher for " + rule);
        }
        String cypher = cypherParam.getDefaultValue();
        return createExecutableFromRule(rule, cypher);
    }
View Full Code Here


     * @return The executable.
     */
    private AbstractRule createExecutableFromRule(Rule rule, String cypher) {
        RuleParam typeParam = rule.getParam(RuleParameter.Type.getName());
        if (typeParam == null) {
            throw new SonarException("Cannot determine type of rule for " + rule);
        }
        AbstractRule executable;
        String type = typeParam.getDefaultValue();
        RuleType ruleType = RuleType.valueOf(type);
        switch (ruleType) {
        case Concept:
            executable = new Concept();
            break;
        case Constraint:
            executable = new Constraint();
            break;
        default:
            throw new SonarException("Rule type is not supported " + ruleType);
        }
        createExecutable(executable, rule.getName(), rule.getDescription(), cypher);
        return executable;
    }
View Full Code Here

        if (check instanceof ConceptTemplateRule) {
            executable = new Concept();
        } else if (check instanceof ConstraintTemplateRule) {
            executable = new Constraint();
        } else {
            throw new SonarException("Unknown type " + check.getClass());
        }
        createExecutable(executable, activeRule.getRule().getName(), activeRule.getRule().getDescription(), check.getCypher());
        return executable;
    }
View Full Code Here

        PluginConfigurationReader pluginConfigurationReader = new PluginConfigurationReaderImpl();
        RulePluginRepository rulePluginRepository;
        try {
            rulePluginRepository = new RulePluginRepositoryImpl(pluginConfigurationReader);
        } catch (PluginRepositoryException e) {
            throw new SonarException("Cannot read rules.", e);
        }
        List<Source> ruleSources = rulePluginRepository.getRuleSources();
        RuleSetReader ruleSetReader = new RuleSetReaderImpl();
        RuleSet ruleSet = ruleSetReader.read(ruleSources);
        for (Concept concept : ruleSet.getConcepts().values()) {
View Full Code Here

    private JqassistantReport readReport(File reportFile) {
        try {
            Unmarshaller unmarshaller = reportContext.createUnmarshaller();
            return unmarshaller.unmarshal(new StreamSource(reportFile), JqassistantReport.class).getValue();
        } catch (JAXBException e) {
            throw new SonarException("Cannot read jQAssistant report from file " + reportFile, e);
        }
    }
View Full Code Here

      }
      configureFields(activeRule, check);
      return check;

    } catch (InstantiationException e) {
      throw new SonarException(CAN_NOT_INSTANTIATE_THE_CHECK_RELATED_TO_THE_RULE + activeRule, e);

    } catch (IllegalAccessException e) {
      throw new SonarException(CAN_NOT_INSTANTIATE_THE_CHECK_RELATED_TO_THE_RULE + activeRule, e);
    }
  }
View Full Code Here

  private void configureFields(ActiveRule activeRule, Object check) {
    for (ActiveRuleParam param : activeRule.getActiveRuleParams()) {
      Field field = getField(check, param.getKey());
      if (field == null) {
        throw new SonarException("The field " + param.getKey() + " does not exist or is not annotated with @RuleProperty in the class " + check.getClass().getName());
      }
      if (StringUtils.isNotBlank(param.getValue())) {
        configureField(check, field, param.getValue());
      }
    }
View Full Code Here

      } else if (field.getType().equals(Boolean.class)) {
        field.set(check, Boolean.parseBoolean(value));

      } else {
        throw new SonarException("The type of the field " + field + " is not supported: " + field.getType());
      }
    } catch (IllegalAccessException e) {
      throw new SonarException("Can not set the value of the field " + field + " in the class: " + check.getClass().getName(), e);
    }
  }
View Full Code Here

    return index.index(resource, parentReference);
  }

  private void logWarning() {
    if (LOG.isDebugEnabled()) {
      LOG.debug("Plugins are no more responsible for indexing physical resources like directories and files. This is now handled by the platform.", new SonarException(
        "Plugin should not index physical resources"));
    }
  }
View Full Code Here

        return DateUtils.parseDateTime(s);
      } catch(SonarException notDateTime) {
        try {
          return DateUtils.parseDate(s);
        } catch (SonarException notDateEither) {
          throw new SonarException(String.format("'%s' cannot be parsed as either a date or date+time", s));
        }
      }
    }
    return null;
  }
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.