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 e366a35abb..5357b8d27f 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,6 +32,10 @@ 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; @@ -41,6 +45,8 @@ 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; @@ -48,6 +54,8 @@ 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. */ @@ -161,4 +169,19 @@ 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/GitRepositoryConfigResource.java b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/api/v2/resources/GitRepositoryConfigResource.java index 81e8b79d60..55627aafee 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 @@ -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; @@ -30,6 +30,7 @@ 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.Getter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import sonia.scm.repository.GitRepositoryConfig; @@ -166,4 +167,14 @@ 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 deleted file mode 100644 index 5893e93a40..0000000000 --- a/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/api/v2/resources/UpdateGitConfigDto.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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 lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -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; - -/** - * This class is currently only used in the openapi scheme - */ -@NoArgsConstructor -@Getter -@Setter -public 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/UpdateGitRepositoryConfigDto.java b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/api/v2/resources/UpdateGitRepositoryConfigDto.java deleted file mode 100644 index 491208fae9..0000000000 --- a/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/api/v2/resources/UpdateGitRepositoryConfigDto.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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 lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -/** - * This class is currently only used in the openapi scheme - */ -@Getter -@Setter -@NoArgsConstructor -public class UpdateGitRepositoryConfigDto { - private String defaultBranch; -} 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 18ac833c76..aa73b6cc6d 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 @@ -21,20 +21,19 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - + package sonia.scm.api.v2.resources; +import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; -import lombok.Setter; /** * This class is currently only used in the openapi scheme */ -@NoArgsConstructor @Getter -@Setter -public class UpdateHgConfigDto { +@NoArgsConstructor(access = AccessLevel.PRIVATE) +final class UpdateHgConfigDto { private boolean disabled; private String hgBinary; private String pythonBinary; 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 8197c87b7b..eb33cd1b3c 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 @@ -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.OpenAPIDefinition; @@ -32,7 +32,11 @@ 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; @@ -156,4 +160,14 @@ 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 deleted file mode 100644 index af140648bd..0000000000 --- a/scm-plugins/scm-svn-plugin/src/main/java/sonia/scm/api/v2/resources/UpdateSvnConfigDto.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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 lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import sonia.scm.repository.Compatibility; - -/** - * This class is currently only used in the openapi scheme - */ -@NoArgsConstructor -@Getter -@Setter -public class UpdateSvnConfigDto { - private boolean disabled; - private Compatibility compatibility; - private boolean enabledGZip; -} 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 bd13b7e5f6..4270b2b7ae 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,6 +32,9 @@ 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; @@ -39,6 +42,7 @@ 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; @@ -187,4 +191,16 @@ public class ApiKeyResource { public void delete(@PathParam("id") String id) { 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/ConfigResource.java b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/ConfigResource.java index f9ed6fe132..ab3fef46ec 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 @@ -27,16 +27,19 @@ package sonia.scm.api.v2.resources; import com.google.common.annotations.VisibleForTesting; import io.swagger.v3.oas.annotations.OpenAPIDefinition; import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; 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 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; @@ -47,8 +50,8 @@ import javax.ws.rs.GET; import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +import java.util.Set; import java.util.function.Consumer; /** @@ -169,4 +172,35 @@ 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 deleted file mode 100644 index a78719d081..0000000000 --- a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/CreateApiKeyDto.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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 lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -import javax.validation.constraints.NotEmpty; - -/** - * This class is currently only used in the openapi scheme - */ -@Getter -@Setter -@NoArgsConstructor -public class CreateApiKeyDto { - @NotEmpty - private String displayName; - @NotEmpty - private String permissionRole; -} 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 deleted file mode 100644 index 420785449c..0000000000 --- a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/CreateRepositoryDto.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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 lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -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; - -/** - * This class is currently only used in the openapi scheme - */ -@Getter -@Setter -@NoArgsConstructor -public 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/CreateRepositoryRoleDto.java b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/CreateRepositoryRoleDto.java deleted file mode 100644 index 6b70fb3f22..0000000000 --- a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/CreateRepositoryRoleDto.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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 lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -import javax.validation.constraints.NotEmpty; -import java.util.Collection; - -/** - * This class is currently only used in the openapi scheme - */ -@Getter -@Setter -@NoArgsConstructor -public 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/CreateUserDto.java b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/CreateUserDto.java deleted file mode 100644 index 54af7edb99..0000000000 --- a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/CreateUserDto.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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 lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import sonia.scm.util.ValidationUtil; - -import javax.validation.constraints.Email; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.Pattern; - -/** - * This class is currently only used in the openapi scheme - */ -@NoArgsConstructor @Getter @Setter -public 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/GroupResource.java b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/GroupResource.java index f3fea99bff..8245430c46 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 @@ -21,21 +21,27 @@ * 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 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; @@ -44,6 +50,8 @@ 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 { @@ -181,4 +189,20 @@ public class GroupResource { public GroupPermissionResource permissions() { 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 0fe94136bb..ed507c7ba5 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 @@ -357,6 +357,5 @@ public class NamespacePermissionResource { .stream() .anyMatch(p -> p.getName().equals(permission.getName()) && p.isGroupPermission() == permission.isGroupPermission()); } + } - - 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 9e161c6136..41e5a8a7e4 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,6 +24,7 @@ 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; @@ -31,6 +32,9 @@ 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; @@ -39,10 +43,14 @@ 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; @@ -52,6 +60,8 @@ 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; @@ -237,4 +247,23 @@ public class RepositoryCollectionResource { SearchRequest searchRequest = new SearchRequest(search, true); 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/RepositoryResource.java b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/RepositoryResource.java index 8020131bae..ecc044f096 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,19 +24,27 @@ 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; @@ -46,6 +54,8 @@ 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; @@ -290,4 +300,23 @@ public class RepositoryResource { private Predicate nameAndNamespaceStaysTheSame(String namespace, String name) { 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 58292cf488..946be8e6ee 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 @@ -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; @@ -31,12 +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 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; @@ -45,6 +49,7 @@ 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 { @@ -154,4 +159,18 @@ public class RepositoryRoleCollectionResource { public Response create(@Valid RepositoryRoleDto repositoryRole) { 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/RepositoryRoleResource.java b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/RepositoryRoleResource.java index 41a6f645e5..72c8fbe4c8 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 @@ -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; @@ -30,12 +30,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 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; @@ -44,6 +48,8 @@ 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 { @@ -161,4 +167,19 @@ public class RepositoryRoleResource { public Response update(@PathParam("name") String name, @Valid RepositoryRoleDto repositoryRole) { 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 deleted file mode 100644 index 7574210e3f..0000000000 --- a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/UpdateConfigDto.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * 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 lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import sonia.scm.security.AnonymousMode; - -import java.util.Set; - -/** - * This class is currently only used in the openapi scheme - */ -@NoArgsConstructor -@Getter -@Setter -public 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/UpdateGroupDto.java b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/UpdateGroupDto.java deleted file mode 100644 index d9f06eb88b..0000000000 --- a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/UpdateGroupDto.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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 lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import sonia.scm.util.ValidationUtil; - -import javax.validation.constraints.Pattern; -import java.time.Instant; -import java.util.List; - -/** - * This class is currently only used in the openapi scheme - */ -@Getter -@Setter -@NoArgsConstructor -public 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/UpdatePermissionListDto.java b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/UpdatePermissionListDto.java index 988169bd2b..00c49e43d7 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 @@ -21,12 +21,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - + package sonia.scm.api.v2.resources; +import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; -import lombok.Setter; import javax.validation.constraints.NotNull; @@ -34,10 +34,8 @@ import javax.validation.constraints.NotNull; * This class is currently only used in the openapi scheme */ @Getter -@Setter -@NoArgsConstructor -public class UpdatePermissionListDto { - +@NoArgsConstructor(access = AccessLevel.PRIVATE) +final class UpdatePermissionListDto { @NotNull private String[] permissions; } 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 deleted file mode 100644 index 2dc2d89a1c..0000000000 --- a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/UpdateRepositoryDto.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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 lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -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; - -/** - * This class is currently only used in the openapi scheme - */ -@Getter -@Setter -@NoArgsConstructor -public 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/UpdateRepositoryRoleDto.java b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/UpdateRepositoryRoleDto.java deleted file mode 100644 index 81193195fe..0000000000 --- a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/UpdateRepositoryRoleDto.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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 lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -import javax.validation.constraints.NotEmpty; -import java.time.Instant; -import java.util.Collection; - -/** - * This class is currently only used in the openapi scheme - */ -@Getter -@Setter -@NoArgsConstructor -public 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/UpdateUserDto.java b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/UpdateUserDto.java deleted file mode 100644 index 28e011f4cd..0000000000 --- a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/UpdateUserDto.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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 lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import sonia.scm.util.ValidationUtil; - -import javax.validation.constraints.Email; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.Pattern; -import java.time.Instant; - -/** - * This class is currently only used in the openapi scheme - */ -@NoArgsConstructor @Getter @Setter -public 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; -} 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 a81aa3fc7a..211a5823d5 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,6 +24,7 @@ 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; @@ -31,16 +32,23 @@ 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; @@ -173,4 +181,24 @@ public class UserCollectionResource { SearchRequest searchRequest = new SearchRequest(search, true); 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/UserResource.java b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/UserResource.java index bed3e188c2..db94bf1195 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,19 +24,27 @@ 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; @@ -45,6 +53,7 @@ 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 { @@ -302,4 +311,26 @@ public class UserResource { public UserPermissionResource permissions() { 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; + } }