当前位置: 首页>>代码示例>>Java>>正文


Java JID.getNode方法代码示例

本文整理汇总了Java中org.xmpp.packet.JID.getNode方法的典型用法代码示例。如果您正苦于以下问题:Java JID.getNode方法的具体用法?Java JID.getNode怎么用?Java JID.getNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.xmpp.packet.JID的用法示例。


在下文中一共展示了JID.getNode方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSession

import org.xmpp.packet.JID; //导入方法依赖的package包/类
/**
 * 根据JID返回与之关联的会话
 * 
 * @param from
 * @return
 */
public ClientSession getSession(JID from) {
	if (from == null || serverName == null
			|| !serverName.equals(from.getDomain())) {
		return null;
	}
	// 检查预认证会话
	if (from.getResource() != null) {
		ClientSession session = preAuthSessions.get(from.getResource());
		if (session != null) {
			return session;
		}
	}
	if (from.getResource() == null || from.getNode() == null) {
		return null;
	}
	return clientSessions.get(from.toString());
}
 
开发者ID:lijian17,项目名称:androidpn-server,代码行数:24,代码来源:SessionManager.java

示例2: handleGetUser

import org.xmpp.packet.JID; //导入方法依赖的package包/类
IQ handleGetUser(IQ packet, JID from, String appId, String payload) 
    throws UnauthorizedException {
  String userName;
  UserId userId = UserId.fromJson(payload);
  if (userId == null || userId.getUserId() == null)
    userName = from.getNode();
  else
    userName = JIDUtil.makeNode(userId.getUserId().toLowerCase(), appId);
  
  try {
    UserManager userManager = XMPPServer.getInstance().getUserManager();
    User user = userManager.getUser(userName);
    UserInfo accountInfo = new UserInfo()
      .setUserId(userId.getUserId())
      .setDisplayName(user.getName())
      .setEmail(user.getEmail());
    IQ response = IQUtils.createResultIQ(packet, accountInfo.toJson());
    return response;
  } catch (UserNotFoundException e) {
    return IQUtils.createErrorIQ(packet,
        UserOperationStatusCode.USER_NOT_FOUND.getMessage(),
        UserOperationStatusCode.USER_NOT_FOUND.getCode());
  }
}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:25,代码来源:MMXUserHandler.java

示例3: handleSetTags

import org.xmpp.packet.JID; //导入方法依赖的package包/类
IQ handleSetTags(IQ packet, JID from, String appId, String payload) {
  String username = from.getNode();
  UserTags userTags = UserTags.fromJson(payload);

  try {
    User user = UserManager.getInstance().getUser(username);
    if (user != null) {
      TagDAO tagDao = DBUtil.getTagDAO();
      tagDao.deleteAllTagsForUsername(appId, username);
      if(!Utils.isNullOrEmpty(userTags.getTags())) {
        for (String tag : userTags.getTags()) {
          tagDao.createUsernameTag(tag, appId, username);
        }
      }
    }
  } catch (Exception e) {
    return IQUtils.createErrorIQ(packet, "User does not exist", StatusCode.BAD_REQUEST);
  }
  MMXStatus status = new MMXStatus();
  status.setCode(StatusCode.SUCCESS)
          .setMessage("Success");
  return IQUtils.createResultIQ(packet, status.toJson());
}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:24,代码来源:MMXUserHandler.java

示例4: handleRemoveTags

import org.xmpp.packet.JID; //导入方法依赖的package包/类
IQ handleRemoveTags(IQ packet, JID from, String appId, String payload) {
  String username = from.getNode();
  UserTags userTags = UserTags.fromJson(payload);
  
  try {
    User user = UserManager.getInstance().getUser(username);
    if (user != null && userTags != null) {
      if(!Utils.isNullOrEmpty(userTags.getTags())) {
        TagDAO tagDao = DBUtil.getTagDAO();
        tagDao.deleteTagsForUsername(appId, username, userTags.getTags());
      }
    }
  } catch (Exception e) {
    return IQUtils.createErrorIQ(packet, "User does not exist", StatusCode.BAD_REQUEST);
  }

  MMXStatus status = new MMXStatus();
  status.setCode(StatusCode.SUCCESS)
        .setMessage("Success");
  return IQUtils.createResultIQ(packet, status.toJson());

}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:23,代码来源:MMXUserHandler.java

示例5: getAppId

import org.xmpp.packet.JID; //导入方法依赖的package包/类
/**
 * Get the appId from the node part of the JID.
 * @param jid
 * @return null or the app ID.
 */
