@Override public boolean deleteServiceDefinition(String serviceDefinitionId) { if (!serviceRepository.exists(serviceDefinitionId)) { return false; } ServiceDefinition serviceDefinition = serviceRepository.findOne(serviceDefinitionId); if (planRepository.countByServiceDefinition(serviceDefinition) > 0) { throw new IllegalStateException( "Can not remove service instance, the instance has plans associated to it"); } serviceRepository.delete(serviceDefinitionId); return true; }
@Override public List<ServiceDefinition> listServices() { return makeCollection(serviceRepository.findAll()); }
@Override public ServiceDefinition createServiceDefinition(ServiceDefinition serviceDefinition) { return serviceRepository.save(serviceDefinition); }