summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Blimkie <Steven.Blimkie@amdocs.com>2018-03-22 14:42:41 +0000
committerGerrit Code Review <gerrit@onap.org>2018-03-22 14:42:41 +0000
commit441c467d1b9280c2ea7425839f6de03f6f4fee6a (patch)
treeeff2b10f3e37ef5d6fcd9f2db868cdacf9a38c0b
parentfbbe3625fd5d7f13d6b070367319418d61ec31c3 (diff)
parent2970dade032d2cc9ea5cc45970ea20cb4d5a8459 (diff)
Merge "Fixes in OxmModelLoader"
-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)) {