gitgabrio commented on code in PR #6259:
URL: 
https://github.com/apache/incubator-kie-drools/pull/6259#discussion_r1961516447


##########
kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1x/XStreamMarshaller.java:
##########
@@ -91,42 +97,113 @@ public Definitions unmarshal(String xml) {
                 default:
                     result = xstream15.unmarshal(secondStringReader);
                     break;
-
             }
             return result;
-        } catch ( Exception e ) {
-            logger.error( "Error unmarshalling DMN model from reader.", e );
+        } catch (Exception e) {
+            logger.error("Error unmarshalling DMN model from reader.", e);
         }
         return null;
     }
 
     public enum DMN_VERSION {
-        UNKNOWN, DMN_v1_1, DMN_v1_2, DMN_v1_3, DMN_v1_4, DMN_v1_5;
+        UNKNOWN(""),
+        DMN_v1_1("v1_1"),
+        DMN_v1_2("v1_2"),
+        DMN_v1_3("v1_3"),
+        DMN_v1_4("v1_4"),
+        DMN_v1_5("v1_5");
+        final String versionString;
+
+        DMN_VERSION(String versionString) {
+            this.versionString = versionString;
+        }
+
+        public String getVersionString() {
+            return versionString;
+        }
+    }
+
+    public enum URI_NAMESPACE {
+        URI_DMN("MODEL"),
+        URI_FEEL("FEEL"),
+        URI_DMNDI("DMNDI"),
+        URI_DI("DI"),
+        URI_DC("DC");
+
+        private final String identifier;
+
+        URI_NAMESPACE(String identifier) {
+            this.identifier = identifier;
+        }
+
+        public String getIdentifier() {
+            return identifier;
+        }
     }
 
-    public static DMN_VERSION inferDMNVersion(Reader from) {
+    public static Collection<String> getNsContextValues(Reader from) {
+        Collection<String> toReturn = Collections.emptySet();
+        XMLStreamReader xmlReader = null;
+        CustomStaxReader customStaxReader = null;
         try {
-            XMLStreamReader xmlReader = 
staxDriver.getInputFactory().createXMLStreamReader(from);
-            CustomStaxReader customStaxReader = new CustomStaxReader(new 
QNameMap(), xmlReader);
-            DMN_VERSION result = DMN_VERSION.UNKNOWN;
-            if 
(customStaxReader.getNsContext().values().stream().anyMatch(org.kie.dmn.model.v1_5.KieDMNModelInstrumentedBase.URI_DMN::equals))
 {
-                result = DMN_VERSION.DMN_v1_5;
-            } else if 
(customStaxReader.getNsContext().values().stream().anyMatch(org.kie.dmn.model.v1_4.KieDMNModelInstrumentedBase.URI_DMN::equals))
 {
-                result = DMN_VERSION.DMN_v1_4;
-            } else if 
(customStaxReader.getNsContext().values().stream().anyMatch(org.kie.dmn.model.v1_3.KieDMNModelInstrumentedBase.URI_DMN::equals))
 {
-                result = DMN_VERSION.DMN_v1_3;
-            } else if 
(customStaxReader.getNsContext().values().stream().anyMatch(org.kie.dmn.model.v1_2.KieDMNModelInstrumentedBase.URI_DMN::equals))
 {
-                result = DMN_VERSION.DMN_v1_2;
-            } else if 
(customStaxReader.getNsContext().values().stream().anyMatch(org.kie.dmn.model.v1_1.KieDMNModelInstrumentedBase.URI_DMN::equals))
 {
-                result = DMN_VERSION.DMN_v1_1;
-            }
-            xmlReader.close();
-            customStaxReader.close();
-            return result;
+            xmlReader = 
staxDriver.getInputFactory().createXMLStreamReader(from);
+            customStaxReader = new CustomStaxReader(new QNameMap(), xmlReader);
+            toReturn = customStaxReader.getNsContext().values();
         } catch (Exception e) {
             logger.error("Error unmarshalling DMN model from reader.", e);
+        } finally {
+            if (customStaxReader != null) {
+                customStaxReader.close();

Review Comment:
   Hi @jomarko I tried, but unfortunately none of those stream is 
`AutoClosable`, so can't use the `try with resources`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to