/*********************************************************************************************************
 * 프로그램명 : TagFilter.java 프로그램설명 : 프로젝트와 관련된 정보를 얻을수 있는 class 작성자 : 강원중 작성일 : 2002.01.06 변경일 : 2004.09.16
 **********************************************************************************************************/
package kr.co.kihyun.text.html;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.URLDecoder;
import java.net.URLEncoder;
import javax.jdo.PersistenceManager;
import javax.jdo.Transaction;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import kr.co.kihyun.beans.entity.Board;
import kr.co.kihyun.beans.entity.TotDoc;
import kr.co.kihyun.beans.entity.TotReport;
import kr.co.kihyun.beans.entity.util.PMF;

import kr.co.kihyun.beans.user.HttpSSOLogin;
import kr.co.kihyun.io.IUploadable;
import kr.co.kihyun.lang.MLong;
import kr.co.kihyun.lang.MString;
import kr.co.kihyun.moumi.MoumiConfig;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
import java.util.Map;
import java.util.ArrayList;
import java.util.Collections;

@WebServlet("/servlet/kr.co.kihyun.text.html.GetAttachFileName")
public class GetAttachFileName extends HttpServlet {

	private static final long serialVersionUID = 1L;
	private static final Logger LOG = LoggerFactory.getLogger(GetAttachFileName.class);

    String tmpAttachment=null;
    String[] contentPri=null;
   String[] tmpSpitStr = null;

	public void doPost(String rptID) throws ServletException, IOException {

			Long reportID = MLong.parseLong(rptID);
            
			//MJH       
			PersistenceManager pm = PMF.get().getPersistenceManager();
			Transaction tx = pm.currentTransaction();

			tx.begin();
					IUploadable uploadable = null;			
						uploadable = pm.getObjectById(TotReport.class, reportID);
						LOG.debug("reportID: {}, attachments: {}", reportID, uploadable.getAttachments());
                        tmpAttachment = uploadable.getAttachments().keySet().toString();

                        tmpSpitStr = tmpAttachment.split(",");
                        
               for (int i = 0; i < tmpSpitStr.length; i++) {
                         tmpSpitStr[i] = tmpSpitStr[i].toString().replace("[", "");
                         tmpSpitStr[i] = tmpSpitStr[i].toString().replace("]", "");
                         tmpSpitStr[i] = tmpSpitStr[i].toString().replace(" ","");
                         //System.out.println(" Split Tmp String::::"+tmpSpitStr[i].toString());
					}                     

			tx.rollback();
     }

    public String getTmpAttachment(){
          return tmpAttachment;
     }
     
    public String[] getTmpContent(){
          return contentPri;
     }

    public String[] getSplitStr(){
          return tmpSpitStr;
     }

}
