use of org.guvnor.ala.exceptions.ProvisioningException in project kie-wb-common by kiegroup.
the class OpenShiftProviderConfigExecutor method apply.
@Override
public Optional<OpenShiftProvider> apply(final OpenShiftProviderConfig openshiftProviderConfig) {
if (openshiftProviderConfig.getName() == null || openshiftProviderConfig.getName().isEmpty()) {
throw new ProvisioningException("No name was provided for the OpenShiftProviderConfig.getName() " + "configuration parameter. You might probably have to properly set " + "the pipeline input parameter: " + ProviderConfig.PROVIDER_NAME);
}
Provider provider = runtimeRegistry.getProvider(openshiftProviderConfig.getName());
OpenShiftProvider openshiftProvider;
if (provider != null) {
if (!(provider instanceof OpenShiftProvider)) {
throw new ProvisioningException("The provider: " + openshiftProviderConfig.getName() + " must be an instance of " + OpenShiftProviderConfig.class + " but is: " + provider.getClass());
} else {
openshiftProvider = (OpenShiftProvider) provider;
}
} else {
openshiftProvider = new OpenShiftProviderImpl(openshiftProviderConfig.getName(), openshiftProviderConfig);
runtimeRegistry.registerProvider(openshiftProvider);
}
return Optional.of(openshiftProvider);
}
Aggregations