Merge "Issue #1501 Use registry version of subscription when sending notification responses" into 13.2.1_delivery

Former-commit-id: f553d99665 [formerly 08e7ce3da9] [formerly f553d99665 [formerly 08e7ce3da9] [formerly f2ed67c841 [formerly 05dde10fa4bab4b93f7a2f25c368a2a99acae581]]]
Former-commit-id: f2ed67c841
Former-commit-id: a41c4056af [formerly 683fdaf376]
Former-commit-id: 876b7d9502
This commit is contained in:
Richard Peter 2013-01-17 17:06:52 -06:00 committed by Gerrit Code Review
commit 670ee08715
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.event.notification.SubscriptionNotificationRequest;
import com.raytheon.uf.common.datadelivery.registry.InitialPendingSubscription; import com.raytheon.uf.common.datadelivery.registry.InitialPendingSubscription;
import com.raytheon.uf.common.datadelivery.registry.Subscription; 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.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority; 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 * Implementation of {@link ISubscriptionNotificationService} that sends the
@ -42,7 +42,8 @@ import com.raytheon.uf.viz.core.requests.ThriftClient;
* *
* Date Ticket# Engineer Description * 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> * </pre>
* *
@ -207,8 +208,7 @@ public class SendToServerSubscriptionNotificationService implements
*/ */
@Override @Override
public void sendSubscriptionActivatedNotification( public void sendSubscriptionActivatedNotification(
Subscription subscription, Subscription subscription, String username) {
String username) {
SubscriptionNotificationRequest req = new SubscriptionNotificationRequest(); SubscriptionNotificationRequest req = new SubscriptionNotificationRequest();
req.setUserId(username); req.setUserId(username);
req.setCategory("Subscription"); req.setCategory("Subscription");
@ -223,8 +223,7 @@ public class SendToServerSubscriptionNotificationService implements
*/ */
@Override @Override
public void sendSubscriptionDeactivatedNotification( public void sendSubscriptionDeactivatedNotification(
Subscription subscription, Subscription subscription, String username) {
String username) {
SubscriptionNotificationRequest req = new SubscriptionNotificationRequest(); SubscriptionNotificationRequest req = new SubscriptionNotificationRequest();
req.setUserId(username); req.setUserId(username);
req.setCategory("Subscription"); req.setCategory("Subscription");
@ -241,8 +240,9 @@ public class SendToServerSubscriptionNotificationService implements
*/ */
private void sendRequest(BaseSubscriptionNotificationRequest<?> req) { private void sendRequest(BaseSubscriptionNotificationRequest<?> req) {
try { try {
ThriftClient.sendRequest(req); RequestRouter
} catch (VizException e) { .route(req, DataDeliveryConstants.DATA_DELIVERY_SERVER);
} catch (Exception e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), 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. * Oct 23, 2012 1286 djohnson Hook into bandwidth management.
* Nov 20, 2012 1286 djohnson Implement IDisplay. * Nov 20, 2012 1286 djohnson Implement IDisplay.
* Jan 04, 2013 1420 mpduff Remove applying of rules. * 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> * </pre>
* *
@ -437,21 +439,26 @@ public class SystemManagementDlg extends CaveSWTDialog implements IDisplay,
sb.append("Would you like to change the bandwidth anyways?."); sb.append("Would you like to change the bandwidth anyways?.");
int response = DataDeliveryUtils.showMessage(getShell(), int response = DataDeliveryUtils.showMessage(getShell(),
SWT.YES | SWT.NO, "Bandwidth Amount", sb.toString()); SWT.YES | SWT.NO, "Bandwidth Amount", sb.toString());
boolean forceApplied = false;
if (response == SWT.YES) { if (response == SWT.YES) {
boolean forceApplied = SystemRuleManager forceApplied = SystemRuleManager
.forceSetAvailableBandwidth(Network.OPSNET, .forceSetAvailableBandwidth(Network.OPSNET,
bandwidth); bandwidth);
if (!forceApplied) { if (forceApplied) {
availableBandwidthModified = false;
} else {
statusHandler statusHandler
.handle(Priority.ERROR, .handle(Priority.ERROR,
"Bandwidth Change", "Bandwidth Change",
"Unable to change the bandwidth for network " "Unable to change the bandwidth for network "
+ Network.OPSNET + Network.OPSNET
+ ". Please check the server for details."); + ". 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.event;bundle-version="1.0.0",
com.raytheon.uf.common.serialization.comm;bundle-version="1.12.1174", 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.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; package com.raytheon.uf.common.datadelivery.event.notification;
import com.raytheon.uf.common.datadelivery.registry.Subscription; 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.ISerializableObject;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; 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. * Base abstract class for the subscription notification response.
* *
* <pre> * <pre>
* *
* SOFTWARE HISTORY * SOFTWARE HISTORY
* *
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Sep 20, 2012 1157 mpduff Initial creation * Sep 20, 2012 1157 mpduff Initial creation
* * Jan 17, 2013 1501 djohnson Allow a response to specify the subscription handler.
*
* </pre> * </pre>
* *
* @author mpduff * @author mpduff
* @version 1.0 * @version 1.0
*/ */
@ -85,4 +87,11 @@ public abstract class BaseSubscriptionNotificationResponse<T extends Subscriptio
this.subscription = subscription; 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; package com.raytheon.uf.common.datadelivery.event.notification;
import com.raytheon.uf.common.datadelivery.registry.InitialPendingSubscription; 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; import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
/** /**
* PendingSubscriptionNotificationResponse object. * PendingSubscriptionNotificationResponse object.
* *
* <pre> * <pre>
* *
* SOFTWARE HISTORY * SOFTWARE HISTORY
* *
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Sep 20, 2012 mpduff Initial creation * Sep 20, 2012 mpduff Initial creation
* * Jan 17, 2013 1501 djohnson Allow a response to specify the subscription handler.
*
* </pre> * </pre>
* *
* @author mpduff * @author mpduff
* @version 1.0 * @version 1.0
*/ */
@ -42,4 +45,12 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
public class PendingSubscriptionNotificationResponse extends public class PendingSubscriptionNotificationResponse extends
BaseSubscriptionNotificationResponse<InitialPendingSubscription> { 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; package com.raytheon.uf.common.datadelivery.event.notification;
import com.raytheon.uf.common.datadelivery.registry.Subscription; 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; import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
/** /**
* SubscriptionNotificationResponse object. * SubscriptionNotificationResponse object.
* *
* <pre> * <pre>
* *
* SOFTWARE HISTORY * SOFTWARE HISTORY
* *
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Jun 25, 2012 mpduff Initial creation. * Jun 25, 2012 mpduff Initial creation.
* Aug 21, 2012 712 mpduff Add a Subscription Object. * Aug 21, 2012 712 mpduff Add a Subscription Object.
* Jan 17, 2013 1501 djohnson Allow a response to specify the subscription handler.
* </pre> * </pre>
* *
* @author mpduff * @author mpduff
* @version 1.0 * @version 1.0
*/ */
@DynamicSerialize @DynamicSerialize
public class SubscriptionNotificationResponse extends public class SubscriptionNotificationResponse extends
BaseSubscriptionNotificationResponse<Subscription>{ 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", org.springframework;bundle-version="2.5.6",
com.raytheon.uf.common.event;bundle-version="1.0.0", 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.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.BaseSubscriptionNotificationResponse;
import com.raytheon.uf.common.datadelivery.event.notification.NotificationRecord; import com.raytheon.uf.common.datadelivery.event.notification.NotificationRecord;
import com.raytheon.uf.common.datadelivery.registry.Subscription; 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.serialization.comm.IRequestHandler;
import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus;
/** /**
* Subscription Notification Handler. * Subscription Notification Handler.
* *
* <pre> * <pre>
* *
* SOFTWARE HISTORY * SOFTWARE HISTORY
* *
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Jun 25, 2012 mpduff Initial creation. * 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. * Aug 31, 2012 1128 mpduff Set priority and category from request.
* Sep 06, 2012 687 mpduff Send a SubscriptionNotificationResponse object. * Sep 06, 2012 687 mpduff Send a SubscriptionNotificationResponse object.
* Sep 24, 2012 1157 mpduff Changed to use BaseSubscriptionNotificationRequest. * 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> * </pre>
* *
* @author mpduff * @author mpduff
* @version 1.0 * @version 1.0
*/ */
public class SubscriptionNotificationHandler<T extends Subscription> extends AbstractHandler implements public class SubscriptionNotificationHandler<T extends Subscription> extends
AbstractHandler implements
IRequestHandler<BaseSubscriptionNotificationRequest<T>> { IRequestHandler<BaseSubscriptionNotificationRequest<T>> {
private static final IUFStatusHandler statusHandler = UFStatus private static final IUFStatusHandler statusHandler = UFStatus
@ -60,7 +63,7 @@ public class SubscriptionNotificationHandler<T extends Subscription> extends Abs
/** /**
* Constructor * Constructor
* *
* @param uri * @param uri
* the jms uri to send the response * the jms uri to send the response
*/ */
@ -70,7 +73,7 @@ public class SubscriptionNotificationHandler<T extends Subscription> extends Abs
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see * @see
* com.raytheon.uf.common.serialization.comm.IRequestHandler#handleRequest * com.raytheon.uf.common.serialization.comm.IRequestHandler#handleRequest
* (com.raytheon.uf.common.serialization.comm.IServerRequest) * (com.raytheon.uf.common.serialization.comm.IServerRequest)
@ -87,9 +90,21 @@ public class SubscriptionNotificationHandler<T extends Subscription> extends Abs
storeAndSend(record, uri); storeAndSend(record, uri);
BaseSubscriptionNotificationResponse<T> response = request.getResponse(); BaseSubscriptionNotificationResponse<T> response = request
.getResponse();
response.setMessage(request.getMessage()); 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); send(response, uri);