[ 
https://issues.apache.org/jira/browse/NIFI-4224?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16118894#comment-16118894
 ] 

ASF GitHub Bot commented on NIFI-4224:
--------------------------------------

Github user mcgilman commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/2051#discussion_r131995022
  
    --- Diff: 
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/FlowResource.java
 ---
    @@ -640,7 +643,128 @@ public Response scheduleComponents(
                                 
componentsToSchedule.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey,
 e -> getRevision(e.getValue(), e.getKey())));
     
                         // update the process group
    -                    final ScheduleComponentsEntity entity = 
serviceFacade.scheduleComponents(id, scheduledState, componentRevisions);
    +                final ScheduleComponentsEntity entity = 
serviceFacade.scheduleComponents(id, scheduledState, componentRevisions);
    +                    return generateOkResponse(entity).build();
    +                }
    +        );
    +    }
    +
    +
    +    @PUT
    +    @Consumes(MediaType.APPLICATION_JSON)
    +    @Produces(MediaType.APPLICATION_JSON)
    +    @Path("process-groups/{id}/controller-services")
    +    @ApiOperation(value = "Enable or disable Controller Services in the 
specified Process Group.",
    +        response = ActivateControllerServicesEntity.class,
    +        authorizations = {
    +            @Authorization(value = "Read - /flow", type = ""),
    +            @Authorization(value = "Write - /{component-type}/{uuid} - For 
every service being enabled/disabled", 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.")
    +            }
    +    )
    +    public Response activateControllerServices(
    +            @Context HttpServletRequest httpServletRequest,
    +            @ApiParam(value = "The process group id.", required = true)
    +            @PathParam("id") String id,
    +            @ApiParam(value = "The request to schedule or unschedule. If 
the comopnents in the request are not specified, all authorized components will 
be considered.", required = true)
    +            final ActivateControllerServicesEntity requestEntity) {
    +
    +        // ensure the same id is being used
    +        if (!id.equals(requestEntity.getId())) {
    +            throw new IllegalArgumentException(String.format("The process 
group id (%s) in the request body does "
    +                + "not equal the process group id of the requested 
resource (%s).", requestEntity.getId(), id));
    +        }
    +
    +        final ControllerServiceState state;
    +        if (requestEntity.getState() == null) {
    +            throw new IllegalArgumentException("The scheduled state must 
be specified.");
    +        } else {
    +            try {
    +                state = 
ControllerServiceState.valueOf(requestEntity.getState());
    +            } catch (final IllegalArgumentException iae) {
    +                throw new IllegalArgumentException(String.format("The 
scheduled must be one of [%s].",
    +                    
StringUtils.join(EnumSet.of(ControllerServiceState.ENABLED, 
ControllerServiceState.DISABLED), ", ")));
    +            }
    +        }
    +
    +        // ensure its a supported scheduled state
    +        if (ControllerServiceState.DISABLING.equals(state) || 
ControllerServiceState.ENABLING.equals(state)) {
    +            throw new IllegalArgumentException(String.format("The 
scheduled must be one of [%s].",
    +                
StringUtils.join(EnumSet.of(ControllerServiceState.ENABLED, 
ControllerServiceState.DISABLED), ", ")));
    +        }
    +
    +        // if the components are not specified, gather all components and 
their current revision
    +        if (requestEntity.getComponents() == null) {
    +            // get the current revisions for the components being updated
    +            final Set<Revision> revisions = 
serviceFacade.getRevisionsFromGroup(id, group -> {
    +                final Set<String> componentIds = new HashSet<>();
    +
    +                final Predicate<ControllerServiceNode> filter;
    +                if (ControllerServiceState.ENABLED.equals(state)) {
    +                    filter = service -> !service.isActive() && 
service.isValid();
    +                } else {
    +                    filter = service -> service.isActive();
    +                }
    +
    +                group.findAllControllerServices().stream()
    +                    .filter(filter)
    --- End diff --
    
    This filter should be finding all Controller Services that are going to be 
enabled/disabled. Part of this check should be whether this current user is 
allowed to perform this action.


> Add Variable Registry at Process Group level
> --------------------------------------------
>
>                 Key: NIFI-4224
>                 URL: https://issues.apache.org/jira/browse/NIFI-4224
>             Project: Apache NiFi
>          Issue Type: New Feature
>          Components: Core Framework
>            Reporter: Mark Payne
>            Assignee: Mark Payne
>
> Currently, NiFi exposes a variable registry that is configurable by adding 
> the name of a properties file to nifi.properties and then treating the 
> referenced properties file as key/value pairs for the variable registry. 
> This, however, is very limiting, as it provides a global scope for all 
> variables, and it requires a restart of NiFi in order to pick up any updates 
> to the file. We should expose a Process Group-level Variable Registry.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to