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


Java JID.asBareJID方法代码示例

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


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

示例1: deleteChannel

import org.xmpp.packet.JID; //导入方法依赖的package包/类
public MMXStatus deleteChannel(JID from, String appId,
                        ChannelAction.DeleteRequest rqt) throws MMXException {
  String channel = ChannelHelper.normalizePath(rqt.getChannel());
  String userId = JIDUtil.getUserId(from);
  JID owner = from.asBareJID();
  String realChannel = ChannelHelper.makeChannel(appId, rqt.isPersonal() ?
          userId : null, channel);
  Node node = mPubSubModule.getNode(realChannel);
  if (node == null) {
    throw new MMXException(StatusCode.CHANNEL_NOT_FOUND.getMessage(channel),
        StatusCode.CHANNEL_NOT_FOUND.getCode());
  }
  int count = deleteNode(node, owner);
  MMXStatus status = (new MMXStatus())
      .setCode(StatusCode.SUCCESS.getCode())
      .setMessage(count+" channel"+((count==1)?" is":"s are")+" deleted");
  return status;
}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:19,代码来源:MMXChannelManager.java

示例2: retractAllFromChannel

import org.xmpp.packet.JID; //导入方法依赖的package包/类
public MMXStatus retractAllFromChannel(JID from, String appId,
    ChannelAction.RetractAllRequest rqt) throws MMXException {
  String channel = ChannelHelper.normalizePath(rqt.getChannel());
  String userId = JIDUtil.getUserId(from);
  JID owner = from.asBareJID();
  String realChannel = ChannelHelper.makeChannel(appId, rqt.isPersonal() ?
          userId : null, channel);
  Node node = mPubSubModule.getNode(realChannel);
  if (node == null) {
    throw new MMXException(StatusCode.CHANNEL_NOT_FOUND.getMessage(channel),
        StatusCode.CHANNEL_NOT_FOUND.getCode());
  }
  if (!node.getOwners().contains(owner)) {
    throw new MMXException(StatusCode.FORBIDDEN.getMessage(channel),
        StatusCode.FORBIDDEN.getCode());
  }
  LeafNode leafNode = (LeafNode) node;
  List<PublishedItem> pubItems = leafNode.getPublishedItems();
  leafNode.deleteItems(pubItems);

  int count = (pubItems == null) ? 0 : pubItems.size();
  MMXStatus status = (new MMXStatus())
      .setCode(StatusCode.SUCCESS.getCode())
      .setMessage(count+" item"+((count==1)?" is":"s are")+" retracted");
  return status;
}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:27,代码来源:MMXChannelManager.java

示例3: unsubscribeForDev

import org.xmpp.packet.JID; //导入方法依赖的package包/类
public MMXStatus unsubscribeForDev(JID from, String appId,
                ChannelAction.UnsubscribeForDevRequest rqt) throws MMXException {
  String prefix = ChannelHelper.CHANNEL_DELIM + appId + ChannelHelper.CHANNEL_DELIM;
  int count = 0;
  JID owner = from.asBareJID();
  String devId = rqt.getDevId();
  for (Node node : mPubSubModule.getNodes()) {
    if (!node.getNodeID().startsWith(prefix)) {
      continue;
    }
    for (NodeSubscription subscription : node.getSubscriptions(owner)) {
      if (devId.equals(subscription.getJID().getResource())) {
        ++count;
        node.cancelSubscription(subscription);
      }
    }
  }
  MMXStatus status = (new MMXStatus())
      .setCode(StatusCode.SUCCESS.getCode())
      .setMessage(count+" subscription"+((count==1)?" is":"s are")+" cancelled");
  return status;
}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:23,代码来源:MMXChannelManager.java

示例4: deleteTopic

import org.xmpp.packet.JID; //导入方法依赖的package包/类
public MMXStatus deleteTopic(JID from, String appId,
                        TopicAction.DeleteRequest rqt) throws MMXException {
  String topic = TopicHelper.normalizePath(rqt.getTopic());
  String userId = JIDUtil.getUserId(from);
  JID owner = from.asBareJID();
  String realTopic = TopicHelper.makeTopic(appId, rqt.isPersonal() ?
      userId : null, topic);
  Node node = mPubSubModule.getNode(realTopic);
  if (node == null) {
    throw new MMXException(StatusCode.TOPIC_NOT_FOUND.getMessage(topic),
        StatusCode.TOPIC_NOT_FOUND.getCode());
  }
  int count = deleteNode(node, owner);
  MMXStatus status = (new MMXStatus())
      .setCode(StatusCode.SUCCESS.getCode())
      .setMessage(count+" topic"+((count==1)?" is":"s are")+" deleted");
  return status;
}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:19,代码来源:MMXTopicManager.java

