diff options
author | niamhcore <niamh.core@est.tech> | 2020-12-11 12:37:35 +0000 |
---|---|---|
committer | niamhcore <niamh.core@est.tech> | 2020-12-11 12:37:35 +0000 |
commit | a0da7f6b3e04ee6f06f4580f8a14e60f3438d5e7 (patch) | |
tree | 58e2b7b641627b27c2b43993293cb45b0f670f70 /cps-rest/src/main | |
parent | e182a6b6cb4a87b4f461adf83fe60a65948fc230 (diff) |
Remove depredcated code/classes
Issue-ID: CPS-93
Signed-off-by: niamhcore <niamh.core@est.tech>
Change-Id: I49db5244400d5eb4206d59e73aaf801b7f90c61c
Diffstat (limited to 'cps-rest/src/main')
-rwxr-xr-x | cps-rest/src/main/java/org/onap/cps/rest/controller/CpsRestController.java | 104 |
1 files changed, 0 insertions, 104 deletions
diff --git a/cps-rest/src/main/java/org/onap/cps/rest/controller/CpsRestController.java b/cps-rest/src/main/java/org/onap/cps/rest/controller/CpsRestController.java index 32ea35c5e0..1802ce7a79 100755 --- a/cps-rest/src/main/java/org/onap/cps/rest/controller/CpsRestController.java +++ b/cps-rest/src/main/java/org/onap/cps/rest/controller/CpsRestController.java @@ -20,31 +20,15 @@ package org.onap.cps.rest.controller; -import com.google.gson.Gson; -import com.google.gson.JsonSyntaxException; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; import java.util.Collection; import javax.validation.Valid; import org.modelmapper.ModelMapper; -import org.onap.cps.api.CpService; import org.onap.cps.api.CpsAdminService; -import org.onap.cps.api.CpsModuleService; import org.onap.cps.rest.api.CpsRestApi; -import org.onap.cps.spi.exceptions.CpsException; -import org.onap.cps.spi.exceptions.DataValidationException; import org.onap.cps.spi.model.Anchor; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; @@ -52,12 +36,6 @@ import org.springframework.web.multipart.MultipartFile; public class CpsRestController implements CpsRestApi { @Autowired - private CpService cpService; - - @Autowired - private CpsModuleService cpsModuleService; - - @Autowired private CpsAdminService cpsAdminService; @Autowired @@ -80,14 +58,6 @@ public class CpsRestController implements CpsRestApi { } @Override - public ResponseEntity<Object> createModules(@Valid final MultipartFile multipartFile, final String dataspaceName) { - final File fileToParse = saveToFile(multipartFile); - final SchemaContext schemaContext = cpsModuleService.parseAndValidateModel(fileToParse); - cpsModuleService.storeSchemaContext(schemaContext, dataspaceName); - return new ResponseEntity<>("Resource successfully created", HttpStatus.CREATED); - } - - @Override public ResponseEntity<Object> createNode(@Valid final MultipartFile multipartFile, final String dataspaceName) { return null; } @@ -129,78 +99,4 @@ public class CpsRestController implements CpsRestApi { public ResponseEntity<Object> getNodeByDataspaceAndAnchor(final String dataspaceName, final String anchorName) { return null; } - - /* - Old rest endpoints before contract first approach (Need to be removed). - */ - - /** - * Upload a JSON file. - * - * @param uploadedFile the JSON Multipart file. - * @return a ResponseEntity. - */ - @PostMapping("/upload-yang-json-data-file") - public final ResponseEntity<String> uploadYangJsonDataFile(@RequestParam("file") final MultipartFile uploadedFile) { - validateJsonStructure(uploadedFile); - final int persistenceObjectId = cpService.storeJsonStructure(getJsonString(uploadedFile)); - return new ResponseEntity<>( - "Object stored in CPS with identity: " + persistenceObjectId, HttpStatus.OK); - } - - /** - * Read a JSON Object using the object identifier. - * - * @param jsonObjectId the JSON object identifier. - * @return a ResponseEntity. - */ - @GetMapping("/json-object/{id}") - public final ResponseEntity<String> getJsonObjectById( - @PathVariable("id") final int jsonObjectId) { - return new ResponseEntity<>(cpService.getJsonById(jsonObjectId), HttpStatus.OK); - } - - /** - * Delete a JSON Object using the object identifier. - * - * @param jsonObjectId the JSON object identifier. - * @return a ResponseEntity. - */ - @DeleteMapping("json-object/{id}") - public final ResponseEntity<Object> deleteJsonObjectById( - @PathVariable("id") final int jsonObjectId) { - cpService.deleteJsonById(jsonObjectId); - return new ResponseEntity<>(HttpStatus.NO_CONTENT); - } - - private static void validateJsonStructure(final MultipartFile multipartFile) { - try { - final Gson gson = new Gson(); - gson.fromJson(getJsonString(multipartFile), Object.class); - } catch (final JsonSyntaxException e) { - throw new DataValidationException("Not a valid JSON file.", e.getMessage(), e); - } - } - - private static File saveToFile(final MultipartFile multipartFile) { - try { - final File file = File.createTempFile("tempFile", ".yang"); - file.deleteOnExit(); - try (final OutputStream outputStream = new FileOutputStream(file)) { - outputStream.write(multipartFile.getBytes()); - } - return file; - - } catch (final IOException e) { - throw new CpsException(e); - } - } - - private static String getJsonString(final MultipartFile multipartFile) { - try { - return new String(multipartFile.getBytes()); - } catch (final IOException e) { - throw new CpsException(e); - } - } } |