Replace java.util Logging with SLF4J
This commit is contained in:
@@ -24,8 +24,6 @@ import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.dom4j.Document;
|
||||
import org.dom4j.DocumentException;
|
||||
@@ -34,8 +32,11 @@ import org.dom4j.io.OutputFormat;
|
||||
import org.dom4j.io.XMLWriter;
|
||||
import org.mustangproject.EStandard;
|
||||
import org.mustangproject.XMLTools;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class UBLDAPullProvider implements IXMLProvider {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger (UBLDAPullProvider.class);
|
||||
|
||||
protected IExportableTransaction trans;
|
||||
protected TransactionCalculator calc;
|
||||
@@ -118,7 +119,7 @@ public class UBLDAPullProvider implements IXMLProvider {
|
||||
try {
|
||||
document = DocumentHelper.parseText(new String(ublData));
|
||||
} catch (final DocumentException e1) {
|
||||
Logger.getLogger(ZUGFeRD2PullProvider.class.getName()).log(Level.SEVERE, null, e1);
|
||||
LOGGER.error ("Failed to parse UBL", e1);
|
||||
}
|
||||
try {
|
||||
final OutputFormat format = OutputFormat.createPrettyPrint();
|
||||
@@ -128,7 +129,7 @@ public class UBLDAPullProvider implements IXMLProvider {
|
||||
res = sw.toString().getBytes(StandardCharsets.UTF_8);
|
||||
|
||||
} catch (final IOException e) {
|
||||
Logger.getLogger(ZUGFeRD2PullProvider.class.getName()).log(Level.SEVERE, null, e);
|
||||
LOGGER.error ("Failed to write XML", e);
|
||||
}
|
||||
|
||||
return res;
|
||||
|
||||
@@ -4,12 +4,13 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.mustangproject.XMLTools;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class XRechnungImporter extends ZUGFeRDImporter {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger (XRechnungImporter.class);
|
||||
|
||||
public XRechnungImporter(byte[] rawXml) {
|
||||
super();
|
||||
@@ -18,7 +19,7 @@ public class XRechnungImporter extends ZUGFeRDImporter {
|
||||
setRawXML(rawXml);
|
||||
containsMeta = true;
|
||||
} catch (final IOException e) {
|
||||
Logger.getLogger(ZUGFeRDImporter.class.getName()).log(Level.SEVERE, null, e);
|
||||
LOGGER.error ("Failed to set raw XML", e);
|
||||
throw new ZUGFeRDExportException(e);
|
||||
}
|
||||
}
|
||||
@@ -30,7 +31,7 @@ public class XRechnungImporter extends ZUGFeRDImporter {
|
||||
setRawXML(Files.readAllBytes(Paths.get(filename)));
|
||||
containsMeta = true;
|
||||
} catch (final IOException e) {
|
||||
Logger.getLogger(ZUGFeRDImporter.class.getName()).log(Level.SEVERE, null, e);
|
||||
LOGGER.error ("Failed to set raw XML", e);
|
||||
throw new ZUGFeRDExportException(e);
|
||||
}
|
||||
|
||||
@@ -42,7 +43,7 @@ public class XRechnungImporter extends ZUGFeRDImporter {
|
||||
setRawXML(XMLTools.getBytesFromStream(fileinput));
|
||||
containsMeta = true;
|
||||
} catch (final IOException e) {
|
||||
Logger.getLogger(ZUGFeRDImporter.class.getName()).log(Level.SEVERE, null, e);
|
||||
LOGGER.error ("Failed to set raw XML", e);
|
||||
throw new ZUGFeRDExportException(e);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,8 +30,6 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.dom4j.Document;
|
||||
import org.dom4j.DocumentException;
|
||||
@@ -39,9 +37,11 @@ import org.dom4j.DocumentHelper;
|
||||
import org.dom4j.io.OutputFormat;
|
||||
import org.dom4j.io.XMLWriter;
|
||||
import org.mustangproject.XMLTools;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class ZUGFeRD1PullProvider extends ZUGFeRD2PullProvider {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger (ZUGFeRD1PullProvider.class);
|
||||
|
||||
//// MAIN CLASS
|
||||
|
||||
@@ -93,7 +93,7 @@ public class ZUGFeRD1PullProvider extends ZUGFeRD2PullProvider {
|
||||
try {
|
||||
document = DocumentHelper.parseText(new String(zugferdData));
|
||||
} catch (final DocumentException e1) {
|
||||
Logger.getLogger(ZUGFeRD1PullProvider.class.getName()).log(Level.SEVERE, null, e1);
|
||||
LOGGER.error ("Failed to parse ZUGFeRD data", e1);
|
||||
}
|
||||
try {
|
||||
final OutputFormat format = OutputFormat.createPrettyPrint();
|
||||
@@ -103,7 +103,7 @@ public class ZUGFeRD1PullProvider extends ZUGFeRD2PullProvider {
|
||||
res = sw.toString().getBytes(StandardCharsets.UTF_8);
|
||||
|
||||
} catch (final IOException e) {
|
||||
Logger.getLogger(ZUGFeRD1PullProvider.class.getName()).log(Level.SEVERE, null, e);
|
||||
LOGGER.error ("Failed to write ZUGFeRD data", e);
|
||||
}
|
||||
|
||||
return res;
|
||||
|
||||
@@ -35,8 +35,6 @@ import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.dom4j.Document;
|
||||
@@ -48,8 +46,11 @@ import org.mustangproject.FileAttachment;
|
||||
import org.mustangproject.IncludedNote;
|
||||
import org.mustangproject.XMLTools;
|
||||
import org.mustangproject.ZUGFeRD.model.DocumentCodeTypeConstants;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class ZUGFeRD2PullProvider implements IXMLProvider {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger (ZUGFeRD2PullProvider.class);
|
||||
|
||||
protected byte[] zugferdData;
|
||||
protected IExportableTransaction trans;
|
||||
@@ -91,7 +92,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
||||
try {
|
||||
document = DocumentHelper.parseText(new String(zugferdData));
|
||||
} catch (final DocumentException e1) {
|
||||
Logger.getLogger(ZUGFeRD2PullProvider.class.getName()).log(Level.SEVERE, null, e1);
|
||||
LOGGER.error ("Failed to parse ZUGFeRD data", e1);
|
||||
}
|
||||
try {
|
||||
final OutputFormat format = OutputFormat.createPrettyPrint();
|
||||
@@ -101,7 +102,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
||||
res = sw.toString().getBytes(StandardCharsets.UTF_8);
|
||||
|
||||
} catch (final IOException e) {
|
||||
Logger.getLogger(ZUGFeRD2PullProvider.class.getName()).log(Level.SEVERE, null, e);
|
||||
LOGGER.error ("Failed to write ZUGFeRD data", e);
|
||||
}
|
||||
|
||||
return res;
|
||||
|
||||
@@ -27,9 +27,6 @@ import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Scanner;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
@@ -52,12 +49,15 @@ import org.mustangproject.EStandard;
|
||||
import org.mustangproject.Item;
|
||||
import org.mustangproject.Product;
|
||||
import org.mustangproject.XMLTools;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
public class ZUGFeRDImporter {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger (ZUGFeRDImporter.class);
|
||||
|
||||
/**
|
||||
* if metadata has been found
|
||||
@@ -90,7 +90,7 @@ public class ZUGFeRDImporter {
|
||||
try (InputStream bis = Files.newInputStream(Paths.get(pdfFilename), StandardOpenOption.READ)) {
|
||||
extractLowLevel(bis);
|
||||
} catch (final IOException e) {
|
||||
Logger.getLogger(ZUGFeRDImporter.class.getName()).log(Level.SEVERE, null, e);
|
||||
LOGGER.error ("Failed to extract ZUGFeRD data", e);
|
||||
throw new ZUGFeRDExportException(e);
|
||||
}
|
||||
}
|
||||
@@ -100,7 +100,7 @@ public class ZUGFeRDImporter {
|
||||
try {
|
||||
extractLowLevel(pdfStream);
|
||||
} catch (final IOException e) {
|
||||
Logger.getLogger(ZUGFeRDImporter.class.getName()).log(Level.SEVERE, null, e);
|
||||
LOGGER.error ("Failed to extract ZUGFeRD data", e);
|
||||
throw new ZUGFeRDExportException(e);
|
||||
}
|
||||
}
|
||||
@@ -127,7 +127,7 @@ public class ZUGFeRDImporter {
|
||||
//start
|
||||
|
||||
if (doc.getDocumentCatalog() == null || doc.getDocumentCatalog().getMetadata() == null) {
|
||||
Logger.getLogger(ZUGFeRDImporter.class.getName()).log(Level.INFO, "no-xmlpart");
|
||||
LOGGER.info("no-xmlpart");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -219,7 +219,7 @@ public class ZUGFeRDImporter {
|
||||
try {
|
||||
setDocument();
|
||||
} catch (ParserConfigurationException | SAXException e) {
|
||||
Logger.getLogger(ZUGFeRDImporter.class.getName()).log(Level.SEVERE, null, e);
|
||||
LOGGER.error ("Failed to parse XML", e);
|
||||
throw new ZUGFeRDExportException(e);
|
||||
}
|
||||
}
|
||||
@@ -236,7 +236,7 @@ public class ZUGFeRDImporter {
|
||||
final XPath xpath = xpathFact.newXPath();
|
||||
result = xpath.evaluate(xpathStr, document);
|
||||
} catch (final XPathExpressionException e) {
|
||||
Logger.getLogger(ZUGFeRDImporter.class.getName()).log(Level.SEVERE, null, e);
|
||||
LOGGER.error ("Failed to evaluate XPath", e);
|
||||
throw new ZUGFeRDExportException(e);
|
||||
}
|
||||
return result;
|
||||
@@ -301,8 +301,7 @@ public class ZUGFeRDImporter {
|
||||
return extractString("//*[local-name() = 'ApplicableHeaderTradeSettlement']//*[local-name() = 'InvoiceCurrencyCode']");
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
Logger.getLogger(ZUGFeRDImporter.class.getName()).log(Level.SEVERE, null, e);
|
||||
|
||||
// Exception was already logged
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -336,7 +335,7 @@ public class ZUGFeRDImporter {
|
||||
return extractString("//*[local-name() = '" + propertyName + "']//*[local-name() = 'IssuerAssignedID']");
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
Logger.getLogger(ZUGFeRDImporter.class.getName()).log(Level.SEVERE, null, e);
|
||||
// Exception was already logged
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -359,7 +358,7 @@ public class ZUGFeRDImporter {
|
||||
return extractString("//*[local-name() = 'ExchangedDocument']//*[local-name() = 'IssueDateTime']//*[local-name() = 'DateTimeString']");
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
Logger.getLogger(ZUGFeRDImporter.class.getName()).log(Level.SEVERE, null, e);
|
||||
// Exception was already logged
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -391,7 +390,7 @@ public class ZUGFeRDImporter {
|
||||
return extractString("//*[local-name() = 'SpecifiedTradeSettlementHeaderMonetarySummation']//*[local-name() = 'TaxBasisTotalAmount']");
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
Logger.getLogger(ZUGFeRDImporter.class.getName()).log(Level.SEVERE, null, e);
|
||||
// Exception was already logged
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -407,7 +406,7 @@ public class ZUGFeRDImporter {
|
||||
return extractString("//*[local-name() = 'SpecifiedTradeSettlementHeaderMonetarySummation']//*[local-name() = 'TaxTotalAmount']");
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
Logger.getLogger(ZUGFeRDImporter.class.getName()).log(Level.SEVERE, null, e);
|
||||
// Exception was already logged
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -423,7 +422,7 @@ public class ZUGFeRDImporter {
|
||||
return extractString("//*[local-name() = 'SpecifiedTradeSettlementHeaderMonetarySummation']//*[local-name() = 'RoundingAmount']");
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
Logger.getLogger(ZUGFeRDImporter.class.getName()).log(Level.SEVERE, null, e);
|
||||
// Exception was already logged
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -439,7 +438,7 @@ public class ZUGFeRDImporter {
|
||||
return extractString("//*[local-name() = 'SpecifiedTradeSettlementHeaderMonetarySummation']//*[local-name() = 'TotalPrepaidAmount']");
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
Logger.getLogger(ZUGFeRDImporter.class.getName()).log(Level.SEVERE, null, e);
|
||||
// Exception was already logged
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -477,7 +476,7 @@ public class ZUGFeRDImporter {
|
||||
return extractString("//*[local-name() = 'ExchangedDocument']//*[local-name() = 'IncludedNote']");
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
Logger.getLogger(ZUGFeRDImporter.class.getName()).log(Level.SEVERE, null, e);
|
||||
// Exception was already logged
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -508,7 +507,7 @@ public class ZUGFeRDImporter {
|
||||
return extractString("//*[local-name() = 'SpecifiedTradeSettlementHeaderMonetarySummation']//*[local-name() = 'LineTotalAmount']");
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
Logger.getLogger(ZUGFeRDImporter.class.getName()).log(Level.SEVERE, null, e);
|
||||
// Exception was already logged
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -531,7 +530,7 @@ public class ZUGFeRDImporter {
|
||||
return extractString("//*[local-name() = 'ActualDeliverySupplyChainEvent']//*[local-name() = 'OccurrenceDateTime']//*[local-name() = 'DateTimeString']");
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
Logger.getLogger(ZUGFeRDImporter.class.getName()).log(Level.SEVERE, null, e);
|
||||
// Exception was already logged
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -547,7 +546,7 @@ public class ZUGFeRDImporter {
|
||||
return extractString("//*[local-name() = 'ExchangedDocument']//*[local-name() = 'ID']");
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
Logger.getLogger(ZUGFeRDImporter.class.getName()).log(Level.SEVERE, null, e);
|
||||
// Exception was already logged
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -564,7 +563,7 @@ public class ZUGFeRDImporter {
|
||||
return extractString("//*[local-name() = 'ExchangedDocument']/*[local-name() = 'TypeCode']");
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
Logger.getLogger(ZUGFeRDImporter.class.getName()).log(Level.SEVERE, null, e);
|
||||
// Exception was already logged
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -581,7 +580,7 @@ public class ZUGFeRDImporter {
|
||||
return extractString("//*[local-name() = 'ApplicableHeaderTradeAgreement']/*[local-name() = 'BuyerReference']");
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
Logger.getLogger(ZUGFeRDImporter.class.getName()).log(Level.SEVERE, null, e);
|
||||
// Exception was already logged
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -806,7 +805,7 @@ public class ZUGFeRDImporter {
|
||||
nl = getNodeListByPath("//*[local-name() = 'CrossIndustryInvoice']//*[local-name() = 'SupplyChainTradeTransaction']//*[local-name() = 'ApplicableHeaderTradeAgreement']//*[local-name() = 'BuyerTradeParty']//*[local-name() = 'PostalTradeAddress']");
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
Logger.getLogger(ZUGFeRDImporter.class.getName()).log(Level.SEVERE, null, e);
|
||||
// Exception was already logged
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -828,7 +827,7 @@ public class ZUGFeRDImporter {
|
||||
nl = getNodeListByPath("//*[local-name() = 'CrossIndustryInvoice']//*[local-name() = 'SupplyChainTradeTransaction']//*[local-name() = 'ApplicableHeaderTradeAgreement']//*[local-name() = 'SellerTradeParty']//*[local-name() = 'PostalTradeAddress']");
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
Logger.getLogger(ZUGFeRDImporter.class.getName()).log(Level.SEVERE, null, e);
|
||||
// Exception was already logged
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -850,7 +849,7 @@ public class ZUGFeRDImporter {
|
||||
nl = getNodeListByPath("//*[local-name() = 'CrossIndustryInvoice']//*[local-name() = 'SupplyChainTradeTransaction']//*[local-name() = 'ApplicableHeaderTradeDelivery']//*[local-name() = 'ShipToTradeParty']//*[local-name() = 'PostalTradeAddress']");
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
Logger.getLogger(ZUGFeRDImporter.class.getName()).log(Level.SEVERE, null, e);
|
||||
// Exception was already logged
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1063,7 +1062,7 @@ public class ZUGFeRDImporter {
|
||||
nl = getNodeListByPath("//*[local-name() = 'IncludedSupplyChainTradeLineItem']");
|
||||
|
||||
} catch (final Exception e) {
|
||||
Logger.getLogger(ZUGFeRDImporter.class.getName()).log(Level.SEVERE, null, e);
|
||||
// Exception was already logged
|
||||
}
|
||||
|
||||
for (int i = 0; i < nl.getLength(); i++) {
|
||||
@@ -1110,7 +1109,7 @@ public class ZUGFeRDImporter {
|
||||
final XPathExpression xpr = xPath.compile(s);
|
||||
return (NodeList) xpr.evaluate(getDocument(), XPathConstants.NODESET);
|
||||
} catch (final Exception e) {
|
||||
Logger.getLogger(ZUGFeRDImporter.class.getName()).log(Level.SEVERE, null, e);
|
||||
LOGGER.error("Failed to evaluate XPath", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,8 +35,6 @@ import java.io.PipedOutputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.xml.transform.Result;
|
||||
import javax.xml.transform.Source;
|
||||
@@ -61,6 +59,10 @@ import org.apache.fop.configuration.ConfigurationException;
|
||||
import org.apache.fop.configuration.DefaultConfigurationBuilder;
|
||||
import org.apache.xmlgraphics.util.MimeConstants;
|
||||
import org.mustangproject.ClasspathResolverURIAdapter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.helger.commons.io.stream.StreamHelper;
|
||||
|
||||
public class ZUGFeRDVisualizer {
|
||||
|
||||
@@ -72,7 +74,7 @@ public class ZUGFeRDVisualizer {
|
||||
|
||||
static final ClassLoader CLASS_LOADER = ZUGFeRDVisualizer.class.getClassLoader();
|
||||
private static final String RESOURCE_PATH = "";
|
||||
private static final Logger LOG = Logger.getLogger(ZUGFeRDVisualizer.class.getName());
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger (ZUGFeRDVisualizer.class);
|
||||
// private static File createTempFileResult(final Transformer transformer, final
|
||||
// StreamSource toTransform,
|
||||
// final String suffix) throws TransformerException, IOException {
|
||||
@@ -118,7 +120,7 @@ public class ZUGFeRDVisualizer {
|
||||
CLASS_LOADER.getResourceAsStream(RESOURCE_PATH + "stylesheets/ZUGFeRD_1p0_c1p0_s1p0.xslt")));
|
||||
}
|
||||
} catch (TransformerConfigurationException ex) {
|
||||
LOG.log(Level.SEVERE, null, ex);
|
||||
LOGGER.error ("Failed to init XSLT templates", ex);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -132,7 +134,7 @@ public class ZUGFeRDVisualizer {
|
||||
try {
|
||||
fileContent = new String(Files.readAllBytes(Paths.get(xmlFilename)), StandardCharsets.UTF_8);
|
||||
} catch (IOException e2) {
|
||||
LOG.log(Level.SEVERE, null, e2);
|
||||
LOGGER.error ("Failed to read file content", e2);
|
||||
}
|
||||
|
||||
ByteArrayOutputStream iaos = new ByteArrayOutputStream();
|
||||
@@ -177,25 +179,17 @@ public class ZUGFeRDVisualizer {
|
||||
// ByteArrayOutputStream
|
||||
iaos.writeTo(out);
|
||||
} catch (IOException e) {
|
||||
LOG.log(Level.SEVERE, null, e);
|
||||
LOGGER.error ("Failed to write to stream", e);
|
||||
} finally {
|
||||
// close the PipedOutputStream here because we're done writing data
|
||||
// once this thread has completed its run
|
||||
if (out != null) {
|
||||
// close the PipedOutputStream cleanly
|
||||
try {
|
||||
out.close();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
LOG.log(Level.SEVERE, null, e);
|
||||
}
|
||||
}
|
||||
StreamHelper.close (out);
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
applyXSLTToHTML(in, baos);
|
||||
} catch (IOException e1) {
|
||||
LOG.log(Level.SEVERE, null, e1);
|
||||
LOGGER.error("Failed to create HTML", e1);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -216,14 +210,15 @@ public class ZUGFeRDVisualizer {
|
||||
new StreamSource(CLASS_LOADER.getResourceAsStream(RESOURCE_PATH + "stylesheets/xr-pdf.xsl")));
|
||||
}
|
||||
} catch (TransformerConfigurationException ex) {
|
||||
LOG.log(Level.SEVERE, null, ex);
|
||||
LOGGER.error("Failed to init XSLT templates", ex);
|
||||
}
|
||||
|
||||
FileInputStream fis = new FileInputStream(xmlFilename);
|
||||
try {
|
||||
// TODO why are we reading the whole file here and discarding the content?
|
||||
new String(Files.readAllBytes(Paths.get(xmlFilename)), StandardCharsets.UTF_8);
|
||||
} catch (IOException e2) {
|
||||
LOG.log(Level.SEVERE, null, e2);
|
||||
LOGGER.error ("Failed to read file", e2);
|
||||
}
|
||||
|
||||
ByteArrayOutputStream iaos = new ByteArrayOutputStream();
|
||||
@@ -245,25 +240,17 @@ public class ZUGFeRDVisualizer {
|
||||
// ByteArrayOutputStream
|
||||
iaos.writeTo(out);
|
||||
} catch (IOException e) {
|
||||
LOG.log(Level.SEVERE, null, e);
|
||||
LOGGER.error("Failed to write to stream", e);
|
||||
} finally {
|
||||
// close the PipedOutputStream here because we're done writing data
|
||||
// once this thread has completed its run
|
||||
if (out != null) {
|
||||
// close the PipedOutputStream cleanly
|
||||
try {
|
||||
out.close();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
LOG.log(Level.SEVERE, null, e);
|
||||
}
|
||||
}
|
||||
StreamHelper.close(out);
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
applyXSLTToPDF(in, baos);
|
||||
} catch (IOException e1) {
|
||||
LOG.log(Level.SEVERE, null, e1);
|
||||
LOGGER.error("Failed to create PDF", e1);
|
||||
}
|
||||
|
||||
|
||||
@@ -284,7 +271,7 @@ public class ZUGFeRDVisualizer {
|
||||
try {
|
||||
result = zvi.toFOP(CIIinputFile.getAbsolutePath());
|
||||
} catch (FileNotFoundException | TransformerException e) {
|
||||
Logger.getLogger(ZUGFeRDVisualizer.class.getName()).log(Level.SEVERE, null, e);
|
||||
LOGGER.error("Failed to apply FOP", e);
|
||||
}
|
||||
/*
|
||||
FopConfParser parser = null;
|
||||
@@ -348,17 +335,9 @@ public class ZUGFeRDVisualizer {
|
||||
|
||||
//Files.write(Paths.get("C:\\Users\\jstaerk\\temp\\fop.pdf"), res.toString().getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
} catch (FOPException e) {
|
||||
Logger.getLogger(ZUGFeRDVisualizer.class.getName()).log(Level.SEVERE, null, e);
|
||||
} catch (TransformerConfigurationException e) {
|
||||
Logger.getLogger(ZUGFeRDVisualizer.class.getName()).log(Level.SEVERE, null, e);
|
||||
} catch (IOException e) {
|
||||
Logger.getLogger(ZUGFeRDVisualizer.class.getName()).log(Level.SEVERE, null, e);
|
||||
} catch (TransformerException e) {
|
||||
Logger.getLogger(ZUGFeRDVisualizer.class.getName()).log(Level.SEVERE, null, e);
|
||||
} catch (FOPException | IOException | TransformerException e) {
|
||||
LOGGER.error("Failed to create PDF", e);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected void applyZF2XSLT(final InputStream xmlFile, final OutputStream HTMLOutstream)
|
||||
|
||||
@@ -6,17 +6,18 @@ import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.mustangproject.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/***
|
||||
* tests the linecalculator and transactioncalculator classes
|
||||
*
|
||||
*/
|
||||
public class CalculationTest {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger (CalculationTest.class);
|
||||
|
||||
@Test
|
||||
public void testLineCalculator_simpleAmounts_resultInValidVATAmount() {
|
||||
@@ -92,7 +93,7 @@ public class CalculationTest {
|
||||
invoice.setDeliveryDate(sqlDate.parse("2020-12-31"));
|
||||
invoice.setDueDate(sqlDate.parse("2021-01-15"));
|
||||
} catch (Exception e) {
|
||||
Logger.getLogger(CalculationTest.class.getName()).log(Level.SEVERE, null, e);
|
||||
LOGGER.error("Failed to set dates", e);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -22,15 +22,16 @@ import java.net.URISyntaxException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
/**
|
||||
* This test utility class is providing usability functions to test file resources
|
||||
*/
|
||||
public class ResourceUtilities {
|
||||
private static final Logger LOG = Logger.getLogger(ResourceUtilities.class.getName());
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger (ResourceUtilities.class);
|
||||
|
||||
/**
|
||||
* Loading a File into a String using a certain encoding and file path
|
||||
@@ -73,7 +74,7 @@ public class ResourceUtilities {
|
||||
uri = ResourceUtilities.class.getClassLoader().getResource(relativeFilePath).toURI();
|
||||
uri = new URI(toExternalForm(uri));
|
||||
} catch (URISyntaxException ex) {
|
||||
LOG.log(Level.SEVERE, null, ex);
|
||||
LOGGER.error("Failed to parse URI", ex);
|
||||
}
|
||||
if (uri == null) {
|
||||
throw new FileNotFoundException("Could not find the file '" + relativeFilePath + "'!");
|
||||
@@ -129,7 +130,7 @@ public class ResourceUtilities {
|
||||
try {
|
||||
filepath = ResourceUtilities.class.getClassLoader().getResource("").toURI().getPath() + relativeFilePath;
|
||||
} catch (URISyntaxException ex) {
|
||||
LOG.log(Level.SEVERE, null, ex);
|
||||
LOGGER.error("Failed to parse URI", ex);
|
||||
}
|
||||
return new File(filepath);
|
||||
}
|
||||
@@ -142,7 +143,7 @@ public class ResourceUtilities {
|
||||
try {
|
||||
testFolder = ResourceUtilities.class.getClassLoader().getResource("").toURI().getPath();
|
||||
} catch (URISyntaxException ex) {
|
||||
LOG.log(Level.SEVERE, null, ex);
|
||||
LOGGER.error("Failed to parse URI", ex);
|
||||
}
|
||||
return testFolder;
|
||||
}
|
||||
@@ -206,7 +207,7 @@ public class ResourceUtilities {
|
||||
try {
|
||||
ret = new URI(sb.toString()).toASCIIString();
|
||||
} catch (URISyntaxException ex) {
|
||||
LOG.log(Level.SEVERE, null, ex);
|
||||
LOGGER.error("Failed to parse URI", ex);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user