snapshot.setSnapshotMetadata(metadata); snapshot.setFlowContents(deserializedSnapshot.getFlowContents());
@Override public VersionedFlowSnapshot registerVersionedFlowSnapshot(final VersionedFlow flow, final VersionedProcessGroup snapshot, final String comments, final int expectedVersion, final NiFiUser user) throws IOException, NiFiRegistryException { final FlowSnapshotClient snapshotClient = getFlowSnapshotClient(user); final VersionedFlowSnapshot versionedFlowSnapshot = new VersionedFlowSnapshot(); versionedFlowSnapshot.setFlowContents(snapshot); final VersionedFlowSnapshotMetadata metadata = new VersionedFlowSnapshotMetadata(); metadata.setBucketIdentifier(flow.getBucketIdentifier()); metadata.setFlowIdentifier(flow.getIdentifier()); metadata.setAuthor(getIdentity(user)); metadata.setTimestamp(System.currentTimeMillis()); metadata.setVersion(expectedVersion); metadata.setComments(comments); versionedFlowSnapshot.setSnapshotMetadata(metadata); return snapshotClient.create(versionedFlowSnapshot); }
destMetadata.setComments(srcFlowSnapshot.getSnapshotMetadata().getComments()); srcFlowSnapshot.setSnapshotMetadata(destMetadata); client.getFlowSnapshotClient().create(srcFlowSnapshot);
srcSnapshot.setSnapshotMetadata(destMetadata);
private VersionedFlowSnapshot getVersionedFlowSnapshot(final BucketEntity bucketEntity, final FlowEntity flowEntity, final Integer version) { // ensure the snapshot exists final FlowSnapshotEntity snapshotEntity = metadataService.getFlowSnapshot(flowEntity.getId(), version); if (snapshotEntity == null) { LOGGER.warn("The specified flow snapshot id [{}] does not exist for version [{}].", flowEntity.getId(), version); throw new ResourceNotFoundException("The specified versioned flow snapshot does not exist for this flow."); } // get the serialized bytes of the snapshot final byte[] serializedSnapshot = flowPersistenceProvider.getFlowContent(bucketEntity.getId(), flowEntity.getId(), version); if (serializedSnapshot == null || serializedSnapshot.length == 0) { throw new IllegalStateException("No serialized content found for snapshot with flow identifier " + flowEntity.getId() + " and version " + version); } // deserialize the contents final InputStream input = new ByteArrayInputStream(serializedSnapshot); final VersionedProcessGroup flowContents = processGroupSerializer.deserialize(input); // map entities to data model final Bucket bucket = DataModelMapper.map(bucketEntity); final VersionedFlow versionedFlow = DataModelMapper.map(bucketEntity, flowEntity); final VersionedFlowSnapshotMetadata snapshotMetadata = DataModelMapper.map(bucketEntity, snapshotEntity); // create the snapshot to return final VersionedFlowSnapshot snapshot = new VersionedFlowSnapshot(); snapshot.setFlowContents(flowContents); snapshot.setSnapshotMetadata(snapshotMetadata); snapshot.setFlow(versionedFlow); snapshot.setBucket(bucket); return snapshot; }