Issue #2889 user who issued change now shows in notification center
Change-Id: I424b965fed273c491f2d80e220a0936eaa79f7cc Former-commit-id: adc364d92a7fcb2a255a2f448efb56ef48492280
This commit is contained in:
parent
a373345f6e
commit
9479219b73
80 changed files with 251 additions and 5967 deletions
|
@ -98,6 +98,7 @@ import com.raytheon.viz.ui.widgets.duallist.IUpdate;
|
|||
* Jun 13, 2013 2108 mpduff Refactored DataSizeUtils.
|
||||
* Oct 28, 2013 2292 mpduff Change overlap services.
|
||||
* Feb 11, 2014 2771 bgonzale Use Data Delivery ID instead of Site.
|
||||
* Mar 31, 2014 2889 dhladky Added username for notification center tracking.
|
||||
* </pre>
|
||||
*
|
||||
* @author jpiatt
|
||||
|
@ -421,7 +422,7 @@ public class UserSelectComp extends Composite implements IUpdate, IDisplay,
|
|||
try {
|
||||
final SubscriptionServiceResult result = DataDeliveryServices
|
||||
.getSubscriptionService().updateWithPendingCheck(
|
||||
new ArrayList<Subscription>(Sets.union(
|
||||
currentUser, new ArrayList<Subscription>(Sets.union(
|
||||
groupSubscriptions,
|
||||
removeFromGroupSubscriptions)), this);
|
||||
if (result.hasMessageToDisplay()) {
|
||||
|
|
|
@ -71,6 +71,7 @@ import com.raytheon.viz.ui.presenter.components.WidgetConf;
|
|||
* Jan 02, 2013 1441 djohnson Access GroupDefinitionManager in a static fashion.
|
||||
* Jan 08, 2013 1453 djohnson Split creation and edit dialogs.
|
||||
* Apr 08, 2013 1826 djohnson Remove delivery options.
|
||||
* Mar 31, 2014 2889 dhladky Added username for notification center tracking.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -290,7 +291,8 @@ public abstract class BaseGroupDefinitionDlg extends CaveSWTDialog implements
|
|||
}
|
||||
|
||||
try {
|
||||
saveGroupDefinition(groupDefinition);
|
||||
saveGroupDefinition(LocalizationManager.getInstance()
|
||||
.getCurrentUser(), groupDefinition);
|
||||
} catch (RegistryHandlerException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Unable to save Group object", e);
|
||||
|
@ -432,7 +434,7 @@ public abstract class BaseGroupDefinitionDlg extends CaveSWTDialog implements
|
|||
* the group definition
|
||||
* @throws RegistryHandlerException
|
||||
*/
|
||||
protected abstract void saveGroupDefinition(GroupDefinition groupDefinition)
|
||||
protected abstract void saveGroupDefinition(String username, GroupDefinition groupDefinition)
|
||||
throws RegistryHandlerException;
|
||||
|
||||
/**
|
||||
|
|
|
@ -44,6 +44,7 @@ import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryUtils;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- -------------------------
|
||||
* Jan 08, 2013 1453 djohnson Split creation and edit dialogs.
|
||||
* Mar 31, 2014 2889 dhladky Added username for notification center tracking.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -112,9 +113,9 @@ public class CreateGroupDefinitionDlg extends BaseGroupDefinitionDlg {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void saveGroupDefinition(GroupDefinition groupDefinition)
|
||||
protected void saveGroupDefinition(String username, GroupDefinition groupDefinition)
|
||||
throws RegistryHandlerException {
|
||||
DataDeliveryHandlers.getGroupDefinitionHandler().store(groupDefinition);
|
||||
DataDeliveryHandlers.getGroupDefinitionHandler().store(username, groupDefinition);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -145,6 +145,7 @@ import com.raytheon.viz.ui.presenter.components.ComboBoxConf;
|
|||
* Nov 08, 2013 2506 bgonzale Removed send notification when a subscription is updated and created.
|
||||
* Jan 14, 2014 2459 mpduff Change Subscription status code
|
||||
* Feb 11, 2014 2771 bgonzale Use Data Delivery ID instead of Site.
|
||||
* Mar 31, 2014 2889 dhladky Added username for notification center tracking.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -1223,7 +1224,7 @@ public class CreateSubscriptionDlg extends CaveSWTDialog {
|
|||
.initialPending(currentUser);
|
||||
|
||||
try {
|
||||
handler.store(pendingSub);
|
||||
handler.store(username, pendingSub);
|
||||
|
||||
this.subscription = pendingSub;
|
||||
|
||||
|
@ -1265,7 +1266,7 @@ public class CreateSubscriptionDlg extends CaveSWTDialog {
|
|||
if (autoApprove) {
|
||||
try {
|
||||
final SubscriptionServiceResult response = subscriptionService
|
||||
.update(subscription,
|
||||
.update(username, subscription,
|
||||
new CancelForceApplyAndIncreaseLatencyDisplayText(
|
||||
"update", getShell()));
|
||||
if (response.hasMessageToDisplay()) {
|
||||
|
@ -1286,7 +1287,7 @@ public class CreateSubscriptionDlg extends CaveSWTDialog {
|
|||
} else {
|
||||
setSubscriptionId(subscription);
|
||||
try {
|
||||
pendingSubHandler.update(pendingSub);
|
||||
pendingSubHandler.update(username, pendingSub);
|
||||
|
||||
subscriptionNotificationService
|
||||
.sendCreatedPendingSubscriptionForSubscriptionNotification(
|
||||
|
@ -1559,7 +1560,7 @@ public class CreateSubscriptionDlg extends CaveSWTDialog {
|
|||
Subscription subscription, String username) {
|
||||
SubscriptionServiceResult result = null;
|
||||
try {
|
||||
result = subscriptionService.store(subscription,
|
||||
result = subscriptionService.store(username, subscription,
|
||||
new CancelForceApplyAndIncreaseLatencyDisplayText("create",
|
||||
getShell()));
|
||||
} catch (RegistryHandlerException e) {
|
||||
|
|
|
@ -52,6 +52,7 @@ import com.raytheon.viz.ui.presenter.components.ComboBoxConf;
|
|||
* Dec 10, 2012 1259 bsteffen Switch Data Delivery from LatLon to referenced envelopes.
|
||||
* Jan 02, 2013 1441 djohnson Access GroupDefinitionManager in a static fashion.
|
||||
* Jan 08, 2013 1453 djohnson Split creation and edit dialogs.
|
||||
* Mar 31, 2014 2889 dhladky Added username for notification center tracking.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -124,10 +125,10 @@ public class EditGroupDefinitionDlg extends BaseGroupDefinitionDlg {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void saveGroupDefinition(GroupDefinition groupDefinition)
|
||||
protected void saveGroupDefinition(String username, GroupDefinition groupDefinition)
|
||||
throws RegistryHandlerException {
|
||||
DataDeliveryHandlers.getGroupDefinitionHandler()
|
||||
.update(groupDefinition);
|
||||
.update(username, groupDefinition);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -69,6 +69,7 @@ import com.raytheon.viz.ui.presenter.components.WidgetConf;
|
|||
* May 21, 2013 2020 mpduff Rename UserSubscription to SiteSubscription.
|
||||
* Nov 08, 2013 2506 bgonzale Removed send notification when a subscription is created.
|
||||
* Feb 11, 2014 2771 bgonzale Use Data Delivery ID instead of Site.
|
||||
* Mar 31, 2014 2889 dhladky Added username for notification center tracking.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -273,7 +274,7 @@ public class GroupAddDlg extends CaveSWTDialog {
|
|||
}
|
||||
|
||||
try {
|
||||
DataDeliveryHandlers.getSubscriptionHandler().store(subscription);
|
||||
DataDeliveryHandlers.getSubscriptionHandler().store(username, subscription);
|
||||
} catch (RegistryHandlerException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Error saving subscription data to the registry.", e);
|
||||
|
|
|
@ -40,6 +40,7 @@ import com.raytheon.uf.viz.datadelivery.subscription.SubscriptionService.IForceA
|
|||
* Nov 28, 2012 1286 djohnson Consolidate more notifications.
|
||||
* Jul 18, 2013 1653 mpduff Added SubscriptionStatusSummary to ISubscriptionServiceResult
|
||||
* Oct 25, 2013 2292 mpduff Move overlap checks to edex.
|
||||
* Mar 31, 2014 2889 dhladky Added username for notification center tracking.
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
|
@ -56,7 +57,7 @@ public interface ISubscriptionService {
|
|||
* @return the result object
|
||||
* @throws RegistryHandlerException
|
||||
*/
|
||||
SubscriptionServiceResult store(Subscription subscription,
|
||||
SubscriptionServiceResult store(String username, Subscription subscription,
|
||||
IForceApplyPromptDisplayText displayTextStrategy)
|
||||
throws RegistryHandlerException;
|
||||
|
||||
|
@ -68,7 +69,7 @@ public interface ISubscriptionService {
|
|||
* @param displayTextStrategy
|
||||
* @return the result object
|
||||
*/
|
||||
SubscriptionServiceResult update(Subscription subscription,
|
||||
SubscriptionServiceResult update(String username, Subscription subscription,
|
||||
IForceApplyPromptDisplayText displayTextStrategy)
|
||||
throws RegistryHandlerException;
|
||||
|
||||
|
@ -81,7 +82,7 @@ public interface ISubscriptionService {
|
|||
* @return the result object
|
||||
* @throws RegistryHandlerException
|
||||
*/
|
||||
SubscriptionServiceResult update(List<Subscription> subscriptions,
|
||||
SubscriptionServiceResult update(String username, List<Subscription> subscriptions,
|
||||
IForceApplyPromptDisplayText displayTextStrategy)
|
||||
throws RegistryHandlerException;
|
||||
|
||||
|
@ -94,7 +95,7 @@ public interface ISubscriptionService {
|
|||
* @return the result
|
||||
* @throws RegistryHandlerException
|
||||
*/
|
||||
SubscriptionServiceResult updateWithPendingCheck(
|
||||
SubscriptionServiceResult updateWithPendingCheck(String username,
|
||||
List<Subscription> subscriptions,
|
||||
IForceApplyPromptDisplayText displayTextStrategy)
|
||||
throws RegistryHandlerException;
|
||||
|
@ -110,7 +111,7 @@ public interface ISubscriptionService {
|
|||
* @return the result object
|
||||
* @throws RegistryHandlerException
|
||||
*/
|
||||
public SubscriptionServiceResult store(AdhocSubscription sub,
|
||||
public SubscriptionServiceResult store(String username, AdhocSubscription sub,
|
||||
IForceApplyPromptDisplayText displayTextStrategy)
|
||||
throws RegistryHandlerException;
|
||||
}
|
||||
|
|
|
@ -156,6 +156,8 @@ import com.raytheon.viz.ui.presenter.IDisplay;
|
|||
* Feb 14, 2014 2806 mpduff Disable activate/deactivate buttons when viewing other site's subscriptions
|
||||
* Feb 11, 2014 2771 bgonzale Use Data Delivery ID instead of Site.
|
||||
* Mar 24, 2014 #2951 lvenable Added dispose checks for SWT widgets.
|
||||
* Mar 31, 2014 2889 dhladky Added username for notification center tracking.
|
||||
*
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -1196,7 +1198,7 @@ public class SubscriptionManagerDlg extends CaveSWTDialog implements
|
|||
|
||||
try {
|
||||
SubscriptionServiceResult response = subscriptionService
|
||||
.update(sub, forceApplyPromptDisplayText);
|
||||
.update(username, sub, forceApplyPromptDisplayText);
|
||||
if (response.hasMessageToDisplay()) {
|
||||
DataDeliveryUtils.showMessage(getShell(),
|
||||
SWT.OK, sub.getName() + " Activated",
|
||||
|
@ -1457,7 +1459,7 @@ public class SubscriptionManagerDlg extends CaveSWTDialog implements
|
|||
.get(ISubscriptionHandler.class);
|
||||
for (Subscription sub : subscriptions) {
|
||||
try {
|
||||
handler.update(sub);
|
||||
handler.update(username, sub);
|
||||
} catch (RegistryHandlerException e) {
|
||||
exceptions.add(e);
|
||||
}
|
||||
|
|
|
@ -98,6 +98,7 @@ import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryUtils;
|
|||
* Nov 07, 2013 2291 skorolev Used showText() method for "Shared Subscription" message.
|
||||
* Jan 26, 2014 2259 mpduff Turn off subs to be deactivated.
|
||||
* Feb 04, 2014 2677 mpduff Don't do overlap checks when deactivating subs.
|
||||
* Mar 31, 2014 2889 dhladky Added username for notification center tracking.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -312,7 +313,7 @@ public class SubscriptionService implements ISubscriptionService {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public SubscriptionServiceResult store(final Subscription subscription,
|
||||
public SubscriptionServiceResult store(final String username, final Subscription subscription,
|
||||
IForceApplyPromptDisplayText displayTextStrategy)
|
||||
throws RegistryHandlerException {
|
||||
|
||||
|
@ -322,13 +323,13 @@ public class SubscriptionService implements ISubscriptionService {
|
|||
final ServiceInteraction action = new ServiceInteraction() {
|
||||
@Override
|
||||
public String call() throws RegistryHandlerException {
|
||||
DataDeliveryHandlers.getSubscriptionHandler().store(
|
||||
DataDeliveryHandlers.getSubscriptionHandler().store(username,
|
||||
subscription);
|
||||
return successMessage;
|
||||
}
|
||||
};
|
||||
|
||||
SubscriptionServiceResult result = performAction(subscriptions, action,
|
||||
SubscriptionServiceResult result = performAction(username, subscriptions, action,
|
||||
displayTextStrategy);
|
||||
|
||||
if (!result.isAllowFurtherEditing()) {
|
||||
|
@ -344,7 +345,7 @@ public class SubscriptionService implements ISubscriptionService {
|
|||
*
|
||||
*/
|
||||
@Override
|
||||
public SubscriptionServiceResult update(final Subscription subscription,
|
||||
public SubscriptionServiceResult update(final String username, final Subscription subscription,
|
||||
IForceApplyPromptDisplayText displayTextStrategy)
|
||||
throws RegistryHandlerException {
|
||||
|
||||
|
@ -355,20 +356,20 @@ public class SubscriptionService implements ISubscriptionService {
|
|||
@Override
|
||||
public String call() throws RegistryHandlerException {
|
||||
subscription.setUnscheduled(false);
|
||||
DataDeliveryHandlers.getSubscriptionHandler().update(
|
||||
DataDeliveryHandlers.getSubscriptionHandler().update(username,
|
||||
subscription);
|
||||
return successMessage;
|
||||
}
|
||||
};
|
||||
|
||||
return performAction(subscriptions, action, displayTextStrategy);
|
||||
return performAction(username, subscriptions, action, displayTextStrategy);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public SubscriptionServiceResult update(final List<Subscription> subs,
|
||||
public SubscriptionServiceResult update(final String username, final List<Subscription> subs,
|
||||
IForceApplyPromptDisplayText displayTextStrategy)
|
||||
throws RegistryHandlerException {
|
||||
|
||||
|
@ -378,20 +379,20 @@ public class SubscriptionService implements ISubscriptionService {
|
|||
public String call() throws RegistryHandlerException {
|
||||
for (Subscription sub : subs) {
|
||||
sub.setUnscheduled(false);
|
||||
DataDeliveryHandlers.getSubscriptionHandler().update(sub);
|
||||
DataDeliveryHandlers.getSubscriptionHandler().update(username, sub);
|
||||
}
|
||||
return successMessage;
|
||||
}
|
||||
};
|
||||
|
||||
return performAction(subs, action, displayTextStrategy);
|
||||
return performAction(username, subs, action, displayTextStrategy);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public SubscriptionServiceResult updateWithPendingCheck(
|
||||
public SubscriptionServiceResult updateWithPendingCheck(String username,
|
||||
final List<Subscription> subscriptions,
|
||||
IForceApplyPromptDisplayText displayTextStrategy)
|
||||
throws RegistryHandlerException {
|
||||
|
@ -445,7 +446,7 @@ public class SubscriptionService implements ISubscriptionService {
|
|||
if (authorized) {
|
||||
subscription.setUnscheduled(false);
|
||||
DataDeliveryHandlers.getSubscriptionHandler()
|
||||
.update(subscription);
|
||||
.update(username, subscription);
|
||||
} else {
|
||||
PendingSubscription pendingSub = subscription
|
||||
.pending(username);
|
||||
|
@ -487,14 +488,14 @@ public class SubscriptionService implements ISubscriptionService {
|
|||
}
|
||||
};
|
||||
|
||||
return performAction(subscriptions, action, displayTextStrategy);
|
||||
return performAction(username, subscriptions, action, displayTextStrategy);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public SubscriptionServiceResult store(final AdhocSubscription sub,
|
||||
public SubscriptionServiceResult store(final String username, final AdhocSubscription sub,
|
||||
IForceApplyPromptDisplayText displayTextStrategy)
|
||||
throws RegistryHandlerException {
|
||||
|
||||
|
@ -504,12 +505,12 @@ public class SubscriptionService implements ISubscriptionService {
|
|||
final ServiceInteraction action = new ServiceInteraction() {
|
||||
@Override
|
||||
public String call() throws RegistryHandlerException {
|
||||
DataDeliveryHandlers.getSubscriptionHandler().store(sub);
|
||||
DataDeliveryHandlers.getSubscriptionHandler().store(username, sub);
|
||||
return successMessage;
|
||||
}
|
||||
};
|
||||
|
||||
SubscriptionServiceResult result = performAction(subscriptions, action,
|
||||
SubscriptionServiceResult result = performAction(username, subscriptions, action,
|
||||
displayTextStrategy);
|
||||
if (!result.isAllowFurtherEditing()) {
|
||||
Date date = bandwidthService.getEstimatedCompletionTime(sub);
|
||||
|
@ -538,7 +539,7 @@ public class SubscriptionService implements ISubscriptionService {
|
|||
* @return the result object
|
||||
* @throws RegistryHandlerException
|
||||
*/
|
||||
private SubscriptionServiceResult performAction(
|
||||
private SubscriptionServiceResult performAction(String username,
|
||||
List<Subscription> subscriptions, ServiceInteraction action,
|
||||
final IForceApplyPromptDisplayText displayTextStrategy)
|
||||
throws RegistryHandlerException {
|
||||
|
@ -610,7 +611,7 @@ public class SubscriptionService implements ISubscriptionService {
|
|||
|
||||
final Set<String> unscheduled = bandwidthService
|
||||
.schedule(subscriptions);
|
||||
updateSubscriptionsByNameToUnscheduled(unscheduled);
|
||||
updateSubscriptionsByNameToUnscheduled(username, unscheduled);
|
||||
|
||||
StringBuilder sb = new StringBuilder(successMessage);
|
||||
getUnscheduledSubscriptionsPortion(sb, unscheduled);
|
||||
|
@ -767,14 +768,14 @@ public class SubscriptionService implements ISubscriptionService {
|
|||
*/
|
||||
private void savePendingSub(PendingSubscription pendingSub, String username)
|
||||
throws RegistryHandlerException {
|
||||
DataDeliveryHandlers.getPendingSubscriptionHandler().store(pendingSub);
|
||||
DataDeliveryHandlers.getPendingSubscriptionHandler().store(username, pendingSub);
|
||||
|
||||
notificationService
|
||||
.sendCreatedPendingSubscriptionForSubscriptionNotification(
|
||||
pendingSub, username);
|
||||
}
|
||||
|
||||
private void updateSubscriptionsByNameToUnscheduled(
|
||||
private void updateSubscriptionsByNameToUnscheduled(String username,
|
||||
java.util.Collection<String> subscriptionNames)
|
||||
throws RegistryHandlerException {
|
||||
ISubscriptionHandler subscriptionHandler = DataDeliveryHandlers
|
||||
|
@ -790,7 +791,7 @@ public class SubscriptionService implements ISubscriptionService {
|
|||
((RecurringSubscription) unscheduledSub)
|
||||
.setSubscriptionState(SubscriptionState.OFF);
|
||||
}
|
||||
subscriptionHandler.update(unscheduledSub);
|
||||
subscriptionHandler.update(username, unscheduledSub);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -866,7 +866,7 @@ public class SubscriptionTableComp extends TableComp implements IGroupAction {
|
|||
.isAuthorized()) {
|
||||
sub.getOfficeIDs().add(CURRENT_SITE);
|
||||
DataDeliveryHandlers.getSubscriptionHandler()
|
||||
.update(sub);
|
||||
.update(user.uniqueId().toString(), sub);
|
||||
}
|
||||
} catch (AuthException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
|
|
|
@ -95,6 +95,7 @@ import com.raytheon.viz.ui.presenter.IDisplay;
|
|||
* Jul 26, 2013 2232 mpduff Refactored Data Delivery permissions.
|
||||
* Sep 03, 2013 2315 mpduff Add subscription name to denied approval message.
|
||||
* Oct 23, 2013 2292 mpduff Move subscription overlap checks to edex.
|
||||
* Mar 31, 2014 2889 dhladky Added username for notification center tracking.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -532,7 +533,7 @@ public class SubscriptionApprovalDlg extends CaveSWTDialog implements
|
|||
String exceptionMessage = "Unable to update subscription.";
|
||||
try {
|
||||
SubscriptionServiceResult result = subscriptionService
|
||||
.update(s,
|
||||
.update(username, s,
|
||||
new ApproveSubscriptionForceApplyPromptDisplayText());
|
||||
if (result.hasMessageToDisplay()) {
|
||||
DataDeliveryUtils.showMessage(getShell(), SWT.OK,
|
||||
|
|
|
@ -146,6 +146,7 @@ import com.raytheon.viz.ui.presenter.IDisplay;
|
|||
* Feb 26, 2014 #2833 lvenable Added code to prevent the Subset (this) dialog from
|
||||
* disappearing when the Subscription button is double clicked.
|
||||
* Added dispose check for subscription button.
|
||||
* Mar 31, 2014 2889 dhladky Added username for notification center tracking.
|
||||
* </pre>
|
||||
*
|
||||
* @author mpduff
|
||||
|
@ -552,7 +553,8 @@ public abstract class SubsetManagerDlg extends CaveSWTDialog implements
|
|||
}
|
||||
try {
|
||||
as.setSubscriptionType(SubscriptionType.QUERY);
|
||||
SubscriptionServiceResult result = subscriptionService.store(
|
||||
SubscriptionServiceResult result = subscriptionService.store(LocalizationManager.getInstance()
|
||||
.getCurrentUser(),
|
||||
as, this);
|
||||
|
||||
if (result.hasMessageToDisplay()) {
|
||||
|
|
|
@ -36,6 +36,7 @@ import com.raytheon.uf.common.datadelivery.registry.Subscription;
|
|||
import com.raytheon.uf.common.datadelivery.registry.ebxml.SubscriptionDataSetNameQuery;
|
||||
import com.raytheon.uf.common.datadelivery.registry.ebxml.SubscriptionFilterableQuery;
|
||||
import com.raytheon.uf.common.registry.RegistryQueryResponse;
|
||||
import com.raytheon.uf.common.registry.ebxml.RegistryUtil;
|
||||
import com.raytheon.uf.common.registry.handler.BaseRegistryObjectHandler;
|
||||
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
|
||||
import com.raytheon.uf.common.registry.handler.RegistryObjectHandlers;
|
||||
|
@ -63,6 +64,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
|
|||
* Jan 14, 2014 2459 mpduff Validate subs should be scheduled before returning them.
|
||||
* Jan 17, 2014 2459 mpduff Persist the state of the expired subs.
|
||||
* Jan 29, 2014 2636 mpduff Scheduling refactor.
|
||||
* Mar 31, 2014 2889 dhladky Added username for notification center tracking.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -241,7 +243,7 @@ public abstract class BaseSubscriptionHandler<T extends Subscription, QUERY exte
|
|||
.get(ISubscriptionHandler.class);
|
||||
for (T s : updateList) {
|
||||
try {
|
||||
sh.update(s);
|
||||
sh.update(RegistryUtil.registryUser, s);
|
||||
statusHandler.info("Subscription "
|
||||
+ s.getName() + " is expired.");
|
||||
} catch (RegistryHandlerException e) {
|
||||
|
|
|
@ -58,6 +58,7 @@ import com.raytheon.uf.common.util.CollectionUtil;
|
|||
* Jun 04, 2013 223 mpduff Added datatype to the filter.
|
||||
* Jun 24, 2013 2106 djohnson Now composes a registryHandler.
|
||||
* Oct 09, 2013 2267 bgonzale Fix Collection cast to List error.
|
||||
* Mar 31, 2014 2889 dhladky Added username for notification center tracking.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -76,15 +77,15 @@ public class DataSetHandler extends
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void store(DataSet obj) throws RegistryHandlerException {
|
||||
public void store(String username, DataSet obj) throws RegistryHandlerException {
|
||||
try {
|
||||
super.store(obj);
|
||||
super.store(username, obj);
|
||||
} catch (RegistryHandlerException e) {
|
||||
boolean tryAgain = handleUnresolvedReferences(obj, e);
|
||||
|
||||
if (tryAgain) {
|
||||
try {
|
||||
super.store(obj);
|
||||
super.store(username, obj);
|
||||
} catch (RegistryHandlerException e1) {
|
||||
throw e1;
|
||||
}
|
||||
|
@ -98,15 +99,15 @@ public class DataSetHandler extends
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void update(DataSet obj) throws RegistryHandlerException {
|
||||
public void update(String username, DataSet obj) throws RegistryHandlerException {
|
||||
try {
|
||||
super.update(obj);
|
||||
super.update(username, obj);
|
||||
} catch (RegistryHandlerException e) {
|
||||
boolean tryAgain = handleUnresolvedReferences(obj, e);
|
||||
|
||||
if (tryAgain) {
|
||||
try {
|
||||
super.update(obj);
|
||||
super.update(username, obj);
|
||||
} catch (RegistryHandlerException e1) {
|
||||
throw e1;
|
||||
}
|
||||
|
@ -169,7 +170,7 @@ public class DataSetHandler extends
|
|||
// non-gridded data...
|
||||
try {
|
||||
DataDeliveryHandlers.getParameterHandler()
|
||||
.update(p);
|
||||
.update(RegistryUtil.registryUser, p);
|
||||
} catch (RegistryHandlerException e1) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 20, 2014 2538 mpduff Initial creation
|
||||
* Jan 29, 2014 2636 mpduff Scheduling refactor.
|
||||
* Mar 31, 2014 2889 dhladky Added username for notification center tracking.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -124,13 +125,13 @@ public class EmptyAdhocSubscriptionHandler implements IAdhocSubscriptionHandler
|
|||
}
|
||||
|
||||
@Override
|
||||
public void store(AdhocSubscription obj) throws RegistryHandlerException {
|
||||
public void store(String username, AdhocSubscription obj) throws RegistryHandlerException {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(AdhocSubscription obj) throws RegistryHandlerException {
|
||||
public void update(String username, AdhocSubscription obj) throws RegistryHandlerException {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@ import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Nov 04, 2013 2545 bgonzale Initial creation
|
||||
* Jan 29, 2014 2636 mpduff Scheduling refactor.
|
||||
* Mar 31, 2014 2889 dhladky Added username for notification center tracking.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -236,7 +237,7 @@ public class EmptySharedSubscriptionHandler implements
|
|||
* java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public void store(SharedSubscription obj) throws RegistryHandlerException {
|
||||
public void store(String username, SharedSubscription obj) throws RegistryHandlerException {
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -247,7 +248,7 @@ public class EmptySharedSubscriptionHandler implements
|
|||
* (java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public void update(SharedSubscription obj) throws RegistryHandlerException {
|
||||
public void update(String username, SharedSubscription obj) throws RegistryHandlerException {
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -44,6 +44,7 @@ import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Nov 04, 2013 2545 bgonzale Initial creation
|
||||
* Jan 29, 2014 2636 mpduff Scheduling refactor.
|
||||
* Mar 31, 2014 2889 dhladky Added username for notification center tracking.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -234,7 +235,7 @@ public class EmptySiteSubscriptionHandler implements ISiteSubscriptionHandler {
|
|||
* java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public void store(SiteSubscription obj) throws RegistryHandlerException {
|
||||
public void store(String username, SiteSubscription obj) throws RegistryHandlerException {
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -245,7 +246,7 @@ public class EmptySiteSubscriptionHandler implements ISiteSubscriptionHandler {
|
|||
* (java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public void update(SiteSubscription obj) throws RegistryHandlerException {
|
||||
public void update(String username, SiteSubscription obj) throws RegistryHandlerException {
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -48,6 +48,7 @@ import com.raytheon.uf.common.status.UFStatus;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 03, 2012 1241 djohnson Initial creation
|
||||
* Jun 24, 2013 2106 djohnson Now composes a registryHandler.
|
||||
* Mar 31, 2014 2889 dhladky Added username for notification center tracking.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -75,19 +76,19 @@ public class ParameterHandler extends
|
|||
* ParameterLevel Objects needed to successfully store the Parameter Object.
|
||||
*/
|
||||
@Override
|
||||
public void store(Parameter obj) throws RegistryHandlerException {
|
||||
public void store(String username, Parameter obj) throws RegistryHandlerException {
|
||||
final String parameterName = obj.getName();
|
||||
try {
|
||||
super.store(obj);
|
||||
super.store(username, obj);
|
||||
|
||||
statusHandler.info(String.format(SUCCESSFULLY_STORED_PARAMETER,
|
||||
parameterName));
|
||||
} catch (RegistryHandlerException e) {
|
||||
boolean tryAgain = handleUnresolvedReferences(obj, e);
|
||||
boolean tryAgain = handleUnresolvedReferences(username, obj, e);
|
||||
|
||||
if (tryAgain) {
|
||||
try {
|
||||
super.store(obj);
|
||||
super.store(username, obj);
|
||||
|
||||
statusHandler.info(String.format(
|
||||
SUCCESSFULLY_STORED_PARAMETER, parameterName));
|
||||
|
@ -109,19 +110,19 @@ public class ParameterHandler extends
|
|||
* ParameterLevel Objects needed to successfully store the Parameter Object.
|
||||
*/
|
||||
@Override
|
||||
public void update(Parameter obj) throws RegistryHandlerException {
|
||||
public void update(String username, Parameter obj) throws RegistryHandlerException {
|
||||
final String parameterName = obj.getName();
|
||||
try {
|
||||
super.update(obj);
|
||||
super.update(username, obj);
|
||||
|
||||
statusHandler.info(String.format(SUCCESSFULLY_UPDATED_PARAMETER,
|
||||
parameterName));
|
||||
} catch (RegistryHandlerException e) {
|
||||
boolean tryAgain = handleUnresolvedReferences(obj, e);
|
||||
boolean tryAgain = handleUnresolvedReferences(username, obj, e);
|
||||
|
||||
if (tryAgain) {
|
||||
try {
|
||||
super.update(obj);
|
||||
super.update(username, obj);
|
||||
|
||||
statusHandler.info(String.format(
|
||||
SUCCESSFULLY_UPDATED_PARAMETER, parameterName));
|
||||
|
@ -153,7 +154,7 @@ public class ParameterHandler extends
|
|||
return response.getResults();
|
||||
}
|
||||
|
||||
private boolean handleUnresolvedReferences(Parameter obj,
|
||||
private boolean handleUnresolvedReferences(String username, Parameter obj,
|
||||
RegistryHandlerException e) {
|
||||
boolean restore = false;
|
||||
|
||||
|
@ -175,7 +176,7 @@ public class ParameterHandler extends
|
|||
pl.setLevelId(Integer.parseInt(parts[0]));
|
||||
pl.setLevelValue(Double.parseDouble(parts[1]));
|
||||
try {
|
||||
DataDeliveryHandlers.getParameterLevelHandler().update(
|
||||
DataDeliveryHandlers.getParameterLevelHandler().update(username,
|
||||
pl);
|
||||
statusHandler
|
||||
.info("Successfully stored ParameterLevel "
|
||||
|
|
|
@ -57,6 +57,7 @@ import com.raytheon.uf.common.util.CollectionUtil;
|
|||
* May 29, 2013 1650 djohnson Fix ability to delete multiple types of subscriptions at once.
|
||||
* Sep 11, 2013 2352 mpduff Add siteId to getSubscribedToDataSetNames method.
|
||||
* Jan 29, 2014 2636 mpduff Scheduling refactor.
|
||||
* Mar 31, 2014 2889 dhladky Added username for notification center tracking.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -250,13 +251,13 @@ public class PendingSubscriptionHandler implements IPendingSubscriptionHandler {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void store(InitialPendingSubscription obj)
|
||||
public void store(String username, InitialPendingSubscription obj)
|
||||
throws RegistryHandlerException {
|
||||
if (obj instanceof InitialPendingSiteSubscription) {
|
||||
siteSubscriptionHandler.store((InitialPendingSiteSubscription) obj);
|
||||
siteSubscriptionHandler.store(username, (InitialPendingSiteSubscription) obj);
|
||||
} else {
|
||||
sharedSubscriptionHandler
|
||||
.store((InitialPendingSharedSubscription) obj);
|
||||
.store(username, (InitialPendingSharedSubscription) obj);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -264,14 +265,14 @@ public class PendingSubscriptionHandler implements IPendingSubscriptionHandler {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void update(InitialPendingSubscription obj)
|
||||
public void update(String username, InitialPendingSubscription obj)
|
||||
throws RegistryHandlerException {
|
||||
if (obj instanceof InitialPendingSiteSubscription) {
|
||||
siteSubscriptionHandler
|
||||
.update((InitialPendingSiteSubscription) obj);
|
||||
.update(username, (InitialPendingSiteSubscription) obj);
|
||||
} else {
|
||||
sharedSubscriptionHandler
|
||||
.update((InitialPendingSharedSubscription) obj);
|
||||
.update(username, (InitialPendingSharedSubscription) obj);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -63,6 +63,7 @@ import com.raytheon.uf.common.util.CollectionUtil;
|
|||
* Sep 11, 2013 2352 mpduff Add siteId to getSubscribedToDataSetNames method.
|
||||
* Jan 20, 2014 2538 mpduff Added AdhocSubscriptionHandler.
|
||||
* Jan 29, 2014 2636 mpduff Scheduling refactor.
|
||||
* Mar 31, 2014 2889 dhladky Added username for notification center tracking.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -321,11 +322,11 @@ public class SubscriptionHandler implements ISubscriptionHandler {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void store(Subscription obj) throws RegistryHandlerException {
|
||||
public void store(String username, Subscription obj) throws RegistryHandlerException {
|
||||
if (obj instanceof SiteSubscription) {
|
||||
siteSubscriptionHandler.store((SiteSubscription) obj);
|
||||
siteSubscriptionHandler.store(username, (SiteSubscription) obj);
|
||||
} else {
|
||||
sharedSubscriptionHandler.store((SharedSubscription) obj);
|
||||
sharedSubscriptionHandler.store(username, (SharedSubscription) obj);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -333,11 +334,11 @@ public class SubscriptionHandler implements ISubscriptionHandler {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void update(Subscription obj) throws RegistryHandlerException {
|
||||
public void update(String username, Subscription obj) throws RegistryHandlerException {
|
||||
if (obj instanceof SiteSubscription) {
|
||||
siteSubscriptionHandler.update((SiteSubscription) obj);
|
||||
siteSubscriptionHandler.update(username, (SiteSubscription) obj);
|
||||
} else {
|
||||
sharedSubscriptionHandler.update((SharedSubscription) obj);
|
||||
sharedSubscriptionHandler.update(username, (SharedSubscription) obj);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ import com.raytheon.uf.common.registry.ebxml.IdQuery;
|
|||
* Aug 02, 2012 955 djohnson Type-safe registry query/responses.
|
||||
* Aug 20, 2012 0743 djohnson Finish making registry type-safe.
|
||||
* Sep 14, 2012 1169 djohnson Must call specific method to allow replace of an object.
|
||||
* Mar 31, 2014 2889 dhladky Added username for notification center tracking.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -109,7 +110,7 @@ public interface RegistryHandler {
|
|||
* @see Object
|
||||
*
|
||||
*/
|
||||
<T> RegistryResponse<T> storeObject(T object);
|
||||
<T> RegistryResponse<T> storeObject(String username, T object);
|
||||
|
||||
/**
|
||||
* Store an Object to the registry, replacing any existing Object with the
|
||||
|
@ -126,6 +127,6 @@ public interface RegistryHandler {
|
|||
* @see Object
|
||||
*
|
||||
*/
|
||||
<T> RegistryResponse<T> storeOrReplaceObject(T object);
|
||||
<T> RegistryResponse<T> storeOrReplaceObject(String username, T object);
|
||||
|
||||
}
|
|
@ -80,6 +80,7 @@ import com.raytheon.uf.common.util.ReflectionException;
|
|||
* 4/9/2013 1802 bphillip Modified to use constants in constants package instead of RegistryUtil
|
||||
* Apr 24, 2013 1910 djohnson RegistryResponseStatus is now an enum.
|
||||
* Jun 24, 2013 2106 djohnson Requires a transaction to already be active.
|
||||
* Mar 31, 2014 2889 dhladky Added username for notification center tracking.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -629,7 +630,7 @@ public class FactoryRegistryHandler implements RegistryHandler {
|
|||
*
|
||||
*/
|
||||
@Override
|
||||
public RegistryResponse<Object> storeObject(final Object object) {
|
||||
public RegistryResponse<Object> storeObject(final String username, final Object object) {
|
||||
final RegistryResponse<Object> response = new RegistryResponse<Object>();
|
||||
final Callable<RegistryResponse<Object>> request = new Callable<RegistryResponse<Object>>() {
|
||||
@Override
|
||||
|
@ -637,7 +638,7 @@ public class FactoryRegistryHandler implements RegistryHandler {
|
|||
LifecycleManager lcm = lifecycleManagerFactory
|
||||
.getLifeCycleManager();
|
||||
QueryManager qm = queryManagerFactory.getQueryManager();
|
||||
List<Object> a = store(lcm, qm, object, Mode.CREATE_ONLY);
|
||||
List<Object> a = store(lcm, qm, username, object, Mode.CREATE_ONLY);
|
||||
response.setRegistryObjects(a);
|
||||
|
||||
return response;
|
||||
|
@ -652,7 +653,7 @@ public class FactoryRegistryHandler implements RegistryHandler {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public RegistryResponse<Object> storeOrReplaceObject(final Object object) {
|
||||
public RegistryResponse<Object> storeOrReplaceObject(final String username, final Object object) {
|
||||
final RegistryResponse<Object> response = new RegistryResponse<Object>();
|
||||
final Callable<RegistryResponse<Object>> request = new Callable<RegistryResponse<Object>>() {
|
||||
@Override
|
||||
|
@ -660,7 +661,7 @@ public class FactoryRegistryHandler implements RegistryHandler {
|
|||
LifecycleManager lcm = lifecycleManagerFactory
|
||||
.getLifeCycleManager();
|
||||
QueryManager qm = queryManagerFactory.getQueryManager();
|
||||
List<Object> a = store(lcm, qm, object, Mode.CREATE_OR_REPLACE);
|
||||
List<Object> a = store(lcm, qm, username, object, Mode.CREATE_OR_REPLACE);
|
||||
response.setRegistryObjects(a);
|
||||
|
||||
return response;
|
||||
|
@ -698,7 +699,7 @@ public class FactoryRegistryHandler implements RegistryHandler {
|
|||
*
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private <T> List<T> store(LifecycleManager lcm, QueryManager qm, T object,
|
||||
private <T> List<T> store(LifecycleManager lcm, QueryManager qm, String username, T object,
|
||||
Mode mode) throws MsgRegistryException, JAXBException,
|
||||
IllegalArgumentException, ReflectionException,
|
||||
SerializationException {
|
||||
|
@ -780,13 +781,13 @@ public class FactoryRegistryHandler implements RegistryHandler {
|
|||
idQuery.setID(classificationNode.getId());
|
||||
objects = getRawObjects(qm, idQuery);
|
||||
if (objects.isEmpty()) {
|
||||
rt = submitObjects(lcm, Arrays.asList(classificationNode));
|
||||
rt = submitObjects(lcm, Arrays.asList(classificationNode), username);
|
||||
if (!RegistryResponseStatus.SUCCESS.equals(rt.getStatus())) {
|
||||
throwUnsuccessfulResponseException(rt);
|
||||
}
|
||||
}
|
||||
|
||||
rt = submitObjects(lcm, Arrays.asList(registryObject));
|
||||
rt = submitObjects(lcm, Arrays.asList(registryObject), username);
|
||||
if (!RegistryResponseStatus.SUCCESS.equals(rt.getStatus())) {
|
||||
throwUnsuccessfulResponseException(rt);
|
||||
}
|
||||
|
@ -801,7 +802,7 @@ public class FactoryRegistryHandler implements RegistryHandler {
|
|||
association.setOwner(registryObject.getOwner());
|
||||
}
|
||||
if (!associations.isEmpty()) {
|
||||
rt = submitObjects(lcm, associations, mode);
|
||||
rt = submitObjects(lcm, associations, username, mode);
|
||||
}
|
||||
|
||||
if (!RegistryResponseStatus.SUCCESS.equals(rt.getStatus())) {
|
||||
|
@ -874,14 +875,14 @@ public class FactoryRegistryHandler implements RegistryHandler {
|
|||
dependentObjects);
|
||||
|
||||
if (!associationsToAdd.isEmpty()) {
|
||||
rt = submitObjects(lcm, associationsToAdd, mode);
|
||||
rt = submitObjects(lcm, associationsToAdd, username, mode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Now that the association are worked out, try again with replace
|
||||
// mode set..
|
||||
rt = submitObjects(lcm, Arrays.asList(registryObject), mode);
|
||||
rt = submitObjects(lcm, Arrays.asList(registryObject), username, mode);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Mode [" + mode
|
||||
+ "] is not currently supported!");
|
||||
|
@ -930,9 +931,9 @@ public class FactoryRegistryHandler implements RegistryHandler {
|
|||
*/
|
||||
private RegistryResponseType submitObjects(
|
||||
LifecycleManager lifecycleManager,
|
||||
List<RegistryObjectType> registryObjects)
|
||||
List<RegistryObjectType> registryObjects, String username)
|
||||
throws MsgRegistryException, JAXBException {
|
||||
return submitObjects(lifecycleManager, registryObjects,
|
||||
return submitObjects(lifecycleManager, registryObjects, username,
|
||||
Mode.CREATE_ONLY);
|
||||
}
|
||||
|
||||
|
@ -957,7 +958,7 @@ public class FactoryRegistryHandler implements RegistryHandler {
|
|||
*/
|
||||
private RegistryResponseType submitObjects(
|
||||
LifecycleManager lifecycleManager,
|
||||
List<RegistryObjectType> registryObjects, Mode mode)
|
||||
List<RegistryObjectType> registryObjects, String username, Mode mode)
|
||||
throws MsgRegistryException, JAXBException {
|
||||
|
||||
RegistryResponseType response = new RegistryResponseType();
|
||||
|
@ -976,7 +977,7 @@ public class FactoryRegistryHandler implements RegistryHandler {
|
|||
List<RegistryObjectType> batch = registryObjects.subList(count,
|
||||
(count = Math.min(count + batchSize, lastIndex)));
|
||||
|
||||
SubmitObjectsRequest a = RegistryUtil.newSubmitObjects(batch,
|
||||
SubmitObjectsRequest a = RegistryUtil.newSubmitObjects(batch, username,
|
||||
mode);
|
||||
|
||||
RegistryResponseType rt = lifecycleManager.submitObjects(a);
|
||||
|
|
|
@ -79,6 +79,7 @@ import com.raytheon.uf.common.util.ReflectionUtil;
|
|||
* Jun 03, 2013 2038 djohnson Allow setting the same encoder strategy.
|
||||
* Jun 24, 2013 2106 djohnson Remove encoder strategy from instance variables.
|
||||
* Dec 04, 2013 2584 dhladky Versions for Registry objects
|
||||
* Mar 31, 2014 2889 dhladky Added username for notification center tracking.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -96,6 +97,8 @@ public final class RegistryUtil {
|
|||
public static final String registryObjectClassName = "registryObjectClassName";
|
||||
|
||||
public static final String registryObjectDefaultVersion = "1.0";
|
||||
|
||||
public static final String registryUser = "Registry";
|
||||
|
||||
static {
|
||||
if (System.getenv("EBXML_REGISTRY_HOST") != null
|
||||
|
@ -612,10 +615,11 @@ public final class RegistryUtil {
|
|||
* @return the request
|
||||
*/
|
||||
public static SubmitObjectsRequest newSubmitObjects(
|
||||
List<RegistryObjectType> asList, Mode mode) {
|
||||
List<RegistryObjectType> asList, String username, Mode mode) {
|
||||
SubmitObjectsRequest request = new SubmitObjectsRequest();
|
||||
request.setCheckReferences(false);
|
||||
request.setMode(mode);
|
||||
request.setUsername(username);
|
||||
RegistryObjectListType registryObjectList = new RegistryObjectListType();
|
||||
registryObjectList.getRegistryObject().addAll(asList);
|
||||
request.setRegistryObjectList(registryObjectList);
|
||||
|
|
|
@ -45,6 +45,7 @@ import com.raytheon.uf.common.serialization.comm.response.ServerErrorResponse;
|
|||
* Nov 15, 2012 1322 djohnson Remove ThriftCommunicator in lieu of server-keyed routing.
|
||||
* Dec 03, 2012 1379 djohnson Use registry service keys.
|
||||
* 4/9/2013 1802 bphillip Modified to use constants in constants package instead of RegistryUtil
|
||||
* Mar 31, 2014 2889 dhladky Added username for notification center tracking.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -192,8 +193,9 @@ public class ThriftRegistryHandler implements RegistryHandler {
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> RegistryResponse<T> storeObject(T object) {
|
||||
public <T> RegistryResponse<T> storeObject(String username, T object) {
|
||||
IRegistryRequest<T> request = new IRegistryRequest<T>();
|
||||
request.setUsername(username);
|
||||
request.setObjects(Arrays.<T> asList(object));
|
||||
request.setAction(Action.STORE);
|
||||
|
||||
|
@ -202,8 +204,9 @@ public class ThriftRegistryHandler implements RegistryHandler {
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> RegistryResponse<T> storeOrReplaceObject(T object) {
|
||||
public <T> RegistryResponse<T> storeOrReplaceObject(String username, T object) {
|
||||
IRegistryRequest<T> request = new IRegistryRequest<T>();
|
||||
request.setUsername(username);
|
||||
request.setObjects(Arrays.<T> asList(object));
|
||||
request.setAction(Action.STORE_OR_REPLACE);
|
||||
|
||||
|
|
|
@ -55,6 +55,7 @@ import com.raytheon.uf.common.util.CollectionUtil;
|
|||
* Oct 05, 2012 1195 djohnson Remove executeQuery method, add getById.
|
||||
* 3/18/2013 1802 bphillip Implemented transaction boundaries
|
||||
* Jun 24, 2013 2106 djohnson Composes the registryHandler.
|
||||
* Mar 31, 2014 2889 dhladky Added username for notification center tracking.
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
|
@ -98,9 +99,9 @@ public abstract class BaseRegistryObjectHandler<T, QUERY extends AdhocRegistryQu
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void store(T obj) throws RegistryHandlerException {
|
||||
public void store(String username, T obj) throws RegistryHandlerException {
|
||||
RegistryResponse<T> response = registryHandler
|
||||
.storeObject(obj);
|
||||
.storeObject(username, obj);
|
||||
|
||||
checkResponse(response, obj, "store");
|
||||
}
|
||||
|
@ -109,9 +110,9 @@ public abstract class BaseRegistryObjectHandler<T, QUERY extends AdhocRegistryQu
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void update(T obj) throws RegistryHandlerException {
|
||||
public void update(String username, T obj) throws RegistryHandlerException {
|
||||
RegistryResponse<?> response = registryHandler
|
||||
.storeOrReplaceObject(obj);
|
||||
.storeOrReplaceObject(username, obj);
|
||||
|
||||
checkResponse(response, obj, "update");
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ import com.raytheon.uf.common.registry.annotations.RegistryObject;
|
|||
* Sep 17, 2012 1169 djohnson Initial creation
|
||||
* Sep 21, 2012 1187 djohnson Add bulk delete operations.
|
||||
* Oct 05, 2012 1195 djohnson Remove executeQuery method, add getById.
|
||||
* Mar 31, 2014 2889 dhladky Added username for notification center tracking.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -71,7 +72,7 @@ public interface IRegistryObjectHandler<T> {
|
|||
* @param obj
|
||||
* the object to store
|
||||
*/
|
||||
void store(T obj) throws RegistryHandlerException;
|
||||
void store(String username, T obj) throws RegistryHandlerException;
|
||||
|
||||
/**
|
||||
* Delete a {@link RegistryObject}.
|
||||
|
@ -80,7 +81,7 @@ public interface IRegistryObjectHandler<T> {
|
|||
* the object to store
|
||||
* @throws RegistryHandlerException
|
||||
*/
|
||||
void update(T obj) throws RegistryHandlerException;
|
||||
void update(String username, T obj) throws RegistryHandlerException;
|
||||
|
||||
/**
|
||||
* Delete a {@link RegistryObject}.
|
||||
|
|
|
@ -34,6 +34,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Mar 16, 2012 jsanchez Initial creation
|
||||
* Nov 08, 2013 2506 bgonzale Added constructors.
|
||||
* Mar 31, 2014 2889 dhladky Added username for notification center tracking.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -48,8 +49,8 @@ public class InsertRegistryEvent extends RegistryEvent {
|
|||
|
||||
}
|
||||
|
||||
public InsertRegistryEvent(String id, String lid, String objectType) {
|
||||
super(id, lid, objectType, Action.INSERT);
|
||||
public InsertRegistryEvent(String id, String lid, String username, String objectType) {
|
||||
super(id, lid, objectType, username, Action.INSERT);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -36,6 +36,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Mar 16, 2012 jsanchez Initial creation
|
||||
* Nov 08, 2013 2506 bgonzale Added constructors.
|
||||
* Mar 31, 2014 2889 dhladky Added username for notification center tracking.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -65,10 +66,11 @@ public abstract class RegistryEvent extends Event {
|
|||
* @param objectType
|
||||
* @param action
|
||||
*/
|
||||
public RegistryEvent(String id, String lid, String objectType, Action action) {
|
||||
public RegistryEvent(String id, String lid, String objectType, String username, Action action) {
|
||||
super(id);
|
||||
this.lid = lid;
|
||||
this.objectType = objectType;
|
||||
this.username = username;
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
|
@ -80,6 +82,9 @@ public abstract class RegistryEvent extends Event {
|
|||
|
||||
@DynamicSerializeElement
|
||||
private Action action;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private String username;
|
||||
|
||||
public void setObjectType(String objectType) {
|
||||
this.objectType = objectType;
|
||||
|
@ -110,4 +115,13 @@ public abstract class RegistryEvent extends Event {
|
|||
public void setAction(Action action) {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
|||
* Mar 16, 2012 jsanchez Initial creation
|
||||
* Nov 08, 2013 2506 bgonzale Added constructors. Added object deleted field.
|
||||
* Added RegistryObjectType field.
|
||||
* Mar 31, 2014 2889 dhladky Added username for notification center tracking.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -48,8 +49,6 @@ public class RemoveRegistryEvent extends RegistryEvent {
|
|||
|
||||
private static final long serialVersionUID = -5854149256576746509L;
|
||||
|
||||
private String username;
|
||||
|
||||
private RegistryObjectType removedObject;
|
||||
|
||||
public RemoveRegistryEvent() {
|
||||
|
@ -58,19 +57,10 @@ public class RemoveRegistryEvent extends RegistryEvent {
|
|||
|
||||
public RemoveRegistryEvent(String username, String id,
|
||||
RegistryObjectType removedObject) {
|
||||
super(id, null, null, Action.DELETE);
|
||||
this.username = username;
|
||||
super(id, null, null, username, Action.DELETE);
|
||||
this.removedObject = removedObject;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the removedObject
|
||||
*/
|
||||
|
|
|
@ -34,6 +34,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Mar 16, 2012 jsanchez Initial creation
|
||||
* Nov 08, 2013 2506 bgonzale Added constructors.
|
||||
* Mar 31, 2014 2889 dhladky Added username for notification center tracking.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -48,7 +49,7 @@ public class UpdateRegistryEvent extends RegistryEvent {
|
|||
|
||||
}
|
||||
|
||||
public UpdateRegistryEvent(String id, String lid, String objectType) {
|
||||
super(id, lid, objectType, Action.UPDATE);
|
||||
public UpdateRegistryEvent(String id, String lid, String username, String objectType) {
|
||||
super(id, lid, objectType, username, Action.UPDATE);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@ import javax.persistence.Entity;
|
|||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Transient;
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
|
@ -81,6 +80,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
|||
* 2012 bphillip Initial implementation
|
||||
* 10/17/2013 1682 bphillip Added software history
|
||||
* 12/2/2013 1829 bphillip Added Hibernate annotations
|
||||
* Mar 31, 2014 2889 dhladky Added username for notification center tracking.
|
||||
* </pre>
|
||||
*
|
||||
* @author bphillip
|
||||
|
@ -120,7 +120,6 @@ public class RemoveObjectsRequest extends RegistryRequestType {
|
|||
@DynamicSerializeElement
|
||||
protected String deletionScope;
|
||||
|
||||
@Transient
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
protected String username;
|
||||
|
|
|
@ -77,6 +77,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
|||
* 2012 bphillip Initial implementation
|
||||
* 10/17/2013 1682 bphillip Added software history
|
||||
* 12/2/2013 1829 bphillip Added Hibernate annotations
|
||||
* Mar 31, 2014 2889 dhladky Added username for notification center tracking.
|
||||
* </pre>
|
||||
*
|
||||
* @author bphillip
|
||||
|
@ -105,6 +106,10 @@ public class SubmitObjectsRequest extends RegistryRequestType {
|
|||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
protected Mode mode;
|
||||
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
protected String username;
|
||||
|
||||
public SubmitObjectsRequest() {
|
||||
super();
|
||||
|
@ -237,6 +242,13 @@ public class SubmitObjectsRequest extends RegistryRequestType {
|
|||
return false;
|
||||
} else if (!registryObjectList.equals(other.registryObjectList))
|
||||
return false;
|
||||
if (username != null) {
|
||||
if (other.username != null) {
|
||||
return false;
|
||||
} else if (!username.equals(other.username)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -256,7 +268,18 @@ public class SubmitObjectsRequest extends RegistryRequestType {
|
|||
builder.append(", \nmode=");
|
||||
builder.append(mode);
|
||||
builder.append("]");
|
||||
builder.append(", \nusername=");
|
||||
builder.append(username);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -82,6 +82,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
|||
* 2012 bphillip Initial implementation
|
||||
* 10/17/2013 1682 bphillip Added software history
|
||||
* 12/2/2013 1829 bphillip Added Hibernate annotations
|
||||
* Mar 31, 2014 2889 dhladky Added username for notification center tracking.
|
||||
* </pre>
|
||||
*
|
||||
* @author bphillip
|
||||
|
@ -121,6 +122,10 @@ public class UpdateObjectsRequest extends RegistryRequestType {
|
|||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
protected Mode mode;
|
||||
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
protected String username;
|
||||
|
||||
public UpdateObjectsRequest() {
|
||||
super();
|
||||
|
@ -315,6 +320,13 @@ public class UpdateObjectsRequest extends RegistryRequestType {
|
|||
return false;
|
||||
} else if (!updateAction.equals(other.updateAction))
|
||||
return false;
|
||||
if (username != null) {
|
||||
if (other.username != null) {
|
||||
return false;
|
||||
} else if (!username.equals(other.username)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -338,7 +350,18 @@ public class UpdateObjectsRequest extends RegistryRequestType {
|
|||
builder.append(", \nmode=");
|
||||
builder.append(mode);
|
||||
builder.append("]");
|
||||
builder.append(", \nusername=");
|
||||
builder.append(username);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -127,6 +127,7 @@ import com.raytheon.uf.edex.datadelivery.util.DataDeliveryIdUtil;
|
|||
* Feb 11, 2014 2771 bgonzale Use Data Delivery ID instead of Site.
|
||||
* Feb 10, 2014 2636 mpduff Pass Network map to be scheduled.
|
||||
* Feb 21, 2014, 2636 dhladky Try catch to keep MaintTask from dying.
|
||||
* Mar 31, 2014 2889 dhladky Added username for notification center tracking.
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
|
@ -406,17 +407,17 @@ public abstract class EdexBandwidthManager<T extends Time, C extends Coverage>
|
|||
case UPDATE:
|
||||
subscriptionNotificationService
|
||||
.sendUpdatedSubscriptionNotification(sub,
|
||||
sub.getOwner());
|
||||
event.getUsername());
|
||||
break;
|
||||
case INSERT:
|
||||
subscriptionNotificationService
|
||||
.sendCreatedSubscriptionNotification(sub,
|
||||
sub.getOwner());
|
||||
event.getUsername());
|
||||
break;
|
||||
case DELETE:
|
||||
subscriptionNotificationService
|
||||
.sendDeletedSubscriptionNotification(sub,
|
||||
sub.getOwner());
|
||||
event.getUsername());
|
||||
break;
|
||||
default:
|
||||
statusHandler.handle(
|
||||
|
|
|
@ -27,6 +27,7 @@ import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel
|
|||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
|
||||
import com.raytheon.uf.common.localization.LocalizationFile;
|
||||
import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||
import com.raytheon.uf.common.registry.ebxml.RegistryUtil;
|
||||
import com.raytheon.uf.common.serialization.SerializationException;
|
||||
import com.raytheon.uf.common.serialization.SerializationUtil;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
|
@ -65,6 +66,7 @@ import com.raytheon.uf.edex.registry.ebxml.init.RegistryInitializedListener;
|
|||
* 3/18/2013 1802 bphillip Modified to insert provider object after database is initialized
|
||||
* Jun 24, 2013 2106 djohnson Accepts ProviderHandler as a constructor argument.
|
||||
* Oct 28, 2013 2361 dhladky Fixed up JAXBManager.
|
||||
* Mar 31, 2014 2889 dhladky Added username for notification center tracking.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -169,7 +171,7 @@ public class CrawlMetaDataHandler implements RegistryInitializedListener {
|
|||
statusHandler.info("Inserting/Updating Provider: "
|
||||
+ provider.getName() + ": "
|
||||
+ provider.getServiceType());
|
||||
providerHandler.update(provider);
|
||||
providerHandler.update(RegistryUtil.registryUser, provider);
|
||||
|
||||
} catch (Exception e) {
|
||||
statusHandler.error("Error inserting/updating Provider! ",
|
||||
|
|
|
@ -153,6 +153,7 @@ import com.raytheon.uf.edex.registry.events.CreateAuditTrailEvent;
|
|||
* 1/21/2014 2613 bphillip Changed max down time which requires a sync
|
||||
* Feb 11, 2014 2771 bgonzale Use Data Delivery ID instead of Site.
|
||||
* 2/13/2014 2769 bphillip Refactored registry sync. Created quartz tasks to monitor registry uptime as well as subscription integrity
|
||||
* Mar 31, 2014 2889 dhladky Added username for notification center tracking.
|
||||
* </pre>
|
||||
*
|
||||
* @author bphillip
|
||||
|
@ -1077,6 +1078,7 @@ public class RegistryFederationManager implements IRegistryFederationManager,
|
|||
registryObjectDao.getById(objIds));
|
||||
request.setCheckReferences(false);
|
||||
request.setMode(Mode.CREATE_OR_REPLACE);
|
||||
request.setUsername(RegistryUtil.registryUser);
|
||||
request.getSlot().add(
|
||||
new SlotType(EbxmlObjectUtil.EVENT_SOURCE_SLOT,
|
||||
new StringValueType(DataDeliveryIdUtil
|
||||
|
|
|
@ -51,6 +51,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
import com.raytheon.uf.common.datadelivery.registry.web.IRegistryDataAccessService;
|
||||
import com.raytheon.uf.common.registry.RegistryException;
|
||||
import com.raytheon.uf.common.registry.constants.CanonicalQueryTypes;
|
||||
import com.raytheon.uf.common.registry.ebxml.RegistryUtil;
|
||||
import com.raytheon.uf.common.registry.services.rest.response.RestCollectionResponse;
|
||||
import com.raytheon.uf.common.serialization.JAXBManager;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
|
@ -78,6 +79,7 @@ import com.raytheon.uf.edex.registry.ebxml.services.query.RegistryQueryUtil;
|
|||
* 10/2/2013 2385 bphillip Fixed subscription backup queries
|
||||
* 10/8/2013 1682 bphillip Added query queries
|
||||
* 11/7/2013 1678 bphillip Added getCustomQueries method
|
||||
* Mar 31, 2014 2889 dhladky Added username for notification center tracking.
|
||||
* </pre>
|
||||
*
|
||||
* @author bphillip
|
||||
|
@ -284,6 +286,7 @@ public class RegistryDataAccessService implements IRegistryDataAccessService {
|
|||
.setComment("Restoring backed up subscriptions");
|
||||
submitObjectsRequest.setId("Restore subscription [" + subId + "]");
|
||||
submitObjectsRequest.setMode(Mode.CREATE_OR_REPLACE);
|
||||
submitObjectsRequest.setUsername(RegistryUtil.registryUser);
|
||||
submitObjectsRequest
|
||||
.setRegistryObjectList(new RegistryObjectListType());
|
||||
submitObjectsRequest.getRegistryObjects().add(sub);
|
||||
|
|
|
@ -14,6 +14,7 @@ import com.raytheon.uf.common.datadelivery.registry.handlers.DataDeliveryHandler
|
|||
import com.raytheon.uf.common.datadelivery.registry.handlers.IDataSetHandler;
|
||||
import com.raytheon.uf.common.datadelivery.registry.handlers.IDataSetMetaDataHandler;
|
||||
import com.raytheon.uf.common.datadelivery.retrieval.xml.ServiceConfig;
|
||||
import com.raytheon.uf.common.registry.ebxml.RegistryUtil;
|
||||
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
|
@ -38,6 +39,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
|
|||
* Oct 03, 2012 1241 djohnson Use registry handler, move unresolved reference handling into handlers themselves.
|
||||
* Nov 19, 2012 1166 djohnson Clean up JAXB representation of registry objects.
|
||||
* Sept 30, 2013 1797 dhladky Generics
|
||||
* Mar 31, 2014 2889 dhladky Added username for notification center tracking.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -90,7 +92,7 @@ public abstract class MetaDataParser implements IParseMetaData {
|
|||
|
||||
IDataSetHandler handler = DataDeliveryHandlers.getDataSetHandler();
|
||||
try {
|
||||
handler.update(dataSetToStore);
|
||||
handler.update(RegistryUtil.registryUser, dataSetToStore);
|
||||
statusHandler.info("Dataset [" + dataSetName
|
||||
+ "] successfully stored in Registry");
|
||||
storeDataSetName(dataSet);
|
||||
|
@ -115,7 +117,7 @@ public abstract class MetaDataParser implements IParseMetaData {
|
|||
dsn.setParameters(dataSetToStore.getParameters());
|
||||
|
||||
try {
|
||||
DataDeliveryHandlers.getDataSetNameHandler().update(dsn);
|
||||
DataDeliveryHandlers.getDataSetNameHandler().update(RegistryUtil.registryUser, dsn);
|
||||
statusHandler.info("DataSetName object store complete, dataset ["
|
||||
+ dsn.getDataSetName() + "]");
|
||||
} catch (RegistryHandlerException e) {
|
||||
|
@ -144,7 +146,7 @@ public abstract class MetaDataParser implements IParseMetaData {
|
|||
final String url = dsmd.getUrl();
|
||||
|
||||
try {
|
||||
handler.update(dsmd);
|
||||
handler.update(RegistryUtil.registryUser, dsmd);
|
||||
statusHandler.info("DataSetMetaData [" + url
|
||||
+ "] successfully stored in Registry");
|
||||
} catch (RegistryHandlerException e) {
|
||||
|
|
|
@ -22,6 +22,7 @@ package com.raytheon.uf.edex.datadelivery.retrieval;
|
|||
import com.raytheon.uf.common.datadelivery.event.INotifiableEvent;
|
||||
import com.raytheon.uf.common.datadelivery.event.notification.NotificationRecord;
|
||||
import com.raytheon.uf.common.event.Event;
|
||||
import com.raytheon.uf.common.registry.ebxml.RegistryUtil;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
|
||||
|
@ -36,6 +37,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Jul 31, 2012 djohnson Initial creation
|
||||
* Dec 07, 2012 1104 djohnson Simplify event type hierarchy.
|
||||
* Mar 31, 2014 2889 dhladky Added username for notification center tracking.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -68,7 +70,7 @@ public class RetrievalEvent extends Event implements
|
|||
public NotificationRecord generateNotification() {
|
||||
NotificationRecord record = new NotificationRecord();
|
||||
record.setCategory("Retrieval");
|
||||
record.setUsername("N/A");
|
||||
record.setUsername(RegistryUtil.registryUser);
|
||||
record.setPriority(1);
|
||||
record.setMessage(toString());
|
||||
record.setDate(getDate());
|
||||
|
|
|
@ -45,6 +45,7 @@ import com.raytheon.uf.edex.auth.resp.AuthorizationResponse;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 18, 2013 1441 djohnson Initial creation
|
||||
* Nov 12, 2013 2506 bgonzale Refactored out notification service.
|
||||
* Mar 31, 2014 2889 dhladky Added username for notification center tracking.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -99,7 +100,7 @@ public class GroupDefinitionServiceHandler extends
|
|||
if (!CollectionUtil.isNullOrEmpty(subsForGroup)) {
|
||||
for (Subscription sub : subsForGroup) {
|
||||
sub.setGroupName(GroupDefinition.NO_GROUP);
|
||||
handler.update(sub);
|
||||
handler.update(user.uniqueId().toString(), sub);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ package com.raytheon.uf.edex.datadelivery.service.verify;
|
|||
|
||||
import com.raytheon.uf.common.datadelivery.registry.Subscription;
|
||||
import com.raytheon.uf.common.datadelivery.registry.handlers.DataDeliveryHandlers;
|
||||
import com.raytheon.uf.common.registry.ebxml.RegistryUtil;
|
||||
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
|
@ -40,6 +41,7 @@ import com.raytheon.uf.edex.datadelivery.service.verify.SubscriptionIntegrityVer
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Dec 10, 2012 1104 djohnson Initial creation
|
||||
* Mar 31, 2014 2889 dhladky Added username for notification center tracking.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -61,7 +63,7 @@ class MarkFailedVerificationSubscriptionsAsInvalid implements
|
|||
subscription.setValid(false);
|
||||
|
||||
try {
|
||||
DataDeliveryHandlers.getSubscriptionHandler().update(subscription);
|
||||
DataDeliveryHandlers.getSubscriptionHandler().update(RegistryUtil.registryUser, subscription);
|
||||
} catch (RegistryHandlerException e) {
|
||||
statusHandler
|
||||
.handle(Priority.ERROR,
|
||||
|
|
|
@ -41,6 +41,7 @@ import com.raytheon.uf.common.datadelivery.registry.handlers.IDataSetHandler;
|
|||
import com.raytheon.uf.common.datadelivery.registry.handlers.IDataSetMetaDataHandler;
|
||||
import com.raytheon.uf.common.dataplugin.PluginDataObject;
|
||||
import com.raytheon.uf.common.geospatial.ISpatialObject;
|
||||
import com.raytheon.uf.common.registry.ebxml.RegistryUtil;
|
||||
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
|
@ -61,6 +62,7 @@ import com.raytheon.uf.edex.ogc.common.db.SimpleLayer;
|
|||
* Jul 23, 2013 bclement Initial creation
|
||||
* Aug 08, 2013 dhladky Made operational
|
||||
* Jan 13, 2014 #2679 dhladky multiple layers
|
||||
* Mar 31, 2014 2889 dhladky Added username for notification center tracking.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -121,7 +123,7 @@ public abstract class RegistryCollectorAddon<D extends SimpleDimension, L extend
|
|||
+ "]");
|
||||
|
||||
try {
|
||||
handler.update(metaData);
|
||||
handler.update(RegistryUtil.registryUser, metaData);
|
||||
statusHandler.info("DataSetMetaData [" + description
|
||||
+ "] successfully stored in Registry");
|
||||
} catch (RegistryHandlerException e) {
|
||||
|
@ -149,7 +151,7 @@ public abstract class RegistryCollectorAddon<D extends SimpleDimension, L extend
|
|||
dsn.setParameters(dataSetToStore.getParameters());
|
||||
|
||||
try {
|
||||
DataDeliveryHandlers.getDataSetNameHandler().update(dsn);
|
||||
DataDeliveryHandlers.getDataSetNameHandler().update(RegistryUtil.registryUser, dsn);
|
||||
statusHandler.info("DataSetName object store complete, dataset ["
|
||||
+ dsn.getDataSetName() + "]");
|
||||
} catch (RegistryHandlerException e) {
|
||||
|
@ -168,7 +170,7 @@ public abstract class RegistryCollectorAddon<D extends SimpleDimension, L extend
|
|||
IDataSetHandler handler = DataDeliveryHandlers.getDataSetHandler();
|
||||
|
||||
try {
|
||||
handler.update(dataSetToStore);
|
||||
handler.update(RegistryUtil.registryUser, dataSetToStore);
|
||||
statusHandler.info("Dataset [" + dataSetName
|
||||
+ "] successfully stored in Registry");
|
||||
storeDataSetName(dataSet);
|
||||
|
@ -187,7 +189,7 @@ public abstract class RegistryCollectorAddon<D extends SimpleDimension, L extend
|
|||
protected void storeProvider(final Provider provider) {
|
||||
|
||||
try {
|
||||
DataDeliveryHandlers.getProviderHandler().update(provider);
|
||||
DataDeliveryHandlers.getProviderHandler().update(RegistryUtil.registryUser, provider);
|
||||
} catch (RegistryHandlerException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Provider [" + provider.getName()
|
||||
|
@ -230,7 +232,7 @@ public abstract class RegistryCollectorAddon<D extends SimpleDimension, L extend
|
|||
protected void storeParameter(Parameter parameter) {
|
||||
|
||||
try {
|
||||
DataDeliveryHandlers.getParameterHandler().update(parameter);
|
||||
DataDeliveryHandlers.getParameterHandler().update(RegistryUtil.registryUser, parameter);
|
||||
} catch (RegistryHandlerException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Failed to store parameter [" + parameter.getName() + "]");
|
||||
|
|
|
@ -67,6 +67,7 @@ import com.raytheon.uf.edex.registry.ebxml.util.EbxmlObjectUtil;
|
|||
* 3/18/2013 1802 bphillip Modified to use transaction boundaries and spring injection
|
||||
* 4/9/2013 1802 bphillip Import changes due to moved constant classes
|
||||
* 5/21/2013 2022 bphillip Implemented RegistryInitializedListener
|
||||
* Mar 31, 2014 2889 dhladky Added username for notification center tracking.
|
||||
* </pre>
|
||||
*
|
||||
* @author bphillip
|
||||
|
@ -212,6 +213,7 @@ public class XACMLPolicyAdministrator implements RegistryInitializedListener {
|
|||
submitRequest.setComment("Submission of access control policy");
|
||||
submitRequest.setCheckReferences(false);
|
||||
submitRequest.setMode(Mode.CREATE_OR_REPLACE);
|
||||
submitRequest.setUsername(RegistryUtil.registryUser);
|
||||
submitRequest.setId("ACP submission");
|
||||
List<RegistryObjectType> regObjs = new ArrayList<RegistryObjectType>();
|
||||
for (int i = 0; i < fileList.length; i++) {
|
||||
|
|
|
@ -109,6 +109,7 @@ import com.raytheon.uf.edex.registry.events.CreateAuditTrailEvent;
|
|||
* 12/2/2013 1829 bphillip Auditable events are not genereted via messages on the event bus
|
||||
* 01/21/2014 2613 bphillip Removed verbose log message from removeObjects
|
||||
* 2/19/2014 2769 bphillip Added current time to audit trail events
|
||||
* Mar 31, 2014 2889 dhladky Added username for notification center tracking.
|
||||
*
|
||||
*
|
||||
* </pre>
|
||||
|
@ -469,7 +470,7 @@ public class LifecycleManagerImpl implements LifecycleManager {
|
|||
if (!objsCreated.isEmpty()) {
|
||||
for (RegistryObjectType obj : objsCreated) {
|
||||
EventBus.publish(new InsertRegistryEvent(obj.getId(), obj
|
||||
.getLid(), obj.getObjectType()));
|
||||
.getLid(), request.getUsername(), obj.getObjectType()));
|
||||
EventBus.publish(new RegistryStatisticsEvent(obj
|
||||
.getObjectType(), obj.getStatus(), obj.getOwner(),
|
||||
avTimePerRecord));
|
||||
|
@ -480,7 +481,7 @@ public class LifecycleManagerImpl implements LifecycleManager {
|
|||
if (!objsUpdated.isEmpty()) {
|
||||
for (RegistryObjectType obj : objsUpdated) {
|
||||
EventBus.publish(new UpdateRegistryEvent(obj.getId(), obj
|
||||
.getLid(), obj.getObjectType()));
|
||||
.getLid(), request.getUsername(), obj.getObjectType()));
|
||||
EventBus.publish(new RegistryStatisticsEvent(obj
|
||||
.getObjectType(), obj.getStatus(), obj.getOwner(),
|
||||
avTimePerRecord));
|
||||
|
|
|
@ -61,6 +61,7 @@ import com.raytheon.uf.common.registry.constants.CanonicalQueryTypes;
|
|||
import com.raytheon.uf.common.registry.constants.DeletionScope;
|
||||
import com.raytheon.uf.common.registry.constants.QueryLanguages;
|
||||
import com.raytheon.uf.common.registry.constants.QueryReturnTypes;
|
||||
import com.raytheon.uf.common.registry.ebxml.RegistryUtil;
|
||||
import com.raytheon.uf.common.registry.services.RegistrySOAPServices;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
|
@ -94,6 +95,7 @@ import com.raytheon.uf.edex.registry.ebxml.util.EbxmlObjectUtil;
|
|||
* 1/15/2014 2613 bphillip Added batching of notification update queries to reduce number of web service calls
|
||||
* 01/21/2014 2613 bphillip Added home slot to remove objects request so delete events are properly handled
|
||||
* 2/4/2014 2769 bphillip Removed flush and clear call
|
||||
* Mar 31, 2014 2889 dhladky Added username for notification center tracking.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -300,6 +302,7 @@ public class NotificationListenerImpl implements NotificationListener {
|
|||
remoteObjects));
|
||||
request.setCheckReferences(false);
|
||||
request.setMode(Mode.CREATE_OR_REPLACE);
|
||||
request.setUsername(RegistryUtil.registryUser);
|
||||
request.getSlot().add(
|
||||
new SlotType(EbxmlObjectUtil.HOME_SLOT_NAME,
|
||||
new StringValueType(clientBaseURL)));
|
||||
|
|
|
@ -105,14 +105,14 @@ public class EDEXRegistryManager extends
|
|||
if (objects.size() > 1) {
|
||||
statusHandler.error(CAN_ONLY_STORE_SINGLE_OBJECT);
|
||||
}
|
||||
response = registryHandler.storeOrReplaceObject(objects
|
||||
response = registryHandler.storeOrReplaceObject(request.getUsername(), objects
|
||||
.get(0));
|
||||
break;
|
||||
case STORE:
|
||||
if (objects.size() > 1) {
|
||||
statusHandler.error(CAN_ONLY_STORE_SINGLE_OBJECT);
|
||||
}
|
||||
response = registryHandler.storeObject(objects.get(0));
|
||||
response = registryHandler.storeObject(request.getUsername(), objects.get(0));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -68,6 +68,7 @@ import com.raytheon.uf.edex.registry.ebxml.util.EbxmlObjectUtil;
|
|||
* 7/30/2012 724 bphillip Initial creation
|
||||
* 3/13/2013 1082 bphillip Modified to use spring injection
|
||||
* Apr 23, 2013 1910 djohnson RegistryResponseStatus is now an enum.
|
||||
* Mar 31, 2014 2889 dhladky Added username for notification center tracking.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -485,6 +486,7 @@ public class RegistryWebUtil {
|
|||
submitRequest.setComment("Object submission");
|
||||
submitRequest.setCheckReferences(false);
|
||||
submitRequest.setMode(Mode.CREATE_OR_REPLACE);
|
||||
submitRequest.setUsername(RegistryUtil.registryUser);
|
||||
submitRequest.setId("User/Organization Profiles and Roles");
|
||||
|
||||
submitRequest.setRegistryObjectList(EbxmlObjectUtil
|
||||
|
|
|
@ -87,7 +87,6 @@
|
|||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="lib" path="lib/javax.servlet_2.5.0.v200910301333.jar"/>
|
||||
<classpathentry kind="lib" path="/com.raytheon.edex.plugin.redbook/res/conf"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/com.raytheon.uf.common.datadelivery.harvester"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/javax.jms"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/org.apache.commons.cxf"/>
|
||||
|
|
|
@ -1,122 +0,0 @@
|
|||
/**
|
||||
* 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.datadelivery.registry.handlers;
|
||||
|
||||
import static org.hamcrest.Matchers.empty;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.raytheon.uf.common.datadelivery.registry.DataType;
|
||||
import com.raytheon.uf.common.datadelivery.registry.InitialPendingSubscription;
|
||||
import com.raytheon.uf.common.datadelivery.registry.PendingSharedSubscription;
|
||||
import com.raytheon.uf.common.datadelivery.registry.PendingSharedSubscriptionFixture;
|
||||
import com.raytheon.uf.common.datadelivery.registry.PendingSiteSubscription;
|
||||
import com.raytheon.uf.common.datadelivery.registry.PendingSiteSubscriptionFixture;
|
||||
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
|
||||
import com.raytheon.uf.edex.registry.ebxml.dao.AbstractRegistryTest;
|
||||
|
||||
/**
|
||||
* Test {@link PendingSubscriptionHandler}.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* May 29, 2013 1650 djohnson Initial creation
|
||||
* Oct 22, 2013 2292 mpduff Implement multiple data types.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
public class PendingSubscriptionHandlerTest extends AbstractRegistryTest {
|
||||
|
||||
@Test
|
||||
public void canDeleteMixedSiteAndPendingSharedSubscriptions()
|
||||
throws RegistryHandlerException {
|
||||
|
||||
final PendingSiteSubscription siteSubscription = PendingSiteSubscriptionFixture.INSTANCE
|
||||
.get(DataType.GRID);
|
||||
final PendingSharedSubscription sharedSubscription = PendingSharedSubscriptionFixture.INSTANCE
|
||||
.get(DataType.GRID);
|
||||
|
||||
storeSubscriptionsForPendingAssociations(siteSubscription,
|
||||
sharedSubscription);
|
||||
|
||||
final IPendingSubscriptionHandler pendingSubHandler = DataDeliveryHandlers
|
||||
.getPendingSubscriptionHandler();
|
||||
pendingSubHandler.store(siteSubscription);
|
||||
pendingSubHandler.store(sharedSubscription);
|
||||
|
||||
List<InitialPendingSubscription> subscriptions = Lists
|
||||
.<InitialPendingSubscription> newArrayList(siteSubscription,
|
||||
sharedSubscription);
|
||||
|
||||
pendingSubHandler.delete(subscriptions);
|
||||
|
||||
assertThat(pendingSubHandler.getAll(), is(empty()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void canDeleteMixedSiteAndPendingSharedSubscriptionsWithUsername()
|
||||
throws RegistryHandlerException {
|
||||
|
||||
final PendingSiteSubscription siteSubscription = PendingSiteSubscriptionFixture.INSTANCE
|
||||
.get(DataType.GRID);
|
||||
final PendingSharedSubscription sharedSubscription = PendingSharedSubscriptionFixture.INSTANCE
|
||||
.get(DataType.GRID);
|
||||
|
||||
storeSubscriptionsForPendingAssociations(siteSubscription,
|
||||
sharedSubscription);
|
||||
|
||||
final IPendingSubscriptionHandler pendingSubHandler = DataDeliveryHandlers
|
||||
.getPendingSubscriptionHandler();
|
||||
pendingSubHandler.store(siteSubscription);
|
||||
pendingSubHandler.store(sharedSubscription);
|
||||
|
||||
List<InitialPendingSubscription> subscriptions = Lists
|
||||
.<InitialPendingSubscription> newArrayList(siteSubscription,
|
||||
sharedSubscription);
|
||||
|
||||
pendingSubHandler.delete("joeSchmo", subscriptions);
|
||||
|
||||
assertThat(pendingSubHandler.getAll(), is(empty()));
|
||||
}
|
||||
|
||||
private void storeSubscriptionsForPendingAssociations(
|
||||
final PendingSiteSubscription siteSubscription,
|
||||
final PendingSharedSubscription sharedSubscription)
|
||||
throws RegistryHandlerException {
|
||||
|
||||
final ISubscriptionHandler subscriptionHandler = DataDeliveryHandlers
|
||||
.getSubscriptionHandler();
|
||||
subscriptionHandler.store(siteSubscription.subscription());
|
||||
subscriptionHandler.store(sharedSubscription.subscription());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,115 +0,0 @@
|
|||
/**
|
||||
* 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.datadelivery.registry.handlers;
|
||||
|
||||
import static org.hamcrest.Matchers.empty;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.raytheon.uf.common.datadelivery.registry.DataType;
|
||||
import com.raytheon.uf.common.datadelivery.registry.SharedSubscription;
|
||||
import com.raytheon.uf.common.datadelivery.registry.SharedSubscriptionFixture;
|
||||
import com.raytheon.uf.common.datadelivery.registry.SiteSubscription;
|
||||
import com.raytheon.uf.common.datadelivery.registry.SiteSubscriptionFixture;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Subscription;
|
||||
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
|
||||
import com.raytheon.uf.edex.registry.ebxml.dao.AbstractRegistryTest;
|
||||
|
||||
/**
|
||||
* Test {@link SubscriptionHandler}.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* May 29, 2013 1650 djohnson Initial creation
|
||||
* May 31, 2013 1650 djohnson Fix ability to get shared subscriptions by id.
|
||||
* Oct 21, 2013 2292 mpduff Implemented point data type
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
public class SubscriptionHandlerTest extends AbstractRegistryTest {
|
||||
|
||||
@Test
|
||||
public void canDeleteMixedSiteAndSharedSubscriptions()
|
||||
throws RegistryHandlerException {
|
||||
final SiteSubscription siteSubscription = SiteSubscriptionFixture.INSTANCE
|
||||
.get(DataType.GRID);
|
||||
final SharedSubscription sharedSubscription = SharedSubscriptionFixture.INSTANCE
|
||||
.get(DataType.GRID);
|
||||
|
||||
final ISubscriptionHandler subscriptionHandler = DataDeliveryHandlers
|
||||
.getSubscriptionHandler();
|
||||
subscriptionHandler.store(siteSubscription);
|
||||
subscriptionHandler.store(sharedSubscription);
|
||||
|
||||
List<Subscription> subscriptions = Lists.<Subscription> newArrayList(
|
||||
siteSubscription, sharedSubscription);
|
||||
|
||||
subscriptionHandler.delete(subscriptions);
|
||||
|
||||
assertThat(subscriptionHandler.getAll(), is(empty()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void canDeleteMixedSiteAndSharedSubscriptionsWithUsername()
|
||||
throws RegistryHandlerException {
|
||||
final SiteSubscription siteSubscription = SiteSubscriptionFixture.INSTANCE
|
||||
.get(DataType.GRID);
|
||||
final SharedSubscription sharedSubscription = SharedSubscriptionFixture.INSTANCE
|
||||
.get(DataType.GRID);
|
||||
|
||||
final ISubscriptionHandler subscriptionHandler = DataDeliveryHandlers
|
||||
.getSubscriptionHandler();
|
||||
subscriptionHandler.store(siteSubscription);
|
||||
subscriptionHandler.store(sharedSubscription);
|
||||
|
||||
List<Subscription> subscriptions = Lists.<Subscription> newArrayList(
|
||||
siteSubscription, sharedSubscription);
|
||||
|
||||
subscriptionHandler.delete("joeSchmo", subscriptions);
|
||||
|
||||
assertThat(subscriptionHandler.getAll(), is(empty()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getByIdReturnsSharedSubscription()
|
||||
throws RegistryHandlerException {
|
||||
final SharedSubscription sharedSubscription = SharedSubscriptionFixture.INSTANCE
|
||||
.get(DataType.GRID);
|
||||
|
||||
final ISubscriptionHandler subscriptionHandler = DataDeliveryHandlers
|
||||
.getSubscriptionHandler();
|
||||
subscriptionHandler.store(sharedSubscription);
|
||||
|
||||
assertNotNull(subscriptionHandler.getById(sharedSubscription.getId()));
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -1,786 +0,0 @@
|
|||
/**
|
||||
* 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.0ONE_HUNDRED
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.edex.datadelivery.bandwidth;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotSame;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.SortedSet;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.bandwidth.BandwidthService;
|
||||
import com.raytheon.uf.common.datadelivery.bandwidth.IBandwidthRequest;
|
||||
import com.raytheon.uf.common.datadelivery.bandwidth.IProposeScheduleResponse;
|
||||
import com.raytheon.uf.common.datadelivery.bandwidth.WfoBandwidthService;
|
||||
import com.raytheon.uf.common.datadelivery.bandwidth.data.BandwidthBucketDescription;
|
||||
import com.raytheon.uf.common.datadelivery.bandwidth.data.BandwidthGraphData;
|
||||
import com.raytheon.uf.common.datadelivery.bandwidth.data.BandwidthMap;
|
||||
import com.raytheon.uf.common.datadelivery.bandwidth.data.SubscriptionStatusSummary;
|
||||
import com.raytheon.uf.common.datadelivery.bandwidth.data.TimeWindowData;
|
||||
import com.raytheon.uf.common.datadelivery.registry.AdhocSubscription;
|
||||
import com.raytheon.uf.common.datadelivery.registry.AdhocSubscriptionFixture;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Coverage;
|
||||
import com.raytheon.uf.common.datadelivery.registry.DataType;
|
||||
import com.raytheon.uf.common.datadelivery.registry.GriddedTime;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Network;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Subscription;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Subscription.SubscriptionPriority;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Time;
|
||||
import com.raytheon.uf.common.datadelivery.registry.handlers.DataDeliveryHandlers;
|
||||
import com.raytheon.uf.common.datadelivery.registry.handlers.ISubscriptionHandler;
|
||||
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
|
||||
import com.raytheon.uf.common.serialization.SerializationUtil;
|
||||
import com.raytheon.uf.common.time.util.TimeUtil;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthAllocation;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthBucket;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionRetrieval;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalPlan;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil;
|
||||
|
||||
/**
|
||||
* Tests for the thrift service of {@link BandwidthManager}.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 22, 2012 1286 djohnson Initial creation
|
||||
* Nov 20, 2012 1286 djohnson Add tests for proposeSchedule methods.
|
||||
* Dec 06, 2012 1397 djohnson Add tests for getting bandwidth graph data.
|
||||
* Feb 20, 2013 1543 djohnson Use WFO bandwidth manager.
|
||||
* Feb 26, 2013 1643 djohnson BandwidthService extends reusable class.
|
||||
* Feb 27, 2013 1644 djohnson Bandwidth service is the WFO version.
|
||||
* May 20, 2013 1650 djohnson Add test for returning required dataset size.
|
||||
* Jun 12, 2013 2038 djohnson Add test for returning required dataset size on subscription update.
|
||||
* Jun 25, 2013 2106 djohnson BandwidthBucket is a big boy class now.
|
||||
* Jul 11, 2013 2106 djohnson Use SubscriptionPriority enum.
|
||||
* Jul 18, 2013 1653 mpduff Added test for sub status summary.
|
||||
* Sept 25, 2013 1797 dhladky separated time from gridded time
|
||||
* Oct 21, 2013 2292 mpduff Implement multiple data types.
|
||||
* Dec 02, 2013 2545 mpduff Get data by network.
|
||||
* Jan 23, 2014 2636 mpduff Removed TimeWindow individual bin code.
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
public class BandwidthServiceIntTest<T extends Time, C extends Coverage>
|
||||
extends AbstractWfoBandwidthManagerIntTest<T, C> {
|
||||
|
||||
private static final int ONE_HUNDRED = 100;
|
||||
|
||||
private final BandwidthService<T, C> service = new WfoBandwidthService<T, C>() {
|
||||
@Override
|
||||
protected Object getResponseFromServer(IBandwidthRequest<T, C> request)
|
||||
throws Exception {
|
||||
// Serialize and deserialize each call, this makes sure the dynamic
|
||||
// serialize annotations are correct as well
|
||||
return SerializationUtil
|
||||
.transformFromThrift(
|
||||
Object.class,
|
||||
SerializationUtil
|
||||
.transformToThrift(BandwidthServiceIntTest.this.bandwidthManager
|
||||
.handleRequest(request)));
|
||||
}
|
||||
};
|
||||
|
||||
@Test
|
||||
public void testRetrieveBandwidthFromServer() {
|
||||
assertEquals("Incorrect bandwidth amount retrieved!", 768,
|
||||
service.getBandwidthForNetworkInKilobytes(Network.OPSNET));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProposeNetworkBandwidthReturnsSubscriptionsUnableToFit()
|
||||
throws RegistryHandlerException {
|
||||
|
||||
// Two subscriptions that will fill up a bucket exactly
|
||||
Subscription<T, C> subscription = createSubscriptionThatFillsHalfABucket();
|
||||
Subscription<T, C> subscription2 = createSubscriptionThatFillsHalfABucket();
|
||||
|
||||
final ISubscriptionHandler subscriptionHandler = DataDeliveryHandlers
|
||||
.getSubscriptionHandler();
|
||||
subscriptionHandler.store(subscription);
|
||||
subscriptionHandler.store(subscription2);
|
||||
|
||||
// bandwidthManager.schedule(subscription);
|
||||
// bandwidthManager.schedule(subscription2);
|
||||
//
|
||||
// // Now we propose dropping the bandwidth by just one kb/s
|
||||
// Set<String> results = service.proposeBandwidthForNetworkInKilobytes(
|
||||
// Network.OPSNET, retrievalManager.getPlan(Network.OPSNET)
|
||||
// .getDefaultBandwidth() - 1);
|
||||
//
|
||||
// assertEquals(
|
||||
// "Expected one subscription to not have been able to fit with the new bandwidth!",
|
||||
// 1, results.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProposeNetworkBandwidthReturnsNoSubscriptionsWhenAbleToFit()
|
||||
throws RegistryHandlerException {
|
||||
|
||||
// Two subscriptions that will fill up only a third of a bucket
|
||||
Subscription<T, C> subscription = createSubscriptionThatFillsAThirdOfABucket();
|
||||
Subscription<T, C> subscription2 = createSubscriptionThatFillsAThirdOfABucket();
|
||||
|
||||
ISubscriptionHandler subscriptionHandler = DataDeliveryHandlers
|
||||
.getSubscriptionHandler();
|
||||
subscriptionHandler.store(subscription);
|
||||
subscriptionHandler.store(subscription2);
|
||||
|
||||
// bandwidthManager.schedule(subscription);
|
||||
// bandwidthManager.schedule(subscription2);
|
||||
//
|
||||
// // Now we propose dropping the bandwidth by just one kb/s
|
||||
// Set<String> results = service.proposeBandwidthForNetworkInKilobytes(
|
||||
// Network.OPSNET, retrievalManager.getPlan(Network.OPSNET)
|
||||
// .getDefaultBandwidth() - 1);
|
||||
//
|
||||
// assertTrue(
|
||||
// "Expected to be able to fit all subscriptions with the new bandwidth!",
|
||||
// results.isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSaveBandwidthToServer() {
|
||||
service.setBandwidthForNetworkInKilobytes(Network.OPSNET, ONE_HUNDRED);
|
||||
assertEquals(
|
||||
"Expected the bandwidth to have been saved to the in memory bandwidth route!",
|
||||
ONE_HUNDRED,
|
||||
service.getBandwidthForNetworkInKilobytes(Network.OPSNET));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSaveBandwidthToServerUpdatesBandwidthMapFile() {
|
||||
service.setBandwidthForNetworkInKilobytes(Network.OPSNET, ONE_HUNDRED);
|
||||
|
||||
File file = IntegrationTestBandwidthContextFactory
|
||||
.getIntegrationTestBandwidthMapConfigFile();
|
||||
BandwidthMap map = BandwidthMap.load(file);
|
||||
assertEquals(
|
||||
"Expected the bandwidth to have been saved to the configuration file!",
|
||||
ONE_HUNDRED, map.getRoute(Network.OPSNET).getDefaultBandwidth());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSaveBandwidthToServerReinitializesBandwidthMap() {
|
||||
service.setBandwidthForNetworkInKilobytes(Network.OPSNET, ONE_HUNDRED);
|
||||
|
||||
// Just check for a bucket with an expected amount of bytes size
|
||||
SortedSet<BandwidthBucket> bucketsInWindow = EdexBandwidthContextFactory
|
||||
.getInstance().retrievalManager.getPlan(Network.OPSNET)
|
||||
.getBucketsInWindow(
|
||||
TimeUtil.currentTimeMillis(),
|
||||
TimeUtil.currentTimeMillis()
|
||||
+ (5 * TimeUtil.MILLIS_PER_MINUTE));
|
||||
BandwidthBucket bucket = bucketsInWindow.iterator().next();
|
||||
assertEquals(
|
||||
"The BandwidthManager does not seem to have been reinitialized!",
|
||||
BandwidthUtil
|
||||
.convertKilobytesPerSecondToBytesPerSpecifiedMinutes(
|
||||
ONE_HUNDRED, 3), bucket.getBucketSize());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testScheduleTwoSubscriptionsThatFitReturnsEmptyList() {
|
||||
// Two subscriptions, the sum of which will fill up a bucket exactly
|
||||
Subscription<T, C> subscription = createSubscriptionThatFillsHalfABucket();
|
||||
Subscription<T, C> subscription2 = createSubscriptionThatFillsHalfABucket();
|
||||
|
||||
// subscription2 will not be able to schedule for cycle hour 8
|
||||
((GriddedTime) subscription.getTime()).setCycleTimes(Arrays.asList(
|
||||
Integer.valueOf(6), Integer.valueOf(8)));
|
||||
((GriddedTime) subscription2.getTime()).setCycleTimes(Arrays.asList(
|
||||
Integer.valueOf(6), Integer.valueOf(8)));
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Set<String> unscheduledSubscriptions = service.schedule(Arrays.asList(
|
||||
subscription, subscription2));
|
||||
verifyNoSubscriptionsWereUnscheduled(unscheduledSubscriptions);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testScheduleTwoSubscriptionsSecondDoesNotFitReturnsSecondsName() {
|
||||
Subscription<T, C> subscription = createSubscriptionThatFillsHalfABucket();
|
||||
// Requires its own full bucket, so cycle hour 3 will succeed and cycle
|
||||
// hour 8 will not
|
||||
Subscription<T, C> subscription2 = createSubscriptionThatFillsUpABucket();
|
||||
|
||||
// subscription2 will not be able to schedule for cycle hour 8
|
||||
((GriddedTime) subscription.getTime()).setCycleTimes(Arrays.asList(
|
||||
Integer.valueOf(6), Integer.valueOf(8)));
|
||||
((GriddedTime) subscription2.getTime()).setCycleTimes(Arrays.asList(
|
||||
Integer.valueOf(3), Integer.valueOf(8)));
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Set<String> unscheduledSubscriptions = service.schedule(Arrays.asList(
|
||||
subscription, subscription2));
|
||||
verifySubscriptionWasNotAbleToBeFullyScheduled(
|
||||
unscheduledSubscriptions, subscription2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testScheduleSubscriptionReturnsNamesOfUnscheduledSubscriptions() {
|
||||
|
||||
Subscription<T, C> subscription = createSubscriptionThatFillsUpABucket();
|
||||
Subscription<T, C> subscription2 = createSubscriptionThatFillsUpABucket();
|
||||
|
||||
// subscription2 will not be able to schedule for cycle hour 8
|
||||
((GriddedTime) subscription.getTime()).setCycleTimes(Arrays.asList(
|
||||
Integer.valueOf(6), Integer.valueOf(8)));
|
||||
((GriddedTime) subscription2.getTime()).setCycleTimes(Arrays.asList(
|
||||
Integer.valueOf(3), Integer.valueOf(8)));
|
||||
|
||||
Set<String> unscheduledSubscriptions = service.schedule(subscription);
|
||||
verifyNoSubscriptionsWereUnscheduled(unscheduledSubscriptions);
|
||||
|
||||
unscheduledSubscriptions = service.schedule(subscription2);
|
||||
verifySubscriptionWasNotAbleToBeFullyScheduled(
|
||||
unscheduledSubscriptions, subscription2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProposeScheduleTwoSubscriptionsThatFitReturnsEmptyList() {
|
||||
|
||||
// Two subscriptions, the sum of which will fill up a bucket exactly
|
||||
Subscription<T, C> subscription = createSubscriptionThatFillsHalfABucket();
|
||||
Subscription<T, C> subscription2 = createSubscriptionThatFillsHalfABucket();
|
||||
|
||||
// subscription2 will not be able to schedule for cycle hour 8
|
||||
((GriddedTime) subscription.getTime()).setCycleTimes(Arrays.asList(
|
||||
Integer.valueOf(6), Integer.valueOf(8)));
|
||||
((GriddedTime) subscription2.getTime()).setCycleTimes(Arrays.asList(
|
||||
Integer.valueOf(6), Integer.valueOf(8)));
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
IProposeScheduleResponse response = service.proposeSchedule(Arrays
|
||||
.asList(subscription, subscription2));
|
||||
Set<String> unscheduledSubscriptions = response
|
||||
.getUnscheduledSubscriptions();
|
||||
verifyNoSubscriptionsWereUnscheduled(unscheduledSubscriptions);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProposeScheduleTwoSubscriptionsThatFitReturnsNotSetRequiredLatency() {
|
||||
|
||||
// Two subscriptions, the sum of which will fill up a bucket exactly
|
||||
Subscription<T, C> subscription = createSubscriptionThatFillsHalfABucket();
|
||||
Subscription<T, C> subscription2 = createSubscriptionThatFillsHalfABucket();
|
||||
|
||||
((GriddedTime) subscription.getTime()).setCycleTimes(Arrays.asList(
|
||||
Integer.valueOf(6), Integer.valueOf(8)));
|
||||
((GriddedTime) subscription2.getTime()).setCycleTimes(Arrays.asList(
|
||||
Integer.valueOf(6), Integer.valueOf(8)));
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
IProposeScheduleResponse response = service.proposeSchedule(Arrays
|
||||
.asList(subscription, subscription2));
|
||||
assertEquals(
|
||||
"Expected the required latency to not be set when the propose schedule fits",
|
||||
IProposeScheduleResponse.VALUE_NOT_SET,
|
||||
response.getRequiredLatency());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProposeScheduleTwoSubscriptionsThatFitReturnsNotSetRequiredDataSetSize() {
|
||||
|
||||
// Two subscriptions, the sum of which will fill up a bucket exactly
|
||||
Subscription<T, C> subscription = createSubscriptionThatFillsHalfABucket();
|
||||
Subscription<T, C> subscription2 = createSubscriptionThatFillsHalfABucket();
|
||||
|
||||
((GriddedTime) subscription.getTime()).setCycleTimes(Arrays.asList(
|
||||
Integer.valueOf(6), Integer.valueOf(8)));
|
||||
((GriddedTime) subscription2.getTime()).setCycleTimes(Arrays.asList(
|
||||
Integer.valueOf(6), Integer.valueOf(8)));
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
IProposeScheduleResponse response = service.proposeSchedule(Arrays
|
||||
.asList(subscription, subscription2));
|
||||
assertEquals(
|
||||
"Expected the required latency to not be set when the propose schedule fits",
|
||||
IProposeScheduleResponse.VALUE_NOT_SET,
|
||||
response.getRequiredDataSetSize());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProposeScheduleTwoSubscriptionsSecondDoesNotFitReturnsSecondsName() {
|
||||
|
||||
// Two subscriptions, the sum of which will fill up a bucket exactly
|
||||
Subscription<T, C> subscription = createSubscriptionThatFillsHalfABucket();
|
||||
// Requires its own full bucket, so cycle hour 3 will succeed and cycle
|
||||
// hour 8 will not
|
||||
Subscription<T, C> subscription2 = createSubscriptionThatFillsUpABucket();
|
||||
|
||||
// subscription2 will not be able to schedule for cycle hour 8
|
||||
((GriddedTime) subscription.getTime()).setCycleTimes(Arrays.asList(
|
||||
Integer.valueOf(6), Integer.valueOf(8)));
|
||||
((GriddedTime) subscription2.getTime()).setCycleTimes(Arrays.asList(
|
||||
Integer.valueOf(3), Integer.valueOf(8)));
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Set<String> unscheduledSubscriptions = service.proposeSchedule(
|
||||
Arrays.asList(subscription, subscription2))
|
||||
.getUnscheduledSubscriptions();
|
||||
verifySubscriptionWasNotAbleToBeFullyScheduled(
|
||||
unscheduledSubscriptions, subscription2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProposeScheduleSubscriptionReturnsNamesOfUnscheduledSubscriptions() {
|
||||
|
||||
Subscription<T, C> subscription = createSubscriptionThatFillsUpABucket();
|
||||
Subscription<T, C> subscription2 = createSubscriptionThatFillsUpABucket();
|
||||
|
||||
// subscription2 will not be able to schedule for cycle hour 8
|
||||
((GriddedTime) subscription.getTime()).setCycleTimes(Arrays.asList(
|
||||
Integer.valueOf(6), Integer.valueOf(8)));
|
||||
((GriddedTime) subscription2.getTime()).setCycleTimes(Arrays.asList(
|
||||
Integer.valueOf(3), Integer.valueOf(8)));
|
||||
|
||||
Set<String> unscheduledSubscriptions = service.schedule(subscription);
|
||||
verifyNoSubscriptionsWereUnscheduled(unscheduledSubscriptions);
|
||||
|
||||
unscheduledSubscriptions = service.proposeSchedule(subscription2)
|
||||
.getUnscheduledSubscriptions();
|
||||
verifySubscriptionWasNotAbleToBeFullyScheduled(
|
||||
unscheduledSubscriptions, subscription2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProposeScheduleSubscriptionsSecondDoesntFitReturnsRequiredLatency() {
|
||||
|
||||
// Two subscriptions that will fill up a bucket exactly
|
||||
Subscription<T, C> subscription = createSubscriptionThatFillsUpABucket();
|
||||
Subscription<T, C> subscription2 = createSubscriptionThatFillsUpABucket();
|
||||
|
||||
// subscription2 will not be able to schedule for cycle hour 8
|
||||
((GriddedTime) subscription.getTime()).setCycleTimes(Arrays.asList(
|
||||
Integer.valueOf(6), Integer.valueOf(8)));
|
||||
((GriddedTime) subscription2.getTime()).setCycleTimes(Arrays.asList(
|
||||
Integer.valueOf(3), Integer.valueOf(8)));
|
||||
|
||||
Set<String> unscheduledSubscriptions = service.schedule(subscription);
|
||||
verifyNoSubscriptionsWereUnscheduled(unscheduledSubscriptions);
|
||||
|
||||
int requiredLatency = service.proposeSchedule(subscription2)
|
||||
.getRequiredLatency();
|
||||
assertEquals(
|
||||
"The required latency should have been returned from propose schedule!",
|
||||
6, requiredLatency);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProposeScheduleSubscriptionsSecondDoesntFitReturnsRequiredSize() {
|
||||
|
||||
Subscription<T, C> subscription = createSubscriptionThatFillsHalfABucket();
|
||||
Subscription<T, C> subscription2 = createSubscriptionThatFillsUpTenBuckets();
|
||||
|
||||
// subscription2 will not be able to schedule for cycle hour 8
|
||||
((GriddedTime) subscription.getTime()).setCycleTimes(Arrays.asList(
|
||||
Integer.valueOf(6), Integer.valueOf(8)));
|
||||
((GriddedTime) subscription2.getTime()).setCycleTimes(Arrays.asList(
|
||||
Integer.valueOf(3), Integer.valueOf(8)));
|
||||
|
||||
Set<String> unscheduledSubscriptions = service.schedule(subscription);
|
||||
verifyNoSubscriptionsWereUnscheduled(unscheduledSubscriptions);
|
||||
|
||||
// The maximum dataset size that could fit in the bucket is another
|
||||
// subscription the same size as the first
|
||||
final long expectedRequiredDataSetSize = subscription.getDataSetSize();
|
||||
final long requiredDataSetSize = service.proposeSchedule(subscription2)
|
||||
.getRequiredDataSetSize();
|
||||
assertEquals(
|
||||
"The required dataset size should have been returned from propose schedule!",
|
||||
expectedRequiredDataSetSize, requiredDataSetSize);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProposeScheduleSubscriptionsSecondDoesntFitReturnsRequiredSizeForSubscriptionUpdate() {
|
||||
|
||||
Subscription<T, C> subscription = createSubscriptionThatFillsHalfABucket();
|
||||
((GriddedTime) subscription.getTime()).setCycleTimes(Arrays.asList(
|
||||
Integer.valueOf(6), Integer.valueOf(8)));
|
||||
|
||||
Set<String> unscheduledSubscriptions = service.schedule(subscription);
|
||||
verifyNoSubscriptionsWereUnscheduled(unscheduledSubscriptions);
|
||||
|
||||
// We can only fit up to a bucket
|
||||
final long expectedRequiredDataSetSize = createSubscriptionThatFillsUpABucket()
|
||||
.getDataSetSize();
|
||||
|
||||
// Try to update the subscription to fill two buckets
|
||||
subscription.setDataSetSize(createSubscriptionThatFillsUpTwoBuckets()
|
||||
.getDataSetSize());
|
||||
|
||||
final long requiredDataSetSize = service.proposeSchedule(subscription)
|
||||
.getRequiredDataSetSize();
|
||||
assertEquals(
|
||||
"The required dataset size should have been returned from propose schedule!",
|
||||
expectedRequiredDataSetSize, requiredDataSetSize);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDetermineRequiredSizeReturnsZeroIfUnableToFitAtAll() {
|
||||
|
||||
Subscription<T, C> subscription = createSubscriptionThatFillsUpABucket();
|
||||
Subscription<T, C> subscription2 = createSubscriptionThatFillsUpABucket();
|
||||
|
||||
// subscription2 will not be able to schedule for cycle hour 8
|
||||
((GriddedTime) subscription.getTime()).setCycleTimes(Arrays.asList(
|
||||
Integer.valueOf(6), Integer.valueOf(8)));
|
||||
((GriddedTime) subscription2.getTime()).setCycleTimes(Arrays.asList(
|
||||
Integer.valueOf(3), Integer.valueOf(8)));
|
||||
|
||||
Set<String> unscheduledSubscriptions = service.schedule(subscription);
|
||||
verifyNoSubscriptionsWereUnscheduled(unscheduledSubscriptions);
|
||||
|
||||
// The maximum dataset size that could fit in the bucket is another
|
||||
// subscription the same size as the first
|
||||
final long expectedRequiredDataSetSize = 0;
|
||||
final long requiredDataSetSize = service.proposeSchedule(subscription2)
|
||||
.getRequiredDataSetSize();
|
||||
assertEquals("The required dataset size should have returned 0!",
|
||||
expectedRequiredDataSetSize, requiredDataSetSize);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReinitializeStartsNewBandwidthManager() {
|
||||
BandwidthManager<T, C> originalBandwidthManager = BandwidthServiceIntTest.this.bandwidthManager;
|
||||
|
||||
service.reinitialize();
|
||||
|
||||
assertNotSame(
|
||||
"Expected the BandwidthManager instance to have been replaced",
|
||||
originalBandwidthManager,
|
||||
EdexBandwidthContextFactory.getInstance());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetEstimatedCompletionTimeReturnsLastBucketTimeForSubscription() {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
AdhocSubscription<T, C> subscription = (AdhocSubscription<T, C>) AdhocSubscriptionFixture.INSTANCE
|
||||
.get(DataType.GRID);
|
||||
((GriddedTime) subscription.getTime()).setCycleTimes(Arrays
|
||||
.asList(Integer.valueOf(0)));
|
||||
subscription.setDataSetSize(createSubscriptionThatFillsUpABucket()
|
||||
.getDataSetSize());
|
||||
|
||||
Set<String> unscheduledSubscriptions = service.schedule(subscription);
|
||||
verifyNoSubscriptionsWereUnscheduled(unscheduledSubscriptions);
|
||||
|
||||
// Jan 2, 18:00 CST
|
||||
Date expected = new Date(172800000L);
|
||||
Date actual = service.getEstimatedCompletionTime(subscription);
|
||||
assertEquals("Received incorrect estimated completion time!", expected,
|
||||
actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetBandwidthGraphDataReturnsCorrectNumberOfSubscriptionNames() {
|
||||
|
||||
// Two subscriptions that will fill up a bucket exactly
|
||||
Subscription<T, C> subscription = createSubscriptionThatFillsUpABucket();
|
||||
Subscription<T, C> subscription2 = createSubscriptionThatFillsUpABucket();
|
||||
|
||||
// subscription2 will not be able to schedule for cycle hour 8
|
||||
((GriddedTime) subscription.getTime()).setCycleTimes(Arrays.asList(
|
||||
Integer.valueOf(6), Integer.valueOf(8)));
|
||||
((GriddedTime) subscription2.getTime()).setCycleTimes(Arrays
|
||||
.asList(Integer.valueOf(3)));
|
||||
|
||||
service.schedule(subscription);
|
||||
service.schedule(subscription2);
|
||||
|
||||
BandwidthGraphData graphData = service.getBandwidthGraphData();
|
||||
|
||||
assertEquals("Incorrect number of subscriptions returned!", 2,
|
||||
graphData.getNumberOfSubscriptions(Network.OPSNET));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetBandwidthGraphDataReturnsCorrectBinMinutes() {
|
||||
|
||||
// Two subscriptions that will fill up a bucket exactly
|
||||
Subscription<T, C> subscription = createSubscriptionThatFillsUpABucket();
|
||||
Subscription<T, C> subscription2 = createSubscriptionThatFillsUpABucket();
|
||||
|
||||
// subscription2 will not be able to schedule for cycle hour 8
|
||||
((GriddedTime) subscription.getTime()).setCycleTimes(Arrays.asList(
|
||||
Integer.valueOf(6), Integer.valueOf(8)));
|
||||
((GriddedTime) subscription2.getTime()).setCycleTimes(Arrays
|
||||
.asList(Integer.valueOf(3)));
|
||||
|
||||
service.schedule(subscription);
|
||||
service.schedule(subscription2);
|
||||
|
||||
BandwidthGraphData graphData = service.getBandwidthGraphData();
|
||||
RetrievalPlan opsnetPlan = retrievalManager.getPlan(Network.OPSNET);
|
||||
|
||||
assertEquals("Incorrect number of subscriptions returned!",
|
||||
opsnetPlan.getBucketMinutes(),
|
||||
graphData.getBinTimeInMinutes(Network.OPSNET));
|
||||
SortedSet<BandwidthBucketDescription> descs = graphData
|
||||
.getNetworkBucketMap().get(Network.OPSNET);
|
||||
long earliestTime = descs.first().getBucketStartTime();
|
||||
long latestTime = descs.last().getBucketStartTime();
|
||||
assertEquals("Incorrect number of buckets returned", opsnetPlan
|
||||
.getBucketsInWindow(earliestTime, latestTime).size(),
|
||||
descs.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetBandwidthGraphDataForFragmentedSubscription() {
|
||||
|
||||
Subscription<T, C> subscription = createSubscriptionThatFillsUpTwoBuckets();
|
||||
subscription.setLatencyInMinutes(6);
|
||||
subscription.setPriority(SubscriptionPriority.HIGH);
|
||||
|
||||
// Reserves a full bucket at 19700103 18:03:00 which fragments the
|
||||
// subscription to 19700103 18:00:00 and 18:06:00
|
||||
BandwidthAllocation allocation = createAllocationToReserveMiddleBucket(subscription);
|
||||
|
||||
retrievalManager.schedule(Arrays.asList(allocation));
|
||||
|
||||
// bandwidthManager.schedule(subscription);
|
||||
//
|
||||
// BandwidthGraphData graphData = service.getBandwidthGraphData();
|
||||
//
|
||||
// final List<TimeWindowData> subscriptionOneTimeWindows = graphData
|
||||
// .getTimeWindowArray(Network.OPSNET, subscription.getName());
|
||||
//
|
||||
// assertEquals(
|
||||
// "Expected there to be two time windows for this subscription over 2 days",
|
||||
// 2, subscriptionOneTimeWindows.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetBandwidthGraphDataReturnsCorrectTimeWindowsForSubscriptions() {
|
||||
|
||||
// Two subscriptions that will fill up a bucket exactly
|
||||
Subscription<T, C> subscription = createSubscriptionThatFillsUpABucket();
|
||||
Subscription<T, C> subscription2 = createSubscriptionThatFillsUpABucket();
|
||||
|
||||
// subscription2 will not be able to schedule for cycle hour 8
|
||||
((GriddedTime) subscription.getTime()).setCycleTimes(Arrays.asList(
|
||||
Integer.valueOf(6), Integer.valueOf(8)));
|
||||
((GriddedTime) subscription2.getTime()).setCycleTimes(Arrays
|
||||
.asList(Integer.valueOf(3)));
|
||||
|
||||
service.schedule(subscription);
|
||||
service.schedule(subscription2);
|
||||
|
||||
BandwidthGraphData graphData = service.getBandwidthGraphData();
|
||||
|
||||
final List<TimeWindowData> subscriptionOneTimeWindows = graphData
|
||||
.getTimeWindowArray(Network.OPSNET, subscription.getName());
|
||||
final List<TimeWindowData> subscriptionTwoTimeWindows = graphData
|
||||
.getTimeWindowArray(Network.OPSNET, subscription2.getName());
|
||||
|
||||
assertEquals(
|
||||
"Expected there to be four retrievals for this subscription over 2 days",
|
||||
4, subscriptionOneTimeWindows.size());
|
||||
assertEquals(
|
||||
"Expected there to be two retrievals for this subscription over 2 days",
|
||||
2, subscriptionTwoTimeWindows.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetBandwidthGraphDataReturnsCorrectPrioritiesForSubscriptions() {
|
||||
|
||||
// Two subscriptions that will fill up a bucket exactly
|
||||
Subscription<T, C> subscription = createSubscriptionThatFillsUpABucket();
|
||||
subscription.setPriority(SubscriptionPriority.NORMAL);
|
||||
Subscription<T, C> subscription2 = createSubscriptionThatFillsUpABucket();
|
||||
subscription.setPriority(SubscriptionPriority.HIGH);
|
||||
|
||||
// subscription2 will not be able to schedule for cycle hour 8
|
||||
((GriddedTime) subscription.getTime()).setCycleTimes(Arrays.asList(
|
||||
Integer.valueOf(6), Integer.valueOf(8)));
|
||||
((GriddedTime) subscription2.getTime()).setCycleTimes(Arrays
|
||||
.asList(Integer.valueOf(3)));
|
||||
|
||||
service.schedule(subscription);
|
||||
service.schedule(subscription2);
|
||||
|
||||
BandwidthGraphData graphData = service.getBandwidthGraphData();
|
||||
assertThat(
|
||||
graphData.getPriority(Network.OPSNET, subscription.getName()),
|
||||
is(equalTo(subscription.getPriority())));
|
||||
|
||||
assertThat(
|
||||
graphData.getPriority(Network.OPSNET, subscription2.getName()),
|
||||
is(equalTo(subscription2.getPriority())));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProposeScheduleSubscriptionsReturnsStatusSummary() {
|
||||
Subscription<T, C> subscription = createSubscriptionThatFillsUpTwoBuckets();
|
||||
|
||||
((GriddedTime) subscription.getTime()).setCycleTimes(Arrays.asList(
|
||||
Integer.valueOf(6), Integer.valueOf(8)));
|
||||
subscription.setLatencyInMinutes(3);
|
||||
|
||||
IProposeScheduleResponse response = service
|
||||
.proposeSchedule(subscription);
|
||||
|
||||
SubscriptionStatusSummary sum = service
|
||||
.getSubscriptionStatusSummary(subscription);
|
||||
|
||||
List<BandwidthAllocation> allocationList = bandwidthDao
|
||||
.getBandwidthAllocations(Network.OPSNET);
|
||||
long actualStartTime = allocationList.get(0).getStartTime()
|
||||
.getTimeInMillis();
|
||||
long actualEndTime = allocationList.get(0).getEndTime()
|
||||
.getTimeInMillis();
|
||||
|
||||
assertEquals("DataSize does not match", subscription.getDataSetSize(),
|
||||
sum.getDataSize());
|
||||
assertEquals("Latency does not match",
|
||||
subscription.getLatencyInMinutes(), sum.getLatency());
|
||||
assertEquals("Start time does not match", actualStartTime,
|
||||
sum.getStartTime());
|
||||
assertEquals("End time does not match", actualEndTime, sum.getEndTime());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProposeScheduleFragmentedSubscriptionReturnsStatusSummary() {
|
||||
Subscription<T, C> subscription = createSubscriptionThatFillsUpTwoBuckets();
|
||||
subscription.setLatencyInMinutes(6);
|
||||
subscription.setPriority(SubscriptionPriority.HIGH);
|
||||
|
||||
// Reserves a full bucket at 19700103 18:03:00 which fragments the
|
||||
// subscription to 19700103 18:00:00 and 18:06:00
|
||||
BandwidthAllocation allocation = createAllocationToReserveMiddleBucket(subscription);
|
||||
|
||||
retrievalManager.schedule(Arrays.asList(allocation));
|
||||
|
||||
IProposeScheduleResponse response = service
|
||||
.proposeSchedule(subscription);
|
||||
|
||||
SubscriptionStatusSummary sum = service
|
||||
.getSubscriptionStatusSummary(subscription);
|
||||
|
||||
List<BandwidthAllocation> allocationList = bandwidthDao
|
||||
.getBandwidthAllocations(Network.OPSNET);
|
||||
for (BandwidthAllocation ba : allocationList) {
|
||||
System.out.println(ba);
|
||||
}
|
||||
long actualStartTime = -1;
|
||||
long actualEndTime = -1;
|
||||
|
||||
for (BandwidthAllocation ba : allocationList) {
|
||||
if (ba instanceof SubscriptionRetrieval) {
|
||||
actualStartTime = ba.getStartTime().getTimeInMillis();
|
||||
actualEndTime = ba.getEndTime().getTimeInMillis();
|
||||
break;
|
||||
}
|
||||
}
|
||||
assertEquals("DataSize does not match", subscription.getDataSetSize(),
|
||||
sum.getDataSize());
|
||||
assertEquals("Latency does not match",
|
||||
subscription.getLatencyInMinutes(), sum.getLatency());
|
||||
assertEquals("Start time does not match", actualStartTime,
|
||||
sum.getStartTime());
|
||||
assertEquals("End time does not match", actualEndTime, sum.getEndTime());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a BandwidthAllocation that will fill up a bucket and reserve
|
||||
* itself for 01/03/1970 18:03:00
|
||||
*
|
||||
* @return the allocation
|
||||
*/
|
||||
private BandwidthAllocation createAllocationToReserveMiddleBucket(
|
||||
Subscription<T, C> subscription) {
|
||||
Calendar cal = TimeUtil.newCalendar();
|
||||
cal.set(Calendar.YEAR, 1970);
|
||||
cal.set(Calendar.MONTH, Calendar.JANUARY);
|
||||
cal.set(Calendar.DAY_OF_MONTH, 3);
|
||||
cal.set(Calendar.HOUR_OF_DAY, 18);
|
||||
cal.set(Calendar.MINUTE, 3);
|
||||
cal.set(Calendar.SECOND, 0);
|
||||
cal.set(Calendar.MILLISECOND, 0);
|
||||
|
||||
BandwidthAllocation allocation = new BandwidthAllocation();
|
||||
allocation.setStartTime(cal);
|
||||
allocation.setEndTime(cal);
|
||||
allocation.setNetwork(subscription.getRoute());
|
||||
allocation.setPriority(SubscriptionPriority.NORMAL);
|
||||
allocation.setAgentType("someAgent");
|
||||
allocation.setEstimatedSize(subscription.getDataSetSize() / 2);
|
||||
|
||||
return allocation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify that no subscriptions were unscheduled.
|
||||
*
|
||||
* @param unscheduledSubscriptions
|
||||
* the set of subscription names returned from the operation
|
||||
*/
|
||||
private static void verifyNoSubscriptionsWereUnscheduled(
|
||||
Set<String> unscheduledSubscriptions) {
|
||||
assertTrue("There should not be any unscheduled subscriptions.",
|
||||
unscheduledSubscriptions.isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify that the specific subscription name was returned as unscheduled in
|
||||
* the results.
|
||||
*
|
||||
* @param unscheduledSubscriptions
|
||||
* the set of unscheduled subscription names
|
||||
* @param subscription
|
||||
* the subscription
|
||||
*/
|
||||
private static void verifySubscriptionWasNotAbleToBeFullyScheduled(
|
||||
Set<String> unscheduledSubscriptions, @SuppressWarnings("rawtypes")
|
||||
Subscription subscription) {
|
||||
assertEquals(
|
||||
"One and only one subscription should not have been able to fully schedule",
|
||||
1, unscheduledSubscriptions.size());
|
||||
assertEquals("The wrong subscription name was returned as unscheduled",
|
||||
subscription.getName(), unscheduledSubscriptions.iterator()
|
||||
.next());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected Network getRouteToUseForSubscription() {
|
||||
return Network.OPSNET;
|
||||
}
|
||||
}
|
|
@ -1,87 +0,0 @@
|
|||
/**
|
||||
* 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.datadelivery.registry.handlers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.registry.DataSetMetaData;
|
||||
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
|
||||
import com.raytheon.uf.common.time.util.ImmutableDate;
|
||||
|
||||
/**
|
||||
* {@link IBaseDataSetMetaDataHandler} in-memory implementation.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 17, 2012 0726 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class BaseMemoryDataSetMetaDataHandler<T extends DataSetMetaData>
|
||||
extends
|
||||
BaseMemoryRegistryObjectHandler<T> implements
|
||||
IBaseDataSetMetaDataHandler<T> {
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Set<ImmutableDate> getDatesForDataSet(String dataSetName,
|
||||
String providerName) throws RegistryHandlerException {
|
||||
Set<ImmutableDate> dates = new HashSet<ImmutableDate>();
|
||||
|
||||
for (T obj : getAll()) {
|
||||
if (matches(dataSetName, obj.getDataSetName())
|
||||
&& matches(providerName, obj.getProviderName())) {
|
||||
dates.add(obj.getDate());
|
||||
}
|
||||
}
|
||||
|
||||
return dates;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<T> getByDataSet(String dataSetName,
|
||||
String providerName) throws RegistryHandlerException {
|
||||
List<T> retVal = new ArrayList<T>();
|
||||
|
||||
for (T obj : getAll()) {
|
||||
if (matches(dataSetName, obj.getDataSetName())
|
||||
&& matches(providerName, obj.getProviderName())) {
|
||||
retVal.add(obj);
|
||||
}
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
}
|
|
@ -1,170 +0,0 @@
|
|||
/**
|
||||
* 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.datadelivery.registry.handlers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.raytheon.uf.common.registry.ebxml.RegistryUtil;
|
||||
import com.raytheon.uf.common.registry.handler.IRegistryObjectHandler;
|
||||
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
|
||||
|
||||
/**
|
||||
* Base memory registry object handler.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 17, 2012 0726 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public abstract class BaseMemoryRegistryObjectHandler<T>
|
||||
implements IRegistryObjectHandler<T> {
|
||||
|
||||
private final Map<String, T> map = new HashMap<String, T>();
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public T getById(String id) throws RegistryHandlerException {
|
||||
return map.get(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<T> getAll() throws RegistryHandlerException {
|
||||
return new ArrayList<T>(map.values());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void store(T obj) throws RegistryHandlerException {
|
||||
map.put(RegistryUtil.getRegistryObjectKey(obj), obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void update(T obj) throws RegistryHandlerException {
|
||||
store(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public final void delete(T obj) throws RegistryHandlerException {
|
||||
delete(Arrays.asList(obj));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public final void delete(Collection<T> objects)
|
||||
throws RegistryHandlerException {
|
||||
delete(null, objects);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public final void delete(String username, T obj)
|
||||
throws RegistryHandlerException {
|
||||
delete(username, Arrays.asList(obj));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public final void delete(String username, Collection<T> objects)
|
||||
throws RegistryHandlerException {
|
||||
List<String> ids = new ArrayList<String>(objects.size());
|
||||
for (T obj : objects) {
|
||||
ids.add(RegistryUtil.getRegistryObjectKey(obj));
|
||||
}
|
||||
|
||||
deleteByIds(username, ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public final void deleteById(String username, String registryId)
|
||||
throws RegistryHandlerException {
|
||||
deleteByIds(username, Arrays.asList(registryId));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void deleteByIds(String username, List<String> registryIds)
|
||||
throws RegistryHandlerException {
|
||||
for (String id : registryIds) {
|
||||
map.remove(id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the attribute is null, or if the equals comparison
|
||||
* between attribute and value resolves as true.
|
||||
*
|
||||
* @param <TYPE>
|
||||
* the type of the attribute
|
||||
* @param attribute
|
||||
* the attribute
|
||||
* @param value
|
||||
* the value from the entity
|
||||
* @return true if the attribute is null, or if the equals comparison
|
||||
* between attribute and value resolves as true.
|
||||
*/
|
||||
protected <TYPE> boolean matches(TYPE attribute,
|
||||
TYPE value) {
|
||||
return attribute == null || attribute.equals(value);
|
||||
}
|
||||
}
|
|
@ -1,196 +0,0 @@
|
|||
/**
|
||||
* 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.datadelivery.registry.handlers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.registry.Network;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Subscription;
|
||||
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
|
||||
|
||||
/**
|
||||
* {@link IBaseSubscriptionHandler} in-memory implementation.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 17, 2012 0726 djohnson Initial creation
|
||||
* Feb 20, 2013 1543 djohnson Implement route filtering.
|
||||
* May 15, 2013 1040 mpduff Office Id now a set.
|
||||
* May 28, 2013 1650 djohnson Add getByNames.
|
||||
* Sep 11, 2013 2352 mpduff Add siteId to getSubscribedToDataSetNames method.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class BaseMemorySubscriptionHandler<T extends Subscription> extends
|
||||
BaseMemoryRegistryObjectHandler<T> implements
|
||||
IBaseSubscriptionHandler<T> {
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public T getByName(String name) throws RegistryHandlerException {
|
||||
for (T obj : getAll()) {
|
||||
if (matches(name, obj.getName())) {
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<T> getByNames(Collection<String> names)
|
||||
throws RegistryHandlerException {
|
||||
List<T> retVal = new ArrayList<T>();
|
||||
for (T obj : getAll()) {
|
||||
if (names.contains(obj.getName())) {
|
||||
retVal.add(obj);
|
||||
}
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<T> getByOwner(String owner) throws RegistryHandlerException {
|
||||
List<T> retVal = new ArrayList<T>();
|
||||
for (T obj : getAll()) {
|
||||
if (matches(owner, obj.getOwner())) {
|
||||
retVal.add(obj);
|
||||
}
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<T> getByGroupName(String group) throws RegistryHandlerException {
|
||||
List<T> retVal = new ArrayList<T>();
|
||||
for (T obj : getAll()) {
|
||||
if (matches(group, obj.getGroupName())) {
|
||||
retVal.add(obj);
|
||||
}
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Set<String> getSubscribedToDataSetNames(String siteId)
|
||||
throws RegistryHandlerException {
|
||||
Set<String> retVal = new HashSet<String>();
|
||||
for (T obj : getAll()) {
|
||||
if (matches(siteId, obj.getOfficeIDs())) {
|
||||
retVal.add(obj.getDataSetName());
|
||||
}
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<T> getByFilters(String group, String officeIds)
|
||||
throws RegistryHandlerException {
|
||||
List<T> retVal = new ArrayList<T>();
|
||||
for (T obj : getAll()) {
|
||||
if (matches(group, obj.getGroupName())
|
||||
&& matches(officeIds, obj.getOfficeIDs())) {
|
||||
retVal.add(obj);
|
||||
}
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<T> getActive() throws RegistryHandlerException {
|
||||
List<T> retVal = new ArrayList<T>();
|
||||
for (T obj : getAll()) {
|
||||
if (obj.isActive()) {
|
||||
retVal.add(obj);
|
||||
}
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<T> getActiveForRoute(Network route)
|
||||
throws RegistryHandlerException {
|
||||
Map<Network, List<T>> subMap = getActiveForRoutes(new Network[] { route });
|
||||
return subMap.get(route);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Map<Network, List<T>> getActiveForRoutes(Network... routes)
|
||||
throws RegistryHandlerException {
|
||||
Map<Network, List<T>> retVal = new HashMap<Network, List<T>>();
|
||||
for (T obj : getActive()) {
|
||||
for (Network route : routes) {
|
||||
if (route == obj.getRoute()) {
|
||||
if (retVal.get(route) == null) {
|
||||
retVal.put(route, new ArrayList<T>());
|
||||
}
|
||||
retVal.get(route).add(obj);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
}
|
|
@ -1,120 +0,0 @@
|
|||
/**
|
||||
* 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.datadelivery.registry.handlers;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.Matchers.emptyCollectionOf;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.rmi.RemoteException;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.registry.GroupDefinition;
|
||||
import com.raytheon.uf.common.datadelivery.registry.GroupDefinitionServiceRequest;
|
||||
import com.raytheon.uf.common.datadelivery.registry.SiteSubscription;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Subscription;
|
||||
import com.raytheon.uf.common.datadelivery.registry.SubscriptionBuilder;
|
||||
import com.raytheon.uf.common.datadelivery.service.GroupDefinitionService;
|
||||
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
|
||||
import com.raytheon.uf.common.registry.handler.RegistryObjectHandlersUtil;
|
||||
import com.raytheon.uf.edex.datadelivery.service.services.GroupDefinitionServiceHandler;
|
||||
|
||||
/**
|
||||
* Test {@link GroupDefinitionHandler}.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 18, 2013 1441 djohnson Initial creation
|
||||
* Feb 26, 2013 1643 djohnson Change exception type thrown.
|
||||
* Mar 28, 2013 1841 djohnson Subscription is now UserSubscription.
|
||||
* Jun 24, 2013 2106 djohnson RegistryManager is gone.
|
||||
* Nov 12, 2013 2506 bgonzale Refactored out notification service.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class GroupDefinitionServiceTest {
|
||||
|
||||
private static final String GROUP_NAME = "someGroup";
|
||||
|
||||
private ISubscriptionHandler subscriptionHandler;
|
||||
|
||||
private IGroupDefinitionHandler groupHandler;
|
||||
|
||||
private final GroupDefinitionService service = new GroupDefinitionService() {
|
||||
@Override
|
||||
protected Object getResponseFromServer(
|
||||
GroupDefinitionServiceRequest request) throws Exception {
|
||||
return new GroupDefinitionServiceHandler().handleRequest(request);
|
||||
}
|
||||
};
|
||||
|
||||
private final GroupDefinition group = new GroupDefinition();
|
||||
|
||||
@Before
|
||||
public void setUp() throws RegistryHandlerException {
|
||||
RegistryObjectHandlersUtil.initMemory();
|
||||
|
||||
subscriptionHandler = DataDeliveryHandlers.getSubscriptionHandler();
|
||||
groupHandler = DataDeliveryHandlers.getGroupDefinitionHandler();
|
||||
|
||||
group.setGroupName(GROUP_NAME);
|
||||
groupHandler.store(group);
|
||||
|
||||
SiteSubscription subscription = new SubscriptionBuilder()
|
||||
.withGroupName(
|
||||
GROUP_NAME).build();
|
||||
SiteSubscription subscription2 = new SiteSubscription(subscription,
|
||||
"sub2");
|
||||
|
||||
subscriptionHandler.store(subscription);
|
||||
subscriptionHandler.store(subscription2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deletingAGroupUpdatesSubscriptionsToNotHaveAGroupName()
|
||||
throws RemoteException, RegistryHandlerException {
|
||||
|
||||
service.deleteGroupDefinition(group);
|
||||
|
||||
assertThat(subscriptionHandler.getByGroupName(GROUP_NAME),
|
||||
is(emptyCollectionOf(Subscription.class)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deletingAGroupDeletesTheGroup() throws RemoteException,
|
||||
RegistryHandlerException {
|
||||
|
||||
service.deleteGroupDefinition(group);
|
||||
|
||||
assertNull(groupHandler.getByName(GROUP_NAME));
|
||||
}
|
||||
|
||||
}
|
|
@ -1,92 +0,0 @@
|
|||
/**
|
||||
* 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.datadelivery.registry.handlers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.geotools.geometry.jts.ReferencedEnvelope;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.registry.DataSet;
|
||||
import com.raytheon.uf.common.datadelivery.registry.DataLevelType.LevelType;
|
||||
import com.raytheon.uf.common.datadelivery.registry.ebxml.DataSetWithFiltersQuery;
|
||||
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
|
||||
|
||||
/**
|
||||
* {@link IDataSetHandler} in-memory implementation.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 17, 2012 0726 djohnson Initial creation
|
||||
* Nov 19, 2012 1166 djohnson Clean up JAXB representation of registry objects.
|
||||
* Dec 10, 2012 1259 bsteffen Switch Data Delivery from LatLon to referenced envelopes.
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class MemoryDataSetHandler extends
|
||||
BaseMemoryRegistryObjectHandler<DataSet> implements IDataSetHandler {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public DataSet getByNameAndProvider(String name, String providerName)
|
||||
throws RegistryHandlerException {
|
||||
for (DataSet obj : getAll()) {
|
||||
if (matches(name, obj.getDataSetName())
|
||||
&& matches(providerName, obj.getProviderName())) {
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<DataSet> getByFilters(List<String> providers,
|
||||
List<String> dataSetNames, Set<LevelType> levels,
|
||||
List<String> parameterNames, List<String> dataTypes,
|
||||
ReferencedEnvelope envelope) throws RegistryHandlerException {
|
||||
List<DataSet> retVal = new ArrayList<DataSet>();
|
||||
|
||||
for (DataSet obj : getAll()) {
|
||||
if ((providers == null || providers.contains(obj.getProviderName()))
|
||||
&& (dataSetNames == null || dataSetNames.contains(obj
|
||||
.getDataSetName()))) {
|
||||
if (DataSetWithFiltersQuery.satisfiesFilterCriteria(obj,
|
||||
levels, envelope)) {
|
||||
retVal.add(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
/**
|
||||
* 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.datadelivery.registry.handlers;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.registry.DataSetMetaData;
|
||||
|
||||
/**
|
||||
* {@link IDataSetMetaDataHandler} in-memory implementation.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 17, 2012 0726 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class MemoryDataSetMetaDataHandler extends
|
||||
BaseMemoryDataSetMetaDataHandler<DataSetMetaData> implements
|
||||
IDataSetMetaDataHandler {
|
||||
}
|
|
@ -1,67 +0,0 @@
|
|||
/**
|
||||
* 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.datadelivery.registry.handlers;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.registry.DataSetName;
|
||||
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
|
||||
|
||||
/**
|
||||
* {@link IDataSetNameHandler} in-memory implementation.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 17, 2012 0726 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class MemoryDataSetNameHandler extends
|
||||
BaseMemoryRegistryObjectHandler<DataSetName> implements
|
||||
IDataSetNameHandler {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Set<String> getByDataTypes(List<String> dataTypes)
|
||||
throws RegistryHandlerException {
|
||||
Set<String> retVal = new HashSet<String>();
|
||||
|
||||
for (DataSetName obj : getAll()) {
|
||||
if (dataTypes == null
|
||||
|| dataTypes.contains(obj.getDataSetType().toString())) {
|
||||
retVal.add(obj.getDataSetName());
|
||||
}
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
/**
|
||||
* 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.datadelivery.registry.handlers;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.registry.DataSetMetaData;
|
||||
import com.raytheon.uf.common.datadelivery.registry.GriddedDataSetMetaData;
|
||||
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
|
||||
|
||||
/**
|
||||
* {@link IGriddedDataSetMetaDataHandler} in-memory implementation.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 17, 2012 0726 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class MemoryGriddedDataSetMetaDataHandler extends
|
||||
BaseMemoryDataSetMetaDataHandler<DataSetMetaData>
|
||||
implements IGriddedDataSetMetaDataHandler {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public GriddedDataSetMetaData getByDataSetDateAndCycle(String dataSetName,
|
||||
String providerName, int cycle, Date date)
|
||||
throws RegistryHandlerException {
|
||||
|
||||
for (DataSetMetaData obj : getByDataSet(dataSetName,
|
||||
providerName)) {
|
||||
if (obj instanceof GriddedDataSetMetaData) {
|
||||
GriddedDataSetMetaData gdsdm = (GriddedDataSetMetaData) obj;
|
||||
if (gdsdm.getCycle() == cycle && matches(date, gdsdm.getDate())) {
|
||||
return gdsdm;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,91 +0,0 @@
|
|||
/**
|
||||
* 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.datadelivery.registry.handlers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.raytheon.uf.common.datadelivery.registry.GroupDefinition;
|
||||
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
|
||||
|
||||
/**
|
||||
* {@link IGroupDefinitionHandler} in-memory implementation.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 17, 2012 0726 djohnson Initial creation
|
||||
* Jan 02, 2013 1441 djohnson Add deleteByName() and getGroupNames().
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class MemoryGroupDefinitionHandler extends
|
||||
BaseMemoryRegistryObjectHandler<GroupDefinition> implements
|
||||
IGroupDefinitionHandler {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public GroupDefinition getByName(String groupName)
|
||||
throws RegistryHandlerException {
|
||||
for (GroupDefinition obj : getAll()) {
|
||||
if (matches(groupName, obj.getGroupName())) {
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void deleteByName(String groupName) throws RegistryHandlerException {
|
||||
GroupDefinition entity = getByName(groupName);
|
||||
if (entity != null) {
|
||||
delete(entity);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<String> getGroupNames() throws RegistryHandlerException {
|
||||
return new ArrayList<String>(Lists.transform(getAll(),
|
||||
new Function<GroupDefinition, String>() {
|
||||
@Override
|
||||
public String apply(GroupDefinition arg0) {
|
||||
return arg0.getGroupName();
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
}
|
|
@ -1,83 +0,0 @@
|
|||
/**
|
||||
* 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.datadelivery.registry.handlers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.registry.DataLevelType;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Parameter;
|
||||
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
|
||||
|
||||
/**
|
||||
* {@link IParameterHandler} in-memory implementation.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 17, 2012 0726 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
public class MemoryParameterHandler extends
|
||||
BaseMemoryRegistryObjectHandler<Parameter> implements IParameterHandler {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Set<String> getNamesByDataTypes(List<String> dataTypes)
|
||||
throws RegistryHandlerException {
|
||||
Set<String> names = new HashSet<String>();
|
||||
for (Parameter parameter : getAll()) {
|
||||
if (dataTypes == null
|
||||
|| dataTypes.contains(parameter.getDataType().toString())) {
|
||||
names.add(parameter.getName());
|
||||
}
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<String> getDataLevelTypeDescriptions(List<String> dataTypes)
|
||||
throws RegistryHandlerException {
|
||||
Set<String> descriptions = new HashSet<String>();
|
||||
for (Parameter parameter : getAll()) {
|
||||
List<DataLevelType> dataLevelTypes = parameter.getLevelType();
|
||||
|
||||
for (DataLevelType dataLevelType : dataLevelTypes) {
|
||||
String description = dataLevelType.getDescription();
|
||||
descriptions.add(description);
|
||||
}
|
||||
}
|
||||
return new ArrayList<String>(descriptions);
|
||||
}
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
/**
|
||||
* 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.datadelivery.registry.handlers;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.registry.ParameterLevel;
|
||||
|
||||
/**
|
||||
* {@link IParameterLevelHandler} in-memory implementation.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 17, 2012 0726 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class MemoryParameterLevelHandler extends
|
||||
BaseMemoryRegistryObjectHandler<ParameterLevel> implements
|
||||
IParameterLevelHandler {
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
/**
|
||||
* 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.datadelivery.registry.handlers;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.registry.InitialPendingSharedSubscription;
|
||||
|
||||
/**
|
||||
* {@link IPendingSharedSubscriptionHandler} in-memory implementation.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* May 29, 2013 1650 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class MemoryPendingSharedSubscriptionHandler extends
|
||||
MemoryPendingSubscriptionTypeHandler<InitialPendingSharedSubscription>
|
||||
implements IPendingSharedSubscriptionHandler {
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
/**
|
||||
* 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.datadelivery.registry.handlers;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.registry.InitialPendingSiteSubscription;
|
||||
|
||||
/**
|
||||
* {@link IPendingSiteSubscriptionHandler} in-memory implementation.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* May 29, 2013 1650 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class MemoryPendingSiteSubscriptionHandler extends
|
||||
MemoryPendingSubscriptionTypeHandler<InitialPendingSiteSubscription>
|
||||
implements IPendingSiteSubscriptionHandler {
|
||||
}
|
|
@ -1,114 +0,0 @@
|
|||
/**
|
||||
* 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.datadelivery.registry.handlers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.registry.InitialPendingSubscription;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Subscription;
|
||||
import com.raytheon.uf.common.registry.ebxml.RegistryUtil;
|
||||
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
|
||||
|
||||
/**
|
||||
* {@link IPendingSubscriptionHandler} in-memory implementation.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 17, 2012 0726 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class MemoryPendingSubscriptionTypeHandler<T extends InitialPendingSubscription>
|
||||
extends BaseMemorySubscriptionHandler<T> implements
|
||||
IBasePendingSubscriptionHandler<T> {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void store(T obj) throws RegistryHandlerException {
|
||||
// TODO: Store an in-memory association to the subscription
|
||||
super.store(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void deleteByIds(String username, List<String> registryIds)
|
||||
throws RegistryHandlerException {
|
||||
// TODO: Delete in-memory association to the subscription
|
||||
super.deleteByIds(username, registryIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public T getBySubscription(Subscription subscription)
|
||||
throws RegistryHandlerException {
|
||||
return getBySubscriptionId(RegistryUtil
|
||||
.getRegistryObjectKey(subscription));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public T getBySubscriptionId(String id) throws RegistryHandlerException {
|
||||
List<T> results = getBySubscriptionIds(Arrays.asList(id));
|
||||
return (!results.isEmpty()) ? results.iterator().next() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<T> getBySubscriptions(Collection<Subscription> subscriptions)
|
||||
throws RegistryHandlerException {
|
||||
List<String> ids = new ArrayList<String>(subscriptions.size());
|
||||
for (Subscription subscription : subscriptions) {
|
||||
ids.add(RegistryUtil.getRegistryObjectKey(subscription));
|
||||
}
|
||||
return getBySubscriptionIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<T> getBySubscriptionIds(List<String> ids)
|
||||
throws RegistryHandlerException {
|
||||
// TODO: Lookup via an in-memory association
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
/**
|
||||
* 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.datadelivery.registry.handlers;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.registry.Provider;
|
||||
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
|
||||
|
||||
/**
|
||||
* {@link IProviderHandler} in-memory implementation.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 17, 2012 0726 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class MemoryProviderHandler extends
|
||||
BaseMemoryRegistryObjectHandler<Provider> implements IProviderHandler {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Provider getByName(String providerName)
|
||||
throws RegistryHandlerException {
|
||||
for (Provider provider : getAll()) {
|
||||
if (matches(providerName, provider.getName())) {
|
||||
return provider;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
/**
|
||||
* 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.datadelivery.registry.handlers;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.registry.SharedSubscription;
|
||||
|
||||
/**
|
||||
* {@link ISharedSubscriptionHandler} in-memory implementation.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* May 29, 2013 1650 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class MemorySharedSubscriptionHandler extends
|
||||
MemorySubscriptionTypeHandler<SharedSubscription> implements
|
||||
ISharedSubscriptionHandler {
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
/**
|
||||
* 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.datadelivery.registry.handlers;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.registry.SiteSubscription;
|
||||
|
||||
/**
|
||||
* {@link ISubscriptionHandler} in-memory implementation.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 17, 2012 0726 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class MemorySiteSubscriptionHandler extends
|
||||
MemorySubscriptionTypeHandler<SiteSubscription> implements
|
||||
ISiteSubscriptionHandler {
|
||||
}
|
|
@ -1,115 +0,0 @@
|
|||
/**
|
||||
* 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.datadelivery.registry.handlers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.registry.InitialPendingSubscription;
|
||||
import com.raytheon.uf.common.datadelivery.registry.PendingSubscription;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Subscription;
|
||||
import com.raytheon.uf.common.registry.ebxml.RegistryUtil;
|
||||
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
|
||||
import com.raytheon.uf.common.registry.handler.RegistryObjectHandlers;
|
||||
import com.raytheon.uf.common.util.CollectionUtil;
|
||||
|
||||
/**
|
||||
* Base {@link ISubscriptionTypeHandler} in-memory implementation.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* May 29, 2013 1650 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public abstract class MemorySubscriptionTypeHandler<T extends Subscription>
|
||||
extends BaseMemorySubscriptionHandler<T> implements
|
||||
IBaseSubscriptionHandler<T>, ISubscriptionTypeHandler<T> {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public T getByPendingSubscription(PendingSubscription pending)
|
||||
throws RegistryHandlerException {
|
||||
return getByPendingSubscriptionId(RegistryUtil
|
||||
.getRegistryObjectKey(pending));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public T getByPendingSubscriptionId(final String id)
|
||||
throws RegistryHandlerException {
|
||||
// TODO: lookup via in-memory association
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overridden because subscriptions must also have their
|
||||
* {@link PendingSubscription} object deleted.
|
||||
*
|
||||
* @param username
|
||||
* the username of the requester
|
||||
* @param ids
|
||||
* the registry ids of the subscription objects
|
||||
*/
|
||||
@Override
|
||||
public void deleteByIds(String username, List<String> ids)
|
||||
throws RegistryHandlerException {
|
||||
IPendingSubscriptionHandler handler = RegistryObjectHandlers
|
||||
.get(IPendingSubscriptionHandler.class);
|
||||
|
||||
List<InitialPendingSubscription> pending = handler
|
||||
.getBySubscriptionIds(ids);
|
||||
if (!CollectionUtil.isNullOrEmpty(pending)) {
|
||||
handler.delete(username, pending);
|
||||
}
|
||||
|
||||
super.deleteByIds(username, ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<T> getActiveByDataSetAndProvider(String dataSetName,
|
||||
String providerName) throws RegistryHandlerException {
|
||||
List<T> retVal = new ArrayList<T>();
|
||||
|
||||
for (T obj : getActive()) {
|
||||
if (matches(dataSetName, obj.getDataSetName())
|
||||
&& matches(providerName, obj.getProvider())) {
|
||||
retVal.add(obj);
|
||||
}
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
}
|
|
@ -1,220 +0,0 @@
|
|||
/**
|
||||
* 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.registry.ebxml;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.net.ConnectException;
|
||||
import java.rmi.RemoteException;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.apache.http.HttpHost;
|
||||
import org.apache.http.conn.HttpHostConnectException;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.raytheon.uf.common.comm.CommunicationException;
|
||||
import com.raytheon.uf.common.registry.IRegistryRequest;
|
||||
import com.raytheon.uf.common.registry.OperationStatus;
|
||||
import com.raytheon.uf.common.registry.RegistryQueryResponse;
|
||||
import com.raytheon.uf.common.registry.RegistryResponse;
|
||||
import com.raytheon.uf.common.registry.constants.RegistryErrorMessage;
|
||||
import com.raytheon.uf.common.serialization.SerializationException;
|
||||
|
||||
/**
|
||||
* Test {@link ThriftRegistryHandler}.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jul 12, 2012 740 djohnson Initial creation
|
||||
* Sep 12, 2012 1167 djohnson Use localization.
|
||||
* Nov 15, 2012 1286 djohnson No constructor arguments for ThriftRegistryHandler.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
public class ThriftRegistryHandlerTest {
|
||||
|
||||
private static final HttpHostConnectException HTTP_HOST_CONNECT_EXCEPTION = new HttpHostConnectException(
|
||||
new HttpHost("someHost"), new ConnectException(
|
||||
"'cause I done thrown it."));
|
||||
|
||||
private static final CommunicationException COMMUNICATION_EXCEPTION = new CommunicationException(
|
||||
RegistryErrorMessage.DATABASE_ERROR_MESSAGE);
|
||||
|
||||
@Test
|
||||
public void testGetObjectsReturnsFailedStatusIfHttpHostConnectExceptionThrown() {
|
||||
RegistryQueryResponse<Object> response = getExceptionThrowingHandler(
|
||||
HTTP_HOST_CONNECT_EXCEPTION).getObjects(null);
|
||||
|
||||
assertEquals(OperationStatus.FAILED, response.getStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetObjectsReturnsUnableToConnectMessageIfHttpHostConnectExceptionThrown() {
|
||||
RegistryQueryResponse<Object> response = getExceptionThrowingHandler(
|
||||
HTTP_HOST_CONNECT_EXCEPTION).getObjects(null);
|
||||
|
||||
assertEquals(RegistryErrorMessage.UNABLE_TO_CONNECT_TO_REGISTRY,
|
||||
response.getErrors().iterator().next().getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemoveObjectsWithQueryReturnsUnableToConnectMessageIfHttpHostConnectExceptionThrown() {
|
||||
RegistryResponse<Object> response = getExceptionThrowingHandler(
|
||||
HTTP_HOST_CONNECT_EXCEPTION).removeObjects(null);
|
||||
|
||||
assertEquals(RegistryErrorMessage.UNABLE_TO_CONNECT_TO_REGISTRY,
|
||||
response.getErrors().iterator().next().getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemoveObjectsWithObjectsReturnsUnableToConnectMessageIfHttpHostConnectExceptionThrown() {
|
||||
RegistryResponse<Object> response = getExceptionThrowingHandler(
|
||||
HTTP_HOST_CONNECT_EXCEPTION).removeObjects("someUsername",
|
||||
Collections.emptyList());
|
||||
|
||||
assertEquals(RegistryErrorMessage.UNABLE_TO_CONNECT_TO_REGISTRY,
|
||||
response.getErrors().iterator().next().getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStoreObjectReturnsUnableToConnectMessageIfHttpHostConnectExceptionThrown() {
|
||||
RegistryResponse<Object> response = getExceptionThrowingHandler(
|
||||
HTTP_HOST_CONNECT_EXCEPTION).storeObject(null);
|
||||
|
||||
assertEquals(RegistryErrorMessage.UNABLE_TO_CONNECT_TO_REGISTRY,
|
||||
response.getErrors().iterator().next().getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemoveObjectsWithQueryReturnsFailedStatusIfHttpHostConnectExceptionThrown() {
|
||||
RegistryResponse<Object> response = getExceptionThrowingHandler(
|
||||
HTTP_HOST_CONNECT_EXCEPTION).removeObjects(null);
|
||||
|
||||
assertEquals(OperationStatus.FAILED, response.getStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemoveObjectsWithObjectsReturnsFailedStatusIfHttpHostConnectExceptionThrown() {
|
||||
RegistryResponse<Object> response = getExceptionThrowingHandler(
|
||||
HTTP_HOST_CONNECT_EXCEPTION).removeObjects("someUsername",
|
||||
Collections.emptyList());
|
||||
|
||||
assertEquals(OperationStatus.FAILED, response.getStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStoreObjectReturnsFailedStatusIfHttpHostConnectExceptionThrown() {
|
||||
RegistryResponse<Object> response = getExceptionThrowingHandler(
|
||||
HTTP_HOST_CONNECT_EXCEPTION).storeObject(null);
|
||||
|
||||
assertEquals(OperationStatus.FAILED, response.getStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetObjectsReturnsFailedStatusIfCommunicationExceptionThrown() {
|
||||
RegistryQueryResponse<Object> response = getExceptionThrowingHandler(
|
||||
COMMUNICATION_EXCEPTION).getObjects(null);
|
||||
|
||||
assertEquals(OperationStatus.FAILED, response.getStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetObjectsReturnsFailedToConnectToTheDatabaseIfCommunicationExceptionThrown() {
|
||||
RegistryQueryResponse<Object> response = getExceptionThrowingHandler(
|
||||
COMMUNICATION_EXCEPTION).getObjects(null);
|
||||
|
||||
assertEquals(RegistryErrorMessage.FAILED_TO_CONNECT_TO_DATABASE,
|
||||
response.getErrors().iterator().next().getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemoveObjectsWithQueryReturnsUnableToConnectMessageIfCommunicationExceptionThrown() {
|
||||
RegistryResponse<Object> response = getExceptionThrowingHandler(
|
||||
COMMUNICATION_EXCEPTION).removeObjects(null);
|
||||
|
||||
assertEquals(RegistryErrorMessage.FAILED_TO_CONNECT_TO_DATABASE,
|
||||
response.getErrors().iterator().next().getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemoveObjectsWithObjectsReturnsUnableToConnectMessageIfCommunicationExceptionThrown() {
|
||||
RegistryResponse<Object> response = getExceptionThrowingHandler(
|
||||
COMMUNICATION_EXCEPTION).removeObjects("someUsername",
|
||||
Collections.emptyList());
|
||||
|
||||
assertEquals(RegistryErrorMessage.FAILED_TO_CONNECT_TO_DATABASE,
|
||||
response.getErrors().iterator().next().getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStoreObjectReturnsUnableToConnectMessageIfCommunicationExceptionThrown() {
|
||||
RegistryResponse<Object> response = getExceptionThrowingHandler(
|
||||
COMMUNICATION_EXCEPTION).storeObject(null);
|
||||
|
||||
assertEquals(RegistryErrorMessage.FAILED_TO_CONNECT_TO_DATABASE,
|
||||
response.getErrors().iterator().next().getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemoveObjectsWithQueryReturnsFailedStatusIfCommunicationExceptionThrown() {
|
||||
RegistryResponse<Object> response = getExceptionThrowingHandler(
|
||||
COMMUNICATION_EXCEPTION).removeObjects(null);
|
||||
|
||||
assertEquals(OperationStatus.FAILED, response.getStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemoveObjectsWithObjectsReturnsFailedStatusIfCommunicationExceptionThrown() {
|
||||
RegistryResponse<Object> response = getExceptionThrowingHandler(
|
||||
COMMUNICATION_EXCEPTION).removeObjects("someUsername",
|
||||
Collections.emptyList());
|
||||
|
||||
assertEquals(OperationStatus.FAILED, response.getStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStoreObjectReturnsFailedStatusIfCommunicationExceptionThrown() {
|
||||
RegistryResponse<Object> response = getExceptionThrowingHandler(
|
||||
COMMUNICATION_EXCEPTION).storeObject(null);
|
||||
|
||||
assertEquals(OperationStatus.FAILED, response.getStatus());
|
||||
}
|
||||
|
||||
private static <T extends Exception> ThriftRegistryHandler getExceptionThrowingHandler(
|
||||
final T t) {
|
||||
ThriftRegistryHandler handler = new ThriftRegistryHandler() {
|
||||
@Override
|
||||
<U> RegistryResponse<U> sendRequestViaThrift(
|
||||
IRegistryRequest<U> request) throws SerializationException,
|
||||
RemoteException {
|
||||
throw new RemoteException(
|
||||
"Error communicating with the server", t);
|
||||
}
|
||||
};
|
||||
return handler;
|
||||
}
|
||||
}
|
|
@ -1,150 +0,0 @@
|
|||
/**
|
||||
* 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.edex.datadelivery.bandwidth.retrieval;
|
||||
|
||||
import static org.hamcrest.Matchers.emptyCollectionOf;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.registry.Network;
|
||||
import com.raytheon.uf.common.datadelivery.registry.OpenDapGriddedDataSetMetaDataFixture;
|
||||
import com.raytheon.uf.common.datadelivery.registry.ProviderFixture;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Subscription;
|
||||
import com.raytheon.uf.common.datadelivery.registry.SubscriptionBuilder;
|
||||
import com.raytheon.uf.common.datadelivery.registry.handlers.DataDeliveryHandlers;
|
||||
import com.raytheon.uf.common.localization.PathManagerFactoryTest;
|
||||
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
|
||||
import com.raytheon.uf.common.registry.handler.RegistryObjectHandlersUtil;
|
||||
import com.raytheon.uf.common.serialization.SerializationException;
|
||||
import com.raytheon.uf.common.util.SpringFiles;
|
||||
import com.raytheon.uf.edex.core.EdexException;
|
||||
import com.raytheon.uf.edex.database.DataAccessLayerException;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDao;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionRetrieval;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionRetrievalAttributes;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.db.IRetrievalDao;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecord;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecord.State;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecordPK;
|
||||
|
||||
/**
|
||||
* Test {@link SubscriptionRetrievalAgent}.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 30, 2013 1543 djohnson Initial creation
|
||||
* Jul 10, 2013 2106 djohnson Inject providerHandler.
|
||||
* Jan 15, 2014 2678 bgonzale Added Queue.
|
||||
* Jan 30, 2014 2686 dhladky refactor of retrieval.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = { SpringFiles.UNIT_TEST_DB_BEANS_XML,
|
||||
SpringFiles.BANDWIDTH_DATADELIVERY_DAOS_XML,
|
||||
SpringFiles.RETRIEVAL_DATADELIVERY_DAOS_XML })
|
||||
public class SubscriptionRetrievalAgentTest {
|
||||
|
||||
@Autowired
|
||||
@Qualifier(value = "retrievalDao")
|
||||
private IRetrievalDao retrievalDao;
|
||||
|
||||
private final ConcurrentLinkedQueue<RetrievalRequestRecordPK> retrievalQueue = new ConcurrentLinkedQueue<RetrievalRequestRecordPK>();
|
||||
|
||||
@Before
|
||||
public void setUp() throws RegistryHandlerException {
|
||||
PathManagerFactoryTest.initLocalization();
|
||||
RegistryObjectHandlersUtil.initMocks();
|
||||
when(DataDeliveryHandlers.getProviderHandler().getByName(anyString()))
|
||||
.thenReturn(ProviderFixture.INSTANCE.get());
|
||||
when(
|
||||
DataDeliveryHandlers.getDataSetMetaDataHandler().getById(
|
||||
anyString())).thenReturn(
|
||||
OpenDapGriddedDataSetMetaDataFixture.INSTANCE.get());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void opsnetRoutedSubscriptionsCreateRetrievalsInPendingState()
|
||||
throws EdexException, SerializationException {
|
||||
testRetrievalIsPlacedInCorrectState(Network.OPSNET, State.PENDING);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sbnRoutedSubscriptionsCreateRetrievalsInPendingState()
|
||||
throws EdexException, SerializationException {
|
||||
testRetrievalIsPlacedInCorrectState(Network.SBN, State.PENDING);
|
||||
}
|
||||
|
||||
private void testRetrievalIsPlacedInCorrectState(final Network route,
|
||||
final State expectedState) throws SerializationException,
|
||||
EdexException, DataAccessLayerException {
|
||||
Subscription subscription = new SubscriptionBuilder().withRoute(route)
|
||||
.build();
|
||||
final SubscriptionRetrieval subscriptionRetrieval = new SubscriptionRetrieval();
|
||||
subscriptionRetrieval.setNetwork(subscription.getRoute());
|
||||
|
||||
SubscriptionRetrievalAttributes attributes = new SubscriptionRetrievalAttributes();
|
||||
attributes.setSubscriptionRetrieval(subscriptionRetrieval);
|
||||
attributes.setSubscription(subscription);
|
||||
|
||||
IBandwidthDao bandwidthDao = mock(IBandwidthDao.class);
|
||||
when(
|
||||
bandwidthDao
|
||||
.getSubscriptionRetrievalAttributes(subscriptionRetrieval))
|
||||
.thenReturn(attributes);
|
||||
|
||||
SubscriptionRetrievalAgent agent = new SubscriptionRetrievalAgent(
|
||||
route, "someUri", new Object(), 1, null, bandwidthDao,
|
||||
retrievalDao, DataDeliveryHandlers.getProviderHandler()) {
|
||||
|
||||
};
|
||||
agent.processAllocation(subscriptionRetrieval);
|
||||
|
||||
final List<RetrievalRequestRecord> requests = retrievalDao
|
||||
.getRequests(subscription.getName());
|
||||
assertThat(requests,
|
||||
is(not(emptyCollectionOf(RetrievalRequestRecord.class))));
|
||||
final RetrievalRequestRecord request = requests.iterator().next();
|
||||
|
||||
assertThat(request.getState(), is(expectedState));
|
||||
}
|
||||
}
|
|
@ -1,102 +0,0 @@
|
|||
/**
|
||||
* 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.edex.datadelivery.bandwidth.util;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.registry.Network;
|
||||
import com.raytheon.uf.common.datadelivery.registry.SiteSubscription;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Subscription;
|
||||
import com.raytheon.uf.common.datadelivery.registry.SubscriptionBuilder;
|
||||
import com.raytheon.uf.common.datadelivery.registry.handlers.DataDeliveryHandlers;
|
||||
import com.raytheon.uf.common.datadelivery.registry.handlers.ISubscriptionHandler;
|
||||
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
|
||||
import com.raytheon.uf.common.registry.handler.RegistryObjectHandlersUtil;
|
||||
|
||||
/**
|
||||
* Test {@link FindActiveSubscriptionsForRoute}.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 19, 2013 1543 djohnson Initial creation
|
||||
* Mar 28, 2013 1841 djohnson Subscription is now UserSubscription.
|
||||
* Jul 10, 2013 2106 djohnson Inject subscriptionHandler.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class FindActiveSubscriptionsForRouteTest {
|
||||
private static ISubscriptionHandler subscriptionHandler;
|
||||
|
||||
@BeforeClass
|
||||
public static void classSetUp() throws RegistryHandlerException {
|
||||
RegistryObjectHandlersUtil.initMemory();
|
||||
subscriptionHandler = DataDeliveryHandlers.getSubscriptionHandler();
|
||||
|
||||
// Two OPSNET subscriptions
|
||||
final SiteSubscription opsnetSub1 = new SubscriptionBuilder()
|
||||
.withName("opsnetSub1").withRoute(Network.OPSNET).build();
|
||||
final SiteSubscription opsnetSub2 = new SiteSubscription(opsnetSub1,
|
||||
"opsnetSub2");
|
||||
|
||||
// Two SBN subscriptions
|
||||
final SiteSubscription sbnSub1 = new SubscriptionBuilder()
|
||||
.withName("sbnSub1").withRoute(Network.SBN).build();
|
||||
final SiteSubscription sbnSub2 = new SiteSubscription(sbnSub1,
|
||||
"sbnSub2");
|
||||
|
||||
// Store all subscriptions
|
||||
for (Subscription sub : new Subscription[] { opsnetSub1, opsnetSub2,
|
||||
sbnSub1, sbnSub2 }) {
|
||||
subscriptionHandler.store(sub);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findsSubscriptionForSingleRoute()
|
||||
throws RegistryHandlerException {
|
||||
// final Set<Subscription> subscriptions = new
|
||||
// FindActiveSubscriptionsForRoute(
|
||||
// subscriptionHandler, Network.SBN).findSubscriptionsToSchedule();
|
||||
// assertThat(subscriptions, hasSize(2));
|
||||
// for (Subscription subscription : subscriptions) {
|
||||
// assertThat(subscription.getRoute(), is(Network.SBN));
|
||||
// }
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findsSubscriptionsForMultipleRoutes()
|
||||
throws RegistryHandlerException {
|
||||
// final Set<Subscription> subscriptions = new
|
||||
// FindActiveSubscriptionsForRoute(
|
||||
// subscriptionHandler, Network.OPSNET, Network.SBN)
|
||||
// .findSubscriptionsToSchedule();
|
||||
// assertThat(subscriptions, hasSize(4));
|
||||
}
|
||||
|
||||
}
|
|
@ -1,307 +0,0 @@
|
|||
/**
|
||||
* 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.edex.datadelivery.service.verify;
|
||||
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.Matchers.same;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.registry.DataDeliveryRegistryObjectTypes;
|
||||
import com.raytheon.uf.common.datadelivery.registry.DataSet;
|
||||
import com.raytheon.uf.common.datadelivery.registry.DataType;
|
||||
import com.raytheon.uf.common.datadelivery.registry.OpenDapGriddedDataSet;
|
||||
import com.raytheon.uf.common.datadelivery.registry.SiteSubscriptionFixture;
|
||||
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.ISubscriptionHandler;
|
||||
import com.raytheon.uf.common.event.EventBus;
|
||||
import com.raytheon.uf.common.registry.event.InsertRegistryEvent;
|
||||
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
|
||||
import com.raytheon.uf.common.registry.handler.RegistryObjectHandlersUtil;
|
||||
import com.raytheon.uf.edex.datadelivery.service.verify.SubscriptionIntegrityVerifier.IVerificationAction;
|
||||
import com.raytheon.uf.edex.datadelivery.service.verify.SubscriptionIntegrityVerifier.IVerificationResponse;
|
||||
import com.raytheon.uf.edex.datadelivery.service.verify.SubscriptionIntegrityVerifier.IVerificationStrategy;
|
||||
|
||||
/**
|
||||
* Test {@link SubscriptionIntegrityVerifier}.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Dec 07, 2012 1104 djohnson Initial creation
|
||||
* Feb 05, 2013 1580 mpduff EventBus refactor.
|
||||
* Oct 21, 2013 2292 mpduff Implement multiple data types.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
public class SubscriptionIntegrityVerifierTest {
|
||||
|
||||
private static final String FAILED_VERIFICATION_MESSAGE = "Failed verification";
|
||||
|
||||
private final OpenDapGriddedDataSet dataSet = new OpenDapGriddedDataSet();
|
||||
|
||||
private final Subscription sub1 = SiteSubscriptionFixture.INSTANCE.get(1,
|
||||
DataType.GRID);
|
||||
|
||||
private final Subscription sub2 = SiteSubscriptionFixture.INSTANCE.get(2,
|
||||
DataType.GRID);
|
||||
|
||||
private final List<Subscription> subscriptions = Arrays.asList(sub1, sub2);
|
||||
|
||||
// Initializer to setup the mock data delivery handlers
|
||||
{
|
||||
RegistryObjectHandlersUtil.initMocks();
|
||||
}
|
||||
|
||||
private final ISubscriptionHandler subscriptionHandler = DataDeliveryHandlers
|
||||
.getSubscriptionHandler();
|
||||
|
||||
private final IVerificationStrategy verificationStrategy = mock(IVerificationStrategy.class);
|
||||
|
||||
private final IVerificationAction successfulVerificationAction = mock(IVerificationAction.class);
|
||||
|
||||
private final IVerificationAction failedVerificationAction = mock(IVerificationAction.class);
|
||||
|
||||
private final SubscriptionIntegrityVerifier verifier = SubscriptionIntegrityVerifier
|
||||
.newInstance(verificationStrategy,
|
||||
Arrays.asList(successfulVerificationAction),
|
||||
Arrays.asList(failedVerificationAction));
|
||||
|
||||
private final InsertRegistryEvent dataSetUpdateEvent = new InsertRegistryEvent(
|
||||
"someId", "someLid", DataDeliveryRegistryObjectTypes.DATASET);
|
||||
|
||||
@Before
|
||||
public void setUp() throws RegistryHandlerException {
|
||||
whenRegistryEventIdLookedUpReturnDataSet();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
EventBus.unregister(verifier);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSubscriptionsForDataSetAreRetrieved()
|
||||
throws RegistryHandlerException {
|
||||
|
||||
EventBus.publish(dataSetUpdateEvent);
|
||||
|
||||
verifySubscriptionsAreRetrievedForDataSet();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSubscriptionsAreVerifiedAgainstDataSet()
|
||||
throws RegistryHandlerException {
|
||||
|
||||
whenSubscriptionsAreRetrievedForDataSetReturnTwo();
|
||||
whenSubscriptionIsVerifiedItSucceeds(sub1);
|
||||
whenSubscriptionIsVerifiedItSucceeds(sub2);
|
||||
|
||||
EventBus.publish(dataSetUpdateEvent);
|
||||
|
||||
verifyEachSubscriptionIsVerifiedAgainstDataSet();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSubscriptionsAlreadyInvalidAreNotVerifiedAgainstDataSet()
|
||||
throws RegistryHandlerException {
|
||||
|
||||
whenSubscriptionsAreRetrievedForDataSetReturnTwo();
|
||||
whenSubscriptionIsVerifiedItSucceeds(sub1);
|
||||
// sub2 is already invalid, should not be verified
|
||||
sub2.setValid(false);
|
||||
|
||||
EventBus.publish(dataSetUpdateEvent);
|
||||
|
||||
verifySubscriptionIsNotVerifiedAgainstDataSet(sub2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailedVerificationActionsAreInvokedForSubscriptionsFailingVerification()
|
||||
throws RegistryHandlerException {
|
||||
|
||||
whenSubscriptionsAreRetrievedForDataSetReturnTwo();
|
||||
whenSubscriptionIsVerifiedItSucceeds(sub1);
|
||||
whenSubscriptionIsVerifiedItFails(sub2);
|
||||
|
||||
EventBus.publish(dataSetUpdateEvent);
|
||||
|
||||
verifyFailedVerificationActionInvoked(sub2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailedVerificationActionsAreNotInvokedForSubscriptionsPassingVerification()
|
||||
throws RegistryHandlerException {
|
||||
|
||||
whenSubscriptionsAreRetrievedForDataSetReturnTwo();
|
||||
whenSubscriptionIsVerifiedItSucceeds(sub1);
|
||||
whenSubscriptionIsVerifiedItFails(sub2);
|
||||
EventBus.publish(dataSetUpdateEvent);
|
||||
|
||||
verifyFailedVerificationActionNotInvoked(sub1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccessfulVerificationActionsAreNotInvokedForSubscriptionsFailingVerification()
|
||||
throws RegistryHandlerException {
|
||||
|
||||
whenSubscriptionsAreRetrievedForDataSetReturnTwo();
|
||||
whenSubscriptionIsVerifiedItSucceeds(sub1);
|
||||
whenSubscriptionIsVerifiedItFails(sub2);
|
||||
|
||||
EventBus.publish(dataSetUpdateEvent);
|
||||
|
||||
verifySuccessfulVerificationActionNotInvoked(sub2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccessfulVerificationActionsAreInvokedForSubscriptionsPassingVerification()
|
||||
throws RegistryHandlerException {
|
||||
|
||||
whenSubscriptionsAreRetrievedForDataSetReturnTwo();
|
||||
whenSubscriptionIsVerifiedItSucceeds(sub1);
|
||||
whenSubscriptionIsVerifiedItFails(sub2);
|
||||
|
||||
EventBus.publish(dataSetUpdateEvent);
|
||||
|
||||
verifySuccessfulVerificationActionInvoked(sub1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnableToRetrieveSubscriptionsDoesNotThrowException()
|
||||
throws RegistryHandlerException {
|
||||
|
||||
whenSubscriptionsAreRetrievedForDataSetThrowException();
|
||||
|
||||
EventBus.publish(dataSetUpdateEvent);
|
||||
|
||||
verifySuccessfulVerificationActionNotInvoked(sub1);
|
||||
verifySuccessfulVerificationActionNotInvoked(sub2);
|
||||
verifyFailedVerificationActionNotInvoked(sub1);
|
||||
verifyFailedVerificationActionNotInvoked(sub2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the DataSet instance when a query is looked up via the registry
|
||||
* handler.
|
||||
*
|
||||
* @throws RegistryHandlerException
|
||||
*/
|
||||
private void whenRegistryEventIdLookedUpReturnDataSet()
|
||||
throws RegistryHandlerException {
|
||||
when(
|
||||
DataDeliveryHandlers.getDataSetHandler().getById(
|
||||
dataSetUpdateEvent.getId())).thenReturn(dataSet);
|
||||
|
||||
}
|
||||
|
||||
private void verifyFailedVerificationActionInvoked(Subscription subscription) {
|
||||
verify(failedVerificationAction).verificationPerformed(
|
||||
same(subscription), any(IVerificationResponse.class));
|
||||
}
|
||||
|
||||
private void verifyFailedVerificationActionNotInvoked(
|
||||
Subscription subscription) {
|
||||
verify(failedVerificationAction, never()).verificationPerformed(
|
||||
same(subscription), any(IVerificationResponse.class));
|
||||
}
|
||||
|
||||
private void verifySuccessfulVerificationActionInvoked(
|
||||
Subscription subscription) {
|
||||
verify(successfulVerificationAction).verificationPerformed(
|
||||
same(subscription), any(IVerificationResponse.class));
|
||||
}
|
||||
|
||||
private void verifySuccessfulVerificationActionNotInvoked(
|
||||
Subscription subscription) {
|
||||
verify(successfulVerificationAction, never()).verificationPerformed(
|
||||
same(subscription), any(IVerificationResponse.class));
|
||||
}
|
||||
|
||||
private void verifySubscriptionsAreRetrievedForDataSet()
|
||||
throws RegistryHandlerException {
|
||||
verify(DataDeliveryHandlers.getSubscriptionHandler())
|
||||
.getActiveByDataSetAndProvider(dataSet.getDataSetName(),
|
||||
dataSet.getProviderName());
|
||||
}
|
||||
|
||||
private void whenSubscriptionsAreRetrievedForDataSetReturnTwo()
|
||||
throws RegistryHandlerException {
|
||||
when(
|
||||
subscriptionHandler.getActiveByDataSetAndProvider(anyString(),
|
||||
anyString())).thenReturn(subscriptions);
|
||||
}
|
||||
|
||||
private void whenSubscriptionsAreRetrievedForDataSetThrowException()
|
||||
throws RegistryHandlerException {
|
||||
when(
|
||||
subscriptionHandler.getActiveByDataSetAndProvider(anyString(),
|
||||
anyString())).thenThrow(
|
||||
new RegistryHandlerException("thrown on purpose"));
|
||||
}
|
||||
|
||||
private void verifyEachSubscriptionIsVerifiedAgainstDataSet() {
|
||||
for (Subscription subscription : subscriptions) {
|
||||
verify(verificationStrategy).verify(dataSet, subscription);
|
||||
}
|
||||
}
|
||||
|
||||
private void verifySubscriptionIsNotVerifiedAgainstDataSet(
|
||||
Subscription subscription) {
|
||||
verify(verificationStrategy, never()).verify(dataSet, subscription);
|
||||
}
|
||||
|
||||
private void whenSubscriptionIsVerifiedItFails(Subscription subscription) {
|
||||
returnVerificationStatusWhenSubscriptionIsVerified(subscription,
|
||||
FAILED_VERIFICATION_MESSAGE);
|
||||
}
|
||||
|
||||
private void whenSubscriptionIsVerifiedItSucceeds(Subscription subscription) {
|
||||
returnVerificationStatusWhenSubscriptionIsVerified(subscription, null);
|
||||
}
|
||||
|
||||
private void returnVerificationStatusWhenSubscriptionIsVerified(
|
||||
Subscription subscription, String notificationMessage) {
|
||||
IVerificationResponse response = mock(IVerificationResponse.class);
|
||||
when(response.hasFailedVerification()).thenReturn(
|
||||
notificationMessage != null);
|
||||
when(response.getNotificationMessage()).thenReturn(notificationMessage);
|
||||
when(
|
||||
verificationStrategy.verify(any(DataSet.class),
|
||||
same(subscription))).thenReturn(response);
|
||||
}
|
||||
}
|
|
@ -1,143 +0,0 @@
|
|||
/**
|
||||
* 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.datadelivery.subscription;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.registry.handlers.DataDeliveryHandlers;
|
||||
import com.raytheon.uf.common.datadelivery.registry.handlers.ISubscriptionHandler;
|
||||
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
|
||||
import com.raytheon.uf.common.registry.handler.RegistryObjectHandlersUtil;
|
||||
import com.raytheon.uf.viz.datadelivery.subscription.SubscriptionService.ForceApplyPromptResponse;
|
||||
|
||||
/**
|
||||
* Provides additional tests for operations that take only a single
|
||||
* subscription, such as update(Subscription) and store(Subscription).
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Dec 3, 2012 1286 djohnson Initial creation
|
||||
* Jan 02, 2012 1345 djohnson Fix broken tests from using VizApp to move work off the UI thread.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
@Ignore
|
||||
public abstract class AbstractSubscriptionServiceSingleSubscriptionTest extends
|
||||
AbstractSubscriptionServiceTest {
|
||||
|
||||
@Test
|
||||
public void testIncreaseLatencyCallsSchedule()
|
||||
throws RegistryHandlerException {
|
||||
returnTwoSubscriptionNamesWhenProposeScheduleCalled();
|
||||
whenForceApplyPromptedUserSelectsIncreaseLatency();
|
||||
|
||||
performServiceInteraction();
|
||||
|
||||
verifyScheduleCalled();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIncreaseLatencyUpdatesSubscriptionLatency()
|
||||
throws RegistryHandlerException {
|
||||
final ISubscriptionHandler subscriptionHandler = DataDeliveryHandlers
|
||||
.getSubscriptionHandler();
|
||||
subscriptionHandler.store(sub2);
|
||||
|
||||
returnTwoSubscriptionNamesWhenProposeScheduleCalled();
|
||||
returnRequiredSubscriptionValuesWhenProposeScheduleCalled();
|
||||
whenForceApplyPromptedUserSelectsIncreaseLatency();
|
||||
|
||||
performServiceInteraction();
|
||||
|
||||
verifySubscriptionLatencyIsIncreasedToRequiredAmount();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIncreaseLatencyInvokesRegistryHandler()
|
||||
throws RegistryHandlerException {
|
||||
RegistryObjectHandlersUtil.initMocks();
|
||||
|
||||
returnTwoSubscriptionNamesWhenProposeScheduleCalled();
|
||||
whenForceApplyPromptedUserSelectsIncreaseLatency();
|
||||
|
||||
performServiceInteraction();
|
||||
|
||||
verifyServiceInteractionWithRegistryHandler();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIncreaseLatencyReturnsSuccessMessage()
|
||||
throws RegistryHandlerException {
|
||||
final ISubscriptionHandler subscriptionHandler = DataDeliveryHandlers
|
||||
.getSubscriptionHandler();
|
||||
subscriptionHandler.store(sub2);
|
||||
|
||||
returnTwoSubscriptionNamesWhenProposeScheduleCalled();
|
||||
whenForceApplyPromptedUserSelectsIncreaseLatency();
|
||||
returnZeroSubscriptionNamesWhenScheduleCalled();
|
||||
|
||||
String expectedMessage = getSuccessfulServiceInteractionMessage();
|
||||
String actualMessage = performServiceInteraction().getMessage();
|
||||
|
||||
assertEquals("Incorrect message returned", expectedMessage,
|
||||
actualMessage);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIncreaseLatencyDisallowsFurtherEdits()
|
||||
throws RegistryHandlerException {
|
||||
final ISubscriptionHandler subscriptionHandler = DataDeliveryHandlers
|
||||
.getSubscriptionHandler();
|
||||
subscriptionHandler.store(sub2);
|
||||
|
||||
returnTwoSubscriptionNamesWhenProposeScheduleCalled();
|
||||
whenForceApplyPromptedUserSelectsIncreaseLatency();
|
||||
returnZeroSubscriptionNamesWhenScheduleCalled();
|
||||
|
||||
SubscriptionServiceResult result = performServiceInteraction();
|
||||
assertFalse("No further edits should be requested",
|
||||
result.isAllowFurtherEditing());
|
||||
}
|
||||
|
||||
/**
|
||||
* When the force apply prompt is displayed, the user selects yes.
|
||||
*/
|
||||
private void whenForceApplyPromptedUserSelectsIncreaseLatency() {
|
||||
when(mockDisplay.getForceApplyPromptResponse()).thenReturn(
|
||||
ForceApplyPromptResponse.INCREASE_LATENCY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that the latency on expected subscriptions
|
||||
*/
|
||||
abstract void verifySubscriptionLatencyIsIncreasedToRequiredAmount();
|
||||
}
|
|
@ -1,505 +0,0 @@
|
|||
/**
|
||||
* 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.datadelivery.subscription;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyListOf;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Mockito.atLeastOnce;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.raytheon.uf.common.auth.req.IPermissionsService;
|
||||
import com.raytheon.uf.common.datadelivery.bandwidth.IBandwidthService;
|
||||
import com.raytheon.uf.common.datadelivery.bandwidth.IProposeScheduleResponse;
|
||||
import com.raytheon.uf.common.datadelivery.registry.AdhocSubscription;
|
||||
import com.raytheon.uf.common.datadelivery.registry.AdhocSubscriptionFixture;
|
||||
import com.raytheon.uf.common.datadelivery.registry.DataType;
|
||||
import com.raytheon.uf.common.datadelivery.registry.SiteSubscriptionFixture;
|
||||
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.ISubscriptionHandler;
|
||||
import com.raytheon.uf.common.datadelivery.service.ISubscriptionNotificationService;
|
||||
import com.raytheon.uf.common.datadelivery.service.subscription.ISubscriptionOverlapService;
|
||||
import com.raytheon.uf.common.localization.PathManagerFactoryTest;
|
||||
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
|
||||
import com.raytheon.uf.common.registry.handler.RegistryObjectHandlersUtil;
|
||||
import com.raytheon.uf.viz.datadelivery.subscription.SubscriptionService.ForceApplyPromptResponse;
|
||||
import com.raytheon.uf.viz.datadelivery.subscription.SubscriptionService.IDisplayForceApplyPrompt;
|
||||
import com.raytheon.uf.viz.datadelivery.subscription.SubscriptionService.IForceApplyPromptDisplayText;
|
||||
|
||||
/**
|
||||
* Test {@link SubscriptionService}. This test uses template methods to verify
|
||||
* that all interactions follow the same patternw when performing stores and
|
||||
* updates.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Nov 7, 2012 1286 djohnson Initial creation
|
||||
* Nov 20, 2012 1286 djohnson Rewrite to support proposing subscription stores/updates and force applying.
|
||||
* Jan 02, 2012 1345 djohnson Fix broken tests from using VizApp to move work off the UI thread.
|
||||
* May 08, 2000 2013 djohnson Allow checks for duplicate subscriptions.
|
||||
* Jul 26, 2031 2232 mpduff Refactored Data Delivery permissions.
|
||||
* Oct 21, 2013 2292 mpduff Implement multiple data types.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
@Ignore
|
||||
public abstract class AbstractSubscriptionServiceTest {
|
||||
|
||||
protected static final int REQUIRED_LATENCY = 2;
|
||||
|
||||
protected static final long REQUIRED_DATASET_SIZE = 1024l;
|
||||
|
||||
final Subscription sub1 = SiteSubscriptionFixture.INSTANCE.get(1,
|
||||
DataType.GRID);
|
||||
|
||||
final Subscription sub2 = SiteSubscriptionFixture.INSTANCE.get(2,
|
||||
DataType.GRID);
|
||||
|
||||
final List<Subscription> subs = Arrays.asList(sub1, sub2);
|
||||
|
||||
final AdhocSubscription adhoc = AdhocSubscriptionFixture.INSTANCE
|
||||
.get(DataType.GRID);
|
||||
|
||||
final String sub1Name = sub1.getName();
|
||||
|
||||
final String sub2Name = sub2.getName();
|
||||
|
||||
final Set<String> subNameResults = new LinkedHashSet<String>();
|
||||
{
|
||||
subNameResults.add(sub1Name);
|
||||
subNameResults.add(sub2Name);
|
||||
}
|
||||
|
||||
final ISubscriptionNotificationService notificationService = mock(ISubscriptionNotificationService.class);
|
||||
|
||||
final IBandwidthService mockBandwidthService = mock(IBandwidthService.class);
|
||||
|
||||
final IPermissionsService permissionsService = mock(RequestFromServerPermissionsService.class);
|
||||
|
||||
final ISubscriptionOverlapService subscriptionOverlapService = mock(ISubscriptionOverlapService.class);
|
||||
|
||||
final IDisplayForceApplyPrompt mockDisplay = mock(IDisplayForceApplyPrompt.class);
|
||||
|
||||
final SubscriptionService service = new SubscriptionService(
|
||||
notificationService, mockBandwidthService, permissionsService,
|
||||
mockDisplay);
|
||||
|
||||
final IProposeScheduleResponse mockProposeScheduleResponse = mock(IProposeScheduleResponse.class);
|
||||
|
||||
final IForceApplyPromptDisplayText mockPromptDisplayText = mock(IForceApplyPromptDisplayText.class);
|
||||
|
||||
@Before
|
||||
public void setUp() throws RegistryHandlerException {
|
||||
PathManagerFactoryTest.initLocalization();
|
||||
RegistryObjectHandlersUtil.initMemory();
|
||||
|
||||
when(
|
||||
mockBandwidthService
|
||||
.proposeSchedule(anyListOf(Subscription.class)))
|
||||
.thenReturn(mockProposeScheduleResponse);
|
||||
when(mockBandwidthService.proposeSchedule(any(Subscription.class)))
|
||||
.thenReturn(mockProposeScheduleResponse);
|
||||
|
||||
setupForceApplyPromptDisplayTextValues();
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup the expected prompt display values.
|
||||
*/
|
||||
private void setupForceApplyPromptDisplayTextValues() {
|
||||
when(
|
||||
mockPromptDisplayText.getOptionDisplayText(
|
||||
ForceApplyPromptResponse.CANCEL, REQUIRED_LATENCY,
|
||||
sub1, subNameResults)).thenReturn("cancel");
|
||||
when(
|
||||
mockPromptDisplayText.getOptionDisplayText(
|
||||
ForceApplyPromptResponse.FORCE_APPLY, REQUIRED_LATENCY,
|
||||
sub1, subNameResults)).thenReturn("force apply");
|
||||
when(
|
||||
mockPromptDisplayText.getOptionDisplayText(
|
||||
ForceApplyPromptResponse.INCREASE_LATENCY,
|
||||
REQUIRED_LATENCY, sub1, subNameResults)).thenReturn(
|
||||
"increase latency");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailedProposeScheduleDoesNotInvokeRegistryHandler()
|
||||
throws RegistryHandlerException {
|
||||
RegistryObjectHandlersUtil.initMocks();
|
||||
|
||||
returnTwoSubscriptionNamesWhenProposeScheduleCalled();
|
||||
whenForceApplyPromptedUserSelectsCancel();
|
||||
|
||||
performServiceInteraction();
|
||||
|
||||
verifyOnlyCheckingForDuplicateSubscriptions();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testServiceInteractionInvokesProposeSchedule()
|
||||
throws RegistryHandlerException {
|
||||
performServiceInteraction();
|
||||
|
||||
verifyProposeScheduleCalled();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccessfulServiceInterfactionReturnsSuccessMessage()
|
||||
throws RegistryHandlerException {
|
||||
returnZeroSubscriptionNamesWhenProposeScheduleCalled();
|
||||
|
||||
String message = performServiceInteraction().getMessage();
|
||||
|
||||
assertEquals("Incorrect response message returned!",
|
||||
getSuccessfulServiceInteractionMessage(), message);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailedProposeSchedulePromptsUserForForceApply()
|
||||
throws RegistryHandlerException {
|
||||
returnTwoSubscriptionNamesWhenProposeScheduleCalled();
|
||||
returnRequiredSubscriptionValuesWhenProposeScheduleCalled();
|
||||
|
||||
whenForceApplyPromptedUserSelectsCancel();
|
||||
|
||||
performServiceInteraction();
|
||||
|
||||
final ForceApplyPromptConfiguration expectedForceApplyConfiguration = getExpectedForceApplyPromptConfiguration();
|
||||
|
||||
verify(mockDisplay).displayForceApplyPrompt(
|
||||
eq(expectedForceApplyConfiguration));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testForceSchedulingCallsSchedule()
|
||||
throws RegistryHandlerException {
|
||||
returnTwoSubscriptionNamesWhenProposeScheduleCalled();
|
||||
whenForceApplyPromptedUserSelectsForceApply();
|
||||
|
||||
performServiceInteraction();
|
||||
|
||||
verifyScheduleCalled();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testForceSchedulingUpdatesUnscheduledSubscriptionsStatus()
|
||||
throws RegistryHandlerException {
|
||||
final ISubscriptionHandler subscriptionHandler = DataDeliveryHandlers
|
||||
.getSubscriptionHandler();
|
||||
subscriptionHandler.store(sub2);
|
||||
|
||||
returnTwoSubscriptionNamesWhenProposeScheduleCalled();
|
||||
whenForceApplyPromptedUserSelectsForceApply();
|
||||
returnSub2NameWhenScheduleCalled();
|
||||
|
||||
performServiceInteraction();
|
||||
|
||||
assertTrue("Sub2 should have been unscheduled", subscriptionHandler
|
||||
.getByName(sub2Name).isUnscheduled());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testForceSchedulingInvokesRegistryHandler()
|
||||
throws RegistryHandlerException {
|
||||
RegistryObjectHandlersUtil.initMocks();
|
||||
|
||||
returnTwoSubscriptionNamesWhenProposeScheduleCalled();
|
||||
whenForceApplyPromptedUserSelectsForceApply();
|
||||
|
||||
performServiceInteraction();
|
||||
|
||||
verifyServiceInteractionWithRegistryHandler();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testForceSchedulingReturnsSuccessMessage()
|
||||
throws RegistryHandlerException {
|
||||
final ISubscriptionHandler subscriptionHandler = DataDeliveryHandlers
|
||||
.getSubscriptionHandler();
|
||||
subscriptionHandler.store(sub2);
|
||||
|
||||
returnTwoSubscriptionNamesWhenProposeScheduleCalled();
|
||||
whenForceApplyPromptedUserSelectsForceApply();
|
||||
returnSub2NameWhenScheduleCalled();
|
||||
|
||||
String expectedMessage = getExpectedSuccessfulForceApplyMessageWithSub2Unscheduled();
|
||||
String actualMessage = performServiceInteraction().getMessage();
|
||||
|
||||
assertEquals("Incorrect message returned", expectedMessage,
|
||||
actualMessage);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testForceSchedulingDisallowsFurtherEdits()
|
||||
throws RegistryHandlerException {
|
||||
final ISubscriptionHandler subscriptionHandler = DataDeliveryHandlers
|
||||
.getSubscriptionHandler();
|
||||
subscriptionHandler.store(sub2);
|
||||
|
||||
returnTwoSubscriptionNamesWhenProposeScheduleCalled();
|
||||
whenForceApplyPromptedUserSelectsForceApply();
|
||||
returnSub2NameWhenScheduleCalled();
|
||||
|
||||
SubscriptionServiceResult result = performServiceInteraction();
|
||||
assertFalse("No further edits should be requested",
|
||||
result.isAllowFurtherEditing());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCancelingDoesNotCallSchedule()
|
||||
throws RegistryHandlerException {
|
||||
returnTwoSubscriptionNamesWhenProposeScheduleCalled();
|
||||
whenForceApplyPromptedUserSelectsCancel();
|
||||
|
||||
performServiceInteraction();
|
||||
|
||||
verifyScheduleNeverCalled();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCancelingDoesNotInvokeRegistryHandler()
|
||||
throws RegistryHandlerException {
|
||||
RegistryObjectHandlersUtil.initMocks();
|
||||
|
||||
returnTwoSubscriptionNamesWhenProposeScheduleCalled();
|
||||
whenForceApplyPromptedUserSelectsCancel();
|
||||
|
||||
performServiceInteraction();
|
||||
|
||||
verifyOnlyCheckingForDuplicateSubscriptions();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCancelingAllowsFurtherEditing()
|
||||
throws RegistryHandlerException {
|
||||
returnTwoSubscriptionNamesWhenProposeScheduleCalled();
|
||||
whenForceApplyPromptedUserSelectsCancel();
|
||||
|
||||
final SubscriptionServiceResult result = performServiceInteraction();
|
||||
|
||||
assertTrue("The service should request that further edits be made",
|
||||
result.isAllowFurtherEditing());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailedRegistryActionInvokesBandwidthManagerReinitialize()
|
||||
throws RegistryHandlerException {
|
||||
RegistryObjectHandlersUtil.initMocks();
|
||||
|
||||
returnZeroSubscriptionNamesWhenProposeScheduleCalled();
|
||||
whenRegistryInteractionOccursThrowException();
|
||||
|
||||
try {
|
||||
performServiceInteraction();
|
||||
fail("An exception should have been thrown, why wasn't it?");
|
||||
} catch (RegistryHandlerException e) {
|
||||
// Expected path
|
||||
}
|
||||
|
||||
verifyBandwidthManagerReinitializeInvoked();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOverlappingSubscriptionsNotifiesUser()
|
||||
throws RegistryHandlerException {
|
||||
// Not valid for adhocs
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that the only interactions with the subscription handler are to
|
||||
* check for duplicate/overlapping subscriptions.
|
||||
*
|
||||
* @throws RegistryHandlerException
|
||||
*/
|
||||
protected void verifyOnlyCheckingForDuplicateSubscriptions()
|
||||
throws RegistryHandlerException {
|
||||
final ISubscriptionHandler subscriptionHandler = DataDeliveryHandlers
|
||||
.getSubscriptionHandler();
|
||||
verify(subscriptionHandler, atLeastOnce())
|
||||
.getActiveByDataSetAndProvider(anyString(), anyString());
|
||||
verifyNoMoreInteractions(subscriptionHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that the bandwidth manager was requested to reinitialize itself
|
||||
* from the persistent store.
|
||||
*/
|
||||
private void verifyBandwidthManagerReinitializeInvoked() {
|
||||
verify(mockBandwidthService).reinitialize();
|
||||
}
|
||||
|
||||
/**
|
||||
* When the force apply prompt is displayed, the user selects no.
|
||||
*/
|
||||
protected void whenForceApplyPromptedUserSelectsCancel() {
|
||||
when(mockDisplay.getForceApplyPromptResponse()).thenReturn(
|
||||
ForceApplyPromptResponse.CANCEL);
|
||||
}
|
||||
|
||||
/**
|
||||
* When the force apply prompt is displayed, the user selects yes.
|
||||
*/
|
||||
protected void whenForceApplyPromptedUserSelectsForceApply() {
|
||||
when(mockDisplay.getForceApplyPromptResponse()).thenReturn(
|
||||
ForceApplyPromptResponse.FORCE_APPLY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify schedule is never called.
|
||||
*/
|
||||
private void verifyScheduleNeverCalled() {
|
||||
verify(mockBandwidthService, never()).schedule(
|
||||
anyListOf(Subscription.class));
|
||||
verify(mockBandwidthService, never()).schedule(any(Subscription.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of {@link #REQUIRED_LATENCY} as the required latency
|
||||
* when propose schedule is called.
|
||||
*/
|
||||
void returnRequiredSubscriptionValuesWhenProposeScheduleCalled() {
|
||||
when(mockProposeScheduleResponse.getRequiredLatency()).thenReturn(
|
||||
REQUIRED_LATENCY);
|
||||
when(mockProposeScheduleResponse.getRequiredDataSetSize()).thenReturn(
|
||||
REQUIRED_DATASET_SIZE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform the service interaction, e.g. store, update, etc.
|
||||
*
|
||||
* @return the response
|
||||
* @throws RegistryHandlerException
|
||||
*/
|
||||
abstract SubscriptionServiceResult performServiceInteraction()
|
||||
throws RegistryHandlerException;
|
||||
|
||||
/**
|
||||
* Throws an exception when the registry interaction occurs.
|
||||
*/
|
||||
abstract void whenRegistryInteractionOccursThrowException()
|
||||
throws RegistryHandlerException;
|
||||
|
||||
/**
|
||||
* When propose schedule is called for this interaction type, then the
|
||||
* bandwidth service will return the set of names of sub1 and sub2 as
|
||||
* unscheduled.
|
||||
*/
|
||||
abstract void returnTwoSubscriptionNamesWhenProposeScheduleCalled();
|
||||
|
||||
/**
|
||||
* Verify propose schedule was called with the expected arguments.
|
||||
*/
|
||||
abstract void verifyProposeScheduleCalled();
|
||||
|
||||
/**
|
||||
* Verify schedule was called with the expected arguments
|
||||
*/
|
||||
abstract void verifyScheduleCalled();
|
||||
|
||||
/**
|
||||
* When a propose schedule is called with the service interaction arguments,
|
||||
* then the bandwidth service will return an empty set.
|
||||
*/
|
||||
abstract void returnZeroSubscriptionNamesWhenProposeScheduleCalled();
|
||||
|
||||
/**
|
||||
* Get the expected message of a force apply.
|
||||
*
|
||||
* @return the expected message
|
||||
*/
|
||||
abstract String getExpectedForceApplyMessage();
|
||||
|
||||
/**
|
||||
* Get the expected message of a successful service interaction.
|
||||
*
|
||||
* @return the expected message
|
||||
*/
|
||||
abstract String getSuccessfulServiceInteractionMessage();
|
||||
|
||||
/**
|
||||
* When schedule is called for the service interaction, then the bandwidth
|
||||
* service will return the name of sub2 as unscheduled.
|
||||
*/
|
||||
abstract void returnSub2NameWhenScheduleCalled();
|
||||
|
||||
/**
|
||||
* When schedule is called for the service interaction, then the bandwidth
|
||||
* service will return zero subscription names.
|
||||
*/
|
||||
abstract void returnZeroSubscriptionNamesWhenScheduleCalled();
|
||||
|
||||
/**
|
||||
* Verify the service interaction caused the expected invocation on the
|
||||
* registry handler.
|
||||
*
|
||||
* @throws RegistryHandlerException
|
||||
*/
|
||||
abstract void verifyServiceInteractionWithRegistryHandler()
|
||||
throws RegistryHandlerException;
|
||||
|
||||
/**
|
||||
* Get the expected message from a successful force apply of the service
|
||||
* interaction.
|
||||
*
|
||||
* @return the message
|
||||
*/
|
||||
abstract String getExpectedSuccessfulForceApplyMessageWithSub2Unscheduled();
|
||||
|
||||
/**
|
||||
* Return the expected subscription argument to the display force apply
|
||||
* prompt.
|
||||
*
|
||||
* @return the subscription argument
|
||||
*/
|
||||
abstract Subscription getExpectedDisplayForceApplyPromptSubscription();
|
||||
|
||||
/**
|
||||
* Return the expected force apply prompt configuration.
|
||||
*
|
||||
* @return the configuration
|
||||
*/
|
||||
abstract ForceApplyPromptConfiguration getExpectedForceApplyPromptConfiguration();
|
||||
}
|
|
@ -1,361 +0,0 @@
|
|||
/**
|
||||
* 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.datadelivery.subscription;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.Matchers.same;
|
||||
import static org.mockito.Mockito.doThrow;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.raytheon.uf.common.auth.AuthException;
|
||||
import com.raytheon.uf.common.auth.req.IPermissionsService.IAuthorizedPermissionResponse;
|
||||
import com.raytheon.uf.common.auth.user.IUser;
|
||||
import com.raytheon.uf.common.datadelivery.bandwidth.IProposeScheduleResponse;
|
||||
import com.raytheon.uf.common.datadelivery.registry.InitialPendingSiteSubscription;
|
||||
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.ISubscriptionHandler;
|
||||
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
|
||||
import com.raytheon.uf.common.registry.handler.RegistryObjectHandlersUtil;
|
||||
import com.raytheon.uf.common.util.CollectionUtil;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
|
||||
/**
|
||||
* Test
|
||||
* {@link SubscriptionService#update(java.util.List, com.raytheon.viz.ui.presenter.IDisplay).
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Nov 21, 2012 1286 djohnson Initial creation
|
||||
* May 08, 2000 2013 djohnson Allow checks for duplicate subscriptions.
|
||||
* Jul 26, 2031 2232 mpduff Refactored Data Delivery permissions.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
public class SubscriptionServiceMassUpdateTest extends
|
||||
AbstractSubscriptionServiceTest {
|
||||
|
||||
private final IAuthorizedPermissionResponse authorizedPermissionsResponse = mock(IAuthorizedPermissionResponse.class);
|
||||
|
||||
@Before
|
||||
public void setUpPermissionsResponse() throws VizException, AuthException {
|
||||
userHasAllPermissions();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateWithPendingCheckCancelingForceApplyDoesNotUpdateSubscriptions()
|
||||
throws RegistryHandlerException {
|
||||
RegistryObjectHandlersUtil.initMocks();
|
||||
|
||||
returnTwoSubscriptionNamesWhenProposeScheduleCalled();
|
||||
whenForceApplyPromptedUserSelectsCancel();
|
||||
|
||||
service.updateWithPendingCheck(subs, mockPromptDisplayText);
|
||||
|
||||
verifyOnlyCheckingForDuplicateSubscriptions();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateWithPendingCheckForceApplyUpdatesSubscriptions()
|
||||
throws RegistryHandlerException {
|
||||
RegistryObjectHandlersUtil.initMocks();
|
||||
|
||||
returnTwoSubscriptionNamesWhenProposeScheduleCalled();
|
||||
whenForceApplyPromptedUserSelectsForceApply();
|
||||
|
||||
service.updateWithPendingCheck(subs, mockPromptDisplayText);
|
||||
|
||||
final ISubscriptionHandler subscriptionHandler = DataDeliveryHandlers
|
||||
.getSubscriptionHandler();
|
||||
for (Subscription sub : subs) {
|
||||
verify(subscriptionHandler).update(sub);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateWithPendingCheckNotifiesOfSubscriptionsAlreadyPending()
|
||||
throws RegistryHandlerException {
|
||||
RegistryObjectHandlersUtil.initMocks();
|
||||
|
||||
returnZeroSubscriptionNamesWhenProposeScheduleCalled();
|
||||
|
||||
subscriptionAlreadyHasPendingChanges(sub1);
|
||||
|
||||
final SubscriptionServiceResult response = service
|
||||
.updateWithPendingCheck(subs, mockPromptDisplayText);
|
||||
|
||||
final String expectedMessage = "The subscriptions have been updated.\n\nThe following subscriptions already had pending changes and were not modified:\n"
|
||||
+ sub1.getName();
|
||||
|
||||
assertThat(response.getMessage(), is(equalTo(expectedMessage)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateWithPendingCheckNotifiesOfSubscriptionsUnableToBeUpdated()
|
||||
throws RegistryHandlerException, VizException {
|
||||
RegistryObjectHandlersUtil.initMocks();
|
||||
|
||||
returnZeroSubscriptionNamesWhenProposeScheduleCalled();
|
||||
|
||||
subscriptionThrowsErrorOnUpdate(sub2);
|
||||
|
||||
final SubscriptionServiceResult response = service
|
||||
.updateWithPendingCheck(subs, mockPromptDisplayText);
|
||||
|
||||
final String expectedMessage = "The subscriptions have been updated.\n\nThe following subscriptions were unable to be modified:\n"
|
||||
+ sub2.getName();
|
||||
|
||||
assertThat(response.getMessage(), is(equalTo(expectedMessage)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateWithPendingCheckNotifiesOfPendingSubscriptionsCreated()
|
||||
throws RegistryHandlerException, VizException, AuthException {
|
||||
RegistryObjectHandlersUtil.initMocks();
|
||||
|
||||
returnZeroSubscriptionNamesWhenProposeScheduleCalled();
|
||||
|
||||
subscriptionCantBeChangedByUser(sub2);
|
||||
|
||||
final SubscriptionServiceResult response = service
|
||||
.updateWithPendingCheck(subs, mockPromptDisplayText);
|
||||
|
||||
final String expectedMessage = "The subscriptions have been updated.\n\nThe following subscriptions have pending changes awaiting approval:\n"
|
||||
+ sub2.getName();
|
||||
|
||||
assertThat(response.getMessage(), is(equalTo(expectedMessage)));
|
||||
}
|
||||
|
||||
/**
|
||||
* When the user requests to change the specified subscription, the registry
|
||||
* throws an exception.
|
||||
*
|
||||
* @param subscription
|
||||
* the subscription
|
||||
* @throws RegistryHandlerException
|
||||
*/
|
||||
private void subscriptionThrowsErrorOnUpdate(Subscription sub2)
|
||||
throws RegistryHandlerException {
|
||||
doThrow(new RegistryHandlerException("thrown on purpose")).when(
|
||||
DataDeliveryHandlers.getSubscriptionHandler()).update(sub2);
|
||||
}
|
||||
|
||||
/**
|
||||
* When the user requests to change the specified subscription, they will
|
||||
* not have permission.
|
||||
*
|
||||
* @param subscription
|
||||
* the subscription
|
||||
* @throws VizException
|
||||
* @throws AuthException
|
||||
*/
|
||||
private void subscriptionCantBeChangedByUser(Subscription subscription)
|
||||
throws VizException, AuthException {
|
||||
IAuthorizedPermissionResponse noPermission = mock(IAuthorizedPermissionResponse.class);
|
||||
when(
|
||||
((RequestFromServerPermissionsService) permissionsService)
|
||||
.checkPermissionToChangeSubscription(any(IUser.class),
|
||||
any(String.class), same(subscription)))
|
||||
.thenReturn(noPermission);
|
||||
when(noPermission.isAuthorized()).thenReturn(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
SubscriptionServiceResult performServiceInteraction()
|
||||
throws RegistryHandlerException {
|
||||
return service.update(subs, mockPromptDisplayText);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
void returnTwoSubscriptionNamesWhenProposeScheduleCalled() {
|
||||
when(mockBandwidthService.proposeSchedule(subs)).thenReturn(
|
||||
mockProposeScheduleResponse);
|
||||
when(mockProposeScheduleResponse.getUnscheduledSubscriptions())
|
||||
.thenReturn(subNameResults);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
void verifyProposeScheduleCalled() {
|
||||
verify(mockBandwidthService).proposeSchedule(subs);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
void verifyScheduleCalled() {
|
||||
verify(mockBandwidthService).schedule(subs);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
void returnZeroSubscriptionNamesWhenProposeScheduleCalled() {
|
||||
when(mockProposeScheduleResponse.getUnscheduledSubscriptions())
|
||||
.thenReturn(Collections.<String> emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
String getExpectedForceApplyMessage() {
|
||||
return "The following subscriptions would not fully schedule with the bandwidth management system if this action were performed:";
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
String getSuccessfulServiceInteractionMessage() {
|
||||
return "The subscriptions have been updated.";
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
void returnSub2NameWhenScheduleCalled() {
|
||||
when(mockBandwidthService.schedule(subs)).thenReturn(
|
||||
CollectionUtil.asSet(sub2Name));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
void returnZeroSubscriptionNamesWhenScheduleCalled() {
|
||||
when(mockBandwidthService.schedule(subs)).thenReturn(
|
||||
Collections.<String> emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
void verifyServiceInteractionWithRegistryHandler()
|
||||
throws RegistryHandlerException {
|
||||
for (Subscription sub : subs) {
|
||||
verify(DataDeliveryHandlers.getSubscriptionHandler()).update(sub);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
String getExpectedSuccessfulForceApplyMessageWithSub2Unscheduled() {
|
||||
return "The subscriptions have been updated.\n\nThe following subscriptions did not fully schedule with the bandwidth management system:\n"
|
||||
+ sub2Name;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
void whenRegistryInteractionOccursThrowException()
|
||||
throws RegistryHandlerException {
|
||||
doThrow(new RegistryHandlerException("thrown on purpose")).when(
|
||||
DataDeliveryHandlers.getSubscriptionHandler()).update(
|
||||
subs.get(0));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
Subscription getExpectedDisplayForceApplyPromptSubscription() {
|
||||
// This test does expect a null argument to be passed, not an error
|
||||
return null;
|
||||
}
|
||||
|
||||
private void userHasAllPermissions() throws VizException, AuthException {
|
||||
when(
|
||||
permissionsService.checkPermission(any(IUser.class),
|
||||
anyString(), any(String.class))).thenReturn(
|
||||
authorizedPermissionsResponse);
|
||||
when(
|
||||
permissionsService.checkPermissions(any(IUser.class),
|
||||
anyString(), any(String.class))).thenReturn(
|
||||
authorizedPermissionsResponse);
|
||||
when(
|
||||
((RequestFromServerPermissionsService) permissionsService)
|
||||
.checkPermissionToChangeSubscription(any(IUser.class),
|
||||
anyString(), any(Subscription.class)))
|
||||
.thenReturn(authorizedPermissionsResponse);
|
||||
when(authorizedPermissionsResponse.isAuthorized()).thenReturn(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a subscription to already have pending changes.
|
||||
*
|
||||
* @param subscription
|
||||
* @throws RegistryHandlerException
|
||||
*/
|
||||
private void subscriptionAlreadyHasPendingChanges(Subscription subscription)
|
||||
throws RegistryHandlerException {
|
||||
when(
|
||||
DataDeliveryHandlers.getPendingSubscriptionHandler()
|
||||
.getBySubscription(subscription)).thenReturn(
|
||||
new InitialPendingSiteSubscription());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
ForceApplyPromptConfiguration getExpectedForceApplyPromptConfiguration() {
|
||||
return new ForceApplyPromptConfiguration(service.TITLE,
|
||||
getExpectedForceApplyMessage(),
|
||||
IProposeScheduleResponse.VALUE_NOT_SET,
|
||||
IProposeScheduleResponse.VALUE_NOT_SET,
|
||||
IProposeScheduleResponse.VALUE_NOT_SET, mockPromptDisplayText,
|
||||
getExpectedDisplayForceApplyPromptSubscription(),
|
||||
subNameResults);
|
||||
}
|
||||
}
|
|
@ -1,191 +0,0 @@
|
|||
/**
|
||||
* 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.datadelivery.subscription;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
||||
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.ISubscriptionHandler;
|
||||
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
|
||||
import com.raytheon.uf.common.util.CollectionUtil;
|
||||
|
||||
/**
|
||||
* Test
|
||||
* {@link SubscriptionService#store(com.raytheon.uf.common.datadelivery.registry.AdhocSubscription, com.raytheon.viz.ui.presenter.IDisplay).
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Nov 21, 2012 1286 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
public class SubscriptionServiceStoreAdhocTest extends
|
||||
AbstractSubscriptionServiceSingleSubscriptionTest {
|
||||
|
||||
@Override
|
||||
public void testFailedRegistryActionInvokesBandwidthManagerReinitialize()
|
||||
throws RegistryHandlerException {
|
||||
// Adhoc subscriptions no longer interact with the registry
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
SubscriptionServiceResult performServiceInteraction()
|
||||
throws RegistryHandlerException {
|
||||
return service.store(adhoc, mockPromptDisplayText);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
void returnTwoSubscriptionNamesWhenProposeScheduleCalled() {
|
||||
when(mockProposeScheduleResponse.getUnscheduledSubscriptions())
|
||||
.thenReturn(subNameResults);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
void verifyProposeScheduleCalled() {
|
||||
verify(mockBandwidthService).proposeSchedule(
|
||||
Arrays.<Subscription> asList(adhoc));
|
||||
}
|
||||
|
||||
@Override
|
||||
void verifyScheduleCalled() {
|
||||
verify(mockBandwidthService).schedule(
|
||||
Arrays.<Subscription> asList(adhoc));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
void returnZeroSubscriptionNamesWhenProposeScheduleCalled() {
|
||||
when(mockBandwidthService.schedule(Arrays.<Subscription> asList(adhoc)))
|
||||
.thenReturn(Collections.<String> emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
void returnSub2NameWhenScheduleCalled() {
|
||||
when(mockBandwidthService.schedule(Arrays.<Subscription> asList(adhoc)))
|
||||
.thenReturn(CollectionUtil.asSet(sub2Name));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
void returnZeroSubscriptionNamesWhenScheduleCalled() {
|
||||
when(mockBandwidthService.schedule(Arrays.<Subscription> asList(adhoc)))
|
||||
.thenReturn(Collections.<String> emptySet());
|
||||
}
|
||||
|
||||
@Override
|
||||
String getExpectedForceApplyMessage() {
|
||||
return "The following subscriptions would not fully schedule with the bandwidth management system if this action were performed:";
|
||||
}
|
||||
|
||||
@Override
|
||||
String getSuccessfulServiceInteractionMessage() {
|
||||
return "The query was successfully stored.";
|
||||
}
|
||||
|
||||
@Override
|
||||
void verifyServiceInteractionWithRegistryHandler()
|
||||
throws RegistryHandlerException {
|
||||
// Adhoc subscriptions no longer interact with the registry
|
||||
}
|
||||
|
||||
@Override
|
||||
String getExpectedSuccessfulForceApplyMessageWithSub2Unscheduled() {
|
||||
return "The query was successfully stored.\n\nThe following subscriptions did not fully schedule with the bandwidth management system:\n"
|
||||
+ sub2Name;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
void whenRegistryInteractionOccursThrowException()
|
||||
throws RegistryHandlerException {
|
||||
// Adhoc subscriptions no longer interact with the registry
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void verifyOnlyCheckingForDuplicateSubscriptions()
|
||||
throws RegistryHandlerException {
|
||||
// Adhocs don't check for duplicates
|
||||
final ISubscriptionHandler subscriptionHandler = DataDeliveryHandlers
|
||||
.getSubscriptionHandler();
|
||||
verifyNoMoreInteractions(subscriptionHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
void verifySubscriptionLatencyIsIncreasedToRequiredAmount() {
|
||||
assertEquals(
|
||||
"Expected the latency to have been set to the required amount!",
|
||||
REQUIRED_LATENCY, adhoc.getLatencyInMinutes());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
Subscription getExpectedDisplayForceApplyPromptSubscription() {
|
||||
return adhoc;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
ForceApplyPromptConfiguration getExpectedForceApplyPromptConfiguration() {
|
||||
return new ForceApplyPromptConfiguration(service.TITLE,
|
||||
getExpectedForceApplyMessage(), REQUIRED_LATENCY, 40,
|
||||
REQUIRED_DATASET_SIZE, mockPromptDisplayText,
|
||||
getExpectedDisplayForceApplyPromptSubscription(),
|
||||
subNameResults);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,173 +0,0 @@
|
|||
/**
|
||||
* 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.datadelivery.subscription;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.Mockito.doThrow;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.registry.Subscription;
|
||||
import com.raytheon.uf.common.datadelivery.registry.handlers.DataDeliveryHandlers;
|
||||
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
|
||||
import com.raytheon.uf.common.util.CollectionUtil;
|
||||
|
||||
/**
|
||||
* Test
|
||||
* {@link SubscriptionService#store(com.raytheon.uf.common.datadelivery.registry.Subscription, com.raytheon.viz.ui.presenter.IDisplay).
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Nov 21, 2012 1286 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
public class SubscriptionServiceStoreTest extends
|
||||
AbstractSubscriptionServiceSingleSubscriptionTest {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
void returnTwoSubscriptionNamesWhenProposeScheduleCalled() {
|
||||
when(mockProposeScheduleResponse.getUnscheduledSubscriptions())
|
||||
.thenReturn(subNameResults);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
SubscriptionServiceResult performServiceInteraction()
|
||||
throws RegistryHandlerException {
|
||||
return service.store(sub1, mockPromptDisplayText);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
void verifyProposeScheduleCalled() {
|
||||
verify(mockBandwidthService).proposeSchedule(Arrays.asList(sub1));
|
||||
}
|
||||
|
||||
@Override
|
||||
void verifyScheduleCalled() {
|
||||
verify(mockBandwidthService).schedule(Arrays.asList(sub1));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
void returnZeroSubscriptionNamesWhenProposeScheduleCalled() {
|
||||
when(mockBandwidthService.schedule(Arrays.asList(sub1))).thenReturn(
|
||||
Collections.<String> emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
void returnSub2NameWhenScheduleCalled() {
|
||||
when(mockBandwidthService.schedule(Arrays.asList(sub1))).thenReturn(
|
||||
CollectionUtil.asSet(sub2Name));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
void returnZeroSubscriptionNamesWhenScheduleCalled() {
|
||||
when(mockBandwidthService.schedule(Arrays.asList(sub1))).thenReturn(
|
||||
Collections.<String> emptySet());
|
||||
}
|
||||
|
||||
@Override
|
||||
String getExpectedForceApplyMessage() {
|
||||
return "The following subscriptions would not fully schedule with the bandwidth management system if this action were performed:";
|
||||
}
|
||||
|
||||
@Override
|
||||
String getSuccessfulServiceInteractionMessage() {
|
||||
return "Subscription " + sub1Name + " has been created.";
|
||||
}
|
||||
|
||||
@Override
|
||||
void verifyServiceInteractionWithRegistryHandler()
|
||||
throws RegistryHandlerException {
|
||||
verify(DataDeliveryHandlers.getSubscriptionHandler()).store(sub1);
|
||||
}
|
||||
|
||||
@Override
|
||||
void verifySubscriptionLatencyIsIncreasedToRequiredAmount() {
|
||||
assertEquals(
|
||||
"Expected the latency to have been set to the required amount!",
|
||||
REQUIRED_LATENCY, sub1.getLatencyInMinutes());
|
||||
}
|
||||
|
||||
@Override
|
||||
String getExpectedSuccessfulForceApplyMessageWithSub2Unscheduled() {
|
||||
return "Subscription "
|
||||
+ sub1Name
|
||||
+ " has been created.\n\nThe following subscriptions did not fully schedule with the bandwidth management system:\n"
|
||||
+ sub2Name;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
void whenRegistryInteractionOccursThrowException()
|
||||
throws RegistryHandlerException {
|
||||
doThrow(new RegistryHandlerException("thrown on purpose")).when(
|
||||
DataDeliveryHandlers.getSubscriptionHandler()).store(sub1);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
Subscription getExpectedDisplayForceApplyPromptSubscription() {
|
||||
return sub1;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
ForceApplyPromptConfiguration getExpectedForceApplyPromptConfiguration() {
|
||||
return new ForceApplyPromptConfiguration(service.TITLE,
|
||||
getExpectedForceApplyMessage(), REQUIRED_LATENCY, 40,
|
||||
REQUIRED_DATASET_SIZE, mockPromptDisplayText,
|
||||
getExpectedDisplayForceApplyPromptSubscription(),
|
||||
subNameResults);
|
||||
}
|
||||
}
|
|
@ -1,85 +0,0 @@
|
|||
/**
|
||||
* 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.datadelivery.subscription;
|
||||
|
||||
import static org.mockito.Mockito.doThrow;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.registry.handlers.DataDeliveryHandlers;
|
||||
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
|
||||
|
||||
/**
|
||||
* Test
|
||||
* {@link SubscriptionService#update(com.raytheon.uf.common.datadelivery.registry.Subscription, com.raytheon.viz.ui.presenter.IDisplay).
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Nov 21, 2012 1286 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
public class SubscriptionServiceUpdateTest extends SubscriptionServiceStoreTest {
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
SubscriptionServiceResult performServiceInteraction()
|
||||
throws RegistryHandlerException {
|
||||
return service.update(sub1, mockPromptDisplayText);
|
||||
}
|
||||
|
||||
@Override
|
||||
void verifyServiceInteractionWithRegistryHandler()
|
||||
throws RegistryHandlerException {
|
||||
verify(DataDeliveryHandlers.getSubscriptionHandler()).update(sub1);
|
||||
}
|
||||
|
||||
@Override
|
||||
String getExpectedForceApplyMessage() {
|
||||
return "The following subscriptions would not fully schedule with the bandwidth management system if this action were performed:";
|
||||
}
|
||||
|
||||
@Override
|
||||
String getSuccessfulServiceInteractionMessage() {
|
||||
return "Subscription " + sub1Name + " has been updated.";
|
||||
}
|
||||
|
||||
@Override
|
||||
String getExpectedSuccessfulForceApplyMessageWithSub2Unscheduled() {
|
||||
return "Subscription "
|
||||
+ sub1Name
|
||||
+ " has been updated.\n\nThe following subscriptions did not fully schedule with the bandwidth management system:\n"
|
||||
+ sub2Name;
|
||||
}
|
||||
|
||||
@Override
|
||||
void whenRegistryInteractionOccursThrowException()
|
||||
throws RegistryHandlerException {
|
||||
doThrow(new RegistryHandlerException("thrown on purpose")).when(
|
||||
DataDeliveryHandlers.getSubscriptionHandler()).update(sub1);
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue