Commit 5fa4e769 authored by Spiros Koulouzis's avatar Spiros Koulouzis

added null check

parent 0c872925
...@@ -89,6 +89,9 @@ public class ConfigurationService { ...@@ -89,6 +89,9 @@ public class ConfigurationService {
@PostAuthorize("(returnObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))") @PostAuthorize("(returnObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))")
public ConfigurationRepresentation delete(String id) { public ConfigurationRepresentation delete(String id) {
ConfigurationRepresentation tr = dao.findOne(id); ConfigurationRepresentation tr = dao.findOne(id);
if(tr == null){
throw new NotFoundException();
}
dao.delete(tr); dao.delete(tr);
return tr; return tr;
} }
......
...@@ -250,18 +250,20 @@ public class ProvisionService { ...@@ -250,18 +250,20 @@ public class ProvisionService {
parameters.add(topology); parameters.add(topology);
Set<String> ids = plan.getLoweLevelPlanIDs(); Set<String> ids = plan.getLoweLevelPlanIDs();
for (String lowID : ids) { if (ids != null) {
PlanResponse lowPlan = planService.getDao().findOne(lowID); for (String lowID : ids) {
topology = new MessageParameter(); PlanResponse lowPlan = planService.getDao().findOne(lowID);
topology.setName("topology"); topology = new MessageParameter();
String value = Converter.map2YmlString(lowPlan.getKeyValue()); topology.setName("topology");
value = value.replaceAll("\\uff0E", "."); String value = Converter.map2YmlString(lowPlan.getKeyValue());
topology.setValue(value); value = value.replaceAll("\\uff0E", ".");
attributes = new HashMap<>(); topology.setValue(value);
attributes.put("level", String.valueOf(lowPlan.getLevel())); attributes = new HashMap<>();
attributes.put("filename", FilenameUtils.removeExtension(lowPlan.getName())); attributes.put("level", String.valueOf(lowPlan.getLevel()));
topology.setAttributes(attributes); attributes.put("filename", FilenameUtils.removeExtension(lowPlan.getName()));
parameters.add(topology); topology.setAttributes(attributes);
parameters.add(topology);
}
} }
return parameters; return parameters;
} }
......
...@@ -135,11 +135,16 @@ public class ConfigurationController { ...@@ -135,11 +135,16 @@ public class ConfigurationController {
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE) @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
@RolesAllowed({UserService.USER, UserService.ADMIN}) @RolesAllowed({UserService.USER, UserService.ADMIN})
@StatusCodes({ @StatusCodes({
@ResponseCode(code = 200, condition = "Successful delete") @ResponseCode(code = 200, condition = "Successful delete"),
@ResponseCode(code = 404, condition = "Object not found")
}) })
public @ResponseBody public @ResponseBody
String delete(@PathVariable("id") String id) { String delete(@PathVariable("id") String id) {
configurationService.delete(id); try {
configurationService.delete(id);
} catch (NotFoundException ex) {
throw ex;
}
return "Deleted : " + id; return "Deleted : " + id;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment