Commit a7f2ee92 authored by Spiros Koulouzis's avatar Spiros Koulouzis

removed accept headers

parent 1a02d6fb
...@@ -12,6 +12,9 @@ spec: ...@@ -12,6 +12,9 @@ spec:
nodePort: 30001 nodePort: 30001
protocol: TCP protocol: TCP
name: https name: https
- port: 80
protocol: TCP
name: http
selector: selector:
io.kompose.service: nginx io.kompose.service: nginx
status: status:
......
...@@ -15,7 +15,6 @@ import org.springframework.web.bind.annotation.RequestBody; ...@@ -15,7 +15,6 @@ import org.springframework.web.bind.annotation.RequestBody;
import javax.validation.Valid; import javax.validation.Valid;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.List; import java.util.List;
import java.util.logging.Level;
import javax.crypto.BadPaddingException; import javax.crypto.BadPaddingException;
import javax.crypto.IllegalBlockSizeException; import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException; import javax.crypto.NoSuchPaddingException;
...@@ -49,26 +48,26 @@ public class CredentialApiController implements CredentialApi { ...@@ -49,26 +48,26 @@ public class CredentialApiController implements CredentialApi {
value = "Created user object", required = true) value = "Created user object", required = true)
@Valid @RequestBody Credential body) { @Valid @RequestBody Credential body) {
String accept = request.getHeader("Accept"); String accept = request.getHeader("Accept");
if (accept != null && accept.contains("application/json")) { // if (accept != null && accept.contains("application/json")) {
try { try {
String id = credentialService.save(body); String id = credentialService.save(body);
return new ResponseEntity<>(id, HttpStatus.OK); return new ResponseEntity<>(id, HttpStatus.OK);
} catch (UnsupportedEncodingException | NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException | IllegalBlockSizeException | BadPaddingException ex) { } catch (UnsupportedEncodingException | NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException | IllegalBlockSizeException | BadPaddingException ex) {
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
} }
} else { // } else {
return new ResponseEntity<>(HttpStatus.NOT_ACCEPTABLE); // return new ResponseEntity<>(HttpStatus.NOT_ACCEPTABLE);
} // }
} }
@Override @Override
public ResponseEntity<List<String>> getCredentialIDs() { public ResponseEntity<List<String>> getCredentialIDs() {
String accept = request.getHeader("Accept"); String accept = request.getHeader("Accept");
if (accept != null && accept.contains("application/json")) { // if (accept != null && accept.contains("application/json")) {
List<String> ids = credentialService.getAllIds(); List<String> ids = credentialService.getAllIds();
return new ResponseEntity<>(ids, HttpStatus.OK); return new ResponseEntity<>(ids, HttpStatus.OK);
} // }
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); // return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
} }
} }
...@@ -53,7 +53,7 @@ public class ToscaTemplateApiController implements ToscaTemplateApi { ...@@ -53,7 +53,7 @@ public class ToscaTemplateApiController implements ToscaTemplateApi {
@PathVariable("id") String id, @ApiParam(value = "The node(s) to delete") @PathVariable("id") String id, @ApiParam(value = "The node(s) to delete")
@Valid @RequestParam(value = "node_names", required = false) List<String> nodeName) { @Valid @RequestParam(value = "node_names", required = false) List<String> nodeName) {
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.delete(id, nodeName); dripService.delete(id, nodeName);
return new ResponseEntity<>(id, HttpStatus.OK); return new ResponseEntity<>(id, HttpStatus.OK);
...@@ -63,15 +63,15 @@ public class ToscaTemplateApiController implements ToscaTemplateApi { ...@@ -63,15 +63,15 @@ public class ToscaTemplateApiController implements ToscaTemplateApi {
} catch (NotFoundException ex) { } catch (NotFoundException ex) {
return new ResponseEntity<>(HttpStatus.NOT_FOUND); return new ResponseEntity<>(HttpStatus.NOT_FOUND);
} }
} else { // } else {
return new ResponseEntity<>(HttpStatus.NOT_ACCEPTABLE); // return new ResponseEntity<>(HttpStatus.NOT_ACCEPTABLE);
} // }
} }
@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);
...@@ -81,9 +81,9 @@ public class ToscaTemplateApiController implements ToscaTemplateApi { ...@@ -81,9 +81,9 @@ public class ToscaTemplateApiController implements ToscaTemplateApi {
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
} }
} else { // } else {
return new ResponseEntity<>(HttpStatus.NOT_ACCEPTABLE); // return new ResponseEntity<>(HttpStatus.NOT_ACCEPTABLE);
} // }
} }
...@@ -93,7 +93,7 @@ public class ToscaTemplateApiController implements ToscaTemplateApi { ...@@ -93,7 +93,7 @@ public class ToscaTemplateApiController implements ToscaTemplateApi {
@PathVariable("id") String id, @ApiParam(value = "file detail") @PathVariable("id") String id, @ApiParam(value = "file detail")
@Valid @RequestPart("file") MultipartFile file) { @Valid @RequestPart("file") MultipartFile file) {
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 {
id = toscaTemplateService.updateToscaTemplateByID(id, file); id = toscaTemplateService.updateToscaTemplateByID(id, file);
return new ResponseEntity<>(id, HttpStatus.OK); return new ResponseEntity<>(id, HttpStatus.OK);
...@@ -102,15 +102,15 @@ public class ToscaTemplateApiController implements ToscaTemplateApi { ...@@ -102,15 +102,15 @@ 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 { // } else {
return new ResponseEntity<>(HttpStatus.NOT_ACCEPTABLE); // return new ResponseEntity<>(HttpStatus.NOT_ACCEPTABLE);
} // }
} }
@Override @Override
public ResponseEntity<String> uploadToscaTemplate(@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file) { public ResponseEntity<String> uploadToscaTemplate(@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file) {
String accept = request.getHeader("Accept"); String accept = request.getHeader("Accept");
if (accept != null && accept.contains("*/*")) { // if (accept != null && accept.contains("*/*")) {
try { try {
String id = toscaTemplateService.saveFile(file); String id = toscaTemplateService.saveFile(file);
return new ResponseEntity<>(id, HttpStatus.OK); return new ResponseEntity<>(id, HttpStatus.OK);
...@@ -119,21 +119,21 @@ public class ToscaTemplateApiController implements ToscaTemplateApi { ...@@ -119,21 +119,21 @@ 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 { // } else {
return new ResponseEntity<>(HttpStatus.NOT_ACCEPTABLE); // return new ResponseEntity<>(HttpStatus.NOT_ACCEPTABLE);
} // }
} }
@Override @Override
public ResponseEntity<List<String>> getToscaTemplateIDs() { public ResponseEntity<List<String>> getToscaTemplateIDs() {
String accept = request.getHeader("Accept"); String accept = request.getHeader("Accept");
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 { // } else {
return new ResponseEntity<>(HttpStatus.NOT_ACCEPTABLE); // return new ResponseEntity<>(HttpStatus.NOT_ACCEPTABLE);
} // }
} }
......
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