public void updateStatus(String message) {
    RequestReader reader = new RequestReader(message);
    Element root = reader.getRoot();
    List<Element> resources = root.elements("Resource");

    // 在线列表
    List<String> onlineSns = new LinkedList<String>();
    // 离线列表
    List<String> offlineSns = new LinkedList<String>();
    for (Element resource : resources) {
      if (TypeDefinition.STATUS_ONLINE.equals(resource.attributeValue("Status"))) {
        onlineSns.add(resource.attributeValue("SN"));
      } else {
        offlineSns.add(resource.attributeValue("SN"));
      }
    }

    // 获取所有的设备ID,key为SN, value为ID
    Map<String, Long> svDeviceMap = svDeviceManager.mapBySn();
    Map<String, Long> tmDeviceMap = tmDeviceManager.mapBySn();
    svDeviceMap.putAll(tmDeviceMap);

    if (onlineSns.size() > 0) {
      onlineManager.reportOnline(onlineSns, svDeviceMap);
    }
    if (offlineSns.size() > 0) {
      onlineManager.reportOffline(offlineSns);
    }
  }
  public String offline(String message) {
    RequestReader reader = new RequestReader(message);
    String ticket = reader.getString("Request/Ticket", false);
    Integer kickFlag = reader.getInteger("Request/KickFlag", true);

    OnlineReal onlineReal = onlineManager.getOnlineReal(ticket);
    if (null != onlineReal) {
      if (logger.isDebugEnabled()) {
        logger.debug("Offline Ticket[" + ticket + "]");
      }
      onlineManager.offline(onlineReal, kickFlag);
    }

    Document doc = XmlUtil.generateResponse("Offline", ErrorCode.SUCCESS, "");
    return XmlUtil.xmlToString(doc);
  }
  public String csLogin(String message) {
    RequestReader reader = new RequestReader(message);
    String loginName = reader.getString("Request/LoginName", false);
    String passwd = reader.getString("Request/Password", false);
    String type = reader.getString("Request/ClientType", false);
    String ip = reader.getString("Request/IP", false);

    List<User> user = userManager.getUserByName(loginName);
    if (user.size() <= 0) {
      throw new BusinessException(
          ErrorCode.USER_NOT_FOUND, "login_name [" + loginName + "] not found!");
    }
    if (!passwd.equals(MD5Util.MD5(user.get(0).getPassword()))) {
      throw new BusinessException(ErrorCode.PASSWORD_ERROR, "password error!");
    }
    // 判断OMC登录权限
    if (type.equals(TypeDefinition.CLIENT_TYPE_OMC)) {
      if (user.get(0).getAdminPriv() == 0) {
        throw new BusinessException(
            ErrorCode.USER_ROLE_INVALID, "user [" + user.get(0).getLogonName() + "] is not admin");
      }
    }
    // 生成ticket
    String ticket = onlineManager.csLogin(user.get(0), type, ip).getTicket();

    Element root = DocumentHelper.createElement("Response");
    root.addAttribute("Method", "UserLogin");
    root.addAttribute("Code", "200");
    root.addAttribute("Message", "");
    Document doc = DocumentHelper.createDocument(root);
    Element ticketE = DocumentHelper.createElement("Ticket");
    Element userId = DocumentHelper.createElement("UseId");
    root.add(ticketE);
    root.add(userId);
    ticketE.setText(ticket);
    userId.setText(user.get(0).getId().toString());
    return XmlUtil.xmlToString(doc);
  }