mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-13 17:05:43 +01:00
cleanup / revert UIPlugin changes
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user