本文整理汇总了Java中org.jivesoftware.openfire.pubsub.NodeAffiliate类的典型用法代码示例。如果您正苦于以下问题:Java NodeAffiliate类的具体用法?Java NodeAffiliate怎么用?Java NodeAffiliate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NodeAffiliate类属于org.jivesoftware.openfire.pubsub包,在下文中一共展示了NodeAffiliate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: canAccessItems
import org.jivesoftware.openfire.pubsub.NodeAffiliate; //导入依赖的package包/类
@Override
public boolean canAccessItems(Node node, JID owner, JID subscriber) {
// Let node owners and sysadmins always get node items
if (node.isAdmin(owner)) {
return true;
}
NodeAffiliate nodeAffiliate = node.getAffiliate(owner);
if (nodeAffiliate == null) {
// This is an unknown entity to the node so deny access
return false;
}
// Any subscription of this entity that was approved will give him access
// to retrieve the node items
for (NodeSubscription subscription : nodeAffiliate.getSubscriptions()) {
if (subscription.isActive()) {
return true;
}
}
// No approved subscription was found so deny access
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: canAccessItems
import org.jivesoftware.openfire.pubsub.NodeAffiliate; //导入依赖的package包/类
@Override
public boolean canAccessItems(Node node, JID owner, JID subscriber) {
// Let node owners and sysadmins always get node items
if (node.isAdmin(owner)) {
return true;
}
NodeAffiliate nodeAffiliate = node.getAffiliate(owner);
if (nodeAffiliate == null) {
// This is an unknown entity to the node so deny access
return false;
}
// Any subscription of this entity that was approved will give him access
// to retrieve the node items
for (NodeSubscription subscription : nodeAffiliate.getSubscriptions()) {
if (subscription.isActive()) {
return true;
}
}
// No approved subscription was found so deny access
return false;
}
示例4: 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;
}
示例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: run
import org.jivesoftware.openfire.pubsub.NodeAffiliate; //导入依赖的package包/类
@Override
public void run()
{
log.debug("[TASK] New subscription : {}", toString());
Node node = getNode();
// This will only occur if a PEP service is not loaded. We can safely do nothing in this
// case since any changes will get loaded from the db when it is loaded.
if (node == null)
return;
if (node.getAffiliate(getOwner()) == null)
{
// add the missing 'none' affiliation
NodeAffiliate affiliate = new NodeAffiliate(node, getOwner());
affiliate.setAffiliation(NodeAffiliate.Affiliation.none);
node.addAffiliate(affiliate);
}
node.addSubscription(getSubscription());
if (node.isPresenceBasedDelivery() && node.getSubscriptions(getSubscription().getOwner()).size() == 1)
{
if (getSubscription().getPresenceStates().isEmpty())
{
// Subscribe to the owner's presence since the node is only
// sending events to online subscribers and this is the first
// subscription of the user and the subscription is not
// filtering notifications based on presence show values.
getService().presenceSubscriptionRequired(getNode(), getOwner());
}
}
}
示例8: readExternal
import org.jivesoftware.openfire.pubsub.NodeAffiliate; //导入依赖的package包/类
@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
{
super.readExternal(in);
jid = (JID) ExternalizableUtil.getInstance().readSerializable(in);
affiliation = (NodeAffiliate.Affiliation) ExternalizableUtil.getInstance().readSerializable(in);
}
示例9: 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;
}
示例10: 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);
}
示例11: run
import org.jivesoftware.openfire.pubsub.NodeAffiliate; //导入依赖的package包/类
public void run()
{
log.debug("[TASK] New subscription : {}", toString());
Node node = getNode();
// This will only occur if a PEP service is not loaded. We can safely do nothing in this
// case since any changes will get loaded from the db when it is loaded.
if (node == null)
return;
if (node.getAffiliate(getOwner()) == null)
{
// add the missing 'none' affiliation
NodeAffiliate affiliate = new NodeAffiliate(node, getOwner());
affiliate.setAffiliation(NodeAffiliate.Affiliation.none);
node.addAffiliate(affiliate);
}
node.addSubscription(getSubscription());
if (node.isPresenceBasedDelivery() && node.getSubscriptions(getSubscription().getOwner()).size() == 1)
{
if (getSubscription().getPresenceStates().isEmpty())
{
// Subscribe to the owner's presence since the node is only
// sending events to online subscribers and this is the first
// subscription of the user and the subscription is not
// filtering notifications based on presence show values.
getService().presenceSubscriptionRequired(getNode(), getOwner());
}
}
}
示例12: readExternal
import org.jivesoftware.openfire.pubsub.NodeAffiliate; //导入依赖的package包/类
@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
{
super.readExternal(in);
jid = (JID) ExternalizableUtil.getInstance().readSerializable(in);
affiliation = (NodeAffiliate.Affiliation) ExternalizableUtil.getInstance().readSerializable(in);
}
示例13: 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;
}
示例14: AffiliationTask
import org.jivesoftware.openfire.pubsub.NodeAffiliate; //导入依赖的package包/类
public AffiliationTask(Node node, JID jid, NodeAffiliate.Affiliation affiliation)
{
super(node);
this.jid = jid;
this.affiliation = affiliation;
}
示例15: getAffilation
import org.jivesoftware.openfire.pubsub.NodeAffiliate; //导入依赖的package包/类
public NodeAffiliate.Affiliation getAffilation()
{
return affiliation;
}