📄 node.java
字号:
for (JID owner : getReplyTo()) { formField.addValue(owner.toString()); } } /** * Returns a data form with the node configuration. The returned data form is used for * notifying node subscribers that the node configuration has changed. The data form is * ony going to be included if node is configure to include payloads in event * notifications. * * @return a data form with the node configuration. */ private DataForm getConfigurationChangeForm() { DataForm form = new DataForm(DataForm.Type.result); FormField formField = form.addField(); formField.setVariable("FORM_TYPE"); formField.setType(FormField.Type.hidden); formField.addValue("http://jabber.org/protocol/pubsub#node_config"); // Add the form fields and configure them for notification // (i.e. no label or options are included) addFormFields(form, false); return form; } /** * Returns a data form containing the node configuration that is going to be used for * service discovery. * * @return a data form with the node configuration. */ public DataForm getMetadataForm() { DataForm form = new DataForm(DataForm.Type.result); FormField formField = form.addField(); formField.setVariable("FORM_TYPE"); formField.setType(FormField.Type.hidden); formField.addValue("http://jabber.org/protocol/pubsub#meta-data"); // Add the form fields addFormFields(form, true); return form; } /** * Returns true if this node is the root node of the pubsub service. * * @return true if this node is the root node of the pubsub service. */ public boolean isRootCollectionNode() { return service.getRootCollectionNode() == this; } /** * Returns true if a user may have more than one subscription with the node. When * multiple subscriptions is enabled each subscription request, event notification and * unsubscription request should include a <tt>subid</tt> attribute. By default multiple * subscriptions is enabled. * * @return true if a user may have more than one subscription with the node. */ public boolean isMultipleSubscriptionsEnabled() { return service.isMultipleSubscriptionsEnabled(); } /** * Returns true if this node is a node container. Node containers may only contain nodes * but are not allowed to get items published. * * @return true if this node is a node container. */ public boolean isCollectionNode() { return false; } /** * Returns true if the specified node is a first-level children of this node. * * @param child the node to check if it is a direct child of this node. * @return true if the specified node is a first-level children of this collection * node. */ public boolean isChildNode(Node child) { return false; } /** * Returns true if the specified node is a direct child node of this node or * a descendant of the children nodes. * * @param child the node to check if it is a descendant of this node. * @return true if the specified node is a direct child node of this node or * a descendant of the children nodes. */ public boolean isDescendantNode(Node child) { return false; } /** * Returns true if the specified user is allowed to administer the node. Node * administrator are allowed to retrieve the node configuration, change the node * configuration, purge the node, delete the node and get the node affiliations and * subscriptions. * * @param user the user to check if he is an admin. * @return true if the specified user is allowed to administer the node. */ public boolean isAdmin(JID user) { if (getOwners().contains(user) || service.isServiceAdmin(user)) { return true; } // Check if we should try again but using the bare JID if (user.getResource() != null) { user = new JID(user.toBareJID()); return isAdmin(user); } return false; } /** * Returns the unique identifier for a node within the context of a pubsub service. * * @return the unique identifier for a node within the context of a pubsub service. */ public String getNodeID() { return nodeID; } /** * Returns the name of the node. The node may not have a configured name. The node's * name can be changed by submiting a completed data form. * * @return the name of the node. */ public String getName() { return name; } /** * Returns true if event notifications will include payloads. Payloads are included when * publishing new items. However, new items may not always include a payload depending * on the node configuration. Nodes can be configured to not deliver payloads for performance * reasons. * * @return true if event notifications will include payloads. */ public boolean isPayloadDelivered() { return deliverPayloads; } public ItemReplyPolicy getReplyPolicy() { return replyPolicy; } /** * Returns true if subscribers will be notified when the node configuration changes. * * @return true if subscribers will be notified when the node configuration changes. */ public boolean isNotifiedOfConfigChanges() { return notifyConfigChanges; } /** * Returns true if subscribers will be notified when the node is deleted. * * @return true if subscribers will be notified when the node is deleted. */ public boolean isNotifiedOfDelete() { return notifyDelete; } /** * Returns true if subscribers will be notified when items are removed from the node. * * @return true if subscribers will be notified when items are removed from the node. */ public boolean isNotifiedOfRetract() { return notifyRetract; } /** * Returns true if notifications are going to be delivered to available users only. * * @return true if notifications are going to be delivered to available users only. */ public boolean isPresenceBasedDelivery() { return presenceBasedDelivery; } /** * Returns true if notifications to the specified user will be delivered when the * user is online. * * @param user the JID of the affiliate that has to be subscribed to the node. * @return true if notifications are going to be delivered when the user is online. */ public boolean isPresenceBasedDelivery(JID user) { Collection<NodeSubscription> subscriptions = getSubscriptions(user); if (!subscriptions.isEmpty()) { if (presenceBasedDelivery) { // Node sends notifications only to only users so return true return true; } else { // Check if there is a subscription configured to only send notifications // based on the user presence for (NodeSubscription subscription : subscriptions) { if (!subscription.getPresenceStates().isEmpty()) { return true; } } } } // User is not subscribed to the node so presence subscription is not required return false; } /** * Returns the JID of the affiliates that are receiving notifications based on their * presence status. * * @return the JID of the affiliates that are receiving notifications based on their * presence status. */ Collection<JID> getPresenceBasedSubscribers() { Collection<JID> affiliatesJID = new ArrayList<JID>(); if (presenceBasedDelivery) { // Add JID of all affiliates that are susbcribed to the node for (NodeAffiliate affiliate : affiliates) { if (!affiliate.getSubscriptions().isEmpty()) { affiliatesJID.add(affiliate.getJID()); } } } else { // Add JID of those affiliates that have a subscription that only wants to be // notified based on the subscriber presence for (NodeAffiliate affiliate : affiliates) { Collection<NodeSubscription> subscriptions = affiliate.getSubscriptions(); for (NodeSubscription subscription : subscriptions) { if (!subscription.getPresenceStates().isEmpty()) { affiliatesJID.add(affiliate.getJID()); break; } } } } return affiliatesJID; } /** * Returns true if the last published item is going to be sent to new subscribers. * * @return true if the last published item is going to be sent to new subscribers. */ public boolean isSendItemSubscribe() { return false; } /** * Returns the publisher model that specifies who is allowed to publish items to the node. * * @return the publisher model that specifies who is allowed to publish items to the node. */ public PublisherModel getPublisherModel() { return publisherModel; } /** * Returns true if users are allowed to subscribe and unsubscribe. * * @return true if users are allowed to subscribe and unsubscribe. */ public boolean isSubscriptionEnabled() { return subscriptionEnabled; } /** * Returns true if new subscriptions should be configured to be active. Inactive * subscriptions will not get event notifications. However, subscribers will be * notified when a node is deleted no matter the subscription status. * * @return true if new subscriptions should be configured to be active. */ public boolean isSubscriptionConfigurationRequired() { return subscriptionConfigurationRequired; } /** * Returns the access model that specifies who is allowed to subscribe and retrieve items. * * @return the access model that specifies who is allowed to subscribe and retrieve items. */ public AccessModel getAccessModel() { return accessModel; } /** * Returns the roster group(s) allowed to subscribe and retrieve items. This information * is going to be used only when using the * {@link org.jivesoftware.openfire.pubsub.models.RosterAccess} access model. * * @return the roster group(s) allowed to subscribe and retrieve items. */ public Collection<String> getRosterGroupsAllowed() { return Collections.unmodifiableCollection(rosterGroupsAllowed); } /** * Adds a new roster group that is allowed to subscribe and retrieve items. * The new roster group is not going to be added to the database. Instead it is just * kept in memory. * * @param groupName the new roster group that is allowed to subscribe and retrieve items. */ void addAllowedRosterGroup(String groupName) { rosterGroupsAllowed.add(groupName); } public Collection<JID> getReplyRooms() { return Collections.unmodifiableCollection(replyRooms); } void addReplyRoom(JID roomJID) { replyRooms.add(roomJID); } public Collection<JID> getReplyTo() { return Collections.unmodifiableCollection(replyTo); } void addReplyTo(JID entity) { replyTo.add(entity); } /** * Returns the type of payload data to be provided at the node. Usually specified by the * namespace of the payload (if any).
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -