diff options
author | Tian Lee <TianL@amdocs.com> | 2017-09-21 13:03:13 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2017-09-21 13:03:13 +0000 |
commit | d24e65a6716e529305f66f0135317ce448870e09 (patch) | |
tree | 07d9805d2c792d63674168040b4420d007b8033e /src/main/java/org | |
parent | c99e4332cb5805e55254985961791b574ec10f97 (diff) | |
parent | d1b007ac1f58aa3b720d241f9194ef2a2ac8e6cc (diff) |
Merge "Fix Blocker/Critical sonar issues"
Diffstat (limited to 'src/main/java/org')
-rw-r--r-- | src/main/java/org/openecomp/sparky/config/oxm/OxmModelLoader.java | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/src/main/java/org/openecomp/sparky/config/oxm/OxmModelLoader.java b/src/main/java/org/openecomp/sparky/config/oxm/OxmModelLoader.java index 8a2cc6e..2a19551 100644 --- a/src/main/java/org/openecomp/sparky/config/oxm/OxmModelLoader.java +++ b/src/main/java/org/openecomp/sparky/config/oxm/OxmModelLoader.java @@ -50,7 +50,6 @@ import org.openecomp.sparky.logging.AaiUiMsgs; import org.openecomp.sparky.synchronizer.entity.SuggestionSearchEntity; import org.openecomp.sparky.viewandinspect.config.TierSupportUiConstants; - /** * The Class OxmModelLoader. */ @@ -133,27 +132,24 @@ public class OxmModelLoader { */ public void loadModel(String version) { String fileName = loadOxmFileName(version); - InputStream inputStream; - try { - inputStream = new FileInputStream(new File(fileName)); - } catch (FileNotFoundException fnf) { - LOG.info(AaiUiMsgs.OXM_READ_ERROR_NONVERBOSE); - LOG.error(AaiUiMsgs.OXM_READ_ERROR_VERBOSE, fileName); - return; - } - Map<String, Object> properties = new HashMap<String, Object>(); - properties.put(JAXBContextProperties.OXM_METADATA_SOURCE, inputStream); - try { - final DynamicJAXBContext oxmContext = DynamicJAXBContextFactory - .createContextFromOXM(Thread.currentThread().getContextClassLoader(), properties); + try(FileInputStream inputStream = new FileInputStream(new File(fileName))) { + Map<String, Object> properties = new HashMap<String, Object>(); + properties.put(JAXBContextProperties.OXM_METADATA_SOURCE, inputStream); - parseOxmContext(oxmContext); - // populateSearchableOxmModel(); - LOG.info(AaiUiMsgs.OXM_LOAD_SUCCESS); + final DynamicJAXBContext oxmContext = DynamicJAXBContextFactory + .createContextFromOXM(Thread.currentThread() + .getContextClassLoader(), properties); + parseOxmContext(oxmContext); + // populateSearchableOxmModel(); + LOG.info(AaiUiMsgs.OXM_LOAD_SUCCESS); + + } catch (FileNotFoundException fnf) { + LOG.info(AaiUiMsgs.OXM_READ_ERROR_NONVERBOSE); + LOG.error(AaiUiMsgs.OXM_READ_ERROR_VERBOSE, fileName); } catch (Exception exc) { - LOG.info(AaiUiMsgs.OXM_PARSE_ERROR_NONVERBOSE); - LOG.error(AaiUiMsgs.OXM_PARSE_ERROR_VERBOSE, fileName, exc.getMessage()); + LOG.info(AaiUiMsgs.OXM_PARSE_ERROR_NONVERBOSE); + LOG.error(AaiUiMsgs.OXM_PARSE_ERROR_VERBOSE, fileName, exc.getMessage()); } } |