cleanup / revert UIPlugin changes

This commit is contained in:
Eduard Heimbuch
2019-07-10 10:46:42 +02:00
parent 89a066fd38
commit 1283b06e98
3 changed files with 12 additions and 39 deletions

View File

@@ -1,15 +1,9 @@
package sonia.scm.api.v2.resources;
import com.google.common.base.Strings;
import de.otto.edison.hal.Links;
import sonia.scm.plugin.PluginWrapper;
import sonia.scm.util.HttpUtil;
import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;
import java.util.Collections;
import java.util.Set;
import java.util.stream.Collectors;
import static de.otto.edison.hal.Links.linkingTo;
@@ -27,7 +21,7 @@ public class PluginDtoMapper {
public PluginDto map(PluginWrapper plugin) {
PluginDto pluginDto = new PluginDto();
pluginDto.setName(plugin.getPlugin().getInformation().getName());
pluginDto.setType(plugin.getPlugin().getInformation().getCategory() != null ? plugin.getPlugin().getInformation().getCategory() : "Sonstige/Miscellaneous");
pluginDto.setType(plugin.getPlugin().getInformation().getCategory() != null ? plugin.getPlugin().getInformation().getCategory() : "Miscellaneous");
pluginDto.setVersion(plugin.getPlugin().getInformation().getVersion());
pluginDto.setAuthor(plugin.getPlugin().getInformation().getAuthor());
pluginDto.setDescription(plugin.getPlugin().getInformation().getDescription());
@@ -40,23 +34,4 @@ public class PluginDtoMapper {
return pluginDto;
}
private Set<String> getScriptResources(PluginWrapper wrapper) {
Set<String> scriptResources = wrapper.getPlugin().getResources().getScriptResources();
if (scriptResources != null) {
return scriptResources.stream()
.map(this::addContextPath)
.collect(Collectors.toSet());
}
return Collections.emptySet();
}
private String addContextPath(String resource) {
String ctxPath = request.getContextPath();
if (Strings.isNullOrEmpty(ctxPath)) {
return resource;
}
return HttpUtil.append(ctxPath, resource);
}
}

View File

@@ -3,18 +3,19 @@ package sonia.scm.api.v2.resources;
import de.otto.edison.hal.HalRepresentation;
import de.otto.edison.hal.Links;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@Getter @Setter @NoArgsConstructor
public class UIPluginDto extends HalRepresentation {
private String name;
private Iterable<String> bundles;
private String type;
private String version;
private String author;
private String description;
public UIPluginDto(String name, Iterable<String> bundles) {
this.name = name;
this.bundles = bundles;
}
@Override
protected HalRepresentation add(Links links) {

View File

@@ -26,13 +26,10 @@ public class UIPluginDtoMapper {
}
public UIPluginDto map(PluginWrapper plugin) {
UIPluginDto dto = new UIPluginDto();
dto.setName(plugin.getPlugin().getInformation().getName());
dto.setBundles(getScriptResources(plugin));
dto.setType(plugin.getPlugin().getInformation().getCategory() != null ? plugin.getPlugin().getInformation().getCategory() : "Miscellaneous");
dto.setVersion(plugin.getPlugin().getInformation().getVersion());
dto.setAuthor(plugin.getPlugin().getInformation().getAuthor());
dto.setDescription(plugin.getPlugin().getInformation().getDescription());
UIPluginDto dto = new UIPluginDto(
plugin.getPlugin().getInformation().getName(),
getScriptResources(plugin)
);
Links.Builder linksBuilder = linkingTo()
.self(resourceLinks.uiPlugin()