本文整理汇总了Java中org.jivesoftware.openfire.pubsub.NodeAffiliate.getAffiliation方法的典型用法代码示例。如果您正苦于以下问题:Java NodeAffiliate.getAffiliation方法的具体用法?Java NodeAffiliate.getAffiliation怎么用?Java NodeAffiliate.getAffiliation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jivesoftware.openfire.pubsub.NodeAffiliate
的用法示例。
在下文中一共展示了NodeAffiliate.getAffiliation方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: canPublish
import org.jivesoftware.openfire.pubsub.NodeAffiliate; //导入方法依赖的package包/类
@Override
public boolean canPublish(Node node, JID entity) {
NodeAffiliate nodeAffiliate = node.getAffiliate(entity);
// Deny access if user does not have any relation with the node or is an outcast
if (nodeAffiliate == null ||
nodeAffiliate.getAffiliation() == NodeAffiliate.Affiliation.outcast) {
return false;
}
// Grant access if user is an owner of publisher
if (nodeAffiliate.getAffiliation() == NodeAffiliate.Affiliation.publisher ||
nodeAffiliate.getAffiliation() == NodeAffiliate.Affiliation.owner) {
return true;
}
// Grant access if at least one subscription of this user was approved
for (NodeSubscription subscription : nodeAffiliate.getSubscriptions()) {
if (subscription.isActive()) {
return true;
}
}
return false;
}
示例2: canPublish
import org.jivesoftware.openfire.pubsub.NodeAffiliate; //导入方法依赖的package包/类
@Override
public boolean canPublish(Node node, JID entity) {
NodeAffiliate nodeAffiliate = node.getAffiliate(entity);
// Deny access if user does not have any relation with the node or is an outcast
if (nodeAffiliate == null ||
nodeAffiliate.getAffiliation() == NodeAffiliate.Affiliation.outcast) {
return false;
}
// Grant access if user is an owner of publisher
if (nodeAffiliate.getAffiliation() == NodeAffiliate.Affiliation.publisher ||
nodeAffiliate.getAffiliation() == NodeAffiliate.Affiliation.owner) {
return true;
}
// Grant access if at least one subscription of this user was approved
for (NodeSubscription subscription : nodeAffiliate.getSubscriptions()) {
if (subscription.isActive()) {
return true;
}
}
return false;
}
示例3: canSubscribe
import org.jivesoftware.openfire.pubsub.NodeAffiliate; //导入方法依赖的package包/类
@Override
public boolean canSubscribe(Node node, JID owner, JID subscriber) {
// Let node owners and sysadmins always subcribe to the node
if (node.isAdmin(owner)) {
return true;
}
// User is in the whitelist if he has an affiliation and it is not of type outcast
NodeAffiliate nodeAffiliate = node.getAffiliate(owner);
return nodeAffiliate != null &&
nodeAffiliate.getAffiliation() != NodeAffiliate.Affiliation.outcast;
}
示例4: canPublish
import org.jivesoftware.openfire.pubsub.NodeAffiliate; //导入方法依赖的package包/类
@Override
public boolean canPublish(Node node, JID entity) {
NodeAffiliate nodeAffiliate = node.getAffiliate(entity);
return nodeAffiliate != null && (
nodeAffiliate.getAffiliation() == NodeAffiliate.Affiliation.publisher ||
nodeAffiliate.getAffiliation() == NodeAffiliate.Affiliation.owner);
}
示例5: canSubscribe
import org.jivesoftware.openfire.pubsub.NodeAffiliate; //导入方法依赖的package包/类
@Override
public boolean canSubscribe(Node node, JID owner, JID subscriber) {
// Let node owners and sysadmins always subcribe to the node
if (node.isAdmin(owner)) {
return true;
}
// User is in the whitelist if he has an affiliation and it is not of type outcast
NodeAffiliate nodeAffiliate = node.getAffiliate(owner);
return nodeAffiliate != null &&
nodeAffiliate.getAffiliation() != NodeAffiliate.Affiliation.outcast;
}
示例6: canPublish
import org.jivesoftware.openfire.pubsub.NodeAffiliate; //导入方法依赖的package包/类
@Override
public boolean canPublish(Node node, JID entity) {
NodeAffiliate nodeAffiliate = node.getAffiliate(entity);
return nodeAffiliate != null && (
nodeAffiliate.getAffiliation() == NodeAffiliate.Affiliation.publisher ||
nodeAffiliate.getAffiliation() == NodeAffiliate.Affiliation.owner);
}
示例7: getItems
import org.jivesoftware.openfire.pubsub.NodeAffiliate; //导入方法依赖的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;
}