summaryrefslogtreecommitdiffstats
path: root/sdnr/wt/odlux/core/model
diff options
context:
space:
mode:
authorMichael Dürre <michael.duerre@highstreet-technologies.com>2020-07-16 05:55:07 +0200
committerMichael Dürre <michael.duerre@highstreet-technologies.com>2020-07-16 05:55:21 +0200
commit7dbe38ba0522b346a0fcd9851e797f0fd71ecd5e (patch)
treecc19db7e0637c8e392d40cdf3a53bb5e5f3e0d30 /sdnr/wt/odlux/core/model
parent25b3759a0907d06e0d8e391f751c6fcf067087f5 (diff)
switch to rfc8040 restconf
change rest interface and some small code cleanups Issue-ID: CCSDK-2572 Signed-off-by: Michael Dürre <michael.duerre@highstreet-technologies.com> Change-Id: I3475bd2574b32950c4bf84fbd1c2a9dac9af208a
Diffstat (limited to 'sdnr/wt/odlux/core/model')
-rw-r--r--sdnr/wt/odlux/core/model/src/main/java/com/opensymphony/xwork2/util/ClassLoaderUtil.java125
-rw-r--r--sdnr/wt/odlux/core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/model/bundles/ClassLoaderUtilExt.java8
-rw-r--r--sdnr/wt/odlux/core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/model/bundles/OdluxBundle.java25
-rw-r--r--sdnr/wt/odlux/core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/model/bundles/OdluxBundleLoader.java2
-rw-r--r--sdnr/wt/odlux/core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/model/bundles/OdluxBundleResourceAccess.java2
5 files changed, 81 insertions, 81 deletions
diff --git a/sdnr/wt/odlux/core/model/src/main/java/com/opensymphony/xwork2/util/ClassLoaderUtil.java b/sdnr/wt/odlux/core/model/src/main/java/com/opensymphony/xwork2/util/ClassLoaderUtil.java
index 133b08494..636c9db29 100644
--- a/sdnr/wt/odlux/core/model/src/main/java/com/opensymphony/xwork2/util/ClassLoaderUtil.java
+++ b/sdnr/wt/odlux/core/model/src/main/java/com/opensymphony/xwork2/util/ClassLoaderUtil.java
@@ -22,11 +22,11 @@ import java.util.*;
/**
- * This class is extremely useful for loading resources and classes in a fault tolerant manner
- * that works across different applications servers.
+ * This class is extremely useful for loading resources and classes in a fault tolerant manner that works across
+ * different applications servers.
*
- * It has come out of many months of frustrating use of multiple application servers at Atlassian,
- * please don't change things unless you're sure they're not going to break in one server or another!
+ * It has come out of many months of frustrating use of multiple application servers at Atlassian, please don't change
+ * things unless you're sure they're not going to break in one server or another!
*
* It was brought in from oscore trunk revision 147.
*
@@ -37,58 +37,59 @@ public class ClassLoaderUtil {
//~ Methods ////////////////////////////////////////////////////////////////
/**
- * Load all resources with a given name, potentially aggregating all results
- * from the searched classloaders. If no results are found, the resource name
- * is prepended by '/' and tried again.
+ * Load all resources with a given name, potentially aggregating all results from the searched classloaders. If no
+ * results are found, the resource name is prepended by '/' and tried again.
*
* This method will try to load the resources using the following methods (in order):
* <ul>
- * <li>From Thread.currentThread().getContextClassLoader()
- * <li>From ClassLoaderUtil.class.getClassLoader()
- * <li>callingClass.getClassLoader()
+ * <li>From Thread.currentThread().getContextClassLoader()
+ * <li>From ClassLoaderUtil.class.getClassLoader()
+ * <li>callingClass.getClassLoader()
* </ul>
*
* @param resourceName The name of the resources to load
* @param callingClass The Class object of the calling object
*/
- public static Iterator<URL> getResources(String resourceName, Class<?> callingClass, boolean aggregate) throws IOException {
+ public static Iterator<URL> getResources(String resourceName, Class<?> callingClass, boolean aggregate)
+ throws IOException {
- AggregateIterator<URL> iterator = new AggregateIterator<>();
+ AggregateIterator<URL> iterator = new AggregateIterator<>();
- iterator.addEnumeration(Thread.currentThread().getContextClassLoader().getResources(resourceName));
+ iterator.addEnumeration(Thread.currentThread().getContextClassLoader().getResources(resourceName));
- if (!iterator.hasNext() || aggregate) {
- iterator.addEnumeration(ClassLoaderUtil.class.getClassLoader().getResources(resourceName));
- }
+ if (!iterator.hasNext() || aggregate) {
+ iterator.addEnumeration(ClassLoaderUtil.class.getClassLoader().getResources(resourceName));
+ }
- if (!iterator.hasNext() || aggregate) {
- ClassLoader cl = callingClass.getClassLoader();
+ if (!iterator.hasNext() || aggregate) {
+ ClassLoader cl = callingClass.getClassLoader();
- if (cl != null) {
- iterator.addEnumeration(cl.getResources(resourceName));
- }
- }
+ if (cl != null) {
+ iterator.addEnumeration(cl.getResources(resourceName));
+ }
+ }
- if (!iterator.hasNext() && resourceName != null && (resourceName.length() == 0 || resourceName.charAt(0) != '/')) {
- return getResources('/' + resourceName, callingClass, aggregate);
- }
+ if (!iterator.hasNext() && resourceName != null
+ && (resourceName.length() == 0 || resourceName.charAt(0) != '/')) {
+ return getResources('/' + resourceName, callingClass, aggregate);
+ }
- return iterator;
- }
+ return iterator;
+ }
/**
- * Load a given resource.
- *
- * This method will try to load the resource using the following methods (in order):
- * <ul>
- * <li>From Thread.currentThread().getContextClassLoader()
- * <li>From ClassLoaderUtil.class.getClassLoader()
- * <li>callingClass.getClassLoader()
- * </ul>
- *
- * @param resourceName The name IllegalStateException("Unable to call ")of the resource to load
- * @param callingClass The Class object of the calling object
- */
+ * Load a given resource.
+ *
+ * This method will try to load the resource using the following methods (in order):
+ * <ul>
+ * <li>From Thread.currentThread().getContextClassLoader()
+ * <li>From ClassLoaderUtil.class.getClassLoader()
+ * <li>callingClass.getClassLoader()
+ * </ul>
+ *
+ * @param resourceName The name IllegalStateException("Unable to call ")of the resource to load
+ * @param callingClass The Class object of the calling object
+ */
public static URL getResource(String resourceName, Class<?> callingClass) {
URL url = Thread.currentThread().getContextClassLoader().getResource(resourceName);
@@ -112,13 +113,13 @@ public class ClassLoaderUtil {
}
/**
- * This is a convenience method to load a resource as a stream.
- *
- * The algorithm used to find the resource is given in getResource()
- *
- * @param resourceName The name of the resource to load
- * @param callingClass The Class object of the calling object
- */
+ * This is a convenience method to load a resource as a stream.
+ *
+ * The algorithm used to find the resource is given in getResource()
+ *
+ * @param resourceName The name of the resource to load
+ * @param callingClass The Class object of the calling object
+ */
public static InputStream getResourceAsStream(String resourceName, Class<?> callingClass) {
URL url = getResource(resourceName, callingClass);
@@ -130,20 +131,20 @@ public class ClassLoaderUtil {
}
/**
- * Load a class with a given name.
- *
- * It will try to load the class in the following order:
- * <ul>
- * <li>From Thread.currentThread().getContextClassLoader()
- * <li>Using the basic Class.forName()
- * <li>From ClassLoaderUtil.class.getClassLoader()
- * <li>From the callingClass.getClassLoader()
- * </ul>
- *
- * @param className The name of the class to load
- * @param callingClass The Class object of the calling object
- * @throws ClassNotFoundException If the class cannot be found anywhere.
- */
+ * Load a class with a given name.
+ *
+ * It will try to load the class in the following order:
+ * <ul>
+ * <li>From Thread.currentThread().getContextClassLoader()
+ * <li>Using the basic Class.forName()
+ * <li>From ClassLoaderUtil.class.getClassLoader()
+ * <li>From the callingClass.getClassLoader()
+ * </ul>
+ *
+ * @param className The name of the class to load
+ * @param callingClass The Class object of the calling object
+ * @throws ClassNotFoundException If the class cannot be found anywhere.
+ */
public static Class<?> loadClass(String className, Class<?> callingClass) throws ClassNotFoundException {
try {
return Thread.currentThread().getContextClassLoader().loadClass(className);
@@ -161,8 +162,8 @@ public class ClassLoaderUtil {
}
/**
- * Aggregates Enumeration instances into one iterator and filters out duplicates. Always keeps one
- * ahead of the enumerator to protect against returning duplicates.
+ * Aggregates Enumeration instances into one iterator and filters out duplicates. Always keeps one ahead of the
+ * enumerator to protect against returning duplicates.
*/
static class AggregateIterator<E> implements Iterator<E> {
diff --git a/sdnr/wt/odlux/core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/model/bundles/ClassLoaderUtilExt.java b/sdnr/wt/odlux/core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/model/bundles/ClassLoaderUtilExt.java
index f6d0b55bf..a4a0e76c3 100644
--- a/sdnr/wt/odlux/core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/model/bundles/ClassLoaderUtilExt.java
+++ b/sdnr/wt/odlux/core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/model/bundles/ClassLoaderUtilExt.java
@@ -37,7 +37,7 @@ public class ClassLoaderUtilExt {
try {
urls = getResources(resourceName, callingClass, true);
} catch (IOException e) {
- LOG.debug("No resource {}",resourceName);
+ LOG.debug("No resource {}", resourceName);
}
if (urls != null) {
while (urls.hasNext()) {
@@ -50,11 +50,9 @@ public class ClassLoaderUtilExt {
if (url == null) {
LOG.debug("res currently not found. try to find with bundle");
Bundle b = FrameworkUtil.getBundle(callingClass);
- if(b!=null)
- {
+ if (b != null) {
url = b.getEntry(resourceName);
- }
- else {
+ } else {
ClassLoader loader = Thread.currentThread().getContextClassLoader();
url = loader.getResource(resourceName);
}
diff --git a/sdnr/wt/odlux/core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/model/bundles/OdluxBundle.java b/sdnr/wt/odlux/core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/model/bundles/OdluxBundle.java
index e1e300a0d..ab69d63c8 100644
--- a/sdnr/wt/odlux/core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/model/bundles/OdluxBundle.java
+++ b/sdnr/wt/odlux/core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/model/bundles/OdluxBundle.java
@@ -25,8 +25,8 @@ import java.io.InputStreamReader;
import java.net.URL;
/**
- * At startup of each karaf bundle, each UI module creates an instance of this class via blueprint.
- * Initialize method gets called at loading of bundle.
+ * At startup of each karaf bundle, each UI module creates an instance of this class via blueprint. Initialize method
+ * gets called at loading of bundle.
*/
public class OdluxBundle {
@@ -103,12 +103,12 @@ public class OdluxBundle {
public String getResourceFileContent(String filename) {
return this.loadFileContent(this.getResource(filename));
}
-
+
protected URL getResource(String filename) {
return ClassLoaderUtilExt.getResource(filename, this.getClass());
}
- protected String loadFileContent(final URL url ) {
+ protected String loadFileContent(final URL url) {
if (url == null)
return null;
LOG.debug("try to load res " + url.toString());
@@ -124,15 +124,14 @@ public class OdluxBundle {
} catch (IOException e) {
LOG.warn("could not load resfile " + url.toString() + ": " + e.getMessage());
return null;
- }
- finally {
- if(in!=null) {
- try {
- in.close();
- } catch (IOException e) {
-
- }
- }
+ } finally {
+ if (in != null) {
+ try {
+ in.close();
+ } catch (IOException e) {
+
+ }
+ }
}
return sb.toString();
diff --git a/sdnr/wt/odlux/core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/model/bundles/OdluxBundleLoader.java b/sdnr/wt/odlux/core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/model/bundles/OdluxBundleLoader.java
index 455c83296..870011e85 100644
--- a/sdnr/wt/odlux/core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/model/bundles/OdluxBundleLoader.java
+++ b/sdnr/wt/odlux/core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/model/bundles/OdluxBundleLoader.java
@@ -25,6 +25,6 @@ public interface OdluxBundleLoader {
public int getNumberOfBundles();
- public String getResourceContent(String fn, OdluxBundleResourceAccess indexBundle);
+ public String getResourceContent(String fn, OdluxBundleResourceAccess indexBundle);
}
diff --git a/sdnr/wt/odlux/core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/model/bundles/OdluxBundleResourceAccess.java b/sdnr/wt/odlux/core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/model/bundles/OdluxBundleResourceAccess.java
index f9a842556..1abed468b 100644
--- a/sdnr/wt/odlux/core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/model/bundles/OdluxBundleResourceAccess.java
+++ b/sdnr/wt/odlux/core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/model/bundles/OdluxBundleResourceAccess.java
@@ -22,7 +22,9 @@ import java.util.List;
public interface OdluxBundleResourceAccess {
boolean hasResource(String fn);
+
String getResourceFileContent(String fn, List<String> bundleNames);
+
String getBundleName();
}