From 1e4df6722c83a314f134bee3726b47aa82e42190 Mon Sep 17 00:00:00 2001 From: Dustin Johnson Date: Thu, 17 Jan 2013 14:15:44 -0600 Subject: [PATCH] Issue #1501 Use registry version of subscription when sending notification responses Change-Id: I96622e8f1d2236ade47d4c5a11ad41b750bc7962 Former-commit-id: 9f775d2dd752d5b25053e6c912c2fc1fe0139f21 [formerly d9064bdc98904ce4ab3fd2f54cd76d931f7affe8] [formerly 9f775d2dd752d5b25053e6c912c2fc1fe0139f21 [formerly d9064bdc98904ce4ab3fd2f54cd76d931f7affe8] [formerly 38036a0e8b0d615744309d0d0937549fb5cc85bc [formerly da8f6de9ae2b897163b465c045114fbd9ebec6e8]]] Former-commit-id: 38036a0e8b0d615744309d0d0937549fb5cc85bc Former-commit-id: 9681f57fac07950955894060cddde285586e90a9 [formerly 13a75fabad9012ea6b4fe384dc17369f02eeb613] Former-commit-id: 6266e3e44c202041fcd1ce522987bfc08ba0af6e --- ...ServerSubscriptionNotificationService.java | 18 +++++----- .../system/SystemManagementDlg.java | 15 ++++++--- .../META-INF/MANIFEST.MF | 3 +- .../BaseSubscriptionNotificationResponse.java | 19 ++++++++--- ...ndingSubscriptionNotificationResponse.java | 21 +++++++++--- .../SubscriptionNotificationResponse.java | 19 ++++++++--- .../META-INF/MANIFEST.MF | 3 +- ...ery-request.xml => event-datadelivery.xml} | 0 .../SubscriptionNotificationHandler.java | 33 ++++++++++++++----- 9 files changed, 93 insertions(+), 38 deletions(-) rename edexOsgi/com.raytheon.uf.edex.datadelivery.event/res/spring/{event-datadelivery-request.xml => event-datadelivery.xml} (100%) diff --git a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/subscription/SendToServerSubscriptionNotificationService.java b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/subscription/SendToServerSubscriptionNotificationService.java index 8206745bcf..934ae37b54 100644 --- a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/subscription/SendToServerSubscriptionNotificationService.java +++ b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/subscription/SendToServerSubscriptionNotificationService.java @@ -26,11 +26,11 @@ import com.raytheon.uf.common.datadelivery.event.notification.PendingSubscriptio import com.raytheon.uf.common.datadelivery.event.notification.SubscriptionNotificationRequest; import com.raytheon.uf.common.datadelivery.registry.InitialPendingSubscription; import com.raytheon.uf.common.datadelivery.registry.Subscription; +import com.raytheon.uf.common.datadelivery.request.DataDeliveryConstants; +import com.raytheon.uf.common.serialization.comm.RequestRouter; 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.viz.core.exception.VizException; -import com.raytheon.uf.viz.core.requests.ThriftClient; /** * Implementation of {@link ISubscriptionNotificationService} that sends the @@ -42,7 +42,8 @@ import com.raytheon.uf.viz.core.requests.ThriftClient; * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Jan 4, 2013 1441 djohnson Initial creation + * Jan 04, 2013 1441 djohnson Initial creation + * Jan 17, 2013 1501 djohnson Route to datadelivery. * * * @@ -207,8 +208,7 @@ public class SendToServerSubscriptionNotificationService implements */ @Override public void sendSubscriptionActivatedNotification( - Subscription subscription, - String username) { + Subscription subscription, String username) { SubscriptionNotificationRequest req = new SubscriptionNotificationRequest(); req.setUserId(username); req.setCategory("Subscription"); @@ -223,8 +223,7 @@ public class SendToServerSubscriptionNotificationService implements */ @Override public void sendSubscriptionDeactivatedNotification( - Subscription subscription, - String username) { + Subscription subscription, String username) { SubscriptionNotificationRequest req = new SubscriptionNotificationRequest(); req.setUserId(username); req.setCategory("Subscription"); @@ -241,8 +240,9 @@ public class SendToServerSubscriptionNotificationService implements */ private void sendRequest(BaseSubscriptionNotificationRequest req) { try { - ThriftClient.sendRequest(req); - } catch (VizException e) { + RequestRouter + .route(req, DataDeliveryConstants.DATA_DELIVERY_SERVER); + } catch (Exception e) { statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e); } } diff --git a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/system/SystemManagementDlg.java b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/system/SystemManagementDlg.java index 61e2bab7e6..bd45484a53 100644 --- a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/system/SystemManagementDlg.java +++ b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/system/SystemManagementDlg.java @@ -65,6 +65,8 @@ import com.raytheon.viz.ui.presenter.IDisplay; * Oct 23, 2012 1286 djohnson Hook into bandwidth management. * Nov 20, 2012 1286 djohnson Implement IDisplay. * Jan 04, 2013 1420 mpduff Remove applying of rules. + * Jan 17, 2013 1501 djohnson Close the dialog when force apply occurs, + * and check whether changes have already been applied when OK is pressed. * * * @@ -437,21 +439,26 @@ public class SystemManagementDlg extends CaveSWTDialog implements IDisplay, sb.append("Would you like to change the bandwidth anyways?."); int response = DataDeliveryUtils.showMessage(getShell(), SWT.YES | SWT.NO, "Bandwidth Amount", sb.toString()); + boolean forceApplied = false; if (response == SWT.YES) { - boolean forceApplied = SystemRuleManager + forceApplied = SystemRuleManager .forceSetAvailableBandwidth(Network.OPSNET, bandwidth); - if (!forceApplied) { + if (forceApplied) { + availableBandwidthModified = false; + } else { statusHandler .handle(Priority.ERROR, "Bandwidth Change", "Unable to change the bandwidth for network " + Network.OPSNET + ". Please check the server for details."); - return false; + } } - return false; + return forceApplied; + } else { + availableBandwidthModified = false; } } diff --git a/edexOsgi/com.raytheon.uf.common.datadelivery.event/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.common.datadelivery.event/META-INF/MANIFEST.MF index 772a6e8dbc..2ffd2f8400 100644 --- a/edexOsgi/com.raytheon.uf.common.datadelivery.event/META-INF/MANIFEST.MF +++ b/edexOsgi/com.raytheon.uf.common.datadelivery.event/META-INF/MANIFEST.MF @@ -17,4 +17,5 @@ Require-Bundle: javax.persistence;bundle-version="1.0.0", com.raytheon.uf.common.event;bundle-version="1.0.0", com.raytheon.uf.common.serialization.comm;bundle-version="1.12.1174", com.raytheon.uf.common.time;bundle-version="1.12.1174", - com.raytheon.uf.common.stats;bundle-version="1.0.0" + com.raytheon.uf.common.stats;bundle-version="1.0.0", + com.raytheon.uf.common.registry.ebxml;bundle-version="1.0.0" diff --git a/edexOsgi/com.raytheon.uf.common.datadelivery.event/src/com/raytheon/uf/common/datadelivery/event/notification/BaseSubscriptionNotificationResponse.java b/edexOsgi/com.raytheon.uf.common.datadelivery.event/src/com/raytheon/uf/common/datadelivery/event/notification/BaseSubscriptionNotificationResponse.java index bdc515c04a..567f1da440 100644 --- a/edexOsgi/com.raytheon.uf.common.datadelivery.event/src/com/raytheon/uf/common/datadelivery/event/notification/BaseSubscriptionNotificationResponse.java +++ b/edexOsgi/com.raytheon.uf.common.datadelivery.event/src/com/raytheon/uf/common/datadelivery/event/notification/BaseSubscriptionNotificationResponse.java @@ -20,6 +20,7 @@ package com.raytheon.uf.common.datadelivery.event.notification; import com.raytheon.uf.common.datadelivery.registry.Subscription; +import com.raytheon.uf.common.datadelivery.registry.handlers.IBaseSubscriptionHandler; import com.raytheon.uf.common.serialization.ISerializableObject; import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; @@ -27,17 +28,18 @@ import com.raytheon.uf.common.serialization.comm.IServerRequest; /** * Base abstract class for the subscription notification response. - * + * *
- *
+ * 
  * SOFTWARE HISTORY
