Search in sources :

Example 1 with VersionedFlowSnapshotResult

use of org.apache.nifi.toolkit.cli.impl.result.VersionedFlowSnapshotResult in project nifi by apache.

the class ExportFlowVersion method doExecute.

@Override
public VersionedFlowSnapshotResult doExecute(final NiFiRegistryClient client, final Properties properties) throws ParseException, IOException, NiFiRegistryException {
    final String flowId = getRequiredArg(properties, CommandOption.FLOW_ID);
    final Integer version = getIntArg(properties, CommandOption.FLOW_VERSION);
    // determine the bucket for the provided flow id
    final String bucketId = getBucketId(client, flowId);
    // if no version was provided then export the latest, otherwise use specific version
    final VersionedFlowSnapshot versionedFlowSnapshot;
    if (version == null) {
        versionedFlowSnapshot = client.getFlowSnapshotClient().getLatest(bucketId, flowId);
    } else {
        versionedFlowSnapshot = client.getFlowSnapshotClient().get(bucketId, flowId, version);
    }
    versionedFlowSnapshot.setFlow(null);
    versionedFlowSnapshot.setBucket(null);
    versionedFlowSnapshot.getSnapshotMetadata().setBucketIdentifier(null);
    versionedFlowSnapshot.getSnapshotMetadata().setFlowIdentifier(null);
    versionedFlowSnapshot.getSnapshotMetadata().setLink(null);
    // currently export doesn't use the ResultWriter concept, it always writes JSON
    // destination will be a file if outputFile is specified, otherwise it will be the output stream of the CLI
    final String outputFile;
    if (properties.containsKey(CommandOption.OUTPUT_FILE.getLongName())) {
        outputFile = properties.getProperty(CommandOption.OUTPUT_FILE.getLongName());
    } else {
        outputFile = null;
    }
    return new VersionedFlowSnapshotResult(versionedFlowSnapshot, outputFile);
}
Also used : VersionedFlowSnapshotResult(org.apache.nifi.toolkit.cli.impl.result.VersionedFlowSnapshotResult) VersionedFlowSnapshot(org.apache.nifi.registry.flow.VersionedFlowSnapshot)

Aggregations

VersionedFlowSnapshot (org.apache.nifi.registry.flow.VersionedFlowSnapshot)1 VersionedFlowSnapshotResult (org.apache.nifi.toolkit.cli.impl.result.VersionedFlowSnapshotResult)1