public static String getAppId(JID jid) {
  if (jid == null) {
    return null;
  }
  String node = jid.getNode();
  if (node == null) {
    return null;
  }

  int delpos = node.lastIndexOf(APP_ID_DELIMITER);
  if (delpos < 0) {
    return null;
  }
  return node.substring(delpos+1);
}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:21,代码来源:JIDUtil.java

示例6: isAdmin

import org.xmpp.packet.JID; //导入方法依赖的package包/类
/**
   * Check if the <code>from</code> has admin capability.  Only the escaped
   * node part (userID) is validate.  TODO: it is not clear how the Openfire
   * stores the node as escaped or unescaped JID.
   *
   * @param from A full JID or bare JID.
   * @return
   */
  public static boolean isAdmin(JID from) {
    XMPPServer server = XMPPServer.getInstance();
    if (server.isLocal(from)) {
      String userId = from.getNode();
      for (JID admin : server.getAdmins()) {
//        if (JID.equals(admin.getNode(), userId)) {
//          return true;
//        }
        String adminNode = admin.getNode();
        if (adminNode.equals(userId)) {
          return true;
        }
      }
    }
    return false;
  }
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:25,代码来源:Helper.java

示例7: handleUpdateUser

import org.xmpp.packet.JID; //导入方法依赖的package包/类
IQ handleUpdateUser(IQ packet, JID from, String appId, String payload)
    throws UnauthorizedException {
  UserInfo request = UserInfo.fromJson(payload);
  String userName = from.getNode();
  
  try {
    UserManager userManager = XMPPServer.getInstance().getUserManager();
    User user = userManager.getUser(userName);
    if (user == null) {
      throw new UserNotFoundException();
    }
    if (request.getEmail() != null) {
      user.setEmail(request.getEmail());
    }
    if (request.getDisplayName() != null) {
      user.setName(request.getDisplayName());
    }
  } catch (UserNotFoundException e) {
    return IQUtils.createErrorIQ(packet,
          UserOperationStatusCode.USER_NOT_FOUND.getMessage(),
          UserOperationStatusCode.USER_NOT_FOUND.getCode());
  }

  MMXStatus userResp = new MMXStatus();
  userResp.setCode(UserOperationStatusCode.USER_UPDATED.getCode());
  userResp.setMessage(UserOperationStatusCode.USER_UPDATED.getMessage());
  IQ response = IQUtils.createResultIQ(packet, userResp.toJson());
  return response;
}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:30,代码来源:MMXUserHandler.java

示例8: getUserId

import org.xmpp.packet.JID; //导入方法依赖的package包/类
/**
 * Get the escaped user ID from the node part.
 * @param jid
 * @return The user ID without the appId.
 */
public static String getUserId(JID jid) {
  if (jid == null) {
    return null;
  }
  String node = jid.getNode();
  return getUserId(node);
}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:13,代码来源:JIDUtil.java

示例9: build

import org.xmpp.packet.JID; //导入方法依赖的package包/类
/**
 * Build a topicName subscription object using the node subscription information.
 * @param nodeSubscription
 * @return
 */
public static ChannelSubscription build (NodeSubscription nodeSubscription) {
  JID subscriberJID = nodeSubscription.getJID();
  String subscriberJIDNode = subscriberJID.getNode();
  String userId = JIDUtil.getUserId(subscriberJIDNode);
  String resource = subscriberJID.getResource();
  AppTopic topic = TopicHelper.parseTopic(nodeSubscription.getNode().getNodeID());
  String topicName = topic.getName();
  ChannelSubscription subscription = new ChannelSubscription();
  subscription.subscriptionId = nodeSubscription.getID();
  subscription.channelName = topicName;
  subscription.userId = userId;
  subscription.deviceId = resource;
  return subscription;
}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:20,代码来源:ChannelSubscription.java

示例10: build

import org.xmpp.packet.JID; //导入方法依赖的package包/类
/**
 * Build a topicName subscription object using the node subscription information.
 * @param nodeSubscription
 * @return
 */
public static TopicSubscription build (NodeSubscription nodeSubscription) {
  JID subscriberJID = nodeSubscription.getJID();
  String subscriberJIDNode = subscriberJID.getNode();
  String username = JIDUtil.getUserId(subscriberJIDNode);
  String resource = subscriberJID.getResource();
  AppTopic topic = TopicHelper.parseTopic(nodeSubscription.getNode().getNodeID());
  String topicName = topic.getName();
  TopicSubscription subscription = new TopicSubscription();
  subscription.subscriptionId = nodeSubscription.getID();
  subscription.topicName = topicName;
  subscription.username = username;
  subscription.deviceId = resource;
  return subscription;
}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:20,代码来源:TopicSubscription.java


注:本文中的org.xmpp.packet.JID.getNode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。