private ProcessorConfigDTO copy(final ProcessorConfigDTO original) { final ProcessorConfigDTO copy = new ProcessorConfigDTO(); copy.setAnnotationData(original.getAnnotationData()); copy.setAutoTerminatedRelationships(copy(original.getAutoTerminatedRelationships())); copy.setComments(original.getComments()); copy.setSchedulingStrategy(original.getSchedulingStrategy()); copy.setExecutionNode(original.getExecutionNode()); copy.setConcurrentlySchedulableTaskCount(original.getConcurrentlySchedulableTaskCount()); copy.setCustomUiUrl(original.getCustomUiUrl()); copy.setDescriptors(copy(original.getDescriptors())); copy.setProperties(copy(original.getProperties())); copy.setSchedulingPeriod(original.getSchedulingPeriod()); copy.setPenaltyDuration(original.getPenaltyDuration()); copy.setYieldDuration(original.getYieldDuration()); copy.setRunDurationMillis(original.getRunDurationMillis()); copy.setBulletinLevel(original.getBulletinLevel()); copy.setDefaultConcurrentTasks(original.getDefaultConcurrentTasks()); copy.setDefaultSchedulingPeriod(original.getDefaultSchedulingPeriod()); copy.setLossTolerant(original.isLossTolerant()); return copy; }
private ProcessorDTO buildProcessorDto(String id, final String annotationData, Map<String, String> properties){ ProcessorDTO processorDto = new ProcessorDTO(); processorDto.setId(id); ProcessorConfigDTO configDto = new ProcessorConfigDTO(); processorDto.setConfig(configDto); configDto.setAnnotationData(annotationData); configDto.setProperties(properties); return processorDto; }
private void updateControllerServiceIdentifiers(final ProcessorConfigDTO configDto, final Map<String, String> serviceIdMap) { if (configDto == null) { return; } final Map<String, String> properties = configDto.getProperties(); final Map<String, PropertyDescriptorDTO> descriptors = configDto.getDescriptors(); if (properties != null && descriptors != null) { for (final PropertyDescriptorDTO descriptor : descriptors.values()) { if (descriptor.getIdentifiesControllerService() != null) { final String currentServiceId = properties.get(descriptor.getName()); if (currentServiceId == null) { continue; } // if this is a copy/paste action, we can continue to reference the same service, in this case // the serviceIdMap will be empty if (serviceIdMap.containsKey(currentServiceId)) { final String newServiceId = serviceIdMap.get(currentServiceId); properties.put(descriptor.getName(), newServiceId); } } } } }
if (newConfig.getConcurrentlySchedulableTaskCount() != null) { values.put(CONCURRENTLY_SCHEDULABLE_TASKS, String.valueOf(processor.getMaxConcurrentTasks())); if (newConfig.getPenaltyDuration() != null) { values.put(PENALTY_DURATION, processor.getPenalizationPeriod()); if (newConfig.getYieldDuration() != null) { values.put(YIELD_DURATION, processor.getYieldPeriod()); if (newConfig.getBulletinLevel() != null) { values.put(BULLETIN_LEVEL, processor.getBulletinLevel().name()); if (newConfig.getAnnotationData() != null) { values.put(ANNOTATION_DATA, processor.getAnnotationData()); if (newConfig.getSchedulingPeriod() != null) { values.put(SCHEDULING_PERIOD, String.valueOf(processor.getSchedulingPeriod())); if (newConfig.getAutoTerminatedRelationships() != null) { if (newConfig.getProperties() != null) { Map<String, String> properties = newConfig.getProperties(); Map<PropertyDescriptor, String> configuredProperties = processor.getProperties(); for (String propertyName : properties.keySet()) { if (newConfig.getComments() != null) { values.put(COMMENTS, processor.getComments());
final ProcessorConfigDTO dto = new ProcessorConfigDTO(); dto.setDescriptors(new LinkedHashMap<String, PropertyDescriptorDTO>()); dto.setProperties(new LinkedHashMap<String, String>()); for (final Map.Entry<PropertyDescriptor, String> entry : orderedProperties.entrySet()) { final PropertyDescriptor descriptor = entry.getKey(); dto.getDescriptors().put(descriptor.getName(), createPropertyDescriptorDto(descriptor, procNode.getProcessGroup().getIdentifier())); dto.getProperties().put(descriptor.getName(), propertyValue); dto.setSchedulingPeriod(procNode.getSchedulingPeriod()); dto.setPenaltyDuration(procNode.getPenalizationPeriod()); dto.setYieldDuration(procNode.getYieldPeriod()); dto.setRunDurationMillis(procNode.getRunDuration(TimeUnit.MILLISECONDS)); dto.setConcurrentlySchedulableTaskCount(procNode.getMaxConcurrentTasks()); dto.setLossTolerant(procNode.isLossTolerant()); dto.setComments(procNode.getComments()); dto.setBulletinLevel(procNode.getBulletinLevel().name()); dto.setSchedulingStrategy(procNode.getSchedulingStrategy().name()); dto.setExecutionNode(procNode.getExecutionNode().name()); dto.setAnnotationData(procNode.getAnnotationData()); defaultConcurrentTasks.put(SchedulingStrategy.EVENT_DRIVEN.name(), String.valueOf(SchedulingStrategy.EVENT_DRIVEN.getDefaultConcurrentTasks())); defaultConcurrentTasks.put(SchedulingStrategy.CRON_DRIVEN.name(), String.valueOf(SchedulingStrategy.CRON_DRIVEN.getDefaultConcurrentTasks())); dto.setDefaultConcurrentTasks(defaultConcurrentTasks); dto.setDefaultSchedulingPeriod(defaultSchedulingPeriod);
map.put(ID_KEY, processorDTO.getId()); map.put(CLASS_KEY, processorDTO.getType()); map.put(SCHEDULING_STRATEGY_KEY, processorDTOConfig.getSchedulingStrategy()); map.put(SCHEDULING_PERIOD_KEY, processorDTOConfig.getSchedulingPeriod()); map.put(CommonPropertyKeys.MAX_CONCURRENT_TASKS_KEY, processorDTOConfig.getConcurrentlySchedulableTaskCount()); map.put(ProcessorSchema.PENALIZATION_PERIOD_KEY, processorDTOConfig.getPenaltyDuration()); map.put(CommonPropertyKeys.YIELD_PERIOD_KEY, processorDTOConfig.getYieldDuration()); Long runDurationMillis = processorDTOConfig.getRunDurationMillis(); if (runDurationMillis != null) { map.put(ProcessorSchema.RUN_DURATION_NANOS_KEY, runDurationMillis * 1000); .map(RelationshipDTO::getName) .collect(Collectors.toList())); map.put(PROPERTIES_KEY, new HashMap<>(nullToEmpty(processorDTOConfig.getProperties()))); String annotationData = processorDTOConfig.getAnnotationData(); if(annotationData != null && !annotationData.isEmpty()) { map.put(ANNOTATION_DATA_KEY, annotationData);
final ProcessorConfigDTO configDto = new ProcessorConfigDTO(); dto.setConfig(configDto); configDto.setComments(getString(element, "comment")); configDto.setConcurrentlySchedulableTaskCount(getInt(element, "maxConcurrentTasks")); final String schedulingPeriod = getString(element, "schedulingPeriod"); configDto.setSchedulingPeriod(schedulingPeriod); configDto.setPenaltyDuration(getString(element, "penalizationPeriod")); configDto.setYieldDuration(getString(element, "yieldPeriod")); configDto.setBulletinLevel(getString(element, "bulletinLevel")); configDto.setLossTolerant(getBoolean(element, "lossTolerant")); final ScheduledState scheduledState = getScheduledState(element); dto.setState(scheduledState.toString()); configDto.setSchedulingStrategy(SchedulingStrategy.TIMER_DRIVEN.name()); } else { configDto.setSchedulingStrategy(schedulingStrategyName.trim()); configDto.setExecutionNode(ExecutionNode.ALL.name()); } else { configDto.setExecutionNode(executionNode.trim()); configDto.setRunDurationMillis(TimeUnit.NANOSECONDS.toMillis(runDurationNanos)); configDto.setProperties(getProperties(element, encryptor)); configDto.setAnnotationData(getString(element, "annotationData")); configDto.setAutoTerminatedRelationships(autoTerminatedRelationships);
if (isNotNull(config.getPenaltyDuration())) { Matcher penaltyMatcher = FormatUtils.TIME_DURATION_PATTERN.matcher(config.getPenaltyDuration()); if (!penaltyMatcher.matches()) { validationErrors.add("Penalty duration is not a valid time duration (ie 30 sec, 5 min)"); if (isNotNull(config.getYieldDuration())) { Matcher yieldMatcher = FormatUtils.TIME_DURATION_PATTERN.matcher(config.getYieldDuration()); if (!yieldMatcher.matches()) { validationErrors.add("Yield duration is not a valid time duration (ie 30 sec, 5 min)"); if (isNotNull(config.getBulletinLevel())) { try { LogLevel.valueOf(config.getBulletinLevel()); } catch (IllegalArgumentException iae) { validationErrors.add(String.format("Bulletin level: Value must be one of [%s]", StringUtils.join(LogLevel.values(), ", "))); if (isNotNull(config.getExecutionNode())) { try { ExecutionNode.valueOf(config.getExecutionNode()); } catch (IllegalArgumentException iae) { validationErrors.add(String.format("Execution node: Value must be one of [%s]", StringUtils.join(ExecutionNode.values(), ", "))); if (isNotNull(config.getSchedulingStrategy())) { try { schedulingStrategy = SchedulingStrategy.valueOf(config.getSchedulingStrategy()); } catch (IllegalArgumentException iae) { validationErrors.add(String.format("Scheduling strategy: Value must be one of [%s]", StringUtils.join(SchedulingStrategy.values(), ", ")));
if (processorConfig.getProperties() != null) { Map<String, String> processorProperties = processorConfig.getProperties(); if (processorConfig.getDescriptors() != null) { final Collection<PropertyDescriptorDTO> descriptors = processorConfig.getDescriptors().values(); for (PropertyDescriptorDTO descriptor : descriptors) { if (Boolean.TRUE.equals(descriptor.isSensitive())) { processorConfig.setCustomUiUrl(null); processorConfig.setDefaultConcurrentTasks(null); processorConfig.setDefaultSchedulingPeriod(null); processorConfig.setAutoTerminatedRelationships(null);
snippet.getProcessors().forEach(dto -> { if (dto.getConfig() == null) { dto.setConfig(new ProcessorConfigDTO()); if (config.getProperties() == null) { config.setProperties(new LinkedHashMap<>()); final ConfigurableComponent configurableComponent = controllerFacade.getTemporaryComponent(dto.getType(), dto.getBundle()); configurableComponent.getPropertyDescriptors().forEach(descriptor -> { if (config.getProperties().get(descriptor.getName()) == null) { config.getProperties().put(descriptor.getName(), descriptor.getDefaultValue());
private ComponentDetails getComponentConfiguration(final ProcessorDTO processor) { final ProcessorConfigDTO processorConfig = processor.getConfig(); return new ComponentDetails.Builder() .id(processor.getId()) .name(processor.getName()) .type(processor.getType()) .state(processor.getState()) .annotationData(processorConfig.getAnnotationData()) .properties(processorConfig.getProperties()) .descriptors(buildComponentDescriptorMap(processorConfig)) .validateErrors(processor.getValidationErrors()).build(); }
private void lookupSensitiveProcessorProperties(final Set<ProcessorDTO> processors) { final ProcessGroup rootGroup = flowController.getFlowManager().getRootGroup(); // go through each processor for (final ProcessorDTO processorDTO : processors) { final ProcessorConfigDTO processorConfig = processorDTO.getConfig(); // ensure that some property configuration have been specified if (processorConfig != null && processorConfig.getProperties() != null) { final Map<String, String> processorProperties = processorConfig.getProperties(); // find the corresponding processor final ProcessorNode processorNode = rootGroup.findProcessor(processorDTO.getId()); if (processorNode == null) { throw new IllegalArgumentException(String.format("Unable to create snippet because Processor '%s' could not be found", processorDTO.getId())); } // look for sensitive properties get the actual value for (Entry<PropertyDescriptor, String> entry : processorNode.getProperties().entrySet()) { final PropertyDescriptor descriptor = entry.getKey(); if (descriptor.isSensitive()) { processorProperties.put(descriptor.getName(), entry.getValue()); } } } } }
nodeProcessor.getConfig().getDescriptors().values().stream().forEach(propertyDescriptor -> { propertyDescriptorMap.computeIfAbsent(propertyDescriptor.getName(), nodeIdToPropertyDescriptor -> new HashMap<>()).put(nodeId, propertyDescriptor); }); final PropertyDescriptorDTO clientPropertyDescriptor = clientDto.getConfig().getDescriptors().get(propertyDescriptor.getName()); PropertyDescriptorDtoMerger.merge(clientPropertyDescriptor, propertyDescriptorByNodeId);
final ProcessorConfigDTO config = processorDTO.getConfig(); procNode.setProcessGroup(processGroup); procNode.setLossTolerant(config.isLossTolerant()); procNode.setPenalizationPeriod(config.getPenaltyDuration()); procNode.setYieldPeriod(config.getYieldDuration()); procNode.setBulletinLevel(LogLevel.valueOf(config.getBulletinLevel())); updateNonFingerprintedProcessorSettings(procNode, processorDTO); if (config.getSchedulingStrategy() != null) { procNode.setSchedulingStrategy(SchedulingStrategy.valueOf(config.getSchedulingStrategy())); if (config.getExecutionNode() != null) { procNode.setExecutionNode(ExecutionNode.valueOf(config.getExecutionNode())); procNode.setMaxConcurrentTasks(config.getConcurrentlySchedulableTaskCount()); procNode.setScheduldingPeriod(config.getSchedulingPeriod()); if (config.getRunDurationMillis() != null) { procNode.setRunDuration(config.getRunDurationMillis(), TimeUnit.MILLISECONDS); procNode.setAnnotationData(config.getAnnotationData()); if (config.getAutoTerminatedRelationships() != null) { final Set<Relationship> relationships = new HashSet<>(); for (final String rel : config.getAutoTerminatedRelationships()) { relationships.add(procNode.getRelationship(rel)); procNode.setProperties(config.getProperties());
map.put(ID_KEY, processorDTO.getId()); map.put(CLASS_KEY, processorDTO.getType()); map.put(SCHEDULING_STRATEGY_KEY, processorDTOConfig.getSchedulingStrategy()); map.put(SCHEDULING_PERIOD_KEY, processorDTOConfig.getSchedulingPeriod()); map.put(CommonPropertyKeys.MAX_CONCURRENT_TASKS_KEY, processorDTOConfig.getConcurrentlySchedulableTaskCount()); map.put(ProcessorSchema.PENALIZATION_PERIOD_KEY, processorDTOConfig.getPenaltyDuration()); map.put(CommonPropertyKeys.YIELD_PERIOD_KEY, processorDTOConfig.getYieldDuration()); Long runDurationMillis = processorDTOConfig.getRunDurationMillis(); if (runDurationMillis != null) { map.put(ProcessorSchema.RUN_DURATION_NANOS_KEY, runDurationMillis * 1000); .map(RelationshipDTO::getName) .collect(Collectors.toList())); map.put(PROPERTIES_KEY, new HashMap<>(nullToEmpty(processorDTOConfig.getProperties()))); String annotationData = processorDTOConfig.getAnnotationData(); if(annotationData != null && !annotationData.isEmpty()) { map.put(ANNOTATION_DATA_KEY, annotationData);
Map<String, PropertyDescriptorDTO> map = processorDTO.getConfig().getDescriptors(); Map<String, String> props = processorDTO.getConfig().getProperties(); for (Entry<String, PropertyDescriptorDTO> entry : map.entrySet()) { if (entry.getValue().getIdentifiesControllerService() != null && props.get(entry.getKey()) != null) {
AuthorizeControllerServiceReference.authorizeControllerServiceReferences(config.getProperties(), authorizable, authorizer, lookup);
private Map<String,ComponentDescriptor> buildComponentDescriptorMap(final ProcessorConfigDTO processorConfig){ final Map<String, ComponentDescriptor> descriptors = new HashMap<>(); for(String key : processorConfig.getDescriptors().keySet()){ PropertyDescriptorDTO descriptor = processorConfig.getDescriptors().get(key); List<AllowableValueEntity> allowableValuesEntity = descriptor.getAllowableValues(); Map<String,String> allowableValues = new HashMap<>(); if(allowableValuesEntity != null) { for (AllowableValueEntity allowableValueEntity : allowableValuesEntity) { final AllowableValueDTO allowableValueDTO = allowableValueEntity.getAllowableValue(); allowableValues.put(allowableValueDTO.getValue(), allowableValueDTO.getDisplayName()); } } ComponentDescriptor componentDescriptor = new ComponentDescriptor.Builder() .name(descriptor.getName()) .displayName(descriptor.getDisplayName()) .defaultValue(descriptor.getDefaultValue()) .allowableValues(allowableValues) .build(); descriptors.put(key,componentDescriptor); } return descriptors; }
if (isAnyNotNull(configDTO.getAnnotationData(), configDTO.getAutoTerminatedRelationships(), configDTO.getBulletinLevel(), configDTO.getComments(), configDTO.getConcurrentlySchedulableTaskCount(), configDTO.getPenaltyDuration(), configDTO.getProperties(), configDTO.getSchedulingPeriod(), configDTO.getSchedulingStrategy(), configDTO.getExecutionNode(), configDTO.getYieldDuration())) {
if (config != null && config.getProperties() != null) { AuthorizeControllerServiceReference.authorizeControllerServiceReferences(config.getProperties(), authorizable, authorizer, lookup);