markap14 commented on a change in pull request #5514:
URL: https://github.com/apache/nifi/pull/5514#discussion_r752416650



##########
File path: 
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/StandardDataFlow.java
##########
@@ -136,4 +152,29 @@ public void error(final SAXParseException e) {
             throw new FlowSerializationException(ex);
         }
     }
+
+    private VersionedDataflow parseVersionedDataflow(final byte[] flow) {
+        if (flow == null || flow.length == 0) {
+            return null;
+        }
+
+        try {
+            final ObjectMapper objectMapper = new ObjectMapper();
+            objectMapper.setAnnotationIntrospector(new 
JaxbAnnotationIntrospector(objectMapper.getTypeFactory()));
+            
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, 
false);
+
+            final VersionedDataflow versionedDataflow = 
objectMapper.readValue(flow, VersionedDataflow.class);
+            return versionedDataflow;
+        } catch (final Exception e) {
+            throw new FlowSerializationException("Could not parse flow as a 
VersionedDataflow", e);
+        }
+    }
+
+    public boolean isXml() {
+        if (flow == null || flow.length == 0) {
+            return true;
+        }
+
+        return flow[0] == '<';

Review comment:
       I don't believe it's worth trying to determine validity, etc. The file 
should never be touched outside of NiFi.




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


Reply via email to