aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-db/src/main/java/org/sonar
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2017-01-30 14:48:10 +0100
committerJulien Lancelot <julien.lancelot@sonarsource.com>2017-01-31 08:31:36 +0100
commite3b230f9cc494554e44904bbf7fce61c74caeac0 (patch)
treecbd1ca02d167fb723fa379d4044bb08b525f0441 /sonar-db/src/main/java/org/sonar
parent7a7bc3f594998a08af666c076d71c774d37160c5 (diff)
downloadsonarqube-e3b230f9cc494554e44904bbf7fce61c74caeac0.tar.gz
sonarqube-e3b230f9cc494554e44904bbf7fce61c74caeac0.zip
SONAR-7299 Fail when project name is empty
Diffstat (limited to 'sonar-db/src/main/java/org/sonar')
-rw-r--r--sonar-db/src/main/java/org/sonar/db/component/ComponentValidator.java4
1 files changed, 4 insertions, 0 deletions
diff --git a/sonar-db/src/main/java/org/sonar/db/component/ComponentValidator.java b/sonar-db/src/main/java/org/sonar/db/component/ComponentValidator.java
index c352c2471d4..bfc0d9f7e59 100644
--- a/sonar-db/src/main/java/org/sonar/db/component/ComponentValidator.java
+++ b/sonar-db/src/main/java/org/sonar/db/component/ComponentValidator.java
@@ -21,6 +21,7 @@
package org.sonar.db.component;
import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Strings.isNullOrEmpty;
import static org.sonar.core.component.ComponentKeys.MAX_COMPONENT_KEY_LENGTH;
public class ComponentValidator {
@@ -32,18 +33,21 @@ public class ComponentValidator {
}
public static String checkComponentName(String name) {
+ checkArgument(!isNullOrEmpty(name), "Component name can't be empty");
checkArgument(name.length() <= MAX_COMPONENT_NAME_LENGTH, "Component name length (%s) is longer than the maximum authorized (%s). '%s' was provided.",
name.length(), MAX_COMPONENT_NAME_LENGTH, name);
return name;
}
public static String checkComponentKey(String key) {
+ checkArgument(!isNullOrEmpty(key), "Component key can't be empty");
checkArgument(key.length() <= MAX_COMPONENT_KEY_LENGTH, "Component key length (%s) is longer than the maximum authorized (%s). '%s' was provided.",
key.length(), MAX_COMPONENT_KEY_LENGTH, key);
return key;
}
public static String checkComponentQualifier(String qualifier) {
+ checkArgument(!isNullOrEmpty(qualifier), "Component qualifier can't be empty");
checkArgument(qualifier.length() <= MAX_COMPONENT_QUALIFIER_LENGTH, "Component qualifier length (%s) is longer than the maximum authorized (%s). '%s' was provided.",
qualifier.length(), MAX_COMPONENT_QUALIFIER_LENGTH, qualifier);
return qualifier;