package kr.co.kihyun.beans.totsys.menu;

import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import javax.jdo.PersistenceManager;
import javax.jdo.Transaction;
import javax.servlet.http.HttpServletRequest;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreeModel;
import javax.swing.tree.TreeNode;
import kr.co.kihyun.beans.entity.TotDoc;
import kr.co.kihyun.beans.entity.util.*;
import kr.co.kihyun.beans.entity.util.MPersistenceManager;
import kr.co.kihyun.lang.Encoder;
import kr.co.kihyun.lang.MLong;
import kr.co.kihyun.lang.MString;

public class DefaultMenu implements Serializable {

//    Long docID = null;
    String docName = "";
//    String docGroupID = "";
    /**
     *
     */
    private static final long serialVersionUID = 1L;
    private static TreeModel menuModel = null;

    public DefaultMenu(HttpServletRequest req) {
        menuModel = null;
        menuModel = getDefaultMenuList(req);
    }

    private TreeModel getDefaultMenuList(HttpServletRequest req) {
//        PersistenceManager pm = new MPersistenceManager(PMF.get().getPersistenceManager());
//        Transaction tx = pm.currentTransaction();
        DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode();

        try {
            StringBuilder sb = new StringBuilder();
            String title = "";
            String boardtitle = "";
            for (Enumeration<String> en = req.getParameterNames(); en.hasMoreElements();) {
                String key = en.nextElement();
                sb.append(key + "=" + req.getParameter(key) + "&");
            }
            String paramStr = sb.toString();
            if (paramStr.length() != 0) {
                paramStr = paramStr.substring(0, paramStr.length() - 1);
            }

//            docID = MLong.parseLong(req.getParameter("docID"), null);
//            if (docID != null) {
////                        tx.begin();
////				TotDoc totDoc = null;
////				PersistenceManager pm = null;
////				pm = new MPersistenceManager(PMF.get().getPersistenceManager());
//                TotDoc totDoc = pm.getObjectById(TotDoc.class, docID);
//                docName = totDoc.getName();
////                        tx.rollback();
//            }
//            if (docName.equals("")) {
//                docName = URLDecoder.decode(MString.checkNull(Encoder.toJava(req.getParameter("docName"))), "UTF-8");
//            }
//
//            setDocName(docName);
//
//            docGroupID = MString.checkNull(req.getParameter("boardGroupID"));

            /**
             * **********************************************************************************
             */
            /**
             * *************************** 사용자 화면 **************************************
             */
            /**
             * **********************************************************************************
             */
            /**
             * ************************* 집계자료등록 ******************************************
             */
            DefaultMutableTreeNode docRegist = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/totper/mydocbox/regbox/doc_regist.jsp?" + paramStr));
            DefaultMutableTreeNode formConfig = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/totper/mydocbox/regbox/doc_form_config.jsp?" + paramStr));
            DefaultMutableTreeNode formTest = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/common/web/documents/tot_doc/popup_inform_preview.jsp?" + paramStr));

                        //DefaultMutableTreeNode prssboxTransfer2 = new DefaultMutableTreeNode(new MenuBean(req,"/totsys/repoper/mydocbox/returnbox/popup_rep_transfer2.jsp?" + paramStr));
            rootNode.add(docRegist);
            rootNode.add(formConfig);
            rootNode.add(formTest);
            //rootNode.add(prssboxTransfer2);

            /**
             * **************************** 집계진행함 ***************************************
             */
            DefaultMutableTreeNode prssboxList = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/totper/mydocbox/prssbox/doc_list.jsp?" + paramStr));
//            DefaultMutableTreeNode prssboxDocView = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/totper/mydocbox/prssbox/doc_view.jsp?" + paramStr));
//            DefaultMutableTreeNode prssboxTransfer = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/totper/mydocbox/prssbox/reports/popup_rep_transfer.jsp?" + paramStr));
//
//            DefaultMutableTreeNode prssboxTransfer2 = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/repoper/mydocbox/returnbox/popup_rep_transfer.jsp?" + paramStr));

            DefaultMutableTreeNode prssboxReportList = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/totper/mydocbox/prssbox/reports/report_list.jsp?" + paramStr));
            DefaultMutableTreeNode prssboxTotReports = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/totper/mydocbox/prssbox/tot_reports/total_reports.jsp?" + paramStr));
//            DefaultMutableTreeNode prssboxTotReport = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/totper/mydocbox/prssbox/tot_report/total_report.jsp?" + paramStr));
//            DefaultMutableTreeNode prssboxFormView = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/totper/mydocbox/prssbox/doc_form_view.jsp?" + paramStr));
            DefaultMutableTreeNode prssboxDocModify = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/totper/mydocbox/prssbox/doc_modify.jsp?" + paramStr));
//            DefaultMutableTreeNode prssboxFormModify = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/totper/mydocbox/prssbox/doc_form_modify.jsp?" + paramStr));
//            DefaultMutableTreeNode prssboxReportView = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/totper/mydocbox/prssbox/reports/report_view.jsp?" + paramStr));

//            prssboxReportList.add(prssboxReportView);
//            prssboxFormView.add(prssboxFormModify);
//            prssboxList.add(prssboxDocView);

            prssboxList.add(prssboxDocModify);
//            prssboxList.add(prssboxTransfer);
//            prssboxList.add(prssboxTransfer2);

//            prssboxList.add(prssboxFormView);
            prssboxList.add(prssboxReportList);
            prssboxList.add(prssboxTotReports);
//            prssboxList.add(prssboxTotReport);
            rootNode.add(prssboxList);

            /**
             * ****************************** 종료함 *****************************************
             */
//            DefaultMutableTreeNode endboxList = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/totper/mydocbox/endbox/doc_list.jsp?" + paramStr));
//            DefaultMutableTreeNode endboxDocView = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/totper/mydocbox/endbox/doc_view.jsp?" + paramStr));
//            DefaultMutableTreeNode endboxtotReports = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/totper/mydocbox/endbox/tot_reports/total_reports.jsp?" + paramStr));
//            DefaultMutableTreeNode endboxReport = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/totper/mydocbox/endbox/reports/report_list.jsp?" + paramStr));
//            DefaultMutableTreeNode endboxTotReport = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/totper/mydocbox/endbox/tot_report/total_report.jsp?" + paramStr));
//            DefaultMutableTreeNode endboxFormView = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/totper/mydocbox/endbox/doc_form_view.jsp?" + paramStr));
//            DefaultMutableTreeNode endboxDocModify = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/totper/mydocbox/endbox/doc_modify.jsp?" + paramStr));
//            DefaultMutableTreeNode endboxReportView = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/totper/mydocbox/endbox/reports/report_view.jsp?" + paramStr));
//
//            endboxReport.add(endboxReportView);
//            endboxList.add(endboxDocView);
//            endboxList.add(endboxDocModify);
//            endboxList.add(endboxFormView);
//            endboxList.add(endboxReport);
//            endboxList.add(endboxtotReports);
//            endboxList.add(endboxTotReport);
//            rootNode.add(endboxList);

            /**
             * ****************************** 종료함 *****************************************
             */
//            DefaultMutableTreeNode cancleboxList = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/totper/mydocbox/canclebox/doc_list.jsp?" + paramStr));
//            DefaultMutableTreeNode cancleboxDocView = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/totper/mydocbox/canclebox/doc_view.jsp?" + paramStr));
//            DefaultMutableTreeNode cancleboxtotReports = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/totper/mydocbox/canclebox/tot_reports/total_reports.jsp?" + paramStr));
//            DefaultMutableTreeNode cancleboxReport = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/totper/mydocbox/canclebox/reports/report_list.jsp?" + paramStr));
//            DefaultMutableTreeNode cancleboxReportView = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/totper/mydocbox/canclebox/reports/report_view.jsp?" + paramStr));
//            DefaultMutableTreeNode cancleboxTotReport = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/totper/mydocbox/canclebox/tot_report/total_report.jsp?" + paramStr));
//            DefaultMutableTreeNode cancleboxFormView = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/totper/mydocbox/canclebox/doc_form_view.jsp?" + paramStr));
//            DefaultMutableTreeNode cancleboxDocModify = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/totper/mydocbox/canclebox/doc_modify.jsp?" + paramStr));
//
//            cancleboxReport.add(cancleboxReportView);
//            cancleboxList.add(cancleboxDocView);
//            cancleboxList.add(cancleboxDocModify);
//            cancleboxList.add(cancleboxFormView);
//            cancleboxList.add(cancleboxReport);
//            cancleboxList.add(cancleboxtotReports);
//            cancleboxList.add(cancleboxTotReport);
//            rootNode.add(cancleboxList);

//            DefaultMutableTreeNode syscancleboxList = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/sysadm/canclebox/doc_list.jsp?" + paramStr));
//            DefaultMutableTreeNode syscancleboxDocView = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/sysadm/canclebox/doc_view.jsp?" + paramStr));
//            DefaultMutableTreeNode syscancleboxtotReports = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/sysadm/canclebox/tot_reports/total_reports.jsp?" + paramStr));
//            DefaultMutableTreeNode syscancleboxReport = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/sysadm/canclebox/reports/report_list.jsp?" + paramStr));
//            DefaultMutableTreeNode syscancleboxReportView = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/sysadm/canclebox/reports/report_view.jsp?" + paramStr));
//            DefaultMutableTreeNode syscancleboxTotReport = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/sysadm/canclebox/tot_report/total_report.jsp?" + paramStr));
//            DefaultMutableTreeNode syscancleboxFormView = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/sysadm/canclebox/doc_form_view.jsp?" + paramStr));
//            DefaultMutableTreeNode syscancleboxDocModify = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/sysadm/canclebox/doc_modify.jsp?" + paramStr));
//
//            syscancleboxReport.add(syscancleboxReportView);
//            cancleboxList.add(syscancleboxDocView);
//            cancleboxList.add(syscancleboxDocModify);
//            cancleboxList.add(syscancleboxFormView);
//            cancleboxList.add(syscancleboxReport);
//            cancleboxList.add(syscancleboxtotReports);
//            cancleboxList.add(syscancleboxTotReport);
//            rootNode.add(syscancleboxList);

            /**
             * ****************************** 양식함 *****************************************
             */
//            DefaultMutableTreeNode formBoxNode = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/totper/mydocbox/formbox/doc_list.jsp?" + paramStr));
//            DefaultMutableTreeNode formInfoNode = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/totper/mydocbox/formbox/doc_view.jsp?" + paramStr));
//            DefaultMutableTreeNode formInfoNodeInf = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/totper/mydocbox/formbox/doc_form_modify.jsp?" + paramStr));
//            DefaultMutableTreeNode formPrivew = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/totper/mydocbox/formbox/doc_form_preview.jsp?" + paramStr));
//            DefaultMutableTreeNode formReformConfig = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/totper/mydocbox/formbox/doc_reform_config.jsp?" + paramStr));
//            DefaultMutableTreeNode formInfoNodeFormShow = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/common/web/documents/tot_doc/modify_inform_preview.jsp?" + paramStr));
//            DefaultMutableTreeNode formInfoNodeForm = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/common/web/documents/form_content_modify/form_content_modify.jsp?" + paramStr));
//            DefaultMutableTreeNode formInfoNodeFormModify = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/totper/mydocbox/prssbox/form_content_modify.jsp?" + paramStr));
//            DefaultMutableTreeNode formInfoNodeFormConfig = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/totper/mydocbox/prssbox/doc_form_config.jsp?" + paramStr));
//            DefaultMutableTreeNode formInsert = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/totper/mydocbox/formbox/doc_regist.jsp?" + paramStr));
//            DefaultMutableTreeNode formInsFormModify = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/totper/mydocbox/formbox/doc_form_config.jsp?" + paramStr));
//            DefaultMutableTreeNode formInsFormPreview = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/common/web/documents/tot_doc/inform_preview_form.jsp?" + paramStr));
//            DefaultMutableTreeNode formInfModify = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/common/web/documents/tot_doc/popup_modify.jsp?" + paramStr));
//
//            formInfoNodeForm.add(formReformConfig);
//            formInfoNodeInf.add(formPrivew);
//
//            formBoxNode.add(formInfModify);
//            formBoxNode.add(formInsFormPreview);
//            formBoxNode.add(formInsFormModify);
//            formBoxNode.add(formInsert);
//            formBoxNode.add(formInfoNodeFormShow);
//            formBoxNode.add(formInfoNodeFormConfig);
//            formBoxNode.add(formInfoNodeFormModify);
//            formBoxNode.add(formInfoNodeForm);
//            formBoxNode.add(formInfoNodeInf);
//            formBoxNode.add(formInfoNode);
//            rootNode.add(formBoxNode);

            /**
             * *************************** 사용자그룹설정 **************************************
             */
            rootNode.add(new DefaultMutableTreeNode(new MenuBean(req, "/totsys/login/envsetting/group/group_setup.jsp?" + paramStr)));
            /**
             * *************************** 통계 **************************************
             */
            rootNode.add(new DefaultMutableTreeNode(new MenuBean(req, "/totsys/common/inc/statistics/statistics.jsp?" + paramStr)));

            /**
             * *************************** 접수함 **************************************
             */
            DefaultMutableTreeNode returnbox = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/repoper/mydocbox/returnbox/report_list.jsp?" + paramStr));
//            DefaultMutableTreeNode returnboxDeptReportList = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/repoper/mydocbox/returnbox/dept_report_list.jsp?" + paramStr));
            DefaultMutableTreeNode returnboxRegist = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/repoper/mydocbox/tempbox/report_regist.jsp?" + paramStr));
            DefaultMutableTreeNode returnboxSubRegist = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/totper/mydocbox/regbox/sub_doc_regist.jsp?" + paramStr));
//            DefaultMutableTreeNode returnboxReportView = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/repoper/mydocbox/acceptbox/report_view.jsp?" + paramStr));
//            DefaultMutableTreeNode returnUpdate = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/repoper/mydocbox/returnbox/report_view.jsp?" + paramStr));
//            DefaultMutableTreeNode returnUpdateTransfer = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/repoper/mydocbox/returnbox/popup_rep_transfer.jsp?" + paramStr));
//            DefaultMutableTreeNode acceptboxUPtrans = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/repoper/mydocbox/acceptbox/popup_rep_transfer.jsp?" + paramStr));
//            DefaultMutableTreeNode returnUTseach = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/repoper/mydocbox/acceptbox/popup_transfer.jsp?" + paramStr));
            DefaultMutableTreeNode returnModify = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/repoper/mydocbox/returnbox/return_report_modify.jsp?" + paramStr));

//            acceptboxUPtrans.add(returnUTseach);
            returnboxRegist.add(returnboxSubRegist);
            // returnboxReportView.add(returnboxRegist);
//            returnboxRegist.add(acceptboxUPtrans);

            returnbox.add(returnboxRegist);
//            returnbox.add(returnUpdate);
//            returnbox.add(returnboxReportView);
//            returnbox.add(returnboxDeptReportList);
//            returnbox.add(returnUpdateTransfer);
            returnbox.add(returnModify);
            rootNode.add(returnbox);

            /**
             * *************************** 임시저장함 **************************************
             */
            DefaultMutableTreeNode tempbox = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/repoper/mydocbox/tempbox/report_list.jsp?" + paramStr));
            DefaultMutableTreeNode tempboxView = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/repoper/mydocbox/tempbox/report_view.jsp?" + paramStr));
            DefaultMutableTreeNode tempboxModify = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/repoper/mydocbox/tempbox/temp_report_modify.jsp?" + paramStr));
//            DefaultMutableTreeNode tempboxTransfer = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/repoper/mydocbox/tempbox/popup_rep_transfer.jsp?" + paramStr));
//            DefaultMutableTreeNode tempboxTransferSc = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/repoper/mydocbox/tempbox/popup_transfer.jsp?" + paramStr));
            // tempboxView.add(tempboxTransfer);

//            tempboxTransfer.add(tempboxTransferSc);
//            tempbox.add(tempboxTransfer);
            tempbox.add(tempboxModify);
            tempbox.add(tempboxView);
            rootNode.add(tempbox);

            /**
             * *************************** 내제출문서함 **************************************
             */
            rootNode.add(new DefaultMutableTreeNode(new MenuBean(req, "/totsys/repoper/mydocbox/compbox/report_list.jsp?" + paramStr)));
            DefaultMutableTreeNode compbox = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/repoper/mydocbox/compbox/report_list.jsp?" + paramStr));
            DefaultMutableTreeNode compboxView = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/repoper/mydocbox/compbox/report_view.jsp?" + paramStr));
//            DefaultMutableTreeNode compboxTransfer = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/repoper/mydocbox/compbox/popup_rep_transfer.jsp?" + paramStr));

            // compboxView.add(compboxTransfer);
            compbox.add(compboxView);
//            rootNode.add(compboxTransfer);
            rootNode.add(compbox);

            /**
             * *************************** 전체제출문서함 **************************************
             */
            rootNode.add(new DefaultMutableTreeNode(new MenuBean(req, "/totsys/repoper/mydocbox/endbox/report_list.jsp?" + paramStr)));
            DefaultMutableTreeNode allcompbox = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/repoper/mydocbox/endbox/report_list.jsp?" + paramStr));
            DefaultMutableTreeNode allcompboxView = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/repoper/mydocbox/endbox/report_view.jsp?" + paramStr));

            allcompbox.add(allcompboxView);
            compbox.add(allcompbox);
            rootNode.add(allcompbox);

            /**
             * *************************** 표복사입력 **************************************
             */
            rootNode.add(new DefaultMutableTreeNode(new MenuBean(req, "/totsys/repoper/mydocbox/tempbox/popup_copy_form.jsp?" + paramStr)));

            /**
             * ************************************ 게시판 **************************************
             */
            DefaultMutableTreeNode boardList = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/sysadm/board/board_list.jsp?" + paramStr));
            DefaultMutableTreeNode boardWrite = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/sysadm/board/board_write.jsp?" + paramStr));
            DefaultMutableTreeNode boardRead = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/sysadm/board/board_view.jsp?" + paramStr));
            DefaultMutableTreeNode boardModify = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/sysadm/board/board_modify.jsp?" + paramStr));

            boardRead.add(boardModify);
            boardList.add(boardRead);
            boardList.add(boardWrite);
            rootNode.add(boardList);

            /**
             * **********************************************************************************
             */
            /**
             * *************************** 시스템관리자 화면 **************************************
             */
            /**
             * **********************************************************************************
             */
//            DefaultMutableTreeNode sys_docformbox = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/sysadm/formbox/doc_list.jsp?" + paramStr));
//            DefaultMutableTreeNode sys_form_info = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/sysadm/formbox/doc_view.jsp?" + paramStr));
//            DefaultMutableTreeNode sys_form_modify = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/common/web/documents/form_content_modify/sysadm_form_content_modify.jsp?" + paramStr));
//            DefaultMutableTreeNode sys_form_attribute = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/sysadm/formbox/doc_form_modify.jsp?" + paramStr));
//            DefaultMutableTreeNode sys_form_test = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/common/web/documents/tot_doc/sysadm_modify_inform_preview.jsp?" + paramStr));
//            sys_form_attribute.add(sys_form_test);
//            sys_form_info.add(sys_form_attribute);
//            sys_form_info.add(sys_form_modify);
//            sys_docformbox.add(sys_form_info);
//            rootNode.add(sys_docformbox);
//
//            DefaultMutableTreeNode sys_doc_list = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/sysadm/prssbox/doc_list.jsp?" + paramStr));
//            DefaultMutableTreeNode sys_report_list = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/sysadm/prssbox/reports/report_list.jsp?" + paramStr));
//            DefaultMutableTreeNode sys_report_list_view = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/sysadm/prssbox/reports/report_view.jsp?" + paramStr));
//            DefaultMutableTreeNode sys_doc_view = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/sysadm/prssbox/doc_view.jsp?" + paramStr));
//            DefaultMutableTreeNode sys_doc_form_view = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/sysadm/prssbox/doc_form_view.jsp?" + paramStr));
//            DefaultMutableTreeNode sys_tot_reports = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/sysadm/prssbox/tot_reports/total_reports.jsp?" + paramStr));
//            DefaultMutableTreeNode sys_tot_report = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/sysadm/prssbox/tot_report/total_report.jsp?" + paramStr));
//            DefaultMutableTreeNode sys_doc_modify = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/sysadm/prssbox/doc_modify.jsp?" + paramStr));
//            DefaultMutableTreeNode sys_form_modify2 = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/sysadm/prssbox/form_content_modify.jsp?" + paramStr));
//            DefaultMutableTreeNode sys_form_config = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/sysadm/prssbox/doc_form_config.jsp?" + paramStr));
//            DefaultMutableTreeNode sys_form_modify3 = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/sysadm/prssbox/doc_form_modify.jsp?" + paramStr));
//            DefaultMutableTreeNode sys_inform_preview = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/sysadm/prssbox/doc_form_preview.jsp?" + paramStr));
//
//            sys_report_list.add(sys_report_list_view);
//            sys_form_modify3.add(sys_inform_preview);
//            sys_form_modify2.add(sys_form_config);
//            sys_doc_form_view.add(sys_form_modify3);
//            sys_doc_form_view.add(sys_form_modify2);
//            sys_doc_view.add(sys_doc_modify);
//            sys_doc_list.add(sys_tot_report);
//            sys_doc_list.add(sys_tot_reports);
//            sys_doc_list.add(sys_doc_form_view);
//            sys_doc_list.add(sys_doc_view);
//            sys_doc_list.add(sys_report_list);
//            rootNode.add(sys_doc_list);
//
//            DefaultMutableTreeNode sys_end_doclist = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/sysadm/endbox/doc_list.jsp?" + paramStr));
//            DefaultMutableTreeNode sys_end_view = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/sysadm/endbox/doc_view.jsp?" + paramStr));
//            DefaultMutableTreeNode sys_end_form = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/sysadm/endbox/doc_form_view.jsp?" + paramStr));
//            DefaultMutableTreeNode sys_end_report = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/sysadm/endbox/reports/report_list.jsp?" + paramStr));
//            DefaultMutableTreeNode sys_end_report_view = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/sysadm/endbox/reports/report_view.jsp?" + paramStr));
//            DefaultMutableTreeNode sys_end_reports = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/sysadm/endbox/tot_reports/total_reports.jsp?" + paramStr));
//            DefaultMutableTreeNode sys_end_tot = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/sysadm/endbox/tot_report/total_report.jsp?" + paramStr));
//            DefaultMutableTreeNode sys_end_doc_modify = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/sysadm/endbox/doc_modify.jsp?" + paramStr));
//
//            sys_end_report.add(sys_end_report_view);
//            sys_end_view.add(sys_end_doc_modify);
//            sys_end_doclist.add(sys_end_tot);
//            sys_end_doclist.add(sys_end_reports);
//            sys_end_doclist.add(sys_end_report);
//            sys_end_doclist.add(sys_end_form);
//            sys_end_doclist.add(sys_end_view);
//            rootNode.add(sys_end_doclist);
//
//            DefaultMutableTreeNode sys_doc_check = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/sysadm/stat/doc_check.jsp?" + paramStr));
//            DefaultMutableTreeNode sys_user_check = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/sysadm/stat/user_check.jsp?" + paramStr));
//            DefaultMutableTreeNode sys_cpu_check = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/sysadm/stat/cpu_check.jsp?" + paramStr));
//
//            rootNode.add(sys_cpu_check);
//            rootNode.add(sys_user_check);
//            rootNode.add(sys_doc_check);
//
            DefaultMutableTreeNode sys_org_view = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/sysadm/org/org_view.jsp?" + paramStr));
            rootNode.add(sys_org_view);
//            DefaultMutableTreeNode sys_org_fileUpload = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/sysadm/org/file_upload.jsp?" + paramStr));
//            rootNode.add(sys_org_fileUpload);
//
//            DefaultMutableTreeNode sys_part_list = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/sysadm/part/part_list.jsp?" + paramStr));
//            DefaultMutableTreeNode sys_part_regist = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/sysadm/part/part_regist.jsp?" + paramStr));
//            DefaultMutableTreeNode sys_part_view = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/sysadm/part/part_view.jsp?" + paramStr));
//            DefaultMutableTreeNode sys_part_modify = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/sysadm/part/part_modify.jsp?" + paramStr));
//
//            sys_part_view.add(sys_part_modify);
//            sys_part_list.add(sys_part_view);
//            sys_part_list.add(sys_part_regist);
//            rootNode.add(sys_part_list);
//
//            DefaultMutableTreeNode sys_group_setup = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/login/envsetting/group/admin_group_setup.jsp?" + paramStr));
//            rootNode.add(sys_group_setup);
//            DefaultMutableTreeNode sys_log = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/sysadm/log/doc_list.jsp?" + paramStr));
//            DefaultMutableTreeNode sys_log_list = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/sysadm/log/log_list.jsp?" + paramStr));
//            DefaultMutableTreeNode sys_log_print = new DefaultMutableTreeNode(new MenuBean(req, "/totsys/sysadm/log/print_log_list.jsp?" + paramStr));
//
//            sys_log_list.add(sys_log_print);
//            sys_log.add(sys_log_list);
//            rootNode.add(sys_log);
        } catch (MalformedURLException e) {
            e.printStackTrace();
//        } catch (UnsupportedEncodingException e) {
//            e.printStackTrace();
        }
//        } finally {
//            if (tx.isActive()) {
//                tx.rollback();
//            }
//            pm.close();
//        }

        return new DefaultTreeModel(rootNode);
    }

    public List<MenuBean> getPath(URL url) {
        List<MenuBean> menuPath = new ArrayList<MenuBean>();

        if (getNode(url) == null) {
            return menuPath;
        }
        for (TreeNode node : getNode(url).getPath()) {
            Object userObj = ((DefaultMutableTreeNode) node).getUserObject();
            if (userObj instanceof MenuBean) {
                menuPath.add((MenuBean) userObj);
            }
        }

        return menuPath;
    }

    @SuppressWarnings("unchecked")
    private DefaultMutableTreeNode getNode(URL url) {
        for (Enumeration<DefaultMutableTreeNode> e = ((DefaultMutableTreeNode) menuModel.getRoot())
                .breadthFirstEnumeration(); e.hasMoreElements();) {
            DefaultMutableTreeNode node = e.nextElement();
            if (node.getUserObject() instanceof MenuBean
                    && ((MenuBean) node.getUserObject()).getUrl().getPath().equals(url.getPath())) {
                return node;
            }
        }
        return null;
    }

    public String getDocName() {
        return docName;
    }

    public void setDocName(String docName) {
        this.docName = docName;
    }
}
