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

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

This reverts commit 708a954081
but with some modifications

Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au>
This commit is contained in:
jimtng
2025-02-15 16:32:17 +01:00
committed by GitHub
parent 07616d150f
commit aa6d82e786
5 changed files with 9 additions and 42 deletions
@@ -142,12 +142,9 @@ public class EclipseAddonService implements AddonService {
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 {
@@ -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 @@ public class AddonInfo implements Identifiable<String> {
this.serviceId = Objects.requireNonNullElse(serviceId, type + "." + id);
this.sourceBundle = sourceBundle;
this.discoveryMethods = discoveryMethods;
this.masterAddonInfo = isMasterAddonInfo;
}
/**
@@ -158,10 +153,6 @@ public class AddonInfo implements Identifiable<String> {
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 class AddonInfo implements Identifiable<String> {
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 @@ public class AddonInfo implements Identifiable<String> {
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 class AddonInfo implements Identifiable<String> {
return this;
}
public Builder isMasterAddonInfo(boolean masterAddonInfo) {
this.masterAddonInfo = masterAddonInfo;
return this;
}
/**
* Build an {@link AddonInfo} from this builder
*
@@ -269,7 +252,7 @@ public class AddonInfo implements Identifiable<String> {
*/
public AddonInfo build() throws IllegalArgumentException {
return new AddonInfo(id, type, uid, name, description, connection, countries, configDescriptionURI,
serviceId, sourceBundle, discoveryMethods, masterAddonInfo);
serviceId, sourceBundle, discoveryMethods);
}
}
}
@@ -95,16 +95,9 @@ public class AddonInfoRegistry {
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());
}
@@ -21,7 +21,6 @@ import java.util.List;
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 @@ public class AddonInfoAddonsXmlProvider implements AddonInfoProvider {
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());
}
@@ -134,12 +134,8 @@ public class KarafAddonService implements AddonService {
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 {