diff options
author | Fiete Ostkamp <Fiete.Ostkamp@telekom.de> | 2024-10-21 16:24:14 +0200 |
---|---|---|
committer | Fiete Ostkamp <Fiete.Ostkamp@telekom.de> | 2024-10-21 16:24:14 +0200 |
commit | 02dacdfc3f1f47103044375a4adcbb5b18c93ee7 (patch) | |
tree | 6a997d3caca1b0ae640f9b4b22740f37a9748b9d /src/main/java/org | |
parent | 8cb2c97c400b30fb71a89aefaf19f247b450d49f (diff) |
- let the framework do the object mapping to BabelRequest
Issue-ID: AAI-4022
Change-Id: Ia657c5ce6974b25b85364b2deff3aab34f27d10a
Signed-off-by: Fiete Ostkamp <Fiete.Ostkamp@telekom.de>
Diffstat (limited to 'src/main/java/org')
-rw-r--r-- | src/main/java/org/onap/aai/babel/service/GenerateArtifactsController.java | 4 | ||||
-rw-r--r-- | src/main/java/org/onap/aai/babel/service/GenerateArtifactsControllerImpl.java | 29 |
2 files changed, 6 insertions, 27 deletions
diff --git a/src/main/java/org/onap/aai/babel/service/GenerateArtifactsController.java b/src/main/java/org/onap/aai/babel/service/GenerateArtifactsController.java index 67fc865..29ebbb2 100644 --- a/src/main/java/org/onap/aai/babel/service/GenerateArtifactsController.java +++ b/src/main/java/org/onap/aai/babel/service/GenerateArtifactsController.java @@ -31,6 +31,7 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; import org.onap.aai.auth.AAIAuthException; +import org.onap.aai.babel.service.data.BabelRequest; /** Generate artifacts from the specified request content */ @Path("/app") @@ -41,6 +42,5 @@ public interface GenerateArtifactsController { @POST @Path("/generateArtifacts") - Response generateArtifacts(@Context UriInfo uriInfo, @Context HttpHeaders headers, - @Context HttpServletRequest servletRequest, String request) throws AAIAuthException; + Response generateArtifacts(BabelRequest babelRequest) throws AAIAuthException; } diff --git a/src/main/java/org/onap/aai/babel/service/GenerateArtifactsControllerImpl.java b/src/main/java/org/onap/aai/babel/service/GenerateArtifactsControllerImpl.java index 189aaf3..4b56798 100644 --- a/src/main/java/org/onap/aai/babel/service/GenerateArtifactsControllerImpl.java +++ b/src/main/java/org/onap/aai/babel/service/GenerateArtifactsControllerImpl.java @@ -22,7 +22,6 @@ package org.onap.aai.babel.service; import com.google.gson.Gson; -import com.google.gson.GsonBuilder; import com.google.gson.JsonSyntaxException; import lombok.RequiredArgsConstructor; @@ -34,9 +33,6 @@ import javax.ws.rs.core.*; import javax.ws.rs.core.Response.Status; import org.apache.commons.lang3.time.StopWatch; -import org.onap.aai.auth.AAIAuthException; -import org.onap.aai.auth.AAIMicroServiceAuth; -import org.onap.aai.auth.AAIMicroServiceAuthCore; import org.onap.aai.babel.csar.CsarConverterException; import org.onap.aai.babel.csar.CsarToXmlConverter; import org.onap.aai.babel.csar.vnfcatalog.ToscaToCatalogException; @@ -63,26 +59,10 @@ public class GenerateArtifactsControllerImpl implements GenerateArtifactsControl private final Gson gson; @Override - public Response generateArtifacts(UriInfo uriInfo, HttpHeaders headers, HttpServletRequest servletRequest, - String requestBody) { + public Response generateArtifacts(BabelRequest babelRequest) { Response response; - // try { - // Get last URI path segment to use for authentication - // List<PathSegment> pathSegments = uriInfo.getPathSegments(); - // String lastPathSegment = pathSegments.isEmpty() ? "" : pathSegments.get(pathSegments.size() - 1).getPath(); - - // boolean authorized = aaiMicroServiceAuth.validateRequest(headers, servletRequest, - // AAIMicroServiceAuthCore.HTTP_METHODS.POST, lastPathSegment); - - response = generateArtifacts(requestBody); - // response = authorized ? generateArtifacts(requestBody) - // : buildResponse(Status.UNAUTHORIZED, "User not authorized to perform the operation."); - // } catch (AAIAuthException e) { - // applicationLogger.error(ApplicationMsgs.PROCESS_REQUEST_ERROR, e); - // applicationLogger.logAuditError(e); - // return buildResponse(Status.INTERNAL_SERVER_ERROR, - // "Error while processing request. Please check the Babel service logs for more details.\n"); - // } + + response = generateArtifactsImpl(babelRequest); StatusCode statusDescription; int statusCode = response.getStatus(); @@ -104,14 +84,13 @@ public class GenerateArtifactsControllerImpl implements GenerateArtifactsControl * the request body in JSON format * @return response object containing the generated XML models */ - protected Response generateArtifacts(String requestBody) { + protected Response generateArtifactsImpl(BabelRequest babelRequest) { StopWatch stopwatch = new StopWatch(); stopwatch.start(); Response response; try { - BabelRequest babelRequest = gson.fromJson(requestBody, BabelRequest.class); new RequestValidator().validateRequest(babelRequest); byte[] csarFile = Base64.getDecoder().decode(babelRequest.getCsar()); |