11/*
22 * Copyright 2020 Fraunhofer Institute for Software and Systems Engineering
3- * Copyright 2021 Fraunhofer Institute for Applied Information Technology
43 *
54 * Licensed under the Apache License, Version 2.0 (the "License");
65 * you may not use this file except in compliance with the License.
1615 */
1716package io .dataspaceconnector .service .message .handler .processor ;
1817
19- import com .fasterxml .jackson .annotation .JsonInclude ;
2018import com .fasterxml .jackson .databind .ObjectMapper ;
21- import de .fraunhofer .fit .appstore .model .portainer .Template ;
22- import de .fraunhofer .fit .appstore .services .registry .RegistryService ;
2319import de .fraunhofer .iais .eis .ArtifactRequestMessageImpl ;
2420import de .fraunhofer .ids .messaging .handler .message .MessagePayload ;
2521import io .dataspaceconnector .common .exception .InvalidInputException ;
3531import lombok .RequiredArgsConstructor ;
3632import lombok .extern .log4j .Log4j2 ;
3733import org .springframework .stereotype .Component ;
34+ import org .springframework .util .Base64Utils ;
3835
3936/**
4037 * Fetches the data of an artifact as the response to an ArtifactRequestMessage.
@@ -55,11 +52,6 @@ class DataRequestProcessor extends IdsProcessor<
5552 */
5653 private final @ NonNull EntityResolver entityResolver ;
5754
58- /**
59- * Service for registry management.
60- */
61- private final @ NonNull RegistryService registryService ;
62-
6355 /**
6456 * Fetches the data of the requested artifact as the response payload and creates an
6557 * ArtifactResponseMessage as the response header.
@@ -81,25 +73,10 @@ protected Response processInternal(final RouteMsg<ArtifactRequestMessageImpl,
8173 final var queryInput = getQueryInputFromPayload (msg .getBody ());
8274 final var data = entityResolver .getDataByArtifactId (artifact , queryInput );
8375
84- // Add user credentials to template.
85- final var userCreds = registryService .createUserCredentialsForPullingImages ();
86- userCreds .setEmail (null );
87- userCreds .setRealname (null );
88-
89- final var objectMapper = new ObjectMapper ();
90- objectMapper .setSerializationInclusion (JsonInclude .Include .NON_NULL );
91-
92- final var dataTmp = objectMapper .readValue (data .readAllBytes (), Template .class );
93- dataTmp .setRegistryUser (userCreds );
94-
95- // TODO: EXCEPTION HANDLING FOR OBJECT MAPPING (JSON TO OBJECT AND OBJECT TO JSON)
96- final var newData
97- = objectMapper .writerWithDefaultPrettyPrinter ().writeValueAsString (dataTmp );
98-
9976 final var desc = new ArtifactResponseMessageDesc (issuer , messageId , transferContract );
10077 final var responseHeader = messageService .buildMessage (desc );
10178
102- return new Response (responseHeader , newData );
79+ return new Response (responseHeader , Base64Utils . encodeToString ( data . readAllBytes ()) );
10380 }
10481
10582 /**
0 commit comments