Search in sources :

Example 1 with VersionedFlowDifference

use of org.apache.nifi.registry.diff.VersionedFlowDifference in project nifi-registry by apache.

the class TestRegistryService method testGetDiffReturnsRemovedComponentChanges.

// -----------------Test Flow Diff Service Method---------------------
@Test
public void testGetDiffReturnsRemovedComponentChanges() {
    when(flowPersistenceProvider.getFlowContent(anyString(), anyString(), anyInt())).thenReturn(new byte[10], new byte[10]);
    final VersionedProcessGroup pgA = createVersionedProcessGroupA();
    final VersionedProcessGroup pgB = createVersionedProcessGroupB();
    when(snapshotSerializer.deserialize(any())).thenReturn(pgA, pgB);
    final VersionedFlowDifference diff = registryService.getFlowDiff("bucketIdentifier", "flowIdentifier", 1, 2);
    assertNotNull(diff);
    Optional<ComponentDifferenceGroup> removedComponent = diff.getComponentDifferenceGroups().stream().filter(p -> p.getComponentId().equals("ID-pg1")).findFirst();
    assertTrue(removedComponent.isPresent());
    assertTrue(removedComponent.get().getDifferences().iterator().next().getDifferenceType().equals("COMPONENT_REMOVED"));
}
Also used : Arrays(java.util.Arrays) SortedSet(java.util.SortedSet) Date(java.util.Date) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) FlowEntity(org.apache.nifi.registry.db.entity.FlowEntity) VersionedFlowSnapshotMetadata(org.apache.nifi.registry.flow.VersionedFlowSnapshotMetadata) VersionedProcessGroup(org.apache.nifi.registry.flow.VersionedProcessGroup) Mockito.doAnswer(org.mockito.Mockito.doAnswer) FlowSnapshotEntity(org.apache.nifi.registry.db.entity.FlowSnapshotEntity) Validator(javax.validation.Validator) Set(java.util.Set) Serializer(org.apache.nifi.registry.serialization.Serializer) BucketEntity(org.apache.nifi.registry.db.entity.BucketEntity) List(java.util.List) VersionedFlowDifference(org.apache.nifi.registry.diff.VersionedFlowDifference) Optional(java.util.Optional) Mockito.mock(org.mockito.Mockito.mock) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Bucket(org.apache.nifi.registry.bucket.Bucket) ValidatorFactory(javax.validation.ValidatorFactory) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Answer(org.mockito.stubbing.Answer) ComponentDifference(org.apache.nifi.registry.diff.ComponentDifference) InvocationOnMock(org.mockito.invocation.InvocationOnMock) ResourceNotFoundException(org.apache.nifi.registry.exception.ResourceNotFoundException) Validation(javax.validation.Validation) ArgumentMatchers.anyInt(org.mockito.ArgumentMatchers.anyInt) Before(org.junit.Before) OutputStream(java.io.OutputStream) VersionedProcessor(org.apache.nifi.registry.flow.VersionedProcessor) ComponentDifferenceGroup(org.apache.nifi.registry.diff.ComponentDifferenceGroup) VersionedProcessGroupSerializer(org.apache.nifi.registry.serialization.VersionedProcessGroupSerializer) Assert.assertNotNull(org.junit.Assert.assertNotNull) FlowPersistenceProvider(org.apache.nifi.registry.flow.FlowPersistenceProvider) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Mockito.times(org.mockito.Mockito.times) Mockito.when(org.mockito.Mockito.when) VersionedFlowSnapshot(org.apache.nifi.registry.flow.VersionedFlowSnapshot) VersionedFlow(org.apache.nifi.registry.flow.VersionedFlow) Mockito.verify(org.mockito.Mockito.verify) ConstraintViolationException(javax.validation.ConstraintViolationException) Assert(org.junit.Assert) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) InputStream(java.io.InputStream) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) VersionedFlowDifference(org.apache.nifi.registry.diff.VersionedFlowDifference) VersionedProcessGroup(org.apache.nifi.registry.flow.VersionedProcessGroup) ComponentDifferenceGroup(org.apache.nifi.registry.diff.ComponentDifferenceGroup) Test(org.junit.Test)