示例5: retractAllFromTopic

import org.xmpp.packet.JID; //导入方法依赖的package包/类
public MMXStatus retractAllFromTopic(JID from, String appId,
    TopicAction.RetractAllRequest rqt) throws MMXException {
  String topic = TopicHelper.normalizePath(rqt.getTopic());
  String userId = JIDUtil.getUserId(from);
  JID owner = from.asBareJID();
  String realTopic = TopicHelper.makeTopic(appId, rqt.isPersonal() ?
      userId : null, topic);
  Node node = mPubSubModule.getNode(realTopic);
  if (node == null) {
    throw new MMXException(StatusCode.TOPIC_NOT_FOUND.getMessage(topic),
        StatusCode.TOPIC_NOT_FOUND.getCode());
  }
  if (!node.getOwners().contains(owner)) {
    throw new MMXException(StatusCode.FORBIDDEN.getMessage(topic),
        StatusCode.FORBIDDEN.getCode());
  }
  LeafNode leafNode = (LeafNode) node;
  List<PublishedItem> pubItems = leafNode.getPublishedItems();
  leafNode.deleteItems(pubItems);

  int count = (pubItems == null) ? 0 : pubItems.size();
  MMXStatus status = (new MMXStatus())
      .setCode(StatusCode.SUCCESS.getCode())
      .setMessage(count+" item"+((count==1)?" is":"s are")+" retracted");
  return status;
}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:27,代码来源:MMXTopicManager.java

示例6: unsubscribeForDev

import org.xmpp.packet.JID; //导入方法依赖的package包/类
public MMXStatus unsubscribeForDev(JID from, String appId,
                TopicAction.UnsubscribeForDevRequest rqt) throws MMXException {
  String prefix = TopicHelper.TOPIC_DELIM + appId + TopicHelper.TOPIC_DELIM;
  int count = 0;
  JID owner = from.asBareJID();
  String devId = rqt.getDevId();
  for (Node node : mPubSubModule.getNodes()) {
    if (!node.getNodeID().startsWith(prefix)) {
      continue;
    }
    for (NodeSubscription subscription : node.getSubscriptions(owner)) {
      if (devId.equals(subscription.getJID().getResource())) {
        ++count;
        node.cancelSubscription(subscription);
      }
    }
  }
  MMXStatus status = (new MMXStatus())
      .setCode(StatusCode.SUCCESS.getCode())
      .setMessage(count+" subscription"+((count==1)?" is":"s are")+" cancelled");
  return status;
}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:23,代码来源:MMXTopicManager.java

示例7: unsubscribeChannel

import org.xmpp.packet.JID; //导入方法依赖的package包/类
public MMXStatus unsubscribeChannel(JID from, String appId,
                ChannelAction.UnsubscribeRequest rqt) throws MMXException {
  String channel = ChannelHelper.normalizePath(rqt.getChannel());
  String realChannel = ChannelHelper.makeChannel(appId, rqt.getUserId(), channel);
  Node node = mPubSubModule.getNode(realChannel);
  if (node == null) {
    throw new MMXException(StatusCode.CHANNEL_NOT_FOUND.getMessage(channel),
        StatusCode.CHANNEL_NOT_FOUND.getCode());
  }
  int count = 0;
  JID owner = from.asBareJID();
  String subId = rqt.getSubId();
  for (NodeSubscription subscription : node.getSubscriptions(owner)) {
    if (subId == null || subscription.getID().equals(subId)) {
      ++count;
      node.cancelSubscription(subscription);
    }
  }
  if (count == 0) {
    throw new MMXException(StatusCode.GONE.getMessage(),
        StatusCode.GONE.getCode());
  }

  MMXStatus status = (new MMXStatus())
      .setCode(StatusCode.SUCCESS.getCode())
      .setMessage(count+" subscription"+((count==1)?" is":"s are")+" cancelled");
  return status;
}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:29,代码来源:MMXChannelManager.java

示例8: unsubscribeTopic

import org.xmpp.packet.JID; //导入方法依赖的package包/类
public MMXStatus unsubscribeTopic(JID from, String appId,
                TopicAction.UnsubscribeRequest rqt) throws MMXException {
  String topic = TopicHelper.normalizePath(rqt.getTopic());
  String realTopic = TopicHelper.makeTopic(appId, rqt.getUserId(), topic);
  Node node = mPubSubModule.getNode(realTopic);
  if (node == null) {
    throw new MMXException(StatusCode.TOPIC_NOT_FOUND.getMessage(topic),
        StatusCode.TOPIC_NOT_FOUND.getCode());
  }
  int count = 0;
  JID owner = from.asBareJID();
  String subId = rqt.getSubId();
  for (NodeSubscription subscription : node.getSubscriptions(owner)) {
    if (subId == null || subscription.getID().equals(subId)) {
      ++count;
      node.cancelSubscription(subscription);
    }
  }
  if (count == 0) {
    throw new MMXException(StatusCode.GONE.getMessage(),
        StatusCode.GONE.getCode());
  }

  MMXStatus status = (new MMXStatus())
      .setCode(StatusCode.SUCCESS.getCode())
      .setMessage(count+" subscription"+((count==1)?" is":"s are")+" cancelled");
  return status;
}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:29,代码来源:MMXTopicManager.java

示例9: getMySubscriptions

import org.xmpp.packet.JID; //导入方法依赖的package包/类
@GET
@Path("my_subscriptions")
@Produces(MediaType.APPLICATION_JSON)
public Response getMySubscriptions(@Context HttpHeaders headers) {
  TokenInfo tokenInfo = RestUtils.getAuthTokenInfo(headers);
  if (tokenInfo == null) {
      return RestUtils.getUnauthJAXRSResp();
  }

  JID from = RestUtils.createJID(tokenInfo);
  JID owner = from.asBareJID();
  String appId = tokenInfo.getMmxAppId();

  try {
    long startTime = System.nanoTime();
    PubSubService service = XMPPServer.getInstance().getPubSubModule();
    List<ChannelSubscription> subList = new ArrayList<ChannelSubscription>();
    CollectionNode appNode = (CollectionNode) service.getNode(appId);
    if (appNode != null) {
      for (Node node : appNode.getNodes()) {
        Collection<NodeSubscription> subscriptions = node.getSubscriptions(owner);
        for (NodeSubscription sub : subscriptions) {
          ChannelSubscription info = ChannelSubscription.build(sub);
          subList.add(info);
        }
      }
    }
    long endTime = System.nanoTime();
    LOGGER.info("Completed processing getSubscriptions in {} milliseconds",
        TimeUnit.MILLISECONDS.convert((endTime - startTime), TimeUnit.NANOSECONDS));
    return RestUtils.getOKJAXRSResp(subList);
  } catch (WebApplicationException e) {
    throw e;
  } catch (Throwable t) {
    LOGGER.warn("Throwable during getSubscriptionsForChannels", t);
    ErrorResponse response = new ErrorResponse(ErrorCode.SEARCH_TOPIC_ISE, t
            .getMessage());
    return RestUtils.getInternalErrorJAXRSResp(response);
  }
}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:41,代码来源:ChannelResource.java

示例10: getItems

