Merge tag 'v2.3.28' into testing
[lgpl/argeo-commons.git] / org.argeo.cms / src / org / argeo / cms / acr / CmsContentNamespace.java
index 429b759fc03a4c6e4ff9fe5c20afd6f5bce12caa..02abd4cda2641d4ff2fcb2e3743f1061e787fd9b 100644 (file)
@@ -1,6 +1,9 @@
 package org.argeo.cms.acr;
 
+import static java.lang.System.Logger.Level.ERROR;
+
 import java.net.MalformedURLException;
+import java.net.URI;
 import java.net.URL;
 import java.util.Objects;
 
@@ -52,8 +55,18 @@ public enum CmsContentNamespace implements ContentNamespace {
                Objects.requireNonNull(namespace);
                this.namespace = namespace;
                if (resourceFileName != null) {
-                       resource = getClass().getResource(RESOURCE_BASE + resourceFileName);
-                       Objects.requireNonNull(resource);
+                       // resource = getClass().getResource(RESOURCE_BASE + resourceFileName);
+                       try {
+                               // FIXME workaround when in nested OSGi frameworks
+                               resource = URI.create("platform:/plugin/org.argeo.cms" + RESOURCE_BASE + resourceFileName).toURL();
+                       } catch (MalformedURLException e) {
+                               resource = null;
+                               System.getLogger(CmsContentNamespace.class.getName()).log(ERROR,
+                                               "Cannot load " + resourceFileName + ": " + e.getMessage());
+                               // throw new IllegalArgumentException("Cannot convert " + resourceFileName + "
+                               // to URL");
+                       }
+                       // Objects.requireNonNull(resource);
                }
                if (publicUrl != null)
                        try {