Skip to content

Commit

Permalink
Merge branch 'develop' into toggleScrolling#130
Browse files Browse the repository at this point in the history
  • Loading branch information
thagel authored Aug 23, 2024
2 parents b0f04d1 + 1f044f0 commit 9281b2f
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 14 deletions.
24 changes: 24 additions & 0 deletions bundled.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,30 @@
"systopic-plugin"
],
"uninstall": []
},
"1.0.0": {
"install": [
"advanced-validator",
"base64",
"contains-string-validator",
"json-format",
"save-manipulator",
"systopic",
"xml-format",
"xml-xsd-validator",
"zip-manipulator"
],
"uninstall": [
"advanced-validator-plugin",
"base64-plugin",
"contains-string-validator-plugin",
"json-format-plugin",
"save-manipulator-plugin",
"systopic-plugin",
"xml-format-plugin",
"xml-xsd-validator-plugin",
"zip-manipulator-plugin"
]
}
}
}
33 changes: 19 additions & 14 deletions core/src/main/java/org/correomqtt/core/plugin/PluginManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ public BundledPluginList.BundledPlugins getBundledPlugins() {
if (bundledPluginUrl == null) {
bundledPluginUrl = VendorConstants.getBundledPluginsUrl();
}

if (bundledPluginUrl.contains("{version}")) {
String latestBundled = bundledPluginUrl.replace("{version}", "latest");
if (checkUrl(latestBundled)) {
Expand All @@ -103,18 +102,30 @@ public BundledPluginList.BundledPlugins getBundledPlugins() {
String versionBundled = bundledPluginUrl.replace("{version}", "v" + VersionUtils.getVersion());
if (checkUrl(versionBundled)) {
bundledPluginUrl = versionBundled;
} else {
// todo use local stored bundled
}
}
}

try {
LOGGER.info("Read bundled plugins '{}'", bundledPluginUrl);
BundledPluginList bundledPluginList = new ObjectMapper().readValue(new URL(bundledPluginUrl), BundledPluginList.class);
BundledPluginList.BundledPlugins bundledPluginsByVersion = bundledPluginList.getVersions().get(VersionUtils.getVersion().trim());
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) {
return BundledPluginList.BundledPlugins.builder().build();
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(),
versionSharp);
bundledPlugins = bundledPluginsByVersion;
}
bundledPlugins = bundledPluginsByVersion;
return bundledPluginsByVersion;
} catch (IOException e) {
LOGGER.warn("Unable to load bundled plugin list from {}.", bundledPluginUrl);
Expand Down Expand Up @@ -183,11 +194,9 @@ public UpdateManager getUpdateManager() {

public List<? extends OutgoingMessageHook<?>> getOutgoingMessageHooks() {
List<HooksDTO.Extension> hooks = pluginConfigProvider.getOutgoingMessageHooks();

if(hooks == null){
if (hooks == null) {
return Collections.emptyList();
}

return hooks
.stream()
.map(extensionDefinition -> {
Expand All @@ -207,11 +216,9 @@ public List<? extends OutgoingMessageHook<?>> getOutgoingMessageHooks() {

public List<? extends IncomingMessageHook<?>> getIncomingMessageHooks() {
List<HooksDTO.Extension> hooks = pluginConfigProvider.getIncomingMessageHooks();

if(hooks == null){
if (hooks == null) {
return Collections.emptyList();
}

return hooks
.stream()
.map(extensionDefinition -> {
Expand All @@ -231,11 +238,9 @@ public List<? extends IncomingMessageHook<?>> getIncomingMessageHooks() {

public List<MessageValidatorHook<?>> getMessageValidators(String topic) {
List<HooksDTO.MessageValidator> validators = pluginConfigProvider.getMessageValidators();

if(validators == null){
if (validators == null) {
return Collections.emptyList();
}

return validators.stream()
.filter(validatorDefinition -> validatorDefinition.getTopic().equals(topic))
.map(validatorDefinition -> validatorDefinition.getExtensions().stream()
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 9281b2f

Please sign in to comment.