public ResponseContext execute(ResponseContext resc) throws BusinessLogicException {
    try {
      RequestContext reqc = getRequestContext();

      String[] targets = reqc.getParameter("target");
      String[] status = reqc.getParameter("status");

      MySqlConnectionManager.getInstance().beginTransaction();

      AbstractDaoFactory factory = AbstractDaoFactory.getFactory("users");
      AbstractDao dao = factory.getAbstractDao();

      List users = new ArrayList();

      for (int i = 0; i < targets.length; i++) {
        Map params = new HashMap();
        params.put("value", targets[i]);
        params.put("where", "where user_id=?");

        UserBean ub = (UserBean) dao.read(params);

        params.put("userId", targets[i]);
        params.put("userbean", ub);
        params.put("userStatus", status[i]);

        dao.update(params);

        users.add(ub.getUserName());
      }

      MySqlConnectionManager.getInstance().commit();
      MySqlConnectionManager.getInstance().closeConnection();

      Map result = new HashMap();
      result.put("list", users);
      result.put("want", "削除");

      resc.setResult(result);
      resc.setTarget("AccountChangeResult");

      return resc;
    } catch (IntegrationException e) {
      throw new BusinessLogicException(e.getMessage(), e);
    }
  }
Exemplo n.º 2
0
  public ResponseContext execute(ResponseContext resc) throws BusinessLogicException {
    try {
      RequestContext reqc = getRequestContext();
      String communityId = reqc.getParameter("communityId")[0];
      Map params = new HashMap();

      // 削除されていないコミュニティを取得するための条件
      params.put("where", "where community_id=? and community_delete_flag=0");
      params.put("communityId", reqc.getParameter("communityId")[0]);
      // DAOの中でキーの値が統一されていないため、同じ値を違うキーで入れています。
      // 犯人は土屋。
      params.put("commId", reqc.getParameter("communityId")[0]);

      MySqlConnectionManager.getInstance().beginTransaction();

      // コミュニティを取得
      AbstractDaoFactory factory = AbstractDaoFactory.getFactory("community");
      AbstractDao dao = factory.getAbstractDao();
      CommunityBean cb = (CommunityBean) dao.read(params);

      // コミュニティがもつトピックを取得
      factory = AbstractDaoFactory.getFactory("topic");
      dao = factory.getAbstractDao();
      cb.setTopics(dao.readAll(params));

      MySqlConnectionManager.getInstance().commit();

      resc.setResult(cb);
      resc.setTarget("topiclist");

      return resc;

    } catch (NullPointerException e) {
      throw new ParameterInvalidException("入力内容が足りません", e);
    } catch (IntegrationException e) {
      throw new BusinessLogicException(e.getMessage(), e);
    } finally {

      MySqlConnectionManager.getInstance().closeConnection();
    }
  }
  public ResponseContext execute(ResponseContext resc) throws BusinessLogicException {
    try {
      RequestContext reqc = getRequestContext();

      String[] articleId = reqc.getParameter("articleId");

      String status = reqc.getParameter("status")[0];

      Map params = new HashMap();

      params.put("status", status);

      AbstractDaoFactory factory = AbstractDaoFactory.getFactory("article");
      AbstractDao dao = factory.getAbstractDao();

      for (int i = 0; i < articleId.length; i++) {
        params.put("articleId", articleId[i]);

        MySqlConnectionManager.getInstance().beginTransaction();

        ArticleBean ab = (ArticleBean) dao.read(params);

        params.put("articlebean", ab);
        dao.update(params);

        MySqlConnectionManager.getInstance().commit();
        MySqlConnectionManager.getInstance().closeConnection();
      }

      resc.setTarget("publicationrangesetting");

      return resc;

    } catch (IntegrationException e) {
      throw new BusinessLogicException(e.getMessage(), e);
    }
  }
Exemplo n.º 4
0
  public ResponseContext execute(ResponseContext resc) throws BusinessLogicException {
    try {
      RequestContext reqc = getRequestContext();

      String articleId = reqc.getParameter("articleId")[0];

      String title = reqc.getParameter("title")[0];
      // タグエスケープ
      title = title.replaceAll("<script", "&lt;script");
      title = title.replaceAll("</script>", "&lt;/script&gt;");
      title = title.replaceAll("<form", "&lt;form");
      title = title.replaceAll("</form>", "&lt;/form&gt;");
      title = title.replaceAll("<input", "&lt;/input");
      title = title.replaceAll("</input>", "&lt;/input&gt;");

      String body = reqc.getParameter("body")[0];
      // タグエスケープ
      body = body.replaceAll("<script", "&lt;script");
      body = body.replaceAll("</script>", "&lt;/script&gt;");
      body = body.replaceAll("<form", "&lt;form");
      body = body.replaceAll("</form>", "&lt;/form&gt;");
      body = body.replaceAll("<input", "&lt;/input");
      body = body.replaceAll("</input>", "&lt;/input&gt;");

      String status = reqc.getParameter("status")[0];

      String[] tags = null;
      // タグはチェックボックス等で複数来る事を想定してます

      boolean tagFlag = false;
      try {
        // tagパラメータがあるかのチェック、jsp変更前の例外防止
        tags = reqc.getParameter("tag[]");

        if (tags.length > 0) {
          tagFlag = true;
        }
      } catch (NullPointerException e) {

      }

      Calendar cal = Calendar.getInstance();
      SimpleDateFormat formatter = new SimpleDateFormat("yyyy/MM/dd HH:mm");
      String date = formatter.format(cal.getTime());

      Map params = new HashMap();
      params.put("articleId", articleId);
      params.put("title", title);
      params.put("body", body);
      params.put("status", status);
      params.put("date", date);

      MySqlConnectionManager.getInstance().beginTransaction();

      AbstractDaoFactory factory = AbstractDaoFactory.getFactory("article");
      AbstractDao dao = factory.getAbstractDao();
      ArticleBean ab = (ArticleBean) dao.read(params);

      params.put("articlebean", ab);
      dao.update(params);

      if (tagFlag) {
        params.clear();

        factory = AbstractDaoFactory.getFactory("tag");
        dao = factory.getAbstractDao();

        params.put("articleId", ab.getArticleId());
        dao.update(params);

        // 既に記事に付いているタグを保持しておくList

        params.clear();

        for (int i = 0; i < tags.length; i++) {

          params.put("articleId", ab.getArticleId());
          params.put("tag", tags[i]);
          dao.insert(params);
          params.clear();
        }
      }

      MySqlConnectionManager.getInstance().commit();

      return resc;

    } catch (NullPointerException e) {
      throw new ParameterInvalidException("入力内容が足りません", e);
    } catch (IntegrationException e) {
      throw new BusinessLogicException(e.getMessage(), e);
    } finally {
      MySqlConnectionManager.getInstance().closeConnection();
    }
  }