package at.gv.egiz.moazs.scheme; import com.sun.xml.bind.marshaller.NamespacePrefixMapper; import org.springframework.stereotype.Component; import java.util.HashMap; import java.util.Map; @Component public class MoaZSPrefixMapper extends NamespacePrefixMapper { private final Map map = new HashMap<>(); public MoaZSPrefixMapper() { map.put(getMsgNamespaceUri(), "msg"); map.put(getMsgPNamespaceUri(), "msgp"); map.put(getMzsNamespaceUri(), "mzs"); map.put(getMzsPNamespaceUri(), "mzsp"); map.put(getDsigNamespaceUri(), "dsig"); } public MoaZSPrefixMapper(boolean isMzs) { this(); map.put((isMzs) ? getMzsPNamespaceUri() : getMsgPNamespaceUri(), "p"); map.put((isMzs) ? getMzsNamespaceUri() : getMsgNamespaceUri(), ""); } @Override public String getPreferredPrefix(String namespaceUri, String suggestion, boolean requirePrefix) { return map.getOrDefault(namespaceUri, suggestion); } private String getMsgNamespaceUri() { return new at.gv.zustellung.msg.xsd.ObjectFactory().createDeliveryRequest(null).getName().getNamespaceURI(); } private String getMsgPNamespaceUri() { return new at.gv.zustellung.msg.xsd.persondata.ObjectFactory().createPerson(null).getName().getNamespaceURI(); } private String getMzsNamespaceUri() { return new at.gv.zustellung.app2mzs.xsd.ObjectFactory().createDeliveryRequest(null).getName().getNamespaceURI(); } private String getMzsPNamespaceUri() { return new at.gv.zustellung.app2mzs.xsd.persondata.ObjectFactory().createAbstractPersonData(null).getName().getNamespaceURI(); } private String getDsigNamespaceUri() { return new org.w3._2000._09.xmldsig_.ObjectFactory().createCanonicalizationMethod(null).getName().getNamespaceURI(); } }