aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ServerClient.java
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@gmail.com>2013-01-17 18:38:55 +0100
committerJulien Lancelot <julien.lancelot@gmail.com>2013-01-17 18:39:12 +0100
commit06270f8f95a8ea553b491d9139cad77926a93db6 (patch)
tree95dee231f154707444ca4342ad19407bc61bf3d1 /sonar-batch/src/main/java/org/sonar/batch/bootstrap/ServerClient.java
parent2d80a79c182283831b0b32047fa5f78580dd767e (diff)
downloadsonarqube-06270f8f95a8ea553b491d9139cad77926a93db6.tar.gz
sonarqube-06270f8f95a8ea553b491d9139cad77926a93db6.zip
SONAR-4048 improve access denied message during analysis
Diffstat (limited to 'sonar-batch/src/main/java/org/sonar/batch/bootstrap/ServerClient.java')
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/bootstrap/ServerClient.java11
1 files changed, 10 insertions, 1 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ServerClient.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ServerClient.java
index eabee747fa5..8f6b79364d9 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ServerClient.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ServerClient.java
@@ -96,9 +96,18 @@ public class ServerClient implements BatchComponent {
private SonarException handleHttpException(HttpDownloader.HttpException he) {
if (he.getResponseCode() == 401) {
- throw new SonarException(String.format("Not authorized. Please check the properties %s and %s.", CoreProperties.LOGIN, CoreProperties.PASSWORD));
+ throw new SonarException(String.format(getMessageWhenNotAuthorized(), CoreProperties.LOGIN, CoreProperties.PASSWORD));
}
throw new SonarException(String.format("Fail to execute request [code=%s, url=%s]", he.getResponseCode(), he.getUri()), he);
}
+ private String getMessageWhenNotAuthorized(){
+ String login = settings.getProperty(CoreProperties.LOGIN);
+ String password = settings.getProperty(CoreProperties.PASSWORD);
+ if (StringUtils.isEmpty(login) && StringUtils.isEmpty(password)) {
+ return "Not authorized. Analyzing this project requires to be authenticated. Please provide the values of the properties %s and %s.";
+ }
+ return "Not authorized. Please check the properties %s and %s.";
+ }
+
}