public StandardDataFlow(final DataFlow toCopy) { this.flow = copy(toCopy.getFlow()); this.snippetBytes = copy(toCopy.getSnippets()); this.authorizerFingerprint = copy(toCopy.getAuthorizerFingerprint()); this.missingComponentIds = Collections.unmodifiableSet(toCopy.getMissingComponents() == null ? new HashSet<>() : new HashSet<>(toCopy.getMissingComponents())); }
private String fingerprint(final DataFlow dataFlow) { final String flowFingerprint = fingerprintFactory.createFingerprint(dataFlow.getFlow()); final String authFingerprint = dataFlow.getAuthorizerFingerprint() == null ? "" : new String(dataFlow.getAuthorizerFingerprint(), StandardCharsets.UTF_8); final String candidateFingerprint = flowFingerprint + authFingerprint; return candidateFingerprint; }
logger.debug("Loaded Flow from bytes"); } else { flowBytes = proposedFlow.getFlow(); authorizerFingerprint = proposedFlow.getAuthorizerFingerprint(); missingComponents = proposedFlow.getMissingComponents(); logger.debug("Loaded flow from proposed flow");
configuration = parseFlowBytes(proposedFlow.getFlow()); if (configuration != null) { logger.trace("Checking bundle compatibility"); configuration = parseFlowBytes(proposedFlow.getFlow()); final byte[] proposedSnippets = proposedFlow.getSnippets(); if (proposedSnippets != null && proposedSnippets.length > 0) { for (final StandardSnippet snippet : SnippetManager.parseBytes(proposedSnippets)) { final String proposedAuthFingerprint = new String(proposedFlow.getAuthorizerFingerprint(), StandardCharsets.UTF_8); managedAuthorizer.inheritFingerprint(proposedAuthFingerprint);
logger.trace("ResponseFlow = " + new String(dataFlow.getFlow(), StandardCharsets.UTF_8)); loadSnippets(dataFlow.getSnippets());
/** * Returns true if the given controller can inherit the proposed flow * without orphaning flow files. * * @param existingFlow flow * @param controller the running controller * @param proposedFlow the flow to inherit * * @return null if the controller can inherit the specified flow, an * explanation of why it cannot be inherited otherwise * * @throws FingerprintException if flow fingerprints could not be generated */ public String checkFlowInheritability(final DataFlow existingFlow, final DataFlow proposedFlow, final FlowController controller) throws FingerprintException { if (existingFlow == null) { return null; // no existing flow, so equivalent to proposed flow } return checkFlowInheritability(existingFlow.getFlow(), proposedFlow.getFlow(), controller); }
final byte[] existing = existingFlow.getAuthorizerFingerprint(); final byte[] proposed = proposedFlow.getAuthorizerFingerprint();
public String checkMissingComponentsInheritability(final DataFlow existingFlow, final DataFlow proposedFlow) { if (existingFlow == null) { return null; // no existing flow, so equivalent to proposed flow } final Set<String> existingMissingComponents = new HashSet<>(existingFlow.getMissingComponents()); existingMissingComponents.removeAll(proposedFlow.getMissingComponents()); if (existingMissingComponents.size() > 0) { final String missingIds = StringUtils.join(existingMissingComponents, ","); return "Current flow has missing components that are not considered missing in the proposed flow (" + missingIds + ")"; } final Set<String> proposedMissingComponents = new HashSet<>(proposedFlow.getMissingComponents()); proposedMissingComponents.removeAll(existingFlow.getMissingComponents()); if (proposedMissingComponents.size() > 0) { final String missingIds = StringUtils.join(proposedMissingComponents, ","); return "Proposed flow has missing components that are not considered missing in the current flow (" + missingIds + ")"; } return null; }
public static boolean isEmpty(final DataFlow dataFlow) { if (dataFlow == null || dataFlow.getFlow() == null || dataFlow.getFlow().length == 0) { return true; } final Document document = parseFlowBytes(dataFlow.getFlow()); final Element rootElement = document.getDocumentElement(); final Element rootGroupElement = (Element) rootElement.getElementsByTagName("rootGroup").item(0); final FlowEncodingVersion encodingVersion = FlowEncodingVersion.parse(rootGroupElement); final ProcessGroupDTO rootGroupDto = FlowFromDOMFactory.getProcessGroup(null, rootGroupElement, null, encodingVersion); final NodeList reportingTasks = rootElement.getElementsByTagName("reportingTask"); final ReportingTaskDTO reportingTaskDTO = reportingTasks.getLength() == 0 ? null : FlowFromDOMFactory.getReportingTask((Element)reportingTasks.item(0),null); final NodeList controllerServices = rootElement.getElementsByTagName("controllerService"); final ControllerServiceDTO controllerServiceDTO = controllerServices.getLength() == 0 ? null : FlowFromDOMFactory.getControllerService((Element)controllerServices.item(0),null); return isEmpty(rootGroupDto) && isEmpty(reportingTaskDTO) && isEmpty(controllerServiceDTO); }
@Override public AdaptedDataFlow marshal(final DataFlow df) { final AdaptedDataFlow aDf = new AdaptedDataFlow(); if (df != null) { aDf.setFlow(df.getFlow()); aDf.setSnippets(df.getSnippets()); aDf.setAuthorizerFingerprint(df.getAuthorizerFingerprint()); aDf.setMissingComponents(df.getMissingComponents()); } return aDf; }
public StandardDataFlow(final DataFlow toCopy) { this.flow = copy(toCopy.getFlow()); this.snippetBytes = copy(toCopy.getSnippets()); this.authorizerFingerprint = copy(toCopy.getAuthorizerFingerprint()); this.missingComponentIds = Collections.unmodifiableSet(toCopy.getMissingComponents() == null ? new HashSet<>() : new HashSet<>(toCopy.getMissingComponents())); }
@Override public AdaptedDataFlow marshal(final DataFlow df) { final AdaptedDataFlow aDf = new AdaptedDataFlow(); if (df != null) { aDf.setFlow(df.getFlow()); aDf.setSnippets(df.getSnippets()); aDf.setAuthorizerFingerprint(df.getAuthorizerFingerprint()); aDf.setMissingComponents(df.getMissingComponents()); } return aDf; }