yesamer commented on code in PR #6254:
URL: 
https://github.com/apache/incubator-kie-drools/pull/6254#discussion_r1957962943


##########
drools-scenario-simulation/drools-scenario-simulation-backend/src/main/java/org/drools/scenariosimulation/backend/util/ScenarioSimulationXMLPersistence.java:
##########
@@ -179,18 +177,17 @@ public String migrateIfNecessary(String rawXml) throws 
Exception {
                                                        
.append(CURRENT_VERSION).toString());
         }
         migrator = migrator.andThen(getMigrationStrategy().end());
-        Document document = DOMParserUtil.getDocument(rawXml);
         migrator.accept(document);
         return DOMParserUtil.getString(document);
     }
 
-    public String extractVersion(String rawXml) {
-        Matcher m = p.matcher(rawXml);
-
-        if (m.find()) {
-            return m.group(1);
+    public String extractVersion(Document document) {
+        try {
+            return 
document.getElementsByTagName(SCENARIO_SIMULATION_MODEL_NODE)
+                    
.item(0).getAttributes().getNamedItem(VERSION_ATTRIBUTE).getTextContent();
+        } catch (Exception e) {
+            throw new IllegalArgumentException("Impossible to extract version 
from the file", e);
         }

Review Comment:
   Thank you @jomarko, I would argue that the try-catch is present in the 
approach you shared, It just moved out in another method. In this case, I don't 
see the need for that, it would create an unnecessary indirection.



-- 
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