Author |
Message
|
gagan.maverick |
Posted: Mon Oct 06, 2014 1:07 am Post subject: To store string value in Local environment |
|
|
Acolyte
Joined: 30 Sep 2014 Posts: 50
|
Hi Guys I need to store a string value which contains file name in Local environment in JCN ..
String s = String.format("Entry: %s ",
entry.getName());
System.out.println(s);
Basically value of s to local environment in Jcn |
|
Back to top |
|
 |
gagan.maverick |
Posted: Mon Oct 06, 2014 1:52 am Post subject: |
|
|
Acolyte
Joined: 30 Sep 2014 Posts: 50
|
if i can't modify the local env in JCN then can you tell me how can i add the file name in the msgbody which i have populated as outputroot.blob.blob.. I mean in headers or in any variable |
|
Back to top |
|
 |
kimbert |
Posted: Mon Oct 06, 2014 3:56 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
You will need to explain slowly and carefully what you want to do, and (this is important) why you want to do it. Right now, I have no idea what you need. _________________ Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too. |
|
Back to top |
|
 |
tank_n_spank |
Posted: Mon Oct 06, 2014 4:10 am Post subject: |
|
|
Apprentice
Joined: 02 Sep 2014 Posts: 37
|
I am with Kimbert on this one.
I honestly have no idea what you have pasted, but from what I've gathered, is that what you're after?
Code: |
DECLARE FILE_NAME CHARACTER;
SET FILE_NAME = 'Local Test' ||'.txt';
SET OutputLocalEnvironment.Destination.File.Name = FILE_NAME;
|
|
|
Back to top |
|
 |
gagan.maverick |
Posted: Mon Oct 06, 2014 4:21 am Post subject: |
|
|
Acolyte
Joined: 30 Sep 2014 Posts: 50
|
Sorry guys for the ambiguity..
My requirement was to unzip the zip files in JAVA , which I did. now in JCN i want to store the file names of the contents of zip file in local environment or any where in the output message to use it for further processing.. in JCN i have stored the file name in s...
Code: |
while ((entry = zipStream.getNextEntry()) != null) {
String s = String.format("Entry: %s ",
entry.getName());
System.out.println(s);
int len= 0;
StringBuffer sb_result = new StringBuffer();
while ((len = zipStream.read(buffer)) > 0) {
sb_result.append(new String(buffer, 0, len));
}
zipStream.closeEntry();
String result = sb_result.toString();
file_num = file_num + 1;
MbElement root = outAssembly.getMessage().getRootElement();
msgBytes = result.getBytes();
msgBody = outMessage.getRootElement().createElementAsLastChildFromBitstream(msgBytes,"NONE", "", "", "", 0, 0, 0);
out.propagate(outAssembly);
msgBody.detach(); |
|
|
Back to top |
|
 |
McueMart |
Posted: Mon Oct 06, 2014 4:21 am Post subject: |
|
|
 Chevalier
Joined: 29 Nov 2011 Posts: 490 Location: UK...somewhere
|
|
Back to top |
|
 |
gagan.maverick |
Posted: Mon Oct 06, 2014 4:26 am Post subject: |
|
|
Acolyte
Joined: 30 Sep 2014 Posts: 50
|
Yes correct i would like to assign the value of s to local environment .. but i am getting type mismatch error.. how to resolve that.. |
|
Back to top |
|
 |
kimbert |
Posted: Mon Oct 06, 2014 6:33 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Thanks for explaining - I get the general idea now. But I still have questions.
Which of the following options are you trying to do:
a) pass a list of zip file entries to the remainder of the same message flow
or
b) pass a list of zip file entries to another message flow _________________ Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too. |
|
Back to top |
|
 |
gagan.maverick |
Posted: Mon Oct 06, 2014 11:08 pm Post subject: |
|
|
Acolyte
Joined: 30 Sep 2014 Posts: 50
|
I am sending the unzipped files as blob to the same message flow for processing as the zip file contained an xml file and one pdf file . I need to do further processing on XML file. so in order to know which files has come out I am trying to store its name in local environment for routing. |
|
Back to top |
|
 |
gagan.maverick |
Posted: Tue Oct 07, 2014 1:20 am Post subject: |
|
|
Acolyte
Joined: 30 Sep 2014 Posts: 50
|
Hi i created an mb element for local environment..
MbElement env = assembly.getLocalEnvironment().getRootElement();
MbElement newEnv = env.getFirstElementByPath("messageType");
but how to assign the string s to it.. I mean to newEnv and propagate to Output localenv.. |
|
Back to top |
|
 |
Esa |
Posted: Tue Oct 07, 2014 2:08 am Post subject: |
|
|
 Grand Master
Joined: 22 May 2008 Posts: 1387 Location: Finland
|
gagan.maverick wrote: |
Hi i created an mb element for local environment..
MbElement env = assembly.getLocalEnvironment().getRootElement();
MbElement newEnv = env.getFirstElementByPath("messageType");
|
No, you didn't create anything yet. You just tried to access a non-existent element. |
|
Back to top |
|
 |
kimbert |
Posted: Tue Oct 07, 2014 5:54 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
I am sending the unzipped files as blob to the same message flow for processing as the zip file contained an xml file and one pdf file . I need to do further processing on XML file. so in order to know which files has come out I am trying to store its name in local environment for routing. |
Sounds like a long-winded way to do it. I don't understand why you need to put the filename into the LocalEnvironment. Is there any reason why you are not doing this:
- extract the XML file as as BLOB. Your loop is already doing that.
- parse the XML file using MbElement.createElementAsLastChildFromBitstream(...). Google will help you with the details.
- Allow the message tree to propagate onward to the downstream nodes in the flow.
One other point - if you know that the zip file contains exactly two entries then the while loop is probably not the best solution. Your code should extract each entry in turn, check that it is the expected type of entry, and complain if it gets unexpected input. _________________ Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too. |
|
Back to top |
|
 |
gagan.maverick |
Posted: Tue Oct 07, 2014 10:04 pm Post subject: |
|
|
Acolyte
Joined: 30 Sep 2014 Posts: 50
|
Hi, Actually in my zip file I have one pdf file as well and i need to store that pdf file name somewhere .. so i was wondering if i could store that name coz i will need it afterwards .. there will be plenty of these pdf files and one xml .. in a zip file |
|
Back to top |
|
 |
gagan.maverick |
Posted: Thu Oct 09, 2014 10:27 pm Post subject: |
|
|
Acolyte
Joined: 30 Sep 2014 Posts: 50
|
Hi guys , can you direct me how can i achieve the above .. I mean storing the file name either in message header or in local environment |
|
Back to top |
|
 |
Esa |
Posted: Fri Oct 10, 2014 2:52 am Post subject: |
|
|
 Grand Master
Joined: 22 May 2008 Posts: 1387 Location: Finland
|
gagan.maverick wrote: |
Hi guys , can you direct me how can i achieve the above .. I mean storing the file name either in message header or in local environment |
You almost did it already.
Take a look at this |
|
Back to top |
|
 |
|