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); } } } } }
public static void merge(PropertyDescriptorDTO clientPropertyDescriptor, Map<NodeIdentifier, PropertyDescriptorDTO> dtoMap) { final Map<Integer, List<AllowableValueEntity>> allowableValueMap = new HashMap<>(); // values are guaranteed to be in order, so map each allowable value for each property descriptor across all node IDs to the index of the value in the descriptor's list of allowable values for (final Map.Entry<NodeIdentifier, PropertyDescriptorDTO> nodeEntry : dtoMap.entrySet()) { final PropertyDescriptorDTO nodePropertyDescriptor = nodeEntry.getValue(); final List<AllowableValueEntity> nodePropertyDescriptorAllowableValues = nodePropertyDescriptor.getAllowableValues(); if (nodePropertyDescriptorAllowableValues != null) { nodePropertyDescriptorAllowableValues.stream().forEach(allowableValueEntity -> { allowableValueMap.computeIfAbsent(nodePropertyDescriptorAllowableValues.indexOf(allowableValueEntity), propertyDescriptorToAllowableValue -> new ArrayList<>()) .add(allowableValueEntity); }); } } // for each AllowableValueEntity in this PropertyDescriptorDTO, get the corresponding AVs previously aggregated and merge them. final List<AllowableValueEntity> clientPropertyDescriptorAllowableValues = clientPropertyDescriptor.getAllowableValues(); if (clientPropertyDescriptorAllowableValues != null) { for (AllowableValueEntity clientAllowableValueEntity : clientPropertyDescriptorAllowableValues) { AllowableValueEntityMerger.merge(clientAllowableValueEntity, allowableValueMap.get(clientPropertyDescriptorAllowableValues.indexOf(clientAllowableValueEntity))); } } } }
/** * The only thing that we really need from the Property Descriptors in the templates is the * flag that indicates whether or not the property identifies a controller service. * Everything else is unneeded and makes templates very verbose and more importantly makes it * so that if one of these things changes, the template itself changes, which makes it hard to * use a CM tool for versioning. So we remove all that we don't need. * * @param descriptor the PropertyDescriptor to scrub */ private static void scrubPropertyDescriptor(final PropertyDescriptorDTO descriptor) { descriptor.setAllowableValues(null); descriptor.setDefaultValue(null); descriptor.setDescription(null); descriptor.setDisplayName(null); descriptor.setDynamic(null); descriptor.setRequired(null); descriptor.setSensitive(null); descriptor.setSupportsEl(null); descriptor.setExpressionLanguageScope(null); descriptor.setIdentifiesControllerServiceBundle(null); }
final PropertyDescriptorDTO dto = new PropertyDescriptorDTO(); dto.setName(propertyDescriptor.getName()); dto.setDisplayName(propertyDescriptor.getDisplayName()); dto.setRequired(propertyDescriptor.isRequired()); dto.setSensitive(propertyDescriptor.isSensitive()); dto.setDynamic(propertyDescriptor.isDynamic()); dto.setDescription(propertyDescriptor.getDescription()); dto.setDefaultValue(propertyDescriptor.getDefaultValue()); dto.setSupportsEl(propertyDescriptor.isExpressionLanguageSupported()); && propertyDescriptor.getExpressionLanguageScope().equals(ExpressionLanguageScope.NONE) ? "true (undefined scope)" : propertyDescriptor.getExpressionLanguageScope().getDescription(); dto.setExpressionLanguageScope(description); dto.setIdentifiesControllerService(serviceClass.getName()); dto.setIdentifiesControllerServiceBundle(createBundleDto(serviceBundle.getBundleDetails().getCoordinate())); if (propertyDescriptor.getAllowableValues() == null) { if (serviceDefinition == null) { dto.setAllowableValues(null); } else { final List<AllowableValueEntity> allowableValues = new ArrayList<>(); dto.setAllowableValues(allowableValues); dto.setAllowableValues(allowableValues);
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; }
final ControllerServiceReferencingComponentEntity nodeEntity = entry.getValue(); nodeEntity.getComponent().getDescriptors().values().stream().forEach(propertyDescriptor -> { propertyDescriptorMap.computeIfAbsent(propertyDescriptor.getName(), nodeIdToPropertyDescriptor -> new HashMap<>()).put(nodeIdentifier, propertyDescriptor); }); nodeReferencingComponentsMap.put(nodeIdentifier, nodeEntity.getComponent().getReferencingComponents()); final PropertyDescriptorDTO clientPropertyDescriptor = clientEntity.getComponent().getDescriptors().get(propertyDescriptor.getName()); PropertyDescriptorDtoMerger.merge(clientPropertyDescriptor, propertyDescriptorByNodeId);
private static void scrubControllerServices(final Set<ControllerServiceDTO> controllerServices) { for (final ControllerServiceDTO serviceDTO : controllerServices) { final Map<String, String> properties = serviceDTO.getProperties(); final Map<String, PropertyDescriptorDTO> descriptors = serviceDTO.getDescriptors(); if (properties != null && descriptors != null) { for (final PropertyDescriptorDTO descriptor : descriptors.values()) { if (Boolean.TRUE.equals(descriptor.isSensitive())) { properties.put(descriptor.getName(), null); } scrubPropertyDescriptor(descriptor); } } serviceDTO.setControllerServiceApis(null); serviceDTO.setExtensionMissing(null); serviceDTO.setMultipleVersionsAvailable(null); serviceDTO.setCustomUiUrl(null); serviceDTO.setValidationErrors(null); serviceDTO.setValidationStatus(null); } }
Map<String, String> props = csDTO.getProperties(); for (Entry<String, PropertyDescriptorDTO> entry : map.entrySet()) { if (entry.getValue().getIdentifiesControllerService() != null && props.get(entry.getKey()) != null) { String key = entry.getKey(); String value = props.get(key); Map<String, String> props = processorDTO.getConfig().getProperties(); for (Entry<String, PropertyDescriptorDTO> entry : map.entrySet()) { if (entry.getValue().getIdentifiesControllerService() != null && props.get(entry.getKey()) != null) { String key = entry.getKey(); String value = props.get(key);
propertyDescriptorMap.computeIfAbsent(propertyDescriptor.getName(), nodeIdToPropertyDescriptor -> new HashMap<>()).put(nodeId, propertyDescriptor); }); final PropertyDescriptorDTO clientPropertyDescriptor = clientDto.getDescriptors().get(propertyDescriptor.getName()); PropertyDescriptorDtoMerger.merge(clientPropertyDescriptor, propertyDescriptorByNodeId);
final Collection<PropertyDescriptorDTO> descriptors = processorConfig.getDescriptors().values(); for (PropertyDescriptorDTO descriptor : descriptors) { if (Boolean.TRUE.equals(descriptor.isSensitive())) { processorProperties.put(descriptor.getName(), null);
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; properties.put(descriptor.getName(), newServiceId);
propertyDescriptorMap.computeIfAbsent(propertyDescriptor.getName(), nodeIdToPropertyDescriptor -> new HashMap<>()).put(nodeId, propertyDescriptor); }); final PropertyDescriptorDTO clientPropertyDescriptor = clientDto.getConfig().getDescriptors().get(propertyDescriptor.getName()); PropertyDescriptorDtoMerger.merge(clientPropertyDescriptor, propertyDescriptorByNodeId);
if (descriptors != null) { descriptors.values().stream().forEach(propertyDescriptor -> { propertyDescriptorMap.computeIfAbsent(propertyDescriptor.getName(), nodeIdToPropertyDescriptor -> new HashMap<>()).put(nodeId, propertyDescriptor); }); final PropertyDescriptorDTO clientPropertyDescriptor = clientDto.getDescriptors().get(propertyDescriptor.getName()); PropertyDescriptorDtoMerger.merge(clientPropertyDescriptor, propertyDescriptorByNodeId);