From 69a3a8a2daee4ce4c69f0904decbb6a43946cd0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Pfeuffer?= Date: Thu, 19 Nov 2020 07:59:48 +0100 Subject: [PATCH] Convert update dto classes to interfaces --- .../scm/api/v2/resources/GitConfigDto.java | 2 +- .../api/v2/resources/GitConfigResource.java | 23 ------ .../v2/resources/GitRepositoryConfigDto.java | 4 +- .../GitRepositoryConfigResource.java | 10 --- .../api/v2/resources/UpdateGitConfigDto.java | 46 +++++++++++ .../UpdateGitRepositoryConfigDto.java | 29 +++++++ .../scm/api/v2/resources/HgConfigDto.java | 4 +- .../api/v2/resources/UpdateHgConfigDto.java | 35 ++++----- .../scm/api/v2/resources/SvnConfigDto.java | 4 +- .../api/v2/resources/SvnConfigResource.java | 14 ---- .../api/v2/resources/UpdateSvnConfigDto.java | 36 +++++++++ .../sonia/scm/api/v2/resources/ApiKeyDto.java | 2 +- .../scm/api/v2/resources/ApiKeyResource.java | 15 ---- .../sonia/scm/api/v2/resources/ConfigDto.java | 2 +- .../scm/api/v2/resources/ConfigResource.java | 35 --------- .../scm/api/v2/resources/CreateApiKeyDto.java | 35 +++++++++ .../scm/api/v2/resources/CreateGroupDto.java | 23 ++---- .../api/v2/resources/CreateRepositoryDto.java | 53 +++++++++++++ .../v2/resources/CreateRepositoryRoleDto.java | 40 ++++++++++ .../scm/api/v2/resources/CreateUserDto.java | 50 ++++++++++++ .../sonia/scm/api/v2/resources/GroupDto.java | 4 +- .../scm/api/v2/resources/GroupResource.java | 23 ------ .../NamespacePermissionResource.java | 4 +- .../api/v2/resources/PermissionListDto.java | 4 +- .../RepositoryCollectionResource.java | 28 ------- .../scm/api/v2/resources/RepositoryDto.java | 4 +- .../v2/resources/RepositoryPermissionDto.java | 4 +- .../RepositoryPermissionRootResource.java | 6 +- .../api/v2/resources/RepositoryResource.java | 28 ------- .../RepositoryRoleCollectionResource.java | 18 ----- .../api/v2/resources/RepositoryRoleDto.java | 4 +- .../v2/resources/RepositoryRoleResource.java | 20 ----- .../scm/api/v2/resources/UpdateConfigDto.java | 77 +++++++++++++++++++ .../scm/api/v2/resources/UpdateGroupDto.java | 50 ++++++++++++ .../v2/resources/UpdatePermissionListDto.java | 14 +--- .../api/v2/resources/UpdateRepositoryDto.java | 55 +++++++++++++ .../UpdateRepositoryPermissionDto.java | 43 +++++++++++ .../v2/resources/UpdateRepositoryRoleDto.java | 43 +++++++++++ .../scm/api/v2/resources/UpdateUserDto.java | 54 +++++++++++++ .../v2/resources/UserCollectionResource.java | 27 ------- .../sonia/scm/api/v2/resources/UserDto.java | 2 +- .../scm/api/v2/resources/UserResource.java | 30 -------- 42 files changed, 664 insertions(+), 340 deletions(-) create mode 100644 scm-plugins/scm-git-plugin/src/main/java/sonia/scm/api/v2/resources/UpdateGitConfigDto.java create mode 100644 scm-plugins/scm-git-plugin/src/main/java/sonia/scm/api/v2/resources/UpdateGitRepositoryConfigDto.java create mode 100644 scm-plugins/scm-svn-plugin/src/main/java/sonia/scm/api/v2/resources/UpdateSvnConfigDto.java create mode 100644 scm-webapp/src/main/java/sonia/scm/api/v2/resources/CreateApiKeyDto.java create mode 100644 scm-webapp/src/main/java/sonia/scm/api/v2/resources/CreateRepositoryDto.java create mode 100644 scm-webapp/src/main/java/sonia/scm/api/v2/resources/CreateRepositoryRoleDto.java create mode 100644 scm-webapp/src/main/java/sonia/scm/api/v2/resources/CreateUserDto.java create mode 100644 scm-webapp/src/main/java/sonia/scm/api/v2/resources/UpdateConfigDto.java create mode 100644 scm-webapp/src/main/java/sonia/scm/api/v2/resources/UpdateGroupDto.java create mode 100644 scm-webapp/src/main/java/sonia/scm/api/v2/resources/UpdateRepositoryDto.java create mode 100644 scm-webapp/src/main/java/sonia/scm/api/v2/resources/UpdateRepositoryPermissionDto.java create mode 100644 scm-webapp/src/main/java/sonia/scm/api/v2/resources/UpdateRepositoryRoleDto.java create mode 100644 scm-webapp/src/main/java/sonia/scm/api/v2/resources/UpdateUserDto.java diff --git a/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/api/v2/resources/GitConfigDto.java b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/api/v2/resources/GitConfigDto.java index 893de773da..99ac469166 100644 --- a/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/api/v2/resources/GitConfigDto.java +++ b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/api/v2/resources/GitConfigDto.java @@ -39,7 +39,7 @@ import static sonia.scm.repository.Branch.VALID_BRANCH_NAMES; @NoArgsConstructor @Getter @Setter -public class GitConfigDto extends HalRepresentation { +public class GitConfigDto extends HalRepresentation implements UpdateGitConfigDto { private boolean disabled = false; diff --git a/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/api/v2/resources/GitConfigResource.java b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/api/v2/resources/GitConfigResource.java index 5357b8d27f..e366a35abb 100644 --- a/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/api/v2/resources/GitConfigResource.java +++ b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/api/v2/resources/GitConfigResource.java @@ -32,10 +32,6 @@ import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.parameters.RequestBody; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.AccessLevel; -import lombok.Getter; -import lombok.NoArgsConstructor; -import org.hibernate.validator.constraints.Length; import sonia.scm.config.ConfigurationPermissions; import sonia.scm.repository.GitConfig; import sonia.scm.repository.GitRepositoryHandler; @@ -45,8 +41,6 @@ import sonia.scm.web.VndMediaType; import javax.inject.Inject; import javax.inject.Provider; import javax.validation.Valid; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.Pattern; import javax.ws.rs.Consumes; import javax.ws.rs.GET; import javax.ws.rs.PUT; @@ -54,8 +48,6 @@ import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.Response; -import static sonia.scm.repository.Branch.VALID_BRANCH_NAMES; - /** * RESTful Web Service Resource to manage the configuration of the git plugin. */ @@ -169,19 +161,4 @@ public class GitConfigResource { public GitRepositoryConfigResource getRepositoryConfig() { return gitRepositoryConfigResource.get(); } - - /** - * This class is currently only used in the openapi scheme - */ - @Getter - @NoArgsConstructor(access = AccessLevel.PRIVATE) - private static final class UpdateGitConfigDto { - private boolean disabled = false; - private String gcExpression; - private boolean nonFastForwardDisallowed; - @NotEmpty - @Length(min = 1, max = 100) - @Pattern(regexp = VALID_BRANCH_NAMES) - private String defaultBranch; - } } diff --git a/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/api/v2/resources/GitRepositoryConfigDto.java b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/api/v2/resources/GitRepositoryConfigDto.java index 92a495669b..46eb671d5c 100644 --- a/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/api/v2/resources/GitRepositoryConfigDto.java +++ b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/api/v2/resources/GitRepositoryConfigDto.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - + package sonia.scm.api.v2.resources; import de.otto.edison.hal.HalRepresentation; @@ -36,7 +36,7 @@ import lombok.Setter; @AllArgsConstructor @NoArgsConstructor @SuppressWarnings("squid:S2160") // there is no proper semantic for equals on this dto -public class GitRepositoryConfigDto extends HalRepresentation { +public class GitRepositoryConfigDto extends HalRepresentation implements UpdateGitRepositoryConfigDto { private String defaultBranch; diff --git a/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/api/v2/resources/GitRepositoryConfigResource.java b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/api/v2/resources/GitRepositoryConfigResource.java index 55627aafee..559dfddae8 100644 --- a/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/api/v2/resources/GitRepositoryConfigResource.java +++ b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/api/v2/resources/GitRepositoryConfigResource.java @@ -167,14 +167,4 @@ public class GitRepositoryConfigResource { private ConfigurationStore getStore(Repository repository) { return gitRepositoryConfigStoreProvider.get(repository); } - - /** - * This class is currently only used in the openapi scheme - */ - @Getter - private static final class UpdateGitRepositoryConfigDto { - private UpdateGitRepositoryConfigDto() { - } - private String defaultBranch; - } } diff --git a/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/api/v2/resources/UpdateGitConfigDto.java b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/api/v2/resources/UpdateGitConfigDto.java new file mode 100644 index 0000000000..66bdcd7278 --- /dev/null +++ b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/api/v2/resources/UpdateGitConfigDto.java @@ -0,0 +1,46 @@ +/* + * MIT License + * + * Copyright (c) 2020-present Cloudogu GmbH and Contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package sonia.scm.api.v2.resources; + +import org.hibernate.validator.constraints.Length; + +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.Pattern; + +import static sonia.scm.repository.Branch.VALID_BRANCH_NAMES; + +interface UpdateGitConfigDto { + + boolean isDisabled(); + + String getGcExpression(); + + boolean isNonFastForwardDisallowed(); + + @NotEmpty + @Length(min = 1, max = 100) + @Pattern(regexp = VALID_BRANCH_NAMES) + String getDefaultBranch(); +} diff --git a/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/api/v2/resources/UpdateGitRepositoryConfigDto.java b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/api/v2/resources/UpdateGitRepositoryConfigDto.java new file mode 100644 index 0000000000..0da843e1af --- /dev/null +++ b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/api/v2/resources/UpdateGitRepositoryConfigDto.java @@ -0,0 +1,29 @@ +/* + * MIT License + * + * Copyright (c) 2020-present Cloudogu GmbH and Contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package sonia.scm.api.v2.resources; + +interface UpdateGitRepositoryConfigDto { + String getDefaultBranch(); +} diff --git a/scm-plugins/scm-hg-plugin/src/main/java/sonia/scm/api/v2/resources/HgConfigDto.java b/scm-plugins/scm-hg-plugin/src/main/java/sonia/scm/api/v2/resources/HgConfigDto.java index b5039cbb44..ec303a4551 100644 --- a/scm-plugins/scm-hg-plugin/src/main/java/sonia/scm/api/v2/resources/HgConfigDto.java +++ b/scm-plugins/scm-hg-plugin/src/main/java/sonia/scm/api/v2/resources/HgConfigDto.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - + package sonia.scm.api.v2.resources; import de.otto.edison.hal.HalRepresentation; @@ -33,7 +33,7 @@ import lombok.Setter; @NoArgsConstructor @Getter @Setter -public class HgConfigDto extends HalRepresentation { +public class HgConfigDto extends HalRepresentation implements UpdateHgConfigDto { private boolean disabled; diff --git a/scm-plugins/scm-hg-plugin/src/main/java/sonia/scm/api/v2/resources/UpdateHgConfigDto.java b/scm-plugins/scm-hg-plugin/src/main/java/sonia/scm/api/v2/resources/UpdateHgConfigDto.java index aa73b6cc6d..743cd2cfaf 100644 --- a/scm-plugins/scm-hg-plugin/src/main/java/sonia/scm/api/v2/resources/UpdateHgConfigDto.java +++ b/scm-plugins/scm-hg-plugin/src/main/java/sonia/scm/api/v2/resources/UpdateHgConfigDto.java @@ -24,23 +24,22 @@ package sonia.scm.api.v2.resources; -import lombok.AccessLevel; -import lombok.Getter; -import lombok.NoArgsConstructor; +interface UpdateHgConfigDto { + boolean isDisabled(); -/** - * This class is currently only used in the openapi scheme - */ -@Getter -@NoArgsConstructor(access = AccessLevel.PRIVATE) -final class UpdateHgConfigDto { - private boolean disabled; - private String hgBinary; - private String pythonBinary; - private String pythonPath; - private String encoding; - private boolean useOptimizedBytecode; - private boolean showRevisionInId; - private boolean disableHookSSLValidation; - private boolean enableHttpPostArgs; + String getHgBinary(); + + String getPythonBinary(); + + String getPythonPath(); + + String getEncoding(); + + boolean isUseOptimizedBytecode(); + + boolean isShowRevisionInId(); + + boolean isDisableHookSSLValidation(); + + boolean isEnableHttpPostArgs(); } diff --git a/scm-plugins/scm-svn-plugin/src/main/java/sonia/scm/api/v2/resources/SvnConfigDto.java b/scm-plugins/scm-svn-plugin/src/main/java/sonia/scm/api/v2/resources/SvnConfigDto.java index 72f7513bb8..9be64e6a3b 100644 --- a/scm-plugins/scm-svn-plugin/src/main/java/sonia/scm/api/v2/resources/SvnConfigDto.java +++ b/scm-plugins/scm-svn-plugin/src/main/java/sonia/scm/api/v2/resources/SvnConfigDto.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - + package sonia.scm.api.v2.resources; import de.otto.edison.hal.HalRepresentation; @@ -34,7 +34,7 @@ import sonia.scm.repository.Compatibility; @NoArgsConstructor @Getter @Setter -public class SvnConfigDto extends HalRepresentation { +public class SvnConfigDto extends HalRepresentation implements UpdateSvnConfigDto { private boolean disabled; diff --git a/scm-plugins/scm-svn-plugin/src/main/java/sonia/scm/api/v2/resources/SvnConfigResource.java b/scm-plugins/scm-svn-plugin/src/main/java/sonia/scm/api/v2/resources/SvnConfigResource.java index eb33cd1b3c..394000c48a 100644 --- a/scm-plugins/scm-svn-plugin/src/main/java/sonia/scm/api/v2/resources/SvnConfigResource.java +++ b/scm-plugins/scm-svn-plugin/src/main/java/sonia/scm/api/v2/resources/SvnConfigResource.java @@ -32,11 +32,7 @@ import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.parameters.RequestBody; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.AccessLevel; -import lombok.Getter; -import lombok.NoArgsConstructor; import sonia.scm.config.ConfigurationPermissions; -import sonia.scm.repository.Compatibility; import sonia.scm.repository.SvnConfig; import sonia.scm.repository.SvnRepositoryHandler; import sonia.scm.web.SvnVndMediaType; @@ -160,14 +156,4 @@ public class SvnConfigResource { return Response.noContent().build(); } - /** - * This class is currently only used in the openapi scheme - */ - @Getter - @NoArgsConstructor(access = AccessLevel.PRIVATE) - private static final class UpdateSvnConfigDto { - private boolean disabled; - private Compatibility compatibility; - private boolean enabledGZip; - } } diff --git a/scm-plugins/scm-svn-plugin/src/main/java/sonia/scm/api/v2/resources/UpdateSvnConfigDto.java b/scm-plugins/scm-svn-plugin/src/main/java/sonia/scm/api/v2/resources/UpdateSvnConfigDto.java new file mode 100644 index 0000000000..87de7d5ec8 --- /dev/null +++ b/scm-plugins/scm-svn-plugin/src/main/java/sonia/scm/api/v2/resources/UpdateSvnConfigDto.java @@ -0,0 +1,36 @@ +/* + * MIT License + * + * Copyright (c) 2020-present Cloudogu GmbH and Contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package sonia.scm.api.v2.resources; + +import sonia.scm.repository.Compatibility; + +interface UpdateSvnConfigDto { + + boolean isDisabled(); + + Compatibility getCompatibility(); + + boolean isEnabledGZip(); +} diff --git a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/ApiKeyDto.java b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/ApiKeyDto.java index b07e329a8a..40cc0feaa0 100644 --- a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/ApiKeyDto.java +++ b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/ApiKeyDto.java @@ -36,7 +36,7 @@ import java.time.Instant; @Getter @Setter @NoArgsConstructor -public class ApiKeyDto extends HalRepresentation { +public class ApiKeyDto extends HalRepresentation implements CreateApiKeyDto { @NotEmpty private String displayName; @NotEmpty diff --git a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/ApiKeyResource.java b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/ApiKeyResource.java index 4270b2b7ae..04dd186b2a 100644 --- a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/ApiKeyResource.java +++ b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/ApiKeyResource.java @@ -32,9 +32,6 @@ import io.swagger.v3.oas.annotations.media.ExampleObject; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.parameters.RequestBody; import io.swagger.v3.oas.annotations.responses.ApiResponse; -import lombok.AccessLevel; -import lombok.Getter; -import lombok.NoArgsConstructor; import sonia.scm.ContextEntry; import sonia.scm.security.ApiKey; import sonia.scm.security.ApiKeyService; @@ -42,7 +39,6 @@ import sonia.scm.web.VndMediaType; import javax.inject.Inject; import javax.validation.Valid; -import javax.validation.constraints.NotEmpty; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.GET; @@ -192,15 +188,4 @@ public class ApiKeyResource { apiKeyService.remove(id); } - /** - * This class is currently only used in the openapi scheme - */ - @Getter - @NoArgsConstructor(access = AccessLevel.PRIVATE) - private static final class CreateApiKeyDto { - @NotEmpty - private String displayName; - @NotEmpty - private String permissionRole; - } } diff --git a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/ConfigDto.java b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/ConfigDto.java index 2b7249c7e7..48b90c9175 100644 --- a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/ConfigDto.java +++ b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/ConfigDto.java @@ -36,7 +36,7 @@ import java.util.Set; @NoArgsConstructor @Getter @Setter -public class ConfigDto extends HalRepresentation { +public class ConfigDto extends HalRepresentation implements UpdateConfigDto { private String proxyPassword; private int proxyPort; diff --git a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/ConfigResource.java b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/ConfigResource.java index ab3fef46ec..13dec7d44e 100644 --- a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/ConfigResource.java +++ b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/ConfigResource.java @@ -33,13 +33,9 @@ import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.parameters.RequestBody; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.AccessLevel; -import lombok.Getter; -import lombok.NoArgsConstructor; import sonia.scm.config.ConfigurationPermissions; import sonia.scm.config.ScmConfiguration; import sonia.scm.repository.NamespaceStrategyValidator; -import sonia.scm.security.AnonymousMode; import sonia.scm.util.ScmConfigurationUtil; import sonia.scm.web.VndMediaType; @@ -51,7 +47,6 @@ import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.Response; -import java.util.Set; import java.util.function.Consumer; /** @@ -173,34 +168,4 @@ public class ConfigResource { return Response.noContent().build(); } - /** - * This class is currently only used in the openapi scheme - */ - @Getter - @NoArgsConstructor(access = AccessLevel.PRIVATE) - private static final class UpdateConfigDto { - private String proxyPassword; - private int proxyPort; - private String proxyServer; - private String proxyUser; - private boolean enableProxy; - private String realmDescription; - private boolean disableGroupingGrid; - private String dateFormat; - private boolean anonymousAccessEnabled; - private AnonymousMode anonymousMode; - private String baseUrl; - private boolean forceBaseUrl; - private int loginAttemptLimit; - private Set proxyExcludes; - private boolean skipFailedAuthenticators; - private String pluginUrl; - private long loginAttemptLimitTimeout; - private boolean enabledXsrfProtection; - private boolean enabledUserConverter; - private String namespaceStrategy; - private String loginInfoUrl; - private String releaseFeedUrl; - private String mailDomainName; - } } diff --git a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/CreateApiKeyDto.java b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/CreateApiKeyDto.java new file mode 100644 index 0000000000..cd7588ffb1 --- /dev/null +++ b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/CreateApiKeyDto.java @@ -0,0 +1,35 @@ +/* + * MIT License + * + * Copyright (c) 2020-present Cloudogu GmbH and Contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package sonia.scm.api.v2.resources; + +import javax.validation.constraints.NotEmpty; + +interface CreateApiKeyDto { + @NotEmpty + String getDisplayName(); + + @NotEmpty + String getPermissionRole(); +} diff --git a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/CreateGroupDto.java b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/CreateGroupDto.java index bc1324e0f1..82ed359010 100644 --- a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/CreateGroupDto.java +++ b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/CreateGroupDto.java @@ -24,26 +24,19 @@ package sonia.scm.api.v2.resources; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; import sonia.scm.util.ValidationUtil; import javax.validation.constraints.Pattern; import java.util.List; -/** - * This class is currently only used in the openapi scheme - */ -@Getter -@Setter -@NoArgsConstructor -public class CreateGroupDto { +interface CreateGroupDto { @Pattern(regexp = ValidationUtil.REGEX_NAME) - private String name; - private String description; - private String type; - private List members; - private boolean external; + String getName(); + + String getDescription(); + + List getMembers(); + + boolean isExternal(); } diff --git a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/CreateRepositoryDto.java b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/CreateRepositoryDto.java new file mode 100644 index 0000000000..29d41bc075 --- /dev/null +++ b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/CreateRepositoryDto.java @@ -0,0 +1,53 @@ +/* + * MIT License + * + * Copyright (c) 2020-present Cloudogu GmbH and Contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package sonia.scm.api.v2.resources; + +import sonia.scm.util.ValidationUtil; + +import javax.validation.constraints.Email; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.Pattern; +import java.time.Instant; +import java.util.List; + +interface CreateRepositoryDto { + + String getNamespace(); + + @Pattern(regexp = ValidationUtil.REGEX_REPOSITORYNAME) + String getName(); + + @NotEmpty + String getType(); + + @Email + String getContact(); + + String getDescription(); + + List getHealthCheckFailures(); + + Instant getLastModified(); +} diff --git a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/CreateRepositoryRoleDto.java b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/CreateRepositoryRoleDto.java new file mode 100644 index 0000000000..0f524d39f2 --- /dev/null +++ b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/CreateRepositoryRoleDto.java @@ -0,0 +1,40 @@ +/* + * MIT License + * + * Copyright (c) 2020-present Cloudogu GmbH and Contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package sonia.scm.api.v2.resources; + +import javax.validation.constraints.NotEmpty; +import java.util.Collection; + +interface CreateRepositoryRoleDto { + + @NotEmpty + String getName(); + + @NoBlankStrings + @NotEmpty + Collection getVerbs(); + + String getType(); +} diff --git a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/CreateUserDto.java b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/CreateUserDto.java new file mode 100644 index 0000000000..ff0b36b404 --- /dev/null +++ b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/CreateUserDto.java @@ -0,0 +1,50 @@ +/* + * MIT License + * + * Copyright (c) 2020-present Cloudogu GmbH and Contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package sonia.scm.api.v2.resources; + +import sonia.scm.util.ValidationUtil; + +import javax.validation.constraints.Email; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.Pattern; + +interface CreateUserDto { + @Pattern(regexp = ValidationUtil.REGEX_NAME) + String getName(); + + @NotEmpty + String getDisplayName(); + + @Email + String getMail(); + + boolean isExternal(); + + String getPassword(); + + boolean isActive(); + + String getType(); +} diff --git a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/GroupDto.java b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/GroupDto.java index 24939609b3..8881470216 100644 --- a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/GroupDto.java +++ b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/GroupDto.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - + package sonia.scm.api.v2.resources; import com.fasterxml.jackson.annotation.JsonInclude; @@ -40,7 +40,7 @@ import java.util.List; @Getter @Setter @NoArgsConstructor -public class GroupDto extends HalRepresentation { +public class GroupDto extends HalRepresentation implements UpdateGroupDto, CreateGroupDto { private Instant creationDate; private String description; diff --git a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/GroupResource.java b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/GroupResource.java index 8245430c46..00a41d7526 100644 --- a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/GroupResource.java +++ b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/GroupResource.java @@ -24,24 +24,18 @@ package sonia.scm.api.v2.resources; -import com.fasterxml.jackson.annotation.JsonInclude; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.ExampleObject; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.parameters.RequestBody; import io.swagger.v3.oas.annotations.responses.ApiResponse; -import lombok.AccessLevel; -import lombok.Getter; -import lombok.NoArgsConstructor; import sonia.scm.group.Group; import sonia.scm.group.GroupManager; -import sonia.scm.util.ValidationUtil; import sonia.scm.web.VndMediaType; import javax.inject.Inject; import javax.validation.Valid; -import javax.validation.constraints.Pattern; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.GET; @@ -50,8 +44,6 @@ import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.Response; -import java.time.Instant; -import java.util.List; public class GroupResource { @@ -190,19 +182,4 @@ public class GroupResource { return groupPermissionResource; } - /** - * This class is currently only used in the openapi scheme - */ - @Getter - @NoArgsConstructor(access = AccessLevel.PRIVATE) - private static final class UpdateGroupDto { - @Pattern(regexp = ValidationUtil.REGEX_NAME) - private String name; - private String description; - @JsonInclude(JsonInclude.Include.NON_NULL) - private Instant lastModified; - private String type; - private List members; - private boolean external; - } } diff --git a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/NamespacePermissionResource.java b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/NamespacePermissionResource.java index ed507c7ba5..68ead6ec60 100644 --- a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/NamespacePermissionResource.java +++ b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/NamespacePermissionResource.java @@ -98,7 +98,7 @@ public class NamespacePermissionResource { requestBody = @RequestBody( content = @Content( mediaType = VndMediaType.REPOSITORY_PERMISSION, - schema = @Schema(implementation = UpdatePermissionListDto.class), + schema = @Schema(implementation = UpdateRepositoryPermissionDto.class), examples = @ExampleObject( name = "Add read permissions for repositories and pull requests to manager group.", value = "{\n \"name\":\"manager\",\n \"verbs\":[\"read\",\"readPullRequest\"],\n \"groupPermission\":true\n}", @@ -244,7 +244,7 @@ public class NamespacePermissionResource { requestBody = @RequestBody( content = @Content( mediaType = VndMediaType.REPOSITORY_PERMISSION, - schema = @Schema(implementation = UpdatePermissionListDto.class), + schema = @Schema(implementation = UpdateRepositoryPermissionDto.class), examples = @ExampleObject( name = "Update permissions of manager group.", value = "{\n \"name\":\"manager\",\n \"verbs\":[\"read\",\"permissionRead\",\"readPullRequest\"],\n \"groupPermission\":true\n}", diff --git a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/PermissionListDto.java b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/PermissionListDto.java index 0a4ae5a1a5..1cfd13d3ad 100644 --- a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/PermissionListDto.java +++ b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/PermissionListDto.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - + package sonia.scm.api.v2.resources; import de.otto.edison.hal.HalRepresentation; @@ -37,7 +37,7 @@ import javax.validation.constraints.NotNull; @Setter @AllArgsConstructor @NoArgsConstructor -public class PermissionListDto extends HalRepresentation { +public class PermissionListDto extends HalRepresentation implements UpdatePermissionListDto { @NotNull private String[] permissions; diff --git a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/RepositoryCollectionResource.java b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/RepositoryCollectionResource.java index 41e5a8a7e4..19d2daf8bd 100644 --- a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/RepositoryCollectionResource.java +++ b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/RepositoryCollectionResource.java @@ -24,7 +24,6 @@ package sonia.scm.api.v2.resources; -import com.fasterxml.jackson.annotation.JsonInclude; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.headers.Header; import io.swagger.v3.oas.annotations.media.Content; @@ -32,9 +31,6 @@ import io.swagger.v3.oas.annotations.media.ExampleObject; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.parameters.RequestBody; import io.swagger.v3.oas.annotations.responses.ApiResponse; -import lombok.AccessLevel; -import lombok.Getter; -import lombok.NoArgsConstructor; import org.apache.shiro.SecurityUtils; import sonia.scm.repository.Repository; import sonia.scm.repository.RepositoryInitializer; @@ -43,14 +39,10 @@ import sonia.scm.repository.RepositoryPermission; import sonia.scm.search.SearchRequest; import sonia.scm.search.SearchUtil; import sonia.scm.user.User; -import sonia.scm.util.ValidationUtil; import sonia.scm.web.VndMediaType; import javax.inject.Inject; import javax.validation.Valid; -import javax.validation.constraints.Email; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.Pattern; import javax.ws.rs.Consumes; import javax.ws.rs.DefaultValue; import javax.ws.rs.GET; @@ -60,8 +52,6 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.Response; -import java.time.Instant; -import java.util.List; import java.util.concurrent.atomic.AtomicReference; import java.util.function.Predicate; @@ -248,22 +238,4 @@ public class RepositoryCollectionResource { return repository -> SearchUtil.matchesOne(searchRequest, repository.getName(), repository.getNamespace(), repository.getDescription()); } - /** - * This class is currently only used in the openapi scheme - */ - @Getter - @NoArgsConstructor(access = AccessLevel.PRIVATE) - private static final class CreateRepositoryDto { - private String namespace; - @Pattern(regexp = ValidationUtil.REGEX_REPOSITORYNAME) - private String name; - @NotEmpty - private String type; - @Email - private String contact; - private String description; - private List healthCheckFailures; - @JsonInclude(JsonInclude.Include.NON_NULL) - private Instant lastModified; - } } diff --git a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/RepositoryDto.java b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/RepositoryDto.java index 2bb457e029..951470a98c 100644 --- a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/RepositoryDto.java +++ b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/RepositoryDto.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - + package sonia.scm.api.v2.resources; import com.fasterxml.jackson.annotation.JsonInclude; @@ -42,7 +42,7 @@ import java.util.List; @Getter @Setter @NoArgsConstructor -public class RepositoryDto extends HalRepresentation { +public class RepositoryDto extends HalRepresentation implements CreateRepositoryDto, UpdateRepositoryDto { @Email private String contact; diff --git a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/RepositoryPermissionDto.java b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/RepositoryPermissionDto.java index 4c533722b9..05c23f0d73 100644 --- a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/RepositoryPermissionDto.java +++ b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/RepositoryPermissionDto.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - + package sonia.scm.api.v2.resources; import de.otto.edison.hal.HalRepresentation; @@ -39,7 +39,7 @@ import java.util.Collection; @Getter @Setter @ToString @NoArgsConstructor @EitherRoleOrVerbs -public class RepositoryPermissionDto extends HalRepresentation { +public class RepositoryPermissionDto extends HalRepresentation implements UpdateRepositoryPermissionDto { public static final String GROUP_PREFIX = "@"; diff --git a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/RepositoryPermissionRootResource.java b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/RepositoryPermissionRootResource.java index 5883a50d39..e0bfda0824 100644 --- a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/RepositoryPermissionRootResource.java +++ b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/RepositoryPermissionRootResource.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - + package sonia.scm.api.v2.resources; import io.swagger.v3.oas.annotations.Operation; @@ -100,7 +100,7 @@ public class RepositoryPermissionRootResource { requestBody = @RequestBody( content = @Content( mediaType = VndMediaType.REPOSITORY_PERMISSION, - schema = @Schema(implementation = UpdatePermissionListDto.class), + schema = @Schema(implementation = UpdateRepositoryPermissionDto.class), examples = @ExampleObject( name = "Add read permissions for repository and pull requests to manager group.", value = "{\n \"name\":\"manager\",\n \"verbs\":[\"read\",\"readPullRequest\"],\n \"groupPermission\":true\n}", @@ -252,7 +252,7 @@ public class RepositoryPermissionRootResource { requestBody = @RequestBody( content = @Content( mediaType = VndMediaType.REPOSITORY_PERMISSION, - schema = @Schema(implementation = UpdatePermissionListDto.class), + schema = @Schema(implementation = UpdateRepositoryPermissionDto.class), examples = @ExampleObject( name = "Update permissions of manager group.", value = "{\n \"name\":\"manager\",\n \"verbs\":[\"read\",\"permissionRead\",\"readPullRequest\"],\n \"groupPermission\":true\n}", diff --git a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/RepositoryResource.java b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/RepositoryResource.java index ecc044f096..17f82d06b7 100644 --- a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/RepositoryResource.java +++ b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/RepositoryResource.java @@ -24,27 +24,19 @@ package sonia.scm.api.v2.resources; -import com.fasterxml.jackson.annotation.JsonInclude; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.ExampleObject; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.parameters.RequestBody; import io.swagger.v3.oas.annotations.responses.ApiResponse; -import lombok.AccessLevel; -import lombok.Getter; -import lombok.NoArgsConstructor; import sonia.scm.repository.NamespaceAndName; import sonia.scm.repository.Repository; import sonia.scm.repository.RepositoryManager; -import sonia.scm.util.ValidationUtil; import sonia.scm.web.VndMediaType; import javax.inject.Inject; import javax.validation.Valid; -import javax.validation.constraints.Email; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.Pattern; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.GET; @@ -54,8 +46,6 @@ import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.Response; -import java.time.Instant; -import java.util.List; import java.util.Optional; import java.util.function.Predicate; import java.util.function.Supplier; @@ -301,22 +291,4 @@ public class RepositoryResource { return changed -> name.equals(changed.getName()) && namespace.equals(changed.getNamespace()); } - /** - * This class is currently only used in the openapi scheme - */ - @Getter - @NoArgsConstructor(access = AccessLevel.PRIVATE) - private static final class UpdateRepositoryDto { - private String namespace; - @Pattern(regexp = ValidationUtil.REGEX_REPOSITORYNAME) - private String name; - @NotEmpty - private String type; - @Email - private String contact; - private String description; - private List healthCheckFailures; - @JsonInclude(JsonInclude.Include.NON_NULL) - private Instant lastModified; - } } diff --git a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/RepositoryRoleCollectionResource.java b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/RepositoryRoleCollectionResource.java index 946be8e6ee..bd82ac4210 100644 --- a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/RepositoryRoleCollectionResource.java +++ b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/RepositoryRoleCollectionResource.java @@ -31,16 +31,12 @@ import io.swagger.v3.oas.annotations.media.ExampleObject; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.parameters.RequestBody; import io.swagger.v3.oas.annotations.responses.ApiResponse; -import lombok.AccessLevel; -import lombok.Getter; -import lombok.NoArgsConstructor; import sonia.scm.repository.RepositoryRole; import sonia.scm.repository.RepositoryRoleManager; import sonia.scm.web.VndMediaType; import javax.inject.Inject; import javax.validation.Valid; -import javax.validation.constraints.NotEmpty; import javax.ws.rs.Consumes; import javax.ws.rs.DefaultValue; import javax.ws.rs.GET; @@ -49,7 +45,6 @@ import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.Response; -import java.util.Collection; public class RepositoryRoleCollectionResource { @@ -160,17 +155,4 @@ public class RepositoryRoleCollectionResource { return adapter.create(repositoryRole, () -> dtoToRepositoryRoleMapper.map(repositoryRole), u -> resourceLinks.repositoryRole().self(u.getName())); } - /** - * This class is currently only used in the openapi scheme - */ - @Getter - @NoArgsConstructor(access = AccessLevel.PRIVATE) - private static final class CreateRepositoryRoleDto { - @NotEmpty - private String name; - private boolean system; - @NoBlankStrings @NotEmpty - private Collection verbs; - private String type; - } } diff --git a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/RepositoryRoleDto.java b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/RepositoryRoleDto.java index 7efef72826..1174ea48af 100644 --- a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/RepositoryRoleDto.java +++ b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/RepositoryRoleDto.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - + package sonia.scm.api.v2.resources; import de.otto.edison.hal.Embedded; @@ -38,7 +38,7 @@ import java.util.Collection; @Getter @Setter @NoArgsConstructor -public class RepositoryRoleDto extends HalRepresentation { +public class RepositoryRoleDto extends HalRepresentation implements CreateRepositoryRoleDto, UpdateRepositoryRoleDto { @NotEmpty private String name; @NoBlankStrings @NotEmpty diff --git a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/RepositoryRoleResource.java b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/RepositoryRoleResource.java index 72c8fbe4c8..c9367cf655 100644 --- a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/RepositoryRoleResource.java +++ b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/RepositoryRoleResource.java @@ -30,16 +30,12 @@ import io.swagger.v3.oas.annotations.media.ExampleObject; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.parameters.RequestBody; import io.swagger.v3.oas.annotations.responses.ApiResponse; -import lombok.AccessLevel; -import lombok.Getter; -import lombok.NoArgsConstructor; import sonia.scm.repository.RepositoryRole; import sonia.scm.repository.RepositoryRoleManager; import sonia.scm.web.VndMediaType; import javax.inject.Inject; import javax.validation.Valid; -import javax.validation.constraints.NotEmpty; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.GET; @@ -48,8 +44,6 @@ import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.Response; -import java.time.Instant; -import java.util.Collection; public class RepositoryRoleResource { @@ -168,18 +162,4 @@ public class RepositoryRoleResource { return adapter.update(name, existing -> dtoToRepositoryRoleMapper.map(repositoryRole)); } - /** - * This class is currently only used in the openapi scheme - */ - @Getter - @NoArgsConstructor(access = AccessLevel.PRIVATE) - private static final class UpdateRepositoryRoleDto { - @NotEmpty - private String name; - private boolean system; - @NoBlankStrings @NotEmpty - private Collection verbs; - private String type; - private Instant lastModified; - } } diff --git a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/UpdateConfigDto.java b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/UpdateConfigDto.java new file mode 100644 index 0000000000..dbe07a2620 --- /dev/null +++ b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/UpdateConfigDto.java @@ -0,0 +1,77 @@ +/* + * MIT License + * + * Copyright (c) 2020-present Cloudogu GmbH and Contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package sonia.scm.api.v2.resources; + +import sonia.scm.security.AnonymousMode; + +import java.util.Set; + +interface UpdateConfigDto { + String getProxyPassword(); + + int getProxyPort(); + + String getProxyServer(); + + String getProxyUser(); + + boolean isEnableProxy(); + + String getRealmDescription(); + + boolean isDisableGroupingGrid(); + + String getDateFormat(); + + boolean isAnonymousAccessEnabled(); + + AnonymousMode getAnonymousMode(); + + String getBaseUrl(); + + boolean isForceBaseUrl(); + + int getLoginAttemptLimit(); + + Set getProxyExcludes(); + + boolean isSkipFailedAuthenticators(); + + String getPluginUrl(); + + long getLoginAttemptLimitTimeout(); + + boolean isEnabledXsrfProtection(); + + boolean isEnabledUserConverter(); + + String getNamespaceStrategy(); + + String getLoginInfoUrl(); + + String getReleaseFeedUrl(); + + String getMailDomainName(); +} diff --git a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/UpdateGroupDto.java b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/UpdateGroupDto.java new file mode 100644 index 0000000000..ba91365c3c --- /dev/null +++ b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/UpdateGroupDto.java @@ -0,0 +1,50 @@ +/* + * MIT License + * + * Copyright (c) 2020-present Cloudogu GmbH and Contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package sonia.scm.api.v2.resources; + +import com.fasterxml.jackson.annotation.JsonInclude; +import sonia.scm.util.ValidationUtil; + +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.Pattern; +import java.time.Instant; +import java.util.List; + +interface UpdateGroupDto { + + @Pattern(regexp = ValidationUtil.REGEX_NAME) + String getName(); + + String getDescription(); + + @JsonInclude(JsonInclude.Include.NON_NULL) + Instant getLastModified(); + + String getType(); + + List getMembers(); + + boolean isExternal(); +} diff --git a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/UpdatePermissionListDto.java b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/UpdatePermissionListDto.java index 00c49e43d7..90fb81a34a 100644 --- a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/UpdatePermissionListDto.java +++ b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/UpdatePermissionListDto.java @@ -24,18 +24,10 @@ package sonia.scm.api.v2.resources; -import lombok.AccessLevel; -import lombok.Getter; -import lombok.NoArgsConstructor; - import javax.validation.constraints.NotNull; -/** - * This class is currently only used in the openapi scheme - */ -@Getter -@NoArgsConstructor(access = AccessLevel.PRIVATE) -final class UpdatePermissionListDto { +interface UpdatePermissionListDto { + @NotNull - private String[] permissions; + String[] getPermissions(); } diff --git a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/UpdateRepositoryDto.java b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/UpdateRepositoryDto.java new file mode 100644 index 0000000000..9b50ba04df --- /dev/null +++ b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/UpdateRepositoryDto.java @@ -0,0 +1,55 @@ +/* + * MIT License + * + * Copyright (c) 2020-present Cloudogu GmbH and Contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package sonia.scm.api.v2.resources; + +import com.fasterxml.jackson.annotation.JsonInclude; +import sonia.scm.util.ValidationUtil; + +import javax.validation.constraints.Email; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.Pattern; +import java.time.Instant; +import java.util.List; + +interface UpdateRepositoryDto { + + String getNamespace(); + + @Pattern(regexp = ValidationUtil.REGEX_REPOSITORYNAME) + String getName(); + + @NotEmpty + String getType(); + + @Email + String getContact(); + + String getDescription(); + + List getHealthCheckFailures(); + + @JsonInclude(JsonInclude.Include.NON_NULL) + Instant getLastModified(); +} diff --git a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/UpdateRepositoryPermissionDto.java b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/UpdateRepositoryPermissionDto.java new file mode 100644 index 0000000000..c726ad5ca5 --- /dev/null +++ b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/UpdateRepositoryPermissionDto.java @@ -0,0 +1,43 @@ +/* + * MIT License + * + * Copyright (c) 2020-present Cloudogu GmbH and Contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package sonia.scm.api.v2.resources; + +import sonia.scm.util.ValidationUtil; + +import javax.validation.constraints.Pattern; +import java.util.Collection; + +interface UpdateRepositoryPermissionDto { + + @Pattern(regexp = ValidationUtil.REGEX_NAME) + String getName(); + + @NoBlankStrings + Collection getVerbs(); + + String getRole(); + + boolean isGroupPermission(); +} diff --git a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/UpdateRepositoryRoleDto.java b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/UpdateRepositoryRoleDto.java new file mode 100644 index 0000000000..499c0da7dd --- /dev/null +++ b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/UpdateRepositoryRoleDto.java @@ -0,0 +1,43 @@ +/* + * MIT License + * + * Copyright (c) 2020-present Cloudogu GmbH and Contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package sonia.scm.api.v2.resources; + +import javax.validation.constraints.NotEmpty; +import java.time.Instant; +import java.util.Collection; + +interface UpdateRepositoryRoleDto { + + @NotEmpty + String getName(); + + @NoBlankStrings + @NotEmpty + Collection getVerbs(); + + String getType(); + + Instant getLastModified(); +} diff --git a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/UpdateUserDto.java b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/UpdateUserDto.java new file mode 100644 index 0000000000..a4b359c005 --- /dev/null +++ b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/UpdateUserDto.java @@ -0,0 +1,54 @@ +/* + * MIT License + * + * Copyright (c) 2020-present Cloudogu GmbH and Contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package sonia.scm.api.v2.resources; + +import sonia.scm.util.ValidationUtil; + +import javax.validation.constraints.Email; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.Pattern; +import java.time.Instant; + +interface UpdateUserDto { + + @Pattern(regexp = ValidationUtil.REGEX_NAME) + String getName(); + + @NotEmpty + String getDisplayName(); + + @Email + String getMail(); + + boolean isExternal(); + + String getPassword(); + + boolean isActive(); + + String getType(); + + Instant getLastModified(); +} diff --git a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/UserCollectionResource.java b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/UserCollectionResource.java index 211a5823d5..12d5294769 100644 --- a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/UserCollectionResource.java +++ b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/UserCollectionResource.java @@ -24,7 +24,6 @@ package sonia.scm.api.v2.resources; -import com.fasterxml.jackson.annotation.JsonInclude; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.headers.Header; import io.swagger.v3.oas.annotations.media.Content; @@ -32,23 +31,16 @@ import io.swagger.v3.oas.annotations.media.ExampleObject; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.parameters.RequestBody; import io.swagger.v3.oas.annotations.responses.ApiResponse; -import lombok.AccessLevel; -import lombok.Getter; -import lombok.NoArgsConstructor; import org.apache.shiro.authc.credential.PasswordService; import sonia.scm.search.SearchRequest; import sonia.scm.search.SearchUtil; import sonia.scm.user.User; import sonia.scm.user.UserManager; import sonia.scm.user.UserPermissions; -import sonia.scm.util.ValidationUtil; import sonia.scm.web.VndMediaType; import javax.inject.Inject; import javax.validation.Valid; -import javax.validation.constraints.Email; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.Pattern; import javax.ws.rs.Consumes; import javax.ws.rs.DefaultValue; import javax.ws.rs.GET; @@ -182,23 +174,4 @@ public class UserCollectionResource { return user -> SearchUtil.matchesOne(searchRequest, user.getName(), user.getDisplayName(), user.getMail()); } - /** - * This class is currently only used in the openapi scheme - */ - @Getter - @NoArgsConstructor(access = AccessLevel.PRIVATE) - private static final class CreateUserDto { - @Pattern(regexp = ValidationUtil.REGEX_NAME) - private String name; - @NotEmpty - private String displayName; - @JsonInclude(JsonInclude.Include.NON_NULL) - @Email - private String mail; - private boolean external; - @JsonInclude(JsonInclude.Include.NON_NULL) - private String password; - private boolean active; - private String type; - } } diff --git a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/UserDto.java b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/UserDto.java index b1eaa1d7a6..26f120b870 100644 --- a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/UserDto.java +++ b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/UserDto.java @@ -39,7 +39,7 @@ import javax.validation.constraints.Pattern; import java.time.Instant; @NoArgsConstructor @Getter @Setter -public class UserDto extends HalRepresentation { +public class UserDto extends HalRepresentation implements CreateUserDto, UpdateUserDto { private boolean active; private boolean external; private Instant creationDate; diff --git a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/UserResource.java b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/UserResource.java index db94bf1195..76902505d7 100644 --- a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/UserResource.java +++ b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/UserResource.java @@ -24,27 +24,19 @@ package sonia.scm.api.v2.resources; -import com.fasterxml.jackson.annotation.JsonInclude; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.ExampleObject; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.parameters.RequestBody; import io.swagger.v3.oas.annotations.responses.ApiResponse; -import lombok.AccessLevel; -import lombok.Getter; -import lombok.NoArgsConstructor; import org.apache.shiro.authc.credential.PasswordService; import sonia.scm.user.User; import sonia.scm.user.UserManager; -import sonia.scm.util.ValidationUtil; import sonia.scm.web.VndMediaType; import javax.inject.Inject; import javax.validation.Valid; -import javax.validation.constraints.Email; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.Pattern; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.GET; @@ -53,7 +45,6 @@ import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.Response; -import java.time.Instant; public class UserResource { @@ -312,25 +303,4 @@ public class UserResource { return userPermissionResource; } - /** - * This class is currently only used in the openapi scheme - */ - @Getter - @NoArgsConstructor(access = AccessLevel.PRIVATE) - private static final class UpdateUserDto { - @Pattern(regexp = ValidationUtil.REGEX_NAME) - private String name; - @NotEmpty - private String displayName; - @JsonInclude(JsonInclude.Include.NON_NULL) - @Email - private String mail; - private boolean external; - @JsonInclude(JsonInclude.Include.NON_NULL) - private String password; - private boolean active; - private String type; - @JsonInclude(JsonInclude.Include.NON_NULL) - private Instant lastModified; - } }