@SuppressWarnings("unchecked") private CloudServiceInstance mapServiceInstanceResource(Map<String, Object> resource) { CloudServiceInstance serviceInstance = new CloudServiceInstance(getMeta(resource), getNameOfResource(resource)); serviceInstance.setType(getEntityAttribute(resource, "type", String.class)); serviceInstance.setDashboardUrl(getEntityAttribute(resource, "dashboard_url", String.class)); serviceInstance.setCredentials(getEntityAttribute(resource, "credentials", Map.class)); Map<String, Object> servicePlanResource = getEmbeddedResource(resource, "service_plan"); serviceInstance.setServicePlan(mapServicePlanResource(servicePlanResource)); CloudService service = mapServiceResource(resource); serviceInstance.setService(service); List<Map<String, Object>> bindingsResource = getEmbeddedResourceList(getEntity(resource), "service_bindings"); List<CloudServiceBinding> bindings = new ArrayList<>(bindingsResource.size()); for (Map<String, Object> bindingResource : bindingsResource) { bindings.add(mapServiceBinding(bindingResource)); } serviceInstance.setBindings(bindings); return serviceInstance; }
private List<CloudServiceBinding> getServiceBindings(CloudControllerClient client, CloudServiceExtended service) { CloudServiceInstance serviceInstance = client.getServiceInstance(service.getName()); return serviceInstance.getBindings(); }
private String buildNewExceptionMessage(Exception e, CloudServiceInstance serviceInstance, String serviceName) { if (serviceInstance == null) { return MessageFormat.format(Messages.ERROR_DELETING_SERVICE_SHORT, serviceName, e.getMessage()); } CloudService service = serviceInstance.getService(); return MessageFormat.format(Messages.ERROR_DELETING_SERVICE, service.getName(), service.getLabel(), service.getPlan(), e.getMessage()); }
if (existingServiceInstance != null && shouldUpdateCredentials(service, existingServiceInstance.getCredentials())) { getStepLogger().debug("Service parameters should be updated"); getStepLogger().debug("New parameters: " + secureSerializer.toJson(service.getCredentials())); getStepLogger().debug("Existing service parameters: " + secureSerializer.toJson(existingServiceInstance.getCredentials())); actions.add(ServiceAction.UPDATE_CREDENTIALS);
if (existingServiceInstance != null && shouldUpdateCredentials(service, existingServiceInstance.getCredentials())) { getStepLogger().debug("Service parameters should be updated"); getStepLogger().debug("New parameters: " + secureSerializer.toJson(service.getCredentials())); getStepLogger().debug("Existing service parameters: " + secureSerializer.toJson(existingServiceInstance.getCredentials())); actions.add(ServiceAction.UPDATE_CREDENTIALS);
@SuppressWarnings("unchecked") private CloudServiceInstance mapServiceInstanceResource(Map<String, Object> resource) { CloudServiceInstance serviceInstance = new CloudServiceInstance(getV2Meta(resource), getNameOfV2Resource(resource)); serviceInstance.setType(getAttributeOfV2Resource(resource, "type", String.class)); serviceInstance.setDashboardUrl(getAttributeOfV2Resource(resource, "dashboard_url", String.class)); serviceInstance.setCredentials(getAttributeOfV2Resource(resource, "credentials", Map.class)); Map<String, Object> servicePlanResource = getEmbeddedResource(resource, "service_plan"); if (servicePlanResource != null) { serviceInstance.setServicePlan(mapServicePlanResource(servicePlanResource)); } CloudService service = mapServiceResource(resource); serviceInstance.setService(service); List<Map<String, Object>> bindingsResource = getEmbeddedResourceList(getEntity(resource), "service_bindings"); List<CloudServiceBinding> bindings = new ArrayList<>(bindingsResource.size()); for (Map<String, Object> bindingResource : bindingsResource) { bindings.add(mapServiceBinding(bindingResource)); } serviceInstance.setBindings(bindings); return serviceInstance; }
private List<CloudServiceBinding> getServiceBindings(CloudControllerClient client, CloudServiceExtended service) { CloudServiceInstance serviceInstance = client.getServiceInstance(service.getName()); return serviceInstance.getBindings(); }
private String buildNewExceptionMessage(Exception e, CloudServiceInstance serviceInstance, String serviceName) { if (serviceInstance == null) { return MessageFormat.format(Messages.ERROR_DELETING_SERVICE_SHORT, serviceName, e.getMessage()); } CloudService service = serviceInstance.getService(); return MessageFormat.format(Messages.ERROR_DELETING_SERVICE, service.getName(), service.getLabel(), service.getPlan(), e.getMessage()); }
try { CloudServiceInstance instance = client.getServiceInstance(service); List<CloudServiceBinding> bindings = (instance != null) ? instance.getBindings() : null; shouldDelete = bindings == null || bindings.isEmpty();
private void unbindService(CloudControllerClient client, String serviceName) { CloudServiceInstance serviceInstance = client.getServiceInstance(serviceName); List<CloudServiceBinding> bindings = serviceInstance.getBindings(); if (bindings.isEmpty()) { return; } logBindings(bindings); for (CloudServiceBinding binding : bindings) { CloudApplication application = StepsUtil.getBoundApplication(client.getApplications(), binding.getAppGuid()); getStepLogger().info(Messages.UNBINDING_APP_FROM_SERVICE, application.getName(), serviceName); client.unbindService(application.getName(), serviceName); } }
private void unbindService(CloudControllerClient client, String serviceName) { CloudServiceInstance serviceInstance = client.getServiceInstance(serviceName); List<CloudServiceBinding> bindings = serviceInstance.getBindings(); if (bindings.isEmpty()) { return; } logBindings(bindings); for (CloudServiceBinding binding : bindings) { CloudApplication application = StepsUtil.getBoundApplication(client.getApplications(), binding.getAppGuid()); getStepLogger().info(Messages.UNBINDING_APP_FROM_SERVICE, application.getName(), serviceName); client.unbindService(application.getName(), serviceName); } }
.getBindings(); CloudServiceBinding existingBindingForApplication = getServiceBindingsForApplication(existingApp, existingServiceBindings); if (existingBindingForApplication == null) {
.getBindings(); CloudServiceBinding existingBindingForApplication = getServiceBindingsForApplication(existingApp, existingServiceBindings); if (existingBindingForApplication == null) {