Append import bundle link to repository type if unbundle command is supported

This commit is contained in:
Eduard Heimbuch
2020-12-10 10:36:08 +01:00
parent 89add3f795
commit 097237734e
3 changed files with 38 additions and 2 deletions

View File

@@ -47,8 +47,13 @@ public abstract class RepositoryTypeToRepositoryTypeDtoMapper extends BaseMapper
void appendLinks(RepositoryType repositoryType, @MappingTarget RepositoryTypeDto target) {
Links.Builder linksBuilder = linkingTo().self(resourceLinks.repositoryType().self(repositoryType.getName()));
if (RepositoryPermissions.create().isPermitted() && repositoryType.getSupportedCommands().contains(Command.PULL)) {
linksBuilder.array(Link.linkBuilder("import", resourceLinks.repository().importFromUrl(repositoryType.getName())).withName("url").build());
if (RepositoryPermissions.create().isPermitted()) {
if (repositoryType.getSupportedCommands().contains(Command.PULL)) {
linksBuilder.array(Link.linkBuilder("import", resourceLinks.repository().importFromUrl(repositoryType.getName())).withName("url").build());
}
if (repositoryType.getSupportedCommands().contains(Command.UNBUNDLE)) {
linksBuilder.array(Link.linkBuilder("import", resourceLinks.repository().importFromBundle(repositoryType.getName())).withName("bundle").build());
}
}
target.add(linksBuilder.build());

View File

@@ -360,6 +360,10 @@ class ResourceLinks {
String importFromUrl(String type) {
return repositoryImportLinkBuilder.method("getRepositoryImportResource").parameters().method("importFromUrl").parameters(type).href();
}
String importFromBundle(String type) {
return repositoryImportLinkBuilder.method("getRepositoryImportResource").parameters().method("importFromBundle").parameters(type).href();
}
}
RepositoryCollectionLinks repositoryCollection() {