You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by mc...@apache.org on 2016/08/03 20:19:03 UTC
[2/7] nifi git commit: NIFI-2237: - Updating Rest Endpoint
documentation specifically regarding access policies. - Ensuring the resource
listing is accurate. - Removing unnecessary code.
http://git-wip-us.apache.org/repos/asf/nifi/blob/9338f102/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ProcessorResource.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ProcessorResource.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ProcessorResource.java
index bf104f5..fae20aa 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ProcessorResource.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ProcessorResource.java
@@ -66,8 +66,8 @@ import java.util.Set;
*/
@Path("/processors")
@Api(
- value = "/processors",
- description = "Endpoint for managing a Processor."
+ value = "/processors",
+ description = "Endpoint for managing a Processor."
)
public class ProcessorResource extends ApplicationResource {
private NiFiServiceFacade serviceFacade;
@@ -144,23 +144,20 @@ public class ProcessorResource extends ApplicationResource {
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("/{id}")
- // TODO - @PreAuthorize("hasAnyRole('ROLE_MONITOR', 'ROLE_DFM', 'ROLE_ADMIN')")
@ApiOperation(
value = "Gets a processor",
response = ProcessorEntity.class,
authorizations = {
- @Authorization(value = "Read Only", type = "ROLE_MONITOR"),
- @Authorization(value = "Data Flow Manager", type = "ROLE_DFM"),
- @Authorization(value = "Administrator", type = "ROLE_ADMIN")
+ @Authorization(value = "Read - /processors/{uuid}", type = "")
}
)
@ApiResponses(
value = {
- @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."),
- @ApiResponse(code = 401, message = "Client could not be authenticated."),
- @ApiResponse(code = 403, message = "Client is not authorized to make this request."),
- @ApiResponse(code = 404, message = "The specified resource could not be found."),
- @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.")
+ @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."),
+ @ApiResponse(code = 401, message = "Client could not be authenticated."),
+ @ApiResponse(code = 403, message = "Client is not authorized to make this request."),
+ @ApiResponse(code = 404, message = "The specified resource could not be found."),
+ @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.")
}
)
public Response getProcessor(
@@ -168,7 +165,7 @@ public class ProcessorResource extends ApplicationResource {
value = "The processor id.",
required = true
)
- @PathParam("id") final String id) throws InterruptedException {
+ @PathParam("id") final String id) throws InterruptedException {
if (isReplicateRequest()) {
return replicate(HttpMethod.GET);
@@ -191,7 +188,7 @@ public class ProcessorResource extends ApplicationResource {
/**
* Returns the descriptor for the specified property.
*
- * @param id The id of the processor
+ * @param id The id of the processor
* @param propertyName The property
* @return a propertyDescriptorEntity
* @throws InterruptedException if interrupted
@@ -200,23 +197,20 @@ public class ProcessorResource extends ApplicationResource {
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("/{id}/descriptors")
- // TODO - @PreAuthorize("hasAnyRole('ROLE_MONITOR', 'ROLE_DFM', 'ROLE_ADMIN')")
@ApiOperation(
value = "Gets the descriptor for a processor property",
response = PropertyDescriptorEntity.class,
authorizations = {
- @Authorization(value = "Read Only", type = "ROLE_MONITOR"),
- @Authorization(value = "Data Flow Manager", type = "ROLE_DFM"),
- @Authorization(value = "Administrator", type = "ROLE_ADMIN")
+ @Authorization(value = "Read - /processors/{uuid}", type = "")
}
)
@ApiResponses(
value = {
- @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."),
- @ApiResponse(code = 401, message = "Client could not be authenticated."),
- @ApiResponse(code = 403, message = "Client is not authorized to make this request."),
- @ApiResponse(code = 404, message = "The specified resource could not be found."),
- @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.")
+ @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."),
+ @ApiResponse(code = 401, message = "Client could not be authenticated."),
+ @ApiResponse(code = 403, message = "Client is not authorized to make this request."),
+ @ApiResponse(code = 404, message = "The specified resource could not be found."),
+ @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.")
}
)
public Response getPropertyDescriptor(
@@ -234,7 +228,7 @@ public class ProcessorResource extends ApplicationResource {
value = "The property name.",
required = true
)
- @QueryParam("propertyName") final String propertyName) throws InterruptedException {
+ @QueryParam("propertyName") final String propertyName) throws InterruptedException {
// ensure the property name is specified
if (propertyName == null) {
@@ -273,29 +267,28 @@ public class ProcessorResource extends ApplicationResource {
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("/{id}/state")
- // TODO - @PreAuthorize("hasAnyRole('ROLE_DFM')")
@ApiOperation(
- value = "Gets the state for a processor",
- response = ComponentStateDTO.class,
- authorizations = {
- @Authorization(value = "Data Flow Manager", type = "ROLE_DFM")
- }
+ value = "Gets the state for a processor",
+ response = ComponentStateDTO.class,
+ authorizations = {
+ @Authorization(value = "Write - /processors/{uuid}", type = "")
+ }
)
@ApiResponses(
- value = {
- @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."),
- @ApiResponse(code = 401, message = "Client could not be authenticated."),
- @ApiResponse(code = 403, message = "Client is not authorized to make this request."),
- @ApiResponse(code = 404, message = "The specified resource could not be found."),
- @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.")
- }
+ value = {
+ @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."),
+ @ApiResponse(code = 401, message = "Client could not be authenticated."),
+ @ApiResponse(code = 403, message = "Client is not authorized to make this request."),
+ @ApiResponse(code = 404, message = "The specified resource could not be found."),
+ @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.")
+ }
)
public Response getState(
- @ApiParam(
- value = "The processor id.",
- required = true
- )
- @PathParam("id") final String id) throws InterruptedException {
+ @ApiParam(
+ value = "The processor id.",
+ required = true
+ )
+ @PathParam("id") final String id) throws InterruptedException {
if (isReplicateRequest()) {
return replicate(HttpMethod.GET);
@@ -322,7 +315,7 @@ public class ProcessorResource extends ApplicationResource {
* Clears the state for a processor.
*
* @param httpServletRequest servlet request
- * @param id The id of the processor
+ * @param id The id of the processor
* @return a componentStateEntity
* @throws InterruptedException if interrupted
*/
@@ -330,30 +323,29 @@ public class ProcessorResource extends ApplicationResource {
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("{id}/state/clear-requests")
- // TODO - @PreAuthorize("hasAnyRole('ROLE_DFM')")
@ApiOperation(
- value = "Clears the state for a processor",
- response = ComponentStateDTO.class,
- authorizations = {
- @Authorization(value = "Data Flow Manager", type = "ROLE_DFM")
- }
+ value = "Clears the state for a processor",
+ response = ComponentStateDTO.class,
+ authorizations = {
+ @Authorization(value = "Write - /processors/{uuid}", type = "")
+ }
)
@ApiResponses(
- value = {
- @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."),
- @ApiResponse(code = 401, message = "Client could not be authenticated."),
- @ApiResponse(code = 403, message = "Client is not authorized to make this request."),
- @ApiResponse(code = 404, message = "The specified resource could not be found."),
- @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.")
- }
+ value = {
+ @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."),
+ @ApiResponse(code = 401, message = "Client could not be authenticated."),
+ @ApiResponse(code = 403, message = "Client is not authorized to make this request."),
+ @ApiResponse(code = 404, message = "The specified resource could not be found."),
+ @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.")
+ }
)
public Response clearState(
- @Context final HttpServletRequest httpServletRequest,
- @ApiParam(
- value = "The processor id.",
- required = true
- )
- @PathParam("id") final String id) throws InterruptedException {
+ @Context final HttpServletRequest httpServletRequest,
+ @ApiParam(
+ value = "The processor id.",
+ required = true
+ )
+ @PathParam("id") final String id) throws InterruptedException {
if (isReplicateRequest()) {
return replicate(HttpMethod.POST);
@@ -386,8 +378,8 @@ public class ProcessorResource extends ApplicationResource {
* Updates the specified processor with the specified values.
*
* @param httpServletRequest request
- * @param id The id of the processor to update.
- * @param processorEntity A processorEntity.
+ * @param id The id of the processor to update.
+ * @param processorEntity A processorEntity.
* @return A processorEntity.
* @throws InterruptedException if interrupted
*/
@@ -395,21 +387,20 @@ public class ProcessorResource extends ApplicationResource {
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Path("/{id}")
- // TODO - @PreAuthorize("hasRole('ROLE_DFM')")
@ApiOperation(
value = "Updates a processor",
response = ProcessorEntity.class,
authorizations = {
- @Authorization(value = "Data Flow Manager", type = "ROLE_DFM")
+ @Authorization(value = "Write - /processors/{uuid}", type = "")
}
)
@ApiResponses(
value = {
- @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."),
- @ApiResponse(code = 401, message = "Client could not be authenticated."),
- @ApiResponse(code = 403, message = "Client is not authorized to make this request."),
- @ApiResponse(code = 404, message = "The specified resource could not be found."),
- @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.")
+ @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."),
+ @ApiResponse(code = 401, message = "Client could not be authenticated."),
+ @ApiResponse(code = 403, message = "Client is not authorized to make this request."),
+ @ApiResponse(code = 404, message = "The specified resource could not be found."),
+ @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.")
}
)
public Response updateProcessor(
@@ -422,7 +413,7 @@ public class ProcessorResource extends ApplicationResource {
@ApiParam(
value = "The processor configuration details.",
required = true
- ) final ProcessorEntity processorEntity) throws InterruptedException {
+ ) final ProcessorEntity processorEntity) throws InterruptedException {
if (processorEntity == null || processorEntity.getComponent() == null) {
throw new IllegalArgumentException("Processor details must be specified.");
@@ -446,20 +437,20 @@ public class ProcessorResource extends ApplicationResource {
// handle expects request (usually from the cluster manager)
final Revision revision = getRevision(processorEntity, id);
return withWriteLock(
- serviceFacade,
- revision,
- lookup -> {
- Authorizable authorizable = lookup.getProcessor(id);
- authorizable.authorize(authorizer, RequestAction.WRITE, NiFiUserUtils.getNiFiUser());
- },
- () -> serviceFacade.verifyUpdateProcessor(requestProcessorDTO),
- () -> {
- // update the processor
- final ProcessorEntity entity = serviceFacade.updateProcessor(revision, requestProcessorDTO);
- populateRemainingProcessorEntityContent(entity);
-
- return clusterContext(generateOkResponse(entity)).build();
- }
+ serviceFacade,
+ revision,
+ lookup -> {
+ Authorizable authorizable = lookup.getProcessor(id);
+ authorizable.authorize(authorizer, RequestAction.WRITE, NiFiUserUtils.getNiFiUser());
+ },
+ () -> serviceFacade.verifyUpdateProcessor(requestProcessorDTO),
+ () -> {
+ // update the processor
+ final ProcessorEntity entity = serviceFacade.updateProcessor(revision, requestProcessorDTO);
+ populateRemainingProcessorEntityContent(entity);
+
+ return clusterContext(generateOkResponse(entity)).build();
+ }
);
}
@@ -467,9 +458,9 @@ public class ProcessorResource extends ApplicationResource {
* Removes the specified processor.
*
* @param httpServletRequest request
- * @param version The revision is used to verify the client is working with the latest version of the flow.
- * @param clientId Optional client id. If the client id is not specified, a new one will be generated. This value (whether specified or generated) is included in the response.
- * @param id The id of the processor to remove.
+ * @param version The revision is used to verify the client is working with the latest version of the flow.
+ * @param clientId Optional client id. If the client id is not specified, a new one will be generated. This value (whether specified or generated) is included in the response.
+ * @param id The id of the processor to remove.
* @return A processorEntity.
* @throws InterruptedException if interrupted
*/
@@ -477,21 +468,20 @@ public class ProcessorResource extends ApplicationResource {
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("/{id}")
- // TODO - @PreAuthorize("hasRole('ROLE_DFM')")
@ApiOperation(
value = "Deletes a processor",
response = ProcessorEntity.class,
authorizations = {
- @Authorization(value = "Data Flow Manager", type = "ROLE_DFM")
+ @Authorization(value = "Write - /processors/{uuid}", type = "")
}
)
@ApiResponses(
value = {
- @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."),
- @ApiResponse(code = 401, message = "Client could not be authenticated."),
- @ApiResponse(code = 403, message = "Client is not authorized to make this request."),
- @ApiResponse(code = 404, message = "The specified resource could not be found."),
- @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.")
+ @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."),
+ @ApiResponse(code = 401, message = "Client could not be authenticated."),
+ @ApiResponse(code = 403, message = "Client is not authorized to make this request."),
+ @ApiResponse(code = 404, message = "The specified resource could not be found."),
+ @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.")
}
)
public Response deleteProcessor(
@@ -510,7 +500,7 @@ public class ProcessorResource extends ApplicationResource {
value = "The processor id.",
required = true
)
- @PathParam("id") final String id) throws InterruptedException {
+ @PathParam("id") final String id) throws InterruptedException {
if (isReplicateRequest()) {
return replicate(HttpMethod.DELETE);
@@ -518,24 +508,25 @@ public class ProcessorResource extends ApplicationResource {
final Revision revision = new Revision(version == null ? null : version.getLong(), clientId.getClientId(), id);
return withWriteLock(
- serviceFacade,
- revision,
- lookup -> {
- final Authorizable processor = lookup.getProcessor(id);
- processor.authorize(authorizer, RequestAction.WRITE, NiFiUserUtils.getNiFiUser());
- },
- () -> serviceFacade.verifyDeleteProcessor(id),
- () -> {
- // delete the processor
- final ProcessorEntity entity = serviceFacade.deleteProcessor(revision, id);
-
- // generate the response
- return clusterContext(generateOkResponse(entity)).build();
- }
+ serviceFacade,
+ revision,
+ lookup -> {
+ final Authorizable processor = lookup.getProcessor(id);
+ processor.authorize(authorizer, RequestAction.WRITE, NiFiUserUtils.getNiFiUser());
+ },
+ () -> serviceFacade.verifyDeleteProcessor(id),
+ () -> {
+ // delete the processor
+ final ProcessorEntity entity = serviceFacade.deleteProcessor(revision, id);
+
+ // generate the response
+ return clusterContext(generateOkResponse(entity)).build();
+ }
);
}
// setters
+
public void setServiceFacade(NiFiServiceFacade serviceFacade) {
this.serviceFacade = serviceFacade;
}
http://git-wip-us.apache.org/repos/asf/nifi/blob/9338f102/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ProvenanceEventResource.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ProvenanceEventResource.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ProvenanceEventResource.java
index 239b612..6f424f4 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ProvenanceEventResource.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ProvenanceEventResource.java
@@ -27,9 +27,7 @@ import org.apache.nifi.controller.repository.claim.ContentDirection;
import org.apache.nifi.stream.io.StreamUtils;
import org.apache.nifi.web.DownloadableContent;
import org.apache.nifi.web.NiFiServiceFacade;
-import org.apache.nifi.web.api.dto.provenance.ProvenanceDTO;
import org.apache.nifi.web.api.dto.provenance.ProvenanceEventDTO;
-import org.apache.nifi.web.api.dto.provenance.lineage.LineageDTO;
import org.apache.nifi.web.api.entity.ProvenanceEventEntity;
import org.apache.nifi.web.api.entity.SubmitReplayRequestEntity;
import org.apache.nifi.web.api.request.LongParameter;
@@ -59,54 +57,37 @@ import java.net.URI;
*/
@Path("/provenance-events")
@Api(
- value = "/provenance-events",
- description = "Endpoint for accessing data flow provenance."
+ value = "/provenance-events",
+ description = "Endpoint for accessing data flow provenance."
)
public class ProvenanceEventResource extends ApplicationResource {
private NiFiServiceFacade serviceFacade;
/**
- * Populates the uri for the specified provenance.
- */
- private ProvenanceDTO populateRemainingProvenanceContent(ProvenanceDTO provenance) {
- provenance.setUri(generateResourceUri("provenance", provenance.getId()));
- return provenance;
- }
-
- /**
- * Populates the uri for the specified lineage.
- */
- private LineageDTO populateRemainingLineageContent(LineageDTO lineage) {
- lineage.setUri(generateResourceUri("provenance", "lineage", lineage.getId()));
- return lineage;
- }
-
- /**
* Gets the content for the input of the specified event.
*
* @param clusterNodeId The id of the node within the cluster this content is on. Required if clustered.
- * @param id The id of the provenance event associated with this content.
+ * @param id The id of the provenance event associated with this content.
* @return The content stream
*/
@GET
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.WILDCARD)
@Path("{id}/content/input")
- // TODO - @PreAuthorize("hasRole('ROLE_PROVENANCE')")
@ApiOperation(
value = "Gets the input content for a provenance event",
authorizations = {
- @Authorization(value = "Provenance", type = "ROLE_PROVENANCE")
+ @Authorization(value = "Read Component Data - /data/{component-type}/{uuid}", type = "")
}
)
@ApiResponses(
value = {
- @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."),
- @ApiResponse(code = 401, message = "Client could not be authenticated."),
- @ApiResponse(code = 403, message = "Client is not authorized to make this request."),
- @ApiResponse(code = 404, message = "The specified resource could not be found."),
- @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.")
+ @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."),
+ @ApiResponse(code = 401, message = "Client could not be authenticated."),
+ @ApiResponse(code = 403, message = "Client is not authorized to make this request."),
+ @ApiResponse(code = 404, message = "The specified resource could not be found."),
+ @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.")
}
)
public Response getInputContent(
@@ -169,27 +150,26 @@ public class ProvenanceEventResource extends ApplicationResource {
* Gets the content for the output of the specified event.
*
* @param clusterNodeId The id of the node within the cluster this content is on. Required if clustered.
- * @param id The id of the provenance event associated with this content.
+ * @param id The id of the provenance event associated with this content.
* @return The content stream
*/
@GET
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.WILDCARD)
@Path("{id}/content/output")
- // TODO - @PreAuthorize("hasRole('ROLE_PROVENANCE')")
@ApiOperation(
value = "Gets the output content for a provenance event",
authorizations = {
- @Authorization(value = "Provenance", type = "ROLE_PROVENANCE")
+ @Authorization(value = "Read Component Data - /data/{component-type}/{uuid}", type = "")
}
)
@ApiResponses(
value = {
- @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."),
- @ApiResponse(code = 401, message = "Client could not be authenticated."),
- @ApiResponse(code = 403, message = "Client is not authorized to make this request."),
- @ApiResponse(code = 404, message = "The specified resource could not be found."),
- @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.")
+ @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."),
+ @ApiResponse(code = 401, message = "Client could not be authenticated."),
+ @ApiResponse(code = 403, message = "Client is not authorized to make this request."),
+ @ApiResponse(code = 404, message = "The specified resource could not be found."),
+ @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.")
}
)
public Response getOutputContent(
@@ -251,7 +231,7 @@ public class ProvenanceEventResource extends ApplicationResource {
/**
* Gets the details for a provenance event.
*
- * @param id The id of the event
+ * @param id The id of the event
* @param clusterNodeId The id of node in the cluster that the event/flowfile originated from. This is only required when clustered.
* @return A provenanceEventEntity
*/
@@ -259,21 +239,20 @@ public class ProvenanceEventResource extends ApplicationResource {
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("{id}")
- // TODO - @PreAuthorize("hasRole('ROLE_PROVENANCE')")
@ApiOperation(
value = "Gets a provenance event",
response = ProvenanceEventEntity.class,
authorizations = {
- @Authorization(value = "Provenance", type = "ROLE_PROVENANCE")
+ @Authorization(value = "Read Component Data - /data/{component-type}/{uuid}", type = "")
}
)
@ApiResponses(
value = {
- @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."),
- @ApiResponse(code = 401, message = "Client could not be authenticated."),
- @ApiResponse(code = 403, message = "Client is not authorized to make this request."),
- @ApiResponse(code = 404, message = "The specified resource could not be found."),
- @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.")
+ @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."),
+ @ApiResponse(code = 401, message = "Client could not be authenticated."),
+ @ApiResponse(code = 403, message = "Client is not authorized to make this request."),
+ @ApiResponse(code = 404, message = "The specified resource could not be found."),
+ @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.")
}
)
public Response getProvenanceEvent(
@@ -283,7 +262,7 @@ public class ProvenanceEventResource extends ApplicationResource {
)
@QueryParam("clusterNodeId") final String clusterNodeId,
@ApiParam(
- value = "The provenence event id.",
+ value = "The provenance event id.",
required = true
)
@PathParam("id") final LongParameter id) {
@@ -318,7 +297,7 @@ public class ProvenanceEventResource extends ApplicationResource {
/**
* Creates a new replay request for the content associated with the specified provenance event id.
*
- * @param httpServletRequest request
+ * @param httpServletRequest request
* @param replayRequestEntity The replay request
* @return A provenanceEventEntity
*/
@@ -326,12 +305,12 @@ public class ProvenanceEventResource extends ApplicationResource {
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Path("replays")
- // TODO - @PreAuthorize("hasRole('ROLE_PROVENANCE') and hasRole('ROLE_DFM')")
@ApiOperation(
value = "Replays content from a provenance event",
response = ProvenanceEventEntity.class,
authorizations = {
- @Authorization(value = "Provenance and Data Flow Manager", type = "ROLE_PROVENANCE and ROLE_DFM")
+ @Authorization(value = "Read Component Data - /data/{component-type}/{uuid}", type = ""),
+ @Authorization(value = "Write Component Data - /data/{component-type}/{uuid}", type = "")
}
)
@ApiResponses(
http://git-wip-us.apache.org/repos/asf/nifi/blob/9338f102/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ProvenanceResource.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ProvenanceResource.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ProvenanceResource.java
index e618e8a..06f1d6f 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ProvenanceResource.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ProvenanceResource.java
@@ -66,8 +66,8 @@ import java.util.Map;
*/
@Path("/provenance")
@Api(
- value = "/provenance",
- description = "Endpoint for accessing data flow provenance."
+ value = "/provenance",
+ description = "Endpoint for accessing data flow provenance."
)
public class ProvenanceResource extends ApplicationResource {
@@ -93,7 +93,7 @@ public class ProvenanceResource extends ApplicationResource {
private void authorizeProvenanceRequest() {
final NiFiUser user = NiFiUserUtils.getNiFiUser();
- final Map<String,String> userContext;
+ final Map<String, String> userContext;
if (!StringUtils.isBlank(user.getClientAddress())) {
userContext = new HashMap<>();
userContext.put(UserContextKeys.CLIENT_ADDRESS.name(), user.getClientAddress());
@@ -102,13 +102,13 @@ public class ProvenanceResource extends ApplicationResource {
}
final AuthorizationRequest request = new AuthorizationRequest.Builder()
- .resource(ResourceFactory.getProvenanceResource())
- .identity(user.getIdentity())
- .anonymous(user.isAnonymous())
- .accessAttempt(true)
- .action(RequestAction.READ)
- .userContext(userContext)
- .build();
+ .resource(ResourceFactory.getProvenanceResource())
+ .identity(user.getIdentity())
+ .anonymous(user.isAnonymous())
+ .accessAttempt(true)
+ .action(RequestAction.READ)
+ .userContext(userContext)
+ .build();
final AuthorizationResult result = authorizer.authorize(request);
if (!Result.Approved.equals(result.getResult())) {
@@ -126,20 +126,19 @@ public class ProvenanceResource extends ApplicationResource {
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("search-options")
- // TODO - @PreAuthorize("hasRole('ROLE_PROVENANCE')")
@ApiOperation(
value = "Gets the searchable attributes for provenance events",
response = ProvenanceOptionsEntity.class,
authorizations = {
- @Authorization(value = "Provenance", type = "ROLE_PROVENANCE")
+ @Authorization(value = "Read - /provenance", type = "")
}
)
@ApiResponses(
value = {
- @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."),
- @ApiResponse(code = 401, message = "Client could not be authenticated."),
- @ApiResponse(code = 403, message = "Client is not authorized to make this request."),
- @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.")
+ @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."),
+ @ApiResponse(code = 401, message = "Client could not be authenticated."),
+ @ApiResponse(code = 403, message = "Client is not authorized to make this request."),
+ @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.")
}
)
public Response getSearchOptions() {
@@ -165,14 +164,13 @@ public class ProvenanceResource extends ApplicationResource {
* Creates provenance using the specified query criteria.
*
* @param httpServletRequest request
- * @param provenanceEntity A provenanceEntity
+ * @param provenanceEntity A provenanceEntity
* @return A provenanceEntity
*/
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Path("") // necessary due to bug in swagger
- // TODO - @PreAuthorize("hasRole('ROLE_PROVENANCE')")
@ApiOperation(
value = "Submits a provenance query",
notes = "Provenance queries may be long running so this endpoint submits a request. The response will include the "
@@ -181,15 +179,16 @@ public class ProvenanceResource extends ApplicationResource {
+ "should be deleted by the client who originally submitted it.",
response = ProvenanceEntity.class,
authorizations = {
- @Authorization(value = "Provenance", type = "ROLE_PROVENANCE")
+ @Authorization(value = "Read - /provenance", type = ""),
+ @Authorization(value = "Read - /data/{component-type}/{uuid}", type = "")
}
)
@ApiResponses(
value = {
- @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."),
- @ApiResponse(code = 401, message = "Client could not be authenticated."),
- @ApiResponse(code = 403, message = "Client is not authorized to make this request."),
- @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.")
+ @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."),
+ @ApiResponse(code = 401, message = "Client could not be authenticated."),
+ @ApiResponse(code = 403, message = "Client is not authorized to make this request."),
+ @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.")
}
)
public Response submitProvenanceRequest(
@@ -260,7 +259,7 @@ public class ProvenanceResource extends ApplicationResource {
/**
* Gets the provenance with the specified id.
*
- * @param id The id of the provenance
+ * @param id The id of the provenance
* @param clusterNodeId The id of node in the cluster to search. This is optional and only relevant when clustered. If clustered and it is not specified the entire cluster is searched.
* @return A provenanceEntity
*/
@@ -268,21 +267,21 @@ public class ProvenanceResource extends ApplicationResource {
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("{id}")
- // TODO - @PreAuthorize("hasRole('ROLE_PROVENANCE')")
@ApiOperation(
value = "Gets a provenance query",
response = ProvenanceEntity.class,
authorizations = {
- @Authorization(value = "Provenance", type = "ROLE_PROVENANCE")
+ @Authorization(value = "Read - /provenance", type = ""),
+ @Authorization(value = "Read - /data/{component-type}/{uuid}", type = "")
}
)
@ApiResponses(
value = {
- @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."),
- @ApiResponse(code = 401, message = "Client could not be authenticated."),
- @ApiResponse(code = 403, message = "Client is not authorized to make this request."),
- @ApiResponse(code = 404, message = "The specified resource could not be found."),
- @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.")
+ @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."),
+ @ApiResponse(code = 401, message = "Client could not be authenticated."),
+ @ApiResponse(code = 403, message = "Client is not authorized to make this request."),
+ @ApiResponse(code = 404, message = "The specified resource could not be found."),
+ @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.")
}
)
public Response getProvenance(
@@ -327,29 +326,28 @@ public class ProvenanceResource extends ApplicationResource {
* Deletes the provenance with the specified id.
*
* @param httpServletRequest request
- * @param id The id of the provenance
- * @param clusterNodeId The id of node in the cluster to search. This is optional and only relevant when clustered. If clustered and it is not specified the entire cluster is searched.
+ * @param id The id of the provenance
+ * @param clusterNodeId The id of node in the cluster to search. This is optional and only relevant when clustered. If clustered and it is not specified the entire cluster is searched.
* @return A provenanceEntity
*/
@DELETE
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("{id}")
- // TODO - @PreAuthorize("hasRole('ROLE_PROVENANCE')")
@ApiOperation(
value = "Deletes a provenance query",
response = ProvenanceEntity.class,
authorizations = {
- @Authorization(value = "Provenance", type = "ROLE_PROVENANCE")
+ @Authorization(value = "Read - /provenance", type = "")
}
)
@ApiResponses(
value = {
- @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."),
- @ApiResponse(code = 401, message = "Client could not be authenticated."),
- @ApiResponse(code = 403, message = "Client is not authorized to make this request."),
- @ApiResponse(code = 404, message = "The specified resource could not be found."),
- @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.")
+ @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."),
+ @ApiResponse(code = 401, message = "Client could not be authenticated."),
+ @ApiResponse(code = 403, message = "Client is not authorized to make this request."),
+ @ApiResponse(code = 404, message = "The specified resource could not be found."),
+ @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.")
}
)
public Response deleteProvenance(
@@ -396,21 +394,20 @@ public class ProvenanceResource extends ApplicationResource {
/**
* Submits a lineage request based on an event or a flowfile uuid.
- *
+ * <p>
* When querying for the lineage of an event you must specify the eventId and the eventDirection. The eventDirection must be 'parents' or 'children' and specifies whether we are going up or down
* the flowfile ancestry. The uuid cannot be specified in these cases.
- *
+ * <p>
* When querying for the lineage of a flowfile you must specify the uuid. The eventId and eventDirection cannot be specified in this case.
*
* @param httpServletRequest request
- * @param lineageEntity A lineageEntity
+ * @param lineageEntity A lineageEntity
* @return A lineageEntity
*/
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Path("lineage")
- // TODO - @PreAuthorize("hasRole('ROLE_PROVENANCE')")
@ApiOperation(
value = "Submits a lineage query",
notes = "Lineage queries may be long running so this endpoint submits a request. The response will include the "
@@ -419,16 +416,17 @@ public class ProvenanceResource extends ApplicationResource {
+ "should be deleted by the client who originally submitted it.",
response = LineageEntity.class,
authorizations = {
- @Authorization(value = "Provenance", type = "ROLE_PROVENANCE")
+ @Authorization(value = "Read - /provenance", type = ""),
+ @Authorization(value = "Read - /data/{component-type}/{uuid}", type = "")
}
)
@ApiResponses(
value = {
- @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."),
- @ApiResponse(code = 401, message = "Client could not be authenticated."),
- @ApiResponse(code = 403, message = "Client is not authorized to make this request."),
- @ApiResponse(code = 404, message = "The specified resource could not be found."),
- @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.")
+ @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."),
+ @ApiResponse(code = 401, message = "Client could not be authenticated."),
+ @ApiResponse(code = 403, message = "Client is not authorized to make this request."),
+ @ApiResponse(code = 404, message = "The specified resource could not be found."),
+ @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.")
}
)
public Response submitLineageRequest(
@@ -505,28 +503,28 @@ public class ProvenanceResource extends ApplicationResource {
* Gets the lineage with the specified id.
*
* @param clusterNodeId The id of node in the cluster that the event/flowfile originated from. This is only required when clustered.
- * @param id The id of the lineage
+ * @param id The id of the lineage
* @return A lineageEntity
*/
@GET
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("lineage/{id}")
- // TODO - @PreAuthorize("hasRole('ROLE_PROVENANCE')")
@ApiOperation(
value = "Gets a lineage query",
response = LineageEntity.class,
authorizations = {
- @Authorization(value = "Provenance", type = "ROLE_PROVENANCE")
+ @Authorization(value = "Read - /provenance", type = ""),
+ @Authorization(value = "Read - /data/{component-type}/{uuid}", type = "")
}
)
@ApiResponses(
value = {
- @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."),
- @ApiResponse(code = 401, message = "Client could not be authenticated."),
- @ApiResponse(code = 403, message = "Client is not authorized to make this request."),
- @ApiResponse(code = 404, message = "The specified resource could not be found."),
- @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.")
+ @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."),
+ @ApiResponse(code = 401, message = "Client could not be authenticated."),
+ @ApiResponse(code = 403, message = "Client is not authorized to make this request."),
+ @ApiResponse(code = 404, message = "The specified resource could not be found."),
+ @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.")
}
)
public Response getLineage(
@@ -565,29 +563,28 @@ public class ProvenanceResource extends ApplicationResource {
* Deletes the lineage with the specified id.
*
* @param httpServletRequest request
- * @param clusterNodeId The id of node in the cluster that the event/flowfile originated from. This is only required when clustered.
- * @param id The id of the lineage
+ * @param clusterNodeId The id of node in the cluster that the event/flowfile originated from. This is only required when clustered.
+ * @param id The id of the lineage
* @return A lineageEntity
*/
@DELETE
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("lineage/{id}")
- // TODO - @PreAuthorize("hasRole('ROLE_PROVENANCE')")
@ApiOperation(
value = "Deletes a lineage query",
response = LineageEntity.class,
authorizations = {
- @Authorization(value = "Provenance", type = "ROLE_PROVENANCE")
+ @Authorization(value = "Read - /provenance", type = "")
}
)
@ApiResponses(
value = {
- @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."),
- @ApiResponse(code = 401, message = "Client could not be authenticated."),
- @ApiResponse(code = 403, message = "Client is not authorized to make this request."),
- @ApiResponse(code = 404, message = "The specified resource could not be found."),
- @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.")
+ @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."),
+ @ApiResponse(code = 401, message = "Client could not be authenticated."),
+ @ApiResponse(code = 403, message = "Client is not authorized to make this request."),
+ @ApiResponse(code = 404, message = "The specified resource could not be found."),
+ @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.")
}
)
public Response deleteLineage(
@@ -627,6 +624,7 @@ public class ProvenanceResource extends ApplicationResource {
}
// setters
+
public void setServiceFacade(NiFiServiceFacade serviceFacade) {
this.serviceFacade = serviceFacade;
}
http://git-wip-us.apache.org/repos/asf/nifi/blob/9338f102/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/RemoteProcessGroupResource.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/RemoteProcessGroupResource.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/RemoteProcessGroupResource.java
index 15ae599..e99b2e3 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/RemoteProcessGroupResource.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/RemoteProcessGroupResource.java
@@ -59,8 +59,8 @@ import java.util.Set;
*/
@Path("/remote-process-groups")
@Api(
- value = "/remote-process-groups",
- description = "Endpoint for managing a Remote Process Group."
+ value = "/remote-process-groups",
+ description = "Endpoint for managing a Remote Process Group."
)
public class RemoteProcessGroupResource extends ApplicationResource {
@@ -101,23 +101,20 @@ public class RemoteProcessGroupResource extends ApplicationResource {
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("{id}")
- // TODO - @PreAuthorize("hasAnyRole('ROLE_MONITOR', 'ROLE_DFM', 'ROLE_ADMIN')")
@ApiOperation(
value = "Gets a remote process group",
response = RemoteProcessGroupEntity.class,
authorizations = {
- @Authorization(value = "Read Only", type = "ROLE_MONITOR"),
- @Authorization(value = "Data Flow Manager", type = "ROLE_DFM"),
- @Authorization(value = "Administrator", type = "ROLE_ADMIN")
+ @Authorization(value = "Read - /remote-process-groups/{uuid}", type = "")
}
)
@ApiResponses(
value = {
- @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."),
- @ApiResponse(code = 401, message = "Client could not be authenticated."),
- @ApiResponse(code = 403, message = "Client is not authorized to make this request."),
- @ApiResponse(code = 404, message = "The specified resource could not be found."),
- @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.")
+ @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."),
+ @ApiResponse(code = 401, message = "Client could not be authenticated."),
+ @ApiResponse(code = 403, message = "Client is not authorized to make this request."),
+ @ApiResponse(code = 404, message = "The specified resource could not be found."),
+ @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.")
}
)
public Response getRemoteProcessGroup(
@@ -148,30 +145,29 @@ public class RemoteProcessGroupResource extends ApplicationResource {
* Removes the specified remote process group.
*
* @param httpServletRequest request
- * @param version The revision is used to verify the client is working with the latest version of the flow.
- * @param clientId Optional client id. If the client id is not specified, a new one will be generated. This value (whether specified or generated) is included in the response.
- * @param id The id of the remote process group to be removed.
+ * @param version The revision is used to verify the client is working with the latest version of the flow.
+ * @param clientId Optional client id. If the client id is not specified, a new one will be generated. This value (whether specified or generated) is included in the response.
+ * @param id The id of the remote process group to be removed.
* @return A remoteProcessGroupEntity.
*/
@DELETE
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("{id}")
- // TODO - @PreAuthorize("hasRole('ROLE_DFM')")
@ApiOperation(
value = "Deletes a remote process group",
response = RemoteProcessGroupEntity.class,
authorizations = {
- @Authorization(value = "Data Flow Manager", type = "ROLE_DFM")
+ @Authorization(value = "Write - /remote-process-groups/{uuid}", type = "")
}
)
@ApiResponses(
value = {
- @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."),
- @ApiResponse(code = 401, message = "Client could not be authenticated."),
- @ApiResponse(code = 403, message = "Client is not authorized to make this request."),
- @ApiResponse(code = 404, message = "The specified resource could not be found."),
- @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.")
+ @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."),
+ @ApiResponse(code = 401, message = "Client could not be authenticated."),
+ @ApiResponse(code = 403, message = "Client is not authorized to make this request."),
+ @ApiResponse(code = 404, message = "The specified resource could not be found."),
+ @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.")
}
)
public Response removeRemoteProcessGroup(
@@ -199,49 +195,48 @@ public class RemoteProcessGroupResource extends ApplicationResource {
// handle expects request (usually from the cluster manager)
final Revision revision = new Revision(version == null ? null : version.getLong(), clientId.getClientId(), id);
return withWriteLock(
- serviceFacade,
- revision,
- lookup -> {
- final Authorizable remoteProcessGroup = lookup.getRemoteProcessGroup(id);
- remoteProcessGroup.authorize(authorizer, RequestAction.WRITE, NiFiUserUtils.getNiFiUser());
- },
- () -> serviceFacade.verifyDeleteRemoteProcessGroup(id),
- () -> {
- final RemoteProcessGroupEntity entity = serviceFacade.deleteRemoteProcessGroup(revision, id);
- return clusterContext(generateOkResponse(entity)).build();
- }
+ serviceFacade,
+ revision,
+ lookup -> {
+ final Authorizable remoteProcessGroup = lookup.getRemoteProcessGroup(id);
+ remoteProcessGroup.authorize(authorizer, RequestAction.WRITE, NiFiUserUtils.getNiFiUser());
+ },
+ () -> serviceFacade.verifyDeleteRemoteProcessGroup(id),
+ () -> {
+ final RemoteProcessGroupEntity entity = serviceFacade.deleteRemoteProcessGroup(revision, id);
+ return clusterContext(generateOkResponse(entity)).build();
+ }
);
}
/**
* Updates the specified remote process group input port.
*
- * @param httpServletRequest request
- * @param id The id of the remote process group to update.
- * @param portId The id of the input port to update.
+ * @param httpServletRequest request
+ * @param id The id of the remote process group to update.
+ * @param portId The id of the input port to update.
* @param remoteProcessGroupPortEntity The remoteProcessGroupPortEntity
- *
* @return A remoteProcessGroupPortEntity
*/
@PUT
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Path("{id}/input-ports/{port-id}")
- // TODO - @PreAuthorize("hasRole('ROLE_DFM')")
@ApiOperation(
value = "Updates a remote port",
+ notes = NON_GUARANTEED_ENDPOINT,
response = RemoteProcessGroupPortEntity.class,
authorizations = {
- @Authorization(value = "Data Flow Manager", type = "ROLE_DFM")
+ @Authorization(value = "Write - /remote-process-groups/{uuid}", type = "")
}
)
@ApiResponses(
value = {
- @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."),
- @ApiResponse(code = 401, message = "Client could not be authenticated."),
- @ApiResponse(code = 403, message = "Client is not authorized to make this request."),
- @ApiResponse(code = 404, message = "The specified resource could not be found."),
- @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.")
+ @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."),
+ @ApiResponse(code = 401, message = "Client could not be authenticated."),
+ @ApiResponse(code = 403, message = "Client is not authorized to make this request."),
+ @ApiResponse(code = 404, message = "The specified resource could not be found."),
+ @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.")
}
)
public Response updateRemoteProcessGroupInputPort(
@@ -277,59 +272,58 @@ public class RemoteProcessGroupResource extends ApplicationResource {
final Revision revision = getRevision(remoteProcessGroupPortEntity, id);
return withWriteLock(
- serviceFacade,
- revision,
- lookup -> {
- final Authorizable remoteProcessGroupInputPort = lookup.getRemoteProcessGroupInputPort(id, portId);
- remoteProcessGroupInputPort.authorize(authorizer, RequestAction.WRITE, NiFiUserUtils.getNiFiUser());
- },
- () -> serviceFacade.verifyUpdateRemoteProcessGroupInputPort(id, requestRemoteProcessGroupPort),
- () -> {
- // update the specified remote process group
- final RemoteProcessGroupPortEntity controllerResponse = serviceFacade.updateRemoteProcessGroupInputPort(revision, id, requestRemoteProcessGroupPort);
-
- // get the updated revision
- final RevisionDTO updatedRevision = controllerResponse.getRevision();
-
- // build the response entity
- final RemoteProcessGroupPortEntity entity = new RemoteProcessGroupPortEntity();
- entity.setRevision(updatedRevision);
- entity.setRemoteProcessGroupPort(controllerResponse.getRemoteProcessGroupPort());
-
- return clusterContext(generateOkResponse(entity)).build();
- }
+ serviceFacade,
+ revision,
+ lookup -> {
+ final Authorizable remoteProcessGroupInputPort = lookup.getRemoteProcessGroupInputPort(id, portId);
+ remoteProcessGroupInputPort.authorize(authorizer, RequestAction.WRITE, NiFiUserUtils.getNiFiUser());
+ },
+ () -> serviceFacade.verifyUpdateRemoteProcessGroupInputPort(id, requestRemoteProcessGroupPort),
+ () -> {
+ // update the specified remote process group
+ final RemoteProcessGroupPortEntity controllerResponse = serviceFacade.updateRemoteProcessGroupInputPort(revision, id, requestRemoteProcessGroupPort);
+
+ // get the updated revision
+ final RevisionDTO updatedRevision = controllerResponse.getRevision();
+
+ // build the response entity
+ final RemoteProcessGroupPortEntity entity = new RemoteProcessGroupPortEntity();
+ entity.setRevision(updatedRevision);
+ entity.setRemoteProcessGroupPort(controllerResponse.getRemoteProcessGroupPort());
+
+ return clusterContext(generateOkResponse(entity)).build();
+ }
);
}
/**
* Updates the specified remote process group output port.
*
- * @param httpServletRequest request
- * @param id The id of the remote process group to update.
- * @param portId The id of the output port to update.
+ * @param httpServletRequest request
+ * @param id The id of the remote process group to update.
+ * @param portId The id of the output port to update.
* @param remoteProcessGroupPortEntity The remoteProcessGroupPortEntity
- *
* @return A remoteProcessGroupPortEntity
*/
@PUT
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Path("{id}/output-ports/{port-id}")
- // TODO - @PreAuthorize("hasRole('ROLE_DFM')")
@ApiOperation(
value = "Updates a remote port",
+ notes = NON_GUARANTEED_ENDPOINT,
response = RemoteProcessGroupPortEntity.class,
authorizations = {
- @Authorization(value = "Data Flow Manager", type = "ROLE_DFM")
+ @Authorization(value = "Write - /remote-process-groups/{uuid}", type = "")
}
)
@ApiResponses(
value = {
- @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."),
- @ApiResponse(code = 401, message = "Client could not be authenticated."),
- @ApiResponse(code = 403, message = "Client is not authorized to make this request."),
- @ApiResponse(code = 404, message = "The specified resource could not be found."),
- @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.")
+ @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."),
+ @ApiResponse(code = 401, message = "Client could not be authenticated."),
+ @ApiResponse(code = 403, message = "Client is not authorized to make this request."),
+ @ApiResponse(code = 404, message = "The specified resource could not be found."),
+ @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.")
}
)
public Response updateRemoteProcessGroupOutputPort(
@@ -366,35 +360,35 @@ public class RemoteProcessGroupResource extends ApplicationResource {
// handle expects request (usually from the cluster manager)
final Revision revision = getRevision(remoteProcessGroupPortEntity, id);
return withWriteLock(
- serviceFacade,
- revision,
- lookup -> {
- final Authorizable remoteProcessGroupOutputPort = lookup.getRemoteProcessGroupOutputPort(id, portId);
- remoteProcessGroupOutputPort.authorize(authorizer, RequestAction.WRITE, NiFiUserUtils.getNiFiUser());
- },
- () -> serviceFacade.verifyUpdateRemoteProcessGroupOutputPort(id, requestRemoteProcessGroupPort),
- () -> {
- // update the specified remote process group
- final RemoteProcessGroupPortEntity controllerResponse = serviceFacade.updateRemoteProcessGroupOutputPort(revision, id, requestRemoteProcessGroupPort);
-
- // get the updated revision
- final RevisionDTO updatedRevision = controllerResponse.getRevision();
-
- // build the response entity
- RemoteProcessGroupPortEntity entity = new RemoteProcessGroupPortEntity();
- entity.setRevision(updatedRevision);
- entity.setRemoteProcessGroupPort(controllerResponse.getRemoteProcessGroupPort());
-
- return clusterContext(generateOkResponse(entity)).build();
- }
+ serviceFacade,
+ revision,
+ lookup -> {
+ final Authorizable remoteProcessGroupOutputPort = lookup.getRemoteProcessGroupOutputPort(id, portId);
+ remoteProcessGroupOutputPort.authorize(authorizer, RequestAction.WRITE, NiFiUserUtils.getNiFiUser());
+ },
+ () -> serviceFacade.verifyUpdateRemoteProcessGroupOutputPort(id, requestRemoteProcessGroupPort),
+ () -> {
+ // update the specified remote process group
+ final RemoteProcessGroupPortEntity controllerResponse = serviceFacade.updateRemoteProcessGroupOutputPort(revision, id, requestRemoteProcessGroupPort);
+
+ // get the updated revision
+ final RevisionDTO updatedRevision = controllerResponse.getRevision();
+
+ // build the response entity
+ RemoteProcessGroupPortEntity entity = new RemoteProcessGroupPortEntity();
+ entity.setRevision(updatedRevision);
+ entity.setRemoteProcessGroupPort(controllerResponse.getRemoteProcessGroupPort());
+
+ return clusterContext(generateOkResponse(entity)).build();
+ }
);
}
/**
* Updates the specified remote process group.
*
- * @param httpServletRequest request
- * @param id The id of the remote process group to update.
+ * @param httpServletRequest request
+ * @param id The id of the remote process group to update.
* @param remoteProcessGroupEntity A remoteProcessGroupEntity.
* @return A remoteProcessGroupEntity.
*/
@@ -402,21 +396,20 @@ public class RemoteProcessGroupResource extends ApplicationResource {
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Path("{id}")
- // TODO - @PreAuthorize("hasRole('ROLE_DFM')")
@ApiOperation(
value = "Updates a remote process group",
response = RemoteProcessGroupEntity.class,
authorizations = {
- @Authorization(value = "Data Flow Manager", type = "ROLE_DFM")
+ @Authorization(value = "Write - /remote-process-groups/{uuid}", type = "")
}
)
@ApiResponses(
value = {
- @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."),
- @ApiResponse(code = 401, message = "Client could not be authenticated."),
- @ApiResponse(code = 403, message = "Client is not authorized to make this request."),
- @ApiResponse(code = 404, message = "The specified resource could not be found."),
- @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.")
+ @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."),
+ @ApiResponse(code = 401, message = "Client could not be authenticated."),
+ @ApiResponse(code = 403, message = "Client is not authorized to make this request."),
+ @ApiResponse(code = 404, message = "The specified resource could not be found."),
+ @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.")
}
)
public Response updateRemoteProcessGroup(
@@ -446,56 +439,57 @@ public class RemoteProcessGroupResource extends ApplicationResource {
// handle expects request (usually from the cluster manager)
final Revision revision = getRevision(remoteProcessGroupEntity, id);
return withWriteLock(
- serviceFacade,
- revision,
- lookup -> {
- Authorizable authorizable = lookup.getRemoteProcessGroup(id);
- authorizable.authorize(authorizer, RequestAction.WRITE, NiFiUserUtils.getNiFiUser());
- },
- () -> serviceFacade.verifyUpdateRemoteProcessGroup(requestRemoteProcessGroup),
- () -> {
- // if the target uri is set we have to verify it here - we don't support updating the target uri on
- // an existing remote process group, however if the remote process group is being created with an id
- // as is the case in clustered mode we need to verify the remote process group. treat this request as
- // though its a new remote process group.
- if (requestRemoteProcessGroup.getTargetUri() != null) {
- // parse the uri
- final URI uri;
- try {
- uri = URI.create(requestRemoteProcessGroup.getTargetUri());
- } catch (final IllegalArgumentException e) {
- throw new IllegalArgumentException("The specified remote process group URL is malformed: " + requestRemoteProcessGroup.getTargetUri());
- }
-
- // validate each part of the uri
- if (uri.getScheme() == null || uri.getHost() == null) {
- throw new IllegalArgumentException("The specified remote process group URL is malformed: " + requestRemoteProcessGroup.getTargetUri());
- }
-
- if (!(uri.getScheme().equalsIgnoreCase("http") || uri.getScheme().equalsIgnoreCase("https"))) {
- throw new IllegalArgumentException("The specified remote process group URL is invalid because it is not http or https: " + requestRemoteProcessGroup.getTargetUri());
+ serviceFacade,
+ revision,
+ lookup -> {
+ Authorizable authorizable = lookup.getRemoteProcessGroup(id);
+ authorizable.authorize(authorizer, RequestAction.WRITE, NiFiUserUtils.getNiFiUser());
+ },
+ () -> serviceFacade.verifyUpdateRemoteProcessGroup(requestRemoteProcessGroup),
+ () -> {
+ // if the target uri is set we have to verify it here - we don't support updating the target uri on
+ // an existing remote process group, however if the remote process group is being created with an id
+ // as is the case in clustered mode we need to verify the remote process group. treat this request as
+ // though its a new remote process group.
+ if (requestRemoteProcessGroup.getTargetUri() != null) {
+ // parse the uri
+ final URI uri;
+ try {
+ uri = URI.create(requestRemoteProcessGroup.getTargetUri());
+ } catch (final IllegalArgumentException e) {
+ throw new IllegalArgumentException("The specified remote process group URL is malformed: " + requestRemoteProcessGroup.getTargetUri());
+ }
+
+ // validate each part of the uri
+ if (uri.getScheme() == null || uri.getHost() == null) {
+ throw new IllegalArgumentException("The specified remote process group URL is malformed: " + requestRemoteProcessGroup.getTargetUri());
+ }
+
+ if (!(uri.getScheme().equalsIgnoreCase("http") || uri.getScheme().equalsIgnoreCase("https"))) {
+ throw new IllegalArgumentException("The specified remote process group URL is invalid because it is not http or https: " + requestRemoteProcessGroup.getTargetUri());
+ }
+
+ // normalize the uri to the other controller
+ String controllerUri = uri.toString();
+ if (controllerUri.endsWith("/")) {
+ controllerUri = StringUtils.substringBeforeLast(controllerUri, "/");
+ }
+
+ // update with the normalized uri
+ requestRemoteProcessGroup.setTargetUri(controllerUri);
}
- // normalize the uri to the other controller
- String controllerUri = uri.toString();
- if (controllerUri.endsWith("/")) {
- controllerUri = StringUtils.substringBeforeLast(controllerUri, "/");
- }
+ // update the specified remote process group
+ final RemoteProcessGroupEntity entity = serviceFacade.updateRemoteProcessGroup(revision, requestRemoteProcessGroup);
+ populateRemainingRemoteProcessGroupEntityContent(entity);
- // update with the normalized uri
- requestRemoteProcessGroup.setTargetUri(controllerUri);
+ return clusterContext(generateOkResponse(entity)).build();
}
-
- // update the specified remote process group
- final RemoteProcessGroupEntity entity = serviceFacade.updateRemoteProcessGroup(revision, requestRemoteProcessGroup);
- populateRemainingRemoteProcessGroupEntityContent(entity);
-
- return clusterContext(generateOkResponse(entity)).build();
- }
);
}
// setters
+
public void setServiceFacade(NiFiServiceFacade serviceFacade) {
this.serviceFacade = serviceFacade;
}