Skip to content
Snippets Groups Projects

Senden von bereits verschlüsselten Anträgen inkl. Abruf von PK

Merged Martin Vogel requested to merge feature/579-send-already-encrypted-data into main
Files
7
@@ -18,7 +18,7 @@ import java.util.UUID;
public class SendEncryptedSubmissionStrategy implements SubmitStrategy {
private static final Logger logger = LoggerFactory.getLogger(SendEncryptedSubmissionStrategy.class);
private static final Logger LOGGER = LoggerFactory.getLogger(SendEncryptedSubmissionStrategy.class);
private final Sender sender;
@@ -29,7 +29,9 @@ public class SendEncryptedSubmissionStrategy implements SubmitStrategy {
@Override
public Optional<SubmitSubmission> send(final SubmissionPayload submissionPayload) {
if (!hasValidPayload(submissionPayload)) { return Optional.empty(); }
if (!hasValidPayload(submissionPayload)) {
return Optional.empty();
}
final UUID destinationId = submissionPayload.getDestinationId();
final ServiceType serviceType = SubmissionUtil.buildServiceType(submissionPayload.getServiceTypePayLoad());
@@ -51,22 +53,22 @@ public class SendEncryptedSubmissionStrategy implements SubmitStrategy {
/** Submit submission **/
sender.sendSubmission(submission);
logger.info("SUCCESSFULLY HANDED IN SUBMISSION !");
LOGGER.info("SUCCESSFULLY HANDED IN SUBMISSION !");
return Optional.of(submission);
} catch (final RestApiException e) {
logger.error("Sending submission failed", e);
LOGGER.error("Sending submission failed", e);
} catch (final SubmissionNotCreatedException e) {
logger.error("Failed to announce new submission", e);
LOGGER.error("Failed to announce new submission", e);
}
return Optional.empty();
}
private void uploadAttachments(final List<AttachmentPayload> attachmentPayloads, final UUID submissionId) {
if (attachmentPayloads.isEmpty()) {
logger.info("No attachments to upload");
LOGGER.info("No attachments to upload");
} else {
logger.info("Uploading {} attachment(s)", attachmentPayloads.size());
LOGGER.info("Uploading {} attachment(s)", attachmentPayloads.size());
}
for (final AttachmentPayload payload : attachmentPayloads) {
sender.uploadAttachment(submissionId, payload.getAttachmentId(), payload.getEncryptedData());
@@ -76,19 +78,19 @@ public class SendEncryptedSubmissionStrategy implements SubmitStrategy {
@Override
public boolean hasValidPayload(final SubmissionPayload submissionPayload) {
if (submissionPayload.getData().getEncryptedData() == null) {
logger.error("Data is mandatory, but was null.");
LOGGER.error("Data is mandatory, but was null.");
return false;
} else if (submissionPayload.getEncryptedMetadata() == null) {
logger.error("Metadata is mandatory, but was null.");
LOGGER.error("Metadata is mandatory, but was null.");
return false;
} else if (submissionPayload.getServiceTypePayLoad().getName() == null) {
logger.error("Service type name is mandatory, but was null.");
LOGGER.error("Service type name is mandatory, but was null.");
return false;
} else if (submissionPayload.getServiceTypePayLoad().getLeikaKey() == null) {
logger.error("Service type identifier is mandatory, but was null.");
LOGGER.error("Service type identifier is mandatory, but was null.");
return false;
} else if (submissionPayload.getDestinationId() == null) {
logger.error("DestinationId is mandatory, but was null.");
LOGGER.error("DestinationId is mandatory, but was null.");
return false;
} else {
return true;
Loading