本文整理汇总了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());
}
示例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());
}
}
示例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());
}
示例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());
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}