- *
+ * 
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Sep 20, 2012    1157    mpduff      Initial creation
- *
+ * Jan 17, 2013 1501       djohnson     Allow a response to specify the subscription handler.
+ * 
  * 
- * + * * @author mpduff * @version 1.0 */ @@ -85,4 +87,11 @@ public abstract class BaseSubscriptionNotificationResponse getSubscriptionHandler(); } diff --git a/edexOsgi/com.raytheon.uf.common.datadelivery.event/src/com/raytheon/uf/common/datadelivery/event/notification/PendingSubscriptionNotificationResponse.java b/edexOsgi/com.raytheon.uf.common.datadelivery.event/src/com/raytheon/uf/common/datadelivery/event/notification/PendingSubscriptionNotificationResponse.java index 46b9f011b7..ef857f96a0 100644 --- a/edexOsgi/com.raytheon.uf.common.datadelivery.event/src/com/raytheon/uf/common/datadelivery/event/notification/PendingSubscriptionNotificationResponse.java +++ b/edexOsgi/com.raytheon.uf.common.datadelivery.event/src/com/raytheon/uf/common/datadelivery/event/notification/PendingSubscriptionNotificationResponse.java @@ -20,21 +20,24 @@ package com.raytheon.uf.common.datadelivery.event.notification; import com.raytheon.uf.common.datadelivery.registry.InitialPendingSubscription; +import com.raytheon.uf.common.datadelivery.registry.handlers.DataDeliveryHandlers; +import com.raytheon.uf.common.datadelivery.registry.handlers.IBaseSubscriptionHandler; import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; /** * PendingSubscriptionNotificationResponse object. - * + * *
- *
+ * 
  * SOFTWARE HISTORY
- *
+ * 
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Sep 20, 2012            mpduff     Initial creation
- *
+ * Jan 17, 2013 1501       djohnson     Allow a response to specify the subscription handler.
+ * 
  * 
- * + * * @author mpduff * @version 1.0 */ @@ -42,4 +45,12 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; public class PendingSubscriptionNotificationResponse extends BaseSubscriptionNotificationResponse { + /** + * {@inheritDoc} + */ + @Override + public IBaseSubscriptionHandler getSubscriptionHandler() { + return DataDeliveryHandlers.getPendingSubscriptionHandler(); + } + } diff --git a/edexOsgi/com.raytheon.uf.common.datadelivery.event/src/com/raytheon/uf/common/datadelivery/event/notification/SubscriptionNotificationResponse.java b/edexOsgi/com.raytheon.uf.common.datadelivery.event/src/com/raytheon/uf/common/datadelivery/event/notification/SubscriptionNotificationResponse.java index 61239fe9e9..f9c81eed46 100644 --- a/edexOsgi/com.raytheon.uf.common.datadelivery.event/src/com/raytheon/uf/common/datadelivery/event/notification/SubscriptionNotificationResponse.java +++ b/edexOsgi/com.raytheon.uf.common.datadelivery.event/src/com/raytheon/uf/common/datadelivery/event/notification/SubscriptionNotificationResponse.java @@ -20,25 +20,36 @@ package com.raytheon.uf.common.datadelivery.event.notification; import com.raytheon.uf.common.datadelivery.registry.Subscription; +import com.raytheon.uf.common.datadelivery.registry.handlers.DataDeliveryHandlers; +import com.raytheon.uf.common.datadelivery.registry.handlers.IBaseSubscriptionHandler; import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; /** * SubscriptionNotificationResponse object. - * + * *
- *
+ * 
  * SOFTWARE HISTORY
- *
+ * 
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Jun 25, 2012            mpduff     Initial creation.
  * Aug 21, 2012     712    mpduff     Add a Subscription Object.
+ * Jan 17, 2013 1501       djohnson     Allow a response to specify the subscription handler.
  * 
- * + * * @author mpduff * @version 1.0 */ @DynamicSerialize public class SubscriptionNotificationResponse extends BaseSubscriptionNotificationResponse{ + + /** + * {@inheritDoc} + */ + @Override + public IBaseSubscriptionHandler getSubscriptionHandler() { + return DataDeliveryHandlers.getSubscriptionHandler(); + } } diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.event/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.edex.datadelivery.event/META-INF/MANIFEST.MF index 370aea781a..df1cbbaed8 100644 --- a/edexOsgi/com.raytheon.uf.edex.datadelivery.event/META-INF/MANIFEST.MF +++ b/edexOsgi/com.raytheon.uf.edex.datadelivery.event/META-INF/MANIFEST.MF @@ -18,4 +18,5 @@ Require-Bundle: com.google.guava;bundle-version="1.0.0", org.springframework;bundle-version="2.5.6", com.raytheon.uf.common.event;bundle-version="1.0.0", com.raytheon.uf.common.datadelivery.registry;bundle-version="1.0.0", - com.raytheon.uf.common.registry.event;bundle-version="1.0.0" + com.raytheon.uf.common.registry.event;bundle-version="1.0.0", + com.raytheon.uf.common.registry.ebxml;bundle-version="1.0.0" diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.event/res/spring/event-datadelivery-request.xml b/edexOsgi/com.raytheon.uf.edex.datadelivery.event/res/spring/event-datadelivery.xml similarity index 100% rename from edexOsgi/com.raytheon.uf.edex.datadelivery.event/res/spring/event-datadelivery-request.xml rename to edexOsgi/com.raytheon.uf.edex.datadelivery.event/res/spring/event-datadelivery.xml diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.event/src/com/raytheon/uf/edex/datadelivery/event/handler/SubscriptionNotificationHandler.java b/edexOsgi/com.raytheon.uf.edex.datadelivery.event/src/com/raytheon/uf/edex/datadelivery/event/handler/SubscriptionNotificationHandler.java index e0a17c731e..814cbe65f7 100644 --- a/edexOsgi/com.raytheon.uf.edex.datadelivery.event/src/com/raytheon/uf/edex/datadelivery/event/handler/SubscriptionNotificationHandler.java +++ b/edexOsgi/com.raytheon.uf.edex.datadelivery.event/src/com/raytheon/uf/edex/datadelivery/event/handler/SubscriptionNotificationHandler.java @@ -25,17 +25,18 @@ import com.raytheon.uf.common.datadelivery.event.notification.BaseSubscriptionNo import com.raytheon.uf.common.datadelivery.event.notification.BaseSubscriptionNotificationResponse; import com.raytheon.uf.common.datadelivery.event.notification.NotificationRecord; import com.raytheon.uf.common.datadelivery.registry.Subscription; +import com.raytheon.uf.common.datadelivery.registry.handlers.IBaseSubscriptionHandler; import com.raytheon.uf.common.serialization.comm.IRequestHandler; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; /** * Subscription Notification Handler. - * + * *
- *
+ * 
  * SOFTWARE HISTORY
- *
+ * 
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Jun 25, 2012            mpduff     Initial creation.
@@ -44,13 +45,15 @@ import com.raytheon.uf.common.status.UFStatus;
  * Aug 31, 2012    1128    mpduff     Set priority and category from request.
  * Sep 06, 2012     687    mpduff     Send a SubscriptionNotificationResponse object.
  * Sep 24, 2012    1157    mpduff     Changed to use BaseSubscriptionNotificationRequest.
+ * Jan 17, 2013 1501       djohnson     If a subscription is still in the registry, use it for the notification response.
  * 
- * + * * @author mpduff * @version 1.0 */ -public class SubscriptionNotificationHandler extends AbstractHandler implements +public class SubscriptionNotificationHandler extends + AbstractHandler implements IRequestHandler> { private static final IUFStatusHandler statusHandler = UFStatus @@ -60,7 +63,7 @@ public class SubscriptionNotificationHandler extends Abs /** * Constructor - * + * * @param uri * the jms uri to send the response */ @@ -70,7 +73,7 @@ public class SubscriptionNotificationHandler extends Abs /* * (non-Javadoc) - * + * * @see * com.raytheon.uf.common.serialization.comm.IRequestHandler#handleRequest * (com.raytheon.uf.common.serialization.comm.IServerRequest) @@ -87,9 +90,21 @@ public class SubscriptionNotificationHandler extends Abs storeAndSend(record, uri); - BaseSubscriptionNotificationResponse response = request.getResponse(); + BaseSubscriptionNotificationResponse response = request + .getResponse(); response.setMessage(request.getMessage()); - response.setSubscription(request.getSubscription()); + + final IBaseSubscriptionHandler subscriptionHandler = response + .getSubscriptionHandler(); + final T requestSubscription = request.getSubscription(); + final T registryVersion = subscriptionHandler + .getByName(requestSubscription.getName()); + + // If the subscription is still in the registry, use that version which + // will reflect any updates that have occurred since the notification + // was sent, otherwise pass along the one provided with the request + response.setSubscription((registryVersion != null) ? registryVersion + : requestSubscription); send(response, uri);