private void verifyControllerServicesInVersionedFlow(final VersionedProcessGroup versionedFlow, final Map<String, Set<BundleCoordinate>> supportedTypes) { if (versionedFlow.getControllerServices() != null) { versionedFlow.getControllerServices().forEach(controllerService -> { if (supportedTypes.containsKey(controllerService.getType())) { if (controllerService.getBundle() == null) { throw new IllegalArgumentException("Controller Service bundle must be specified."); } verifyBundleInVersionedFlow(controllerService.getBundle(), supportedTypes.get(controllerService.getType())); } else { throw new IllegalStateException("Invalid Controller Service Type: " + controllerService.getType()); } }); } if (versionedFlow.getProcessGroups() != null) { versionedFlow.getProcessGroups().forEach(processGroup -> { verifyControllerServicesInVersionedFlow(processGroup, supportedTypes); }); } }
private static void populateComponentTypes(final VersionedProcessGroup group, final Set<Tuple<String, BundleCoordinate>> componentTypes) { group.getProcessors().stream() .map(versionedProc -> new Tuple<>(versionedProc.getType(), createBundleCoordinate(versionedProc.getBundle()))) .forEach(componentTypes::add); group.getControllerServices().stream() .map(versionedSvc -> new Tuple<>(versionedSvc.getType(), createBundleCoordinate(versionedSvc.getBundle()))) .forEach(componentTypes::add); for (final VersionedProcessGroup childGroup : group.getProcessGroups()) { populateComponentTypes(childGroup, componentTypes); } }
final BundleCoordinate serviceToAddCoordinate = toCoordinate(serviceToAdd.getBundle());
private ControllerServiceNode addControllerService(final ProcessGroup destination, final VersionedControllerService proposed, final String componentIdSeed) { final String type = proposed.getType(); final String id = generateUuid(proposed.getIdentifier(), destination.getIdentifier(), componentIdSeed); final Bundle bundle = proposed.getBundle(); final BundleCoordinate coordinate = toCoordinate(bundle); final boolean firstTimeAdded = true; final Set<URL> additionalUrls = Collections.emptySet(); final ControllerServiceNode newService = flowManager.createControllerService(type, id, coordinate, additionalUrls, firstTimeAdded, true); newService.setVersionedComponentId(proposed.getIdentifier()); destination.addControllerService(newService); updateControllerService(newService, proposed); return newService; }
private void updateControllerService(final ControllerServiceNode service, final VersionedControllerService proposed) { service.pauseValidationTrigger(); try { service.setAnnotationData(proposed.getAnnotationData()); service.setComments(proposed.getComments()); service.setName(proposed.getName()); final Map<String, String> properties = populatePropertiesMap(service.getProperties(), proposed.getProperties(), proposed.getPropertyDescriptors(), service.getProcessGroup()); service.setProperties(properties, true); if (!isEqual(service.getBundleCoordinate(), proposed.getBundle())) { final BundleCoordinate newBundleCoordinate = toCoordinate(proposed.getBundle()); final List<PropertyDescriptor> descriptors = new ArrayList<>(service.getProperties().keySet()); final Set<URL> additionalUrls = service.getAdditionalClasspathResources(descriptors); flowController.getReloadComponent().reload(service, proposed.getType(), newBundleCoordinate, additionalUrls); } } finally { service.resumeValidationTrigger(); } }
final BundleCoordinate coordinate = BundleUtils.getCompatibleBundle(extensionManager, controllerService.getType(), createBundleDto(controllerService.getBundle()));