Skip to content

Commit

Permalink
Added debugging for plugin repos
Browse files Browse the repository at this point in the history
  • Loading branch information
farion committed Aug 20, 2024
1 parent 8014ea6 commit e233b35
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 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 @@ -37,6 +37,7 @@
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 @@ -94,7 +95,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 +103,26 @@ 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 version = VersionUtils.getVersion().trim();
BundledPluginList.BundledPlugins bundledPluginsByVersion = bundledPluginList.getVersions().get(version);
if (bundledPluginsByVersion == null) {
return BundledPluginList.BundledPlugins.builder().build();
LOGGER.warn("No bundled plugins found for version '{}'", version);
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);
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 +191,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 +213,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 +235,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

0 comments on commit e233b35

Please sign in to comment.