All Downloads are FREE. Search and download functionalities are using the official Maven repository.

dev.fitko.fitconnect.api.domain.model.event.EventPayload Maven / Gradle / Ivy

Go to download

Library that provides client access to the FIT-Connect api-endpoints for sending, subscribing and routing

There is a newer version: 2.3.5
Show newest version
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();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy