mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-14 01:15:44 +01:00
cleanup / revert UIPlugin changes
This commit is contained in:
@@ -1,15 +1,9 @@
|
|||||||
package sonia.scm.api.v2.resources;
|
package sonia.scm.api.v2.resources;
|
||||||
|
|
||||||
import com.google.common.base.Strings;
|
|
||||||
import de.otto.edison.hal.Links;
|
import de.otto.edison.hal.Links;
|
||||||
import sonia.scm.plugin.PluginWrapper;
|
import sonia.scm.plugin.PluginWrapper;
|
||||||
import sonia.scm.util.HttpUtil;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
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;
|
import static de.otto.edison.hal.Links.linkingTo;
|
||||||
|
|
||||||
@@ -27,7 +21,7 @@ public class PluginDtoMapper {
|
|||||||
public PluginDto map(PluginWrapper plugin) {
|
public PluginDto map(PluginWrapper plugin) {
|
||||||
PluginDto pluginDto = new PluginDto();
|
PluginDto pluginDto = new PluginDto();
|
||||||
pluginDto.setName(plugin.getPlugin().getInformation().getName());
|
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.setVersion(plugin.getPlugin().getInformation().getVersion());
|
||||||
pluginDto.setAuthor(plugin.getPlugin().getInformation().getAuthor());
|
pluginDto.setAuthor(plugin.getPlugin().getInformation().getAuthor());
|
||||||
pluginDto.setDescription(plugin.getPlugin().getInformation().getDescription());
|
pluginDto.setDescription(plugin.getPlugin().getInformation().getDescription());
|
||||||
@@ -40,23 +34,4 @@ public class PluginDtoMapper {
|
|||||||
|
|
||||||
return pluginDto;
|
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.HalRepresentation;
|
||||||
import de.otto.edison.hal.Links;
|
import de.otto.edison.hal.Links;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
@Getter
|
@Getter @Setter @NoArgsConstructor
|
||||||
@Setter
|
|
||||||
public class UIPluginDto extends HalRepresentation {
|
public class UIPluginDto extends HalRepresentation {
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
private Iterable<String> bundles;
|
private Iterable<String> bundles;
|
||||||
private String type;
|
|
||||||
private String version;
|
public UIPluginDto(String name, Iterable<String> bundles) {
|
||||||
private String author;
|
this.name = name;
|
||||||
private String description;
|
this.bundles = bundles;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected HalRepresentation add(Links links) {
|
protected HalRepresentation add(Links links) {
|
||||||
|
|||||||
@@ -26,13 +26,10 @@ public class UIPluginDtoMapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public UIPluginDto map(PluginWrapper plugin) {
|
public UIPluginDto map(PluginWrapper plugin) {
|
||||||
UIPluginDto dto = new UIPluginDto();
|
UIPluginDto dto = new UIPluginDto(
|
||||||
dto.setName(plugin.getPlugin().getInformation().getName());
|
plugin.getPlugin().getInformation().getName(),
|
||||||
dto.setBundles(getScriptResources(plugin));
|
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());
|
|
||||||
|
|
||||||
Links.Builder linksBuilder = linkingTo()
|
Links.Builder linksBuilder = linkingTo()
|
||||||
.self(resourceLinks.uiPlugin()
|
.self(resourceLinks.uiPlugin()
|
||||||
|
|||||||
Reference in New Issue
Block a user