private void addReportingTaskFingerprint(final StringBuilder builder, final ReportingTaskDTO dto) { builder.append(dto.getId()); builder.append(dto.getType()); builder.append(dto.getName()); addBundleFingerprint(builder, dto.getBundle()); builder.append(dto.getComments()); builder.append(dto.getSchedulingPeriod()); builder.append(dto.getSchedulingStrategy()); builder.append(dto.getAnnotationData()); // get the temp instance of the ReportingTask so that we know the default property values final BundleCoordinate coordinate = getCoordinate(dto.getType(), dto.getBundle()); final ConfigurableComponent configurableComponent = extensionManager.getTempComponent(dto.getType(), coordinate); if (configurableComponent == null) { logger.warn("Unable to get ReportingTask of type {}; its default properties will be fingerprinted instead of being ignored.", dto.getType()); } addPropertiesFingerprint(builder, configurableComponent, dto.getProperties()); }
@Override public void verifyCreate(final ReportingTaskDTO reportingTaskDTO) { verifyCreate(reportingTaskProvider.getExtensionManager(), reportingTaskDTO.getType(), reportingTaskDTO.getBundle()); }
@Override public ReportingTaskNode createReportingTask(final ReportingTaskDTO reportingTaskDTO) { // ensure the type is specified if (reportingTaskDTO.getType() == null) { throw new IllegalArgumentException("The reporting task type must be specified."); } try { // create the reporting task final ExtensionManager extensionManager = reportingTaskProvider.getExtensionManager(); final BundleCoordinate bundleCoordinate = BundleUtils.getBundle(extensionManager, reportingTaskDTO.getType(), reportingTaskDTO.getBundle()); final ReportingTaskNode reportingTask = reportingTaskProvider.createReportingTask( reportingTaskDTO.getType(), reportingTaskDTO.getId(), bundleCoordinate, true); // ensure we can perform the update verifyUpdate(reportingTask, reportingTaskDTO); // perform the update configureReportingTask(reportingTask, reportingTaskDTO); return reportingTask; } catch (ReportingTaskInstantiationException rtie) { throw new NiFiCoreException(rtie.getMessage(), rtie); } }
/** * Populates the uri for the specified reporting task. */ public ReportingTaskDTO populateRemainingReportingTaskContent(final ReportingTaskDTO reportingTask) { final BundleDTO bundle = reportingTask.getBundle(); if (bundle == null) { return reportingTask; } // see if this processor has any ui extensions final UiExtensionMapping uiExtensionMapping = (UiExtensionMapping) servletContext.getAttribute("nifi-ui-extensions"); if (uiExtensionMapping.hasUiExtension(reportingTask.getType(), bundle.getGroup(), bundle.getArtifact(), bundle.getVersion())) { final List<UiExtension> uiExtensions = uiExtensionMapping.getUiExtension(reportingTask.getType(), bundle.getGroup(), bundle.getArtifact(), bundle.getVersion()); for (final UiExtension uiExtension : uiExtensions) { if (UiExtensionType.ReportingTaskConfiguration.equals(uiExtension.getExtensionType())) { reportingTask.setCustomUiUrl(uiExtension.getContextPath() + "/configure"); } } } return reportingTask; }
private ComponentDetails getComponentConfiguration(final ReportingTaskDTO reportingTask) { return new ComponentDetails.Builder() .id(reportingTask.getId()) .name(reportingTask.getName()) .type(reportingTask.getType()) .state(reportingTask.getState()) .annotationData(reportingTask.getAnnotationData()) .properties(reportingTask.getProperties()) .validateErrors(reportingTask.getValidationErrors()).build(); } }
private ReportingTaskNode getOrCreateReportingTask(final FlowController controller, final ReportingTaskDTO dto, final boolean controllerInitialized, final boolean existingFlowEmpty) throws ReportingTaskInstantiationException { // create a new reporting task node when the controller is not initialized or the flow is empty if (!controllerInitialized || existingFlowEmpty) { BundleCoordinate coordinate; try { coordinate = BundleUtils.getCompatibleBundle(extensionManager, dto.getType(), dto.getBundle()); } catch (final IllegalStateException e) { final BundleDTO bundleDTO = dto.getBundle(); if (bundleDTO == null) { coordinate = BundleCoordinate.UNKNOWN_COORDINATE; } else { coordinate = new BundleCoordinate(bundleDTO.getGroup(), bundleDTO.getArtifact(), bundleDTO.getVersion()); } } final ReportingTaskNode reportingTask = controller.createReportingTask(dto.getType(), dto.getId(), coordinate, false); reportingTask.setName(dto.getName()); reportingTask.setComments(dto.getComments()); reportingTask.setSchedulingPeriod(dto.getSchedulingPeriod()); reportingTask.setSchedulingStrategy(SchedulingStrategy.valueOf(dto.getSchedulingStrategy())); reportingTask.setAnnotationData(dto.getAnnotationData()); reportingTask.setProperties(dto.getProperties()); return reportingTask; } else { // otherwise return the existing reporting task node return controller.getReportingTaskNode(dto.getId()); } }