Merge branch 'develop' into feature/verify_gpg_signatures

This commit is contained in:
Eduard Heimbuch
2020-07-28 12:36:15 +02:00
100 changed files with 2329 additions and 1247 deletions

View File

@@ -53,6 +53,7 @@ public class PluginDto extends HalRepresentation {
private Boolean core;
private Boolean markedForUninstall;
private Set<String> dependencies;
private Set<String> optionalDependencies;
public PluginDto(Links links) {
add(links);

View File

@@ -68,6 +68,7 @@ public abstract class PluginDtoMapper {
private void map(PluginDto dto, Plugin plugin) {
dto.setDependencies(plugin.getDescriptor().getDependencies());
dto.setOptionalDependencies(plugin.getDescriptor().getOptionalDependencies());
map(plugin.getDescriptor().getInformation(), dto);
if (dto.getCategory() == null) {
dto.setCategory("Miscellaneous");

View File

@@ -253,21 +253,40 @@ public class DefaultPluginManager implements PluginManager {
private void collectPluginsToInstallOrUpdate(List<AvailablePlugin> plugins, String name) {
if (!isInstalledOrPending(name) || isUpdatable(name)) {
AvailablePlugin plugin = getAvailable(name).orElseThrow(() -> NotFoundException.notFound(entity(AvailablePlugin.class, name)));
Set<String> dependencies = plugin.getDescriptor().getDependencies();
if (dependencies != null) {
for (String dependency : dependencies) {
collectPluginsToInstallOrUpdate(plugins, dependency);
}
}
plugins.add(plugin);
collectDependentPlugins(plugins, name);
} else {
LOG.info("plugin {} is already installed or installation is pending, skipping installation", name);
}
}
private void collectOptionalPluginToInstallOrUpdate(List<AvailablePlugin> plugins, String name) {
if (isInstalledOrPending(name) && isUpdatable(name)) {
collectDependentPlugins(plugins, name);
} else {
LOG.info("optional plugin {} is not installed or not updatable", name);
}
}
private void collectDependentPlugins(List<AvailablePlugin> plugins, String name) {
AvailablePlugin plugin = getAvailable(name).orElseThrow(() -> NotFoundException.notFound(entity(AvailablePlugin.class, name)));
Set<String> dependencies = plugin.getDescriptor().getDependencies();
if (dependencies != null) {
for (String dependency : dependencies) {
collectPluginsToInstallOrUpdate(plugins, dependency);
}
}
Set<String> optionalDependencies = plugin.getDescriptor().getOptionalDependencies();
if (dependencies != null) {
for (String optionalDependency : optionalDependencies) {
collectOptionalPluginToInstallOrUpdate(plugins, optionalDependency);
}
}
plugins.add(plugin);
}
private boolean isInstalledOrPending(String name) {
return getInstalled(name).isPresent() || getPending(name).isPresent();
}

View File

@@ -85,6 +85,9 @@ public final class PluginCenterDto implements Serializable {
@XmlElement(name = "dependencies")
private Set<String> dependencies;
@XmlElement(name = "optionalDependencies")
private Set<String> optionalDependencies;
@XmlElement(name = "_links")
private Map<String, Link> links;
}

View File

@@ -43,7 +43,7 @@ public abstract class PluginCenterDtoMapper {
for (PluginCenterDto.Plugin plugin : pluginCenterDto.getEmbedded().getPlugins()) {
String url = plugin.getLinks().get("download").getHref();
AvailablePluginDescriptor descriptor = new AvailablePluginDescriptor(
map(plugin), map(plugin.getConditions()), plugin.getDependencies(), url, plugin.getSha256sum()
map(plugin), map(plugin.getConditions()), plugin.getDependencies(), plugin.getOptionalDependencies(), url, plugin.getSha256sum()
);
plugins.add(new AvailablePlugin(descriptor));
}

View File

@@ -73,7 +73,7 @@ public class RepositoryInitializer {
}
}
private class InitializerContextImpl implements RepositoryContentInitializer.InitializerContext {
private static class InitializerContextImpl implements RepositoryContentInitializer.InitializerContext {
private final Repository repository;
private final ModifyCommandBuilder builder;
@@ -90,11 +90,11 @@ public class RepositoryInitializer {
@Override
public RepositoryContentInitializer.CreateFile create(String path) {
return new CreateFileImpl(this, builder.createFile(path).setOverwrite(true));
return new CreateFileImpl(this, builder.useDefaultPath(true).createFile(path).setOverwrite(true));
}
}
private class CreateFileImpl implements RepositoryContentInitializer.CreateFile {
private static class CreateFileImpl implements RepositoryContentInitializer.CreateFile {
private final RepositoryContentInitializer.InitializerContext initializerContext;
private final ModifyCommandBuilder.WithOverwriteFlagContentLoader contentLoader;