Issue #1501 Use registry version of subscription when sending notification responses

Change-Id: I96622e8f1d2236ade47d4c5a11ad41b750bc7962

Former-commit-id: 9f775d2dd7 [formerly d9064bdc98] [formerly 9f775d2dd7 [formerly d9064bdc98] [formerly 38036a0e8b [formerly da8f6de9ae2b897163b465c045114fbd9ebec6e8]]]
Former-commit-id: 38036a0e8b
Former-commit-id: 9681f57fac [formerly 13a75fabad]
Former-commit-id: 6266e3e44c
This commit is contained in:
Dustin Johnson 2013-01-17 14:15:44 -06:00
parent e3cf0246c7
commit 1e4df6722c
9 changed files with 93 additions and 38 deletions

View file

@ -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.
*
* </pre>
*
@ -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);
}
}

View file

@ -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.
*
* </pre>
*
@ -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;
}
}

View file

@ -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"

View file

@ -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.
*
*
* <pre>
*
*
* 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.
*
* </pre>
*
*
* @author mpduff
* @version 1.0
*/
@ -85,4 +87,11 @@ public abstract class BaseSubscriptionNotificationResponse<T extends Subscriptio
this.subscription = subscription;
}
/**
* Get the subscription handler that corresponds to the subscription type
* for this notification.
*
* @return the subscription handler
*/
public abstract IBaseSubscriptionHandler<T> getSubscriptionHandler();
}

View file

@ -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.
*
*
* <pre>
*
*
* 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.
*
* </pre>
*
*
* @author mpduff
* @version 1.0
*/
@ -42,4 +45,12 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
public class PendingSubscriptionNotificationResponse extends
BaseSubscriptionNotificationResponse<InitialPendingSubscription> {
/**
* {@inheritDoc}
*/
@Override
public IBaseSubscriptionHandler<InitialPendingSubscription> getSubscriptionHandler() {
return DataDeliveryHandlers.getPendingSubscriptionHandler();
}
}

View file

@ -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.
*
*
* <pre>
*
*
* 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.
* </pre>
*
*
* @author mpduff
* @version 1.0
*/
@DynamicSerialize
public class SubscriptionNotificationResponse extends
BaseSubscriptionNotificationResponse<Subscription>{
/**
* {@inheritDoc}
*/
@Override
public IBaseSubscriptionHandler<Subscription> getSubscriptionHandler() {
return DataDeliveryHandlers.getSubscriptionHandler();
}
}

View file

@ -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"

View file

@ -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.
*
*
* <pre>
*
*
* 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.
* </pre>
*
*
* @author mpduff
* @version 1.0
*/
public class SubscriptionNotificationHandler<T extends Subscription> extends AbstractHandler implements
public class SubscriptionNotificationHandler<T extends Subscription> extends
AbstractHandler implements
IRequestHandler<BaseSubscriptionNotificationRequest<T>> {
private static final IUFStatusHandler statusHandler = UFStatus
@ -60,7 +63,7 @@ public class SubscriptionNotificationHandler<T extends Subscription> extends Abs
/**
* Constructor
*
*
* @param uri
* the jms uri to send the response
*/
@ -70,7 +73,7 @@ public class SubscriptionNotificationHandler<T extends Subscription> 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<T extends Subscription> extends Abs
storeAndSend(record, uri);
BaseSubscriptionNotificationResponse<T> response = request.getResponse();
BaseSubscriptionNotificationResponse<T> response = request
.getResponse();
response.setMessage(request.getMessage());
response.setSubscription(request.getSubscription());
final IBaseSubscriptionHandler<T> 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);