dev.fitko.fitconnect.api.domain.model.event.EventPayload Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of client Show documentation
Show all versions of client Show documentation
Library that provides client access to the FIT-Connect api-endpoints for sending, subscribing and
routing
package dev.fitko.fitconnect.api.domain.model.event;
import dev.fitko.fitconnect.api.domain.model.event.authtags.AuthenticationTags;
import dev.fitko.fitconnect.api.domain.model.event.problems.Problem;
import dev.fitko.fitconnect.api.domain.model.submission.Submission;
import dev.fitko.fitconnect.api.domain.model.submission.SubmissionForPickup;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.UUID;
@Data
@Builder
@AllArgsConstructor
public class EventPayload {
private UUID submissionId;
private UUID destinationId;
private UUID caseId;
// auth-tags for validation
private String metadataAuthTag;
private String dataAuthTag;
private Map attachmentAuthTags;
private List problems;
public static EventPayload forRejectEvent(final SubmissionForPickup submission, final List problems) {
return EventPayload.builder()
.submissionId(submission.getSubmissionId())
.destinationId(submission.getDestinationId())
.caseId(submission.getCaseId())
.problems(problems)
.build();
}
public static EventPayload forRejectEvent(final Submission submission, final List problems) {
return EventPayload.builder()
.submissionId(submission.getSubmissionId())
.destinationId(submission.getDestinationId())
.caseId(submission.getCaseId())
.problems(problems)
.build();
}
public static EventPayload forAcceptEvent(final Submission submission, final Problem... problems) {
return EventPayload.builder()
.submissionId(submission.getSubmissionId())
.destinationId(submission.getDestinationId())
.caseId(submission.getCaseId())
.dataAuthTag(AuthenticationTags.buildAuthTag(submission.getEncryptedData()))
.metadataAuthTag(AuthenticationTags.buildAuthTag(submission.getEncryptedMetadata()))
.attachmentAuthTags(Collections.emptyMap())
.problems(Arrays.asList(problems))
.build();
}
public static EventPayload forAcceptEventWithAttachments(final Submission submission, final Map attachmentAuthTags, final Problem... problems) {
return EventPayload.builder()
.submissionId(submission.getSubmissionId())
.destinationId(submission.getDestinationId())
.caseId(submission.getCaseId())
.dataAuthTag(AuthenticationTags.buildAuthTag(submission.getEncryptedData()))
.metadataAuthTag(AuthenticationTags.buildAuthTag(submission.getEncryptedMetadata()))
.attachmentAuthTags(attachmentAuthTags)
.problems(Arrays.asList(problems))
.build();
}
}