Commit 07b2988e authored by Spiros Koulouzis's avatar Spiros Koulouzis

return correct errors

parent 630f2716
...@@ -47,8 +47,10 @@ public class CredentialApiController implements CredentialApi { ...@@ -47,8 +47,10 @@ public class CredentialApiController implements CredentialApi {
if (accept != null && accept.contains("application/json")) { if (accept != null && accept.contains("application/json")) {
String id = credentialService.save(body); String id = credentialService.save(body);
return new ResponseEntity<>(id, HttpStatus.OK); return new ResponseEntity<>(id, HttpStatus.OK);
} else {
return new ResponseEntity<>(HttpStatus.NOT_ACCEPTABLE);
} }
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
} }
@Override @Override
......
...@@ -52,7 +52,9 @@ public class DeployerApiController implements DeployerApi { ...@@ -52,7 +52,9 @@ public class DeployerApiController implements DeployerApi {
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
} }
} else {
return new ResponseEntity<>(HttpStatus.NOT_ACCEPTABLE);
} }
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
} }
} }
...@@ -2,6 +2,8 @@ package nl.uva.sne.drip.api; ...@@ -2,6 +2,8 @@ package nl.uva.sne.drip.api;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import java.io.IOException;
import java.util.concurrent.TimeoutException;
import java.util.logging.Level; import java.util.logging.Level;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -41,19 +43,20 @@ public class PlannerApiController implements PlannerApi { ...@@ -41,19 +43,20 @@ public class PlannerApiController implements PlannerApi {
@PathVariable("id") String id) { @PathVariable("id") String id) {
String accept = request.getHeader("Accept"); String accept = request.getHeader("Accept");
if (accept != null && accept.contains("text/plain")) { if (accept != null && accept.contains("text/plain")) {
try { try {
dripService.setRequestQeueName(queueName); dripService.setRequestQeueName(queueName);
String planedYemplateId = dripService.plan(id); String planedYemplateId = dripService.plan(id);
return new ResponseEntity<>(planedYemplateId, HttpStatus.OK); return new ResponseEntity<>(planedYemplateId, HttpStatus.OK);
} catch (ApiException ex) { } catch (ApiException | NotFoundException | IOException | TimeoutException | InterruptedException ex) {
java.util.logging.Logger.getLogger(PlannerApiController.class.getName()).log(Level.SEVERE, null, ex);
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
} catch (Exception ex) {
java.util.logging.Logger.getLogger(PlannerApiController.class.getName()).log(Level.SEVERE, null, ex); java.util.logging.Logger.getLogger(PlannerApiController.class.getName()).log(Level.SEVERE, null, ex);
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
} }
} else {
return new ResponseEntity<>(HttpStatus.NOT_ACCEPTABLE);
} }
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
} }
} }
...@@ -56,9 +56,9 @@ public class ProvisionerApiController implements ProvisionerApi { ...@@ -56,9 +56,9 @@ public class ProvisionerApiController implements ProvisionerApi {
java.util.logging.Logger.getLogger(ProvisionerApiController.class.getName()).log(Level.SEVERE, null, ex); java.util.logging.Logger.getLogger(ProvisionerApiController.class.getName()).log(Level.SEVERE, null, ex);
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
} }
} else {
return new ResponseEntity<>(HttpStatus.NOT_ACCEPTABLE);
} }
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
} }
} }
...@@ -43,28 +43,28 @@ public class ToscaTemplateApiController implements ToscaTemplateApi { ...@@ -43,28 +43,28 @@ public class ToscaTemplateApiController implements ToscaTemplateApi {
if (accept != null && accept.contains("*/*")) { if (accept != null && accept.contains("*/*")) {
toscaTemplateService.deleteByID(id); toscaTemplateService.deleteByID(id);
return new ResponseEntity<>("", HttpStatus.OK); return new ResponseEntity<>("", HttpStatus.OK);
} else {
return new ResponseEntity<>(HttpStatus.NOT_ACCEPTABLE);
} }
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
} }
@Override @Override
public ResponseEntity<String> getToscaTemplateByID(@ApiParam(value = "ID of topolog template to return", required = true) @PathVariable("id") String id) { public ResponseEntity<String> getToscaTemplateByID(@ApiParam(value = "ID of topolog template to return", required = true) @PathVariable("id") String id) {
String accept = request.getHeader("Accept"); String accept = request.getHeader("Accept");
if (accept != null && accept.contains("text/plain")) { if (accept != null && accept.contains("text/plain")) {
try { try {
String ymlStr = toscaTemplateService.findByID(id); String ymlStr = toscaTemplateService.findByID(id);
return new ResponseEntity<>(ymlStr, HttpStatus.OK); return new ResponseEntity<>(ymlStr, HttpStatus.OK);
} catch (IOException e) { } catch (JsonProcessingException | NotFoundException ex) {
log.error("Couldn't serialize response for content type ", e);
java.util.logging.Logger.getLogger(ToscaTemplateApiController.class.getName()).log(Level.SEVERE, null, e);
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
} catch (NotFoundException ex) {
java.util.logging.Logger.getLogger(ToscaTemplateApiController.class.getName()).log(Level.SEVERE, null, ex); java.util.logging.Logger.getLogger(ToscaTemplateApiController.class.getName()).log(Level.SEVERE, null, ex);
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
} }
} else {
return new ResponseEntity<>(HttpStatus.NOT_ACCEPTABLE);
} }
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
} }
@Override @Override
...@@ -82,9 +82,10 @@ public class ToscaTemplateApiController implements ToscaTemplateApi { ...@@ -82,9 +82,10 @@ public class ToscaTemplateApiController implements ToscaTemplateApi {
java.util.logging.Logger.getLogger(ToscaTemplateApiController.class.getName()).log(Level.SEVERE, null, e); java.util.logging.Logger.getLogger(ToscaTemplateApiController.class.getName()).log(Level.SEVERE, null, e);
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
} }
} else {
return new ResponseEntity<>(HttpStatus.NOT_ACCEPTABLE);
} }
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
} }
@Override @Override
...@@ -99,9 +100,10 @@ public class ToscaTemplateApiController implements ToscaTemplateApi { ...@@ -99,9 +100,10 @@ public class ToscaTemplateApiController implements ToscaTemplateApi {
log.error("Couldn't serialize response for content type application/json", e); log.error("Couldn't serialize response for content type application/json", e);
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
} }
} else {
return new ResponseEntity<>(HttpStatus.NOT_ACCEPTABLE);
} }
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
} }
@Override @Override
...@@ -110,9 +112,10 @@ public class ToscaTemplateApiController implements ToscaTemplateApi { ...@@ -110,9 +112,10 @@ public class ToscaTemplateApiController implements ToscaTemplateApi {
if (accept != null && accept.contains("application/json")) { if (accept != null && accept.contains("application/json")) {
List<String> ids = toscaTemplateService.getAllIds(); List<String> ids = toscaTemplateService.getAllIds();
return new ResponseEntity<>(ids, HttpStatus.NOT_IMPLEMENTED); return new ResponseEntity<>(ids, HttpStatus.NOT_IMPLEMENTED);
} else {
return new ResponseEntity<>(HttpStatus.NOT_ACCEPTABLE);
} }
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
} }
} }
...@@ -107,7 +107,7 @@ public class DRIPService { ...@@ -107,7 +107,7 @@ public class DRIPService {
return toscaTemplate; return toscaTemplate;
} }
public String plan(String id) throws ApiException, Exception { public String plan(String id) throws ApiException, NotFoundException, IOException, JsonProcessingException, TimeoutException, InterruptedException {
ToscaTemplate toscaTemplate = initExecution(id); ToscaTemplate toscaTemplate = initExecution(id);
return execute(toscaTemplate); return execute(toscaTemplate);
} }
......
...@@ -141,7 +141,7 @@ class CloudStormService { ...@@ -141,7 +141,7 @@ class CloudStormService {
topTopology.setTopologies(cloudsStormSubTopology); topTopology.setTopologies(cloudsStormSubTopology);
objectMapper.writeValue(new File(tempInputDirPath + File.separator + TOP_TOPOLOGY_FILE_NAME), topTopology); objectMapper.writeValue(new File(tempInputDirPath + File.separator + TOP_TOPOLOGY_FILE_NAME), topTopology);
Logger.getLogger(CloudStormService.class.getName()).log(Level.INFO, "Wrote CloudStorm topology files in: " + tempInputDirPath + File.separator + TOP_TOPOLOGY_FILE_NAME); Logger.getLogger(CloudStormService.class.getName()).log(Level.INFO, "Wrote CloudStorm topology files in: " + TOP_TOPOLOGY_FILE_NAME, new Object[]{tempInputDirPath, File.separator});
return subTopologiesAndVMs; return subTopologiesAndVMs;
} }
......
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