package fr.insee.eno.utils;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class FileArchiver {
	
	private static final Logger LOGGER = LoggerFactory.getLogger(FileArchiver.class);
	
	/**
     * Add a file into Zip file.
     * 
     * @param filePath
     * @param zipStream
     * @throws FileNotFoundException
     * @throws IOException
     */
    public static void writeToZipFile(String surveyName, String filePath, ZipOutputStream zipStream)
            throws FileNotFoundException, IOException {
    	
    	LOGGER.info("Writing file : '"+filePath+ "' to archive file.");

        File file = new File(filePath);
        FileInputStream fileIS = new FileInputStream(file);
        
        ZipEntry zipEntry = new ZipEntry(surveyName + "/" + file.getParentFile().getName()+"/form/"+file.getName());
        
        zipStream.putNextEntry(zipEntry);
        zipStream.write(IOUtils.toByteArray(fileIS));
        zipStream.closeEntry();
        fileIS.close();
    }

}

@@ -422,16 +422,96 @@
 ass);%0A%09%0A
+%09private static final String ZIP_ENTRY_PATH_FORMAT = %22orbeon/fr/%25s/%25s/form/%25s%22;%0A
 %09/**%0A   
@@ -1050,16 +1050,64 @@
 ipEntry(
+%0A        %09%09String.format(ZIP_ENTRY_PATH_FORMAT, 
 surveyNa
@@ -1112,16 +1112,9 @@
 Name
- + %22/%22 +
+,
  fil
@@ -1144,18 +1144,9 @@
 me()
-+%22/form/%22+
+,
 file
@@ -1156,16 +1156,17 @@
 tName())
+)
 ;%0A      

Update FileArchiver.java