diff --git a/core/src/main/java/lucee/runtime/extension/ExtensionMetadata.java b/core/src/main/java/lucee/runtime/extension/ExtensionMetadata.java index 7861ce40c6..850c395d30 100644 --- a/core/src/main/java/lucee/runtime/extension/ExtensionMetadata.java +++ b/core/src/main/java/lucee/runtime/extension/ExtensionMetadata.java @@ -4,9 +4,12 @@ import java.util.List; import java.util.Map; +import lucee.Info; import lucee.commons.io.log.Log; import lucee.commons.lang.StringUtil; import lucee.runtime.osgi.BundleInfo; +import lucee.runtime.osgi.VersionRange; +import lucee.runtime.type.util.ListUtil; public class ExtensionMetadata { private static final String[] EMPTY = new String[0]; @@ -18,10 +21,12 @@ public class ExtensionMetadata { private String symbolicName; private String description; private String type; + private boolean trial; private String image; private boolean startBundles; private BundleInfo[] bundles; + private VersionRange minCoreVersion; private String[] jars; private String[] flds; @@ -303,8 +308,9 @@ public String getSymbolicName() { return StringUtil.isEmpty(symbolicName) ? getId() : symbolicName; } - public void setSymbolicName(String symbolicName) { - this.symbolicName = symbolicName; + public void setSymbolicName(String str) { + str = StringUtil.unwrap(str); + if (!StringUtil.isEmpty(str, true)) symbolicName = str.trim(); } public int getReleaseType() { @@ -331,6 +337,14 @@ public void setTrial(boolean trial) { this.trial = trial; } + public VersionRange getMinCoreVersion() { + return minCoreVersion; + } + + public void setMinCoreVersion(String str, Info info) { + this.minCoreVersion = StringUtil.isEmpty(str, true) ? null : new VersionRange(str); + } + public String getImage() { return image; } @@ -371,8 +385,11 @@ public String[] getCategories() { return categories == null ? EMPTY : categories; } - public void setCategories(String[] categories) { - this.categories = categories; + public void setCategories(String cat) { + if (!StringUtil.isEmpty(cat, true)) { + this.categories = ListUtil.trimItems(ListUtil.listToStringArray(cat, ",")); + } + else this.categories = null; } public String[] getWebContexts() { diff --git a/core/src/main/java/lucee/runtime/extension/RHExtension.java b/core/src/main/java/lucee/runtime/extension/RHExtension.java index a5232d3dfd..38c64350d8 100644 --- a/core/src/main/java/lucee/runtime/extension/RHExtension.java +++ b/core/src/main/java/lucee/runtime/extension/RHExtension.java @@ -128,8 +128,6 @@ public class RHExtension implements Serializable { private Resource extensionFile; - private VersionRange minCoreVersion; - private double minLoaderVersion; public boolean softLoaded = false; @@ -516,7 +514,7 @@ private void readManifestConfig(Config config, Manifest manifest, String label, Attributes attr = manifest.getMainAttributes(); - readSymbolicName(label, StringUtil.unwrap(attr.getValue("symbolic-name"))); + metadata.setSymbolicName(StringUtil.unwrap(attr.getValue("symbolic-name"))); readName(label, StringUtil.unwrap(attr.getValue("name"))); label = metadata.getName(); readVersion(label, StringUtil.unwrap(attr.getValue("version"))); @@ -528,8 +526,8 @@ private void readManifestConfig(Config config, Manifest manifest, String label, metadata.setImage(_img); String cat = StringUtil.unwrap(attr.getValue("category")); if (StringUtil.isEmpty(cat, true)) cat = StringUtil.unwrap(attr.getValue("categories")); - readCategories(label, cat); - readCoreVersion(label, StringUtil.unwrap(attr.getValue("lucee-core-version")), info); + metadata.setCategories(cat); + metadata.setMinCoreVersion(StringUtil.unwrap(attr.getValue("lucee-core-version")), info); readLoaderVersion(label, StringUtil.unwrap(attr.getValue("lucee-loader-version"))); metadata.setStartBundles(Caster.toBooleanValue(StringUtil.unwrap(attr.getValue("start-bundles")), true)); @@ -554,7 +552,7 @@ private void readManifestConfig(Config config, String id, Struct data, String la Log logger = ThreadLocalPageContext.getLog(config, "deploy"); Info info = ConfigUtil.getEngine(config).getInfo(); - readSymbolicName(label, ConfigFactoryImpl.getAttr(data, "symbolicName", "symbolic-name")); + metadata.setSymbolicName(ConfigFactoryImpl.getAttr(data, "symbolicName", "symbolic-name")); readName(label, ConfigFactoryImpl.getAttr(data, "name")); label = getMetadata().getName(); readVersion(label, ConfigFactoryImpl.getAttr(data, "version")); @@ -566,8 +564,8 @@ private void readManifestConfig(Config config, String id, Struct data, String la metadata.setImage(_img); String cat = ConfigFactoryImpl.getAttr(data, "category"); if (StringUtil.isEmpty(cat, true)) cat = ConfigFactoryImpl.getAttr(data, "categories"); - readCategories(label, cat); - readCoreVersion(label, ConfigFactoryImpl.getAttr(data, "luceeCoreVersion", "lucee-core-version"), info); + metadata.setCategories(cat); + metadata.setMinCoreVersion(ConfigFactoryImpl.getAttr(data, "luceeCoreVersion", "lucee-core-version"), info); readLoaderVersion(label, ConfigFactoryImpl.getAttr(data, "luceeLoaderVersion", "lucee-loader-version")); metadata.setStartBundles(Caster.toBooleanValue(ConfigFactoryImpl.getAttr(data, "startBundles", "start-bundles"), true)); @@ -594,23 +592,12 @@ private void readLoaderVersion(String label, String str) { */ } - private void readCoreVersion(String label, String str, Info info) { - - minCoreVersion = StringUtil.isEmpty(str, true) ? null : new VersionRange(str); - /* - * if (minCoreVersion != null && OSGiUtil.isNewerThan(minCoreVersion, info.getVersion())) { throw - * new InvalidVersion("The Extension [" + label + "] cannot be loaded, " + Constants.NAME + - * " Version must be at least [" + minCoreVersion.toString() + "], version is [" + - * info.getVersion().toString() + "]."); } - */ - } - public void validate(Config config) throws ApplicationException { validate(ConfigUtil.getEngine(config).getInfo()); } public void validate(Info info) throws ApplicationException { - + VersionRange minCoreVersion = metadata.getMinCoreVersion(); if (minCoreVersion != null && !minCoreVersion.isWithin(info.getVersion())) { throw new InvalidVersion("The Extension [" + metadata.getName() + "] cannot be loaded, " + Constants.NAME + " Version must be at least [" + minCoreVersion.toString() + "], version is [" + info.getVersion().toString() + "]."); @@ -622,6 +609,7 @@ public void validate(Info info) throws ApplicationException { } public boolean isValidFor(Info info) { + VersionRange minCoreVersion = metadata.getMinCoreVersion(); if (minCoreVersion != null && !minCoreVersion.isWithin(info.getVersion())) { return false; } @@ -631,13 +619,6 @@ public boolean isValidFor(Info info) { return true; } - private void readCategories(String label, String cat) { - if (!StringUtil.isEmpty(cat, true)) { - metadata.setCategories(ListUtil.trimItems(ListUtil.listToStringArray(cat, ","))); - } - else metadata.setCategories(null); - } - private void readId(String label, String id) throws ApplicationException { id = StringUtil.unwrap(id); if (!Decision.isUUId(id)) { @@ -661,11 +642,6 @@ private void readName(String label, String str) throws ApplicationException { metadata.setName(str.trim()); } - private void readSymbolicName(String label, String str) { - str = StringUtil.unwrap(str); - if (!StringUtil.isEmpty(str, true)) metadata.setSymbolicName(str.trim()); - } - public void deployBundles(Config config, boolean load) throws IOException, BundleException { // no we read the content of the zip ZipInputStream zis = new ZipInputStream(IOUtil.toBufferedInputStream(extensionFile.getInputStream())); @@ -881,6 +857,7 @@ public void populate(Struct el, boolean full) { else el.removeEL(KeyImpl.init("categories")); // core version + VersionRange minCoreVersion = metadata.getMinCoreVersion(); if (minCoreVersion != null) el.setEL("luceeCoreVersion", toStringForAttr(minCoreVersion.toString())); else el.removeEL(KeyImpl.init("luceeCoreVersion"));