public boolean handleMessage(IMMessage msg) {
   GroupMessageDB db = GroupMessageDB.getInstance();
   IMessage imsg = new IMessage();
   imsg.sender = msg.sender;
   imsg.receiver = msg.receiver;
   imsg.timestamp = msg.timestamp;
   imsg.setContent(msg.content);
   boolean r = db.insertMessage(imsg, imsg.receiver);
   msg.msgLocalID = imsg.msgLocalID;
   return r;
 }
 @Override
 public void sendMessage(ILocationSpecifier loc, IMessage message, IRequestSender requestSender) {
   ConnectionInstance connectionInstance = instancesMapping.get(loc);
   int xid = XidGenerator.generateXid();
   message.setXid(xid);
   messagesMapping.put(xid, message);
   connectionInstance.sendRequest(message, requestSender);
   requestSendersMapping.put(xid, requestSender);
 }
  public IMessage toMessage(Class clas) {

    IMessage msg = null;
    if (clas != null) {
      msg = super.toMessage(clas);
    } else {
      msg = super.toMessage(RemoteFWEventImpl.class);
    }

    // xstream version
    // XStream xstream = new XStream();
    // String bxml = xstream.toXML(bundles);
    // msg.setElement(new Element("bundles",bxml));
    // System.out.println("RFWEvent streamed: " + bxml);

    // byte version
    msg.setElement(new Element("bundles", bundles));

    return (msg);
  }
 public boolean handleGroupNotification(String notification) {
   GroupMessageDB db = GroupMessageDB.getInstance();
   IMessage.GroupNotification groupNotification = IMessage.newGroupNotification(notification);
   IMessage imsg = new IMessage();
   imsg.sender = 0;
   imsg.receiver = groupNotification.groupID;
   imsg.timestamp = groupNotification.timestamp;
   imsg.setContent(groupNotification);
   return db.insertMessage(imsg, groupNotification.groupID);
 }
  @Override
  protected void process(ArrayList<IMessage> l) {
    // Traverse in reverse order from most recent to earliest.
    Collections.reverse(l);

    /*
     * Algorithm: Traverse from the latest message to the earliest.
     *
     * For each message, we see if we have a splice from a previously
     * verified message (a reverse-index of splicepoints to the
     * corresponding messages is stored in splices) If so, then verify the
     * splice. If not, or a bad splice check the signature. If a message
     * validates via one of these mechanisms, then this message is valid and
     * add its splicepoints to splices.
     */

    /**
     * For each version number a confirmed valid message that claims to splice the requested message
     */
    HashMap<Integer, IMessage> splices = new HashMap<Integer, IMessage>();

    /** Cache of the parsed trees */
    HashMap<IMessage, HistoryTree<byte[], byte[]>> trees =
        new HashMap<IMessage, HistoryTree<byte[], byte[]>>();

    for (IMessage m : l) {
      // System.out.format("*Checking message at leaf %d\n",m.getSignatureBlob().getLeaf());

      boolean validated = false;
      HistoryTree<byte[], byte[]> tree = HistTreeTools.parseHistoryTree(m);

      if (!Verifier.checkLeaf(m, tree)) {
        m.signatureValidity(false);
        continue;
      }

      int version = tree.version();
      // See if this message can be spliced on to something we already
      // know about.
      if (splices.containsKey(version)) {
        IMessage latermsg = splices.get(version);
        HistoryTree<byte[], byte[]> latertree = trees.get(latermsg);
        // Confirm the splice.
        if (Arrays.equals(latertree.aggV(version), tree.agg())) {
          // Splice is good! Is the message validated?
          if (Verifier.checkLeaf(m, tree)) {
            // And so is the message in it!
            // System.out.format("Using verified splice %d in tree version %d\n",version,
            // latertree.version());
            validated = true;
          } else {
            System.out.println("Broken proof that doesn't validate message in proof.");
          }
        } else {
          // BAD SPLICE.
          System.out.println("Bad Splice: Did history replay? Skipped messagae");
          // But see if we can check the signature.
        }
      }
      // No splice or invalid splice.
      if (validated == false) {
        // System.out.format("Splices do not have tree %d\n",version);
        if (HistTreeTools.verifyHistoryRoot(signer, m, tree)) {
          validated = true; // GOOD signature.
        } else {
          System.out.println("Signature necessary, but doesn't validate. Skip message");
        }
      }

      // Put in a 'splice' for the tree's version
      if (validated && !splices.containsKey(version)) {
        // System.out.format("Store self-splice at %d with tree-version
        // %d\n",tree.version(),version);
        splices.put(tree.version(), m);
        trees.put(m, tree);
      }

      // Save the splices, if any, of this message, if validated.
      if (validated && m.getSignatureBlob().getSpliceHintCount() > 0) {
        trees.put(m, tree);
        for (int splice : m.getSignatureBlob().getSpliceHintList()) {
          if (tree.leaf(splice) == null) {
            // Claims it has splice, but doesn't have the leaf.
            // System.out.println("Claims splice, but no splice included.");
          } else {
            // System.out.format("Store splice at %d with tree-version %d\n",
            // splice, version);
            splices.put(splice, m);
          }
        }
      }
      // Now invoke the callback with the validity.
      m.signatureValidity(validated);
    }
  }
 private String editPermission(
     Operation op, IMessage message, Permission permission, List<String> args) {
   String first = args.size() >= 1 ? args.get(0) : "";
   String second = args.size() >= 2 ? args.get(1) : "";
   String third = args.size() >= 3 ? args.get(2) : "";
   String fourth = args.size() >= 4 ? args.get(3) : "";
   if (first.equalsIgnoreCase("this")) {
     // this <channel|guild>
     if (second.equalsIgnoreCase("channel")) {
       // this channel
       return editChannelPermission(op, permission, message.getChannel());
     } else if (second.equalsIgnoreCase("server")) {
       // this guild
       if (message.getChannel().isPrivate()) {
         return "Not a valid call from private channels";
       }
       IGuild guild = message.getChannel().getGuild();
       return editGuildPermission(op, permission, guild);
     } else {
       return "Use `this channel` or `this server`";
     }
   } else if (first.equalsIgnoreCase("user")) {
     // user <name or id>
     List<IUser> matching =
         discordService
             .getClient()
             .getGuilds()
             .stream()
             .flatMap(g -> g.getUsers().stream())
             .filter(u -> u.getName().equalsIgnoreCase(second) || u.getID().equals(second))
             .distinct()
             .collect(Collectors.toList());
     if (matching.size() > 1) {
       StringBuilder builder =
           new StringBuilder("Multiple users matched, please narrow search or use ID\n");
       for (IUser user : matching) {
         builder.append(user.getName()).append(" has id `").append(user.getID()).append("`\n");
       }
       return builder.toString();
     } else if (matching.isEmpty()) {
       return "User " + second + " not found in cache";
     } else {
       return editUserPermission(op, permission, matching.get(0));
     }
   } else if (first.equalsIgnoreCase("channel")) {
     // channel <name or id>
     List<IChannel> matching =
         discordService
             .getClient()
             .getGuilds()
             .stream()
             .flatMap(g -> g.getChannels().stream())
             .filter(c -> c.getName().equalsIgnoreCase(second) || c.getID().equals(second))
             .distinct()
             .collect(Collectors.toList());
     if (matching.size() > 1) {
       StringBuilder builder =
           new StringBuilder("Multiple channels matched, please narrow search or use ID\n");
       for (IChannel channel : matching) {
         builder
             .append(channel.getName())
             .append(" has id `")
             .append(channel.getID())
             .append("`\n");
       }
       return builder.toString();
     } else if (matching.isEmpty()) {
       return "Channel " + second + " not found in cache";
     } else {
       return editChannelPermission(op, permission, matching.get(0));
     }
   } else if (first.equalsIgnoreCase("server")) {
     // guild <name or id>
     List<IGuild> matching =
         discordService
             .getClient()
             .getGuilds()
             .stream()
             .filter(g -> g.getName().equalsIgnoreCase(second) || g.getID().equals(second))
             .distinct()
             .collect(Collectors.toList());
     if (matching.size() > 1) {
       StringBuilder builder =
           new StringBuilder("Multiple servers matched, please narrow search or use ID\n");
       for (IGuild guild : matching) {
         builder.append(guild.getName()).append(" has id `").append(guild.getID()).append("`\n");
       }
       return builder.toString();
     } else if (matching.isEmpty()) {
       return "Server " + second + " not found in cache";
     } else {
       return editGuildPermission(op, permission, matching.get(0));
     }
   } else if (first.equalsIgnoreCase("role")) {
     // role <name or id> [in <guild name or id>]
     // when a guild name/id is not specified:
     //      if triggered from a private channel, all case insensitive matches are picked up
     //      if triggered from a public channel, only the channel's guild is searched
     boolean isPrivate = message.getChannel().isPrivate();
     boolean specific = third.equalsIgnoreCase("in") && !fourth.isEmpty();
     List<IRole> matching =
         discordService
             .getClient()
             .getGuilds()
             .stream()
             .filter(
                 g -> {
                   if (isPrivate) {
                     return !specific
                         || g.getName().equalsIgnoreCase(fourth)
                         || g.getID().equals(fourth);
                   } else {
                     if (!specific) {
                       return g.equals(message.getChannel().getGuild());
                     } else {
                       return g.getName().equalsIgnoreCase(fourth) || g.getID().equals(fourth);
                     }
                   }
                 })
             .flatMap(g -> g.getRoles().stream())
             .filter(r -> r.getName().equalsIgnoreCase(second) || r.getID().equals(second))
             .distinct()
             .collect(Collectors.toList());
     if (matching.size() > 1) {
       StringBuilder builder =
           new StringBuilder("Multiple role matched, please narrow search or use ID\n");
       for (IRole role : matching) {
         builder.append(role.getName()).append(" has id `").append(role.getID()).append("`\n");
       }
       return builder.toString();
     } else if (matching.isEmpty()) {
       return "Role " + second + " not found in cache";
     } else {
       return editRolePermission(op, permission, matching.get(0));
     }
   } else {
     return "Invalid argument format! Check details with `.perm -?`";
   }
 }
 public Response handleResponse(IMessage message) {
   IRequestSender iRequestSender = requestSendersMapping.get(message.getXid());
   iRequestSender.onSuccess(message);
   return okResponse();
 }
  public ExecuteResult doService(IMessage message, String soa_processid) {
    // 获取运行流程项
    IProcess process = ProcessFactory.getInstance(soa_processid);
    String processInfo = process.getNameSpace() + "." + process.getName();
    if (!initFordo(message, soa_processid)) {
      log.error(processInfo + ",修改用户,初始化服务运行失败");
      return ExecuteResult.fail;
    }

    try {
      Statement stmt = null;
      ResultSet rs = null;
      try {
        IDAO_UserManager dao =
            DAOFactory_UserManager.getInstance(DataBaseType.getDataBaseType(con));
        if (dao == null) {
          message.addServiceException(
              new ServiceException(
                  ServiceExceptionType.UNKNOWNDATABASETYPE,
                  "",
                  this.getId(),
                  soa_processid,
                  new Date(),
                  null));
          log.error(processInfo + ",修改用户,加载数据库错误,未知的数据库类型");
          return ExecuteResult.fail;
        }
        log.debug(processInfo + ",修改用户,加载数据库成功");
        stmt = con.createStatement();
        String sql_check = dao.getSQL_QueryCountForUserNo(usrno);
        log.debug("取得用户id是否重复的sql语句: sql_check = " + sql_check);
        rs = stmt.executeQuery(sql_check);
        int count = 0;
        if (rs.next()) {
          count = rs.getInt(1);
        }
        if (count == 0) {
          message.addServiceException(
              new ServiceException(
                  ServiceExceptionType.UNKNOWN,
                  "没有要更新的数据!",
                  this.getId(),
                  soa_processid,
                  new Date(),
                  null));
          log.error(processInfo + ",修改用户时,没有要更新的数据  count = " + count);
          return ExecuteResult.fail;
        }

        /*
         * 查询所有参数放入Map中
         */
        Map<String, String> data = new HashMap<String, String>();
        String rs_usrno = null;
        String rs_usrname = null;
        String rs_password = null;
        String rs_employeeid = null;
        String rs_state = null;
        String rs_lastupdateuser = null;
        String rs_lastupdatetime = null;
        String rs_note = null;
        String rs_enabled = null;
        String map_sql_select = dao.getSQL_QueryUserInfoForUserID(usrno);
        log.debug(processInfo + "查询此用户所有参数的sql语句: map_sql_select = " + map_sql_select);
        rs = stmt.executeQuery(map_sql_select);
        while (rs.next()) {
          rs_usrno = rs.getString(1);
          rs_usrname = rs.getString(2);
          rs_password = rs.getString(3);
          rs_employeeid = rs.getString(5);
          rs_state = rs.getString(6);
          rs_lastupdateuser = rs.getString(7);
          rs_lastupdatetime = rs.getString(8);
          rs_note = rs.getString(9);
          rs_enabled = rs.getString(10);
        }
        String rs_debug =
            "rs_usrno = "
                + rs_usrno
                + "\n"
                + "rs_usrname = "
                + rs_usrname
                + "\n"
                + "rs_password = "******"\n"
                + "rs_employeeid = "
                + rs_employeeid
                + "\n"
                + "rs_state = "
                + rs_state
                + "\n"
                + "rs_lastupdateuser = "******"\n"
                + "rs_lastupdatetime = "
                + rs_lastupdatetime
                + "\n"
                + "rs_note = "
                + rs_note
                + "\n"
                + "rs_enabled = "
                + rs_enabled;
        log.debug(processInfo + "查询的所有信息为: rs_debug = " + rs_debug);
        data.put("rs_usrno", rs_usrno);
        data.put("rs_usrname", rs_usrname);
        data.put("rs_password", rs_password);
        data.put("rs_oldRoleno", oldRoleno);
        data.put("rs_old_default_roleno", old_default_roleno);
        data.put("rs_employeeid", rs_employeeid);
        data.put("rs_state", rs_state);
        data.put("rs_lastupdateuser", rs_lastupdateuser);
        data.put("rs_lastupdatetime", rs_lastupdatetime);
        data.put("rs_note", rs_note);
        data.put("rs_enabled", rs_enabled);
        message.setOtherParameter(this.getClass().getName(), data);

        String sql_update;
        // password be changed
        if (!password.equals("********")) {
          sql_update =
              dao.getSQL_UpdateUser(
                  usrno,
                  usrname,
                  password,
                  employeeid,
                  state,
                  lastupdateuser,
                  lastupdatetime,
                  note,
                  enabled);
        } else // password not changed
        {
          sql_update =
              dao.getSQL_UpdateUser(
                  usrno, usrname, employeeid, state, lastupdateuser, lastupdatetime, note, enabled);
        }
        log.debug("根据用户id,更改用户信息,包括密码的sql语句: sql_update = " + sql_update);
        stmt.executeUpdate(sql_update);
        String sql_deleteDataUserRole = "";
        String sql_insertDataUserRole = "";

        String[] role_new = roleno.split(":");
        sql_deleteDataUserRole = dao.getSQL_DeleteDataUserRole(new Integer(usrno));
        log.debug("根据角色号,删除原有角色号的sql语句:sql_deleteDataUserRole = " + sql_deleteDataUserRole);
        stmt.executeUpdate(sql_deleteDataUserRole);
        for (String ch : role_new) {
          if (ch != null && !ch.equals("")) {
            if (default_roleno.equals(ch)) {
              sql_insertDataUserRole =
                  dao.getSQL_insertDataUserRole(new Integer(usrno), new Integer(ch), "0");
            } else {
              sql_insertDataUserRole =
                  dao.getSQL_insertDataUserRole(new Integer(usrno), new Integer(ch), "1");
            }
            log.debug(
                "插入新角色号data_user_role表的sql语句: sql_insertDataUserRole = " + sql_insertDataUserRole);
            stmt.executeUpdate(sql_insertDataUserRole);
          }
        }

      } catch (SQLException sqle) {
        message.addServiceException(
            new ServiceException(
                ServiceExceptionType.DATABASEERROR,
                "数据库错误" + sqle,
                this.getId(),
                soa_processid,
                new Date(),
                sqle));
        log.fatal(processInfo + ",修改用户,数据库操作异常" + sqle.toString());
        return ExecuteResult.fail;
      } finally {
        if (rs != null) rs.close();
        if (stmt != null) stmt.close();
      }
    } catch (Exception e) {
      message.addServiceException(
          new ServiceException(
              ServiceExceptionType.UNKNOWN,
              e.toString(),
              this.getId(),
              soa_processid,
              new java.util.Date(),
              e));
      log.fatal(processInfo + ",修改用户,未知异常" + e.toString());
      return ExecuteResult.fail;
    }
    return ExecuteResult.sucess;
  }
  private boolean initFordo(IMessage message, String soa_processid) {

    con = null;
    usrno = null;
    usrname = null;
    password = null;
    roleno = null;
    employeeid = null;
    state = null;
    lastupdateuser = null;
    lastupdatetime = null;
    note = null;
    enabled = null;
    oldRoleno = null;

    con = (Connection) message.getOtherParameter("con");
    usrno = message.getUserParameterValue("usrno");
    usrname = message.getUserParameterValue("usrname");
    password = message.getUserParameterValue("password");
    roleno = message.getUserParameterValue("roleno").trim();
    oldRoleno = message.getUserParameterValue("oldRoleno").trim();
    default_roleno = message.getUserParameterValue("default_roleno");
    old_default_roleno = message.getUserParameterValue("old_default_roleno");
    employeeid = message.getUserParameterValue("employeeid");
    state = message.getUserParameterValue("state");
    lastupdateuser = message.getUserParameterValue("lastupdateuser");
    lastupdatetime = message.getUserParameterValue("lastupdatetime");
    note = message.getUserParameterValue("note");
    enabled = message.getUserParameterValue("enabled");
    // 获取运行流程项
    IProcess process = ProcessFactory.getInstance(soa_processid);
    String processInfo = process.getNameSpace() + "." + process.getName();
    String debug_UpdateUser =
        "******"
            + usrno
            + "\n"
            + "usrname = "
            + usrname
            + "\n"
            + "password = "******"\n"
            + "roleno = "
            + roleno
            + "\n"
            + "oldRoleno = "
            + oldRoleno
            + "\n"
            + "default_roleno = "
            + default_roleno
            + "\n"
            + "old_default_roleno = "
            + old_default_roleno
            + "\n"
            + "employeeid = "
            + employeeid
            + "\n"
            + "state = "
            + state
            + "\n\r"
            + "lastupdateuser = "******"\n"
            + "lastupdatetime = "
            + lastupdatetime
            + "\n"
            + "note = "
            + note
            + "\n"
            + "enabled = "
            + enabled
            + "\n";
    log.debug(processInfo + ",修改用户时用户提交的参数: " + debug_UpdateUser);

    if (usrno == null
        || usrname == null
        || password == null
        || roleno == null
        || employeeid == null
        || state == null
        || lastupdateuser == null
        || lastupdatetime == null
        || note == null
        || enabled == null) {
      message.addServiceException(
          new ServiceException(
              ServiceExceptionType.PARAMETERLOST,
              "添加用户时参数为空",
              this.getId(),
              soa_processid,
              new java.util.Date(),
              null));
      log.error(processInfo + ",修改用户,缺少输入参数");
      return false;
    }
    return true;
  }
  @SuppressWarnings("unchecked")
  public ExecuteResult undoService(IMessage message, String soa_processid) {
    IProcess process = ProcessFactory.getInstance(soa_processid);
    String processInfo = process.getNameSpace() + "." + process.getName();
    Object obj = message.getOtherParameter(this.getClass().getName());
    if (obj instanceof Map) {
      Map<String, String> map = (Map<String, String>) obj;
      String map_usrno = map.get("rs_usrno");
      String map_usrname = map.get("rs_usrname");
      String map_password = map.get("rs_password");
      String map_oldRoleno = map.get("rs_oldRoleno").trim();
      String map_employeeid = map.get("rs_employeeid").trim();
      String map_old_default_roleno = map.get("rs_old_default_roleno");
      String map_state = map.get("rs_state");
      String map_lastupdateuser = map.get("rs_lastupdateuser");
      String map_lastupdatetime = map.get("rs_lastupdatetime");
      String map_note = map.get("rs_note");
      String map_enabled = map.get("rs_enabled");
      String map_debug =
          "map_usrno = "
              + map_usrno
              + "\n"
              + "map_usrname = "
              + map_usrname
              + "\n"
              + "map_password = "******"\n"
              + "map_oldRoleno = "
              + map_oldRoleno
              + "\n"
              + "map_employeeid = "
              + map_employeeid
              + "\n"
              + "map_state = "
              + map_state
              + "\n"
              + "map_lastupdateuser = "******"\n"
              + "map_lastupdatetime = "
              + map_lastupdatetime
              + "\n"
              + "map_note = "
              + map_note
              + "\n"
              + "map_enabled = "
              + map_enabled;
      log.debug(processInfo + "修改用户回退操作Map接收的所有信息为: map_debug = " + map_debug);
      try {
        Statement stmt = null;
        try {
          IDAO_UserManager dao =
              DAOFactory_UserManager.getInstance(DataBaseType.getDataBaseType(con));
          if (dao == null) {
            message.addServiceException(
                new ServiceException(
                    ServiceExceptionType.UNKNOWNDATABASETYPE,
                    "",
                    this.getId(),
                    soa_processid,
                    new Date(),
                    null));
            log.error(processInfo + ",修改用户回退操作,加载数据库错误,未知的数据库类型");
            return ExecuteResult.fail;
          }
          log.debug(processInfo + ",修改用户回退操作,加载数据库成功");
          stmt = con.createStatement();
          String undo_sql_update;
          // password be changed
          if (!password.equals("********")) {
            undo_sql_update =
                dao.getSQL_UpdateUser(
                    map_usrno,
                    map_usrname,
                    map_password,
                    map_employeeid,
                    map_state,
                    map_lastupdateuser,
                    map_lastupdatetime,
                    map_note,
                    map_enabled);
          } else // password not changed
          {
            undo_sql_update =
                dao.getSQL_UpdateUser(
                    map_usrno,
                    map_usrname,
                    map_employeeid,
                    map_state,
                    map_lastupdateuser,
                    map_lastupdatetime,
                    map_note,
                    map_enabled);
          }
          log.debug("修改用户回退操作的sql语句: undo_sql_update = " + undo_sql_update);
          stmt.executeUpdate(undo_sql_update);

          String sql_deleteDataUserRole = "";
          String sql_insertDataUserRole = "";

          String[] role_old = map_oldRoleno.split(":");
          sql_deleteDataUserRole = dao.getSQL_DeleteDataUserRole(new Integer(map_usrno));
          log.debug("根据角色号,删除新角色号的sql语句:sql_deleteDataUserRole = " + sql_deleteDataUserRole);
          stmt.executeUpdate(sql_deleteDataUserRole);
          for (String ch : role_old) {
            if (ch != null && !ch.equals("")) {
              if (map_old_default_roleno.equals(ch)) {
                sql_insertDataUserRole =
                    dao.getSQL_insertDataUserRole(new Integer(usrno), new Integer(ch), "0");
              } else {
                sql_insertDataUserRole =
                    dao.getSQL_insertDataUserRole(new Integer(usrno), new Integer(ch), "1");
              }
              log.debug(
                  "插入原有角色号data_user_role表的sql语句: sql_insertDataUserRole = "
                      + sql_insertDataUserRole);
              stmt.executeUpdate(sql_insertDataUserRole);
            }
          }

        } catch (SQLException sqle) {
          message.addServiceException(
              new ServiceException(
                  ServiceExceptionType.DATABASEERROR,
                  "数据库错误" + sqle,
                  this.getId(),
                  soa_processid,
                  new Date(),
                  sqle));
          log.fatal(processInfo + ",修改用户,数据库操作异常" + sqle.toString());
          return ExecuteResult.fail;
        } finally {
          if (stmt != null) stmt.close();
        }
      } catch (Exception e) {
        message.addServiceException(
            new ServiceException(
                ServiceExceptionType.UNKNOWN,
                e.toString(),
                this.getId(),
                soa_processid,
                new java.util.Date(),
                e));
        log.fatal(processInfo + ",修改用户,未知异常" + e.toString());
        return ExecuteResult.fail;
      }
    }
    return ExecuteResult.sucess;
  }
  protected void delete(String[] params, HttpServletRequest request, HttpServletResponse response) {
    IUser user;
    ISocialmore sm;
    IPost post;
    IMessage msg;
    int msg_id, post_id = -1;

    HttpSession session = request.getSession();

    sm = Socialmore.connect(this);
    user = User.getSession(request);

    if (sm == null || user == null) {
      forwardTo(request, response, "Sessions/login");
      return;
    }

    if (params[0].equalsIgnoreCase("cancel-message")) {
      try {
        ArrayList<IMessage> inbox = (ArrayList<IMessage>) user.getInbox();
        request.setAttribute("inbox", inbox);
      } catch (RemoteException e1) {
        forwardTo(request, response, "Users/index");
        return;
      }

      try {
        msg_id = Integer.parseInt(params[1]);
        msg = user.getSentMessage(msg_id);
        if (user.getID() == msg.getSenderID() && msg.getReceiving() == null) {
          if (user.removeMessage(msg_id)) {
            request.setAttribute("flash_type", "alert-success");
            request.setAttribute("flash", "Your scheduled message was cancelled!");
            forwardTo(request, response, "Messages/index");
            return;
          }
        }
      } catch (Exception e) {

      }

      request.setAttribute("flash_type", "alert-error");
      request.setAttribute(
          "flash", "It was <b>not</b> possible to remove the schedule message specified");
      forwardTo(request, response, "Messages/index");
      return;
    }

    try {
      post_id = Integer.parseInt(params[1]);
    } catch (Exception e) {
    }

    try {
      post = sm.getPost(post_id);
      if (post != null) {
        post.delete(user.getID());
        System.out.println("Delete " + post_id);
      }
    } catch (RemoteException e) {

    }

    forwardTo(request, response, "Users/index");
  }
 public void processMessage(IMessage msg) {
   LOG.info("===>\t\tGOT MESSAGE:\n" + msg.toXMLString());
 }