/*
 * 
 * Created on Aug 3, 2005
 * 
 * György Süveges
 * Etixpert Kft.
 * Copyright(c) 2005
 * 
 */
package com.etixpert.evolution.gui.servlets.pageactions;

import javax.servlet.http.*;
import org.apache.commons.fileupload.*;
import java.util.*;
import com.etixpert.evolution.*;



/**
 * @author Suveges Gyorgy
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class newsletter_delete extends MultipartPageActionHandler {

    /**
     * 
     */
    public newsletter_delete() {
        super();
        // TODO Auto-generated constructor stub
    }

    /* (non-Javadoc)
     * @see com.etixpert.evolution.gui.servlets.pageactions.PageActionHandler#handle(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
     */
    protected void handle(HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        	
        HttpSession session = request.getSession();
        Map jspMap = (Map) session.getAttribute("newsletter.jsp");
        if (jspMap == null) return;
        List l = (List) jspMap.get("files");
        if (l==null) return;
        logger.info("delfile" + Tools.getVal(jspMap, "delfile","-1"));
        int index = new Integer(Tools.getVal(jspMap, "delfile","-1")).intValue();
        logger.info("deleting "+index+". file from the attachment list");
        if (index<0) 
            return;
        
       // FileItem item = (FileItem) l.get(index);
        //item.delete();
        l.remove(index);

    }

}
