From 2ffe30332415484d218e71d0b4a9dde1384ab57e Mon Sep 17 00:00:00 2001 From: Brian Clements Date: Mon, 16 Jun 2014 14:57:29 -0500 Subject: [PATCH] Omaha #3288 collaboration feed venue config comes from server Change-Id: I5bc747507e44cc31093d7a7f470a263d0cf116c0 Former-commit-id: f38f9fae51df7cd2fc76b7ea8dd0c4ee67693645 [formerly 8205f7cd56bca4ce6d540edb636979c9d9ec076c] [formerly e93c5642291bd6c8ebb4fc3528e55bf08184500d [formerly b6a2bf0ae4a7f723a181358a86b9d8a9dbc790df]] [formerly 84e3f967d92ba0bb524a7992a57ed01c5771ea2a [formerly b6a2bf0ae4a7f723a181358a86b9d8a9dbc790df [formerly baab2ea12e1117446295ae60bc06228eb6139895]]] Former-commit-id: 84e3f967d92ba0bb524a7992a57ed01c5771ea2a Former-commit-id: d0ae674bb4714971796f2565a9a4ddf679e2c503 [formerly 5436efb886bb32ec1386b487d0e9d4327b7a1476] Former-commit-id: 4dc81aabfa1f81650d13f0f44aef4766d1643414 --- .../connection/CollaborationConnection.java | 26 ++- .../provider/session/CreateSessionData.java | 27 ++- .../session/FeedVenueConfigManager.java | 120 ++++++++++++ .../session/SharedDisplaySession.java | 6 +- .../comm/provider/session/VenueSession.java | 77 ++++---- .../comm/provider/user/VenueId.java | 30 +++ .../META-INF/MANIFEST.MF | 5 +- .../collaboration/ui/CreateSessionDialog.java | 10 +- .../uf/viz/collaboration/ui/InviteDialog.java | 5 +- .../ui/actions/DisplayFeedAction.java | 37 +++- .../uf/common/xmpp/iq/FeedVenueConfig.java | 181 ++++++++++++++++++ .../xmpp/iq/FeedVenueConfigProvider.java | 105 ++++++++++ .../HttpConfigurationPlugin.java | 7 +- .../iq/FeedVenueConfigHandler.java | 168 ++++++++++++++++ .../plugin.xml | 5 + .../web/feed-venue-admin.jsp | 121 ++++++++++++ 16 files changed, 851 insertions(+), 79 deletions(-) create mode 100644 cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/session/FeedVenueConfigManager.java create mode 100644 edexOsgi/com.raytheon.uf.common.xmpp/src/com/raytheon/uf/common/xmpp/iq/FeedVenueConfig.java create mode 100644 edexOsgi/com.raytheon.uf.common.xmpp/src/com/raytheon/uf/common/xmpp/iq/FeedVenueConfigProvider.java create mode 100644 javaUtilities/com.raytheon.openfire.plugin.configuration.collaboration/java/com/raytheon/openfire/plugin/configuration/collaboration/iq/FeedVenueConfigHandler.java create mode 100644 javaUtilities/com.raytheon.openfire.plugin.configuration.collaboration/web/feed-venue-admin.jsp diff --git a/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/connection/CollaborationConnection.java b/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/connection/CollaborationConnection.java index 02b491aa50..5e71f11fef 100644 --- a/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/connection/CollaborationConnection.java +++ b/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/connection/CollaborationConnection.java @@ -48,6 +48,8 @@ import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.xmpp.PacketConstants; import com.raytheon.uf.common.xmpp.iq.AuthInfo; import com.raytheon.uf.common.xmpp.iq.AuthInfoProvider; +import com.raytheon.uf.common.xmpp.iq.FeedVenueConfig; +import com.raytheon.uf.common.xmpp.iq.FeedVenueConfigProvider; import com.raytheon.uf.viz.collaboration.comm.Activator; import com.raytheon.uf.viz.collaboration.comm.identity.CollaborationException; import com.raytheon.uf.viz.collaboration.comm.identity.IAccountManager; @@ -62,12 +64,14 @@ import com.raytheon.uf.viz.collaboration.comm.provider.account.AccountManager; import com.raytheon.uf.viz.collaboration.comm.provider.account.ClientAuthManager; import com.raytheon.uf.viz.collaboration.comm.provider.event.VenueUserEvent; import com.raytheon.uf.viz.collaboration.comm.provider.session.CreateSessionData; +import com.raytheon.uf.viz.collaboration.comm.provider.session.FeedVenueConfigManager; import com.raytheon.uf.viz.collaboration.comm.provider.session.PeerToPeerChat; import com.raytheon.uf.viz.collaboration.comm.provider.session.SharedDisplaySession; import com.raytheon.uf.viz.collaboration.comm.provider.session.VenueSession; import com.raytheon.uf.viz.collaboration.comm.provider.user.ContactsManager; import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId; import com.raytheon.uf.viz.collaboration.comm.provider.user.UserSearch; +import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueId; import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueParticipant; /** @@ -121,6 +125,7 @@ import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueParticipant; * Apr 23, 2014 2822 bclement added resource name and getCollaborationVersion() * May 09, 2014 3107 bclement added ability for packet timeout to be set via system properties * May 19, 2014 3180 bclement added getJoinedVenueSessions() + * Jun 16, 2014 3288 bclement feed venue configuration changes * * * @@ -137,6 +142,8 @@ public class CollaborationConnection implements IEventPublisher { PacketConstants.COLLAB_XMLNS, new SessionPayloadProvider()); pm.addIQProvider(PacketConstants.QUERY_ELEMENT_NAME, AuthInfo.AUTH_QUERY_XMLNS, new AuthInfoProvider()); + pm.addIQProvider(PacketConstants.QUERY_ELEMENT_NAME, + FeedVenueConfig.FEED_QUERY_XMLNS, new FeedVenueConfigProvider()); /* * smack doesn't support some of the OWNER operations such as getting * all subscriptions on a node. PubSubOperations creates the request @@ -437,6 +444,7 @@ public class CollaborationConnection implements IEventPublisher { } connection = null; } + FeedVenueConfigManager.reset(); PeerToPeerCommHelper.reset(); synchronized (CollaborationConnection.class) { if (this == instance) { @@ -483,9 +491,9 @@ public class CollaborationConnection implements IEventPublisher { SharedDisplayVenueInvite sdvInvite = (SharedDisplayVenueInvite) invitation .getInvite(); String sessionId = invitation.getInvite().getSessionId(); - String venueName = invitation.getRoomId().getName(); + VenueId venueId = invitation.getRoomId(); SharedDisplaySession rval = new SharedDisplaySession(eventBus, this, - venueName, handle, sessionId); + venueId, handle, sessionId); setupCollaborationVenue(rval, sdvInvite.getSessionLeader(), sdvInvite.getDataProvider()); return rval; @@ -526,12 +534,12 @@ public class CollaborationConnection implements IEventPublisher { * server. The session should be unregistered when no longer active using * {@link CollaborationConnection#removeSession(ISession)} * - * @param venueName + * @param venueId * @param handle * @return */ - public VenueSession createTextOnlyVenue(String venueName, String handle) { - return createTextOnlyVenue(new CreateSessionData(venueName, handle)); + public VenueSession createTextOnlyVenue(VenueId venueId, String handle) { + return createTextOnlyVenue(new CreateSessionData(venueId, handle)); } /** @@ -551,14 +559,13 @@ public class CollaborationConnection implements IEventPublisher { /** * Check if venue exists on server * + * @param subdomain * @param venueName * @return false on error */ - public boolean venueExistsOnServer(String venueName) { - String roomId = VenueSession.getRoomId(connection.getServiceName(), - venueName); + public boolean venueExistsOnServer(String subdomain, String venueName) { try { - return VenueSession.roomExistsOnServer(connection, roomId); + return VenueSession.roomExistsOnServer(subdomain, venueName); } catch (XMPPException e) { statusHandler.error("Unable to check for room on server", e); return false; @@ -674,4 +681,5 @@ public class CollaborationConnection implements IEventPublisher { protected static IUFStatusHandler getStatusHandler() { return statusHandler; } + } diff --git a/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/session/CreateSessionData.java b/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/session/CreateSessionData.java index f2668ef621..cb02fe4716 100644 --- a/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/session/CreateSessionData.java +++ b/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/session/CreateSessionData.java @@ -19,6 +19,8 @@ **/ package com.raytheon.uf.viz.collaboration.comm.provider.session; +import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueId; + /** * Configuration used to create a new session * @@ -32,6 +34,7 @@ package com.raytheon.uf.viz.collaboration.comm.provider.session; * Jan 30, 2014 2698 bclement moved to collaboration.comm project from collaboration.ui * added handle * Mar 10, 2014 2848 bclement added constructor with required fields + * Jun 16, 2014 3288 bclement changed String venueName to VenueId venueId * * * @@ -39,7 +42,7 @@ package com.raytheon.uf.viz.collaboration.comm.provider.session; * @version 1.0 */ public class CreateSessionData { - private String name; + private VenueId venueId; private String handle; @@ -54,13 +57,13 @@ public class CreateSessionData { private String sessionId; /** - * @param name - * name of session venue + * @param id + * id of session venue * @param handle * name user is known by in venue */ - public CreateSessionData(String name, String handle) { - this.name = name; + public CreateSessionData(VenueId venueId, String handle) { + this.venueId = venueId; this.handle = handle; this.collaborationSession = false; } @@ -73,12 +76,18 @@ public class CreateSessionData { this.sessionId = sessionId; } - public String getName() { - return name; + /** + * @return + */ + public VenueId getVenueId() { + return venueId; } - public void setName(String name) { - this.name = name; + /** + * @param venueId + */ + public void setVenueId(VenueId venueId) { + this.venueId = venueId; } /** diff --git a/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/session/FeedVenueConfigManager.java b/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/session/FeedVenueConfigManager.java new file mode 100644 index 0000000000..e6d8f672d2 --- /dev/null +++ b/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/session/FeedVenueConfigManager.java @@ -0,0 +1,120 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.viz.collaboration.comm.provider.session; + +import org.jivesoftware.smack.XMPPConnection; +import org.jivesoftware.smack.XMPPException; +import org.jivesoftware.smack.packet.IQ; +import org.jivesoftware.smack.packet.Packet; +import org.jivesoftware.smack.util.SyncPacketSend; + +import com.raytheon.uf.common.status.IUFStatusHandler; +import com.raytheon.uf.common.status.UFStatus; +import com.raytheon.uf.common.xmpp.BaseProvider; +import com.raytheon.uf.common.xmpp.iq.FeedVenueConfig; +import com.raytheon.uf.common.xmpp.iq.FeedVenueConfig.VenueType; +import com.raytheon.uf.viz.collaboration.comm.provider.connection.CollaborationConnection; + +/** + * Utility responsible for retrieving feed venue configuration from XMPP server + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Jun 16, 2014 3288       bclement     Initial creation
+ * 
+ * 
+ * + * @author bclement + * @version 1.0 + */ +public class FeedVenueConfigManager { + + private static final IUFStatusHandler log = UFStatus + .getHandler(FeedVenueConfigManager.class); + + private static FeedVenueConfig feedVenueConfig = null; + + private static final String FEED_VENUE_FALLBACK_SUBDOMAIN = "conference"; + + private static final String FEED_VENUE_FALLBACK_NAME = "nws-collaboration"; + + private static final VenueType FEED_VENUE_FALLBACK_TYPE = VenueType.SINGLE; + + /** + * Get feed venue configuration from server. Results from server are cached. + * + * @return defaults if configuration cannot be retrieved from server + */ + public static synchronized FeedVenueConfig getConfig(){ + FeedVenueConfig rval; + if ( feedVenueConfig == null){ + XMPPConnection conn = CollaborationConnection.getConnection() + .getXmppConnection(); + rval = new FeedVenueConfig(FEED_VENUE_FALLBACK_SUBDOMAIN, + FEED_VENUE_FALLBACK_NAME, FEED_VENUE_FALLBACK_TYPE); + if (canQueryForConfig(conn)) { + IQ query = FeedVenueConfig.createGet(); + try { + Packet reply = SyncPacketSend.getReply(conn, query); + if (reply instanceof FeedVenueConfig) { + rval = feedVenueConfig = (FeedVenueConfig) reply; + } else { + log.error("Unexpected feed venue config return type: " + + reply.getClass()); + } + } catch (XMPPException e) { + log.error("Problem querying for feed venue configuration", + e); + } + } + } else { + rval = feedVenueConfig; + } + return rval; + } + + /** + * @param conn + * @return true if server returns that it supports feed venue configuration + */ + private static boolean canQueryForConfig(XMPPConnection conn) { + boolean rval = false; + try { + rval = BaseProvider.serverSupportsFeature(conn, + FeedVenueConfig.FEED_QUERY_XMLNS); + } catch (XMPPException e) { + log.error("Unable to determine if server supports " + + "feed venue configuration queries", e); + } + return rval; + } + + /** + * reset internal state + */ + public static synchronized void reset() { + feedVenueConfig = null; + } + +} diff --git a/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/session/SharedDisplaySession.java b/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/session/SharedDisplaySession.java index 39f28a693a..ed21ada64d 100644 --- a/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/session/SharedDisplaySession.java +++ b/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/session/SharedDisplaySession.java @@ -71,6 +71,7 @@ import com.raytheon.uf.viz.collaboration.comm.provider.event.LeaderChangeEvent; import com.raytheon.uf.viz.collaboration.comm.provider.user.ContactsManager; import com.raytheon.uf.viz.collaboration.comm.provider.user.IDConverter; import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId; +import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueId; import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueParticipant; /** @@ -105,6 +106,7 @@ import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueParticipant; * Apr 29, 2014 3061 bclement added createInviteMessage() * May 09, 2014 3107 bclement default to trust transfer event when verify errors out * May 14, 2014 3061 bclement added better checks for when to send invite/session payloads + * Jun 16, 2014 3288 bclement feed venue configuration changes * * * @@ -133,9 +135,9 @@ public class SharedDisplaySession extends VenueSession implements private boolean closed = false; public SharedDisplaySession(EventBus externalBus, - CollaborationConnection manager, String venueName, String handle, + CollaborationConnection manager, VenueId venueId, String handle, String sessionId) { - super(externalBus, manager, venueName, handle, sessionId); + super(externalBus, manager, venueId, handle, sessionId); init(); } diff --git a/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/session/VenueSession.java b/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/session/VenueSession.java index 18c9a7368c..04ecaca107 100644 --- a/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/session/VenueSession.java +++ b/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/session/VenueSession.java @@ -61,6 +61,7 @@ import com.raytheon.uf.viz.collaboration.comm.provider.event.VenueUserEvent; import com.raytheon.uf.viz.collaboration.comm.provider.info.Venue; import com.raytheon.uf.viz.collaboration.comm.provider.user.IDConverter; import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId; +import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueId; import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueParticipant; /** @@ -111,6 +112,7 @@ import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueParticipant; * Apr 23, 2014 2822 bclement added formatInviteAddress() * Apr 29, 2014 3061 bclement moved invite payload to shared display session * May 09, 2014 3107 bclement removed catch from isRoomOwner() so callers know about errors + * Jun 16, 2014 3288 bclement changed String venueName to VenueId venueId, added createVenueId() * * * @@ -142,7 +144,7 @@ public class VenueSession extends BaseSession implements IVenueSession { private volatile boolean admin = false; - private String venueName; + private VenueId venueId; private volatile boolean otherParticipants = false; @@ -152,9 +154,9 @@ public class VenueSession extends BaseSession implements IVenueSession { * @param eventBus */ public VenueSession(EventBus externalBus, CollaborationConnection manager, - String venueName, String handle, String sessionId) { + VenueId venueId, String handle, String sessionId) { super(externalBus, manager, sessionId); - this.venueName = venueName; + this.venueId = venueId; this.handle = handle; } @@ -166,7 +168,7 @@ public class VenueSession extends BaseSession implements IVenueSession { public VenueSession(EventBus externalBus, CollaborationConnection manager, CreateSessionData data) { super(externalBus, manager); - this.venueName = data.getName(); + this.venueId = data.getVenueId(); this.handle = data.getHandle(); } @@ -313,34 +315,12 @@ public class VenueSession extends BaseSession implements IVenueSession { */ CollaborationConnection manager = getSessionManager(); XMPPConnection conn = manager.getXmppConnection(); - String roomId = getRoomId(conn.getServiceName(), venueName); - this.muc = new MultiUserChat(conn, roomId); + this.muc = new MultiUserChat(conn, venueId.getFQName()); this.venue = new Venue(conn, muc); createListeners(); setHandle(manager, handle); } - /** - * Construct room id from name and host - * - * @param host - * @param roomName - * @return - */ - public static String getRoomId(String host, String roomName) { - return roomName + "@" + getQualifiedHost(host); - } - - /** - * Prepend conference subdomain on host - * - * @param host - * @return - */ - public static String getQualifiedHost(String host) { - return "conference." + host; - } - /** * Create room and connect to it * @@ -352,7 +332,7 @@ public class VenueSession extends BaseSession implements IVenueSession { try { CollaborationConnection manager = getSessionManager(); XMPPConnection conn = manager.getXmppConnection(); - String roomId = getRoomId(conn.getServiceName(), data.getName()); + String roomId = venueId.getFQName(); if (roomExistsOnServer(conn, roomId)) { throw new CollaborationException("Session name already in use"); } @@ -360,7 +340,7 @@ public class VenueSession extends BaseSession implements IVenueSession { createListeners(); setHandle(manager, data.getHandle()); muc.create(this.handle); - muc.sendConfigurationForm(getRoomConfig(data.getName())); + muc.sendConfigurationForm(getRoomConfig()); muc.changeSubject(data.getSubject()); this.venue = new Venue(conn, muc); sendPresence(CollaborationConnection.getConnection().getPresence()); @@ -378,7 +358,7 @@ public class VenueSession extends BaseSession implements IVenueSession { msg = xmppError.getCondition(); } } else { - msg = "Error creating venue " + data.getName(); + msg = "Error creating venue " + data.getVenueId(); } closeMuc(); throw new CollaborationException(msg, e); @@ -403,11 +383,10 @@ public class VenueSession extends BaseSession implements IVenueSession { /** * Get filled out configuration form for room creation * - * @param roomName * @return * @throws CollaborationException */ - protected Form getRoomConfig(String roomName) throws CollaborationException { + protected Form getRoomConfig() throws CollaborationException { Form form; try { form = muc.getConfigurationForm(); @@ -425,8 +404,8 @@ public class VenueSession extends BaseSession implements IVenueSession { submitForm.setDefaultAnswer(field.getVariable()); } } - submitForm.setAnswer("muc#roomconfig_roomname", roomName); - submitForm.setAnswer("muc#roomconfig_roomdesc", roomName); + submitForm.setAnswer("muc#roomconfig_roomname", venueId.getName()); + submitForm.setAnswer("muc#roomconfig_roomdesc", venueId.getName()); submitForm.setAnswer("muc#roomconfig_publicroom", false); submitForm.setAnswer("muc#roomconfig_membersonly", true); submitForm.setAnswer("muc#roomconfig_allowinvites", true); @@ -440,11 +419,12 @@ public class VenueSession extends BaseSession implements IVenueSession { * @return true if room exists on server * @throws XMPPException */ - public static boolean roomExistsOnServer(String roomName) + public static boolean roomExistsOnServer(String subdomain, String roomName) throws XMPPException { CollaborationConnection conn = CollaborationConnection.getConnection(); XMPPConnection xmpp = conn.getXmppConnection(); - String id = getRoomId(xmpp.getServiceName(), roomName); + String id = new VenueId(subdomain, xmpp.getServiceName(), roomName) + .getFQName(); return roomExistsOnServer(conn.getXmppConnection(), id); } @@ -858,10 +838,8 @@ public class VenueSession extends BaseSession implements IVenueSession { message.setBody(moddedBody); TextMessage msg = new TextMessage(message.getFrom(), message.getBody()); - UserId account = CollaborationConnection.getConnection() - .getUser(); msg.setFrom(new VenueParticipant(this.getVenueName(), - getQualifiedHost(account.getHost()), msgHandle)); + venueId.getHost(), msgHandle)); msg.setTimeStamp(time); msg.setSubject(site); msg.setStatus(SEND_HISTORY); @@ -939,8 +917,8 @@ public class VenueSession extends BaseSession implements IVenueSession { @Override public VenueParticipant getUserID() { UserId account = getAccount(); - return new VenueParticipant(this.getVenueName(), - getQualifiedHost(account.getHost()), handle, account); + return new VenueParticipant(this.getVenueName(), venueId.getHost(), + handle, account); } /** @@ -998,7 +976,7 @@ public class VenueSession extends BaseSession implements IVenueSession { */ @Override public String getVenueName() { - return venueName; + return venueId.getName(); } /* @@ -1011,4 +989,19 @@ public class VenueSession extends BaseSession implements IVenueSession { public boolean hasOtherParticipants() { return otherParticipants; } + + /** + * Create a venue ID with the default subdomain on the currently connected + * server + * + * @param venueName + * @return + */ + public static VenueId createVenueId(String venueName) { + CollaborationConnection conn = CollaborationConnection.getConnection(); + XMPPConnection xmpp = conn.getXmppConnection(); + return new VenueId(VenueId.DEFAULT_SUBDOMAIN, xmpp.getServiceName(), + venueName); + } + } diff --git a/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/user/VenueId.java b/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/user/VenueId.java index 979553d5fa..965b17b438 100644 --- a/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/user/VenueId.java +++ b/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/user/VenueId.java @@ -34,6 +34,7 @@ import com.raytheon.uf.viz.collaboration.comm.provider.Tools; * Mar 29, 2012 jkorman Initial creation * Feb 13, 2014 2751 bclement removed resource, fixed getFQN * May 19, 2014 3180 bclement added isSameVenue() fromString() and hashcode/equals + * Jun 16, 2014 3288 bclement added constructors, default subdomain * * * @@ -43,10 +44,39 @@ import com.raytheon.uf.viz.collaboration.comm.provider.Tools; public class VenueId implements IQualifiedID { + public static final String DEFAULT_SUBDOMAIN = "conference"; + private String host; private String name; + /** + * + */ + public VenueId() { + } + + /** + * @param host + * @param name + */ + public VenueId(String host, String name) { + this.host = host; + this.name = name; + } + + /** + * subdomain and domain are combined to create the host + * + * @param subdomain + * @param domain + * @param name + */ + public VenueId(String subdomain, String domain, String name) { + this.host = subdomain + "." + domain; + this.name = name; + } + /** * @see com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID#setHost(java.lang.String) */ diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/META-INF/MANIFEST.MF b/cave/com.raytheon.uf.viz.collaboration.ui/META-INF/MANIFEST.MF index 9aa1171912..177e6fa54e 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/META-INF/MANIFEST.MF +++ b/cave/com.raytheon.uf.viz.collaboration.ui/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Collaboration UI Plugin Bundle-SymbolicName: com.raytheon.uf.viz.collaboration.ui;singleton:=true -Bundle-Version: 1.0.0.qualifier +Bundle-Version: 1.14.0 Bundle-Activator: com.raytheon.uf.viz.collaboration.ui.Activator Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Eclipse-RegisterBuddy: com.raytheon.uf.viz.core @@ -19,4 +19,5 @@ Require-Bundle: org.eclipse.ui, com.raytheon.viz.core;bundle-version="1.12.1174", org.jivesoftware.smack;bundle-version="3.3.0" Bundle-ActivationPolicy: lazy -Import-Package: com.raytheon.uf.viz.core.maps.display +Import-Package: com.raytheon.uf.common.xmpp.iq, + com.raytheon.uf.viz.core.maps.display diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/CreateSessionDialog.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/CreateSessionDialog.java index 012d4fc974..db3789faf9 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/CreateSessionDialog.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/CreateSessionDialog.java @@ -61,6 +61,7 @@ import com.raytheon.uf.viz.collaboration.comm.provider.connection.PeerToPeerComm import com.raytheon.uf.viz.collaboration.comm.provider.session.CreateSessionData; import com.raytheon.uf.viz.collaboration.comm.provider.session.SharedDisplaySession; import com.raytheon.uf.viz.collaboration.comm.provider.session.VenueSession; +import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueId; import com.raytheon.uf.viz.collaboration.display.data.SharedDisplaySessionMgr; import com.raytheon.uf.viz.collaboration.display.roles.dataprovider.ISharedEditorsManagerListener; import com.raytheon.uf.viz.collaboration.display.roles.dataprovider.SharedEditorsManager; @@ -95,6 +96,7 @@ import com.raytheon.viz.ui.editor.IMultiPaneEditor; * Mar 06, 2014 2848 bclement moved session creation logic to separate method * Apr 16, 2014 3021 bclement increased width of dialog * Apr 22, 2014 3056 bclement made room name lowercase to match xmpp server + * Jun 16, 2014 3288 bclement added call to get full venue ID for chosen name * * * @@ -471,8 +473,9 @@ public class CreateSessionDialog extends CaveSWTDialog { } if (focusField == null) { - CreateSessionData result = new CreateSessionData(name, - handle); + VenueId venueId = VenueSession.createVenueId(name); + CreateSessionData result = new CreateSessionData( + venueId, handle); result.setSubject(subject); result.setCollaborationSessioh(sharedSessionDisplay .getSelection()); @@ -574,7 +577,8 @@ public class CreateSessionDialog extends CaveSWTDialog { err = "Session name contains invalid characters."; } else { try { - if (VenueSession.roomExistsOnServer(name)) { + if (VenueSession.roomExistsOnServer(VenueId.DEFAULT_SUBDOMAIN, + name)) { err = "Session already exists. Pick a different name."; } } catch (XMPPException e) { diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/InviteDialog.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/InviteDialog.java index 0dd8aacd47..7feb3a4f97 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/InviteDialog.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/InviteDialog.java @@ -68,6 +68,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialogBase; * Mar 06, 2014 2848 bclement moved join logic to separate method * Mar 27, 2014 2632 mpduff Set the OK button as the default button. * Apr 18, 2014 2955 mpduff Make dialog non-modal. + * Jun 16, 2014 3288 bclement pass along venueId instead of just the name * * * @@ -299,7 +300,7 @@ public class InviteDialog extends CaveSWTDialogBase { */ public void join(IVenueInvitationEvent invitation, String handle) throws CollaborationException { - String venueName = invitation.getRoomId().getName(); + VenueId venueId = invitation.getRoomId(); CollaborationConnection connection = CollaborationConnection .getConnection(); // create session object @@ -314,7 +315,7 @@ public class InviteDialog extends CaveSWTDialogBase { SharedDisplayRole.PARTICIPANT); session = displaySession; } else { - session = connection.createTextOnlyVenue(venueName, handle); + session = connection.createTextOnlyVenue(venueId, handle); } try { // join session diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/actions/DisplayFeedAction.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/actions/DisplayFeedAction.java index 6fcbe99247..6e004472a5 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/actions/DisplayFeedAction.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/actions/DisplayFeedAction.java @@ -33,15 +33,19 @@ import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; +import org.jivesoftware.smack.XMPPConnection; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; +import com.raytheon.uf.common.xmpp.iq.FeedVenueConfig; import com.raytheon.uf.viz.collaboration.comm.identity.CollaborationException; import com.raytheon.uf.viz.collaboration.comm.identity.ISession; import com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession; import com.raytheon.uf.viz.collaboration.comm.provider.connection.CollaborationConnection; +import com.raytheon.uf.viz.collaboration.comm.provider.session.FeedVenueConfigManager; import com.raytheon.uf.viz.collaboration.comm.provider.session.VenueSession; +import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueId; import com.raytheon.uf.viz.collaboration.ui.Activator; import com.raytheon.uf.viz.collaboration.ui.prefs.HandleUtil; import com.raytheon.uf.viz.collaboration.ui.session.SessionFeedView; @@ -66,6 +70,7 @@ import com.raytheon.viz.ui.views.CaveWorkbenchPageManager; * Mar 06, 2014 2848 bclement removed CollaborationConnection.joinTextOnlyVenue() * Apr 10, 2014 2937 bgonzale Connect to the venue after the feed view is available * to display messages. + * Jun 16, 2014 3288 bclement feed venue configuration changes * * * @@ -78,9 +83,6 @@ public class DisplayFeedAction extends Action { private static final transient IUFStatusHandler statusHandler = UFStatus .getHandler(DisplayFeedAction.class); - // TODO make this configurable? - public static final String FEED_VENUE = "nws-collaboration"; - public DisplayFeedAction() { super("Display Feed", SWT.TOGGLE); setImageDescriptor(IconUtil.getImageDescriptor(Activator.getDefault() @@ -108,8 +110,9 @@ public class DisplayFeedAction extends Action { String sessionId = null; for (ISession session : connection.getSessions()) { if (session instanceof IVenueSession) { - if (((IVenueSession) session).getVenueName() - .equalsIgnoreCase(FEED_VENUE)) { + FeedVenueConfig config = FeedVenueConfigManager.getConfig(); + if (((IVenueSession) session).getVenueName().equalsIgnoreCase( + config.getName())) { sessionId = session.getSessionId(); } } @@ -128,7 +131,9 @@ public class DisplayFeedAction extends Action { CollaborationConnection connection = CollaborationConnection .getConnection(); String defaultHandle = HandleUtil.getDefaultHandle(); - VenueSession session = connection.createTextOnlyVenue(FEED_VENUE, + FeedVenueConfig config = FeedVenueConfigManager.getConfig(); + VenueId venueId = createVenueId(config); + VenueSession session = connection.createTextOnlyVenue(venueId, defaultHandle); try { session.configureVenue(); @@ -150,13 +155,29 @@ public class DisplayFeedAction extends Action { } } + /** + * Create venue ID using configuration and the server name of the XMPP + * server currently connected + * + * @param config + * @return + */ + private static VenueId createVenueId(FeedVenueConfig config) { + CollaborationConnection conn = CollaborationConnection.getConnection(); + XMPPConnection xmpp = conn.getXmppConnection(); + return new VenueId(config.getSubdomain(), xmpp.getServiceName(), + config.getName()); + } + @Override public void run() { CollaborationConnection connection = CollaborationConnection .getConnection(); - if (!connection.venueExistsOnServer(FEED_VENUE)) { + FeedVenueConfig config = FeedVenueConfigManager.getConfig(); + if (!connection.venueExistsOnServer(config.getSubdomain(), + config.getName())) { statusHandler.info("Feed venue doesn't exist on server: " - + FEED_VENUE); + + config.getName()); setChecked(false); return; } diff --git a/edexOsgi/com.raytheon.uf.common.xmpp/src/com/raytheon/uf/common/xmpp/iq/FeedVenueConfig.java b/edexOsgi/com.raytheon.uf.common.xmpp/src/com/raytheon/uf/common/xmpp/iq/FeedVenueConfig.java new file mode 100644 index 0000000000..d8a5838cd5 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.xmpp/src/com/raytheon/uf/common/xmpp/iq/FeedVenueConfig.java @@ -0,0 +1,181 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.common.xmpp.iq; + +import java.util.ArrayList; +import java.util.List; + +import org.jivesoftware.smack.packet.IQ; + +import com.raytheon.uf.common.xmpp.PacketConstants; +import com.raytheon.uf.common.xmpp.XmlBuilder; +import com.raytheon.uf.common.xmpp.XmlBuilder.Pair; + +/** + * Info Query packet for feed venue configuration + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Jun 16, 2014 3288       bclement     Initial creation
+ * 
+ * 
+ * + * @author bclement + * @version 1.0 + */ +public class FeedVenueConfig extends IQ { + + public static enum VenueType { + /* SINGLE is a normal room, AGGREGATE is multiple rooms viewed as one */ + SINGLE, AGGREGATE; + } + + public static final String FEED_QUERY_XMLNS = "urn:uf:viz:collaboration:iq:feed"; + + public static final String FEED_VENUE_SUBDOMAIN_ATTRIBUTE = "subdomain"; + + public static final String FEED_VENUE_NAME_ATTRIBUTE = "name"; + + public static final String FEED_VENUE_TYPE_ATTRIBUTE = "type"; + + private String subdomain; + + private String name; + + private VenueType venueType; + + /** + * + */ + public FeedVenueConfig() { + } + + /** + * @param iq + */ + public FeedVenueConfig(IQ iq) { + super(iq); + } + + /** + * Create a query packet + * + * @return + */ + public static FeedVenueConfig createGet() { + FeedVenueConfig rval = new FeedVenueConfig(); + rval.setType(Type.GET); + return rval; + } + + /** + * @param subdomain + * @param name + * @param type + */ + public FeedVenueConfig(String subdomain, String name, VenueType type) { + this.subdomain = subdomain; + this.name = name; + this.venueType = type; + } + + /* + * (non-Javadoc) + * + * @see org.jivesoftware.smack.packet.IQ#getChildElementXML() + */ + @Override + public String getChildElementXML() { + XmlBuilder builder = new XmlBuilder(); + List attributes = new ArrayList(3); + addAttributeIfPresent(attributes, FEED_VENUE_SUBDOMAIN_ATTRIBUTE, name); + addAttributeIfPresent(attributes, FEED_VENUE_SUBDOMAIN_ATTRIBUTE, + subdomain); + addAttributeIfPresent(attributes, FEED_VENUE_TYPE_ATTRIBUTE, venueType); + builder.appendTag(PacketConstants.QUERY_ELEMENT_NAME, FEED_QUERY_XMLNS, + attributes, true); + return builder.toXml(); + } + + /** + * Add a new pair object to list if value is non-null. Attribute value will + * be the object's toString() value + * + * @param attributes + * @param attributeName + * @param valueObject + */ + private static void addAttributeIfPresent(List attributes, + String attributeName, Object valueObject) { + if (valueObject != null) { + attributes.add(new Pair(attributeName, valueObject.toString())); + } + } + + /** + * @return the subdomain + */ + public String getSubdomain() { + return subdomain; + } + + /** + * @param subdomain + * the subdomain to set + */ + public void setSubdomain(String subdomain) { + this.subdomain = subdomain; + } + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @param name + * the name to set + */ + public void setName(String name) { + this.name = name; + } + + /** + * @return the venueType + */ + public VenueType getVenueType() { + return venueType; + } + + /** + * @param venueType + * the venueType to set + */ + public void setVenueType(VenueType venueType) { + this.venueType = venueType; + } + +} diff --git a/edexOsgi/com.raytheon.uf.common.xmpp/src/com/raytheon/uf/common/xmpp/iq/FeedVenueConfigProvider.java b/edexOsgi/com.raytheon.uf.common.xmpp/src/com/raytheon/uf/common/xmpp/iq/FeedVenueConfigProvider.java new file mode 100644 index 0000000000..7ddf234a0e --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.xmpp/src/com/raytheon/uf/common/xmpp/iq/FeedVenueConfigProvider.java @@ -0,0 +1,105 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.common.xmpp.iq; + +import java.io.IOException; + +import org.jivesoftware.smack.packet.IQ; +import org.jivesoftware.smack.provider.IQProvider; +import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; + +import com.raytheon.uf.common.xmpp.BaseProvider; +import com.raytheon.uf.common.xmpp.PacketConstants; +import com.raytheon.uf.common.xmpp.iq.FeedVenueConfig.VenueType; + +/** + * Info Query parsing support for feed venue configuration packets + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Jun 16, 2014 3288       bclement     Initial creation
+ * 
+ * 
+ * + * @author bclement + * @version 1.0 + */ +public class FeedVenueConfigProvider extends BaseProvider + implements IQProvider { + + /** + */ + public FeedVenueConfigProvider() { + super(PacketConstants.QUERY_ELEMENT_NAME); + } + + /* + * (non-Javadoc) + * + * @see org.jivesoftware.smack.provider.IQProvider#parseIQ(org.xmlpull.v1. + * XmlPullParser) + */ + @Override + public IQ parseIQ(XmlPullParser parser) throws Exception { + String subdomain = null; + String name = null; + VenueType type = null; + + do { + String tagName = parser.getName(); + switch (parser.getEventType()) { + case XmlPullParser.START_TAG: + if (PacketConstants.QUERY_ELEMENT_NAME.equals(tagName)) { + subdomain = parser.getAttributeValue(null, + FeedVenueConfig.FEED_VENUE_SUBDOMAIN_ATTRIBUTE); + name = parser.getAttributeValue(null, + FeedVenueConfig.FEED_VENUE_NAME_ATTRIBUTE); + String typeStr = parser.getAttributeValue(null, + FeedVenueConfig.FEED_VENUE_TYPE_ATTRIBUTE); + if (typeStr != null && !typeStr.trim().isEmpty()) { + type = VenueType.valueOf(typeStr.trim().toUpperCase()); + } + } + break; + } + parser.next(); + } while (!atEndOfPacket(parser)); + return new FeedVenueConfig(subdomain, name, type); + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.common.xmpp.BaseProvider#parseInternal(org.xmlpull.v1 + * .XmlPullParser) + */ + @Override + protected FeedVenueConfig parseInternal(XmlPullParser parser) + throws XmlPullParserException, IOException { + return super.parse(parser); + } + +} diff --git a/javaUtilities/com.raytheon.openfire.plugin.configuration.collaboration/java/com/raytheon/openfire/plugin/configuration/collaboration/HttpConfigurationPlugin.java b/javaUtilities/com.raytheon.openfire.plugin.configuration.collaboration/java/com/raytheon/openfire/plugin/configuration/collaboration/HttpConfigurationPlugin.java index 05422647f3..f36fe9c8f3 100644 --- a/javaUtilities/com.raytheon.openfire.plugin.configuration.collaboration/java/com/raytheon/openfire/plugin/configuration/collaboration/HttpConfigurationPlugin.java +++ b/javaUtilities/com.raytheon.openfire.plugin.configuration.collaboration/java/com/raytheon/openfire/plugin/configuration/collaboration/HttpConfigurationPlugin.java @@ -46,6 +46,7 @@ import com.raytheon.openfire.plugin.configuration.collaboration.configuration.Co import com.raytheon.openfire.plugin.configuration.collaboration.http.HttpStatusMonitor; import com.raytheon.openfire.plugin.configuration.collaboration.iq.AbstractConfigHandler; import com.raytheon.openfire.plugin.configuration.collaboration.iq.DataAuthHandler; +import com.raytheon.openfire.plugin.configuration.collaboration.iq.FeedVenueConfigHandler; import com.raytheon.openfire.plugin.configuration.collaboration.iq.HttpAddressHandler; import com.raytheon.openfire.plugin.configuration.collaboration.iq.SecurityToggleHandler; import com.raytheon.openfire.plugin.configuration.collaboration.listener.CollaborationSessionEventListener; @@ -66,6 +67,7 @@ import com.raytheon.openfire.plugin.configuration.collaboration.listener.Collabo * Feb 14, 2013 2756 bclement rename and refactor for operation with generic http * server configured over XMPP * Mar 04, 2014 2756 bclement added dataserver security toggle update to setLegacySupport + * Jun 16, 2014 3288 bclement feed venue configuration handler * * * @@ -153,8 +155,9 @@ public class HttpConfigurationPlugin implements Plugin { DataAuthHandler authHandler = new DataAuthHandler(); HttpAddressHandler addressHandler = new HttpAddressHandler(); SecurityToggleHandler secTogHandler = new SecurityToggleHandler(); - registerConfigHandlers(server, - Arrays.asList(authHandler, addressHandler, secTogHandler)); + FeedVenueConfigHandler feedConfigHandler = new FeedVenueConfigHandler(); + registerConfigHandlers(server, Arrays.asList(authHandler, + addressHandler, secTogHandler, feedConfigHandler)); /* Retrieve openfire components. */ serverId = new JID(server.getServerInfo().getXMPPDomain()); diff --git a/javaUtilities/com.raytheon.openfire.plugin.configuration.collaboration/java/com/raytheon/openfire/plugin/configuration/collaboration/iq/FeedVenueConfigHandler.java b/javaUtilities/com.raytheon.openfire.plugin.configuration.collaboration/java/com/raytheon/openfire/plugin/configuration/collaboration/iq/FeedVenueConfigHandler.java new file mode 100644 index 0000000000..68a89b2a29 --- /dev/null +++ b/javaUtilities/com.raytheon.openfire.plugin.configuration.collaboration/java/com/raytheon/openfire/plugin/configuration/collaboration/iq/FeedVenueConfigHandler.java @@ -0,0 +1,168 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.openfire.plugin.configuration.collaboration.iq; + +import java.util.Arrays; + +import org.dom4j.Element; +import org.dom4j.tree.DefaultAttribute; +import org.jivesoftware.openfire.IQHandlerInfo; +import org.jivesoftware.openfire.XMPPServer; +import org.jivesoftware.openfire.auth.UnauthorizedException; +import org.jivesoftware.openfire.muc.MUCRoom; +import org.jivesoftware.openfire.muc.MultiUserChatManager; +import org.jivesoftware.openfire.muc.MultiUserChatService; +import org.jivesoftware.util.JiveGlobals; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.xmpp.packet.IQ; + +/** + * Handler for feed venue configuration queries + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Jun 16, 2014 3288       bclement     Initial creation
+ * 
+ * 
+ * + * @author bclement + * @version 1.0 + */ +public class FeedVenueConfigHandler extends AbstractConfigHandler { + + private static final Logger log = LoggerFactory + .getLogger(FeedVenueConfigHandler.class); + + public static enum VenueType { + /* SINGLE is a normal room, AGGREGATE is multiple rooms viewed as one */ + SINGLE, AGGREGATE; + } + + /* XML constants */ + + public static final String FEED_QUERY_XMLNS = "urn:uf:viz:collaboration:iq:feed"; + + public static final String FEED_VENUE_SUBDOMAIN_ATTRIBUTE = "subdomain"; + + public static final String FEED_VENUE_NAME_ATTRIBUTE = "name"; + + public static final String FEED_VENUE_TYPE_ATTRIBUTE = "type"; + + /* config storage constants */ + + public static final String FEED_VENUE_SUBDOMAIN_KEY = "plugin.collaboration.feed.venue.subdomain"; + + public static final String FEED_VENUE_SUBDOMAIN_DEFAULT = "conference"; + + public static final String FEED_VENUE_NAME_KEY = "plugin.collaboration.feed.venue.name"; + + public static final String FEED_VENUE_NAME_DEFAULT = "nws-collaboration"; + + public static final String FEED_VENUE_TYPE_KEY = "plugin.collaboration.feed.venue.type"; + + public static final VenueType FEED_VENUE_TYPE_DEFAULT = VenueType.SINGLE; + + + /** + * + */ + public FeedVenueConfigHandler() { + super("Collaboration Dataserver Feed Venue Configuration Handler", + Arrays.asList(FEED_QUERY_XMLNS), new IQHandlerInfo( + QUERY_ELEMENT_NAME, FEED_QUERY_XMLNS)); + } + + /* (non-Javadoc) + * @see com.raytheon.openfire.plugin.configuration.collaboration.iq.AbstractConfigHandler#handleGet(org.xmpp.packet.IQ) + */ + @Override + protected IQ handleGet(IQ packet) throws UnauthorizedException { + String subdomain = getFeedVenueSubdomain(); + String name = getFeedVenueName(); + /* always default until we implement aggregate */ + VenueType type = FEED_VENUE_TYPE_DEFAULT; + + Element query = packet.getChildElement(); + query.setParent(null); + query.add(new DefaultAttribute(FEED_VENUE_SUBDOMAIN_ATTRIBUTE, + subdomain)); + query.add(new DefaultAttribute(FEED_VENUE_NAME_ATTRIBUTE, name)); + query.add(new DefaultAttribute(FEED_VENUE_TYPE_ATTRIBUTE, type + .toString())); + IQ rval = IQ.createResultIQ(packet); + rval.setChildElement(query); + return rval; + } + + /* (non-Javadoc) + * @see com.raytheon.openfire.plugin.configuration.collaboration.iq.AbstractConfigHandler#handleSet(org.xmpp.packet.IQ) + */ + @Override + protected IQ handleSet(IQ packet) throws UnauthorizedException { + log.debug("Received unsupported packet type: " + packet.getType()); + throw new UnauthorizedException( + "Feed Venue configuration can only be queried"); + } + + + /** + * @param subdomain + * @param name + * @return false if subdomain or name do not exist on server + */ + public static boolean setFeedVenueConfig(String subdomain, String name) { + XMPPServer server = XMPPServer.getInstance(); + MultiUserChatManager mucManager = server.getMultiUserChatManager(); + MultiUserChatService service = mucManager + .getMultiUserChatService(subdomain); + boolean rval = false; + if (service != null) { + MUCRoom chatRoom = service.getChatRoom(name); + if (chatRoom != null) { + JiveGlobals.setProperty(FEED_VENUE_SUBDOMAIN_KEY, subdomain); + JiveGlobals.setProperty(FEED_VENUE_NAME_KEY, name); + rval = true; + } + } + return rval; + } + + /** + * @return + */ + public static String getFeedVenueSubdomain() { + return JiveGlobals.getProperty(FEED_VENUE_SUBDOMAIN_KEY, + FEED_VENUE_SUBDOMAIN_DEFAULT); + } + + /** + * @return + */ + public static String getFeedVenueName() { + return JiveGlobals.getProperty(FEED_VENUE_NAME_KEY, + FEED_VENUE_NAME_DEFAULT); + } + +} diff --git a/javaUtilities/com.raytheon.openfire.plugin.configuration.collaboration/plugin.xml b/javaUtilities/com.raytheon.openfire.plugin.configuration.collaboration/plugin.xml index ee9b9ac8d2..97360ba6f0 100644 --- a/javaUtilities/com.raytheon.openfire.plugin.configuration.collaboration/plugin.xml +++ b/javaUtilities/com.raytheon.openfire.plugin.configuration.collaboration/plugin.xml @@ -19,6 +19,11 @@ url="http-collaboration-monitor-admin.jsp" description="Click to administer settings for the Http Collaboration Monitor." /> + + + \ No newline at end of file diff --git a/javaUtilities/com.raytheon.openfire.plugin.configuration.collaboration/web/feed-venue-admin.jsp b/javaUtilities/com.raytheon.openfire.plugin.configuration.collaboration/web/feed-venue-admin.jsp new file mode 100644 index 0000000000..ff33d04376 --- /dev/null +++ b/javaUtilities/com.raytheon.openfire.plugin.configuration.collaboration/web/feed-venue-admin.jsp @@ -0,0 +1,121 @@ +<%@ page + import="org.jivesoftware.openfire.XMPPServer, + com.raytheon.openfire.plugin.configuration.collaboration.iq.FeedVenueConfigHandler, + org.jivesoftware.util.ParamUtils, + java.util.HashMap, + java.util.Map" + errorPage="error.jsp"%> + +<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%> +<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt"%> + +<%! + public static String getSafeParam(HttpServletRequest request, String name){ + String rval = ParamUtils.getParameter(request, name, true); + return rval != null ? rval : ""; + } +%> + +<% + boolean save = ((request.getParameter("save") == null) == false); + String feedVenueName = getSafeParam(request, "feedVenueName"); + String feedVenueSubdomain = getSafeParam(request, "feedVenueSubdomain"); + /* feeVenueType will be added when aggregate rooms are implemented */ + + if (save) + { + boolean success = FeedVenueConfigHandler.setFeedVenueConfig(feedVenueSubdomain, feedVenueName); + response.sendRedirect("feed-venue-admin.jsp?settingsSaved=" + success); + return; + } + + feedVenueName = FeedVenueConfigHandler.getFeedVenueName(); + feedVenueSubdomain = FeedVenueConfigHandler.getFeedVenueSubdomain(); +%> + + + + Collaboration Feed Venue Settings + + + +
+
+ Collaboration Feed Venue Settings +
+
+ <% if (ParamUtils.getBooleanParameter(request, "settingsSaved")) { %> + +
+ + + + + + + +
Settings Saved Successfully!
+
+ + <% }else if (ParamUtils.getParameter(request, "settingsSaved") != null){ %> + +
+ + + + + + + +
Invalid configuration settings, check that subdomain and room exist on server
+
+ + <% } %> + +

+ Set Multi-User Chat Subdomain for Feed Venue chatroom +

+ + + + + + + + +
Subdomain:  + +
+


+

+ Set Feed Venue chatroom name +

+ + + + + + + + +
Room Name:  + +
+
+ +
+ + + + + + + + + + + + +