Skip to content

Commit

Permalink
Fixed Plugin Repos
Browse files Browse the repository at this point in the history
  • Loading branch information
farion committed Aug 20, 2024
1 parent e233b35 commit 1f044f0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
13 changes: 8 additions & 5 deletions core/src/main/java/org/correomqtt/core/plugin/PluginManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.file.Path;
import java.sql.Array;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
Expand Down Expand Up @@ -111,16 +110,20 @@ public BundledPluginList.BundledPlugins getBundledPlugins() {
try {
LOGGER.info("Read bundled plugins '{}'", bundledPluginUrl);
BundledPluginList bundledPluginList = new ObjectMapper().readValue(new URL(bundledPluginUrl), BundledPluginList.class);
String version = VersionUtils.getVersion().trim();
BundledPluginList.BundledPlugins bundledPluginsByVersion = bundledPluginList.getVersions().get(version);
String versionSharp = VersionUtils.getVersion();
String versionUnsharp = VersionUtils.getMajorMinorPatch(versionSharp);
BundledPluginList.BundledPlugins bundledPluginsByVersion = bundledPluginList.getVersions().get(versionSharp);
if(bundledPluginsByVersion == null) {
bundledPluginsByVersion = bundledPluginList.getVersions().get(versionUnsharp);
}
if (bundledPluginsByVersion == null) {
LOGGER.warn("No bundled plugins found for version '{}'", version);
LOGGER.warn("No bundled plugins found for version '{}'", versionSharp);
bundledPlugins = BundledPluginList.BundledPlugins.builder().build();
} else {
LOGGER.info("Found {} bundled plugins and {} plugins to be removed for version '{}'.",
bundledPluginsByVersion.getInstall().size(),
bundledPluginsByVersion.getUninstall().size(),
version);
versionSharp);
bundledPlugins = bundledPluginsByVersion;
}
return bundledPluginsByVersion;
Expand Down
11 changes: 11 additions & 0 deletions core/src/main/java/org/correomqtt/core/utils/VersionUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public class VersionUtils {

private static final Pattern MAJOR_MINOR_PATTERN = Pattern.compile("^([0-9]+).([0-9]+)");

private static final Pattern MAJOR_MINOR_PATCH_PATTERN = Pattern.compile("^([0-9]+).([0-9]+).([0-9]+)");

private VersionUtils() {
// private constructor
}
Expand Down Expand Up @@ -90,4 +92,13 @@ public static String getMajorMinor(String version) {
}
return "invalid";
}


public static String getMajorMinorPatch(String version) {
Matcher matcher = MAJOR_MINOR_PATCH_PATTERN.matcher(version);
if (matcher.find() && matcher.groupCount() > 1) {
return matcher.group(0);
}
return "invalid";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ private int installBundledPlugins(UpdateManager updateManager,
PluginManager pluginManager,
BundledPluginList.BundledPlugins bundledPlugins) {
int installedPlugins = 0;
if(bundledPlugins == null){
return installedPlugins;
}
for (String pluginId : bundledPlugins.getInstall()) {
// Already installed?
if (pluginManager.getPlugin(pluginId) != null) {
Expand Down

0 comments on commit 1f044f0

Please sign in to comment.