protected void verifyCreate(final ExtensionManager extensionManager, final String type, final BundleDTO bundle) {
final List<Bundle> bundles = extensionManager.getBundles(type);
if (bundle != null) {
final BundleCoordinate coordinate = new BundleCoordinate(bundle.getGroup(), bundle.getArtifact(), bundle.getVersion());
if (bundles.stream().filter(b -> b.getBundleDetails().getCoordinate().equals(coordinate)).count() == 0) {
throw new IllegalStateException(String.format("%s is not known to this NiFi instance.", coordinate.toString()));
}
} else {
if (bundles.isEmpty()) {
throw new IllegalStateException(String.format("%s is not known to this NiFi instance.", type));
} else if (bundles.size() > 1) {
throw new IllegalStateException(String.format("Multiple versions of %s exist. Please specify the desired bundle.", type));
}
}
}
}