Update the license for 2017-2018 license
[aai/aai-common.git] / aai-core / src / main / java / org / onap / aai / introspection / MoxyLoader.java
index 56ad2dc..63b9a12 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * org.onap.aai
  * ================================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,8 +16,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  * ============LICENSE_END=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
  */
 package org.onap.aai.introspection;
 
@@ -34,6 +32,7 @@ import org.onap.aai.introspection.exceptions.AAIUnmarshallingException;
 import org.onap.aai.logging.ErrorLogHelper;
 import org.onap.aai.logging.LogFormatTools;
 import org.onap.aai.restcore.MediaType;
+import org.onap.aai.util.AAIConstants;
 import org.onap.aai.workarounds.NamingExceptions;
 import org.w3c.dom.Document;
 import org.w3c.dom.NodeList;
@@ -46,8 +45,7 @@ import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.transform.stream.StreamSource;
-import java.io.IOException;
-import java.io.StringReader;
+import java.io.*;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
@@ -176,7 +174,19 @@ public class MoxyLoader extends Loader {
                        docFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
 
                        final DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
-                       final Document doc = docBuilder.parse(fileName);
+
+                       InputStream inputStream;
+                       File oxmFile = new File(AAIConstants.AAI_HOME_ETC + fileName);
+
+                       if(oxmFile.exists()){
+                           LOGGER.info("Oxm file exists on the system {}", oxmFile);
+                               inputStream = new FileInputStream(oxmFile);
+                       } else {
+                               LOGGER.warn("Unable to find oxm file {} on the system so using classloader", oxmFile);
+                               inputStream = getClass().getClassLoader().getResourceAsStream(fileName);
+                       }
+
+                       final Document doc = docBuilder.parse(inputStream);
                        final NodeList list = doc.getElementsByTagName("java-type");
 
                        for (int i = 0; i < list.getLength(); i++) {