mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-07 22:15:45 +01:00
fix Mapping / implement endpoint
This commit is contained in:
@@ -75,11 +75,14 @@ import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.xml.bind.JAXB;
|
||||
|
||||
import sonia.scm.net.ahc.AdvancedHttpClient;
|
||||
|
||||
import static sonia.scm.plugin.PluginCenterDtoMapper.*;
|
||||
|
||||
/**
|
||||
* TODO replace aether stuff.
|
||||
* TODO check AdvancedPluginConfiguration from 1.x
|
||||
@@ -592,8 +595,8 @@ public class DefaultPluginManager implements PluginManager
|
||||
{
|
||||
PluginCenter center = null; // cache.get(PluginCenter.class.getName());
|
||||
|
||||
if (center == null)
|
||||
{
|
||||
// if (center == null)
|
||||
// {
|
||||
synchronized (DefaultPluginManager.class)
|
||||
{
|
||||
String pluginUrl = configuration.getPluginUrl();
|
||||
@@ -611,7 +614,8 @@ public class DefaultPluginManager implements PluginManager
|
||||
{
|
||||
center = new PluginCenter();
|
||||
PluginCenterDto pluginCenterDto = httpClient.get(pluginUrl).request().contentFromJson(PluginCenterDto.class);
|
||||
center.setPlugins(mapPluginsFromPluginCenter(pluginCenterDto.getEmbedded().getPlugins()));
|
||||
Set<PluginInformation> pluginInformationSet = map(pluginCenterDto.getEmbedded().getPlugins());
|
||||
center.setPlugins(pluginInformationSet);
|
||||
preparePlugins(center);
|
||||
cache.put(PluginCenter.class.getName(), center);
|
||||
|
||||
@@ -632,33 +636,11 @@ public class DefaultPluginManager implements PluginManager
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// }
|
||||
|
||||
return center;
|
||||
}
|
||||
|
||||
private Set<PluginInformation> mapPluginsFromPluginCenter(List<PluginCenterDto.Plugin> plugins) {
|
||||
HashSet<PluginInformation> pluginInformationSet = new HashSet<>();
|
||||
|
||||
for (PluginCenterDto.Plugin plugin : plugins) {
|
||||
|
||||
PluginInformation pluginInformation = new PluginInformation();
|
||||
pluginInformation.setName(plugin.getName());
|
||||
pluginInformation.setAuthor(plugin.getAuthor());
|
||||
pluginInformation.setCategory(plugin.getCategory());
|
||||
pluginInformation.setVersion(plugin.getVersion());
|
||||
pluginInformation.setDescription(plugin.getDescription());
|
||||
|
||||
if (plugin.getConditions() != null) {
|
||||
PluginCenterDto.Condition condition = plugin.getConditions();
|
||||
pluginInformation.setCondition(new PluginCondition(condition.getMinVersion(), Collections.singletonList(condition.getOs()), condition.getArch()));
|
||||
}
|
||||
|
||||
pluginInformationSet.add(pluginInformation);
|
||||
}
|
||||
return pluginInformationSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
|
||||
@@ -9,6 +9,7 @@ import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@XmlRootElement
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@@ -56,8 +57,7 @@ public final class PluginCenterDto implements Serializable {
|
||||
private Dependency dependencies;
|
||||
|
||||
@XmlElement(name = "_links")
|
||||
private Links links;
|
||||
|
||||
private Map<String, Object> links;
|
||||
}
|
||||
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@@ -81,7 +81,14 @@ public final class PluginCenterDto implements Serializable {
|
||||
@XmlRootElement(name = "_links")
|
||||
@Getter
|
||||
static class Links {
|
||||
private String download;
|
||||
private Link link;
|
||||
private boolean templated;
|
||||
}
|
||||
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@Getter
|
||||
static class Link {
|
||||
private String url;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,35 @@
|
||||
package sonia.scm.plugin;
|
||||
|
||||
public class PluginCenterDtoMapper {
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class PluginCenterDtoMapper {
|
||||
|
||||
public static Set<PluginInformation> map(List<PluginCenterDto.Plugin> plugins) {
|
||||
HashSet<PluginInformation> pluginInformationSet = new HashSet<>();
|
||||
|
||||
for (PluginCenterDto.Plugin plugin : plugins) {
|
||||
|
||||
PluginInformation pluginInformation = new PluginInformation();
|
||||
pluginInformation.setName(plugin.getName());
|
||||
pluginInformation.setAuthor(plugin.getAuthor());
|
||||
pluginInformation.setCategory(plugin.getCategory());
|
||||
pluginInformation.setVersion(plugin.getVersion());
|
||||
pluginInformation.setDescription(plugin.getDescription());
|
||||
|
||||
if (plugin.getConditions() != null) {
|
||||
PluginCenterDto.Condition condition = plugin.getConditions();
|
||||
pluginInformation.setCondition(new PluginCondition(condition.getMinVersion(), Collections.singletonList(condition.getOs()), condition.getArch()));
|
||||
}
|
||||
|
||||
if (plugin.getLinks() != null) {
|
||||
pluginInformation.setLinks(plugin.getLinks());
|
||||
}
|
||||
|
||||
pluginInformationSet.add(pluginInformation);
|
||||
}
|
||||
return pluginInformationSet;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user