working on #878
This commit is contained in:
@@ -4,6 +4,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.text.ParseException;
|
||||
|
||||
import org.mustangproject.XMLTools;
|
||||
import org.slf4j.Logger;
|
||||
@@ -18,7 +19,7 @@ public class XRechnungImporter extends ZUGFeRDImporter {
|
||||
try {
|
||||
setRawXML(rawXml);
|
||||
containsMeta = true;
|
||||
} catch (final IOException e) {
|
||||
} catch (final IOException | ParseException e) {
|
||||
LOGGER.error ("Failed to set raw XML", e);
|
||||
throw new ZUGFeRDExportException(e);
|
||||
}
|
||||
@@ -30,24 +31,21 @@ public class XRechnungImporter extends ZUGFeRDImporter {
|
||||
try {
|
||||
setRawXML(Files.readAllBytes(Paths.get(filename)));
|
||||
containsMeta = true;
|
||||
} catch (final IOException e) {
|
||||
LOGGER.error ("Failed to set raw XML", e);
|
||||
} catch (final IOException | ParseException e) {
|
||||
LOGGER.error ("Failed to set raw XML", e);
|
||||
throw new ZUGFeRDExportException(e);
|
||||
}
|
||||
|
||||
}
|
||||
public XRechnungImporter(InputStream fileinput) {
|
||||
super();
|
||||
|
||||
try {
|
||||
setRawXML(XMLTools.getBytesFromStream(fileinput));
|
||||
containsMeta = true;
|
||||
} catch (final IOException e) {
|
||||
LOGGER.error ("Failed to set raw XML", e);
|
||||
} catch (final IOException | ParseException e) {
|
||||
LOGGER.error ("Failed to set raw XML", e);
|
||||
throw new ZUGFeRDExportException(e);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ package org.mustangproject.ZUGFeRD;
|
||||
* @author jstaerk
|
||||
*/
|
||||
import java.io.*;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
@@ -452,7 +453,11 @@ public class ZUGFeRDImporter extends ZUGFeRDInvoiceImporter {
|
||||
* @throws IOException if raw can not be set
|
||||
*/
|
||||
public void setMeta(String meta) throws IOException {
|
||||
setRawXML(meta.getBytes());
|
||||
try {
|
||||
setRawXML(meta.getBytes());
|
||||
} catch (ParseException e) {
|
||||
LOGGER.error("Failed to parse", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -174,7 +174,12 @@ public class ZUGFeRDInvoiceImporter {
|
||||
} else {
|
||||
// no PDF probably XML
|
||||
containsMeta = true;
|
||||
setRawXML(XMLTools.getBytesFromStream(pdfStream));
|
||||
try {
|
||||
setRawXML(XMLTools.getBytesFromStream(pdfStream));
|
||||
} catch(ParseException e) {
|
||||
LOGGER.error("Failed to parse PDF", e);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -219,8 +224,11 @@ public class ZUGFeRDInvoiceImporter {
|
||||
// ByteArrayOutputStream();
|
||||
// FileOutputStream fos = new FileOutputStream(file);
|
||||
|
||||
setRawXML(embeddedFile.toByteArray());
|
||||
|
||||
try {
|
||||
setRawXML(embeddedFile.toByteArray());
|
||||
} catch (ParseException e) {
|
||||
LOGGER.error("Failed to parse XML", e);
|
||||
}
|
||||
// fos.write(embeddedFile.getByteArray());
|
||||
// fos.close();
|
||||
}
|
||||
@@ -237,7 +245,7 @@ public class ZUGFeRDInvoiceImporter {
|
||||
* @param doParse automatically parse input for zugferdImporter (not ZUGFeRDInvoiceImporter)
|
||||
* @throws IOException if parsing xml throws it (unlikely its string based)
|
||||
*/
|
||||
public void setRawXML(byte[] rawXML, boolean doParse) throws IOException {
|
||||
public void setRawXML(byte[] rawXML, boolean doParse) throws IOException, ParseException {
|
||||
this.containsMeta = true;
|
||||
this.rawXML = rawXML;
|
||||
this.version = null;
|
||||
@@ -245,7 +253,7 @@ public class ZUGFeRDInvoiceImporter {
|
||||
|
||||
try {
|
||||
setDocument();
|
||||
} catch (ParserConfigurationException | SAXException | ParseException e) {
|
||||
} catch (ParserConfigurationException | SAXException e) {
|
||||
LOGGER.error("Failed to parse XML", e);
|
||||
throw new ZUGFeRDExportException(e);
|
||||
}
|
||||
@@ -257,7 +265,7 @@ public class ZUGFeRDInvoiceImporter {
|
||||
* @param rawXML the cii(?) as a string
|
||||
* @throws IOException if parsing xml throws it (unlikely its string based)
|
||||
*/
|
||||
public void setRawXML(byte[] rawXML) throws IOException {
|
||||
public void setRawXML(byte[] rawXML) throws IOException, ParseException {
|
||||
setRawXML(rawXML, true);
|
||||
}
|
||||
|
||||
@@ -1205,7 +1213,7 @@ public class ZUGFeRDInvoiceImporter {
|
||||
* sets the XML for the importer to parse
|
||||
* @param XML the UBL or CII
|
||||
*/
|
||||
public void fromXML(String XML) {
|
||||
public void fromXML(String XML) throws ParseException{
|
||||
try {
|
||||
containsMeta = true;
|
||||
setRawXML(XML.getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
@@ -79,7 +79,7 @@ public class DeSerializationTest extends ResourceCase {
|
||||
try {
|
||||
zii.fromXML(new String(Files.readAllBytes(inputCII.toPath()), StandardCharsets.UTF_8));
|
||||
|
||||
} catch (IOException e) {
|
||||
} catch (IOException | ParseException e) {
|
||||
hasExceptions = true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user