本文整理汇总了Java中org.jivesoftware.openfire.pubsub.Node.isCollectionNode方法的典型用法代码示例。如果您正苦于以下问题:Java Node.isCollectionNode方法的具体用法?Java Node.isCollectionNode怎么用?Java Node.isCollectionNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jivesoftware.openfire.pubsub.Node
的用法示例。
在下文中一共展示了Node.isCollectionNode方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: listTopicsForAppId
import org.jivesoftware.openfire.pubsub.Node; //导入方法依赖的package包/类
/**
* Get a list of Leaf Topic nodes for the passed in appId
* (collection nodes aren't returned)
* @param appId
* @return
*/
public List<TopicNode> listTopicsForAppId(String appId) {
ArrayList<TopicNode> result = new ArrayList<TopicNode>();
CollectionNode rootNode = getRootAppTopic(appId);
if (rootNode != null) {
Collection<Node> nodes = rootNode.getNodes();
for (Node node : nodes) {
//For fixing: https://magneteng.atlassian.net/browse/MOB-833
if (node.isCollectionNode()) {
continue;
}
String identifier = node.getNodeID();
boolean isAppTopic = TopicHelper.isAppTopic(identifier, appId);
if (isAppTopic) {
TopicNode tn = TopicNode.build(appId, node);
result.add(tn);
}
}
}
return result;
}
示例2: getTopicInfo
import org.jivesoftware.openfire.pubsub.Node; //导入方法依赖的package包/类
/**
* Get a list of Leaf Topic nodes for the passed in appId
* (collection nodes aren't returned)
* @param appId
* @return
*/
public List<com.magnet.mmx.server.api.v1.protocol.TopicInfo> getTopicInfo(String appId) {
ArrayList<com.magnet.mmx.server.api.v1.protocol.TopicInfo> result =
new ArrayList<com.magnet.mmx.server.api.v1.protocol.TopicInfo>();
CollectionNode rootNode = getRootAppTopic(appId);
if (rootNode != null) {
Collection<Node> nodes = rootNode.getNodes();
for (Node node : nodes) {
//For fixing: https://magneteng.atlassian.net/browse/MOB-833
if (node.isCollectionNode()) {
continue;
}
String identifier = node.getNodeID();
boolean isAppTopic = TopicHelper.isAppTopic(identifier, appId);
if (isAppTopic) {
com.magnet.mmx.server.api.v1.protocol.TopicInfo info =
getTopicInfoFromNode(appId, node);
result.add(info);
}
}
}
return result;
}
示例3: nodeToInfo
import org.jivesoftware.openfire.pubsub.Node; //导入方法依赖的package包/类
private TopicInfo nodeToInfo(String userId, String topic, Node node) {
TopicInfo info = new TopicInfo(
userId, node.getName() != null ? node.getName() : topic, node.isCollectionNode())
.setCreationDate(node.getCreationDate())
.setDescription(node.getDescription())
.setModifiedDate(node.getModificationDate())
.setCreator(node.getCreator().toString())
.setSubscriptionEnabled(node.isSubscriptionEnabled());
if (!node.isCollectionNode()) {
LeafNode leafNode = (LeafNode) node;
info.setMaxItems(leafNode.isPersistPublishedItems() ?
leafNode.getMaxPublishedItems() : 0)
.setMaxPayloadSize(leafNode.getMaxPayloadSize())
.setPersistent(leafNode.isPersistPublishedItems())
.setPublisherType(ConfigureForm.convert(leafNode.getPublisherModel()));
} else {
info.setMaxItems(0)
.setMaxPayloadSize(0)
.setPersistent(false)
.setPublisherType(null);
}
return info;
}
示例4: build
import org.jivesoftware.openfire.pubsub.Node; //导入方法依赖的package包/类
public static TopicNode build(String appId, Node node) {
TopicNode tn = new TopicNode();
tn.setDescription(node.getDescription());
tn.setCollection(node.isCollectionNode());
MMXTopicId tid = TopicHelper.parseNode(node.getNodeID());
tn.setUserId(tid.getUserId());
tn.setTopicName(tid.getName());
tn.setSubscriptionCount(node.getAllSubscriptions().size());
tn.setCollection(node.isCollectionNode());
tn.setSubscriptionEnabled(node.isSubscriptionEnabled());
if (!node.isCollectionNode()) {
LeafNode leafNode = (LeafNode) node;
tn.setMaxItems(leafNode.getMaxPublishedItems());
tn.setMaxPayloadSize(leafNode.getMaxPayloadSize());
tn.setPersistent(leafNode.isPersistPublishedItems());
tn.setPublisherType(ConfigureForm.convert(leafNode.getPublisherModel()).name());
} else {
tn.setMaxItems(0);
tn.setMaxPayloadSize(0);
tn.setPersistent(false);
tn.setPublisherType(null);
}
return tn;
}
示例5: build
import org.jivesoftware.openfire.pubsub.Node; //导入方法依赖的package包/类
public static ChannelNode build(String appId, Node node) {
ChannelNode tn = new ChannelNode();
tn.setDescription(node.getDescription());
tn.setCollection(node.isCollectionNode());
MMXChannelId tid = ChannelHelper.parseNode(node.getNodeID());
tn.setUserId(tid.getUserId());
tn.setChannelName(tid.getName());
tn.setSubscriptionCount(node.getAllSubscriptions().size());
tn.setCollection(node.isCollectionNode());
tn.setSubscriptionEnabled(node.isSubscriptionEnabled());
if (!node.isCollectionNode()) {
LeafNode leafNode = (LeafNode) node;
tn.setMaxItems(leafNode.getMaxPublishedItems());
tn.setMaxPayloadSize(leafNode.getMaxPayloadSize());
tn.setPersistent(leafNode.isPersistPublishedItems());
tn.setPublishPermission(ConfigureForm.convert(leafNode.getPublisherModel()).name());
} else {
tn.setMaxItems(0);
tn.setMaxPayloadSize(0);
tn.setPersistent(false);
tn.setPublishPermission(null);
}
return tn;
}
示例6: getRootAppTopic
import org.jivesoftware.openfire.pubsub.Node; //导入方法依赖的package包/类
/**
* Get the root collection node for an app
*
* @param appId
* @return
*/
public CollectionNode getRootAppTopic(String appId) {
Node result = mPubSubModule.getNode(appId);
if (result != null && result.isCollectionNode()) {
return (CollectionNode) result;
} else {
return null;
}
}
示例7: createCollectionNode
import org.jivesoftware.openfire.pubsub.Node; //导入方法依赖的package包/类
CollectionNode createCollectionNode(String creatorUsername, String nodeId, CollectionNode parentNode) {
CollectionNode parent = (parentNode == null) ? mPubSubModule.getRootCollectionNode() : parentNode;
Node result = mPubSubModule.getNode(nodeId);
if (result != null && !result.isCollectionNode()) {
result.delete();
result = null;
// TODO cleanup existing published Items for this node
}
if (result == null) {
ConfigureForm form = new ConfigureForm(DataForm.Type.submit);
form.setSendItemSubscribe(true);
form.setDeliverPayloads(true);
form.setNotifyRetract(false);
form.setNotifyDelete(false);
form.setNotifyConfig(false);
form.setNodeType(ConfigureForm.NodeType.collection);
form.setPublishModel(ConfigureForm.PublishModel.open);
LOGGER.trace("Collection config form: " + form);
JID jid = new JID(creatorUsername, mServer.getServerInfo().getXMPPDomain(), null);
CollectionNode node = new CollectionNode(mPubSubModule, parent, nodeId, jid);
node.addOwner(jid);
try {
node.configure(form);
} catch (NotAcceptableException e) {
LOGGER.warn("NotAcceptableException", e);
}
node.saveToDB();
CacheFactory.doClusterTask(new RefreshNodeTask(node));
result = node;
}
return (CollectionNode) result;
}
示例8: getItemsByIds
import org.jivesoftware.openfire.pubsub.Node; //导入方法依赖的package包/类
@Path("/byids")
@GET
@Produces({MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN})
public Response getItemsByIds(@Context HttpHeaders headers,
@PathParam(MMXServerConstants.TOPICNAME_PATH_PARAM) String topicName,
@QueryParam(ID_KEY) List<String> idList) {
try {
ErrorResponse errorResponse = isAuthenticated(headers, DBUtil.getAppDAO());
if (errorResponse != null) {
return errorResponse.toJaxRSResponse();
}
MultivaluedMap<String, String> requestHeaders = headers.getRequestHeaders();
String appId = requestHeaders.getFirst(MMXServerConstants.HTTP_HEADER_APP_ID);
if (idList == null || idList.isEmpty()) {
throw buildForBadRequest(ErrorCode.TOPIC_ITEMS_BY_ID.getCode(), ErrorMessages.ERROR_ITEM_ID_LIST_INVALID);
}
PubSubService pubSubService = getPubSubService();
String topic = TopicHelper.normalizePath(topicName);
// MMX-3207 handle user topic.
MMXTopicId topicId = TopicResource.nameToId(topicName);
String realTopic = TopicHelper.makeTopic(appId, topicId.getEscUserId(), topicId.getName());
Node node = pubSubService.getNode(realTopic);
if (node == null || node.isCollectionNode()) {
LOGGER.info("Topic with name:{} not found", topicName);
String message = String.format(ErrorMessages.ERROR_TOPIC_NOT_FOUND, topicName);
throw buildWebApplicationException(ErrorCode.TOPIC_ITEMS_BY_ID.getCode(), message, Response.Status.NOT_FOUND);
}
JID creator = node.getCreator();
MMXTopicManager topicManager = MMXTopicManager.getInstance();
TopicAction.FetchResponse itemList = topicManager.getItems(creator, appId, new TopicAction.ItemsByIdsRequest(null, topicName, idList));
return Response.status(Response.Status.OK).entity(itemList).build();
} catch (WebApplicationException e) {
throw e;
} catch (Throwable t) {
LOGGER.warn("Throwable during getItems", t);
throw new WebApplicationException(
Response
.status(Response.Status.INTERNAL_SERVER_ERROR)
.entity(new ErrorResponse(ErrorCode.SEND_PUSH_MESSAGE_ISE, t.getMessage()))
.build()
);
}
}
示例9: retractFromTopic
import org.jivesoftware.openfire.pubsub.Node; //导入方法依赖的package包/类
public Map<String, Integer> retractFromTopic(JID from, String appId,
TopicAction.RetractRequest 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 retract items from a collection topic",
StatusCode.NOT_IMPLEMENTED.getCode());
}
LeafNode leafNode = (LeafNode) node;
List<String> itemIds = rqt.getItemIds();
if (itemIds == null || itemIds.size() == 0) {
throw new MMXException(StatusCode.BAD_REQUEST.getMessage("no item ID's"),
StatusCode.BAD_REQUEST.getCode());
}
if (!leafNode.isItemRequired()) {
// Cannot delete items from a leaf node that doesn't handle itemIDs
throw new MMXException("Items required in this topic",
StatusCode.NOT_IMPLEMENTED.getCode());
}
List<PublishedItem> pubItems = new ArrayList<PublishedItem>(itemIds.size());
Map<String, Integer> results = new HashMap<String, Integer>(itemIds.size());
for (String itemId : itemIds) {
if (itemId == null) {
continue;
}
PublishedItem item = leafNode.getPublishedItem(itemId);
if (item == null) {
results.put(itemId, StatusCode.ITEM_NOT_FOUND.getCode());
}
if (!item.canDelete(from)) {
results.put(itemId, StatusCode.FORBIDDEN.getCode());
}
pubItems.add(item);
results.put(itemId, StatusCode.SUCCESS.getCode());
}
leafNode.deleteItems(pubItems);
return results;
}
示例10: getTopChildNodes
import org.jivesoftware.openfire.pubsub.Node; //导入方法依赖的package包/类
private int getTopChildNodes(boolean recursive, Node root,
TopicAction.ListResponse resp, int limit, ListType type, String userId, List<String> roles) {
boolean globalOnly = (type == ListType.global);
if (roles == null || roles.isEmpty()) {
roles = Collections.singletonList(MMXServerConstants.TOPIC_ROLE_PUBLIC);
}
for (Node child : root.getNodes()) {
AppTopic topic = TopicHelper.parseTopic(child.getNodeID());
if (topic == null) {
LOGGER.warn("Ignore malformed topic: " + child.getNodeID());
continue;
}
// Brain teaser: the xor below is actually same as
// (type == ListType.global && !topic.isUserTopic()) ||
// (type == ListType.personal && topic.isUserTopic()))
if ((type == ListType.both) || (globalOnly ^ topic.isUserTopic())) {
if (topic.isUserTopic() && !topic.getEscUserId().equals(userId)) {
continue;
}
if (--limit < 0) {
return limit;
}
//resp.add(nodeToInfo(topic.getUserId(), topic.getName(), child));
/**
* Add a check to see if the topic role mapping allows current user's roles
* to access this topic. The check should be done only for global topics
*/
if (!topic.isUserTopic()) {
boolean userHasRole = isAllowed(child.getNodeID(), roles);
if (userHasRole) {
resp.add(nodeToInfo(topic.getUserId(), topic.getName(), child));
}
} else {
resp.add(nodeToInfo(topic.getUserId(), topic.getName(), child));
}
if (recursive && child.isCollectionNode()) {
limit = getChildNodes(recursive, child, resp, limit);
}
}
}
return limit;
}
示例11: getItems
import org.jivesoftware.openfire.pubsub.Node; //导入方法依赖的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;
}