@Test void removeRepository() { final WebClient client = dogma.httpClient(); createRepository(client,"foo"); final AggregatedHttpResponse aRes = client.delete(REPOS_PREFIX + "/foo").aggregate().join(); assertThat(ResponseHeaders.of(aRes.headers()).status()).isEqualTo(HttpStatus.NO_CONTENT); }
@Delete("/projects/{projectName}/repos/{repoName}") @RequiresRole(roles = ProjectRole.OWNER) public CompletableFuture<Void> removeRepository(ServiceRequestContext ctx, @Param String repoName, Repository repository, Author author) { if (Project.isReservedRepoName(repoName)) { return HttpApiUtil.throwResponse(ctx, HttpStatus.FORBIDDEN, "A reserved repository cannot be removed."); } return execute(Command.removeRepository(author, repository.parent().name(), repository.name())) .thenCompose(unused -> mds.removeRepo(author, repository.parent().name(), repository.name())) .handle(HttpApiUtil::throwUnsafelyIfNonNull); }
RepositoryServiceV1 extends AbstractService { @Delete("/projects/{projectName}/repos/{repoName}") @RequiresRole(roles = ProjectRole.OWNER) public CompletableFuture<Void> removeRepository(ServiceRequestContext ctx, @Param String repoName, Repository repository, Author author) { if (Project.isReservedRepoName(repoName)) { return HttpApiUtil.throwResponse(ctx, HttpStatus.FORBIDDEN, "A reserved repository cannot be removed."); } return execute(Command.removeRepository(author, repository.parent().name(), repository.name())) .thenCompose(unused -> mds.removeRepo(author, repository.parent().name(), repository.name())) .handle(HttpApiUtil::throwUnsafelyIfNonNull); } }
RepositoryServiceV1 extends AbstractService { @Delete("/projects/{projectName}/repos/{repoName}") @RequiresRole(roles = ProjectRole.OWNER) public CompletableFuture<Void> removeRepository(ServiceRequestContext ctx, @Param String repoName, Repository repository, Author author) { if (Project.isReservedRepoName(repoName)) { return HttpApiUtil.throwResponse(ctx, HttpStatus.FORBIDDEN, "A reserved repository cannot be removed."); } return execute(Command.removeRepository(author, repository.parent().name(), repository.name())) .thenCompose(unused -> mds.removeRepo(author, repository.parent().name(), repository.name())) .handle(HttpApiUtil::throwUnsafelyIfNonNull); } RepositoryServiceV1(ProjectManager projectManager, CommandExecutor executor,
                               MetadataService mds); }
RepositoryServiceV1 extends AbstractService { @Delete("/projects/{projectName}/repos/{repoName}") @RequiresRole(roles = ProjectRole.OWNER) public CompletableFuture<Void> removeRepository(ServiceRequestContext ctx, @Param String repoName, Repository repository, Author author) { if (Project.isReservedRepoName(repoName)) { return HttpApiUtil.throwResponse(ctx, HttpStatus.FORBIDDEN, "A reserved repository cannot be removed."); } return execute(Command.removeRepository(author, repository.parent().name(), repository.name())) .thenCompose(unused -> mds.removeRepo(author, repository.parent().name(), repository.name())) .handle(HttpApiUtil::throwUnsafelyIfNonNull); } RepositoryServiceV1(ProjectManager projectManager, CommandExecutor executor,
                               MetadataService mds); @Get("/projects/{projectName}/repos") CompletableFuture<List<RepositoryDto>> listRepositories(ServiceRequestContext ctx, Project project,
                                                                   @Param @Nullable String status, User user); @Post("/projects/{projectName}/repos") @StatusCode(201) @ResponseConverter(CreateApiResponseConverter.class) @RequiresRole(roles = ProjectRole.OWNER) CompletableFuture<RepositoryDto> createRepository(ServiceRequestContext ctx, Project project,
                                                             CreateRepositoryRequest request,
                                                             Author author); @Delete("/projects/{projectName}/repos/{repoName}") @RequiresRole(roles = ProjectRole.OWNER) CompletableFuture<Void> removeRepository(ServiceRequestContext ctx,
                                                    @Param String repoName,
                                                    Repository repository,
                                                    Author author); @Delete("/projects/{projectName}/repos/{repoName}/removed") @RequiresRole(roles = ProjectRole.OWNER) CompletableFuture<Void> purgeRepository(@Param String repoName,
                                                   Project project, Author author); @Consumes("application/json-patch+json") @Patch("/projects/{projectName}/repos/{repoName}") @RequiresRole(roles = ProjectRole.OWNER) CompletableFuture<RepositoryDto> patchRepository(@Param String repoName,
                                                            Project project,
                                                            JsonNode node,
                                                            Author author); @Get("/projects/{projectName}/repos/{repoName}/revision/{revision}") @RequiresReadPermission Map<String, Integer> normalizeRevision(Repository repository, @Param String revision); }
RepositoryServiceV1 extends AbstractService { @Delete("/projects/{projectName}/repos/{repoName}") @RequiresRole(roles = ProjectRole.OWNER) public CompletableFuture<Void> removeRepository(ServiceRequestContext ctx, @Param String repoName, Repository repository, Author author) { if (Project.isReservedRepoName(repoName)) { return HttpApiUtil.throwResponse(ctx, HttpStatus.FORBIDDEN, "A reserved repository cannot be removed."); } return execute(Command.removeRepository(author, repository.parent().name(), repository.name())) .thenCompose(unused -> mds.removeRepo(author, repository.parent().name(), repository.name())) .handle(HttpApiUtil::throwUnsafelyIfNonNull); } RepositoryServiceV1(ProjectManager projectManager, CommandExecutor executor,
                               MetadataService mds); @Get("/projects/{projectName}/repos") CompletableFuture<List<RepositoryDto>> listRepositories(ServiceRequestContext ctx, Project project,
                                                                   @Param @Nullable String status, User user); @Post("/projects/{projectName}/repos") @StatusCode(201) @ResponseConverter(CreateApiResponseConverter.class) @RequiresRole(roles = ProjectRole.OWNER) CompletableFuture<RepositoryDto> createRepository(ServiceRequestContext ctx, Project project,
                                                             CreateRepositoryRequest request,
                                                             Author author); @Delete("/projects/{projectName}/repos/{repoName}") @RequiresRole(roles = ProjectRole.OWNER) CompletableFuture<Void> removeRepository(ServiceRequestContext ctx,
                                                    @Param String repoName,
                                                    Repository repository,
                                                    Author author); @Delete("/projects/{projectName}/repos/{repoName}/removed") @RequiresRole(roles = ProjectRole.OWNER) CompletableFuture<Void> purgeRepository(@Param String repoName,
                                                   Project project, Author author); @Consumes("application/json-patch+json") @Patch("/projects/{projectName}/repos/{repoName}") @RequiresRole(roles = ProjectRole.OWNER) CompletableFuture<RepositoryDto> patchRepository(@Param String repoName,
                                                            Project project,
                                                            JsonNode node,
                                                            Author author); @Get("/projects/{projectName}/repos/{repoName}/revision/{revision}") @RequiresReadPermission Map<String, Integer> normalizeRevision(Repository repository, @Param String revision);  }