xml import - run in one transaction
This commit is contained in:
parent
d0dc2167ff
commit
4b5d007d69
1 changed files with 13 additions and 12 deletions
|
|
@ -109,9 +109,9 @@ import com.alexanderlogistics.mahnlauf.MahnlaufService;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Stateless
|
@Stateless
|
||||||
public class CargosoftXMLInvoiceImportImportService {
|
public class CargosoftXMLInvoiceImportService {
|
||||||
|
|
||||||
private static Logger logger = Logger.getLogger(CargosoftXMLInvoiceImportImportService.class.getName());
|
private static Logger logger = Logger.getLogger(CargosoftXMLInvoiceImportService.class.getName());
|
||||||
public static final String OPTION_MANDANT_ID = "mandant.id";
|
public static final String OPTION_MANDANT_ID = "mandant.id";
|
||||||
public static final String DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss";
|
public static final String DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss";
|
||||||
public static final String REGEX_IMPORTTEXTPATTERN = "^R[1-8] .*$";
|
public static final String REGEX_IMPORTTEXTPATTERN = "^R[1-8] .*$";
|
||||||
|
|
@ -218,7 +218,7 @@ public class CargosoftXMLInvoiceImportImportService {
|
||||||
ftpClient.connect(ftpServer, ftpPort);
|
ftpClient.connect(ftpServer, ftpPort);
|
||||||
|
|
||||||
if (ftpClient.login(ftpUser, ftpPassword) == false) {
|
if (ftpClient.login(ftpUser, ftpPassword) == false) {
|
||||||
throw new PluginException(CargosoftXMLInvoiceImportImportService.class.getName(),
|
throw new PluginException(CargosoftXMLInvoiceImportService.class.getName(),
|
||||||
"FTP_ERROR", "FTP file transfer failed: login failed!");
|
"FTP_ERROR", "FTP file transfer failed: login failed!");
|
||||||
}
|
}
|
||||||
ftpClient.enterLocalPassiveMode();
|
ftpClient.enterLocalPassiveMode();
|
||||||
|
|
@ -227,7 +227,7 @@ public class CargosoftXMLInvoiceImportImportService {
|
||||||
ftpClient.setControlEncoding("UTF-8");
|
ftpClient.setControlEncoding("UTF-8");
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new PluginException(CargosoftXMLInvoiceImportImportService.class.getName(),
|
throw new PluginException(CargosoftXMLInvoiceImportService.class.getName(),
|
||||||
"FTP_ERROR", e.getMessage());
|
"FTP_ERROR", e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -252,7 +252,7 @@ public class CargosoftXMLInvoiceImportImportService {
|
||||||
// try to enter the working directory and read all files...
|
// try to enter the working directory and read all files...
|
||||||
boolean bWorkingDir = ftpClient.changeWorkingDirectory(ftpPath);
|
boolean bWorkingDir = ftpClient.changeWorkingDirectory(ftpPath);
|
||||||
if (bWorkingDir == false) {
|
if (bWorkingDir == false) {
|
||||||
throw new PluginException(CargosoftXMLInvoiceImportImportService.class.getName(),
|
throw new PluginException(CargosoftXMLInvoiceImportService.class.getName(),
|
||||||
"FTP_ERROR", "...failed to change into working directory: ");
|
"FTP_ERROR", "...failed to change into working directory: ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -282,11 +282,12 @@ public class CargosoftXMLInvoiceImportImportService {
|
||||||
if (invoice != null) {
|
if (invoice != null) {
|
||||||
// persist workitem only if not exists and with a matching mandant.id
|
// persist workitem only if not exists and with a matching mandant.id
|
||||||
if (!invoice.getItemValueString("mandant.id").equals(mandantID)) {
|
if (!invoice.getItemValueString("mandant.id").equals(mandantID)) {
|
||||||
throw new PluginException(CargosoftXMLInvoiceImportImportService.class.getName(),
|
throw new PluginException(CargosoftXMLInvoiceImportService.class.getName(),
|
||||||
"FTP_ERROR", "Invoice does not match mandantID " + mandantID);
|
"FTP_ERROR", "Invoice does not match mandantID " + mandantID);
|
||||||
}
|
}
|
||||||
count++;
|
count++;
|
||||||
workflowService.processWorkItem(invoice);
|
workflowService.processWorkItemByNewTransaction(invoice);
|
||||||
|
// .processWorkItem(invoice);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -302,7 +303,7 @@ public class CargosoftXMLInvoiceImportImportService {
|
||||||
|
|
||||||
} catch (AccessDeniedException | ProcessingErrorException | PluginException
|
} catch (AccessDeniedException | ProcessingErrorException | PluginException
|
||||||
| ModelException | XPathExpressionException | TransformerException e) {
|
| ModelException | XPathExpressionException | TransformerException e) {
|
||||||
throw new PluginException(CargosoftXMLInvoiceImportImportService.class.getName(),
|
throw new PluginException(CargosoftXMLInvoiceImportService.class.getName(),
|
||||||
"FTP_ERROR", e.getMessage());
|
"FTP_ERROR", e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -314,7 +315,7 @@ public class CargosoftXMLInvoiceImportImportService {
|
||||||
int r = ftpClient.getReplyCode();
|
int r = ftpClient.getReplyCode();
|
||||||
logger.severe("FTP ReplyCode=" + r);
|
logger.severe("FTP ReplyCode=" + r);
|
||||||
|
|
||||||
throw new PluginException(CargosoftXMLInvoiceImportImportService.class.getName(),
|
throw new PluginException(CargosoftXMLInvoiceImportService.class.getName(),
|
||||||
"FTP_ERROR", e.getMessage());
|
"FTP_ERROR", e.getMessage());
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
|
|
@ -325,7 +326,7 @@ public class CargosoftXMLInvoiceImportImportService {
|
||||||
ftpClient.disconnect();
|
ftpClient.disconnect();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
documentImportService.logMessage("...FTP file transfer failed: " + e.getMessage(), event);
|
documentImportService.logMessage("...FTP file transfer failed: " + e.getMessage(), event);
|
||||||
throw new PluginException(CargosoftXMLInvoiceImportImportService.class.getName(),
|
throw new PluginException(CargosoftXMLInvoiceImportService.class.getName(),
|
||||||
"FTP_ERROR", e.getMessage());
|
"FTP_ERROR", e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -455,11 +456,11 @@ public class CargosoftXMLInvoiceImportImportService {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finally we attache the pdf file and the XML conent to the workitem.
|
// Finally we attache the pdf file and the XML content to the workitem.
|
||||||
attacheFiles(doc, workitem);
|
attacheFiles(doc, workitem);
|
||||||
|
|
||||||
} catch (ParserConfigurationException | SAXException | IOException e) {
|
} catch (ParserConfigurationException | SAXException | IOException e) {
|
||||||
throw new PluginException(CargosoftXMLInvoiceImportImportService.class.getName(),
|
throw new PluginException(CargosoftXMLInvoiceImportService.class.getName(),
|
||||||
"XML_ERROR", e.getMessage());
|
"XML_ERROR", e.getMessage());
|
||||||
}
|
}
|
||||||
return workitem;
|
return workitem;
|
||||||
Loading…
Reference in a new issue