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



##########
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:
       Would it also make sense to have an "isJson()" equivalent, and maybe an 
"isValid()" (expecting one or the other), or are we depending on application 
control of the data input?




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