http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/a53cc3d7/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java index 88637b4..df4cdf1 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java @@ -211,7 +211,6 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { // ----------------------------------------- // Verification Operations // ----------------------------------------- - @Override public void verifyCreateConnection(String groupId, ConnectionDTO connectionDTO) { connectionDAO.verifyCreate(groupId, connectionDTO); @@ -365,21 +364,20 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { // ----------------------------------------- // Write Operations // ----------------------------------------- - @Override public ConfigurationSnapshot<ConnectionDTO> updateConnection(final Revision revision, final String groupId, final ConnectionDTO connectionDTO) { // if connection does not exist, then create new connection if (connectionDAO.hasConnection(groupId, connectionDTO.getId()) == false) { return createConnection(revision, groupId, connectionDTO); } - + return optimisticLockingManager.configureFlow(revision, new ConfigurationRequest<ConnectionDTO>() { @Override public ConnectionDTO execute() { final Connection connection = connectionDAO.updateConnection(groupId, connectionDTO); controllerFacade.save(); - + return dtoFactory.createConnectionDto(connection); } }); @@ -391,7 +389,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { if (processorDAO.hasProcessor(groupId, processorDTO.getId()) == false) { return createProcessor(revision, groupId, processorDTO); } - + return optimisticLockingManager.configureFlow(revision, new ConfigurationRequest<ProcessorDTO>() { @Override public ProcessorDTO execute() { @@ -400,7 +398,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { // save the flow controllerFacade.save(); - + return dtoFactory.createProcessorDto(processor); } }); @@ -412,7 +410,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { if (labelDAO.hasLabel(groupId, labelDTO.getId()) == false) { return createLabel(revision, groupId, labelDTO); } - + return optimisticLockingManager.configureFlow(revision, new ConfigurationRequest<LabelDTO>() { @Override public LabelDTO execute() { @@ -421,7 +419,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { // save updated controller controllerFacade.save(); - + return dtoFactory.createLabelDto(label); } }); @@ -433,7 +431,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { if (funnelDAO.hasFunnel(groupId, funnelDTO.getId()) == false) { return createFunnel(revision, groupId, funnelDTO); } - + return optimisticLockingManager.configureFlow(revision, new ConfigurationRequest<FunnelDTO>() { @Override public FunnelDTO execute() { @@ -442,7 +440,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { // save updated controller controllerFacade.save(); - + return dtoFactory.createFunnelDto(funnel); } }); @@ -463,7 +461,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { if (snippetDAO.hasSnippet(snippetDto.getId()) == false) { return createSnippet(revision, snippetDto); } - + return optimisticLockingManager.configureFlow(revision, new ConfigurationRequest<SnippetDTO>() { @Override public SnippetDTO execute() { @@ -478,7 +476,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { if (snippetDto.getParentGroupId() != null && snippet.isLinked()) { controllerFacade.save(); } - + return responseSnippetDto; } }); @@ -490,7 +488,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { if (inputPortDAO.hasPort(groupId, inputPortDTO.getId()) == false) { return createInputPort(revision, groupId, inputPortDTO); } - + return optimisticLockingManager.configureFlow(revision, new ConfigurationRequest<PortDTO>() { @Override public PortDTO execute() { @@ -498,8 +496,8 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { // save updated controller controllerFacade.save(); - - return dtoFactory.createPortDto(inputPort); + + return dtoFactory.createPortDto(inputPort); } }); } @@ -510,7 +508,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { if (outputPortDAO.hasPort(groupId, outputPortDTO.getId()) == false) { return createOutputPort(revision, groupId, outputPortDTO); } - + return optimisticLockingManager.configureFlow(revision, new ConfigurationRequest<PortDTO>() { @Override public PortDTO execute() { @@ -518,7 +516,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { // save updated controller controllerFacade.save(); - + return dtoFactory.createPortDto(outputPort); } }); @@ -530,7 +528,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { if (remoteProcessGroupDAO.hasRemoteProcessGroup(groupId, remoteProcessGroupDTO.getId()) == false) { return createRemoteProcessGroup(revision, groupId, remoteProcessGroupDTO); } - + return optimisticLockingManager.configureFlow(revision, new ConfigurationRequest<RemoteProcessGroupDTO>() { @Override public RemoteProcessGroupDTO execute() { @@ -538,7 +536,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { // save updated controller controllerFacade.save(); - + return dtoFactory.createRemoteProcessGroupDto(remoteProcessGroup); } }); @@ -554,7 +552,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { // save updated controller controllerFacade.save(); - + return dtoFactory.createRemoteProcessGroupPortDto(remoteGroupPort); } }); @@ -570,7 +568,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { // save updated controller controllerFacade.save(); - + return dtoFactory.createRemoteProcessGroupPortDto(remoteGroupPort); } }); @@ -586,7 +584,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { return createProcessGroup(parentGroupId, revision, processGroupDTO); } } - + return optimisticLockingManager.configureFlow(revision, new ConfigurationRequest<ProcessGroupDTO>() { @Override public ProcessGroupDTO execute() { @@ -595,7 +593,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { // save updated controller controllerFacade.save(); - + return dtoFactory.createProcessGroupDto(processGroup); } }); @@ -625,7 +623,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { // save the flow controllerFacade.save(); - + return controllerConfig; } }); @@ -662,14 +660,14 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { @Override public ConfigurationSnapshot<Void> deleteConnection(final Revision revision, final String groupId, final String connectionId) { - return optimisticLockingManager.configureFlow(revision, new ConfigurationRequest<Void>(){ + return optimisticLockingManager.configureFlow(revision, new ConfigurationRequest<Void>() { @Override public Void execute() { connectionDAO.deleteConnection(groupId, connectionId); // save the flow controllerFacade.save(); - + return null; } }); @@ -685,7 +683,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { // save the flow controllerFacade.save(); - + return null; } }); @@ -701,7 +699,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { // save the flow controllerFacade.save(); - + return null; } }); @@ -717,7 +715,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { // save the flow controllerFacade.save(); - + return null; } }); @@ -744,7 +742,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { if (linked) { controllerFacade.save(); } - + return null; } }); @@ -759,7 +757,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { // save the flow controllerFacade.save(); - + return null; } }); @@ -774,7 +772,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { // save the flow controllerFacade.save(); - + return null; } }); @@ -789,7 +787,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { // save the flow controllerFacade.save(); - + return null; } }); @@ -804,7 +802,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { // save the flow controllerFacade.save(); - + return null; } }); @@ -830,7 +828,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { // save the flow controllerFacade.save(); - + return dtoFactory.createConnectionDto(connection); } }); @@ -851,7 +849,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { // save the flow controllerFacade.save(); - + return dtoFactory.createProcessorDto(processor); } }); @@ -872,7 +870,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { // save the flow controllerFacade.save(); - + return dtoFactory.createLabelDto(label); } }); @@ -893,7 +891,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { // save the flow controllerFacade.save(); - + return dtoFactory.createFunnelDto(funnel); } }); @@ -960,7 +958,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { @Override public FlowSnippetDTO execute() { String id = snippetId; - + // ensure id is set if (StringUtils.isBlank(id)) { id = UUID.randomUUID().toString(); @@ -974,7 +972,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { // save the flow controllerFacade.save(); - + return flowSnippet; } }); @@ -994,7 +992,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { final Snippet snippet = snippetDAO.createSnippet(snippetDTO); final SnippetDTO responseSnippetDTO = dtoFactory.createSnippetDto(snippet); responseSnippetDTO.setContents(snippetUtils.populateFlowSnippet(snippet, false)); - + return responseSnippetDTO; } }); @@ -1014,7 +1012,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { // save the flow controllerFacade.save(); - + return dtoFactory.createPortDto(inputPort); } }); @@ -1034,7 +1032,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { // save the flow controllerFacade.save(); - + return dtoFactory.createPortDto(outputPort); } }); @@ -1054,7 +1052,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { // save the flow controllerFacade.save(); - + return dtoFactory.createProcessGroupDto(processGroup); } }); @@ -1074,7 +1072,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { // save the flow controllerFacade.save(); - + return dtoFactory.createRemoteProcessGroupDto(remoteProcessGroup); } }); @@ -1136,7 +1134,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { // save the flow controllerFacade.save(); - + return flowSnippet; } }); @@ -1206,7 +1204,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { } else { controllerFacade.save(); } - + return dtoFactory.createControllerServiceDto(controllerService); } }); @@ -1218,7 +1216,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { if (controllerServiceDAO.hasControllerService(controllerServiceDTO.getId()) == false) { return createControllerService(revision, controllerServiceDTO); } - + return optimisticLockingManager.configureFlow(revision, new ConfigurationRequest<ControllerServiceDTO>() { @Override public ControllerServiceDTO execute() { @@ -1261,7 +1259,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { } else { controllerFacade.save(); } - + return null; } }); @@ -1286,7 +1284,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { } else { controllerFacade.save(); } - + return dtoFactory.createReportingTaskDto(reportingTask); } }); @@ -1298,7 +1296,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { if (reportingTaskDAO.hasReportingTask(reportingTaskDTO.getId()) == false) { return createReportingTask(revision, reportingTaskDTO); } - + return optimisticLockingManager.configureFlow(revision, new ConfigurationRequest<ReportingTaskDTO>() { @Override public ReportingTaskDTO execute() { @@ -1330,7 +1328,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { } else { controllerFacade.save(); } - + return null; } }); @@ -1488,7 +1486,6 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { // ----------------------------------------- // Read Operations // ----------------------------------------- - @Override public RevisionDTO getRevision() { return dtoFactory.createRevisionDTO(optimisticLockingManager.getLastModification()); @@ -1738,12 +1735,12 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { public PropertyDescriptorDTO getProcessorPropertyDescriptor(String groupId, String id, String property) { final ProcessorNode processor = processorDAO.getProcessor(groupId, id); PropertyDescriptor descriptor = processor.getPropertyDescriptor(property); - + // return an invalid descriptor if the processor doesn't suppor this property if (descriptor == null) { descriptor = new PropertyDescriptor.Builder().name(property).addValidator(Validator.INVALID).dynamic(true).build(); } - + return dtoFactory.createPropertyDescriptorDto(descriptor); } @@ -2057,15 +2054,15 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { public PropertyDescriptorDTO getControllerServicePropertyDescriptor(String id, String property) { final ControllerServiceNode controllerService = controllerServiceDAO.getControllerService(id); PropertyDescriptor descriptor = controllerService.getControllerServiceImplementation().getPropertyDescriptor(property); - + // return an invalid descriptor if the controller service doesn't support this property if (descriptor == null) { descriptor = new PropertyDescriptor.Builder().name(property).addValidator(Validator.INVALID).dynamic(true).build(); } - + return dtoFactory.createPropertyDescriptorDto(descriptor); } - + @Override public Set<ControllerServiceReferencingComponentDTO> getControllerServiceReferencingComponents(String controllerServiceId) { final ControllerServiceNode service = controllerServiceDAO.getControllerService(controllerServiceId); @@ -2090,15 +2087,15 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { public PropertyDescriptorDTO getReportingTaskPropertyDescriptor(String id, String property) { final ReportingTaskNode reportingTask = reportingTaskDAO.getReportingTask(id); PropertyDescriptor descriptor = reportingTask.getReportingTask().getPropertyDescriptor(property); - + // return an invalid descriptor if the reporting task doesn't support this property if (descriptor == null) { descriptor = new PropertyDescriptor.Builder().name(property).addValidator(Validator.INVALID).dynamic(true).build(); } - + return dtoFactory.createPropertyDescriptorDto(descriptor); } - + @Override public StatusHistoryDTO getProcessGroupStatusHistory(String groupId) { return controllerFacade.getProcessGroupStatusHistory(groupId);
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/a53cc3d7/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiWebConfigurationContext.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiWebConfigurationContext.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiWebConfigurationContext.java index 8d51a58..a1cfcd5 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiWebConfigurationContext.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiWebConfigurationContext.java @@ -68,8 +68,8 @@ import org.apache.nifi.web.api.entity.ReportingTaskEntity; import org.apache.nifi.web.util.ClientResponseUtils; /** - * Implements the NiFiWebConfigurationContext interface to support a context in both - * standalone and clustered environments. + * Implements the NiFiWebConfigurationContext interface to support a context in + * both standalone and clustered environments. */ public class StandardNiFiWebConfigurationContext implements NiFiWebConfigurationContext { @@ -99,7 +99,7 @@ public class StandardNiFiWebConfigurationContext implements NiFiWebConfiguration if (requestContext.getExtensionType() == null) { throw new IllegalArgumentException("The UI extension type must be specified."); } - + Component componentType = null; switch (requestContext.getExtensionType()) { case ProcessorConfiguration: @@ -116,7 +116,7 @@ public class StandardNiFiWebConfigurationContext implements NiFiWebConfiguration if (componentType == null) { throw new IllegalArgumentException("UI extension type must support Processor, ControllerService, or ReportingTask configuration."); } - + // - when running standalone or cluster ncm - actions from custom UIs are stored locally // - clustered nodes do not serve custom UIs directly to users so they should never be invoking this method final Date now = new Date(); @@ -192,25 +192,25 @@ public class StandardNiFiWebConfigurationContext implements NiFiWebConfiguration if (requestContext.getExtensionType() == null) { throw new IllegalArgumentException("The UI extension type must be specified."); } - + // get the component facade for interacting directly with that type of object ComponentFacade componentFacade = null; switch (requestContext.getExtensionType()) { case ProcessorConfiguration: componentFacade = new ProcessorFacade(); break; - case ControllerServiceConfiguration: + case ControllerServiceConfiguration: componentFacade = new ControllerServiceFacade(); break; case ReportingTaskConfiguration: componentFacade = new ReportingTaskFacade(); break; } - + if (componentFacade == null) { throw new IllegalArgumentException("UI extension type must support Processor, ControllerService, or ReportingTask configuration."); } - + return componentFacade.getComponentDetails(requestContext); } @@ -224,7 +224,7 @@ public class StandardNiFiWebConfigurationContext implements NiFiWebConfiguration if (StringUtils.isBlank(id)) { throw new ResourceNotFoundException(String.format("Configuration request context did not have a component ID.")); } - + // ensure the path could be if (requestContext.getExtensionType() == null) { throw new IllegalArgumentException("The UI extension type must be specified."); @@ -236,18 +236,18 @@ public class StandardNiFiWebConfigurationContext implements NiFiWebConfiguration case ProcessorConfiguration: componentFacade = new ProcessorFacade(); break; - case ControllerServiceConfiguration: + case ControllerServiceConfiguration: componentFacade = new ControllerServiceFacade(); break; case ReportingTaskConfiguration: componentFacade = new ReportingTaskFacade(); break; } - + if (componentFacade == null) { throw new IllegalArgumentException("UI extension type must support Processor, ControllerService, or ReportingTask configuration."); } - + return componentFacade.setAnnotationData(requestContext, annotationData); } @@ -255,32 +255,34 @@ public class StandardNiFiWebConfigurationContext implements NiFiWebConfiguration * Facade over accessing different types of NiFi components. */ private interface ComponentFacade { + /** * Gets the component details using the specified request context. - * + * * @param requestContext - * @return + * @return */ ComponentDetails getComponentDetails(NiFiWebRequestContext requestContext); - + /** * Sets the annotation data using the specified request context. - * + * * @param requestContext * @param annotationData - * @return + * @return */ ComponentDetails setAnnotationData(NiFiWebConfigurationRequestContext requestContext, String annotationData); } - + /** * Interprets the request/response with the underlying Processor model. */ private class ProcessorFacade implements ComponentFacade { + @Override public ComponentDetails getComponentDetails(final NiFiWebRequestContext requestContext) { final String id = requestContext.getId(); - + final ProcessorDTO processor; if (properties.isClusterManager()) { // create the request URL @@ -320,7 +322,7 @@ public class StandardNiFiWebConfigurationContext implements NiFiWebConfiguration public ComponentDetails setAnnotationData(final NiFiWebConfigurationRequestContext requestContext, final String annotationData) { final Revision revision = requestContext.getRevision(); final String id = requestContext.getId(); - + final ProcessorDTO processor; if (properties.isClusterManager()) { // create the request URL @@ -360,7 +362,7 @@ public class StandardNiFiWebConfigurationContext implements NiFiWebConfiguration // check for issues replicating request checkResponse(nodeResponse, id); - + // return processor ProcessorEntity entity = (ProcessorEntity) nodeResponse.getUpdatedEntity(); if (entity == null) { @@ -371,11 +373,11 @@ public class StandardNiFiWebConfigurationContext implements NiFiWebConfiguration final ConfigurationSnapshot<ProcessorDTO> response = serviceFacade.setProcessorAnnotationData(revision, id, annotationData); processor = response.getConfiguration(); } - + // return the processor info return getComponentConfiguration(processor); } - + private ComponentDetails getComponentConfiguration(final ProcessorDTO processor) { final ProcessorConfigDTO processorConfig = processor.getConfig(); return new ComponentDetails.Builder() @@ -388,16 +390,18 @@ public class StandardNiFiWebConfigurationContext implements NiFiWebConfiguration .validateErrors(processor.getValidationErrors()).build(); } } - + /** - * Interprets the request/response with the underlying ControllerService model. + * Interprets the request/response with the underlying ControllerService + * model. */ private class ControllerServiceFacade implements ComponentFacade { + @Override public ComponentDetails getComponentDetails(final NiFiWebRequestContext requestContext) { final String id = requestContext.getId(); final ControllerServiceDTO controllerService; - + // if the lookup has the service that means we are either a node or // the ncm and the service is available there only if (controllerServiceLookup.getControllerService(id) != null) { @@ -408,7 +412,7 @@ public class StandardNiFiWebConfigurationContext implements NiFiWebConfiguration if (!properties.isClusterManager()) { throw new ResourceNotFoundException(String.format("Controller service[%s] could not be found on this NiFi.", id)); } - + // create the request URL URI requestUrl; try { @@ -443,13 +447,13 @@ public class StandardNiFiWebConfigurationContext implements NiFiWebConfiguration public ComponentDetails setAnnotationData(final NiFiWebConfigurationRequestContext requestContext, final String annotationData) { final Revision revision = requestContext.getRevision(); final String id = requestContext.getId(); - + final ControllerServiceDTO controllerService; if (controllerServiceLookup.getControllerService(id) != null) { final ControllerServiceDTO controllerServiceDto = new ControllerServiceDTO(); controllerServiceDto.setId(id); controllerServiceDto.setAnnotationData(annotationData); - + final ConfigurationSnapshot<ControllerServiceDTO> response = serviceFacade.updateControllerService(revision, controllerServiceDto); controllerService = response.getConfiguration(); } else { @@ -458,13 +462,13 @@ public class StandardNiFiWebConfigurationContext implements NiFiWebConfiguration if (!properties.isClusterManager()) { throw new ResourceNotFoundException(String.format("Controller service[%s] could not be found on this NiFi.", id)); } - + // since this PUT request can be interpreted as a request to create a controller service // we need to be sure that this service exists on the node before the request is replicated. // this is done by attempting to get the details. if the service doesn't exist it will // throw a ResourceNotFoundException getComponentDetails(requestContext); - + // create the request URL URI requestUrl; try { @@ -498,7 +502,7 @@ public class StandardNiFiWebConfigurationContext implements NiFiWebConfiguration // check for issues replicating request checkResponse(nodeResponse, id); - + // return controller service ControllerServiceEntity entity = (ControllerServiceEntity) nodeResponse.getUpdatedEntity(); if (entity == null) { @@ -506,11 +510,11 @@ public class StandardNiFiWebConfigurationContext implements NiFiWebConfiguration } controllerService = entity.getControllerService(); } - + // return the controller service info return getComponentConfiguration(controllerService); } - + private ComponentDetails getComponentConfiguration(final ControllerServiceDTO controllerService) { return new ComponentDetails.Builder() .id(controllerService.getId()) @@ -522,16 +526,18 @@ public class StandardNiFiWebConfigurationContext implements NiFiWebConfiguration .validateErrors(controllerService.getValidationErrors()).build(); } } - + /** - * Interprets the request/response with the underlying ControllerService model. + * Interprets the request/response with the underlying ControllerService + * model. */ private class ReportingTaskFacade implements ComponentFacade { + @Override public ComponentDetails getComponentDetails(final NiFiWebRequestContext requestContext) { final String id = requestContext.getId(); final ReportingTaskDTO reportingTask; - + // if the provider has the service that means we are either a node or // the ncm and the service is available there only if (reportingTaskProvider.getReportingTaskNode(id) != null) { @@ -542,7 +548,7 @@ public class StandardNiFiWebConfigurationContext implements NiFiWebConfiguration if (!properties.isClusterManager()) { throw new ResourceNotFoundException(String.format("Reporting task[%s] could not be found on this NiFi.", id)); } - + // create the request URL URI requestUrl; try { @@ -577,13 +583,13 @@ public class StandardNiFiWebConfigurationContext implements NiFiWebConfiguration public ComponentDetails setAnnotationData(final NiFiWebConfigurationRequestContext requestContext, final String annotationData) { final Revision revision = requestContext.getRevision(); final String id = requestContext.getId(); - + final ReportingTaskDTO reportingTask; if (reportingTaskProvider.getReportingTaskNode(id) != null) { final ReportingTaskDTO reportingTaskDto = new ReportingTaskDTO(); reportingTaskDto.setId(id); reportingTaskDto.setAnnotationData(annotationData); - + final ConfigurationSnapshot<ReportingTaskDTO> response = serviceFacade.updateReportingTask(revision, reportingTaskDto); reportingTask = response.getConfiguration(); } else { @@ -592,13 +598,13 @@ public class StandardNiFiWebConfigurationContext implements NiFiWebConfiguration if (!properties.isClusterManager()) { throw new ResourceNotFoundException(String.format("Reporting task[%s] could not be found on this NiFi.", id)); } - + // since this PUT request can be interpreted as a request to create a reporting task // we need to be sure that this task exists on the node before the request is replicated. // this is done by attempting to get the details. if the service doesn't exist it will // throw a ResourceNotFoundException getComponentDetails(requestContext); - + // create the request URL URI requestUrl; try { @@ -632,7 +638,7 @@ public class StandardNiFiWebConfigurationContext implements NiFiWebConfiguration // check for issues replicating request checkResponse(nodeResponse, id); - + // return reporting task ReportingTaskEntity entity = (ReportingTaskEntity) nodeResponse.getUpdatedEntity(); if (entity == null) { @@ -640,11 +646,11 @@ public class StandardNiFiWebConfigurationContext implements NiFiWebConfiguration } reportingTask = entity.getReportingTask(); } - + // return the processor info return getComponentConfiguration(reportingTask); } - + private ComponentDetails getComponentConfiguration(final ReportingTaskDTO reportingTask) { return new ComponentDetails.Builder() .id(reportingTask.getId()) @@ -656,7 +662,7 @@ public class StandardNiFiWebConfigurationContext implements NiFiWebConfiguration .validateErrors(reportingTask.getValidationErrors()).build(); } } - + /** * Gets the headers for the request to replicate to each node while * clustered. @@ -685,13 +691,13 @@ public class StandardNiFiWebConfigurationContext implements NiFiWebConfiguration } return headers; } - + /** * Checks the specified response and drains the stream appropriately. - * + * * @param nodeResponse * @param revision - * @param id + * @param id */ private void checkResponse(final NodeResponse nodeResponse, final String id) { if (nodeResponse.hasThrowable()) { http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/a53cc3d7/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiWebContext.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiWebContext.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiWebContext.java index eaf457e..07b982f 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiWebContext.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiWebContext.java @@ -288,8 +288,8 @@ public class StandardNiFiWebContext implements NiFiWebContext { * Gets the headers for the request to replicate to each node while * clustered. * - * @param config - * @return + * @param config config + * @return headers */ private Map<String, String> getHeaders(final NiFiWebContextConfig config) { final Map<String, String> headers = new HashMap<>(); http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/a53cc3d7/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ApplicationResource.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ApplicationResource.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ApplicationResource.java index 787fffa..66b237e 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ApplicationResource.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ApplicationResource.java @@ -179,7 +179,7 @@ public abstract class ApplicationResource { // get cluster context from threadlocal ClusterContext clusterCtx = ClusterContextThreadLocal.getContext(); if (clusterCtx != null) { - + // serialize cluster context String serializedClusterContext = WebUtils.serializeObjectToHex(clusterCtx); if (serializedClusterContext.length() > CLUSTER_CONTEXT_HEADER_VALUE_MAX_BYTES) { http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/a53cc3d7/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ControllerResource.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ControllerResource.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ControllerResource.java index c0b4cd7..9228be4 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ControllerResource.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ControllerResource.java @@ -159,7 +159,7 @@ public class ControllerResource extends ApplicationResource { public SnippetResource getSnippetResource() { return resourceContext.getResource(SnippetResource.class); } - + /** * Locates the Controller Services sub-resource. * @@ -169,7 +169,7 @@ public class ControllerResource extends ApplicationResource { public ControllerServiceResource getControllerServiceResource() { return resourceContext.getResource(ControllerServiceResource.class); } - + /** * Locates the Reporting Tasks sub-resource. * @@ -730,7 +730,7 @@ public class ControllerResource extends ApplicationResource { // generate the response return clusterContext(generateOkResponse(entity)).build(); } - + /** * Retrieves the types of controller services that this NiFi supports. * @@ -766,7 +766,7 @@ public class ControllerResource extends ApplicationResource { // generate the response return clusterContext(generateOkResponse(entity)).build(); } - + /** * Retrieves the types of reporting tasks that this NiFi supports. * http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/a53cc3d7/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ControllerServiceResource.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ControllerServiceResource.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ControllerServiceResource.java index 1711f3c..bd3daf2 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ControllerServiceResource.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ControllerServiceResource.java @@ -84,12 +84,12 @@ public class ControllerServiceResource extends ApplicationResource { @Context private ServletContext servletContext; - + /** * Populates the uri for the specified controller service. - * + * * @param controllerServices - * @return + * @return */ private Set<ControllerServiceDTO> populateRemainingControllerServicesContent(final String availability, final Set<ControllerServiceDTO> controllerServices) { for (ControllerServiceDTO controllerService : controllerServices) { @@ -97,7 +97,7 @@ public class ControllerServiceResource extends ApplicationResource { } return controllerServices; } - + /** * Populates the uri for the specified controller service. */ @@ -105,7 +105,7 @@ public class ControllerServiceResource extends ApplicationResource { // populate the controller service href controllerService.setUri(generateResourceUri("controller", "controller-services", availability, controllerService.getId())); controllerService.setAvailability(availability); - + // see if this processor has any ui extensions final UiExtensionMapping uiExtensionMapping = (UiExtensionMapping) servletContext.getAttribute("nifi-ui-extensions"); if (uiExtensionMapping.hasUiExtension(controllerService.getType())) { @@ -116,16 +116,16 @@ public class ControllerServiceResource extends ApplicationResource { } } } - + return controllerService; } /** - * Parses the availability and ensure that the specified availability makes sense for the - * given NiFi instance. - * + * Parses the availability and ensure that the specified availability makes + * sense for the given NiFi instance. + * * @param availability - * @return + * @return */ private Availability parseAvailability(final String availability) { final Availability avail; @@ -134,23 +134,24 @@ public class ControllerServiceResource extends ApplicationResource { } catch (IllegalArgumentException iae) { throw new IllegalArgumentException(String.format("Availability: Value must be one of [%s]", StringUtils.join(Availability.values(), ", "))); } - + // ensure this nifi is an NCM is specifying NCM availability if (!properties.isClusterManager() && Availability.NCM.equals(avail)) { throw new IllegalArgumentException("Availability of NCM is only applicable when the NiFi instance is the cluster manager."); } - + return avail; } - + /** * Retrieves all the of controller services in this NiFi. * * @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 availability Whether the controller service is available on the NCM only (ncm) or on the - * nodes only (node). If this instance is not clustered all services should use the node availability. + * @param availability Whether the controller service is available on the + * NCM only (ncm) or on the nodes only (node). If this instance is not + * clustered all services should use the node availability. * @return A controllerServicesEntity. */ @GET @@ -160,7 +161,7 @@ public class ControllerServiceResource extends ApplicationResource { @TypeHint(ControllerServicesEntity.class) public Response getControllerServices(@QueryParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId, @PathParam("availability") String availability) { final Availability avail = parseAvailability(availability); - + // replicate if cluster manager if (properties.isClusterManager() && Availability.NODE.equals(avail)) { return clusterManager.applyRequest(HttpMethod.GET, getAbsolutePath(), getRequestParameters(true), getHeaders()).getResponse(); @@ -168,7 +169,7 @@ public class ControllerServiceResource extends ApplicationResource { // get all the controller services final Set<ControllerServiceDTO> controllerServices = populateRemainingControllerServicesContent(availability, serviceFacade.getControllerServices()); - + // create the revision final RevisionDTO revision = new RevisionDTO(); revision.setClientId(clientId.getClientId()); @@ -191,8 +192,9 @@ public class ControllerServiceResource extends ApplicationResource { * @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 availability Whether the controller service is available on the NCM only (ncm) or on the - * nodes only (node). If this instance is not clustered all services should use the node availability. + * @param availability Whether the controller service is available on the + * NCM only (ncm) or on the nodes only (node). If this instance is not + * clustered all services should use the node availability. * @param type The type of controller service to create. * @return A controllerServiceEntity. */ @@ -206,9 +208,9 @@ public class ControllerServiceResource extends ApplicationResource { @Context HttpServletRequest httpServletRequest, @FormParam(VERSION) LongParameter version, @FormParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId, - @PathParam("availability") String availability, + @PathParam("availability") String availability, @FormParam("type") String type) { - + // create the controller service DTO final ControllerServiceDTO controllerServiceDTO = new ControllerServiceDTO(); controllerServiceDTO.setType(type); @@ -232,8 +234,9 @@ public class ControllerServiceResource extends ApplicationResource { * Creates a new Controller Service. * * @param httpServletRequest - * @param availability Whether the controller service is available on the NCM only (ncm) or on the - * nodes only (node). If this instance is not clustered all services should use the node availability. + * @param availability Whether the controller service is available on the + * NCM only (ncm) or on the nodes only (node). If this instance is not + * clustered all services should use the node availability. * @param controllerServiceEntity A controllerServiceEntity. * @return A controllerServiceEntity. */ @@ -245,19 +248,19 @@ public class ControllerServiceResource extends ApplicationResource { @TypeHint(ControllerServiceEntity.class) public Response createControllerService( @Context HttpServletRequest httpServletRequest, - @PathParam("availability") String availability, + @PathParam("availability") String availability, ControllerServiceEntity controllerServiceEntity) { - + final Availability avail = parseAvailability(availability); - if (controllerServiceEntity == null || controllerServiceEntity.getControllerService()== null) { + if (controllerServiceEntity == null || controllerServiceEntity.getControllerService() == null) { throw new IllegalArgumentException("Controller service details must be specified."); } if (controllerServiceEntity.getRevision() == null) { throw new IllegalArgumentException("Revision must be specified."); } - + if (controllerServiceEntity.getControllerService().getId() != null) { throw new IllegalArgumentException("Controller service ID cannot be specified."); } @@ -265,10 +268,10 @@ public class ControllerServiceResource extends ApplicationResource { if (StringUtils.isBlank(controllerServiceEntity.getControllerService().getType())) { throw new IllegalArgumentException("The type of controller service to create must be specified."); } - + // get the revision final RevisionDTO revision = controllerServiceEntity.getRevision(); - + // if cluster manager, convert POST to PUT (to maintain same ID across nodes) and replicate if (properties.isClusterManager() && Availability.NODE.equals(avail)) { // create ID for resource @@ -324,8 +327,9 @@ public class ControllerServiceResource extends ApplicationResource { * @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 availability Whether the controller service is available on the NCM only (ncm) or on the - * nodes only (node). If this instance is not clustered all services should use the node availability. + * @param availability Whether the controller service is available on the + * NCM only (ncm) or on the nodes only (node). If this instance is not + * clustered all services should use the node availability. * @param id The id of the controller service to retrieve * @return A controllerServiceEntity. */ @@ -334,11 +338,11 @@ public class ControllerServiceResource extends ApplicationResource { @Path("/{availability}/{id}") @PreAuthorize("hasAnyRole('ROLE_MONITOR', 'ROLE_DFM', 'ROLE_ADMIN')") @TypeHint(ControllerServiceEntity.class) - public Response getControllerService(@QueryParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId, + public Response getControllerService(@QueryParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId, @PathParam("availability") String availability, @PathParam("id") String id) { final Availability avail = parseAvailability(availability); - + // replicate if cluster manager if (properties.isClusterManager() && Availability.NODE.equals(avail)) { return clusterManager.applyRequest(HttpMethod.GET, getAbsolutePath(), getRequestParameters(true), getHeaders()).getResponse(); @@ -358,10 +362,10 @@ public class ControllerServiceResource extends ApplicationResource { return clusterContext(generateOkResponse(entity)).build(); } - + /** * Returns the descriptor for the specified property. - * + * * @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. @@ -376,46 +380,47 @@ public class ControllerServiceResource extends ApplicationResource { @PreAuthorize("hasAnyRole('ROLE_MONITOR', 'ROLE_DFM', 'ROLE_ADMIN')") @TypeHint(PropertyDescriptorEntity.class) public Response getPropertyDescriptor( - @QueryParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId, - @PathParam("availability") String availability, @PathParam("id") String id, + @QueryParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId, + @PathParam("availability") String availability, @PathParam("id") String id, @QueryParam("propertyName") String propertyName) { - + final Availability avail = parseAvailability(availability); - + // ensure the property name is specified if (propertyName == null) { throw new IllegalArgumentException("The property name must be specified."); } - + // replicate if cluster manager and service is on node if (properties.isClusterManager() && Availability.NODE.equals(avail)) { return clusterManager.applyRequest(HttpMethod.GET, getAbsolutePath(), getRequestParameters(true), getHeaders()).getResponse(); } - + // get the property descriptor final PropertyDescriptorDTO descriptor = serviceFacade.getControllerServicePropertyDescriptor(id, propertyName); - + // create the revision final RevisionDTO revision = new RevisionDTO(); revision.setClientId(clientId.getClientId()); - + // generate the response entity final PropertyDescriptorEntity entity = new PropertyDescriptorEntity(); entity.setRevision(revision); entity.setPropertyDescriptor(descriptor); - + // generate the response return clusterContext(generateOkResponse(entity)).build(); } - + /** * Retrieves the references of the specified controller service. * * @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 availability Whether the controller service is available on the NCM only (ncm) or on the - * nodes only (node). If this instance is not clustered all services should use the node availability. + * @param availability Whether the controller service is available on the + * NCM only (ncm) or on the nodes only (node). If this instance is not + * clustered all services should use the node availability. * @param id The id of the controller service to retrieve * @return A controllerServiceEntity. */ @@ -429,7 +434,7 @@ public class ControllerServiceResource extends ApplicationResource { @PathParam("availability") String availability, @PathParam("id") String id) { final Availability avail = parseAvailability(availability); - + // replicate if cluster manager if (properties.isClusterManager() && Availability.NODE.equals(avail)) { return clusterManager.applyRequest(HttpMethod.GET, getAbsolutePath(), getRequestParameters(true), getHeaders()).getResponse(); @@ -449,7 +454,7 @@ public class ControllerServiceResource extends ApplicationResource { return clusterContext(generateOkResponse(entity)).build(); } - + /** * Updates the references of the specified controller service. * @@ -459,12 +464,14 @@ public class ControllerServiceResource extends ApplicationResource { * @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 availability Whether the controller service is available on the NCM only (ncm) or on the - * nodes only (node). If this instance is not clustered all services should use the node availability. + * @param availability Whether the controller service is available on the + * NCM only (ncm) or on the nodes only (node). If this instance is not + * clustered all services should use the node availability. * @param id The id of the controller service to retrieve - * @param state Sets the state of referencing components. A value of RUNNING or STOPPED will update - * referencing schedulable components (Processors and Reporting Tasks). A value of ENABLED or - * DISABLED will update referencing controller services. + * @param state Sets the state of referencing components. A value of RUNNING + * or STOPPED will update referencing schedulable components (Processors and + * Reporting Tasks). A value of ENABLED or DISABLED will update referencing + * controller services. * @return A controllerServiceEntity. */ @PUT @@ -481,7 +488,6 @@ public class ControllerServiceResource extends ApplicationResource { @FormParam("state") @DefaultValue(StringUtils.EMPTY) String state) { // parse the state to determine the desired action - // need to consider controller service state first as it shares a state with // scheduled state (disabled) which is applicable for referencing services // but not referencing schedulable components @@ -491,29 +497,29 @@ public class ControllerServiceResource extends ApplicationResource { } catch (final IllegalArgumentException iae) { // ignore } - + ScheduledState scheduledState = null; try { scheduledState = ScheduledState.valueOf(state); } catch (final IllegalArgumentException iae) { // ignore } - + // ensure an action has been specified if (scheduledState == null && controllerServiceState == null) { throw new IllegalArgumentException("Must specify the updated state. To update referencing Processors " + "and Reporting Tasks the state should be RUNNING or STOPPED. To update the referencing Controller Services the " + "state should be ENABLED or DISABLED."); } - + // ensure the controller service state is not ENABLING or DISABLING if (controllerServiceState != null && (ControllerServiceState.ENABLING.equals(controllerServiceState) || ControllerServiceState.DISABLING.equals(controllerServiceState))) { throw new IllegalArgumentException("Cannot set the referencing services to ENABLING or DISABLING"); } - + // determine the availability final Availability avail = parseAvailability(availability); - + // replicate if cluster manager if (properties.isClusterManager() && Availability.NODE.equals(avail)) { return clusterManager.applyRequest(HttpMethod.PUT, getAbsolutePath(), getRequestParameters(true), getHeaders()).getResponse(); @@ -525,16 +531,16 @@ public class ControllerServiceResource extends ApplicationResource { serviceFacade.verifyUpdateControllerServiceReferencingComponents(id, scheduledState, controllerServiceState); return generateContinueResponse().build(); } - + // determine the specified version Long clientVersion = null; if (version != null) { clientVersion = version.getLong(); } - + // get the controller service - final ConfigurationSnapshot<Set<ControllerServiceReferencingComponentDTO>> response = - serviceFacade.updateControllerServiceReferencingComponents(new Revision(clientVersion, clientId.getClientId()), id, scheduledState, controllerServiceState); + final ConfigurationSnapshot<Set<ControllerServiceReferencingComponentDTO>> response + = serviceFacade.updateControllerServiceReferencingComponents(new Revision(clientVersion, clientId.getClientId()), id, scheduledState, controllerServiceState); // create the revision final RevisionDTO revision = new RevisionDTO(); @@ -558,14 +564,17 @@ public class ControllerServiceResource extends ApplicationResource { * @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 availability Whether the controller service is available on the NCM only (ncm) or on the - * nodes only (node). If this instance is not clustered all services should use the node availability. + * @param availability Whether the controller service is available on the + * NCM only (ncm) or on the nodes only (node). If this instance is not + * clustered all services should use the node availability. * @param id The id of the controller service to update. * @param name The name of the controller service * @param annotationData The annotation data for the controller service * @param comments The comments for the controller service - * @param state The state of this controller service. Should be ENABLED or DISABLED. - * @param markedForDeletion Array of property names whose value should be removed. + * @param state The state of this controller service. Should be ENABLED or + * DISABLED. + * @param markedForDeletion Array of property names whose value should be + * removed. * @param formParams Additionally, the processor properties and styles are * specified in the form parameters. Because the property names and styles * differ from processor to processor they are specified in a map-like @@ -599,7 +608,7 @@ public class ControllerServiceResource extends ApplicationResource { // create collections for holding the controller service properties final Map<String, String> updatedProperties = new LinkedHashMap<>(); - + // go through each parameter and look for processor properties for (String parameterName : formParams.keySet()) { if (StringUtils.isNotBlank(parameterName)) { @@ -615,12 +624,12 @@ public class ControllerServiceResource extends ApplicationResource { } } } - + // set the properties to remove for (String propertyToDelete : markedForDeletion) { updatedProperties.put(propertyToDelete, null); } - + // create the controller service DTO final ControllerServiceDTO controllerServiceDTO = new ControllerServiceDTO(); controllerServiceDTO.setId(id); @@ -633,7 +642,7 @@ public class ControllerServiceResource extends ApplicationResource { if (!updatedProperties.isEmpty()) { controllerServiceDTO.setProperties(updatedProperties); } - + // create the revision final RevisionDTO revision = new RevisionDTO(); revision.setClientId(clientId.getClientId()); @@ -654,8 +663,9 @@ public class ControllerServiceResource extends ApplicationResource { * Updates the specified a new Controller Service. * * @param httpServletRequest - * @param availability Whether the controller service is available on the NCM only (ncm) or on the - * nodes only (node). If this instance is not clustered all services should use the node availability. + * @param availability Whether the controller service is available on the + * NCM only (ncm) or on the nodes only (node). If this instance is not + * clustered all services should use the node availability. * @param id The id of the controller service to update. * @param controllerServiceEntity A controllerServiceEntity. * @return A controllerServiceEntity. @@ -668,13 +678,13 @@ public class ControllerServiceResource extends ApplicationResource { @TypeHint(ControllerServiceEntity.class) public Response updateControllerService( @Context HttpServletRequest httpServletRequest, - @PathParam("availability") String availability, + @PathParam("availability") String availability, @PathParam("id") String id, ControllerServiceEntity controllerServiceEntity) { final Availability avail = parseAvailability(availability); - - if (controllerServiceEntity == null || controllerServiceEntity.getControllerService()== null) { + + if (controllerServiceEntity == null || controllerServiceEntity.getControllerService() == null) { throw new IllegalArgumentException("Controller service details must be specified."); } @@ -698,7 +708,7 @@ public class ControllerServiceResource extends ApplicationResource { // replicate the request return clusterManager.applyRequest(HttpMethod.PUT, getAbsolutePath(), updateClientId(controllerServiceEntity), getHeaders(headersToOverride)).getResponse(); } - + // handle expects request (usually from the cluster manager) final String expects = httpServletRequest.getHeader(WebClusterManager.NCM_EXPECTS_HTTP_HEADER); if (expects != null) { @@ -736,8 +746,9 @@ public class ControllerServiceResource extends ApplicationResource { * @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 availability Whether the controller service is available on the NCM only (ncm) or on the - * nodes only (node). If this instance is not clustered all services should use the node availability. + * @param availability Whether the controller service is available on the + * NCM only (ncm) or on the nodes only (node). If this instance is not + * clustered all services should use the node availability. * @param id The id of the controller service to remove. * @return A entity containing the client id and an updated revision. */ @@ -753,7 +764,7 @@ public class ControllerServiceResource extends ApplicationResource { @PathParam("availability") String availability, @PathParam("id") String id) { final Availability avail = parseAvailability(availability); - + // replicate if cluster manager if (properties.isClusterManager() && Availability.NODE.equals(avail)) { return clusterManager.applyRequest(HttpMethod.DELETE, getAbsolutePath(), getRequestParameters(true), getHeaders()).getResponse(); @@ -788,7 +799,6 @@ public class ControllerServiceResource extends ApplicationResource { } // setters - public void setServiceFacade(NiFiServiceFacade serviceFacade) { this.serviceFacade = serviceFacade; } http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/a53cc3d7/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/FunnelResource.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/FunnelResource.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/FunnelResource.java index 3492de2..4e6095e 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/FunnelResource.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/FunnelResource.java @@ -72,8 +72,9 @@ public class FunnelResource extends ApplicationResource { /** * Populates the uri for the specified funnels. + * * @param funnels - * @return + * @return */ public Set<FunnelDTO> populateRemainingFunnelsContent(Set<FunnelDTO> funnels) { for (FunnelDTO funnel : funnels) { http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/a53cc3d7/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/HistoryResource.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/HistoryResource.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/HistoryResource.java index 0f60f52..49bede82 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/HistoryResource.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/HistoryResource.java @@ -262,7 +262,7 @@ public class HistoryResource extends ApplicationResource { // generate the response return generateOkResponse(entity).build(); } - + /** * Gets the actions for the specified controller service. * @@ -293,7 +293,7 @@ public class HistoryResource extends ApplicationResource { // generate the response return generateOkResponse(entity).build(); } - + /** * Gets the actions for the specified reporting task. * @@ -324,7 +324,7 @@ public class HistoryResource extends ApplicationResource { // generate the response return generateOkResponse(entity).build(); } - + /* setters */ public void setServiceFacade(NiFiServiceFacade serviceFacade) { this.serviceFacade = serviceFacade; http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/a53cc3d7/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/InputPortResource.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/InputPortResource.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/InputPortResource.java index f3a6326..9b5eeba 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/InputPortResource.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/InputPortResource.java @@ -74,8 +74,9 @@ public class InputPortResource extends ApplicationResource { /** * Populates the uri for the specified input ports. + * * @param inputPorts - * @return + * @return */ public Set<PortDTO> populateRemainingInputPortsContent(Set<PortDTO> inputPorts) { for (PortDTO inputPort : inputPorts) { http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/a53cc3d7/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/LabelResource.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/LabelResource.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/LabelResource.java index 6435671..4905ad3 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/LabelResource.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/LabelResource.java @@ -74,8 +74,9 @@ public class LabelResource extends ApplicationResource { /** * Populates the uri for the specified labels. + * * @param labels - * @return + * @return */ public Set<LabelDTO> populateRemainingLabelsContent(Set<LabelDTO> labels) { for (LabelDTO label : labels) { http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/a53cc3d7/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/OutputPortResource.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/OutputPortResource.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/OutputPortResource.java index a9dce5f..168ec90 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/OutputPortResource.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/OutputPortResource.java @@ -74,8 +74,9 @@ public class OutputPortResource extends ApplicationResource { /** * Populates the uri for the specified output ports. + * * @param outputPorts - * @return + * @return */ public Set<PortDTO> populateRemainingOutputPortsContent(Set<PortDTO> outputPorts) { for (PortDTO outputPort : outputPorts) { http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/a53cc3d7/nifi/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/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/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ProcessorResource.java index 31ab10b..00b6fe3 100644 --- a/nifi/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/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ProcessorResource.java @@ -262,7 +262,7 @@ public class ProcessorResource extends ApplicationResource { if (processorEntity.getProcessor().getId() != null) { throw new IllegalArgumentException("Processor ID cannot be specified."); } - + if (StringUtils.isBlank(processorEntity.getProcessor().getType())) { throw new IllegalArgumentException("The type of processor to create must be specified."); } @@ -394,10 +394,10 @@ public class ProcessorResource extends ApplicationResource { // generate the response return clusterContext(generateOkResponse(entity)).build(); } - + /** * Returns the descriptor for the specified property. - * + * * @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. @@ -411,31 +411,31 @@ public class ProcessorResource extends ApplicationResource { @PreAuthorize("hasAnyRole('ROLE_MONITOR', 'ROLE_DFM', 'ROLE_ADMIN')") @TypeHint(PropertyDescriptorEntity.class) public Response getPropertyDescriptor( - @QueryParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId, + @QueryParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId, @PathParam("id") String id, @QueryParam("propertyName") String propertyName) { - + // ensure the property name is specified if (propertyName == null) { throw new IllegalArgumentException("The property name must be specified."); } - + // replicate if cluster manager if (properties.isClusterManager()) { return clusterManager.applyRequest(HttpMethod.GET, getAbsolutePath(), getRequestParameters(true), getHeaders()).getResponse(); } - + // get the property descriptor final PropertyDescriptorDTO descriptor = serviceFacade.getProcessorPropertyDescriptor(groupId, id, propertyName); - + // create the revision final RevisionDTO revision = new RevisionDTO(); revision.setClientId(clientId.getClientId()); - + // generate the response entity final PropertyDescriptorEntity entity = new PropertyDescriptorEntity(); entity.setRevision(revision); entity.setPropertyDescriptor(descriptor); - + // generate the response return clusterContext(generateOkResponse(entity)).build(); } http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/a53cc3d7/nifi/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/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/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/RemoteProcessGroupResource.java index 4e15c36..b171835 100644 --- a/nifi/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/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/RemoteProcessGroupResource.java @@ -370,7 +370,7 @@ public class RemoteProcessGroupResource extends ApplicationResource { if (uri.getScheme() == null || uri.getHost() == null) { throw new IllegalArgumentException("The specified remote process group URL is malformed: " + requestProcessGroupDTO.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: " + requestProcessGroupDTO.getTargetUri()); } @@ -864,7 +864,7 @@ public class RemoteProcessGroupResource extends ApplicationResource { 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()); }
