mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 15:35:49 +01:00
parse pluginBackendResponse to pluginCenterDto / add Endpoint / remove groupId + artefactId from plugins
This commit is contained in:
@@ -73,7 +73,7 @@ public class ScmConfiguration implements Configuration {
|
||||
* Default plugin url
|
||||
*/
|
||||
public static final String DEFAULT_PLUGINURL =
|
||||
"http://plugins.scm-manager.org/scm-plugin-backend/api/{version}/plugins?os={os}&arch={arch}&snapshot=false";
|
||||
"http://download.scm-manager.org/api/v2/plugins.json";
|
||||
|
||||
/**
|
||||
* Default plugin url from version 1.0
|
||||
|
||||
@@ -88,7 +88,6 @@ public class PluginInformation
|
||||
{
|
||||
PluginInformation clone = new PluginInformation();
|
||||
|
||||
clone.setArtifactId(artifactId);
|
||||
clone.setAuthor(author);
|
||||
clone.setCategory(category);
|
||||
clone.setTags(tags);
|
||||
@@ -99,7 +98,6 @@ public class PluginInformation
|
||||
}
|
||||
|
||||
clone.setDescription(description);
|
||||
clone.setGroupId(groupId);
|
||||
clone.setName(name);
|
||||
|
||||
if (Util.isNotEmpty(screenshots))
|
||||
@@ -139,13 +137,12 @@ public class PluginInformation
|
||||
final PluginInformation other = (PluginInformation) obj;
|
||||
|
||||
//J-
|
||||
return Objects.equal(artifactId, other.artifactId)
|
||||
&& Objects.equal(author, other.author)
|
||||
return
|
||||
Objects.equal(author, other.author)
|
||||
&& Objects.equal(category, other.category)
|
||||
&& Objects.equal(tags, other.tags)
|
||||
&& Objects.equal(condition, other.condition)
|
||||
&& Objects.equal(description, other.description)
|
||||
&& Objects.equal(groupId, other.groupId)
|
||||
&& Objects.equal(name, other.name)
|
||||
&& Objects.equal(screenshots, other.screenshots)
|
||||
&& Objects.equal(state, other.state)
|
||||
@@ -164,8 +161,8 @@ public class PluginInformation
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return Objects.hashCode(artifactId, author, category, tags, condition,
|
||||
description, groupId, name, screenshots, state, url, version, wiki);
|
||||
return Objects.hashCode(author, category, tags, condition,
|
||||
description, name, screenshots, state, url, version, wiki);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -179,13 +176,11 @@ public class PluginInformation
|
||||
{
|
||||
//J-
|
||||
return MoreObjects.toStringHelper(this)
|
||||
.add("artifactId", artifactId)
|
||||
.add("author", author)
|
||||
.add("category", category)
|
||||
.add("tags", tags)
|
||||
.add("condition", condition)
|
||||
.add("description", description)
|
||||
.add("groupId", groupId)
|
||||
.add("name", name)
|
||||
.add("screenshots", screenshots)
|
||||
.add("state", state)
|
||||
@@ -198,17 +193,6 @@ public class PluginInformation
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getArtifactId()
|
||||
{
|
||||
return artifactId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
@@ -253,16 +237,6 @@ public class PluginInformation
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getGroupId()
|
||||
{
|
||||
return groupId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
@@ -273,7 +247,7 @@ public class PluginInformation
|
||||
@Override
|
||||
public String getId()
|
||||
{
|
||||
return getId(true);
|
||||
return getName(true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -285,11 +259,9 @@ public class PluginInformation
|
||||
* @return
|
||||
* @since 1.21
|
||||
*/
|
||||
public String getId(boolean withVersion)
|
||||
public String getName(boolean withVersion)
|
||||
{
|
||||
StringBuilder id = new StringBuilder(groupId);
|
||||
|
||||
id.append(":").append(artifactId);
|
||||
StringBuilder id = new StringBuilder(name);
|
||||
|
||||
if (withVersion)
|
||||
{
|
||||
@@ -385,22 +357,11 @@ public class PluginInformation
|
||||
@Override
|
||||
public boolean isValid()
|
||||
{
|
||||
return Util.isNotEmpty(groupId) && Util.isNotEmpty(artifactId)
|
||||
&& Util.isNotEmpty(name) && Util.isNotEmpty(version);
|
||||
return Util.isNotEmpty(name) && Util.isNotEmpty(version);
|
||||
}
|
||||
|
||||
//~--- set methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param artifactId
|
||||
*/
|
||||
public void setArtifactId(String artifactId)
|
||||
{
|
||||
this.artifactId = artifactId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
@@ -446,16 +407,6 @@ public class PluginInformation
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param groupId
|
||||
*/
|
||||
public void setGroupId(String groupId)
|
||||
{
|
||||
this.groupId = groupId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
@@ -536,9 +487,6 @@ public class PluginInformation
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private String artifactId;
|
||||
|
||||
/** Field description */
|
||||
private String author;
|
||||
|
||||
@@ -551,9 +499,6 @@ public class PluginInformation
|
||||
/** Field description */
|
||||
private String description;
|
||||
|
||||
/** Field description */
|
||||
private String groupId;
|
||||
|
||||
/** Field description */
|
||||
private String name;
|
||||
|
||||
|
||||
@@ -75,11 +75,7 @@ public class PluginInformationComparator
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
result = Util.compare(plugin.getGroupId(), other.getGroupId());
|
||||
|
||||
if (result == 0)
|
||||
{
|
||||
result = Util.compare(plugin.getArtifactId(), other.getArtifactId());
|
||||
result = Util.compare(plugin.getName(), other.getName());
|
||||
|
||||
if (result == 0)
|
||||
{
|
||||
@@ -99,7 +95,6 @@ public class PluginInformationComparator
|
||||
result = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -219,16 +219,10 @@ public final class SmpArchive
|
||||
throw new PluginException("could not find information section");
|
||||
}
|
||||
|
||||
if (Strings.isNullOrEmpty(info.getGroupId()))
|
||||
if (Strings.isNullOrEmpty(info.getName()))
|
||||
{
|
||||
throw new PluginException(
|
||||
"could not find groupId in plugin descriptor");
|
||||
}
|
||||
|
||||
if (Strings.isNullOrEmpty(info.getArtifactId()))
|
||||
{
|
||||
throw new PluginException(
|
||||
"could not find artifactId in plugin descriptor");
|
||||
"could not find name in plugin descriptor");
|
||||
}
|
||||
|
||||
if (Strings.isNullOrEmpty(info.getVersion()))
|
||||
|
||||
@@ -85,7 +85,7 @@ public class SmpArchiveTest
|
||||
public void testExtract()
|
||||
throws IOException, ParserConfigurationException, SAXException
|
||||
{
|
||||
File archive = createArchive("sonia.sample", "sample", "1.0");
|
||||
File archive = createArchive("sonia.sample", "1.0");
|
||||
File target = tempFolder.newFolder();
|
||||
|
||||
IOUtil.mkdirs(target);
|
||||
@@ -112,7 +112,7 @@ public class SmpArchiveTest
|
||||
@Test
|
||||
public void testGetPlugin() throws IOException
|
||||
{
|
||||
File archive = createArchive("sonia.sample", "sample", "1.0");
|
||||
File archive = createArchive("sonia.sample", "1.0");
|
||||
Plugin plugin = SmpArchive.create(archive).getPlugin();
|
||||
|
||||
assertNotNull(plugin);
|
||||
@@ -121,8 +121,7 @@ public class SmpArchiveTest
|
||||
|
||||
assertNotNull(info);
|
||||
|
||||
assertEquals("sonia.sample", info.getGroupId());
|
||||
assertEquals("sample", info.getArtifactId());
|
||||
assertEquals("sonia.sample", info.getName());
|
||||
assertEquals("1.0", info.getVersion());
|
||||
}
|
||||
|
||||
@@ -132,22 +131,9 @@ public class SmpArchiveTest
|
||||
* @throws IOException
|
||||
*/
|
||||
@Test(expected = PluginException.class)
|
||||
public void testWithMissingArtifactId() throws IOException
|
||||
public void testWithMissingName() throws IOException
|
||||
{
|
||||
File archive = createArchive("sonia.sample", null, "1.0");
|
||||
|
||||
SmpArchive.create(archive).getPlugin();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
@Test(expected = PluginException.class)
|
||||
public void testWithMissingGroupId() throws IOException
|
||||
{
|
||||
File archive = createArchive(null, "sample", "1.0");
|
||||
File archive = createArchive( null, "1.0");
|
||||
|
||||
SmpArchive.create(archive).getPlugin();
|
||||
}
|
||||
@@ -160,7 +146,7 @@ public class SmpArchiveTest
|
||||
@Test(expected = PluginException.class)
|
||||
public void testWithMissingVersion() throws IOException
|
||||
{
|
||||
File archive = createArchive("sonia.sample", "sample", null);
|
||||
File archive = createArchive("sonia.sample", null);
|
||||
|
||||
SmpArchive.create(archive).getPlugin();
|
||||
}
|
||||
@@ -169,13 +155,12 @@ public class SmpArchiveTest
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param groupId
|
||||
* @param artifactId
|
||||
* @param name
|
||||
* @param version
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private File createArchive(String groupId, String artifactId, String version)
|
||||
private File createArchive(String name, String version)
|
||||
{
|
||||
File archiveFile;
|
||||
|
||||
@@ -183,7 +168,7 @@ public class SmpArchiveTest
|
||||
{
|
||||
File descriptor = tempFolder.newFile();
|
||||
|
||||
writeDescriptor(descriptor, groupId, artifactId, version);
|
||||
writeDescriptor(descriptor, name, version);
|
||||
archiveFile = tempFolder.newFile();
|
||||
|
||||
try (ZipOutputStream zos =
|
||||
@@ -229,14 +214,13 @@ public class SmpArchiveTest
|
||||
*
|
||||
*
|
||||
* @param descriptor
|
||||
* @param groupId
|
||||
* @param artifactId
|
||||
* @param name
|
||||
* @param version
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
private void writeDescriptor(File descriptor, String groupId,
|
||||
String artifactId, String version)
|
||||
private void writeDescriptor(File descriptor, String name,
|
||||
String version)
|
||||
throws IOException
|
||||
{
|
||||
try
|
||||
@@ -252,8 +236,7 @@ public class SmpArchiveTest
|
||||
writer.writeStartDocument();
|
||||
writer.writeStartElement("plugin");
|
||||
writer.writeStartElement("information");
|
||||
writeElement(writer, "groupId", groupId);
|
||||
writeElement(writer, "artifactId", artifactId);
|
||||
writeElement(writer, "name", name);
|
||||
writeElement(writer, "version", version);
|
||||
|
||||
writer.writeEndElement();
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.google.inject.Inject;
|
||||
import de.otto.edison.hal.Embedded;
|
||||
import de.otto.edison.hal.HalRepresentation;
|
||||
import de.otto.edison.hal.Links;
|
||||
import sonia.scm.plugin.PluginInformation;
|
||||
import sonia.scm.plugin.PluginWrapper;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -24,7 +25,12 @@ public class PluginDtoCollectionMapper {
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
public HalRepresentation map(Collection<PluginWrapper> plugins) {
|
||||
public HalRepresentation map(List<PluginWrapper> plugins) {
|
||||
List<PluginDto> dtos = plugins.stream().map(mapper::map).collect(toList());
|
||||
return new HalRepresentation(createLinks(), embedDtos(dtos));
|
||||
}
|
||||
|
||||
public HalRepresentation map(Collection<PluginInformation> plugins) {
|
||||
List<PluginDto> dtos = plugins.stream().map(mapper::map).collect(toList());
|
||||
return new HalRepresentation(createLinks(), embedDtos(dtos));
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package sonia.scm.api.v2.resources;
|
||||
|
||||
import de.otto.edison.hal.Links;
|
||||
import sonia.scm.plugin.PluginInformation;
|
||||
import sonia.scm.plugin.PluginWrapper;
|
||||
import javax.inject.Inject;
|
||||
|
||||
@@ -16,16 +17,20 @@ public class PluginDtoMapper {
|
||||
}
|
||||
|
||||
public PluginDto map(PluginWrapper plugin) {
|
||||
return map(plugin.getPlugin().getInformation());
|
||||
}
|
||||
|
||||
public PluginDto map(PluginInformation pluginInformation) {
|
||||
Links.Builder linksBuilder = linkingTo()
|
||||
.self(resourceLinks.plugin()
|
||||
.self(plugin.getPlugin().getInformation().getId(false)));
|
||||
.self(pluginInformation.getName()));
|
||||
|
||||
PluginDto pluginDto = new PluginDto(linksBuilder.build());
|
||||
pluginDto.setName(plugin.getPlugin().getInformation().getName());
|
||||
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());
|
||||
pluginDto.setName(pluginInformation.getName());
|
||||
pluginDto.setCategory(pluginInformation.getCategory() != null ? pluginInformation.getCategory() : "Miscellaneous");
|
||||
pluginDto.setVersion(pluginInformation.getVersion());
|
||||
pluginDto.setAuthor(pluginInformation.getAuthor());
|
||||
pluginDto.setDescription(pluginInformation.getDescription());
|
||||
|
||||
return pluginDto;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,10 @@ import com.webcohesion.enunciate.metadata.rs.ResponseCode;
|
||||
import com.webcohesion.enunciate.metadata.rs.StatusCodes;
|
||||
import com.webcohesion.enunciate.metadata.rs.TypeHint;
|
||||
import sonia.scm.plugin.Plugin;
|
||||
import sonia.scm.plugin.PluginCenter;
|
||||
import sonia.scm.plugin.PluginInformation;
|
||||
import sonia.scm.plugin.PluginLoader;
|
||||
import sonia.scm.plugin.PluginManager;
|
||||
import sonia.scm.plugin.PluginPermissions;
|
||||
import sonia.scm.plugin.PluginWrapper;
|
||||
import sonia.scm.web.VndMediaType;
|
||||
@@ -16,6 +19,7 @@ import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Response;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -27,12 +31,14 @@ public class PluginResource {
|
||||
private final PluginLoader pluginLoader;
|
||||
private final PluginDtoCollectionMapper collectionMapper;
|
||||
private final PluginDtoMapper mapper;
|
||||
private final PluginManager pluginManager;
|
||||
|
||||
@Inject
|
||||
public PluginResource(PluginLoader pluginLoader, PluginDtoCollectionMapper collectionMapper, PluginDtoMapper mapper) {
|
||||
public PluginResource(PluginLoader pluginLoader, PluginDtoCollectionMapper collectionMapper, PluginDtoMapper mapper, PluginCenter pluginCenter1, PluginManager pluginManager) {
|
||||
this.pluginLoader = pluginLoader;
|
||||
this.collectionMapper = collectionMapper;
|
||||
this.mapper = mapper;
|
||||
this.pluginManager = pluginManager;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -74,7 +80,7 @@ public class PluginResource {
|
||||
PluginPermissions.read().check();
|
||||
Optional<PluginDto> pluginDto = pluginLoader.getInstalledPlugins()
|
||||
.stream()
|
||||
.filter(plugin -> id.equals(plugin.getPlugin().getInformation().getId(false)))
|
||||
.filter(plugin -> id.equals(plugin.getPlugin().getInformation().getName(false)))
|
||||
.map(mapper::map)
|
||||
.findFirst();
|
||||
if (pluginDto.isPresent()) {
|
||||
@@ -84,4 +90,23 @@ public class PluginResource {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a collection of available plugins.
|
||||
*
|
||||
* @return collection of available plugins.
|
||||
*/
|
||||
@GET
|
||||
@Path("/available")
|
||||
@StatusCodes({
|
||||
@ResponseCode(code = 200, condition = "success"),
|
||||
@ResponseCode(code = 500, condition = "internal server error")
|
||||
})
|
||||
@TypeHint(CollectionDto.class)
|
||||
@Produces(VndMediaType.PLUGIN_COLLECTION)
|
||||
public Response getAvailablePlugins() {
|
||||
PluginPermissions.read().check();
|
||||
Collection<PluginInformation> plugins = pluginManager.getAvailable();
|
||||
return Response.ok(collectionMapper.map(plugins)).build();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -67,10 +67,12 @@ import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -99,7 +101,7 @@ public class DefaultPluginManager implements PluginManager
|
||||
LoggerFactory.getLogger(DefaultPluginManager.class);
|
||||
|
||||
/** enable or disable remote plugins */
|
||||
private static final boolean REMOTE_PLUGINS_ENABLED = false;
|
||||
private static final boolean REMOTE_PLUGINS_ENABLED = true;
|
||||
|
||||
/** Field description */
|
||||
public static final Predicate<PluginInformation> FILTER_UPDATES =
|
||||
@@ -309,14 +311,12 @@ public class DefaultPluginManager implements PluginManager
|
||||
PluginPermissions.manage().check();
|
||||
|
||||
String[] idParts = id.split(":");
|
||||
String groupId = idParts[0];
|
||||
String artefactId = idParts[1];
|
||||
String name = idParts[0];
|
||||
PluginInformation installed = null;
|
||||
|
||||
for (PluginInformation info : getInstalled())
|
||||
{
|
||||
if (groupId.equals(info.getGroupId())
|
||||
&& artefactId.equals(info.getArtifactId()))
|
||||
if (name.equals(info.getName()))
|
||||
{
|
||||
installed = info;
|
||||
|
||||
@@ -326,9 +326,9 @@ public class DefaultPluginManager implements PluginManager
|
||||
|
||||
if (installed == null)
|
||||
{
|
||||
StringBuilder msg = new StringBuilder(groupId);
|
||||
StringBuilder msg = new StringBuilder(name);
|
||||
|
||||
msg.append(":").append(groupId).append(" is not install");
|
||||
msg.append(" is not install");
|
||||
|
||||
throw new PluginNotInstalledException(msg.toString());
|
||||
}
|
||||
@@ -423,7 +423,7 @@ public class DefaultPluginManager implements PluginManager
|
||||
|
||||
for (PluginInformation info : centerPlugins)
|
||||
{
|
||||
if (!installedPlugins.containsKey(info.getId()))
|
||||
if (!installedPlugins.containsKey(info.getName()))
|
||||
{
|
||||
availablePlugins.add(info);
|
||||
}
|
||||
@@ -590,7 +590,7 @@ public class DefaultPluginManager implements PluginManager
|
||||
*/
|
||||
private PluginCenter getPluginCenter()
|
||||
{
|
||||
PluginCenter center = cache.get(PluginCenter.class.getName());
|
||||
PluginCenter center = null; // cache.get(PluginCenter.class.getName());
|
||||
|
||||
if (center == null)
|
||||
{
|
||||
@@ -605,15 +605,13 @@ public class DefaultPluginManager implements PluginManager
|
||||
logger.info("fetch plugin informations from {}", pluginUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
* remote plugins are disabled for early 2.0.0-SNAPSHOTS
|
||||
* TODO enable remote plugins later
|
||||
*/
|
||||
if (REMOTE_PLUGINS_ENABLED && Util.isNotEmpty(pluginUrl))
|
||||
{
|
||||
try
|
||||
{
|
||||
center = httpClient.get(pluginUrl).request().contentFromXml(PluginCenter.class);
|
||||
center = new PluginCenter();
|
||||
PluginCenterDto pluginCenterDto = httpClient.get(pluginUrl).request().contentFromJson(PluginCenterDto.class);
|
||||
center.setPlugins(mapPluginsFromPluginCenter(pluginCenterDto.getEmbedded().getPlugins()));
|
||||
preparePlugins(center);
|
||||
cache.put(PluginCenter.class.getName(), center);
|
||||
|
||||
@@ -633,17 +631,35 @@ public class DefaultPluginManager implements PluginManager
|
||||
logger.error("could not load plugins from plugin center", ex);
|
||||
}
|
||||
}
|
||||
|
||||
if (center == null)
|
||||
{
|
||||
center = new PluginCenter();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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());
|
||||
pluginInformation.setUrl(plugin.getLinks().getDownload());
|
||||
|
||||
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
|
||||
*
|
||||
@@ -719,8 +735,7 @@ public class DefaultPluginManager implements PluginManager
|
||||
*/
|
||||
private boolean isSamePlugin(PluginInformation p1, PluginInformation p2)
|
||||
{
|
||||
return p1.getGroupId().equals(p2.getGroupId())
|
||||
&& p1.getArtifactId().equals(p2.getArtifactId());
|
||||
return p1.getName().equals(p2.getName());
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
@@ -115,8 +115,8 @@ public final class ExplodedSmp implements Comparable<ExplodedSmp>
|
||||
}
|
||||
else
|
||||
{
|
||||
String id = plugin.getInformation().getId(false);
|
||||
String oid = o.plugin.getInformation().getId(false);
|
||||
String id = plugin.getInformation().getName(false);
|
||||
String oid = o.plugin.getInformation().getName(false);
|
||||
|
||||
if (depends.contains(oid) && odepends.contains(id))
|
||||
{
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
package sonia.scm.plugin;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import lombok.Getter;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@XmlRootElement
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public final class PluginCenterDto implements Serializable {
|
||||
|
||||
@XmlElement(name = "_embedded")
|
||||
private Embedded embedded;
|
||||
|
||||
public Embedded getEmbedded() {
|
||||
return embedded;
|
||||
}
|
||||
|
||||
@XmlRootElement(name = "_embedded")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
static class Embedded {
|
||||
|
||||
@XmlElement(name = "plugins")
|
||||
private List<Plugin> plugins;
|
||||
|
||||
public List<Plugin> getPlugins() {
|
||||
if (plugins == null) {
|
||||
plugins = ImmutableList.of();
|
||||
}
|
||||
return plugins;
|
||||
}
|
||||
}
|
||||
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlRootElement(name = "plugins")
|
||||
@Getter
|
||||
static class Plugin {
|
||||
|
||||
private String name;
|
||||
private String displayName;
|
||||
private String description;
|
||||
private String category;
|
||||
private String version;
|
||||
private String author;
|
||||
private String sha256;
|
||||
|
||||
@XmlElement(name = "conditions")
|
||||
private Condition conditions;
|
||||
|
||||
@XmlElement(name = "dependecies")
|
||||
private Dependency dependencies;
|
||||
|
||||
@XmlElement(name = "_links")
|
||||
private Links links;
|
||||
|
||||
}
|
||||
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlRootElement(name = "conditions")
|
||||
@Getter
|
||||
static class Condition {
|
||||
|
||||
private String os;
|
||||
private String arch;
|
||||
private String minVersion;
|
||||
}
|
||||
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlRootElement(name = "dependencies")
|
||||
@Getter
|
||||
static class Dependency {
|
||||
private String name;
|
||||
}
|
||||
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlRootElement(name = "_links")
|
||||
@Getter
|
||||
static class Links {
|
||||
private String download;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package sonia.scm.plugin;
|
||||
|
||||
public class PluginCenterDtoMapper {
|
||||
|
||||
}
|
||||
@@ -126,7 +126,7 @@ public final class PluginNode
|
||||
*/
|
||||
public String getId()
|
||||
{
|
||||
return plugin.getPlugin().getInformation().getId(false);
|
||||
return plugin.getPlugin().getInformation().getName(false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -377,7 +377,7 @@ public final class PluginProcessor
|
||||
URL[] urlArray = urls.toArray(new URL[urls.size()]);
|
||||
Plugin plugin = smp.getPlugin();
|
||||
|
||||
String id = plugin.getInformation().getId(false);
|
||||
String id = plugin.getInformation().getName(false);
|
||||
|
||||
if (smp.getPlugin().isChildFirstClassLoader())
|
||||
{
|
||||
|
||||
@@ -109,7 +109,7 @@ public final class PluginsInternal
|
||||
{
|
||||
PluginInformation info = plugin.getInformation();
|
||||
|
||||
return new File(new File(parent, info.getGroupId()), info.getArtifactId());
|
||||
return new File(parent, info.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -131,14 +131,14 @@ public final class PluginsInternal
|
||||
if (directory.exists())
|
||||
{
|
||||
logger.debug("delete directory {} for plugin extraction",
|
||||
archive.getPlugin().getInformation().getId(false));
|
||||
archive.getPlugin().getInformation().getName(false));
|
||||
IOUtil.delete(directory);
|
||||
}
|
||||
|
||||
IOUtil.mkdirs(directory);
|
||||
|
||||
logger.debug("extract plugin {}",
|
||||
archive.getPlugin().getInformation().getId(false));
|
||||
archive.getPlugin().getInformation().getName(false));
|
||||
archive.extract(directory);
|
||||
Files.write(checksum, checksumFile, Charsets.UTF_8);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user