Skip to content

Commit

Permalink
Fix missing query prefix in JarFileAddonService (#3664)
Browse files Browse the repository at this point in the history
See title. This brings the query id in-line with the other add-on services.

Also adds correct content type.

Signed-off-by: Jan N. Klug <github@klug.nrw>
  • Loading branch information
J-N-K authored Jun 18, 2023
1 parent d64bd3b commit 36f95bb
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
public class JarFileAddonService extends BundleTracker<Bundle> implements AddonService {
public static final String SERVICE_ID = "jar";
public static final String SERVICE_NAME = "JAR-File add-on service";
private static final String ADDONS_CONTENT_TYPE = "application/vnd.openhab.bundle";

private static final Map<String, AddonType> ADDON_TYPE_MAP = Map.of( //
"automation", new AddonType("automation", "Automation"), //
Expand Down Expand Up @@ -155,7 +156,7 @@ private Addon toAddon(Bundle bundle, AddonInfo addonInfo) {
.withVersion(bundle.getVersion().toString()).withLabel(addonInfo.getName())
.withConfigDescriptionURI(addonInfo.getConfigDescriptionURI())
.withDescription(Objects.requireNonNullElse(addonInfo.getDescription(), bundle.getSymbolicName()))
.build();
.withContentType(ADDONS_CONTENT_TYPE).build();
}

@Override
Expand All @@ -168,7 +169,8 @@ public List<Addon> getAddons(@Nullable Locale locale) {

@Override
public @Nullable Addon getAddon(String id, @Nullable Locale locale) {
return addons.get(id);
String queryId = id.startsWith(ADDON_ID_PREFIX) ? id : ADDON_ID_PREFIX + id;
return addons.get(queryId);
}

@Override
Expand Down

0 comments on commit 36f95bb

Please sign in to comment.