package org.sonar.server.permission.ws;
-import com.google.common.base.CharMatcher;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
import javax.annotation.Nullable;
import org.sonar.core.permission.ProjectPermissions;
import org.sonar.server.exceptions.BadRequestException;
+import static com.google.common.base.CharMatcher.WHITESPACE;
import static com.google.common.base.Strings.isNullOrEmpty;
import static java.lang.String.format;
import static org.sonar.api.security.DefaultGroups.isAnyone;
}
public static void validateTemplateNameFormat(String name) {
- String nameWithoutWhitespaces = CharMatcher.WHITESPACE.removeFrom(name);
+ String nameWithoutWhitespaces = WHITESPACE.trimFrom(name);
checkRequest(!nameWithoutWhitespaces.isEmpty(), MSG_TEMPLATE_NAME_NOT_BLANK);
}
*/
package org.sonar.api.server.ws.internal;
+import com.google.common.base.CharMatcher;
import com.google.common.base.Splitter;
import com.google.common.collect.Lists;
-import org.apache.commons.lang.StringUtils;
-import org.sonar.api.server.ws.Request;
-import org.sonar.api.server.ws.WebService;
-import org.sonar.api.utils.log.Loggers;
-
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
+import javax.annotation.CheckForNull;
+import javax.annotation.Nullable;
+import org.apache.commons.lang.StringUtils;
+import org.sonar.api.server.ws.Request;
+import org.sonar.api.server.ws.WebService;
+import org.sonar.api.utils.log.Loggers;
/**
* @since 4.2
private String param(String key, boolean validateValue) {
WebService.Param definition = action.param(key);
String value = readParamOrDefaultValue(key, definition);
- if (value != null && validateValue) {
- validate(value, definition);
+ String trimmedValue = value == null ? value : CharMatcher.WHITESPACE.trimFrom(value);
+ if (trimmedValue != null && validateValue) {
+ validate(trimmedValue, definition);
}
- return value;
+ return trimmedValue;
}
@CheckForNull