Search in sources :

Example 6 with MessageException

use of org.sonar.process.MessageException in project sonarqube by SonarSource.

the class EsSettings method getFileNameFromPathProperty.

private String getFileNameFromPathProperty(ProcessProperties.Property processProperty) {
    String processPropertyPath = props.value(processProperty.getKey());
    if (processPropertyPath == null) {
        throw new MessageException(processProperty.name() + " property need to be set " + "when using elastic search authentication");
    }
    Path path = Paths.get(processPropertyPath);
    if (!path.toFile().exists()) {
        throw new MessageException("Unable to configure: " + processProperty.getKey() + ". " + "File specified in [" + processPropertyPath + "] does not exist");
    }
    if (!path.toFile().canRead()) {
        throw new MessageException("Unable to configure: " + processProperty.getKey() + ". " + "Could not get read access to [" + processPropertyPath + "]");
    }
    return path.getFileName().toString();
}
Also used : Path(java.nio.file.Path) MessageException(org.sonar.process.MessageException)

Aggregations

MessageException (org.sonar.process.MessageException)6 File (java.io.File)2 Test (org.junit.Test)2 LoggerContext (ch.qos.logback.classic.LoggerContext)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 Props (org.sonar.process.Props)1