mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-22 20:12:07 +01:00
Notification type for pubsub node config
This commit is contained in:
parent
ea7be844de
commit
d5aaf8fdab
4 changed files with 70 additions and 1 deletions
|
@ -406,6 +406,30 @@ public class ConfigureForm extends Form {
|
||||||
setAnswer(ConfigureNodeFields.notify_retract.getFieldName(), notify);
|
setAnswer(ConfigureNodeFields.notify_retract.getFieldName(), notify);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines the type of notifications which are sent.
|
||||||
|
*
|
||||||
|
* @return NotificationType for the node configuration
|
||||||
|
* @since 4.3
|
||||||
|
*/
|
||||||
|
public NotificationType getNotificationType() {
|
||||||
|
String value = getFieldValue(ConfigureNodeFields.notification_type);
|
||||||
|
if (value == null)
|
||||||
|
return null;
|
||||||
|
return NotificationType.valueOf(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the NotificationType for the node.
|
||||||
|
*
|
||||||
|
* @param notificationType The enum representing the possible options
|
||||||
|
* @since 4.3
|
||||||
|
*/
|
||||||
|
public void setNotificationType(NotificationType notificationType) {
|
||||||
|
addField(ConfigureNodeFields.notification_type, FormField.Type.list_single);
|
||||||
|
setAnswer(ConfigureNodeFields.notification_type.getFieldName(), getListSingle(notificationType.toString()));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines whether items should be persisted in the node.
|
* Determines whether items should be persisted in the node.
|
||||||
*
|
*
|
||||||
|
|
|
@ -147,6 +147,13 @@ public enum ConfigureNodeFields {
|
||||||
*/
|
*/
|
||||||
notify_retract,
|
notify_retract,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type of notification that the nodes sends.
|
||||||
|
*
|
||||||
|
* <p><b>Value: {@link NotificationType}</b></p>
|
||||||
|
*/
|
||||||
|
notification_type,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether to persist items to storage. This is required to have. multiple
|
* Whether to persist items to storage. This is required to have. multiple
|
||||||
* items in the node.
|
* items in the node.
|
||||||
|
@ -205,7 +212,7 @@ public enum ConfigureNodeFields {
|
||||||
title,
|
title,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type of node data, ussually specified by the namespace
|
* The type of node data, usually specified by the namespace
|
||||||
* of the payload(if any);MAY be a list-single rather than a
|
* of the payload(if any);MAY be a list-single rather than a
|
||||||
* text single.
|
* text single.
|
||||||
*
|
*
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright the original author or authors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.jivesoftware.smackx.pubsub;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specify the delivery style for event notifications. Denotes possible values
|
||||||
|
* for {@link ConfigureForm#setNotificationType(NotificationType)}.
|
||||||
|
*
|
||||||
|
* @author Timothy Pitt
|
||||||
|
*/
|
||||||
|
public enum NotificationType {
|
||||||
|
normal,
|
||||||
|
headline
|
||||||
|
}
|
|
@ -97,4 +97,14 @@ public class ConfigureFormTest extends InitExtensions {
|
||||||
|
|
||||||
node.getNodeConfiguration();
|
node.getNodeConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void checkNotificationType() {
|
||||||
|
ConfigureForm form = new ConfigureForm(DataForm.Type.submit);
|
||||||
|
form.setNotificationType(NotificationType.normal);
|
||||||
|
assertEquals(NotificationType.normal, form.getNotificationType());
|
||||||
|
form.setNotificationType(NotificationType.headline);
|
||||||
|
assertEquals(NotificationType.headline, form.getNotificationType());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue