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

eu.peppol.PeppolStandardBusinessHeader Maven / Gradle / Ivy

Go to download

Holds the stuff required by external components, which may be hooked into Oxalis. Classes and resources in this module should be made available to oxalis-inbound by placing it into a shared library in the web container.

There is a newer version: 4.1.2
Show newest version
package eu.peppol;

import eu.peppol.identifier.*;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;

/**
 * Our representation of the SBDH (Standard Business Document Header), which makes us
 * independent of the StandardBusinessDocumentHeader generated by JAXB. Furthermore
 * the UN/CEFACT SBDH is kind of awkward to use as some of the elements of interest to us,
 * are split into several fields.
 *
 * @author steinar
 * @author thore
 */
public class PeppolStandardBusinessHeader {

    /**
     * Peppol Participant Identification for the recipient
     */
    private ParticipantId recipientId;

    /**
     * Peppol Participant Identification for the sender
     */
    private ParticipantId senderId;

    /**
     * The type of document to send
     */
    private PeppolDocumentTypeId peppolDocumentTypeId;

    /**
     * The business process this document is a part of
     */
    private PeppolProcessTypeId profileTypeIdentifier;

    /**
     * Represents the unique identity of the message envelope, this is only used by the AS2 protocol and
     * identifies the AS2 envelope (SBDH).  Upon resending the same SBDH, the same messageId can be used.
     *
     * This messageId is not the same as the "AS2 Message-ID" or the "START message id", which really are
     * are unique "transmission id's" that should be unique for each transmission.
     *
     * //StandardBusinessDocumentHeader/DocumentIdentification/InstanceIdentifier
     */
    private MessageId messageId;

    private Date creationDateAndTime;

    /**
     * Set the time to current and makes a random MessageId as default
     */
    public static PeppolStandardBusinessHeader createPeppolStandardBusinessHeaderWithUniqueMessageIdAndDate() {
        PeppolStandardBusinessHeader p = new PeppolStandardBusinessHeader();
        p.setCreationDateAndTime(new Date());
        p.setMessageId(new MessageId(UUID.randomUUID().toString()));
        return p;
    }

    /**
     * Empty constructor, no defaults - all must be supplied by user
     */
    public PeppolStandardBusinessHeader() {
        /* intentionally nothing */
    }

    /**
     * Copy constructor
     */
    public PeppolStandardBusinessHeader(PeppolStandardBusinessHeader sbdh) {
        recipientId = sbdh.getRecipientId();
        senderId = sbdh.getSenderId();
        peppolDocumentTypeId = sbdh.getDocumentTypeIdentifier();
        profileTypeIdentifier = sbdh.getProfileTypeIdentifier();
        messageId = sbdh.getMessageId();
        creationDateAndTime = sbdh.getCreationDateAndTime();
    }

    /**
     * Do we have enough transport details to send the message?
     * @return true if transport details are complete.
     */
    public boolean isComplete() {
        return (
                (recipientId != null) &&
                (senderId != null) &&
                (peppolDocumentTypeId != null) &&
                (profileTypeIdentifier != null) &&
                (messageId != null) &&
                (creationDateAndTime != null)
               );
    }

    /**
     * Returns a list of property names that are still missing.
     * @return empty list if headers are complete
     */
    public List listMissingProperties() {
        List mhf = new ArrayList();
        if (recipientId == null) mhf.add("recipientId");
        if (senderId == null) mhf.add("senderId");
        if (peppolDocumentTypeId == null) mhf.add("peppolDocumentTypeId");
        if (profileTypeIdentifier == null) mhf.add("profileTypeIdentifier");
        if (messageId == null) mhf.add("messageId");
        if (creationDateAndTime == null) mhf.add("creationDateAndTime");
        return mhf;
    }

    public void setRecipientId(ParticipantId recipientId) {
        this.recipientId = recipientId;
    }

    public ParticipantId getRecipientId() {
        return recipientId;
    }

    public void setSenderId(ParticipantId senderId) {
        this.senderId = senderId;
    }

    public ParticipantId getSenderId() {
        return senderId;
    }

    public void setMessageId(MessageId messageId) {
        this.messageId = messageId;
    }

    public MessageId getMessageId() {
        return messageId;
    }

    public void setCreationDateAndTime(Date creationDateAndTime) {
        this.creationDateAndTime = creationDateAndTime;
    }

    public Date getCreationDateAndTime() {
        return creationDateAndTime;
    }

    public void setDocumentTypeIdentifier(PeppolDocumentTypeId documentTypeIdentifier) {
        this.peppolDocumentTypeId = documentTypeIdentifier;
    }

    public PeppolDocumentTypeId getDocumentTypeIdentifier() {
        return peppolDocumentTypeId;
    }

    public void setProfileTypeIdentifier(PeppolProcessTypeId profileTypeIdentifier) {
        this.profileTypeIdentifier = profileTypeIdentifier;
    }

    public PeppolProcessTypeId getProfileTypeIdentifier() {
        return profileTypeIdentifier;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy