Freedom9339 commented on code in PR #7734: URL: https://github.com/apache/nifi/pull/7734#discussion_r1513383264
########## nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ControllerServiceResource.java: ########## @@ -680,6 +681,116 @@ public Response updateControllerService( ); } + /** + * Moves the specified Controller Service to parent/child process groups. + * + * @param id The id of the controller service to update. + * @param requestControllerServiceEntity A controllerServiceEntity. + * @return A controllerServiceEntity. + */ + @PUT + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @Path("{id}/move") + @Operation( + summary = "Move Controller Service to the specified Process Group.", + responses = @ApiResponse(content = @Content(schema = @Schema(implementation = ControllerServiceEntity.class))), + security = { + @SecurityRequirement(name = "Write - /controller-services/{uuid}"), + @SecurityRequirement(name = "Write - Parent Process Group if scoped by Process Group - /process-groups/{uuid}"), + @SecurityRequirement(name = "Write - Controller if scoped by Controller - /controller"), + @SecurityRequirement(name = "Read - any referenced Controller Services - /controller-services/{uuid}") + }) + @ApiResponses( + value = { + @ApiResponse(responseCode = "400", description = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."), + @ApiResponse(responseCode = "401", description = "Client could not be authenticated."), + @ApiResponse(responseCode = "403", description = "Client is not authorized to make this request."), + @ApiResponse(responseCode = "404", description = "The specified resource could not be found."), + @ApiResponse(responseCode = "409", description = "The request was valid but NiFi was not in the appropriate state to process it.") + } + ) + public Response moveControllerServices( + @Parameter( + description = "The controller service id.", + required = true + ) + @PathParam("id") final String id, + @Parameter( + description = "The controller service entity", + required = true + ) + final ControllerServiceEntity requestControllerServiceEntity) { + + if (requestControllerServiceEntity == null) { + throw new IllegalArgumentException("Controller service must be specified."); + } + + if (requestControllerServiceEntity.getRevision() == null) { + throw new IllegalArgumentException("Revision must be specified."); + } + + if (requestControllerServiceEntity.getParentGroupId() == null) { + throw new IllegalArgumentException("ParentGroupId must be specified."); + } + + final ControllerServiceDTO requestControllerServiceDTO = serviceFacade.getControllerService(id, true).getComponent(); + ControllerServiceState requestControllerServiceState = null; + try { + requestControllerServiceState = ControllerServiceState.valueOf(requestControllerServiceDTO.getState()); + } catch (final IllegalArgumentException iae) { + // ignore + } + + // ensure an action has been specified + if (requestControllerServiceState == null) { + throw new IllegalArgumentException("Must specify the updated state. To update the referencing Controller Services the " + + "state should be DISABLED."); + } + + // ensure the controller service state is not DISABLING + if (!ControllerServiceState.DISABLED.equals(requestControllerServiceState) ) { + throw new IllegalArgumentException("Cannot set the referencing services to ENABLING or DISABLING"); + } Review Comment: Moving the controller service can now be done if it is enabled. removed this check. -- 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. To unsubscribe, e-mail: issues-unsubscr...@nifi.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org