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

return correct errors

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