public <T> T executeServiceOperation(CloudServiceExtended service, Supplier<T> serviceOperation, StepLogger stepLogger) { try { return serviceOperation.get(); } catch (CloudOperationException e) { if (!service.isOptional()) { if (e.getStatusCode() == HttpStatus.BAD_GATEWAY) { throw new CloudServiceBrokerException(e); } throw new CloudControllerException(e); } stepLogger.warn(e, Messages.COULD_NOT_EXECUTE_OPERATION_OVER_OPTIONAL_SERVICE, service.getName()); return null; } }
public <T> T executeServiceOperation(CloudServiceExtended service, Supplier<T> serviceOperation, StepLogger stepLogger) { try { return serviceOperation.get(); } catch (CloudOperationException e) { if (!service.isOptional()) { if (e.getStatusCode() == HttpStatus.BAD_GATEWAY) { throw new CloudServiceBrokerException(e); } throw new CloudControllerException(e); } stepLogger.warn(e, Messages.COULD_NOT_EXECUTE_OPERATION_OVER_OPTIONAL_SERVICE, service.getName()); return null; } }
private CloudOperationException evaluateCloudOperationException(CloudOperationException e, String serviceName) { if (e.getStatusCode() == HttpStatus.NOT_FOUND) { getStepLogger().warn(e, Messages.COULD_NOT_DELETE_SERVICE, serviceName); return null; } if (e.getStatusCode() == HttpStatus.BAD_GATEWAY) { return new CloudServiceBrokerException(e); } return new CloudControllerException(e); }
private CloudOperationException evaluateCloudOperationException(CloudOperationException e, String serviceName) { if (e.getStatusCode() == HttpStatus.NOT_FOUND) { getStepLogger().warn(e, Messages.COULD_NOT_DELETE_SERVICE, serviceName); return null; } if (e.getStatusCode() == HttpStatus.BAD_GATEWAY) { return new CloudServiceBrokerException(e); } return new CloudControllerException(e); }
private void createServiceBroker(DelegateExecution context, CloudServiceBrokerExtended serviceBroker, CloudControllerClient client) { try { getStepLogger().info(MessageFormat.format(Messages.CREATING_SERVICE_BROKER, serviceBroker.getName())); serviceBrokerCreator.createServiceBroker(client, serviceBroker); getStepLogger().debug(MessageFormat.format(Messages.CREATED_SERVICE_BROKER, serviceBroker.getName())); } catch (CloudOperationException e) { switch (e.getStatusCode()) { case FORBIDDEN: if (shouldSucceed(context)) { getStepLogger().warn(Messages.CREATE_OF_SERVICE_BROKERS_FAILED_403, serviceBroker.getName()); return; } throw new CloudServiceBrokerException(e); case BAD_GATEWAY: throw new CloudServiceBrokerException(e); default: throw e; } } }
private void processServiceCreationFailure(CloudServiceExtended service, CloudOperationException e) { if (!service.isOptional()) { if (e.getStatusCode() == HttpStatus.BAD_GATEWAY) { throw new CloudServiceBrokerException(e); } throw new CloudControllerException(e); } getStepLogger().warn(e, Messages.COULD_NOT_EXECUTE_OPERATION_OVER_OPTIONAL_SERVICE, service.getName()); }
private void createServiceBroker(DelegateExecution context, CloudServiceBrokerExtended serviceBroker, CloudControllerClient client) { try { getStepLogger().info(MessageFormat.format(Messages.CREATING_SERVICE_BROKER, serviceBroker.getName())); serviceBrokerCreator.createServiceBroker(client, serviceBroker); getStepLogger().debug(MessageFormat.format(Messages.CREATED_SERVICE_BROKER, serviceBroker.getName())); } catch (CloudOperationException e) { switch (e.getStatusCode()) { case FORBIDDEN: if (shouldSucceed(context)) { getStepLogger().warn(Messages.CREATE_OF_SERVICE_BROKERS_FAILED_403, serviceBroker.getName()); return; } throw new CloudServiceBrokerException(e); case BAD_GATEWAY: throw new CloudServiceBrokerException(e); default: throw e; } } }
private void processServiceCreationFailure(CloudServiceExtended service, CloudOperationException e) { if (!service.isOptional()) { if (e.getStatusCode() == HttpStatus.BAD_GATEWAY) { throw new CloudServiceBrokerException(e); } throw new CloudControllerException(e); } getStepLogger().warn(e, Messages.COULD_NOT_EXECUTE_OPERATION_OVER_OPTIONAL_SERVICE, service.getName()); }
protected void updateServiceBroker(DelegateExecution context, CloudServiceBroker serviceBroker, CloudControllerClient client) { try { getStepLogger().info(MessageFormat.format(Messages.UPDATING_SERVICE_BROKER, serviceBroker.getName())); client.updateServiceBroker(serviceBroker); getStepLogger().debug(MessageFormat.format(Messages.UPDATED_SERVICE_BROKER, serviceBroker.getName())); } catch (CloudOperationException e) { switch (e.getStatusCode()) { case NOT_IMPLEMENTED: getStepLogger().warn(Messages.UPDATE_OF_SERVICE_BROKERS_FAILED_501, serviceBroker.getName()); break; case FORBIDDEN: if (shouldSucceed(context)) { getStepLogger().warn(Messages.UPDATE_OF_SERVICE_BROKERS_FAILED_403, serviceBroker.getName()); return; } throw new CloudServiceBrokerException(e); case BAD_GATEWAY: throw new CloudServiceBrokerException(e); default: throw e; } } }
protected void updateServiceBroker(DelegateExecution context, CloudServiceBroker serviceBroker, CloudControllerClient client) { try { getStepLogger().info(MessageFormat.format(Messages.UPDATING_SERVICE_BROKER, serviceBroker.getName())); client.updateServiceBroker(serviceBroker); getStepLogger().debug(MessageFormat.format(Messages.UPDATED_SERVICE_BROKER, serviceBroker.getName())); } catch (CloudOperationException e) { switch (e.getStatusCode()) { case NOT_IMPLEMENTED: getStepLogger().warn(Messages.UPDATE_OF_SERVICE_BROKERS_FAILED_501, serviceBroker.getName()); break; case FORBIDDEN: if (shouldSucceed(context)) { getStepLogger().warn(Messages.UPDATE_OF_SERVICE_BROKERS_FAILED_403, serviceBroker.getName()); return; } throw new CloudServiceBrokerException(e); case BAD_GATEWAY: throw new CloudServiceBrokerException(e); default: throw e; } } }
private void deleteServiceBrokerIfNecessary(DelegateExecution context, CloudApplication app, List<String> serviceBrokersToCreate, CloudControllerClient client) { ApplicationAttributes appAttributes = ApplicationAttributes.fromApplication(app); if (!appAttributes.get(SupportedParameters.CREATE_SERVICE_BROKER, Boolean.class, false)) { return; } String name = appAttributes.get(SupportedParameters.SERVICE_BROKER_NAME, String.class, app.getName()); CloudServiceBroker serviceBroker = client.getServiceBroker(name, false); if (serviceBroker != null && !serviceBrokersToCreate.contains(name)) { try { getStepLogger().info(MessageFormat.format(Messages.DELETING_SERVICE_BROKER, name, app.getName())); client.deleteServiceBroker(name); getStepLogger().debug(MessageFormat.format(Messages.DELETED_SERVICE_BROKER, name, app.getName())); } catch (CloudOperationException e) { switch (e.getStatusCode()) { case FORBIDDEN: if (shouldSucceed(context)) { getStepLogger().warn(Messages.DELETE_OF_SERVICE_BROKERS_FAILED_403, name); return; } throw new CloudServiceBrokerException(e); case BAD_GATEWAY: throw new CloudServiceBrokerException(e); default: throw e; } } } }
private void deleteServiceBrokerIfNecessary(DelegateExecution context, CloudApplication app, List<String> serviceBrokersToCreate, CloudControllerClient client) { ApplicationAttributes appAttributes = ApplicationAttributes.fromApplication(app); if (!appAttributes.get(SupportedParameters.CREATE_SERVICE_BROKER, Boolean.class, false)) { return; } String name = appAttributes.get(SupportedParameters.SERVICE_BROKER_NAME, String.class, app.getName()); CloudServiceBroker serviceBroker = client.getServiceBroker(name, false); if (serviceBroker != null && !serviceBrokersToCreate.contains(name)) { try { getStepLogger().info(MessageFormat.format(Messages.DELETING_SERVICE_BROKER, name, app.getName())); client.deleteServiceBroker(name); getStepLogger().debug(MessageFormat.format(Messages.DELETED_SERVICE_BROKER, name, app.getName())); } catch (CloudOperationException e) { switch (e.getStatusCode()) { case FORBIDDEN: if (shouldSucceed(context)) { getStepLogger().warn(Messages.DELETE_OF_SERVICE_BROKERS_FAILED_403, name); return; } throw new CloudServiceBrokerException(e); case BAD_GATEWAY: throw new CloudServiceBrokerException(e); default: throw e; } } } }