diff options
author | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2019-08-12 11:16:43 +0200 |
---|---|---|
committer | SonarTech <sonartech@sonarsource.com> | 2019-08-14 20:21:14 +0200 |
commit | e9ae396829a95e449d2e02934fc0567e7f09f833 (patch) | |
tree | 35d6ef00a01d5914a29985b3708311db30b8535b /server/sonar-server | |
parent | 3a3948b47bcb86fe0bb7c427397303f54bfaa0ed (diff) | |
download | sonarqube-e9ae396829a95e449d2e02934fc0567e7f09f833.tar.gz sonarqube-e9ae396829a95e449d2e02934fc0567e7f09f833.zip |
move some WSUtils methods to NotFoundException and ServerException
Diffstat (limited to 'server/sonar-server')
21 files changed, 23 insertions, 24 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/component/ComponentFinder.java b/server/sonar-server/src/main/java/org/sonar/server/component/ComponentFinder.java index 847d9d68653..86259eb3d01 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/component/ComponentFinder.java +++ b/server/sonar-server/src/main/java/org/sonar/server/component/ComponentFinder.java @@ -36,8 +36,8 @@ import org.sonar.server.exceptions.NotFoundException; import static com.google.common.base.Preconditions.checkArgument; import static java.lang.String.format; -import static org.sonar.server.ws.WsUtils.checkFoundWithOptional; -import static org.sonar.server.ws.WsUtils.checkRequest; +import static org.sonar.server.exceptions.NotFoundException.checkFoundWithOptional; +import static org.sonar.server.exceptions.BadRequestException.checkRequest; public class ComponentFinder { private static final String MSG_COMPONENT_ID_OR_KEY_TEMPLATE = "Either '%s' or '%s' must be provided"; diff --git a/server/sonar-server/src/main/java/org/sonar/server/component/ComponentService.java b/server/sonar-server/src/main/java/org/sonar/server/component/ComponentService.java index 2b25909072c..bdef35a72ff 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/component/ComponentService.java +++ b/server/sonar-server/src/main/java/org/sonar/server/component/ComponentService.java @@ -42,7 +42,7 @@ import static java.util.Collections.singleton; import static java.util.Collections.singletonList; import static org.sonar.core.component.ComponentKeys.isValidProjectKey; import static org.sonar.db.component.ComponentKeyUpdaterDao.checkIsProjectOrModule; -import static org.sonar.server.ws.WsUtils.checkRequest; +import static org.sonar.server.exceptions.BadRequestException.checkRequest; @ServerSide public class ComponentService { diff --git a/server/sonar-server/src/main/java/org/sonar/server/component/ComponentUpdater.java b/server/sonar-server/src/main/java/org/sonar/server/component/ComponentUpdater.java index 564dd64524a..f39283fef5f 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/component/ComponentUpdater.java +++ b/server/sonar-server/src/main/java/org/sonar/server/component/ComponentUpdater.java @@ -42,7 +42,7 @@ import org.sonar.server.permission.PermissionTemplateService; import static java.util.Collections.singletonList; import static org.sonar.api.resources.Qualifiers.PROJECT; import static org.sonar.core.component.ComponentKeys.isValidProjectKey; -import static org.sonar.server.ws.WsUtils.checkRequest; +import static org.sonar.server.exceptions.BadRequestException.checkRequest; public class ComponentUpdater { diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/AssignAction.java b/server/sonar-server/src/main/java/org/sonar/server/issue/AssignAction.java index 87105457585..884fad73b69 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/AssignAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/AssignAction.java @@ -34,7 +34,7 @@ import org.sonar.server.user.UserSession; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Strings.isNullOrEmpty; -import static org.sonar.server.ws.WsUtils.checkFound; +import static org.sonar.server.exceptions.NotFoundException.checkFound; @ServerSide public class AssignAction extends Action { diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/ApplyPermissionTemplateQuery.java b/server/sonar-server/src/main/java/org/sonar/server/permission/ApplyPermissionTemplateQuery.java index 42d163ab66c..f3b58fe6c02 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/ApplyPermissionTemplateQuery.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/ApplyPermissionTemplateQuery.java @@ -22,7 +22,7 @@ package org.sonar.server.permission; import java.util.List; import static org.apache.commons.lang.StringUtils.isNotBlank; -import static org.sonar.server.ws.WsUtils.checkRequest; +import static org.sonar.server.exceptions.BadRequestException.checkRequest; public class ApplyPermissionTemplateQuery { diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/GroupPermissionChanger.java b/server/sonar-server/src/main/java/org/sonar/server/permission/GroupPermissionChanger.java index f285f7b0d25..5e6a0a48dd0 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/GroupPermissionChanger.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/GroupPermissionChanger.java @@ -30,7 +30,7 @@ import static org.sonar.core.permission.GlobalPermissions.SYSTEM_ADMIN; import static org.sonar.server.permission.PermissionChange.Operation.ADD; import static org.sonar.server.permission.PermissionChange.Operation.REMOVE; import static org.sonar.server.permission.RequestValidator.validateNotAnyoneAndAdminPermission; -import static org.sonar.server.ws.WsUtils.checkRequest; +import static org.sonar.server.exceptions.BadRequestException.checkRequest; public class GroupPermissionChanger { diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/PermissionChange.java b/server/sonar-server/src/main/java/org/sonar/server/permission/PermissionChange.java index 8fe28ff7872..94ed74562d5 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/PermissionChange.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/PermissionChange.java @@ -26,7 +26,7 @@ import org.sonar.db.permission.OrganizationPermission; import static java.util.Objects.requireNonNull; import static org.sonar.core.util.stream.MoreCollectors.toList; -import static org.sonar.server.ws.WsUtils.checkRequest; +import static org.sonar.server.exceptions.BadRequestException.checkRequest; public abstract class PermissionChange { diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/RequestValidator.java b/server/sonar-server/src/main/java/org/sonar/server/permission/RequestValidator.java index be763cce0e2..8fe5e6ba069 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/RequestValidator.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/RequestValidator.java @@ -29,11 +29,10 @@ import org.sonar.api.resources.ResourceType; import org.sonar.api.resources.ResourceTypes; import org.sonar.core.permission.GlobalPermissions; import org.sonar.server.exceptions.BadRequestException; -import org.sonar.server.ws.WsUtils; import static com.google.common.base.Strings.isNullOrEmpty; import static java.lang.String.format; -import static org.sonar.server.ws.WsUtils.checkRequest; +import static org.sonar.server.exceptions.BadRequestException.checkRequest; import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_PERMISSION; import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_PROJECT_KEY_PATTERN; import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_QUALIFIER; @@ -49,7 +48,7 @@ public class RequestValidator { } public String validateProjectPermission(String permission) { - WsUtils.checkRequest(permissionService.getAllProjectPermissions().contains(permission), + BadRequestException.checkRequest(permissionService.getAllProjectPermissions().contains(permission), String.format("The '%s' parameter for project permissions must be one of %s. '%s' was passed.", PARAM_PERMISSION, allProjectsPermissionsOnOneLine, permission)); return permission; diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/UserPermissionChanger.java b/server/sonar-server/src/main/java/org/sonar/server/permission/UserPermissionChanger.java index 62d4a15ff64..04239af9724 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/UserPermissionChanger.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/UserPermissionChanger.java @@ -29,7 +29,7 @@ import static org.sonar.api.web.UserRole.PUBLIC_PERMISSIONS; import static org.sonar.core.permission.GlobalPermissions.SYSTEM_ADMIN; import static org.sonar.server.permission.PermissionChange.Operation.ADD; import static org.sonar.server.permission.PermissionChange.Operation.REMOVE; -import static org.sonar.server.ws.WsUtils.checkRequest; +import static org.sonar.server.exceptions.BadRequestException.checkRequest; /** * Adds and removes user permissions. Both global and project scopes are supported. diff --git a/server/sonar-server/src/main/java/org/sonar/server/plugins/PluginDownloader.java b/server/sonar-server/src/main/java/org/sonar/server/plugins/PluginDownloader.java index c958b7c834b..d61efac304c 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/plugins/PluginDownloader.java +++ b/server/sonar-server/src/main/java/org/sonar/server/plugins/PluginDownloader.java @@ -45,7 +45,7 @@ import static org.apache.commons.io.FileUtils.forceMkdir; import static org.apache.commons.io.FileUtils.toFile; import static org.apache.commons.lang.StringUtils.substringAfterLast; import static org.sonar.core.util.FileUtils.deleteQuietly; -import static org.sonar.server.ws.WsUtils.checkRequest; +import static org.sonar.server.exceptions.BadRequestException.checkRequest; /** * Downloads plugins from update center. Files are copied in the directory extensions/downloads and then diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualitygate/QualityGateConditionsUpdater.java b/server/sonar-server/src/main/java/org/sonar/server/qualitygate/QualityGateConditionsUpdater.java index e4fd0b477c0..fb9400b9525 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualitygate/QualityGateConditionsUpdater.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualitygate/QualityGateConditionsUpdater.java @@ -56,7 +56,7 @@ import static org.sonar.server.measure.Rating.E; import static org.sonar.server.qualitygate.Condition.Operator.GREATER_THAN; import static org.sonar.server.qualitygate.Condition.Operator.LESS_THAN; import static org.sonar.server.qualitygate.ValidRatingMetrics.isCoreRatingMetric; -import static org.sonar.server.ws.WsUtils.checkRequest; +import static org.sonar.server.exceptions.BadRequestException.checkRequest; public class QualityGateConditionsUpdater { diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileExporters.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileExporters.java index 89ad36e61f5..43e795587ae 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileExporters.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileExporters.java @@ -56,7 +56,7 @@ import org.sonar.db.rule.RuleDefinitionDto; import org.sonar.server.exceptions.BadRequestException; import org.sonar.server.exceptions.NotFoundException; -import static org.sonar.server.ws.WsUtils.checkRequest; +import static org.sonar.server.exceptions.BadRequestException.checkRequest; @ServerSide public class QProfileExporters { diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileFactoryImpl.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileFactoryImpl.java index aef07c464c5..580f13aa45e 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileFactoryImpl.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileFactoryImpl.java @@ -39,7 +39,7 @@ import org.sonar.server.exceptions.BadRequestException; import org.sonar.server.qualityprofile.index.ActiveRuleIndexer; import static com.google.common.base.Preconditions.checkArgument; -import static org.sonar.server.ws.WsUtils.checkRequest; +import static org.sonar.server.exceptions.BadRequestException.checkRequest; public class QProfileFactoryImpl implements QProfileFactory { diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileTreeImpl.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileTreeImpl.java index b50a32a9d96..af5f778d0ed 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileTreeImpl.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileTreeImpl.java @@ -33,7 +33,7 @@ import org.sonar.db.qualityprofile.QProfileDto; import org.sonar.server.exceptions.BadRequestException; import org.sonar.server.qualityprofile.index.ActiveRuleIndexer; -import static org.sonar.server.ws.WsUtils.checkRequest; +import static org.sonar.server.exceptions.BadRequestException.checkRequest; public class QProfileTreeImpl implements QProfileTree { diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivationContext.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivationContext.java index c96a3c75ac4..28a55cdb37f 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivationContext.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivationContext.java @@ -42,7 +42,7 @@ import static java.util.Objects.requireNonNull; import static org.sonar.core.util.stream.MoreCollectors.index; import static org.sonar.core.util.stream.MoreCollectors.toArrayList; import static org.sonar.core.util.stream.MoreCollectors.uniqueIndex; -import static org.sonar.server.ws.WsUtils.checkRequest; +import static org.sonar.server.exceptions.BadRequestException.checkRequest; /** * Cache of the data required to activate/deactivate diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivator.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivator.java index 8d36ea471c0..2b5a2f8e19f 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivator.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivator.java @@ -52,7 +52,7 @@ import org.sonar.server.user.UserSession; import org.sonar.server.util.TypeValidations; import static com.google.common.base.Preconditions.checkArgument; -import static org.sonar.server.ws.WsUtils.checkRequest; +import static org.sonar.server.exceptions.BadRequestException.checkRequest; /** * Activation and deactivation of rules in Quality profiles diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/RuleCreator.java b/server/sonar-server/src/main/java/org/sonar/server/rule/RuleCreator.java index 691fccc29e8..5a4074a20bd 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/rule/RuleCreator.java +++ b/server/sonar-server/src/main/java/org/sonar/server/rule/RuleCreator.java @@ -49,7 +49,7 @@ import org.sonar.server.util.TypeValidations; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.collect.Lists.newArrayList; import static java.lang.String.format; -import static org.sonar.server.ws.WsUtils.checkRequest; +import static org.sonar.server.exceptions.BadRequestException.checkRequest; @ServerSide public class RuleCreator { diff --git a/server/sonar-server/src/main/java/org/sonar/server/user/UserUpdater.java b/server/sonar-server/src/main/java/org/sonar/server/user/UserUpdater.java index 7ed5e8d49d5..4c41bbd9ff7 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/user/UserUpdater.java +++ b/server/sonar-server/src/main/java/org/sonar/server/user/UserUpdater.java @@ -58,7 +58,7 @@ import static org.sonar.api.CoreProperties.DEFAULT_ISSUE_ASSIGNEE; import static org.sonar.core.util.Slug.slugify; import static org.sonar.core.util.stream.MoreCollectors.toList; import static org.sonar.process.ProcessProperties.Property.ONBOARDING_TUTORIAL_SHOW_TO_NEW_USERS; -import static org.sonar.server.ws.WsUtils.checkRequest; +import static org.sonar.server.exceptions.BadRequestException.checkRequest; @ServerSide public class UserUpdater { diff --git a/server/sonar-server/src/main/java/org/sonar/server/util/BooleanTypeValidation.java b/server/sonar-server/src/main/java/org/sonar/server/util/BooleanTypeValidation.java index 6dee27fde5d..1b3ade32e60 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/util/BooleanTypeValidation.java +++ b/server/sonar-server/src/main/java/org/sonar/server/util/BooleanTypeValidation.java @@ -24,7 +24,7 @@ import javax.annotation.Nullable; import org.apache.commons.lang.StringUtils; import org.sonar.api.PropertyType; -import static org.sonar.server.ws.WsUtils.checkRequest; +import static org.sonar.server.exceptions.BadRequestException.checkRequest; public class BooleanTypeValidation implements TypeValidation { diff --git a/server/sonar-server/src/main/java/org/sonar/server/util/StringListTypeValidation.java b/server/sonar-server/src/main/java/org/sonar/server/util/StringListTypeValidation.java index 48e224fb963..acb1c7dca8f 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/util/StringListTypeValidation.java +++ b/server/sonar-server/src/main/java/org/sonar/server/util/StringListTypeValidation.java @@ -24,7 +24,7 @@ import javax.annotation.Nullable; import org.apache.commons.lang.StringUtils; import org.sonar.api.PropertyType; -import static org.sonar.server.ws.WsUtils.checkRequest; +import static org.sonar.server.exceptions.BadRequestException.checkRequest; public class StringListTypeValidation implements TypeValidation { diff --git a/server/sonar-server/src/main/java/org/sonar/server/util/TypeValidations.java b/server/sonar-server/src/main/java/org/sonar/server/util/TypeValidations.java index 0766d073ed5..2c8883b77eb 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/util/TypeValidations.java +++ b/server/sonar-server/src/main/java/org/sonar/server/util/TypeValidations.java @@ -26,7 +26,7 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.sonar.api.server.ServerSide; -import static org.sonar.server.ws.WsUtils.checkRequest; +import static org.sonar.server.exceptions.BadRequestException.checkRequest; @ServerSide public class TypeValidations { |