package cn.dremy.hfut.hfutedulib.common;

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;

import cn.dremy.hfut.hfutedulib.model.SitePage;

public class XmlParser {

    @SuppressWarnings("unchecked")
    public static Map<String, Object> parseSiteConfig() {
        Map<String, Object> siteConfig = new HashMap<String, Object>();
        String filePath = XmlParser.class.getClassLoader().getResource("urls.xml").getPath();
       
        try {

            File file = new File(filePath);
            SAXReader reader = new SAXReader();
            Document document;
            
            document = reader.read(file);
            
            Element root = document.getRootElement();
            
            Element hostnamesElement = root.element("hostnames");
            List<Element> hostnameElementList = hostnamesElement.elements();
            List<String> hostnameList = new ArrayList<String>();
            for (Element hostnameElement : hostnameElementList) {
                hostnameList.add(hostnameElement.getText());
            }
            siteConfig.put("hostnameList", hostnameList);
            siteConfig.put("encode", root.elementText("encode"));
            
            
            Element pagesElement = root.element("pages");
            List<Element> pageElementList = pagesElement.elements();
            Map<String, Object> sitePages = new HashMap<String, Object>();
            for (Element pageElement : pageElementList) {
                
                String id = pageElement.attributeValue("id");
                String note = pageElement.elementText("note");
                String url = pageElement.elementText("url");
                String method = pageElement.elementText("method");
                
                SitePage sitePage = new SitePage(id, note, url, method);
                sitePages.put(id, sitePage);
            }
            siteConfig.put("sitePages", sitePages);
            return siteConfig;
        } catch (Exception e) {
            return null;
        }
    }
}

@@ -56,16 +56,44 @@
 o.File;%0A
+import java.io.InputStream;%0A
 import j
@@ -606,25 +606,26 @@
 h();%0A       
+ 
 %0A
-
         try 
@@ -629,53 +629,8 @@
 ry %7B
-%0A%0A            File file = new File(filePath);
 %0A   
@@ -709,33 +709,273 @@
 nt;%0A            
-%0A
+if (filePath.indexOf(%22!%22) != -1) %7B%0A                InputStream input = XmlParser.class.getResourceAsStream(%22/urls.xml%22);%0A                document = reader.read(input);%0A            %7D else %7B%0A                File file = new File(filePath);%0A    
             docu
@@ -1004,32 +1004,34 @@
 e);%0A            
+%7D%0A
 %0A            Ele

Fix bug in jar