Example 2 with VersionedFlowDifference

use of org.apache.nifi.registry.diff.VersionedFlowDifference in project nifi-registry by apache.

the class TestRegistryService method testGetDiffReturnsChangesInChronologicalOrder.

@Test
public void testGetDiffReturnsChangesInChronologicalOrder() {
    when(flowPersistenceProvider.getFlowContent(anyString(), anyString(), anyInt())).thenReturn(new byte[10], new byte[10]);
    final VersionedProcessGroup pgA = createVersionedProcessGroupA();
    final VersionedProcessGroup pgB = createVersionedProcessGroupB();
    when(snapshotSerializer.deserialize(any())).thenReturn(pgA, pgB);
    // getFlowDiff orders the changes in ascending order of version number regardless of param order
    final VersionedFlowDifference diff = registryService.getFlowDiff("bucketIdentifier", "flowIdentifier", 2, 1);
    assertNotNull(diff);
    Optional<ComponentDifferenceGroup> nameChangedComponent = diff.getComponentDifferenceGroups().stream().filter(p -> p.getComponentId().equals("ProcessorFirstV1")).findFirst();
    assertTrue(nameChangedComponent.isPresent());
    ComponentDifference nameChangeDifference = nameChangedComponent.get().getDifferences().stream().filter(d -> d.getDifferenceType().equals("NAME_CHANGED")).findFirst().get();
    assertEquals("ProcessorFirstV1", nameChangeDifference.getValueA());
    assertEquals("ProcessorFirstV2", nameChangeDifference.getValueB());
}
Also used : Arrays(java.util.Arrays) SortedSet(java.util.SortedSet) Date(java.util.Date) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) FlowEntity(org.apache.nifi.registry.db.entity.FlowEntity) VersionedFlowSnapshotMetadata(org.apache.nifi.registry.flow.VersionedFlowSnapshotMetadata) VersionedProcessGroup(org.apache.nifi.registry.flow.VersionedProcessGroup) Mockito.doAnswer(org.mockito.Mockito.doAnswer) FlowSnapshotEntity(org.apache.nifi.registry.db.entity.FlowSnapshotEntity) Validator(javax.validation.Validator) Set(java.util.Set) Serializer(org.apache.nifi.registry.serialization.Serializer) BucketEntity(org.apache.nifi.registry.db.entity.BucketEntity) List(java.util.List) VersionedFlowDifference(org.apache.nifi.registry.diff.VersionedFlowDifference) Optional(java.util.Optional) Mockito.mock(org.mockito.Mockito.mock) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Bucket(org.apache.nifi.registry.bucket.Bucket) ValidatorFactory(javax.validation.ValidatorFactory) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Answer(org.mockito.stubbing.Answer) ComponentDifference(org.apache.nifi.registry.diff.ComponentDifference) InvocationOnMock(org.mockito.invocation.InvocationOnMock) ResourceNotFoundException(org.apache.nifi.registry.exception.ResourceNotFoundException) Validation(javax.validation.Validation) ArgumentMatchers.anyInt(org.mockito.ArgumentMatchers.anyInt) Before(org.junit.Before) OutputStream(java.io.OutputStream) VersionedProcessor(org.apache.nifi.registry.flow.VersionedProcessor) ComponentDifferenceGroup(org.apache.nifi.registry.diff.ComponentDifferenceGroup) VersionedProcessGroupSerializer(org.apache.nifi.registry.serialization.VersionedProcessGroupSerializer) Assert.assertNotNull(org.junit.Assert.assertNotNull) FlowPersistenceProvider(org.apache.nifi.registry.flow.FlowPersistenceProvider) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Mockito.times(org.mockito.Mockito.times) Mockito.when(org.mockito.Mockito.when) VersionedFlowSnapshot(org.apache.nifi.registry.flow.VersionedFlowSnapshot) VersionedFlow(org.apache.nifi.registry.flow.VersionedFlow) Mockito.verify(org.mockito.Mockito.verify) ConstraintViolationException(javax.validation.ConstraintViolationException) Assert(org.junit.Assert) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) InputStream(java.io.InputStream) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ComponentDifference(org.apache.nifi.registry.diff.ComponentDifference) VersionedFlowDifference(org.apache.nifi.registry.diff.VersionedFlowDifference) VersionedProcessGroup(org.apache.nifi.registry.flow.VersionedProcessGroup) ComponentDifferenceGroup(org.apache.nifi.registry.diff.ComponentDifferenceGroup) Test(org.junit.Test)

