cancel
Showing results for 
Search instead for 
Did you mean: 

Retaining the fileName inside the zipped files

Former Member
0 Kudos

Hi Experts,

I am working on a file to file scenario, in which the files have to be picked up the files in pair(pdf) and zip them and post in the particular folder.

I have used PayloadZipBean for zipping the files, but not able to get the original file names inside the zip, but i am getting one Mail and one additional file.

This thread seems to be similar to my problem:

Please suggest.

Thanks,

Sushama

Accepted Solutions (0)

Answers (1)

Answers (1)

stefan_grube
Active Contributor
0 Kudos

The PayloadZipBan is not very flexible for creating file names inside the zip file.

Especially when you want to zip several files together, you should think about alternatives, for example zipping the files with a user command.

Former Member
0 Kudos

Hi,

I have done developed an adapter module for retaining the file name, before PauloadZip Bean, in receiver file adapter:

*/

package sample;

import javax.ejb.CreateException;

import javax.ejb.SessionBean;

import javax.ejb.SessionContext;

import com.sap.aii.af.mp.module.*;

import com.sap.aii.af.ra.ms.api.*;

/**

  • @ejbHome <{com.sap.aii.af.mp.module.ModuleHome}>

  • @ejbLocal <{com.sap.aii.af.mp.module.ModuleLocal}>

  • @ejbLocalHome <{com.sap.aii.af.mp.module.ModuleLocalHome}>

  • @ejbRemote <{com.sap.aii.af.mp.module.ModuleRemote}>

  • @stateless

*/

public class SetAttachmentName implements SessionBean, Module{

private SessionContext myContext;

public void ejbRemove() {

}

public void ejbActivate() {

}

public void ejbPassivate() {

}

public void setSessionContext(SessionContext context) {

myContext = context;

}

public void ejbCreate() throws CreateException {

}

public ModuleData process(ModuleContext moduleContext, ModuleData inputModuleData)

throws ModuleException{

try {

Message msg = (Message) inputModuleData.getPrincipalData();

Payload payload = msg.getDocument();

String fileName = msg.getMessageProperty("http://sap.com/xi/XI/System/File",

"FileName");

if(fileName == null) fileName="default.txt";

payload.setContentType("text/plain;charset = \"UTF-8\";"

+ "name=\"" + fileName + "\"");

inputModuleData.setPrincipalData(msg);

} catch (Exception e) {

throw new ModuleException(e);

}

return inputModuleData;

}

}

But, I am getting corrupted files .

Please advise.

Thanks,

sushama

Edited by: sushama pandey on Sep 28, 2011 4:52 AM