exceptionfactory commented on a change in pull request #319:
URL: https://github.com/apache/nifi-registry/pull/319#discussion_r616786093
##########
File path:
nifi-registry-core/nifi-registry-web-api/src/main/java/org/apache/nifi/registry/web/api/BucketFlowResource.java
##########
@@ -385,6 +520,64 @@ public Response getLatestFlowVersionMetadata(
return Response.status(Response.Status.OK).entity(latest).build();
}
+ @GET
+ @Path("{flowId}/versions/{versionNumber: \\d+}/export")
+ @Consumes(MediaType.WILDCARD)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(
+ value = "Exports specified bucket flow version content",
+ notes = "Exports the specified version of a flow, including the
metadata and content of the flow.",
+ response = VersionedFlowSnapshot.class,
+ extensions = {
+ @Extension(name = "access-policy", properties = {
+ @ExtensionProperty(name = "action", value =
"read"),
+ @ExtensionProperty(name = "resource", value =
"/buckets/{bucketId}")})
+ }
+ )
+ @ApiResponses({
+ @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 exportVersionedFlow(
+ @PathParam("bucketId")
+ @ApiParam("The bucket identifier") final String bucketId,
+ @PathParam("flowId")
+ @ApiParam("The flow identifier") final String flowId,
+ @PathParam("versionNumber")
+ @ApiParam("The version number") final Integer versionNumber) {
+
+ if (StringUtils.isBlank(bucketId)) {
+ throw new IllegalArgumentException("The bucket identifier is
required.");
+ }
+
+ if (StringUtils.isBlank(flowId)) {
+ throw new IllegalArgumentException("The flow identifier is
required.");
+ }
+
+ if (versionNumber == null) {
+ throw new IllegalArgumentException("The version number is
required.");
+ }
+
+ final VersionedFlowSnapshot versionedFlowSnapshot =
serviceFacade.getFlowSnapshot(bucketId, flowId, versionNumber);
+
+ versionedFlowSnapshot.setFlow(null);
+ versionedFlowSnapshot.setBucket(null);
+ versionedFlowSnapshot.getSnapshotMetadata().setBucketIdentifier(null);
+ versionedFlowSnapshot.getSnapshotMetadata().setFlowIdentifier(null);
+ versionedFlowSnapshot.getSnapshotMetadata().setLink(null);
+
+ String attachmentName = "flow-version-" + versionNumber;
+
+ UriUtils.encodePath(attachmentName, StandardCharsets.UTF_8);
+
+ String filename = attachmentName + ".json";
+
+ final String versionedFlowSnapshotJsonString =
serializeToJson(versionedFlowSnapshot);
+
+ return
generateOkResponse(versionedFlowSnapshotJsonString).header(HttpHeaders.CONTENT_DISPOSITION,
String.format("attachment; filename=\"%s\"", filename)).build();
Review comment:
For ease for reading, what do you think about formatting the content
disposition separately and including the filename in the format?
```suggestion
final String versionedFlowSnapshotJsonString =
serializeToJson(versionedFlowSnapshot);
final String contentDisposition = String.format("attachment;
filename=\"file-version-%d.json\"", versionNumber)
return
generateOkResponse(versionedFlowSnapshotJsonString).header(HttpHeaders.CONTENT_DISPOSITION,
contentDisposition).build();
```
##########
File path:
nifi-registry-core/nifi-registry-web-api/src/main/java/org/apache/nifi/registry/web/api/BucketFlowResource.java
##########
@@ -385,6 +520,64 @@ public Response getLatestFlowVersionMetadata(
return Response.status(Response.Status.OK).entity(latest).build();
}
+ @GET
+ @Path("{flowId}/versions/{versionNumber: \\d+}/export")
Review comment:
Is there supposed to be a space between `versionNumber` and the `\\d+`
pattern?
##########
File path:
nifi-registry-core/nifi-registry-web-ui/src/main/webapp/services/nf-registry.api.js
##########
@@ -75,6 +75,113 @@ NfRegistryApi.prototype = {
);
},
+ /**
+ * Retrieves the specified versioned flow snapshot for an existing droplet
the registry has stored.
+ *
+ * @param {string} dropletUri The uri of the droplet to request.
+ * @param {number} versionNumber The version of the flow to request.
+ * @returns {*}
+ */
+ exportDropletVersionedSnapshot: function (dropletUri, versionNumber) {
+ var self = this;
+ var url = '../nifi-registry-api/' + dropletUri;
+ url += '/versions/' + versionNumber + '/export';
Review comment:
Is there a reason for building the `url` in two lines as opposed to one?
##########
File path:
nifi-registry-core/nifi-registry-web-api/src/main/java/org/apache/nifi/registry/web/api/BucketFlowResource.java
##########
@@ -291,6 +303,129 @@ public Response createFlowVersion(
return
Response.status(Response.Status.OK).entity(createdSnapshot).build();
}
+ @POST
+ @Path("{flowId}/versions/import")
+ @Consumes(MediaType.MULTIPART_FORM_DATA)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(
+ value = "Upload flow version",
+ notes = "Uploads the next version of a flow. The version number of
the object being created must be the " +
+ "next available version integer. Flow versions are
immutable after they are created.",
+ response = VersionedFlowSnapshot.class,
+ extensions = {
+ @Extension(name = "access-policy", properties = {
+ @ExtensionProperty(name = "action", value =
"write"),
+ @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 importVersionedFlow(
+ @PathParam("bucketId")
+ @ApiParam("The bucket identifier")
+ final String bucketId,
+ @PathParam("flowId")
+ @ApiParam(value = "The flow identifier")
+ final String flowId,
+ @FormDataParam("file") final InputStream in,
+ @FormDataParam("comments") final String comments) {
+
+ if (StringUtils.isBlank(bucketId)) {
+ throw new IllegalArgumentException("The bucket identifier is
required.");
+ }
+
+ if (StringUtils.isBlank(flowId)) {
+ throw new IllegalArgumentException("The flow identifier is
required.");
+ }
+
+ // deserialize InputStream to a VersionedFlowSnapshot
+ VersionedFlowSnapshot versionedFlowSnapshot;
+
+ versionedFlowSnapshot = deserializeVersionedFlowSnapshot(in);
+
+ // clear or set the necessary snapShotMetadata
+ if (versionedFlowSnapshot.getSnapshotMetadata() != null) {
+
versionedFlowSnapshot.getSnapshotMetadata().setBucketIdentifier(null);
+
versionedFlowSnapshot.getSnapshotMetadata().setFlowIdentifier(null);
+ versionedFlowSnapshot.getSnapshotMetadata().setLink(null);
+ versionedFlowSnapshot.getSnapshotMetadata().setVersion(-1);
+ versionedFlowSnapshot.getSnapshotMetadata().setVersion(-1);
+ // if there are new comments, then set it
+ // otherwise, keep the original comments
+ if (!StringUtils.isBlank(comments)) {
+
versionedFlowSnapshot.getSnapshotMetadata().setComments(comments);
+ }
+ }
+
+ return createFlowVersion(bucketId, flowId, versionedFlowSnapshot);
+ }
+
+ @POST
+ @Path("import")
+ @Consumes(MediaType.MULTIPART_FORM_DATA)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(
+ value = "Create flow",
+ notes = "Creates a flow in the given bucket. The flow id is
created by the server and populated in the returned entity.",
+ response = VersionedFlow.class,
+ extensions = {
+ @Extension(name = "access-policy", properties = {
+ @ExtensionProperty(name = "action", value =
"write"),
+ @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 importFlow(
+ @PathParam("bucketId")
+ @ApiParam("The bucket identifier") final String bucketId,
+ @FormDataParam("file") final InputStream in,
+ @FormDataParam("name") final String name,
+ @FormDataParam("description") final String description) {
+
+ if (StringUtils.isBlank(bucketId)) {
+ throw new IllegalArgumentException("The bucket identifier is
required.");
+ }
+
+ if (StringUtils.isBlank(name)) {
+ throw new IllegalArgumentException("The flow name is required.");
+ }
+
+ // create VersionedFlow
+ final VersionedFlow versionedFlow = new VersionedFlow();
+
+ versionedFlow.setName(name);
+ versionedFlow.setRevision(new RevisionInfo(null, 0L));
+ if (!StringUtils.isBlank(description)) {
+ versionedFlow.setDescription(description);
+ }
+
+ final VersionedFlow createdFlow =
createAndPublishVersionedFlow(bucketId, versionedFlow);
+
+ // deserialize InputStream and create new VersionedFlowSnapshot
+ final VersionedFlowSnapshot versionedFlowSnapshot =
deserializeVersionedFlowSnapshot(in);
+
+ setSnaphotMetadataIfMissing(bucketId, createdFlow.getIdentifier(),
versionedFlowSnapshot);
+
+ // set remaining snapshot metadata
+ final String userIdentity = NiFiUserUtils.getNiFiUserIdentity();
+ versionedFlowSnapshot.getSnapshotMetadata().setAuthor(userIdentity);
+ versionedFlowSnapshot.getSnapshotMetadata().setVersion(-1);
Review comment:
Recommend updating this version reference as well with a static variable.
##########
File path:
nifi-registry-core/nifi-registry-web-api/src/main/java/org/apache/nifi/registry/web/api/BucketFlowResource.java
##########
@@ -291,6 +303,129 @@ public Response createFlowVersion(
return
Response.status(Response.Status.OK).entity(createdSnapshot).build();
}
+ @POST
+ @Path("{flowId}/versions/import")
+ @Consumes(MediaType.MULTIPART_FORM_DATA)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(
+ value = "Upload flow version",
+ notes = "Uploads the next version of a flow. The version number of
the object being created must be the " +
+ "next available version integer. Flow versions are
immutable after they are created.",
+ response = VersionedFlowSnapshot.class,
+ extensions = {
+ @Extension(name = "access-policy", properties = {
+ @ExtensionProperty(name = "action", value =
"write"),
+ @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 importVersionedFlow(
+ @PathParam("bucketId")
+ @ApiParam("The bucket identifier")
+ final String bucketId,
+ @PathParam("flowId")
+ @ApiParam(value = "The flow identifier")
+ final String flowId,
+ @FormDataParam("file") final InputStream in,
+ @FormDataParam("comments") final String comments) {
+
+ if (StringUtils.isBlank(bucketId)) {
+ throw new IllegalArgumentException("The bucket identifier is
required.");
+ }
+
+ if (StringUtils.isBlank(flowId)) {
+ throw new IllegalArgumentException("The flow identifier is
required.");
+ }
+
+ // deserialize InputStream to a VersionedFlowSnapshot
+ VersionedFlowSnapshot versionedFlowSnapshot;
+
+ versionedFlowSnapshot = deserializeVersionedFlowSnapshot(in);
+
+ // clear or set the necessary snapShotMetadata
+ if (versionedFlowSnapshot.getSnapshotMetadata() != null) {
+
versionedFlowSnapshot.getSnapshotMetadata().setBucketIdentifier(null);
+
versionedFlowSnapshot.getSnapshotMetadata().setFlowIdentifier(null);
+ versionedFlowSnapshot.getSnapshotMetadata().setLink(null);
+ versionedFlowSnapshot.getSnapshotMetadata().setVersion(-1);
+ versionedFlowSnapshot.getSnapshotMetadata().setVersion(-1);
+ // if there are new comments, then set it
+ // otherwise, keep the original comments
+ if (!StringUtils.isBlank(comments)) {
+
versionedFlowSnapshot.getSnapshotMetadata().setComments(comments);
+ }
+ }
+
+ return createFlowVersion(bucketId, flowId, versionedFlowSnapshot);
+ }
+
+ @POST
+ @Path("import")
+ @Consumes(MediaType.MULTIPART_FORM_DATA)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(
+ value = "Create flow",
+ notes = "Creates a flow in the given bucket. The flow id is
created by the server and populated in the returned entity.",
+ response = VersionedFlow.class,
+ extensions = {
+ @Extension(name = "access-policy", properties = {
+ @ExtensionProperty(name = "action", value =
"write"),
+ @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 importFlow(
+ @PathParam("bucketId")
+ @ApiParam("The bucket identifier") final String bucketId,
+ @FormDataParam("file") final InputStream in,
+ @FormDataParam("name") final String name,
+ @FormDataParam("description") final String description) {
+
+ if (StringUtils.isBlank(bucketId)) {
+ throw new IllegalArgumentException("The bucket identifier is
required.");
+ }
+
+ if (StringUtils.isBlank(name)) {
+ throw new IllegalArgumentException("The flow name is required.");
+ }
+
+ // create VersionedFlow
+ final VersionedFlow versionedFlow = new VersionedFlow();
+
+ versionedFlow.setName(name);
+ versionedFlow.setRevision(new RevisionInfo(null, 0L));
+ if (!StringUtils.isBlank(description)) {
+ versionedFlow.setDescription(description);
+ }
+
+ final VersionedFlow createdFlow =
createAndPublishVersionedFlow(bucketId, versionedFlow);
+
+ // deserialize InputStream and create new VersionedFlowSnapshot
+ final VersionedFlowSnapshot versionedFlowSnapshot =
deserializeVersionedFlowSnapshot(in);
+
+ setSnaphotMetadataIfMissing(bucketId, createdFlow.getIdentifier(),
versionedFlowSnapshot);
+
+ // set remaining snapshot metadata
+ final String userIdentity = NiFiUserUtils.getNiFiUserIdentity();
+ versionedFlowSnapshot.getSnapshotMetadata().setAuthor(userIdentity);
+ versionedFlowSnapshot.getSnapshotMetadata().setVersion(-1);
+
+ final VersionedFlowSnapshot createdSnapshot =
serviceFacade.createFlowSnapshot(versionedFlowSnapshot);
+ publish(EventFactory.flowVersionCreated(createdSnapshot));
+
+ return
Response.status(Response.Status.OK).entity(createdSnapshot).build();
Review comment:
Although Response.Status.OK is accurate, Response.Status.CREATED seems
more applicable given that a resource is being created.
##########
File path:
nifi-registry-core/nifi-registry-web-api/src/main/java/org/apache/nifi/registry/web/api/BucketFlowResource.java
##########
@@ -385,6 +520,64 @@ public Response getLatestFlowVersionMetadata(
return Response.status(Response.Status.OK).entity(latest).build();
}
+ @GET
+ @Path("{flowId}/versions/{versionNumber: \\d+}/export")
+ @Consumes(MediaType.WILDCARD)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(
+ value = "Exports specified bucket flow version content",
+ notes = "Exports the specified version of a flow, including the
metadata and content of the flow.",
+ response = VersionedFlowSnapshot.class,
+ extensions = {
+ @Extension(name = "access-policy", properties = {
+ @ExtensionProperty(name = "action", value =
"read"),
+ @ExtensionProperty(name = "resource", value =
"/buckets/{bucketId}")})
+ }
+ )
+ @ApiResponses({
+ @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 exportVersionedFlow(
+ @PathParam("bucketId")
+ @ApiParam("The bucket identifier") final String bucketId,
+ @PathParam("flowId")
+ @ApiParam("The flow identifier") final String flowId,
+ @PathParam("versionNumber")
+ @ApiParam("The version number") final Integer versionNumber) {
+
+ if (StringUtils.isBlank(bucketId)) {
+ throw new IllegalArgumentException("The bucket identifier is
required.");
+ }
+
+ if (StringUtils.isBlank(flowId)) {
+ throw new IllegalArgumentException("The flow identifier is
required.");
+ }
+
+ if (versionNumber == null) {
+ throw new IllegalArgumentException("The version number is
required.");
+ }
+
+ final VersionedFlowSnapshot versionedFlowSnapshot =
serviceFacade.getFlowSnapshot(bucketId, flowId, versionNumber);
+
+ versionedFlowSnapshot.setFlow(null);
+ versionedFlowSnapshot.setBucket(null);
+ versionedFlowSnapshot.getSnapshotMetadata().setBucketIdentifier(null);
+ versionedFlowSnapshot.getSnapshotMetadata().setFlowIdentifier(null);
+ versionedFlowSnapshot.getSnapshotMetadata().setLink(null);
+
+ String attachmentName = "flow-version-" + versionNumber;
+
+ UriUtils.encodePath(attachmentName, StandardCharsets.UTF_8);
Review comment:
This line does not assign a variable, and it does not seem necessary
since the attachmentName should not include any characters that require
encoding based on the value assigned.
##########
File path: nifi-registry-core/nifi-registry-web-api/pom.xml
##########
@@ -423,6 +423,16 @@
<artifactId>jjwt</artifactId>
<version>0.7.0</version>
</dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.google.protobuf</groupId>
+ <artifactId>protobuf-java</artifactId>
+ <version>3.11.4</version>
+ <scope>compile</scope>
+ </dependency>
Review comment:
Is this dependency necessary? There do not appear to be any references
to protobuf in the changed classes.
##########
File path:
nifi-registry-core/nifi-registry-web-api/src/main/java/org/apache/nifi/registry/web/api/BucketFlowResource.java
##########
@@ -291,6 +303,129 @@ public Response createFlowVersion(
return
Response.status(Response.Status.OK).entity(createdSnapshot).build();
}
+ @POST
+ @Path("{flowId}/versions/import")
+ @Consumes(MediaType.MULTIPART_FORM_DATA)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(
+ value = "Upload flow version",
+ notes = "Uploads the next version of a flow. The version number of
the object being created must be the " +
+ "next available version integer. Flow versions are
immutable after they are created.",
+ response = VersionedFlowSnapshot.class,
+ extensions = {
+ @Extension(name = "access-policy", properties = {
+ @ExtensionProperty(name = "action", value =
"write"),
+ @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 importVersionedFlow(
+ @PathParam("bucketId")
+ @ApiParam("The bucket identifier")
+ final String bucketId,
+ @PathParam("flowId")
+ @ApiParam(value = "The flow identifier")
+ final String flowId,
+ @FormDataParam("file") final InputStream in,
+ @FormDataParam("comments") final String comments) {
+
+ if (StringUtils.isBlank(bucketId)) {
+ throw new IllegalArgumentException("The bucket identifier is
required.");
+ }
+
+ if (StringUtils.isBlank(flowId)) {
+ throw new IllegalArgumentException("The flow identifier is
required.");
+ }
+
+ // deserialize InputStream to a VersionedFlowSnapshot
+ VersionedFlowSnapshot versionedFlowSnapshot;
+
+ versionedFlowSnapshot = deserializeVersionedFlowSnapshot(in);
+
+ // clear or set the necessary snapShotMetadata
+ if (versionedFlowSnapshot.getSnapshotMetadata() != null) {
+
versionedFlowSnapshot.getSnapshotMetadata().setBucketIdentifier(null);
+
versionedFlowSnapshot.getSnapshotMetadata().setFlowIdentifier(null);
+ versionedFlowSnapshot.getSnapshotMetadata().setLink(null);
+ versionedFlowSnapshot.getSnapshotMetadata().setVersion(-1);
+ versionedFlowSnapshot.getSnapshotMetadata().setVersion(-1);
Review comment:
Since the value of `-1` is being used in multiple places, it would be
helpful to define and reuse a static variable named something like
`DEFAULT_VERSION` or `INITIAL_VERSION`.
##########
File path:
nifi-registry-core/nifi-registry-web-ui/src/main/webapp/components/explorer/grid-list/dialogs/download-versioned-flow/nf-registry-download-versioned-flow.js
##########
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { Component } from '@angular/core';
+import NfRegistryApi from 'services/nf-registry.api';
+import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material';
+import { FdsSnackBarService } from '@nifi-fds/core';
+
+/**
+ * NfRegistryDownloadVersionedFlow constructor.
+ *
+ * @param nfRegistryApi The api service.
+ * @param fdsSnackBarService The FDS snack bar service module.
+ * @param matDialogRef The angular material dialog ref.
+ * @param data The data passed into this component.
+ * @constructor
+ */
+function NfRegistryDownloadVersionedFlow(nfRegistryApi, fdsSnackBarService,
matDialogRef, data) {
+ // Services
+ this.snackBarService = fdsSnackBarService;
+ this.nfRegistryApi = nfRegistryApi;
+ this.dialogRef = matDialogRef;
+ // local state
+ this.keepDialogOpen = false;
+ this.protocol = location.protocol;
+ this.droplet = data.droplet;
+ this.selectedVersion = this.droplet.snapshotMetadata[0].version;
+}
+
+NfRegistryDownloadVersionedFlow.prototype = {
+ constructor: NfRegistryDownloadVersionedFlow,
+
+ /**
+ * Download specified versioned flow snapshot.
+ */
+ downloadVersion: function () {
+ var self = this;
+ var version = this.selectedVersion;
+
+
this.nfRegistryApi.exportDropletVersionedSnapshot(this.droplet.link.href,
version).subscribe(function (response) {
+ if (!response.status || response.status === 200) {
Review comment:
Does a false for `response.status` also indicate a success? Not quite
following the logic.
##########
File path:
nifi-registry-core/nifi-registry-web-ui/src/main/webapp/components/explorer/grid-list/dialogs/import-new-flow/nf-registry-import-new-flow.js
##########
@@ -0,0 +1,182 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { Component } from '@angular/core';
+
+import NfRegistryApi from 'services/nf-registry.api';
+import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material';
+import { FdsSnackBarService } from '@nifi-fds/core';
+
+/**
+ * NfRegistryImportNewFlow constructor.
+ *
+ * @param nfRegistryApi The api service.
+ * @param fdsSnackBarService The FDS snack bar service module.
+ * @param matDialogRef The angular material dialog ref.
+ * @param data The data passed into this component.
+ * @constructor
+ */
+function NfRegistryImportNewFlow(nfRegistryApi, fdsSnackBarService,
matDialogRef, data) {
+ // Services
+ this.snackBarService = fdsSnackBarService;
+ this.nfRegistryApi = nfRegistryApi;
+ this.dialogRef = matDialogRef;
+ // local state
+ this.keepDialogOpen = false;
+ this.protocol = location.protocol;
+ this.buckets = data.buckets;
+ this.writableBuckets = [];
+ this.fileToUpload = null;
+ this.fileName = null;
+ this.name = '';
+ this.description = '';
+ this.selectedBucket = '';
+ this.hoverValidity = '';
+ this.extensions = 'application/json';
+ this.multiple = false;
+}
+
+NfRegistryImportNewFlow.prototype = {
+ constructor: NfRegistryImportNewFlow,
+
+ ngOnInit: function () {
+ // only show buckets the user can write
+ var self = this;
+ self.writableBuckets = self.filterWritableBuckets(self.buckets);
+ },
+
+ //TODO: get from the service instead
Review comment:
Is the goal to implement this filtering as part of the PR? It could be
useful as a convenience methods or optional parameter, but the client-side
filtering seems acceptable given that the buckets are visible to the user, just
available with different permissions.
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]