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