コード例 #1
0
 @Override
 public void upload(
     ComponentParameter compParameter,
     IMultipartFile multipartFile,
     HashMap<String, Object> json) {
   try {
     ID id = ItSiteUtil.getLoginUser(compParameter).getId();
     if (id != null) {
       final Document document =
           Jsoup.parse(
               multipartFile.getInputStream(), compParameter.request.getCharacterEncoding(), "");
       final Elements as = document.getElementsByTag("a");
       for (final Element a : as) {
         if (a.hasAttr("add_date")) {
           final BookmarkBean bean = new BookmarkBean();
           final long t = ConvertUtils.toLong(a.attr("add_date"), 0) * 1000;
           bean.setTitle(a.text());
           bean.setUrl(a.attr("href"));
           bean.setUserId(id);
           bean.setUpdateDate(new Date(t));
           try {
             BookmarkUtils.applicationModule.doUpdate(bean);
           } catch (Exception e) {
           }
         }
       }
     }
   } catch (final Exception e) {
     throw DataObjectException.wrapException("没有权限");
   }
 }
コード例 #2
0
ファイル: ProgressBarUtils.java プロジェクト: codepython/51os
 public static String doProgressBarHandle(
     final HttpServletRequest request, final HttpServletResponse response) {
   final ComponentParameter nComponentParameter = getComponentParameter(request, response);
   if (nComponentParameter.componentBean != null) {
     final IProgressBarHandle handle =
         (IProgressBarHandle) nComponentParameter.getComponentHandle();
     if (handle != null) {
       final HttpSession httpSession = request.getSession();
       ProgressState state;
       final String beanId = nComponentParameter.componentBean.hashId();
       if (ConvertUtils.toBoolean(request.getParameter("starting"), false)) {
         httpSession.setAttribute(beanId, state = new ProgressState());
       } else {
         state = (ProgressState) httpSession.getAttribute(beanId);
       }
       if (state != null) {
         if (ConvertUtils.toBoolean(request.getParameter("messages"), false)) {
           return JSONUtils.toJSON(state.messages);
         }
         state.abort = ConvertUtils.toBoolean(request.getParameter("abort"), false);
         handle.doProgressState(nComponentParameter, state);
         final StringBuilder sb = new StringBuilder();
         sb.append("{");
         sb.append("\"step\" : ").append(state.step).append(",");
         sb.append("\"maxProgressValue\" : ").append(state.maxProgressValue).append(",");
         final int size = state.messages.size();
         if (size > 0) {
           sb.append("\"message\" : \"");
           sb.append(JavascriptUtils.escape(String.valueOf(state.messages.get(size - 1))));
           sb.append("\",");
         }
         sb.append("\"abort\" : ").append(state.abort);
         sb.append("}");
         return sb.toString();
       }
     }
   }
   return "{}";
 }