Jacques,
What is the other way that you can suggest? Regards, Pierre Sent from my iPhone > On 6 jul. 2014, at 18:33, Jacques Le Roux <[hidden email]> wrote: > > If you could share your code in another way it would be easier to read ;) > > Jacques > > Le 03/07/2014 15:38, Pierre Smits a écrit : >> Hi all, >> >> Based on some code in OFBiz, I came up with the following to enable upload >> and (partly) process the XML file to create entity records: >> >> public static Map<String, Object> importCamt053(DispatchContext dctx, >> Map<String, Object> context) { >> Debug.logInfo("in MyXmlImportService.java : starting ", >> module); >> Delegator delegator = dctx.getDelegator(); >> LocalDispatcher dispatcher = dctx.getDispatcher(); >> Locale locale = (Locale) context.get("locale"); >> >> GenericValue userLogin = (GenericValue) context.get("userLogin"); >> >> ByteBuffer fileBytes = (ByteBuffer) context.get("uploadedFile"); >> if (fileBytes == null) { >> return >> ServiceUtil.returnError(UtilProperties.getMessage(resource, >> "UploadedFileNotValid", locale)); >> } >> String encoding = System.getProperty("file.encoding"); >> String xmlFile = >> Charset.forName(encoding).decode(fileBytes).toString(); >> >> >> if (xmlFile != null) { >> >> Debug.logInfo("in MyXmlImportService.java : xmlFile = " >> + xmlFile, module); >> >> Document myImportXmlMessage = null; >> try { >> myImportXmlMessage = UtilXml.readXmlDocument(xmlFile, >> false); >> >> Debug.logInfo("in MyXmlImportService.java : >> myImportXmlMessage = " + myImportXmlMessage, module); >> >> Element myXmlDocument = >> myImportXmlMessage.getDocumentElement(); >> >> Debug.logInfo("in MyXmlImportService.java : >> myXmlDocument = " + myXmlDocument, module); >> >> Element HeaderElement = >> UtilXml.firstChildElement(myXmlDocument, “header"); >> String Header = UtilXml.elementValue(HeaderElement); >> Debug.logInfo("in MyXmlImportService.java : Header >> = " + Header, module); >> >> Element TransactionElement = >> UtilXml.firstChildElement(myXmlDocument, “transaction"); >> String Transaction = >> UtilXml.elementValue(TransactionElement); >> Debug.logInfo("in MyXmlImportService.java : >> Transaction = " + Transaction, module); >> >> >> As you can see there are some debug statements to see if it processing >> correctly. >> >> The process in broad strokes is as follows: >> >> 1. I execute opening a new screen and form in my component to upload the >> XML file >> 2. I attach the intended file and execute the process to upload. >> >> In the log I subsequently see that the XML is uploaded and the content of >> the file is shown in the log (as string) through code line: >> >> Debug.logInfo("in MyXmlImportService.java : xmlFile = " + xmlFile, >> module); >> >> >> There it stops doing what is intended. I don't see the result of getting >> the XML or the document element of the XML getting logged with >> >> Debug.logInfo("in MyXmlImportService.java : myImportXmlMessage = " >> + myImportXmlMessage, module); >> >> or >> >> Debug.logInfo("in MyXmlImportService.java : myXmlDocument = " + >> myXmlDocument, module); >> >> >> Nor am I getting any log moments of child elements in the document elements. >> >> Apparently I am missing something in code. >> >> Can you help me out by pointing out the right direction with a code example? >> >> Regards, >> >> >> Pierre Smits >> >> *ORRTIZ.COM <http://www.orrtiz.com>* >> Services & Solutions for Cloud- >> Based Manufacturing, Professional >> Services and Retail & Trade >> http://www.orrtiz.com > > -- |
Administrator
|
Upload a file in Nabble for instance
Jacques Le 06/07/2014 20:02, Pierre @GMail a écrit : > Jacques, > > What is the other way that you can suggest? > > Regards, > > Pierre > > Sent from my iPhone > >> On 6 jul. 2014, at 18:33, Jacques Le Roux <[hidden email]> wrote: >> >> If you could share your code in another way it would be easier to read ;) >> >> Jacques >> >> Le 03/07/2014 15:38, Pierre Smits a écrit : >>> Hi all, >>> >>> Based on some code in OFBiz, I came up with the following to enable upload >>> and (partly) process the XML file to create entity records: >>> >>> public static Map<String, Object> importCamt053(DispatchContext dctx, >>> Map<String, Object> context) { >>> Debug.logInfo("in MyXmlImportService.java : starting ", >>> module); >>> Delegator delegator = dctx.getDelegator(); >>> LocalDispatcher dispatcher = dctx.getDispatcher(); >>> Locale locale = (Locale) context.get("locale"); >>> >>> GenericValue userLogin = (GenericValue) context.get("userLogin"); >>> >>> ByteBuffer fileBytes = (ByteBuffer) context.get("uploadedFile"); >>> if (fileBytes == null) { >>> return >>> ServiceUtil.returnError(UtilProperties.getMessage(resource, >>> "UploadedFileNotValid", locale)); >>> } >>> String encoding = System.getProperty("file.encoding"); >>> String xmlFile = >>> Charset.forName(encoding).decode(fileBytes).toString(); >>> >>> >>> if (xmlFile != null) { >>> >>> Debug.logInfo("in MyXmlImportService.java : xmlFile = " >>> + xmlFile, module); >>> >>> Document myImportXmlMessage = null; >>> try { >>> myImportXmlMessage = UtilXml.readXmlDocument(xmlFile, >>> false); >>> >>> Debug.logInfo("in MyXmlImportService.java : >>> myImportXmlMessage = " + myImportXmlMessage, module); >>> >>> Element myXmlDocument = >>> myImportXmlMessage.getDocumentElement(); >>> >>> Debug.logInfo("in MyXmlImportService.java : >>> myXmlDocument = " + myXmlDocument, module); >>> >>> Element HeaderElement = >>> UtilXml.firstChildElement(myXmlDocument, “header"); >>> String Header = UtilXml.elementValue(HeaderElement); >>> Debug.logInfo("in MyXmlImportService.java : Header >>> = " + Header, module); >>> >>> Element TransactionElement = >>> UtilXml.firstChildElement(myXmlDocument, “transaction"); >>> String Transaction = >>> UtilXml.elementValue(TransactionElement); >>> Debug.logInfo("in MyXmlImportService.java : >>> Transaction = " + Transaction, module); >>> >>> >>> As you can see there are some debug statements to see if it processing >>> correctly. >>> >>> The process in broad strokes is as follows: >>> >>> 1. I execute opening a new screen and form in my component to upload the >>> XML file >>> 2. I attach the intended file and execute the process to upload. >>> >>> In the log I subsequently see that the XML is uploaded and the content of >>> the file is shown in the log (as string) through code line: >>> >>> Debug.logInfo("in MyXmlImportService.java : xmlFile = " + xmlFile, >>> module); >>> >>> >>> There it stops doing what is intended. I don't see the result of getting >>> the XML or the document element of the XML getting logged with >>> >>> Debug.logInfo("in MyXmlImportService.java : myImportXmlMessage = " >>> + myImportXmlMessage, module); >>> >>> or >>> >>> Debug.logInfo("in MyXmlImportService.java : myXmlDocument = " + >>> myXmlDocument, module); >>> >>> >>> Nor am I getting any log moments of child elements in the document elements. >>> >>> Apparently I am missing something in code. >>> >>> Can you help me out by pointing out the right direction with a code example? >>> >>> Regards, >>> >>> >>> Pierre Smits >>> >>> *ORRTIZ.COM <http://www.orrtiz.com>* >>> Services & Solutions for Cloud- >>> Based Manufacturing, Professional >>> Services and Retail & Trade >>> http://www.orrtiz.com >> -- > -- |
Jacques,
Thank you for the suggestion. Unfortunately, the nabble site doesn't allow members to register or login in a secured, encrypted way (through ssl). Nor does the Terms of Use ( see here: http://www.nabble.com/Terms.jtp ) assure me that the utmost is done to keep my credentials private and my postings unaltered. It is for those reasons that I must respectfully decline to follow up on your suggestion to post anything directly there. I trust you know of an alternative way to share the code. Regards, Pierre Smits *ORRTIZ.COM <http://www.orrtiz.com>* Services & Solutions for Cloud- Based Manufacturing, Professional Services and Retail & Trade http://www.orrtiz.com On Mon, Jul 7, 2014 at 10:52 AM, Jacques Le Roux < [hidden email]> wrote: > Upload a file in Nabble for instance > |
Administrator
|
http://www.sitepoint.com/top-5-places-to-share-code-quickly/ ?
Jacques Le 07/07/2014 11:23, Pierre Smits a écrit : > Jacques, > > Thank you for the suggestion. Unfortunately, the nabble site doesn't allow > members to register or login in a secured, encrypted way (through ssl). Nor > does the Terms of Use ( see here: http://www.nabble.com/Terms.jtp ) assure > me that the utmost is done to keep my credentials private and my postings > unaltered. It is for those reasons that I must respectfully decline to > follow up on your suggestion to post anything directly there. > > I trust you know of an alternative way to share the code. > > Regards, > > Pierre Smits > > *ORRTIZ.COM <http://www.orrtiz.com>* > Services & Solutions for Cloud- > Based Manufacturing, Professional > Services and Retail & Trade > http://www.orrtiz.com > > > On Mon, Jul 7, 2014 at 10:52 AM, Jacques Le Roux < > [hidden email]> wrote: > >> Upload a file in Nabble for instance >> -- |
Free forum by Nabble | Edit this page |