Source Code Cross Referenced for DefaultNodeConfiguration.java in  » Net » openfire » org » jivesoftware » openfire » pubsub » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Net » openfire » org.jivesoftware.openfire.pubsub 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * $RCSfile: $
003:         * $Revision: $
004:         * $Date: $
005:         *
006:         * Copyright (C) 2006 Jive Software. All rights reserved.
007:         *
008:         * This software is published under the terms of the GNU Public License (GPL),
009:         * a copy of which is included in this distribution.
010:         */package org.jivesoftware.openfire.pubsub;
011:
012:        import org.jivesoftware.util.LocaleUtils;
013:        import org.jivesoftware.openfire.pubsub.models.AccessModel;
014:        import org.jivesoftware.openfire.pubsub.models.PublisherModel;
015:        import org.xmpp.forms.DataForm;
016:        import org.xmpp.forms.FormField;
017:
018:        /**
019:         * A DefaultNodeConfiguration keeps the default configuration values for leaf or collection
020:         * nodes of a particular publish-subscribe service. New nodes created for the service 
021:         * will be initialized with the values defined in the default configuration.
022:         *
023:         * @author Matt Tucker
024:         */
025:        public class DefaultNodeConfiguration {
026:
027:            /**
028:             * Flag indicating whether this default configutation belongs to a leaf node or not.
029:             */
030:            private boolean leaf;
031:            /**
032:             * Flag that indicates whether to deliver payloads with event notifications.
033:             */
034:            private boolean deliverPayloads;
035:            /**
036:             * The maximum payload size in bytes.
037:             */
038:            private int maxPayloadSize;
039:            /**
040:             * Flag that indicates whether to persist items to storage. Note that when the
041:             * variable is false then the last published item is the only items being saved
042:             * to the backend storage.
043:             */
044:            private boolean persistPublishedItems;
045:            /**
046:             * Maximum number of published items to persist. Note that all nodes are going to persist
047:             * their published items. The only difference is the number of the last published items
048:             * to be persisted. Even nodes that are configured to not use persitent items are going
049:             * to save the last published item.
050:             */
051:            private int maxPublishedItems;
052:            /**
053:             * Flag that indicates whether to notify subscribers when the node configuration changes.
054:             */
055:            private boolean notifyConfigChanges;
056:            /**
057:             * Flag that indicates whether to notify subscribers when the node is deleted.
058:             */
059:            private boolean notifyDelete;
060:            /**
061:             * Flag that indicates whether to notify subscribers when items are removed from the node.
062:             */
063:            private boolean notifyRetract;
064:            /**
065:             * Flag that indicates whether to deliver notifications to available users only.
066:             */
067:            private boolean presenceBasedDelivery;
068:            /**
069:             * Flag that indicates whether to send items to new subscribers.
070:             */
071:            private boolean sendItemSubscribe = false;
072:            /**
073:             * Publisher model that specifies who is allowed to publish items to the node.
074:             */
075:            private PublisherModel publisherModel = PublisherModel.open;
076:            /**
077:             * Flag that indicates that subscribing and unsubscribing are enabled.
078:             */
079:            private boolean subscriptionEnabled;
080:            /**
081:             * Access model that specifies who is allowed to subscribe and retrieve items.
082:             */
083:            private AccessModel accessModel = AccessModel.open;
084:            /**
085:             * The default language of the node.
086:             */
087:            private String language = "";
088:            /**
089:             * Policy that defines whether owners or publisher should receive replies to items.
090:             */
091:            private Node.ItemReplyPolicy replyPolicy = Node.ItemReplyPolicy.owner;
092:            /**
093:             * Policy that defines who may associate leaf nodes with a collection.
094:             */
095:            private CollectionNode.LeafNodeAssociationPolicy associationPolicy = CollectionNode.LeafNodeAssociationPolicy.all;
096:            /**
097:             * Max number of leaf nodes that this collection node might have. A value of -1 means
098:             * that there is no limit.
099:             */
100:            private int maxLeafNodes = -1;
101:
102:            public DefaultNodeConfiguration(boolean isLeafType) {
103:                this .leaf = isLeafType;
104:            }
105:
106:            /**
107:             * Returns true if this default configutation belongs to a leaf node.
108:             *
109:             * @return true if this default configutation belongs to a leaf node.
110:             */
111:            public boolean isLeaf() {
112:                return leaf;
113:            }
114:
115:            /**
116:             * Returns true if payloads are going to be delivered with event notifications.
117:             *
118:             * @return true if payloads are going to be delivered with event notifications.
119:             */
120:            public boolean isDeliverPayloads() {
121:                return deliverPayloads;
122:            }
123:
124:            /**
125:             * Returns the maximum payload size in bytes.
126:             *
127:             * @return the maximum payload size in bytes.
128:             */
129:            public int getMaxPayloadSize() {
130:                return maxPayloadSize;
131:            }
132:
133:            /**
134:             * Returns true if items are going to be persisted in a storage. Note that when the
135:             * variable is false then the last published item is the only items being saved
136:             * to the backend storage.
137:             *
138:             * @return true if items are going to be persisted in a storage.
139:             */
140:            public boolean isPersistPublishedItems() {
141:                return persistPublishedItems;
142:            }
143:
144:            /**
145:             * Returns the maximum number of published items to persist. Note that all nodes are going
146:             * to persist their published items. The only difference is the number of the last published
147:             * items to be persisted. Even nodes that are configured to not use persitent items are going
148:             * to save the last published item.
149:             *
150:             * @return the maximum number of published items to persist.
151:             */
152:            public int getMaxPublishedItems() {
153:                return maxPublishedItems;
154:            }
155:
156:            /**
157:             * Returns true if subscribers are going to be notified when node configuration changes.
158:             *
159:             * @return true if subscribers are going to be notified when node configuration changes.
160:             */
161:            public boolean isNotifyConfigChanges() {
162:                return notifyConfigChanges;
163:            }
164:
165:            /**
166:             * Returns true if subscribers are going to be notified when node is deleted.
167:             *
168:             * @return true if subscribers are going to be notified when node is deleted.
169:             */
170:            public boolean isNotifyDelete() {
171:                return notifyDelete;
172:            }
173:
174:            /**
175:             * Returns true if subscribers are going to be notified when items are removed from the node.
176:             *
177:             * @return true if subscribers are going to be notified when items are removed from the node.
178:             */
179:            public boolean isNotifyRetract() {
180:                return notifyRetract;
181:            }
182:
183:            /**
184:             * Returns true if notifications are going to be delivered only to available users.
185:             *
186:             * @return true if notifications are going to be delivered only to available users.
187:             */
188:            public boolean isPresenceBasedDelivery() {
189:                return presenceBasedDelivery;
190:            }
191:
192:            /**
193:             * Returns true if new subscribers are going to receive new items once subscribed.
194:             *
195:             * @return true if new subscribers are going to receive new items once subscribed.
196:             */
197:            public boolean isSendItemSubscribe() {
198:                return sendItemSubscribe;
199:            }
200:
201:            /**
202:             * Returnes the publisher model that specifies who is allowed to publish items to the node.
203:             *
204:             * @return the publisher model that specifies who is allowed to publish items to the node.
205:             */
206:            public PublisherModel getPublisherModel() {
207:                return publisherModel;
208:            }
209:
210:            /**
211:             * Returns true if subscribing and unsubscribing are enabled.
212:             *
213:             * @return true if subscribing and unsubscribing are enabled.
214:             */
215:            public boolean isSubscriptionEnabled() {
216:                return subscriptionEnabled;
217:            }
218:
219:            /**
220:             * Returns the access model that specifies who is allowed to subscribe and retrieve items.
221:             *
222:             * @return the access model that specifies who is allowed to subscribe and retrieve items.
223:             */
224:            public AccessModel getAccessModel() {
225:                return accessModel;
226:            }
227:
228:            /**
229:             * Returns the default language of the node.
230:             *
231:             * @return the default language of the node.
232:             */
233:            public String getLanguage() {
234:                return language;
235:            }
236:
237:            /**
238:             * Returns the policy that defines whether owners or publisher should receive
239:             * replies to items.
240:             *
241:             * @return the policy that defines whether owners or publisher should receive 
242:             *        replies to items.
243:             */
244:            public Node.ItemReplyPolicy getReplyPolicy() {
245:                return replyPolicy;
246:            }
247:
248:            /**
249:             * Returns the policy that defines who may associate leaf nodes with a collection.
250:             *
251:             * @return the policy that defines who may associate leaf nodes with a collection.
252:             */
253:            public CollectionNode.LeafNodeAssociationPolicy getAssociationPolicy() {
254:                return associationPolicy;
255:            }
256:
257:            /**
258:             * Returns the max number of leaf nodes that this collection node might have. A value of
259:             * -1 means that there is no limit.
260:             *
261:             * @return the max number of leaf nodes that this collection node might have.
262:             */
263:            public int getMaxLeafNodes() {
264:                return maxLeafNodes;
265:            }
266:
267:            /**
268:             * Sets if payloads are going to be delivered with event notifications.
269:             *
270:             * @param deliverPayloads true if payloads are going to be delivered with event notifications.
271:             */
272:            public void setDeliverPayloads(boolean deliverPayloads) {
273:                this .deliverPayloads = deliverPayloads;
274:            }
275:
276:            /**
277:             * Sets the maximum payload size in bytes.
278:             *
279:             * @param maxPayloadSize the maximum payload size in bytes.
280:             */
281:            public void setMaxPayloadSize(int maxPayloadSize) {
282:                this .maxPayloadSize = maxPayloadSize;
283:            }
284:
285:            /**
286:             * Sets if items are going to be persisted in a storage. Note that when the
287:             * variable is false then the last published item is the only items being saved
288:             * to the backend storage.
289:             *
290:             * @param persistPublishedItems true if items are going to be persisted in a storage.
291:             */
292:            public void setPersistPublishedItems(boolean persistPublishedItems) {
293:                this .persistPublishedItems = persistPublishedItems;
294:            }
295:
296:            /**
297:             * Sets the maximum number of published items to persist. Note that all nodes are going
298:             * to persist their published items. The only difference is the number of the last published
299:             * items to be persisted. Even nodes that are configured to not use persitent items are going
300:             * to save the last published item.
301:             *
302:             * @param maxPublishedItems the maximum number of published items to persist.
303:             */
304:            public void setMaxPublishedItems(int maxPublishedItems) {
305:                this .maxPublishedItems = maxPublishedItems;
306:            }
307:
308:            /**
309:             * Sets if subscribers are going to be notified when node configuration changes.
310:             *
311:             * @param notifyConfigChanges true if subscribers are going to be notified when node
312:             *        configuration changes.
313:             */
314:            public void setNotifyConfigChanges(boolean notifyConfigChanges) {
315:                this .notifyConfigChanges = notifyConfigChanges;
316:            }
317:
318:            /**
319:             * Sets if subscribers are going to be notified when node is deleted.
320:             *
321:             * @param notifyDelete true if subscribers are going to be notified when node is deleted.
322:             */
323:            public void setNotifyDelete(boolean notifyDelete) {
324:                this .notifyDelete = notifyDelete;
325:            }
326:
327:            /**
328:             * Sets if subscribers are going to be notified when items are removed from the node.
329:             *
330:             * @param notifyRetract true if subscribers are going to be notified when items are removed
331:             *        from the node.
332:             */
333:            public void setNotifyRetract(boolean notifyRetract) {
334:                this .notifyRetract = notifyRetract;
335:            }
336:
337:            /**
338:             * Sets if notifications are going to be delivered only to available users.
339:             *
340:             * @param presenceBasedDelivery true if notifications are going to be delivered only to
341:             *        available users.
342:             */
343:            public void setPresenceBasedDelivery(boolean presenceBasedDelivery) {
344:                this .presenceBasedDelivery = presenceBasedDelivery;
345:            }
346:
347:            /**
348:             * Sets if new subscribers are going to receive new items once subscribed.
349:             *
350:             * @param sendItemSubscribe true if new subscribers are going to receive new items
351:             *        once subscribed.
352:             */
353:            public void setSendItemSubscribe(boolean sendItemSubscribe) {
354:                this .sendItemSubscribe = sendItemSubscribe;
355:            }
356:
357:            /**
358:             * Sets the publisher model that specifies who is allowed to publish items to the node.
359:             *
360:             * @param publisherModel the publisher model that specifies who is allowed to publish
361:             *        items to the node.
362:             */
363:            public void setPublisherModel(PublisherModel publisherModel) {
364:                this .publisherModel = publisherModel;
365:            }
366:
367:            /**
368:             * Sets if subscribing and unsubscribing are enabled.
369:             *
370:             * @param subscriptionEnabled true if subscribing and unsubscribing are enabled.
371:             */
372:            public void setSubscriptionEnabled(boolean subscriptionEnabled) {
373:                this .subscriptionEnabled = subscriptionEnabled;
374:            }
375:
376:            /**
377:             * Sets the access model that specifies who is allowed to subscribe and retrieve items.
378:             *
379:             * @param accessModel the access model that specifies who is allowed to subscribe and
380:             *        retrieve items.
381:             */
382:            public void setAccessModel(AccessModel accessModel) {
383:                this .accessModel = accessModel;
384:            }
385:
386:            /**
387:             * Sets the default language of the node.
388:             *
389:             * @param language the default language of the node.
390:             */
391:            public void setLanguage(String language) {
392:                this .language = language;
393:            }
394:
395:            /**
396:             * Sets the policy that defines whether owners or publisher should receive replies to items.
397:             *
398:             * @param replyPolicy the policy that defines whether owners or publisher should receive
399:             *        replies to items.
400:             */
401:            public void setReplyPolicy(Node.ItemReplyPolicy replyPolicy) {
402:                this .replyPolicy = replyPolicy;
403:            }
404:
405:            /**
406:             * Sets the policy that defines who may associate leaf nodes with a collection.
407:             *
408:             * @param associationPolicy the policy that defines who may associate leaf nodes
409:             *        with a collection.
410:             */
411:            public void setAssociationPolicy(
412:                    CollectionNode.LeafNodeAssociationPolicy associationPolicy) {
413:                this .associationPolicy = associationPolicy;
414:            }
415:
416:            /**
417:             * Sets the max number of leaf nodes that this collection node might have. A value of
418:             * -1 means that there is no limit.
419:             *
420:             * @param maxLeafNodes the max number of leaf nodes that this collection node might have.
421:             */
422:            public void setMaxLeafNodes(int maxLeafNodes) {
423:                this .maxLeafNodes = maxLeafNodes;
424:            }
425:
426:            public DataForm getConfigurationForm() {
427:                DataForm form = new DataForm(DataForm.Type.form);
428:                form.setTitle(LocaleUtils
429:                        .getLocalizedString("pubsub.form.default.title"));
430:                form.addInstruction(LocaleUtils
431:                        .getLocalizedString("pubsub.form.default.instruction"));
432:                // Add the form fields and configure them for edition
433:
434:                FormField formField = form.addField();
435:                formField.setVariable("FORM_TYPE");
436:                formField.setType(FormField.Type.hidden);
437:                formField
438:                        .addValue("http://jabber.org/protocol/pubsub#node_config");
439:
440:                formField = form.addField();
441:                formField.setVariable("pubsub#subscribe");
442:                formField.setType(FormField.Type.boolean_type);
443:                formField.setLabel(LocaleUtils
444:                        .getLocalizedString("pubsub.form.conf.subscribe"));
445:                formField.addValue(subscriptionEnabled);
446:
447:                formField = form.addField();
448:                formField.setVariable("pubsub#deliver_payloads");
449:                formField.setType(FormField.Type.boolean_type);
450:                formField
451:                        .setLabel(LocaleUtils
452:                                .getLocalizedString("pubsub.form.conf.deliver_payloads"));
453:                formField.addValue(deliverPayloads);
454:
455:                formField = form.addField();
456:                formField.setVariable("pubsub#notify_config");
457:                formField.setType(FormField.Type.boolean_type);
458:                formField.setLabel(LocaleUtils
459:                        .getLocalizedString("pubsub.form.conf.notify_config"));
460:                formField.addValue(notifyConfigChanges);
461:
462:                formField = form.addField();
463:                formField.setVariable("pubsub#notify_delete");
464:                formField.setType(FormField.Type.boolean_type);
465:                formField.setLabel(LocaleUtils
466:                        .getLocalizedString("pubsub.form.conf.notify_delete"));
467:                formField.addValue(notifyDelete);
468:
469:                formField = form.addField();
470:                formField.setVariable("pubsub#notify_retract");
471:                formField.setType(FormField.Type.boolean_type);
472:                formField.setLabel(LocaleUtils
473:                        .getLocalizedString("pubsub.form.conf.notify_retract"));
474:                formField.addValue(notifyRetract);
475:
476:                formField = form.addField();
477:                formField.setVariable("pubsub#presence_based_delivery");
478:                formField.setType(FormField.Type.boolean_type);
479:                formField.setLabel(LocaleUtils
480:                        .getLocalizedString("pubsub.form.conf.presence_based"));
481:                formField.addValue(presenceBasedDelivery);
482:
483:                if (leaf) {
484:                    formField = form.addField();
485:                    formField.setVariable("pubsub#send_item_subscribe");
486:                    formField.setType(FormField.Type.boolean_type);
487:                    formField
488:                            .setLabel(LocaleUtils
489:                                    .getLocalizedString("pubsub.form.conf.send_item_subscribe"));
490:                    formField.addValue(sendItemSubscribe);
491:
492:                    formField = form.addField();
493:                    formField.setVariable("pubsub#persist_items");
494:                    formField.setType(FormField.Type.boolean_type);
495:                    formField
496:                            .setLabel(LocaleUtils
497:                                    .getLocalizedString("pubsub.form.conf.persist_items"));
498:                    formField.addValue(persistPublishedItems);
499:
500:                    formField = form.addField();
501:                    formField.setVariable("pubsub#max_items");
502:                    formField.setType(FormField.Type.text_single);
503:                    formField.setLabel(LocaleUtils
504:                            .getLocalizedString("pubsub.form.conf.max_items"));
505:                    formField.addValue(maxPublishedItems);
506:
507:                    formField = form.addField();
508:                    formField.setVariable("pubsub#max_payload_size");
509:                    formField.setType(FormField.Type.text_single);
510:                    formField
511:                            .setLabel(LocaleUtils
512:                                    .getLocalizedString("pubsub.form.conf.max_payload_size"));
513:                    formField.addValue(maxPayloadSize);
514:                }
515:
516:                formField = form.addField();
517:                formField.setVariable("pubsub#access_model");
518:                formField.setType(FormField.Type.list_single);
519:                formField.setLabel(LocaleUtils
520:                        .getLocalizedString("pubsub.form.conf.access_model"));
521:                formField.addOption(null, AccessModel.authorize.getName());
522:                formField.addOption(null, AccessModel.open.getName());
523:                formField.addOption(null, AccessModel.presence.getName());
524:                formField.addOption(null, AccessModel.roster.getName());
525:                formField.addOption(null, AccessModel.whitelist.getName());
526:                formField.addValue(accessModel.getName());
527:
528:                formField = form.addField();
529:                formField.setVariable("pubsub#publish_model");
530:                formField.setType(FormField.Type.list_single);
531:                formField.setLabel(LocaleUtils
532:                        .getLocalizedString("pubsub.form.conf.publish_model"));
533:                formField.addOption(null, PublisherModel.publishers.getName());
534:                formField.addOption(null, PublisherModel.subscribers.getName());
535:                formField.addOption(null, PublisherModel.open.getName());
536:                formField.addValue(publisherModel.getName());
537:
538:                formField = form.addField();
539:                formField.setVariable("pubsub#language");
540:                formField.setType(FormField.Type.text_single);
541:                formField.setLabel(LocaleUtils
542:                        .getLocalizedString("pubsub.form.conf.language"));
543:                formField.addValue(language);
544:
545:                formField = form.addField();
546:                formField.setVariable("pubsub#itemreply");
547:                formField.setType(FormField.Type.list_single);
548:                formField.setLabel(LocaleUtils
549:                        .getLocalizedString("pubsub.form.conf.itemreply"));
550:                if (replyPolicy != null) {
551:                    formField.addValue(replyPolicy.name());
552:                }
553:
554:                if (!leaf) {
555:                    formField = form.addField();
556:                    formField
557:                            .setVariable("pubsub#leaf_node_association_policy");
558:                    formField.setType(FormField.Type.list_single);
559:                    formField
560:                            .setLabel(LocaleUtils
561:                                    .getLocalizedString("pubsub.form.conf.leaf_node_association"));
562:                    formField
563:                            .addOption(
564:                                    null,
565:                                    CollectionNode.LeafNodeAssociationPolicy.all
566:                                            .name());
567:                    formField.addOption(null,
568:                            CollectionNode.LeafNodeAssociationPolicy.owners
569:                                    .name());
570:                    formField.addOption(null,
571:                            CollectionNode.LeafNodeAssociationPolicy.whitelist
572:                                    .name());
573:                    formField.addValue(associationPolicy.name());
574:
575:                    formField = form.addField();
576:                    formField.setVariable("pubsub#leaf_nodes_max");
577:                    formField.setType(FormField.Type.text_single);
578:                    formField
579:                            .setLabel(LocaleUtils
580:                                    .getLocalizedString("pubsub.form.conf.leaf_nodes_max"));
581:                    formField.addValue(maxLeafNodes);
582:                }
583:
584:                return form;
585:            }
586:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.