/******************************************************************************* * Copyright 2020 Graz University of Technology * MOA ZS has been developed in a cooperation between EGIZ * and Graz University of Technology. * Licensed under the EUPL, Version 1.2 or - as soon they will be approved by * the European Commission - subsequent versions of the EUPL (the "Licence"); * You may not use this work except in compliance with the Licence. * You may obtain a copy of the Licence at: * https://joinup.ec.europa.eu/news/understanding-eupl-v12 * * Unless required by applicable law or agreed to in writing, software * distributed under the Licence is distributed on an "AS IS" basis, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the Licence for the specific language governing permissions and * limitations under the Licence. * * This product combines work with different licenses. See the "NOTICE" text * file for details on the various modules and licenses. * The "NOTICE" text file is part of the distribution. Any derivative works * that you distribute must include a readable copy of the "NOTICE" text file. *******************************************************************************/ package at.gv.egiz.moazs.scheme; import at.gv.zustellung.app2mzs.xsd.Mzs2AppPortType; import at.gv.zustellung.msg.xsd.DeliveryAnswerType; import javax.xml.bind.JAXBElement; import java.util.Optional; import java.util.concurrent.CompletableFuture; /** * Represents responses to DeliveryRequests that were received from the msg service. * @param The type of the response. * @author Christof Rabensteiner */ public abstract class MsgResponse { protected String id; protected MsgResponse(){ this.id = ""; } public static String createResponseId(String appDeliveryID, String idSuffix) { return appDeliveryID + idSuffix; } public String getResponseID() { return id; } public String getRootElementLocalPart() {return getResponseAsJAXBElement().getName().getLocalPart();} public abstract DeliveryAnswerType getAnswer(); public abstract T getResponse(); public abstract JAXBElement getResponseAsJAXBElement(); public abstract String getAppDeliveryID(); public abstract String getZSDeliveryID(); /** * Create an error response that is based on the current response. * @param text describes the error. * @param code contains an error code. * @return Deep Copy of response but of "error" type */ public abstract MsgResponse generateError(String text, String code); public abstract CompletableFuture sendToAppClient(Msg2MzsConverter converter, Optional signedStatus, Mzs2AppPortType client); }