diff options
author | leventecsanyi <levente.csanyi@est.tech> | 2024-08-08 16:21:07 +0200 |
---|---|---|
committer | leventecsanyi <levente.csanyi@est.tech> | 2024-08-13 14:18:04 +0200 |
commit | e31db7316963f7554c493c1e65ff21df37f8f0b2 (patch) | |
tree | a07d7a4e6a19bb5d99fc1856e09eca515294714f /cps-ncmp-service/src/main/java | |
parent | d3c1e7246ab4f41cf3dad97e559ca2736b0014cf (diff) |
Refactored Data Job interfaces
-modified writejob & status endpoints
Issue-ID: CPS-2360
Change-Id: I87647f59493886593825f5175c6ed708e55b3e30
Signed-off-by: leventecsanyi <levente.csanyi@est.tech>
Diffstat (limited to 'cps-ncmp-service/src/main/java')
5 files changed, 29 insertions, 24 deletions
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/datajobs/DataJobStatusService.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/datajobs/DataJobStatusService.java index 50d96f858c..9cfc49f1d4 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/datajobs/DataJobStatusService.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/datajobs/DataJobStatusService.java @@ -31,15 +31,13 @@ public interface DataJobStatusService { * * @param authorization The authorization header from the REST request. * @param dmiServiceName The name of the DMI Service relevant to the data job. - * @param requestId The unique identifier for the overall data job request. - * @param dataProducerJobId The identifier of the data producer job within the DMI system. * @param dataProducerId The ID of the producer registered by DMI, used for operations related to this request. * This could include alternate IDs or specific identifiers. + * @param dataProducerJobId The identifier of the data producer job within the DMI system. * @return The current status of the data job as a String. */ String getDataJobStatus(final String authorization, final String dmiServiceName, - final String requestId, - final String dataProducerJobId, - final String dataProducerId); + final String dataProducerId, + final String dataProducerJobId); } diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/datajobs/models/SubJobWriteRequest.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/datajobs/models/SubJobWriteRequest.java index 0e0498ec49..a7a6573279 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/datajobs/models/SubJobWriteRequest.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/datajobs/models/SubJobWriteRequest.java @@ -25,17 +25,20 @@ import java.util.Collection; /** * Request data for a write operation by the DMI Plugin. * + * @param destination The destination of the results. ( e.g. S3 Bucket) * @param dataAcceptType Define the data response accept type. * e.g. "application/vnd.3gpp.object-tree-hierarchical+json", * "application/vnd.3gpp.object-tree-flat+json" etc. * @param dataContentType Define the data request content type. * e.g. "application/3gpp-json-patch+json" etc. * @param dataProducerId Identifier of the data producer. - * + * @param dataJobId Identifier for the overall Datajob * @param data A collection of outgoing write operations. */ public record SubJobWriteRequest ( + String destination, String dataAcceptType, String dataContentType, String dataProducerId, + String dataJobId, Collection<DmiWriteOperation> data) {}
\ No newline at end of file diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/datajobs/DataJobStatusServiceImpl.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/datajobs/DataJobStatusServiceImpl.java index a6ecaa1097..fb17f066ce 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/datajobs/DataJobStatusServiceImpl.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/datajobs/DataJobStatusServiceImpl.java @@ -42,26 +42,25 @@ public class DataJobStatusServiceImpl implements DataJobStatusService { @Override public String getDataJobStatus(final String authorization, final String dmiServiceName, - final String requestId, - final String dataProducerJobId, - final String dataProducerId) { + final String dataProducerId, + final String dataProducerJobId) { - final UrlTemplateParameters urlTemplateParameters = buildUrlParameters(dmiServiceName, requestId, - dataProducerJobId, dataProducerId); + final UrlTemplateParameters urlTemplateParameters = buildUrlParameters(dmiServiceName, + dataProducerId, + dataProducerJobId); return dmiRestClient.getDataJobStatus(urlTemplateParameters, authorization).block(); } private UrlTemplateParameters buildUrlParameters(final String dmiServiceName, - final String requestId, - final String dataProducerJobId, - final String dataProducerId) { + final String dataProducerId, + final String dataProducerJobId) { return DmiServiceUrlTemplateBuilder.newInstance() - .fixedPathSegment("dataJob") - .variablePathSegment("requestId", requestId) + .fixedPathSegment("cmwriteJob") + .fixedPathSegment("dataProducer") + .variablePathSegment("dataProducerId", dataProducerId) .fixedPathSegment("dataProducerJob") .variablePathSegment("dataProducerJobId", dataProducerJobId) .fixedPathSegment("status") - .queryParameter("dataProducerId", dataProducerId) .createUrlTemplateParameters(dmiServiceName, dmiProperties.getDmiBasePath()); } } diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/datajobs/DmiSubJobRequestHandler.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/datajobs/DmiSubJobRequestHandler.java index c93709ce75..0d14dace5e 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/datajobs/DmiSubJobRequestHandler.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/datajobs/DmiSubJobRequestHandler.java @@ -64,10 +64,15 @@ public class DmiSubJobRequestHandler { final Map<ProducerKey, List<DmiWriteOperation>> dmiWriteOperationsPerProducerKey) { final List<SubJobWriteResponse> subJobWriteResponses = new ArrayList<>(dmiWriteOperationsPerProducerKey.size()); dmiWriteOperationsPerProducerKey.forEach((producerKey, dmi3ggpWriteOperations) -> { - final SubJobWriteRequest subJobWriteRequest = new SubJobWriteRequest(dataJobMetadata.dataAcceptType(), - dataJobMetadata.dataContentType(), producerKey.dataProducerIdentifier(), dmi3ggpWriteOperations); + final SubJobWriteRequest subJobWriteRequest = new SubJobWriteRequest(dataJobMetadata.destination(), + dataJobMetadata.dataAcceptType(), + dataJobMetadata.dataContentType(), + producerKey.dataProducerIdentifier(), + dataJobId, + dmi3ggpWriteOperations); - final UrlTemplateParameters urlTemplateParameters = getUrlTemplateParameters(dataJobId, producerKey); + final UrlTemplateParameters urlTemplateParameters = getUrlTemplateParameters(dataJobMetadata.destination(), + producerKey); final ResponseEntity<Object> responseEntity = dmiRestClient.synchronousPostOperationWithJsonData( RequiredDmiService.DATA, urlTemplateParameters, @@ -82,10 +87,10 @@ public class DmiSubJobRequestHandler { return subJobWriteResponses; } - private UrlTemplateParameters getUrlTemplateParameters(final String dataJobId, final ProducerKey producerKey) { + private UrlTemplateParameters getUrlTemplateParameters(final String destination, final ProducerKey producerKey) { return DmiServiceUrlTemplateBuilder.newInstance() - .fixedPathSegment("writeJob") - .variablePathSegment("requestId", dataJobId) + .fixedPathSegment("cmwriteJob") + .queryParameter("destination", destination) .createUrlTemplateParameters(producerKey.dmiServiceName(), dmiProperties.getDmiBasePath()); } } diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/dmi/DmiRestClient.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/dmi/DmiRestClient.java index ba6bba9c53..177b4b0bf2 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/dmi/DmiRestClient.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/dmi/DmiRestClient.java @@ -160,7 +160,7 @@ public class DmiRestClient { .headers(httpHeaders -> configureHttpHeaders(httpHeaders, authorization)) .retrieve() .bodyToMono(JsonNode.class) - .map(responseHealthStatus -> responseHealthStatus.path("status").asText()) + .map(jsonNode -> jsonNode.path("status").asText()) .onErrorMap(throwable -> handleDmiClientException(throwable, OperationType.READ.getOperationName())); } |