summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorburdziak <olaf.burdziakowski@nokia.com>2018-03-22 10:46:20 +0100
committerburdziak <olaf.burdziakowski@nokia.com>2018-03-22 12:48:28 +0100
commit2970dade032d2cc9ea5cc45970ea20cb4d5a8459 (patch)
tree7addc4934b797e6892e89d93572aae62ddf480c1
parentbf99eb77b31a4cfbc590762cc6ba669820c21439 (diff)
Fixes in OxmModelLoader
Change-Id: Iaef524c5ce7dab3704ed5e199b6e3315f935a422 Issue-ID: AAI-919 Signed-off-by: burdziak <olaf.burdziakowski@nokia.com>
-rw-r--r--src/main/java/org/onap/aai/datarouter/util/OxmModelLoader.java21
1 files changed, 9 insertions, 12 deletions
diff --git a/src/main/java/org/onap/aai/datarouter/util/OxmModelLoader.java b/src/main/java/org/onap/aai/datarouter/util/OxmModelLoader.java
index c9d114e..345bc48 100644
--- a/src/main/java/org/onap/aai/datarouter/util/OxmModelLoader.java
+++ b/src/main/java/org/onap/aai/datarouter/util/OxmModelLoader.java
@@ -24,10 +24,11 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Collection;
+import java.util.NoSuchElementException;
import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -40,23 +41,20 @@ import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext;
import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContextFactory;
import org.onap.aai.cl.eelf.LoggerFactory;
import org.onap.aai.datarouter.logging.DataRouterMsgs;
-import org.onap.aai.datarouter.util.ExternalOxmModelProcessor;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.core.io.support.ResourcePatternResolver;
public class OxmModelLoader {
- private static Map<String, DynamicJAXBContext> versionContextMap = new ConcurrentHashMap<>();
+ private static Map<String, DynamicJAXBContext> versionContextMap = new ConcurrentHashMap<>();
private static List<ExternalOxmModelProcessor> oxmModelProcessorRegistry = new ArrayList<>();
- final static Pattern p = Pattern.compile("aai_oxm_(.*).xml");
-
-
+ static final Pattern p = Pattern.compile("aai_oxm_(.*).xml");
private static org.onap.aai.cl.api.Logger logger = LoggerFactory.getInstance()
.getLogger(OxmModelLoader.class.getName());
- public synchronized static void loadModels() throws FileNotFoundException {
+ public static synchronized void loadModels() throws FileNotFoundException {
ClassLoader cl = OxmModelLoader.class.getClassLoader();
ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(cl);
@@ -89,9 +87,8 @@ public class OxmModelLoader {
}
-
- private synchronized static void loadModel(String version,String resourceName,InputStream inputStream) throws JAXBException, FileNotFoundException {
+ private static synchronized void loadModel(String version,String resourceName,InputStream inputStream) throws JAXBException {
Map<String, Object> properties = new HashMap<>();
properties.put(JAXBContextProperties.OXM_METADATA_SOURCE, inputStream);
final DynamicJAXBContext jaxbContext = DynamicJAXBContextFactory
@@ -105,11 +102,11 @@ public class OxmModelLoader {
logger.info(DataRouterMsgs.LOADED_OXM_FILE, resourceName);
}
- public static DynamicJAXBContext getContextForVersion(String version) throws Exception {
+ public static DynamicJAXBContext getContextForVersion(String version) throws NoSuchElementException, FileNotFoundException {
if (versionContextMap == null || versionContextMap.isEmpty()) {
loadModels();
} else if (!versionContextMap.containsKey(version)) {
- throw new Exception(Status.NOT_FOUND.toString());
+ throw new NoSuchElementException(Status.NOT_FOUND.toString());
}
@@ -124,7 +121,7 @@ public class OxmModelLoader {
OxmModelLoader.versionContextMap = versionContextMap;
}
- public synchronized static void registerExternalOxmModelProcessors(Collection<ExternalOxmModelProcessor> processors) {
+ public static synchronized void registerExternalOxmModelProcessors(Collection<ExternalOxmModelProcessor> processors) {
if(processors != null) {
for(ExternalOxmModelProcessor processor : processors) {
if(!oxmModelProcessorRegistry.contains(processor)) {