Example usage for java.lang.reflect InvocationTargetException printStackTrace

List of usage examples for java.lang.reflect InvocationTargetException printStackTrace

Introduction

In this page you can find the example usage for java.lang.reflect InvocationTargetException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:cn.jcenterhome.web.action.CpAction.java

public ActionForward cp_import(HttpServletRequest request, HttpServletResponse response) {
    Map<String, Object> sGlobal = (Map<String, Object>) request.getAttribute("sGlobal");
    Map<String, Object> sConfig = (Map<String, Object>) request.getAttribute("sConfig");
    if (!Common.checkPerm(request, response, "allowblog")) {
        MessageVO msgVO = Common.ckSpaceLog(request);
        if (msgVO != null) {
            return showMessage(request, response, msgVO);
        }/*from w  w w .  j  a v a  2s .c  o m*/
        return showMessage(request, response, "no_privilege");
    }
    if (!cpService.checkRealName(request, "blog")) {
        return showMessage(request, response, "no_privilege_realname");
    }
    if (!cpService.checkVideoPhoto(request, response, "blog")) {
        return showMessage(request, response, "no_privilege_videophoto");
    }
    switch (cpService.checkNewUser(request, response)) {
    case 1:
        break;
    case 2:
        return showMessage(request, response, "no_privilege_newusertime", "", 1,
                String.valueOf(sConfig.get("newusertime")));
    case 3:
        return showMessage(request, response, "no_privilege_avatar");
    case 4:
        return showMessage(request, response, "no_privilege_friendnum", "", 1,
                String.valueOf(sConfig.get("need_friendnum")));
    case 5:
        return showMessage(request, response, "no_privilege_email");
    }
    int waitTime = Common.checkInterval(request, response, "post");
    if (waitTime > 0) {
        return showMessage(request, response, "operating_too_fast", "", 1, String.valueOf(waitTime));
    }
    try {
        String siteUrl = Common.getSiteUrl(request);
        File userFile = new File(JavaCenterHome.jchRoot + "./data/temp/" + sGlobal.get("supe_uid") + ".data");
        if (submitCheck(request, "importsubmit")) {
            Map reward = Common.getReward("blogimport", false, 0, "", true, request, response);
            Map space = (Map) request.getAttribute("space");
            int spaceExperience = (Integer) space.get("experience");
            int spaceCredit = (Integer) space.get("credit");
            int rewardExperience = (Integer) reward.get("experience");
            int rewardCredit = (Integer) reward.get("credit");
            if (spaceExperience < rewardExperience) {
                return showMessage(request, response, "experience_inadequate", "", 1,
                        new String[] { String.valueOf(spaceExperience), String.valueOf(rewardExperience) });
            }
            if (spaceCredit < rewardCredit) {
                return showMessage(request, response, "integral_inadequate", "", 1,
                        new String[] { String.valueOf(spaceCredit), String.valueOf(rewardCredit) });
            }
            String url = request.getParameter("url").trim();
            Map urls = cpService.parseUrl(url);
            if (Common.empty(url) || urls.isEmpty()) {
                return showMessage(request, response, "url_is_not_correct");
            }
            XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
            config.setServerURL(new URL(url));
            XmlRpcClient client = new XmlRpcClient();
            client.setConfig(config);
            Vector params = new Vector();
            params.addElement("blog");
            params.addElement(
                    Common.sHtmlSpecialChars(Common.siconv(request.getParameter("username"), "utf-8", "", "")));
            params.addElement(Common.sHtmlSpecialChars(request.getParameter("password")));
            params.addElement(sConfig.get("importnum"));
            Object[] results = (Object[]) client.execute("metaWeblog.getRecentPosts", params);
            if (results == null || results.length == 0) {
                return showMessage(request, response, "blog_import_no_data", null, 1,
                        "<textarea name=\"tmp[]\" style=\"width:98%;\" rows=\"4\">no data</textarea>");
            }
            HashMap last = (HashMap) results[results.length - 1];
            if (last.containsKey("postid") == false) {
                return showMessage(request, response, "blog_import_no_data", null, 1,
                        Common.implode(last, ","));
            }
            PHPSerializer phpSerializer = new PHPSerializer(JavaCenterHome.JCH_CHARSET);
            FileHelper.writeFile(userFile, phpSerializer.serialize(results));
            request.setAttribute("results", results);
            request.setAttribute("incount", 0);
        } else if (submitCheck(request, "import2submit")) {
            ArrayList results = null;
            if (userFile.exists()) {
                String result = FileHelper.readFile(userFile);
                if (Common.empty(result) == false) {
                    PHPSerializer phpSerializer = new PHPSerializer(JavaCenterHome.JCH_CHARSET);
                    results = ((AssocArray) phpSerializer.unserialize(result)).toArrayList();
                }
            }
            String[] ids = request.getParameterValues("ids[]");
            if (Common.empty(results) || Common.empty(ids)) {
                return showMessage(request, response, "choose_at_least_one_log", "cp.jsp?ac=import");
            }
            int allCount = 0;
            int inCount = 0;
            ArrayList newResults = new ArrayList();
            for (int i = 0, size = results.size(); i < size; i++) {
                int key = i;
                allCount += 1;
                Map currBlog = ((AssocArray) results.get(i)).toHashMap();
                if (currBlog.get("dateCreated") instanceof Calendar) {
                    Calendar calendar = (Calendar) currBlog.get("dateCreated");
                    int dateline = (int) (calendar.getTimeInMillis() / 1000);
                    currBlog.put("dateCreated", Common.gmdate("yyyyMMdd'T'HH:mm:ss", dateline,
                            String.valueOf(sConfig.get("timeoffset"))));
                }
                if (Common.in_array(ids, key)) {
                    Map value = (Map) Common.sAddSlashes(currBlog);
                    int dateline = Common.strToTime(value.get("dateCreated").toString(),
                            String.valueOf(sConfig.get("timeoffset")), "yyyyMMdd'T'HH:mm:ss");
                    String subject = Common.getStr(value.get("title").toString(), 80, true, true, true, 0, 0,
                            request, response);
                    String message = value.containsKey("description") ? value.get("description").toString()
                            : value.get("content").toString();
                    message = Common.getStr(message, 0, true, true, true, 0, 1, request, response);
                    message = blogService.checkHtml(request, response, message);
                    if (Common.empty(subject) || Common.empty(message)) {
                        currBlog.put("status", "--");
                        currBlog.put("blogid", 0);
                        continue;
                    }
                    Map blogarr = new HashMap();
                    blogarr.put("uid", sGlobal.get("supe_uid"));
                    blogarr.put("username", sGlobal.get("supe_username"));
                    blogarr.put("subject", subject);
                    blogarr.put("pic", blogService.getMessagePic(message));
                    blogarr.put("dateline", dateline != 0 ? dateline : sGlobal.get("timestamp"));
                    int blogId = dataBaseService.insertTable("blog", blogarr, true, false);
                    Map fieldarr = new HashMap();
                    fieldarr.put("blogid", blogId);
                    fieldarr.put("uid", sGlobal.get("supe_uid"));
                    fieldarr.put("message", message);
                    fieldarr.put("postip", Common.getOnlineIP(request));
                    fieldarr.put("related", "");
                    fieldarr.put("target_ids", "");
                    fieldarr.put("hotuser", "");
                    dataBaseService.insertTable("blogfield", fieldarr, false, false);
                    inCount += 1;
                    currBlog.put("status", "OK");
                    currBlog.put("blogid", blogId);
                } else {
                    currBlog.put("status", "--");
                    currBlog.put("blogid", 0);
                }
                newResults.add(currBlog);
            }
            if (inCount != 0) {
                Common.getReward("blogimport", true, 0, "", true, request, response);
                userFile.delete();
            }
            request.setAttribute("results", newResults);
            request.setAttribute("incount", inCount);
        } else if (submitCheck(request, "resubmit")) {
            userFile.delete();
        }
        request.setAttribute("siteurl", siteUrl);
    } catch (XmlRpcException xre) {
        return showMessage(request, response, "blog_import_no_data", null, 1,
                "<textarea name=\"tmp[]\" style=\"width:98%;\" rows=\"4\">" + xre.code + ", " + xre.getMessage()
                        + "</textarea>");
    } catch (IllegalAccessException iace) {
        iace.printStackTrace();
    } catch (IllegalArgumentException iare) {
        iare.printStackTrace();
    } catch (InvocationTargetException ite) {
        ite.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
        return showMessage(request, response, e.getMessage());
    }
    return include(request, response, sConfig, sGlobal, "cp_import.jsp");
}