Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Fix addon name localisation before installation (#3908)" #4573

Merged
merged 2 commits into from
Feb 15, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -142,12 +142,9 @@ private Addon getAddon(Bundle bundle, @Nullable Locale locale) {
AddonInfo addonInfo = addonInfoRegistry.getAddonInfo(uid, locale);

if (addonInfo != null) {
if (addonInfo.isMasterAddonInfo()) {
addon = addon.withLabel(addonInfo.getName()).withDescription(addonInfo.getDescription());
} else {
addon = addon.withLabel(name);
}
addon = addon.withConnection(addonInfo.getConnection()).withCountries(addonInfo.getCountries())
// only enrich if this add-on is installed, otherwise wrong data might be added
addon = addon.withLabel(addonInfo.getName()).withDescription(addonInfo.getDescription())
.withConnection(addonInfo.getConnection()).withCountries(addonInfo.getCountries())
.withLink(getDefaultDocumentationLink(type, name))
.withConfigDescriptionURI(addonInfo.getConfigDescriptionURI());
} else {
Original file line number Diff line number Diff line change
@@ -48,13 +48,10 @@ public class AddonInfo implements Identifiable<String> {
private @Nullable String sourceBundle;
private @Nullable List<AddonDiscoveryMethod> discoveryMethods;

private boolean masterAddonInfo = true;

private AddonInfo(String id, String type, @Nullable String uid, String name, String description,
@Nullable String connection, List<String> countries, @Nullable String configDescriptionURI,
@Nullable String serviceId, @Nullable String sourceBundle,
@Nullable List<AddonDiscoveryMethod> discoveryMethods, boolean isMasterAddonInfo)
throws IllegalArgumentException {
@Nullable List<AddonDiscoveryMethod> discoveryMethods) throws IllegalArgumentException {
// mandatory fields
if (id.isBlank()) {
throw new IllegalArgumentException("The ID must neither be null nor empty!");
@@ -82,8 +79,6 @@ private AddonInfo(String id, String type, @Nullable String uid, String name, Str
this.serviceId = Objects.requireNonNullElse(serviceId, type + "." + id);
this.sourceBundle = sourceBundle;
this.discoveryMethods = discoveryMethods;

this.masterAddonInfo = isMasterAddonInfo;
}

/**
@@ -158,10 +153,6 @@ public List<AddonDiscoveryMethod> getDiscoveryMethods() {
return discoveryMethods != null ? discoveryMethods : List.of();
}

public boolean isMasterAddonInfo() {
return masterAddonInfo;
}

public static Builder builder(String id, String type) {
return new Builder(id, type);
}
@@ -184,8 +175,6 @@ public static class Builder {
private @Nullable String sourceBundle;
private @Nullable List<AddonDiscoveryMethod> discoveryMethods;

private boolean masterAddonInfo = true;

private Builder(String id, String type) {
this.id = id;
this.type = type;
@@ -203,7 +192,6 @@ private Builder(AddonInfo addonInfo) {
this.serviceId = addonInfo.serviceId;
this.sourceBundle = addonInfo.sourceBundle;
this.discoveryMethods = addonInfo.discoveryMethods;
this.masterAddonInfo = addonInfo.masterAddonInfo;
}

public Builder withUID(@Nullable String uid) {
@@ -256,11 +244,6 @@ public Builder withDiscoveryMethods(@Nullable List<AddonDiscoveryMethod> discove
return this;
}

public Builder isMasterAddonInfo(boolean masterAddonInfo) {
this.masterAddonInfo = masterAddonInfo;
return this;
}

/**
* Build an {@link AddonInfo} from this builder
*
@@ -269,7 +252,7 @@ public Builder isMasterAddonInfo(boolean masterAddonInfo) {
*/
public AddonInfo build() throws IllegalArgumentException {
return new AddonInfo(id, type, uid, name, description, connection, countries, configDescriptionURI,
serviceId, sourceBundle, discoveryMethods, masterAddonInfo);
serviceId, sourceBundle, discoveryMethods);
}
}
}
Original file line number Diff line number Diff line change
@@ -95,16 +95,9 @@ public void removeAddonInfoProvider(AddonInfoProvider addonInfoProvider) {
return a;
}
AddonInfo.Builder builder = AddonInfo.builder(a);
if (a.isMasterAddonInfo()) {
builder.withName(a.getName());
builder.withDescription(a.getDescription());
} else {
builder.withName(b.getName());
if (a.getDescription().isBlank()) {
builder.withDescription(b.getDescription());
}
if (!a.isMasterAddonInfo() && b.isMasterAddonInfo()) {
builder.isMasterAddonInfo(true);
}
if (a.getConnection() == null && b.getConnection() != null) {
builder.withConnection(b.getConnection());
}
Original file line number Diff line number Diff line change
@@ -21,7 +21,6 @@
import java.util.Locale;
import java.util.Set;
import java.util.regex.PatternSyntaxException;
import java.util.stream.Collectors;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
@@ -94,8 +93,7 @@ private void initialize() {
try {
String xml = Files.readString(file.toPath());
if (xml != null && !xml.isBlank()) {
addonInfos.addAll(reader.readFromXML(xml).getAddons().stream()
.map(a -> AddonInfo.builder(a).isMasterAddonInfo(false).build()).collect(Collectors.toSet()));
addonInfos.addAll(reader.readFromXML(xml).getAddons());
} else {
logger.warn("File '{}' contents are null or empty", file.getName());
}
Original file line number Diff line number Diff line change
@@ -134,12 +134,8 @@ private Addon getAddon(Feature feature, @Nullable Locale locale) {
AddonInfo addonInfo = addonInfoRegistry.getAddonInfo(uid, locale);

if (addonInfo != null) {
if (addonInfo.isMasterAddonInfo()) {
addon = addon.withLabel(addonInfo.getName()).withDescription(addonInfo.getDescription());
} else {
addon = addon.withLabel(feature.getDescription());
}
addon = addon.withConnection(addonInfo.getConnection()).withCountries(addonInfo.getCountries())
addon = addon.withLabel(addonInfo.getName()).withDescription(addonInfo.getDescription())
.withConnection(addonInfo.getConnection()).withCountries(addonInfo.getCountries())
.withLink(getDefaultDocumentationLink(type, name))
.withConfigDescriptionURI(addonInfo.getConfigDescriptionURI());
} else {