mirror of
https://github.com/danieldemus/openhab-core.git
synced 2026-07-29 12:34:22 +02:00
* 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:
+3
-6
@@ -142,12 +142,9 @@ public class EclipseAddonService implements AddonService {
|
|||||||
AddonInfo addonInfo = addonInfoRegistry.getAddonInfo(uid, locale);
|
AddonInfo addonInfo = addonInfoRegistry.getAddonInfo(uid, locale);
|
||||||
|
|
||||||
if (addonInfo != null) {
|
if (addonInfo != null) {
|
||||||
if (addonInfo.isMasterAddonInfo()) {
|
// only enrich if this add-on is installed, otherwise wrong data might be added
|
||||||
addon = addon.withLabel(addonInfo.getName()).withDescription(addonInfo.getDescription());
|
addon = addon.withLabel(addonInfo.getName()).withDescription(addonInfo.getDescription())
|
||||||
} else {
|
.withConnection(addonInfo.getConnection()).withCountries(addonInfo.getCountries())
|
||||||
addon = addon.withLabel(name);
|
|
||||||
}
|
|
||||||
addon = addon.withConnection(addonInfo.getConnection()).withCountries(addonInfo.getCountries())
|
|
||||||
.withLink(getDefaultDocumentationLink(type, name))
|
.withLink(getDefaultDocumentationLink(type, name))
|
||||||
.withConfigDescriptionURI(addonInfo.getConfigDescriptionURI());
|
.withConfigDescriptionURI(addonInfo.getConfigDescriptionURI());
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -48,13 +48,10 @@ public class AddonInfo implements Identifiable<String> {
|
|||||||
private @Nullable String sourceBundle;
|
private @Nullable String sourceBundle;
|
||||||
private @Nullable List<AddonDiscoveryMethod> discoveryMethods;
|
private @Nullable List<AddonDiscoveryMethod> discoveryMethods;
|
||||||
|
|
||||||
private boolean masterAddonInfo = true;
|
|
||||||
|
|
||||||
private AddonInfo(String id, String type, @Nullable String uid, String name, String description,
|
private AddonInfo(String id, String type, @Nullable String uid, String name, String description,
|
||||||
@Nullable String connection, List<String> countries, @Nullable String configDescriptionURI,
|
@Nullable String connection, List<String> countries, @Nullable String configDescriptionURI,
|
||||||
@Nullable String serviceId, @Nullable String sourceBundle,
|
@Nullable String serviceId, @Nullable String sourceBundle,
|
||||||
@Nullable List<AddonDiscoveryMethod> discoveryMethods, boolean isMasterAddonInfo)
|
@Nullable List<AddonDiscoveryMethod> discoveryMethods) throws IllegalArgumentException {
|
||||||
throws IllegalArgumentException {
|
|
||||||
// mandatory fields
|
// mandatory fields
|
||||||
if (id.isBlank()) {
|
if (id.isBlank()) {
|
||||||
throw new IllegalArgumentException("The ID must neither be null nor empty!");
|
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.serviceId = Objects.requireNonNullElse(serviceId, type + "." + id);
|
||||||
this.sourceBundle = sourceBundle;
|
this.sourceBundle = sourceBundle;
|
||||||
this.discoveryMethods = discoveryMethods;
|
this.discoveryMethods = discoveryMethods;
|
||||||
|
|
||||||
this.masterAddonInfo = isMasterAddonInfo;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -158,10 +153,6 @@ public class AddonInfo implements Identifiable<String> {
|
|||||||
return discoveryMethods != null ? discoveryMethods : List.of();
|
return discoveryMethods != null ? discoveryMethods : List.of();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isMasterAddonInfo() {
|
|
||||||
return masterAddonInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Builder builder(String id, String type) {
|
public static Builder builder(String id, String type) {
|
||||||
return new Builder(id, type);
|
return new Builder(id, type);
|
||||||
}
|
}
|
||||||
@@ -184,8 +175,6 @@ public class AddonInfo implements Identifiable<String> {
|
|||||||
private @Nullable String sourceBundle;
|
private @Nullable String sourceBundle;
|
||||||
private @Nullable List<AddonDiscoveryMethod> discoveryMethods;
|
private @Nullable List<AddonDiscoveryMethod> discoveryMethods;
|
||||||
|
|
||||||
private boolean masterAddonInfo = true;
|
|
||||||
|
|
||||||
private Builder(String id, String type) {
|
private Builder(String id, String type) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
@@ -203,7 +192,6 @@ public class AddonInfo implements Identifiable<String> {
|
|||||||
this.serviceId = addonInfo.serviceId;
|
this.serviceId = addonInfo.serviceId;
|
||||||
this.sourceBundle = addonInfo.sourceBundle;
|
this.sourceBundle = addonInfo.sourceBundle;
|
||||||
this.discoveryMethods = addonInfo.discoveryMethods;
|
this.discoveryMethods = addonInfo.discoveryMethods;
|
||||||
this.masterAddonInfo = addonInfo.masterAddonInfo;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder withUID(@Nullable String uid) {
|
public Builder withUID(@Nullable String uid) {
|
||||||
@@ -256,11 +244,6 @@ public class AddonInfo implements Identifiable<String> {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder isMasterAddonInfo(boolean masterAddonInfo) {
|
|
||||||
this.masterAddonInfo = masterAddonInfo;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build an {@link AddonInfo} from this builder
|
* Build an {@link AddonInfo} from this builder
|
||||||
*
|
*
|
||||||
@@ -269,7 +252,7 @@ public class AddonInfo implements Identifiable<String> {
|
|||||||
*/
|
*/
|
||||||
public AddonInfo build() throws IllegalArgumentException {
|
public AddonInfo build() throws IllegalArgumentException {
|
||||||
return new AddonInfo(id, type, uid, name, description, connection, countries, configDescriptionURI,
|
return new AddonInfo(id, type, uid, name, description, connection, countries, configDescriptionURI,
|
||||||
serviceId, sourceBundle, discoveryMethods, masterAddonInfo);
|
serviceId, sourceBundle, discoveryMethods);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-8
@@ -95,16 +95,9 @@ public class AddonInfoRegistry {
|
|||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
AddonInfo.Builder builder = AddonInfo.builder(a);
|
AddonInfo.Builder builder = AddonInfo.builder(a);
|
||||||
if (a.isMasterAddonInfo()) {
|
if (a.getDescription().isBlank()) {
|
||||||
builder.withName(a.getName());
|
|
||||||
builder.withDescription(a.getDescription());
|
|
||||||
} else {
|
|
||||||
builder.withName(b.getName());
|
|
||||||
builder.withDescription(b.getDescription());
|
builder.withDescription(b.getDescription());
|
||||||
}
|
}
|
||||||
if (!a.isMasterAddonInfo() && b.isMasterAddonInfo()) {
|
|
||||||
builder.isMasterAddonInfo(true);
|
|
||||||
}
|
|
||||||
if (a.getConnection() == null && b.getConnection() != null) {
|
if (a.getConnection() == null && b.getConnection() != null) {
|
||||||
builder.withConnection(b.getConnection());
|
builder.withConnection(b.getConnection());
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-3
@@ -21,7 +21,6 @@ import java.util.List;
|
|||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.regex.PatternSyntaxException;
|
import java.util.regex.PatternSyntaxException;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
@@ -94,8 +93,7 @@ public class AddonInfoAddonsXmlProvider implements AddonInfoProvider {
|
|||||||
try {
|
try {
|
||||||
String xml = Files.readString(file.toPath());
|
String xml = Files.readString(file.toPath());
|
||||||
if (xml != null && !xml.isBlank()) {
|
if (xml != null && !xml.isBlank()) {
|
||||||
addonInfos.addAll(reader.readFromXML(xml).getAddons().stream()
|
addonInfos.addAll(reader.readFromXML(xml).getAddons());
|
||||||
.map(a -> AddonInfo.builder(a).isMasterAddonInfo(false).build()).collect(Collectors.toSet()));
|
|
||||||
} else {
|
} else {
|
||||||
logger.warn("File '{}' contents are null or empty", file.getName());
|
logger.warn("File '{}' contents are null or empty", file.getName());
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-6
@@ -134,12 +134,8 @@ public class KarafAddonService implements AddonService {
|
|||||||
AddonInfo addonInfo = addonInfoRegistry.getAddonInfo(uid, locale);
|
AddonInfo addonInfo = addonInfoRegistry.getAddonInfo(uid, locale);
|
||||||
|
|
||||||
if (addonInfo != null) {
|
if (addonInfo != null) {
|
||||||
if (addonInfo.isMasterAddonInfo()) {
|
addon = addon.withLabel(addonInfo.getName()).withDescription(addonInfo.getDescription())
|
||||||
addon = addon.withLabel(addonInfo.getName()).withDescription(addonInfo.getDescription());
|
.withConnection(addonInfo.getConnection()).withCountries(addonInfo.getCountries())
|
||||||
} else {
|
|
||||||
addon = addon.withLabel(feature.getDescription());
|
|
||||||
}
|
|
||||||
addon = addon.withConnection(addonInfo.getConnection()).withCountries(addonInfo.getCountries())
|
|
||||||
.withLink(getDefaultDocumentationLink(type, name))
|
.withLink(getDefaultDocumentationLink(type, name))
|
||||||
.withConfigDescriptionURI(addonInfo.getConfigDescriptionURI());
|
.withConfigDescriptionURI(addonInfo.getConfigDescriptionURI());
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user