Example 3 with VersionedFlowDifference

use of org.apache.nifi.registry.diff.VersionedFlowDifference in project nifi-registry by apache.

the class RegistryService method getFlowDiff.

/**
 * Returns the differences between two specified versions of a flow.
 *
 * @param bucketIdentifier the id of the bucket the flow exists in
 * @param flowIdentifier the flow to be examined
 * @param versionA the first version of the comparison
 * @param versionB the second version of the comparison
 * @return The differences between two specified versions, grouped by component.
 */
public VersionedFlowDifference getFlowDiff(final String bucketIdentifier, final String flowIdentifier, final Integer versionA, final Integer versionB) {
    if (StringUtils.isBlank(bucketIdentifier)) {
        throw new IllegalArgumentException("Bucket identifier cannot be null or blank");
    }
    if (StringUtils.isBlank(flowIdentifier)) {
        throw new IllegalArgumentException("Flow identifier cannot be null or blank");
    }
    if (versionA == null || versionB == null) {
        throw new IllegalArgumentException("Version cannot be null or blank");
    }
    // older version is always the lower, regardless of the order supplied
    final Integer older = Math.min(versionA, versionB);
    final Integer newer = Math.max(versionA, versionB);
    readLock.lock();
    try {
        // Get the content for both versions of the flow
        final byte[] serializedSnapshotA = flowPersistenceProvider.getFlowContent(bucketIdentifier, flowIdentifier, older);
        if (serializedSnapshotA == null || serializedSnapshotA.length == 0) {
            throw new IllegalStateException("No serialized content found for snapshot with flow identifier " + flowIdentifier + " and version " + older);
        }
        final byte[] serializedSnapshotB = flowPersistenceProvider.getFlowContent(bucketIdentifier, flowIdentifier, newer);
        if (serializedSnapshotB == null || serializedSnapshotB.length == 0) {
            throw new IllegalStateException("No serialized content found for snapshot with flow identifier " + flowIdentifier + " and version " + newer);
        }
        // deserialize the contents
        final InputStream inputA = new ByteArrayInputStream(serializedSnapshotA);
        final VersionedProcessGroup flowContentsA = processGroupSerializer.deserialize(inputA);
        final InputStream inputB = new ByteArrayInputStream(serializedSnapshotB);
        final VersionedProcessGroup flowContentsB = processGroupSerializer.deserialize(inputB);
        final ComparableDataFlow comparableFlowA = new StandardComparableDataFlow(String.format("Version %d", older), flowContentsA);
        final ComparableDataFlow comparableFlowB = new StandardComparableDataFlow(String.format("Version %d", newer), flowContentsB);
        // Compare the two versions of the flow
        final FlowComparator flowComparator = new StandardFlowComparator(comparableFlowA, comparableFlowB, null, new ConciseEvolvingDifferenceDescriptor());
        final FlowComparison flowComparison = flowComparator.compare();
        VersionedFlowDifference result = new VersionedFlowDifference();
        result.setBucketId(bucketIdentifier);
        result.setFlowId(flowIdentifier);
        result.setVersionA(older);
        result.setVersionB(newer);
        Set<ComponentDifferenceGroup> differenceGroups = getStringComponentDifferenceGroupMap(flowComparison.getDifferences());
        result.setComponentDifferenceGroups(differenceGroups);
        return result;
    } finally {
        readLock.unlock();
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) VersionedProcessGroup(org.apache.nifi.registry.flow.VersionedProcessGroup) FlowComparison(org.apache.nifi.registry.flow.diff.FlowComparison) ConciseEvolvingDifferenceDescriptor(org.apache.nifi.registry.flow.diff.ConciseEvolvingDifferenceDescriptor) StandardFlowComparator(org.apache.nifi.registry.flow.diff.StandardFlowComparator) StandardComparableDataFlow(org.apache.nifi.registry.flow.diff.StandardComparableDataFlow) ComparableDataFlow(org.apache.nifi.registry.flow.diff.ComparableDataFlow) ByteArrayInputStream(java.io.ByteArrayInputStream) VersionedFlowDifference(org.apache.nifi.registry.diff.VersionedFlowDifference) ComponentDifferenceGroup(org.apache.nifi.registry.diff.ComponentDifferenceGroup) StandardComparableDataFlow(org.apache.nifi.registry.flow.diff.StandardComparableDataFlow) StandardFlowComparator(org.apache.nifi.registry.flow.diff.StandardFlowComparator) FlowComparator(org.apache.nifi.registry.flow.diff.FlowComparator)

Example 4 with VersionedFlowDifference

use of org.apache.nifi.registry.diff.VersionedFlowDifference in project nifi-registry by apache.

the class UnsecuredNiFiRegistryClientIT method testNiFiRegistryClient.

@Test
public void testNiFiRegistryClient() throws IOException, NiFiRegistryException {
    // ---------------------- TEST BUCKETS --------------------------//
    final BucketClient bucketClient = client.getBucketClient();
    // create buckets
    final int numBuckets = 10;
    final List<Bucket> createdBuckets = new ArrayList<>();
    for (int i = 0; i < numBuckets; i++) {
        final Bucket createdBucket = createBucket(bucketClient, i);
        LOGGER.info("Created bucket # " + i + " with id " + createdBucket.getIdentifier());
        createdBuckets.add(createdBucket);
    }
    // get each bucket
    for (final Bucket bucket : createdBuckets) {
        final Bucket retrievedBucket = bucketClient.get(bucket.getIdentifier());
        Assert.assertNotNull(retrievedBucket);
        LOGGER.info("Retrieved bucket " + retrievedBucket.getIdentifier());
    }
    // final Bucket nonExistentBucket = bucketClient.get("does-not-exist");
    // Assert.assertNull(nonExistentBucket);
    // get bucket fields
    final Fields bucketFields = bucketClient.getFields();
    Assert.assertNotNull(bucketFields);
    LOGGER.info("Retrieved bucket fields, size = " + bucketFields.getFields().size());
    Assert.assertTrue(bucketFields.getFields().size() > 0);
    // get all buckets
    final List<Bucket> allBuckets = bucketClient.getAll();
    LOGGER.info("Retrieved buckets, size = " + allBuckets.size());
    Assert.assertEquals(numBuckets, allBuckets.size());
    allBuckets.stream().forEach(b -> System.out.println("Retrieve bucket " + b.getIdentifier()));
    // update each bucket
    for (final Bucket bucket : createdBuckets) {
        final Bucket bucketUpdate = new Bucket();
        bucketUpdate.setIdentifier(bucket.getIdentifier());
        bucketUpdate.setDescription(bucket.getDescription() + " UPDATE");
        final Bucket updatedBucket = bucketClient.update(bucketUpdate);
        Assert.assertNotNull(updatedBucket);
        LOGGER.info("Updated bucket " + updatedBucket.getIdentifier());
    }
    // ---------------------- TEST FLOWS --------------------------//
    final FlowClient flowClient = client.getFlowClient();
    // create flows
    final Bucket flowsBucket = createdBuckets.get(0);
    final VersionedFlow flow1 = createFlow(flowClient, flowsBucket, 1);
    LOGGER.info("Created flow # 1 with id " + flow1.getIdentifier());
    final VersionedFlow flow2 = createFlow(flowClient, flowsBucket, 2);
    LOGGER.info("Created flow # 2 with id " + flow2.getIdentifier());
    // get flow
    final VersionedFlow retrievedFlow1 = flowClient.get(flowsBucket.getIdentifier(), flow1.getIdentifier());
    Assert.assertNotNull(retrievedFlow1);
    LOGGER.info("Retrieved flow # 1 with id " + retrievedFlow1.getIdentifier());
    final VersionedFlow retrievedFlow2 = flowClient.get(flowsBucket.getIdentifier(), flow2.getIdentifier());
    Assert.assertNotNull(retrievedFlow2);
    LOGGER.info("Retrieved flow # 2 with id " + retrievedFlow2.getIdentifier());
    // update flows
    final VersionedFlow flow1Update = new VersionedFlow();
    flow1Update.setIdentifier(flow1.getIdentifier());
    flow1Update.setName(flow1.getName() + " UPDATED");
    final VersionedFlow updatedFlow1 = flowClient.update(flowsBucket.getIdentifier(), flow1Update);
    Assert.assertNotNull(updatedFlow1);
    LOGGER.info("Updated flow # 1 with id " + updatedFlow1.getIdentifier());
    // get flow fields
    final Fields flowFields = flowClient.getFields();
    Assert.assertNotNull(flowFields);
    LOGGER.info("Retrieved flow fields, size = " + flowFields.getFields().size());
    Assert.assertTrue(flowFields.getFields().size() > 0);
    // get flows in bucket
    final List<VersionedFlow> flowsInBucket = flowClient.getByBucket(flowsBucket.getIdentifier());
    Assert.assertNotNull(flowsInBucket);
    Assert.assertEquals(2, flowsInBucket.size());
    flowsInBucket.stream().forEach(f -> LOGGER.info("Flow in bucket, flow id " + f.getIdentifier()));
    // ---------------------- TEST SNAPSHOTS --------------------------//
    final FlowSnapshotClient snapshotClient = client.getFlowSnapshotClient();
    // create snapshots
    final VersionedFlow snapshotFlow = flow1;
    final VersionedFlowSnapshot snapshot1 = createSnapshot(snapshotClient, snapshotFlow, 1);
    LOGGER.info("Created snapshot # 1 with version " + snapshot1.getSnapshotMetadata().getVersion());
    final VersionedFlowSnapshot snapshot2 = createSnapshot(snapshotClient, snapshotFlow, 2);
    LOGGER.info("Created snapshot # 2 with version " + snapshot2.getSnapshotMetadata().getVersion());
    // get snapshot
    final VersionedFlowSnapshot retrievedSnapshot1 = snapshotClient.get(snapshotFlow.getBucketIdentifier(), snapshotFlow.getIdentifier(), 1);
    Assert.assertNotNull(retrievedSnapshot1);
    Assert.assertFalse(retrievedSnapshot1.isLatest());
    LOGGER.info("Retrieved snapshot # 1 with version " + retrievedSnapshot1.getSnapshotMetadata().getVersion());
    final VersionedFlowSnapshot retrievedSnapshot2 = snapshotClient.get(snapshotFlow.getBucketIdentifier(), snapshotFlow.getIdentifier(), 2);
    Assert.assertNotNull(retrievedSnapshot2);
    Assert.assertTrue(retrievedSnapshot2.isLatest());
    LOGGER.info("Retrieved snapshot # 2 with version " + retrievedSnapshot2.getSnapshotMetadata().getVersion());
    // get latest
    final VersionedFlowSnapshot retrievedSnapshotLatest = snapshotClient.getLatest(snapshotFlow.getBucketIdentifier(), snapshotFlow.getIdentifier());
    Assert.assertNotNull(retrievedSnapshotLatest);
    Assert.assertEquals(snapshot2.getSnapshotMetadata().getVersion(), retrievedSnapshotLatest.getSnapshotMetadata().getVersion());
    Assert.assertTrue(retrievedSnapshotLatest.isLatest());
    LOGGER.info("Retrieved latest snapshot with version " + retrievedSnapshotLatest.getSnapshotMetadata().getVersion());
    // get metadata
    final List<VersionedFlowSnapshotMetadata> retrievedMetadata = snapshotClient.getSnapshotMetadata(snapshotFlow.getBucketIdentifier(), snapshotFlow.getIdentifier());
    Assert.assertNotNull(retrievedMetadata);
    Assert.assertEquals(2, retrievedMetadata.size());
    Assert.assertEquals(2, retrievedMetadata.get(0).getVersion());
    Assert.assertEquals(1, retrievedMetadata.get(1).getVersion());
    retrievedMetadata.stream().forEach(s -> LOGGER.info("Retrieved snapshot metadata " + s.getVersion()));
    // get latest metadata
    final VersionedFlowSnapshotMetadata latestMetadata = snapshotClient.getLatestMetadata(snapshotFlow.getBucketIdentifier(), snapshotFlow.getIdentifier());
    Assert.assertNotNull(latestMetadata);
    Assert.assertEquals(2, latestMetadata.getVersion());
    // get latest metadata that doesn't exist
    try {
        snapshotClient.getLatestMetadata(snapshotFlow.getBucketIdentifier(), "DOES-NOT-EXIST");
        Assert.fail("Should have thrown exception");
    } catch (NiFiRegistryException nfe) {
        Assert.assertEquals("Error retrieving latest snapshot metadata: The specified flow ID does not exist in this bucket.", nfe.getMessage());
    }
    // ---------------------- TEST ITEMS --------------------------//
    final ItemsClient itemsClient = client.getItemsClient();
    // get fields
    final Fields itemFields = itemsClient.getFields();
    Assert.assertNotNull(itemFields.getFields());
    Assert.assertTrue(itemFields.getFields().size() > 0);
    // get all items
    final List<BucketItem> allItems = itemsClient.getAll();
    Assert.assertEquals(2, allItems.size());
    allItems.stream().forEach(i -> Assert.assertNotNull(i.getBucketName()));
    allItems.stream().forEach(i -> LOGGER.info("All items, item " + i.getIdentifier()));
    // get items for bucket
    final List<BucketItem> bucketItems = itemsClient.getByBucket(flowsBucket.getIdentifier());
    Assert.assertEquals(2, bucketItems.size());
    allItems.stream().forEach(i -> Assert.assertNotNull(i.getBucketName()));
    bucketItems.stream().forEach(i -> LOGGER.info("Items in bucket, item " + i.getIdentifier()));
    // ----------------------- TEST DIFF ---------------------------//
    final VersionedFlowSnapshot snapshot3 = buildSnapshot(snapshotFlow, 3);
    final VersionedProcessGroup newlyAddedPG = new VersionedProcessGroup();
    newlyAddedPG.setIdentifier("new-pg");
    newlyAddedPG.setName("NEW Process Group");
    snapshot3.getFlowContents().getProcessGroups().add(newlyAddedPG);
    snapshotClient.create(snapshot3);
    VersionedFlowDifference diff = flowClient.diff(snapshotFlow.getBucketIdentifier(), snapshotFlow.getIdentifier(), 3, 2);
    Assert.assertNotNull(diff);
    Assert.assertEquals(1, diff.getComponentDifferenceGroups().size());
    // ---------------------- DELETE DATA --------------------------//
    final VersionedFlow deletedFlow1 = flowClient.delete(flowsBucket.getIdentifier(), flow1.getIdentifier());
    Assert.assertNotNull(deletedFlow1);
    LOGGER.info("Deleted flow " + deletedFlow1.getIdentifier());
    final VersionedFlow deletedFlow2 = flowClient.delete(flowsBucket.getIdentifier(), flow2.getIdentifier());
    Assert.assertNotNull(deletedFlow2);
    LOGGER.info("Deleted flow " + deletedFlow2.getIdentifier());
    // delete each bucket
    for (final Bucket bucket : createdBuckets) {
        final Bucket deletedBucket = bucketClient.delete(bucket.getIdentifier());
        Assert.assertNotNull(deletedBucket);
        LOGGER.info("Deleted bucket " + deletedBucket.getIdentifier());
    }
    Assert.assertEquals(0, bucketClient.getAll().size());
    LOGGER.info("!!! SUCCESS !!!");
}
Also used : BucketClient(org.apache.nifi.registry.client.BucketClient) ArrayList(java.util.ArrayList) VersionedFlow(org.apache.nifi.registry.flow.VersionedFlow) VersionedProcessGroup(org.apache.nifi.registry.flow.VersionedProcessGroup) ItemsClient(org.apache.nifi.registry.client.ItemsClient) FlowClient(org.apache.nifi.registry.client.FlowClient) FlowSnapshotClient(org.apache.nifi.registry.client.FlowSnapshotClient) VersionedFlowSnapshotMetadata(org.apache.nifi.registry.flow.VersionedFlowSnapshotMetadata) Fields(org.apache.nifi.registry.field.Fields) Bucket(org.apache.nifi.registry.bucket.Bucket) VersionedFlowDifference(org.apache.nifi.registry.diff.VersionedFlowDifference) VersionedFlowSnapshot(org.apache.nifi.registry.flow.VersionedFlowSnapshot) BucketItem(org.apache.nifi.registry.bucket.BucketItem) NiFiRegistryException(org.apache.nifi.registry.client.NiFiRegistryException) Test(org.junit.Test)

Example 5 with VersionedFlowDifference

use of org.apache.nifi.registry.diff.VersionedFlowDifference in project nifi-registry by apache.

the class BucketFlowResource method getFlowDiff.

@GET
@Path("{flowId}/diff/{versionA: \\d+}/{versionB: \\d+}")
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Returns a list of differences between 2 versions of a flow", response = VersionedFlowDifference.class, extensions = { @Extension(name = "access-policy", properties = { @ExtensionProperty(name = "action", value = "read"), @ExtensionProperty(name = "resource", value = "/buckets/{bucketId}") }) })
@ApiResponses({ @ApiResponse(code = 400, message = HttpStatusMessages.MESSAGE_400), @ApiResponse(code = 401, message = HttpStatusMessages.MESSAGE_401), @ApiResponse(code = 403, message = HttpStatusMessages.MESSAGE_403), @ApiResponse(code = 404, message = HttpStatusMessages.MESSAGE_404), @ApiResponse(code = 409, message = HttpStatusMessages.MESSAGE_409) })
public Response getFlowDiff(@PathParam("bucketId") @ApiParam("The bucket identifier") final String bucketId, @PathParam("flowId") @ApiParam("The flow identifier") final String flowId, @PathParam("versionA") @ApiParam("The first version number") final Integer versionNumberA, @PathParam("versionB") @ApiParam("The second version number") final Integer versionNumberB) {
    authorizeBucketAccess(RequestAction.READ, bucketId);
    VersionedFlowDifference result = registryService.getFlowDiff(bucketId, flowId, versionNumberA, versionNumberB);
    return Response.status(Response.Status.OK).entity(result).build();
}
Also used : VersionedFlowDifference(org.apache.nifi.registry.diff.VersionedFlowDifference) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

VersionedFlowDifference (org.apache.nifi.registry.diff.VersionedFlowDifference)5 VersionedProcessGroup (org.apache.nifi.registry.flow.VersionedProcessGroup)4 InputStream (java.io.InputStream)3 ArrayList (java.util.ArrayList)3 Bucket (org.apache.nifi.registry.bucket.Bucket)3 ComponentDifferenceGroup (org.apache.nifi.registry.diff.ComponentDifferenceGroup)3 VersionedFlow (org.apache.nifi.registry.flow.VersionedFlow)3 VersionedFlowSnapshot (org.apache.nifi.registry.flow.VersionedFlowSnapshot)3 VersionedFlowSnapshotMetadata (org.apache.nifi.registry.flow.VersionedFlowSnapshotMetadata)3 Test (org.junit.Test)3 OutputStream (java.io.OutputStream)2 Arrays (java.util.Arrays)2 Collections (java.util.Collections)2 Date (java.util.Date)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 List (java.util.List)2 Optional (java.util.Optional)2 Set (java.util.Set)2 SortedSet (java.util.SortedSet)2