Skip to content

Commit e233b35

Browse files
committed
Added debugging for plugin repos
1 parent 8014ea6 commit e233b35

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

core/src/main/java/org/correomqtt/core/plugin/PluginManager.java

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import java.net.MalformedURLException;
3838
import java.net.URL;
3939
import java.nio.file.Path;
40+
import java.sql.Array;
4041
import java.util.ArrayList;
4142
import java.util.Collection;
4243
import java.util.Collections;
@@ -94,7 +95,6 @@ public BundledPluginList.BundledPlugins getBundledPlugins() {
9495
if (bundledPluginUrl == null) {
9596
bundledPluginUrl = VendorConstants.getBundledPluginsUrl();
9697
}
97-
9898
if (bundledPluginUrl.contains("{version}")) {
9999
String latestBundled = bundledPluginUrl.replace("{version}", "latest");
100100
if (checkUrl(latestBundled)) {
@@ -103,18 +103,26 @@ public BundledPluginList.BundledPlugins getBundledPlugins() {
103103
String versionBundled = bundledPluginUrl.replace("{version}", "v" + VersionUtils.getVersion());
104104
if (checkUrl(versionBundled)) {
105105
bundledPluginUrl = versionBundled;
106+
} else {
107+
// todo use local stored bundled
106108
}
107109
}
108110
}
109-
110111
try {
111112
LOGGER.info("Read bundled plugins '{}'", bundledPluginUrl);
112113
BundledPluginList bundledPluginList = new ObjectMapper().readValue(new URL(bundledPluginUrl), BundledPluginList.class);
113-
BundledPluginList.BundledPlugins bundledPluginsByVersion = bundledPluginList.getVersions().get(VersionUtils.getVersion().trim());
114+
String version = VersionUtils.getVersion().trim();
115+
BundledPluginList.BundledPlugins bundledPluginsByVersion = bundledPluginList.getVersions().get(version);
114116
if (bundledPluginsByVersion == null) {
115-
return BundledPluginList.BundledPlugins.builder().build();
117+
LOGGER.warn("No bundled plugins found for version '{}'", version);
118+
bundledPlugins = BundledPluginList.BundledPlugins.builder().build();
119+
} else {
120+
LOGGER.info("Found {} bundled plugins and {} plugins to be removed for version '{}'.",
121+
bundledPluginsByVersion.getInstall().size(),
122+
bundledPluginsByVersion.getUninstall().size(),
123+
version);
124+
bundledPlugins = bundledPluginsByVersion;
116125
}
117-
bundledPlugins = bundledPluginsByVersion;
118126
return bundledPluginsByVersion;
119127
} catch (IOException e) {
120128
LOGGER.warn("Unable to load bundled plugin list from {}.", bundledPluginUrl);
@@ -183,11 +191,9 @@ public UpdateManager getUpdateManager() {
183191

184192
public List<? extends OutgoingMessageHook<?>> getOutgoingMessageHooks() {
185193
List<HooksDTO.Extension> hooks = pluginConfigProvider.getOutgoingMessageHooks();
186-
187-
if(hooks == null){
194+
if (hooks == null) {
188195
return Collections.emptyList();
189196
}
190-
191197
return hooks
192198
.stream()
193199
.map(extensionDefinition -> {
@@ -207,11 +213,9 @@ public List<? extends OutgoingMessageHook<?>> getOutgoingMessageHooks() {
207213

208214
public List<? extends IncomingMessageHook<?>> getIncomingMessageHooks() {
209215
List<HooksDTO.Extension> hooks = pluginConfigProvider.getIncomingMessageHooks();
210-
211-
if(hooks == null){
216+
if (hooks == null) {
212217
return Collections.emptyList();
213218
}
214-
215219
return hooks
216220
.stream()
217221
.map(extensionDefinition -> {
@@ -231,11 +235,9 @@ public List<? extends IncomingMessageHook<?>> getIncomingMessageHooks() {
231235

232236
public List<MessageValidatorHook<?>> getMessageValidators(String topic) {
233237
List<HooksDTO.MessageValidator> validators = pluginConfigProvider.getMessageValidators();
234-
235-
if(validators == null){
238+
if (validators == null) {
236239
return Collections.emptyList();
237240
}
238-
239241
return validators.stream()
240242
.filter(validatorDefinition -> validatorDefinition.getTopic().equals(topic))
241243
.map(validatorDefinition -> validatorDefinition.getExtensions().stream()

0 commit comments

Comments
 (0)