mirror of
https://github.com/itplr-kosit/validator.git
synced 2026-05-25 16:55:39 +00:00
(enhance) introduce resolving strategy (configurable xml security); introduce API configuration
This commit is contained in:
parent
7a86f049ac
commit
35c0797898
67 changed files with 2441 additions and 845 deletions
|
|
@ -36,7 +36,6 @@ import javax.xml.bind.Unmarshaller;
|
|||
import javax.xml.bind.ValidationEventHandler;
|
||||
import javax.xml.bind.annotation.XmlRegistry;
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.stream.XMLInputFactory;
|
||||
import javax.xml.stream.XMLOutputFactory;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
|
|
@ -47,7 +46,6 @@ import javax.xml.transform.stream.StreamSource;
|
|||
import javax.xml.validation.Schema;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
|
|
@ -86,6 +84,15 @@ public class ConversionService {
|
|||
// context setup
|
||||
private JAXBContext jaxbContext;
|
||||
|
||||
public JAXBContext
|
||||
|
||||
getJaxbContext() {
|
||||
if (this.jaxbContext == null) {
|
||||
initialize();
|
||||
}
|
||||
return this.jaxbContext;
|
||||
}
|
||||
|
||||
private static <T> QName createQName(final T model) {
|
||||
return new QName(model.getClass().getSimpleName().toLowerCase());
|
||||
}
|
||||
|
|
@ -141,13 +148,6 @@ public class ConversionService {
|
|||
}
|
||||
}
|
||||
|
||||
private JAXBContext getJaxbContext() {
|
||||
if (this.jaxbContext == null) {
|
||||
initialize();
|
||||
}
|
||||
return this.jaxbContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unmarshalls a specifc xml model into a defined java object.
|
||||
*
|
||||
|
|
@ -233,24 +233,8 @@ public class ConversionService {
|
|||
}
|
||||
}
|
||||
|
||||
public <T> Document writeDocument(final T input) {
|
||||
if (input == null) {
|
||||
throw new ConversionExeption("Can not serialize null");
|
||||
}
|
||||
final DocumentBuilder builder = ObjectFactory.createDocumentBuilder(false);
|
||||
final Document document = builder.newDocument();
|
||||
|
||||
// Marshal the Object to a Document
|
||||
Marshaller marshaller = null;
|
||||
try {
|
||||
marshaller = getJaxbContext().createMarshaller();
|
||||
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
|
||||
marshaller.marshal(input, document);
|
||||
return document;
|
||||
} catch (final JAXBException e) {
|
||||
throw new ConversionExeption(String.format("Error serializing Object %s to document", input.getClass().getName()), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public <T> T readDocument(final Source source, final Class<T> type) {
|
||||
try {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue