test Switched back to ObejctMapper

This commit is contained in:
deiflaender 2022-05-11 10:19:13 +02:00
parent cc2d02162d
commit fd2762e0f7

View File

@ -2,6 +2,7 @@ package com.iqser.red.service.redaction.v1.server.storage;
import com.dslplatform.json.DslJson;
import com.dslplatform.json.runtime.Settings;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.dossier.file.FileType;
import com.iqser.red.service.redaction.v1.model.ImportedRedactions;
import com.iqser.red.service.redaction.v1.model.RedactionLog;
@ -29,7 +30,7 @@ public class RedactionStorageService {
private final StorageService storageService;
private final DslJson<Object> dslJson = new DslJson<>(Settings.basicSetup());
private final ObjectMapper objectMapper;
@SneakyThrows
@ -41,10 +42,8 @@ public class RedactionStorageService {
@SneakyThrows
public void storeObject(String dossierId, String fileId, FileType fileType, Object any) {
var baos = new ByteArrayOutputStream();
dslJson.newWriter();
dslJson.serialize(any, baos);
storageService.storeObject(StorageIdUtils.getStorageId(dossierId, fileId, fileType), baos.toByteArray());
var bytes = objectMapper.writeValueAsBytes(any);
storageService.storeObject(StorageIdUtils.getStorageId(dossierId, fileId, fileType), bytes);
}
@SneakyThrows
@ -65,8 +64,7 @@ public class RedactionStorageService {
}
try {
dslJson.newReader();
return dslJson.deserialize(ImportedRedactions.class, inputStreamResource.getInputStream());
return objectMapper.readValue(inputStreamResource.getInputStream(), ImportedRedactions.class);
} catch (IOException e) {
throw new RuntimeException("Could not imported redactions", e);
}
@ -84,8 +82,7 @@ public class RedactionStorageService {
}
try {
dslJson.newReader();
return dslJson.deserialize(RedactionLog.class, inputStreamResource.getInputStream());
return objectMapper.readValue(inputStreamResource.getInputStream(), RedactionLog.class);
} catch (IOException e) {
throw new RuntimeException("Could not convert RedactionLog", e);
}
@ -103,8 +100,7 @@ public class RedactionStorageService {
}
try {
dslJson.newReader();
return dslJson.deserialize(Text.class, inputStreamResource.getInputStream());
return objectMapper.readValue(inputStreamResource.getInputStream(), Text.class);
} catch (IOException e) {
throw new RuntimeException("Could not convert Text", e);
}
@ -121,8 +117,7 @@ public class RedactionStorageService {
}
try {
dslJson.newReader();
return dslJson.deserialize(NerEntities.class, inputStreamResource.getInputStream());
return objectMapper.readValue(inputStreamResource.getInputStream(), NerEntities.class);
} catch (IOException e) {
throw new RuntimeException("Could not convert NER Entities", e);
}
@ -133,8 +128,7 @@ public class RedactionStorageService {
try {
var sectionGrid = storageService.getObject(StorageIdUtils.getStorageId(dossierId, fileId, FileType.SECTION_GRID));
dslJson.newReader();
return dslJson.deserialize(SectionGrid.class, sectionGrid.getInputStream());
return objectMapper.readValue(sectionGrid.getInputStream(), SectionGrid.class);
} catch (StorageObjectDoesNotExist e) {
throw new NotFoundException("Section Grid is not available.");
} catch (IOException e) {