import org.xmpp.packet.JID; //导入方法依赖的package包/类
public ChannelAction.FetchResponse getItems(JID from, String appId,
    ChannelAction.ItemsByIdsRequest rqt) throws MMXException {
  String channel = ChannelHelper.normalizePath(rqt.getChannel());
  String realChannel = ChannelHelper.makeChannel(appId, rqt.getUserId(), channel);
  Node node = mPubSubModule.getNode(realChannel);
  if (node == null) {
    throw new MMXException(StatusCode.CHANNEL_NOT_FOUND.getMessage(channel),
        StatusCode.CHANNEL_NOT_FOUND.getCode());
  }
  if (node.isCollectionNode()) {
    throw new MMXException("Cannot get items from a collection channel",
        StatusCode.NOT_IMPLEMENTED.getCode());
  }

  LeafNode leafNode = (LeafNode) node;
  List<String> itemIds = rqt.getItemIds();
  if (itemIds == null || itemIds.isEmpty()) {
    throw new MMXException(StatusCode.BAD_REQUEST.getMessage("no item ID's"),
        StatusCode.BAD_REQUEST.getCode());
  }
  // Check if sender and subscriber JIDs match or if a valid "trusted proxy" is being used
  // Assumed that the owner of the subscription is the bare JID of the subscription JID.
  JID owner = from.asBareJID();
  if (!node.getAccessModel().canAccessItems(node, owner, from)) {
    throw new MMXException(StatusCode.FORBIDDEN.getMessage(channel),
        StatusCode.FORBIDDEN.getCode());
  }
  // Check that the requester is not an outcast
  NodeAffiliate affiliate = node.getAffiliate(owner);
  if (affiliate != null && affiliate.getAffiliation() == NodeAffiliate.Affiliation.outcast) {
      throw new MMXException(StatusCode.FORBIDDEN.getMessage(channel),
          StatusCode.FORBIDDEN.getCode());
  }

  // TODO: do we need to check for subscription first?
  List<MMXPublishedItem> mmxItems = new ArrayList<MMXPublishedItem>(itemIds.size());
  for (String itemId : itemIds) {
    if (itemId == null) {
      throw new MMXException(StatusCode.BAD_REQUEST.getMessage("null item ID"),
          StatusCode.BAD_REQUEST.getCode());
    }
    PublishedItem pubItem = leafNode.getPublishedItem(itemId);
    if (pubItem == null) {
      // Ignored the invalid item ID.
      continue;
    }
    MMXPublishedItem mmxItem = new MMXPublishedItem(pubItem.getID(),
          pubItem.getPublisher().toBareJID(),
          pubItem.getCreationDate(),
          pubItem.getPayloadXML());
    mmxItems.add(mmxItem);
  }
  ChannelAction.FetchResponse resp = new ChannelAction.FetchResponse(
      rqt.getUserId(), channel, mmxItems.size(), mmxItems);
  return resp;
}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:57,代码来源:MMXChannelManager.java

示例11: getItems

import org.xmpp.packet.JID; //导入方法依赖的package包/类
public TopicAction.FetchResponse getItems(JID from, String appId,
    TopicAction.ItemsByIdsRequest rqt) throws MMXException {
  String topic = TopicHelper.normalizePath(rqt.getTopic());
  String realTopic = TopicHelper.makeTopic(appId, rqt.getUserId(), topic);
  Node node = mPubSubModule.getNode(realTopic);
  if (node == null) {
    throw new MMXException(StatusCode.TOPIC_NOT_FOUND.getMessage(topic),
        StatusCode.TOPIC_NOT_FOUND.getCode());
  }
  if (node.isCollectionNode()) {
    throw new MMXException("Cannot get items from a collection topic",
        StatusCode.NOT_IMPLEMENTED.getCode());
  }

  LeafNode leafNode = (LeafNode) node;
  List<String> itemIds = rqt.getItemIds();
  if (itemIds == null || itemIds.isEmpty()) {
    throw new MMXException(StatusCode.BAD_REQUEST.getMessage("no item ID's"),
        StatusCode.BAD_REQUEST.getCode());
  }
  // Check if sender and subscriber JIDs match or if a valid "trusted proxy" is being used
  // Assumed that the owner of the subscription is the bare JID of the subscription JID.
  JID owner = from.asBareJID();
  if (!node.getAccessModel().canAccessItems(node, owner, from)) {
    throw new MMXException(StatusCode.FORBIDDEN.getMessage(topic),
        StatusCode.FORBIDDEN.getCode());
  }
  // Check that the requester is not an outcast
  NodeAffiliate affiliate = node.getAffiliate(owner);
  if (affiliate != null && affiliate.getAffiliation() == NodeAffiliate.Affiliation.outcast) {
      throw new MMXException(StatusCode.FORBIDDEN.getMessage(topic),
          StatusCode.FORBIDDEN.getCode());
  }

  // TODO: do we need to check for subscription first?
  List<MMXPublishedItem> mmxItems = new ArrayList<MMXPublishedItem>(itemIds.size());
  for (String itemId : itemIds) {
    if (itemId == null) {
      throw new MMXException(StatusCode.BAD_REQUEST.getMessage("null item ID"),
          StatusCode.BAD_REQUEST.getCode());
    }
    PublishedItem pubItem = leafNode.getPublishedItem(itemId);
    if (pubItem == null) {
      // Ignored the invalid item ID.
      continue;
    }
    MMXPublishedItem mmxItem = new MMXPublishedItem(pubItem.getID(),
          pubItem.getPublisher().toBareJID(),
          pubItem.getCreationDate(),
          pubItem.getPayloadXML());
    mmxItems.add(mmxItem);
  }
  TopicAction.FetchResponse resp = new TopicAction.FetchResponse(
      rqt.getUserId(), topic, mmxItems.size(), mmxItems);
  return resp;
}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:57,代码来源:MMXTopicManager.java


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