mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-17 10:41:06 +01:00
Fix minor review mentions
This commit is contained in:
@@ -69,24 +69,29 @@ public class DefaultPluginManager implements PluginManager {
|
||||
private final Collection<PendingPluginUninstallation> pendingUninstallQueue = new ArrayList<>();
|
||||
private final PluginDependencyTracker dependencyTracker = new PluginDependencyTracker();
|
||||
|
||||
private Function<List<AvailablePlugin>, PluginInstallationContext> contextFactory;
|
||||
private final Function<List<AvailablePlugin>, PluginInstallationContext> contextFactory;
|
||||
|
||||
@Inject
|
||||
public DefaultPluginManager(PluginLoader loader, PluginCenter center, PluginInstaller installer, Restarter restarter, ScmEventBus eventBus) {
|
||||
this(loader, center, installer, restarter, eventBus, null);
|
||||
}
|
||||
|
||||
DefaultPluginManager(PluginLoader loader, PluginCenter center, PluginInstaller installer, Restarter restarter, ScmEventBus eventBus, Function<List<AvailablePlugin>, PluginInstallationContext> contextFactory) {
|
||||
this.loader = loader;
|
||||
this.center = center;
|
||||
this.installer = installer;
|
||||
this.restarter = restarter;
|
||||
this.eventBus = eventBus;
|
||||
|
||||
if (contextFactory != null) {
|
||||
this.contextFactory = contextFactory;
|
||||
} else {
|
||||
this.contextFactory = (availablePlugins -> PluginInstallationContext.from(getInstalled(), availablePlugins));
|
||||
}
|
||||
|
||||
this.computeInstallationDependencies();
|
||||
this.contextFactory = (availablePlugins -> PluginInstallationContext.from(getInstalled(), availablePlugins));
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void setContextFactory(Function<List<AvailablePlugin>, PluginInstallationContext> contextFactory) {
|
||||
this.contextFactory = contextFactory;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
synchronized void computeInstallationDependencies() {
|
||||
|
||||
@@ -26,7 +26,7 @@ package sonia.scm.plugin;
|
||||
|
||||
import static sonia.scm.ContextEntry.ContextBuilder.entity;
|
||||
|
||||
@SuppressWarnings("java:S110")
|
||||
@SuppressWarnings("squid:MaximumInheritanceDepth") // exceptions have a deep inheritance depth themselves; therefore we accept this here
|
||||
public class DependencyNotFoundException extends PluginInstallException {
|
||||
|
||||
private final String plugin;
|
||||
|
||||
@@ -29,7 +29,7 @@ import lombok.Getter;
|
||||
import static sonia.scm.ContextEntry.ContextBuilder.entity;
|
||||
|
||||
@Getter
|
||||
@SuppressWarnings("java:S110")
|
||||
@SuppressWarnings("squid:MaximumInheritanceDepth") // exceptions have a deep inheritance depth themselves; therefore we accept this here
|
||||
public class DependencyVersionMismatchException extends PluginInstallException {
|
||||
|
||||
private final String plugin;
|
||||
|
||||
@@ -26,7 +26,7 @@ package sonia.scm.plugin;
|
||||
|
||||
import static sonia.scm.ContextEntry.ContextBuilder.entity;
|
||||
|
||||
@SuppressWarnings("java:S110")
|
||||
@SuppressWarnings("squid:MaximumInheritanceDepth") // exceptions have a deep inheritance depth themselves; therefore we accept this here
|
||||
public class PluginChecksumMismatchException extends PluginInstallException {
|
||||
public PluginChecksumMismatchException(AvailablePlugin plugin, String calculatedChecksum, String expectedChecksum) {
|
||||
super(
|
||||
|
||||
@@ -29,7 +29,7 @@ import lombok.Getter;
|
||||
import static sonia.scm.ContextEntry.ContextBuilder.entity;
|
||||
|
||||
@Getter
|
||||
@SuppressWarnings("java:S110")
|
||||
@SuppressWarnings("squid:MaximumInheritanceDepth") // exceptions have a deep inheritance depth themselves; therefore we accept this here
|
||||
public class PluginInformationMismatchException extends PluginInstallException {
|
||||
|
||||
private final PluginInformation api;
|
||||
|
||||
@@ -38,7 +38,8 @@ import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Optional;
|
||||
|
||||
@SuppressWarnings("UnstableApiUsage") // guava hash is marked as unstable
|
||||
@SuppressWarnings("UnstableApiUsage")
|
||||
// guava hash is marked as unstable
|
||||
class PluginInstaller {
|
||||
|
||||
private final SCMContextProvider scmContext;
|
||||
@@ -76,28 +77,28 @@ class PluginInstaller {
|
||||
}
|
||||
}
|
||||
|
||||
private void verifyInformation(AvailablePluginDescriptor api, InstalledPluginDescriptor downloaded) {
|
||||
verifyInformation(api.getInformation(), downloaded.getInformation());
|
||||
private void verifyInformation(AvailablePluginDescriptor descriptorFromPluginCenter, InstalledPluginDescriptor downloadedDescriptor) {
|
||||
verifyInformation(descriptorFromPluginCenter.getInformation(), downloadedDescriptor.getInformation());
|
||||
}
|
||||
|
||||
private void verifyInformation(PluginInformation api, PluginInformation downloaded) {
|
||||
if (!api.getName().equals(downloaded.getName())) {
|
||||
private void verifyInformation(PluginInformation informationFromPluginCenter, PluginInformation downloadedInformation) {
|
||||
if (!informationFromPluginCenter.getName().equals(downloadedInformation.getName())) {
|
||||
throw new PluginInformationMismatchException(
|
||||
api, downloaded,
|
||||
informationFromPluginCenter, downloadedInformation,
|
||||
String.format(
|
||||
"downloaded plugin name \"%s\" does not match the expected name \"%s\" from plugin-center",
|
||||
downloaded.getName(),
|
||||
api.getName()
|
||||
downloadedInformation.getName(),
|
||||
informationFromPluginCenter.getName()
|
||||
)
|
||||
);
|
||||
}
|
||||
if (!api.getVersion().equals(downloaded.getVersion())) {
|
||||
if (!informationFromPluginCenter.getVersion().equals(downloadedInformation.getVersion())) {
|
||||
throw new PluginInformationMismatchException(
|
||||
api, downloaded,
|
||||
informationFromPluginCenter, downloadedInformation,
|
||||
String.format(
|
||||
"downloaded plugin version \"%s\" does not match the expected version \"%s\" from plugin-center",
|
||||
downloaded.getVersion(),
|
||||
api.getVersion()
|
||||
downloadedInformation.getVersion(),
|
||||
informationFromPluginCenter.getVersion()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user