Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS will be completely phased out by mid-2025. To see alternatives please check here

Skip to content
Snippets Groups Projects
Commit f3471efb authored by Joze RIHTARSIC's avatar Joze RIHTARSIC
Browse files

Upgrade BDMSL version to 4.2-RC1 with "optional participant schema" in test environment

parent 3e4d6c99
No related branches found
No related tags found
No related merge requests found
......@@ -20,10 +20,10 @@ ENV SMP_HOME=/opt/smp \
SMP_DB_USER_PASSWORD=smp \
MYSQL_ROOT_PASSWORD=root \
# sml environment variables
SML_VERSION=4.0.1 \
SML_VERSION=4.2.RC1 \
SML_DISTRIBUTION_URL=https://ec.europa.eu/digital-building-blocks/artifact/repository/public/eu/europa/ec/bdmsl/bdmsl-webapp/ \
SML_SHA512=b40d6ff717216635839e420f467b9dbf5cab87582babc103dea3ed7cbb0fd264f0755fc95607bb3d5ddbcd976a13f0d2170cbf824b3dfebb2ca046579a5d5278 \
SML_SETUP_SHA512=dee04b6c60696c052f4807cc24df72a09dd7443e1c87df82967b08a02381c3042af338f726bc60f40e9428de301af8c317839d286ac58e37b5c7c6ae36c42468 \
SML_SHA512=2330e6caf557fd6a6e8725eb339c26cb2d06f0ca768fd1766989f5dec7557e41375ef61b65cad5d87fa478f3c468272880ebe8521bb66e8e7dee9bb16d0a3d51 \
SML_SETUP_SHA512=f9b7a9607f34f2d547acac13e7044df04fdf616b163f4cae8788f7b1eccd837c3db947458b4f55273d263f6af2e794c18d5216484cc8132e3cfd2dc176d9e1bf \
SML_DB_SCHEMA=sml \
SML_DB_USER=sml \
SML_DB_USER_PASSWORD=sml \
......
......@@ -18,7 +18,6 @@ import eu.europa.ec.edelivery.smp.exceptions.ErrorCode;
import eu.europa.ec.edelivery.smp.exceptions.SMPRuntimeException;
import eu.europa.ec.edelivery.smp.logging.SMPLogger;
import eu.europa.ec.edelivery.smp.logging.SMPLoggerFactory;
import eu.europa.ec.smp.api.Identifiers;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.oasis_open.docs.bdxr.ns.smp._2016._05.ExtensionType;
......@@ -53,22 +52,22 @@ public class ServiceGroupConverter {
/**
* Class has only static members.
*/
private ServiceGroupConverter() {
private ServiceGroupConverter() {
}
private static final String PARSER_DISALLOW_DTD_PARSING_FEATURE = "http://apache.org/xml/features/disallow-doctype-decl";
private static final SMPLogger LOG = SMPLoggerFactory.getLogger(ServiceGroupConverter.class);
private static final ThreadLocal<Unmarshaller> jaxbUnmarshaller = ThreadLocal.withInitial( () -> {
private static final ThreadLocal<Unmarshaller> jaxbUnmarshaller = ThreadLocal.withInitial(() -> {
try {
JAXBContext jaxbContext = JAXBContext.newInstance(ServiceGroup.class);
return jaxbContext.createUnmarshaller();
}catch(JAXBException ex) {
} catch (JAXBException ex) {
LOG.error("Error occurred while initializing JAXBContext for ServiceMetadata. Cause message:", ex);
}
return null;
} );
});
private static Unmarshaller getUnmarshaller() {
......@@ -77,6 +76,7 @@ public class ServiceGroupConverter {
/**
* Method umarshal ServiceGroup from xml string
*
* @param serviceGroupXml
* @return
*/
......@@ -85,12 +85,13 @@ public class ServiceGroupConverter {
Document serviceGroupDoc = parse(serviceGroupXml);
return getUnmarshaller().unmarshal(serviceGroupDoc, ServiceGroup.class).getValue();
} catch (ParserConfigurationException | IOException | SAXException | JAXBException ex) {
throw new SMPRuntimeException(ErrorCode.XML_PARSE_EXCEPTION,ex,ServiceGroup.class.getName(), ExceptionUtils.getRootCauseMessage(ex));
throw new SMPRuntimeException(ErrorCode.XML_PARSE_EXCEPTION, ex, ServiceGroup.class.getName(), ExceptionUtils.getRootCauseMessage(ex));
}
}
/**
* Method umarshal ServiceGroup from xml bytearraz
*
* @param serviceGroupXml
* @return
*/
......@@ -99,7 +100,7 @@ public class ServiceGroupConverter {
try {
System.out.println("UNMARSHAL SERVICE GROUP " + new String(serviceGroupXml));
Document serviceGroupDoc = parse(serviceGroupXml);
ServiceGroup serviceGroup = getUnmarshaller().unmarshal(serviceGroupDoc, ServiceGroup.class).getValue();
ServiceGroup serviceGroup = getUnmarshaller().unmarshal(serviceGroupDoc, ServiceGroup.class).getValue();
/*
if (serviceGroup!=null && serviceGroup.getParticipantIdentifier()!=null
&& StringUtils.isBlank(serviceGroup.getParticipantIdentifier().getScheme())
......@@ -113,7 +114,7 @@ public class ServiceGroupConverter {
}*/
return serviceGroup;
} catch (ParserConfigurationException | IOException | SAXException | JAXBException ex) {
throw new SMPRuntimeException(ErrorCode.XML_PARSE_EXCEPTION,ex,ServiceGroup.class.getName(), ExceptionUtils.getRootCauseMessage(ex));
throw new SMPRuntimeException(ErrorCode.XML_PARSE_EXCEPTION, ex, ServiceGroup.class.getName(), ExceptionUtils.getRootCauseMessage(ex));
}
}
......@@ -125,28 +126,28 @@ public class ServiceGroupConverter {
* @param dsg - database service group entity
* @return Oasis ServiceGroup entity or null if parameter is null
*/
public static ServiceGroup toServiceGroup(DBServiceGroup dsg, boolean concatenateEBCoreID){
public static ServiceGroup toServiceGroup(DBServiceGroup dsg, boolean concatenateEBCoreID) {
if (dsg==null){
if (dsg == null) {
return null;
}
ServiceGroup serviceGroup = new ServiceGroup();
String schema = dsg.getParticipantScheme();
String value = dsg.getParticipantIdentifier();
if (concatenateEBCoreID && StringUtils.startsWithIgnoreCase(schema, EBCORE_IDENTIFIER_PREFIX) ){
String schema = dsg.getParticipantScheme();
String value = dsg.getParticipantIdentifier();
if (concatenateEBCoreID && StringUtils.startsWithIgnoreCase(schema, EBCORE_IDENTIFIER_PREFIX)) {
value = schema + ":" + value;
schema = null;
}
ParticipantIdentifierType identifier = new ParticipantIdentifierType(value, schema);
serviceGroup.setParticipantIdentifier(identifier);
if (dsg.getExtension()!=null){
if (dsg.getExtension() != null) {
try {
List<ExtensionType> extensions = ExtensionConverter.unmarshalExtensions(dsg.getExtension());
serviceGroup.getExtensions().addAll(extensions);
} catch (JAXBException e) {
throw new SMPRuntimeException(INVALID_EXTENSION_FOR_SG, e, dsg.getParticipantIdentifier(),
dsg.getParticipantScheme(),ExceptionUtils.getRootCauseMessage(e));
throw new SMPRuntimeException(INVALID_EXTENSION_FOR_SG, e, dsg.getParticipantIdentifier(),
dsg.getParticipantScheme(), ExceptionUtils.getRootCauseMessage(e));
}
}
serviceGroup.setServiceMetadataReferenceCollection(new ServiceMetadataReferenceCollectionType(new ArrayList()));
......@@ -163,6 +164,7 @@ public class ServiceGroupConverter {
InputStream inputStream = new ByteArrayInputStream(serviceGroupXml);
return getDocumentBuilder().parse(inputStream);
}
private static DocumentBuilder getDocumentBuilder() throws ParserConfigurationException {
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
documentBuilderFactory.setNamespaceAware(true);
......@@ -173,7 +175,7 @@ public class ServiceGroupConverter {
public static byte[] extractExtensionsPayload(ServiceGroup sg) {
try {
return ExtensionConverter.marshalExtensions(sg.getExtensions());
} catch (JAXBException | XMLStreamException | IOException e) {
} catch (JAXBException | XMLStreamException | IOException e) {
throw new SMPRuntimeException(INVALID_EXTENSION_FOR_SG, e,
sg.getParticipantIdentifier().getValue(), sg.getParticipantIdentifier().getScheme(),
ExceptionUtils.getRootCauseMessage(e));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment