Issue #1441 Create new datadelivery services plugin

Add GroupDefinition service.
Update subscriptions to not have a group name when their group is deleted.

Amend:
  Rebase to HEAD of 13.2.1.

Change-Id: I817ca1912f76ccf347907ddb12e3f6fd8de7e5aa

Former-commit-id: 464b46dd4f4af60dbeb917f65c18c876d712e4ad
This commit is contained in:
Dustin Johnson 2013-01-18 14:27:55 -06:00
parent 2eda48aa0d
commit 15c2c55ff9
61 changed files with 799 additions and 56 deletions

View file

@ -99,6 +99,13 @@
version="0.0.0"
unpack="false"/>
<plugin
id="com.raytheon.uf.common.datadelivery.service"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="com.raytheon.uf.common.stats"
download-size="0"

View file

@ -29,7 +29,8 @@ Require-Bundle: org.eclipse.ui,
com.raytheon.uf.common.registry.ebxml;bundle-version="1.0.0",
com.raytheon.uf.common.gridcoverage;bundle-version="1.0.0",
com.raytheon.uf.common.datadelivery.bandwidth;bundle-version="1.0.0",
com.raytheon.uf.common.datadelivery.retrieval;bundle-version="1.0.0"
com.raytheon.uf.common.datadelivery.retrieval;bundle-version="1.0.0",
com.raytheon.uf.common.datadelivery.service;bundle-version="1.0.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Export-Package: com.raytheon.uf.viz.datadelivery;uses:="org.eclipse.ui.plugin,org.osgi.framework",

View file

@ -8,11 +8,14 @@
class="com.raytheon.uf.common.datadelivery.bandwidth.BandwidthService" />
<bean id="subscriptionNotificationService"
class="com.raytheon.uf.viz.datadelivery.subscription.SendToServerSubscriptionNotificationService" />
class="com.raytheon.uf.common.datadelivery.service.SendToServerSubscriptionNotificationService" />
<bean id="permissionsService"
class="com.raytheon.uf.viz.datadelivery.subscription.RequestFromServerPermissionsService" />
<bean id="groupDefinitionService"
class="com.raytheon.uf.common.datadelivery.service.GroupDefinitionService" />
<bean id="subscriptionService"
class="com.raytheon.uf.viz.datadelivery.subscription.SubscriptionService"
factory-method="newInstance">
@ -28,6 +31,7 @@
<property name="subscriptionNotificationService" ref="subscriptionNotificationService" />
<property name="bandwidthService" ref="bandwidthService" />
<property name="permissionsService" ref="permissionsService" />
<property name="groupDefinitionService" ref="groupDefinitionService" />
</bean>
<bean id="systemRuleManager"

View file

@ -61,7 +61,7 @@ import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.Slider;
import com.raytheon.uf.common.datadelivery.bandwidth.data.BandwidthGraphData;
import com.raytheon.uf.common.datadelivery.event.notification.SubscriptionNotificationResponse;
import com.raytheon.uf.common.datadelivery.service.SubscriptionNotificationResponse;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.time.util.TimeUtil;

View file

@ -20,8 +20,9 @@
package com.raytheon.uf.viz.datadelivery.services;
import com.raytheon.uf.common.datadelivery.bandwidth.IBandwidthService;
import com.raytheon.uf.common.datadelivery.service.IGroupDefinitionService;
import com.raytheon.uf.common.datadelivery.service.ISubscriptionNotificationService;
import com.raytheon.uf.viz.datadelivery.subscription.IPermissionsService;
import com.raytheon.uf.viz.datadelivery.subscription.ISubscriptionNotificationService;
import com.raytheon.uf.viz.datadelivery.subscription.ISubscriptionService;
/**
@ -55,6 +56,8 @@ public final class DataDeliveryServices {
private IPermissionsService permissionsService;
private IGroupDefinitionService groupDefinitionService;
/**
* Disabled constructor.
*/
@ -147,4 +150,24 @@ public final class DataDeliveryServices {
public void setPermissionsService(IPermissionsService permissionsService) {
this.permissionsService = permissionsService;
}
/**
* Get the group definition service.
*
* @return the groupDefinitionService
*/
public static IGroupDefinitionService getGroupDefinitionService() {
return INSTANCE.groupDefinitionService;
}
/**
* Set the group definition service.
*
* @param groupDefinitionService
* the groupDefinitionService to set
*/
public void setGroupDefinitionService(
IGroupDefinitionService groupDefinitionService) {
this.groupDefinitionService = groupDefinitionService;
}
}

View file

@ -29,12 +29,14 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;
import com.raytheon.uf.common.datadelivery.registry.handlers.DataDeliveryHandlers;
import com.raytheon.uf.common.datadelivery.service.IGroupDefinitionService;
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.viz.datadelivery.common.ui.GroupSelectComp;
import com.raytheon.uf.viz.datadelivery.common.ui.IGroupAction;
import com.raytheon.uf.viz.datadelivery.services.DataDeliveryServices;
import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryUtils;
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
@ -47,7 +49,8 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jan 2, 2013 1441 djohnson Initial creation
* Jan 2, 2013 1441 djohnson Initial creation
* Jan 18, 2013 1441 djohnson Use group definition service.
*
* </pre>
*
@ -68,6 +71,9 @@ public class DeleteGroupDlg extends CaveSWTDialog {
private final IUFStatusHandler statusHandler = UFStatus
.getHandler(DeleteGroupDlg.class);
private final IGroupDefinitionService groupService = DataDeliveryServices
.getGroupDefinitionService();
/**
* @param shell
* @param groupAction
@ -144,8 +150,11 @@ public class DeleteGroupDlg extends CaveSWTDialog {
+ groupName + "?")) {
try {
DataDeliveryHandlers.getGroupDefinitionHandler()
.deleteByName(groupName);
groupService
.deleteGroupDefinition(
DataDeliveryHandlers
.getGroupDefinitionHandler()
.getByName(groupName));
groupAction.loadGroupNames();
return true;
} catch (RegistryHandlerException e) {

View file

@ -34,6 +34,7 @@ import org.eclipse.swt.widgets.Shell;
import com.raytheon.uf.common.datadelivery.registry.GroupDefinition;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.datadelivery.registry.handlers.DataDeliveryHandlers;
import com.raytheon.uf.common.datadelivery.service.ISubscriptionNotificationService;
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;

View file

@ -19,12 +19,14 @@
**/
package com.raytheon.uf.viz.datadelivery.subscription;
import com.raytheon.uf.common.auth.resp.SuccessfulExecution;
import com.raytheon.uf.common.auth.user.IUser;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.datadelivery.request.DataDeliveryAuthRequest;
import com.raytheon.uf.common.datadelivery.request.DataDeliveryConstants;
import com.raytheon.uf.common.datadelivery.request.DataDeliveryPermission;
import com.raytheon.uf.common.serialization.comm.RequestRouter;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.requests.ThriftClient;
/**
* {@link IPermissionsService} implementation that requests permissions from the
@ -37,6 +39,7 @@ import com.raytheon.uf.viz.core.requests.ThriftClient;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jan 04, 2013 1441 djohnson Initial creation
* Jan 21, 2013 1441 djohnson Use RequestRouter.
*
* </pre>
*
@ -93,8 +96,13 @@ public class RequestFromServerPermissionsService implements IPermissionsService
*/
private DataDeliveryAuthRequest sendAuthorizationRequest(
DataDeliveryAuthRequest request) throws VizException {
return (DataDeliveryAuthRequest) ThriftClient
.sendPrivilegedRequest(request);
try {
return (DataDeliveryAuthRequest) ((SuccessfulExecution) RequestRouter
.route(request, DataDeliveryConstants.DATA_DELIVERY_SERVER))
.getResponse();
} catch (Exception e) {
throw new VizException(e);
}
}
/**

View file

@ -53,6 +53,7 @@ import com.raytheon.uf.common.auth.user.IUser;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.datadelivery.registry.handlers.ISubscriptionHandler;
import com.raytheon.uf.common.datadelivery.request.DataDeliveryPermission;
import com.raytheon.uf.common.datadelivery.service.ISubscriptionNotificationService;
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
import com.raytheon.uf.common.registry.handler.RegistryObjectHandlers;
import com.raytheon.uf.common.status.IUFStatusHandler;

View file

@ -43,6 +43,7 @@ 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.IPendingSubscriptionHandler;
import com.raytheon.uf.common.datadelivery.registry.handlers.ISubscriptionHandler;
import com.raytheon.uf.common.datadelivery.service.ISubscriptionNotificationService;
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;

View file

@ -47,12 +47,12 @@ import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import com.raytheon.uf.common.auth.user.IUser;
import com.raytheon.uf.common.datadelivery.event.notification.SubscriptionNotificationResponse;
import com.raytheon.uf.common.datadelivery.registry.PendingSubscription;
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.request.DataDeliveryPermission;
import com.raytheon.uf.common.datadelivery.service.SubscriptionNotificationResponse;
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
import com.raytheon.uf.common.registry.handler.RegistryObjectHandlers;
import com.raytheon.uf.common.status.IUFStatusHandler;

View file

@ -33,14 +33,14 @@ import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import com.raytheon.uf.common.datadelivery.event.notification.ApprovedPendingSubscriptionNotificationResponse;
import com.raytheon.uf.common.datadelivery.event.notification.BaseSubscriptionNotificationResponse;
import com.raytheon.uf.common.datadelivery.event.notification.DeniedPendingSubscriptionNotificationResponse;
import com.raytheon.uf.common.datadelivery.event.notification.PendingSubscriptionNotificationResponse;
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.datadelivery.registry.handlers.DataDeliveryHandlers;
import com.raytheon.uf.common.datadelivery.service.ApprovedPendingSubscriptionNotificationResponse;
import com.raytheon.uf.common.datadelivery.service.BaseSubscriptionNotificationResponse;
import com.raytheon.uf.common.datadelivery.service.DeniedPendingSubscriptionNotificationResponse;
import com.raytheon.uf.common.datadelivery.service.PendingSubscriptionNotificationResponse;
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;

View file

@ -40,6 +40,7 @@ import com.raytheon.uf.common.datadelivery.registry.PendingSubscription;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.datadelivery.registry.handlers.IPendingSubscriptionHandler;
import com.raytheon.uf.common.datadelivery.request.DataDeliveryPermission;
import com.raytheon.uf.common.datadelivery.service.ISubscriptionNotificationService;
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
import com.raytheon.uf.common.registry.handler.RegistryObjectHandlers;
import com.raytheon.uf.common.status.IUFStatusHandler;
@ -57,7 +58,6 @@ import com.raytheon.uf.viz.datadelivery.services.DataDeliveryServices;
import com.raytheon.uf.viz.datadelivery.subscription.CancelForceApplyAndIncreaseLatencyDisplayText;
import com.raytheon.uf.viz.datadelivery.subscription.IPermissionsService;
import com.raytheon.uf.viz.datadelivery.subscription.IPermissionsService.IAuthorizedPermissionResponse;
import com.raytheon.uf.viz.datadelivery.subscription.ISubscriptionNotificationService;
import com.raytheon.uf.viz.datadelivery.subscription.ISubscriptionService;
import com.raytheon.uf.viz.datadelivery.subscription.ISubscriptionService.ISubscriptionServiceResult;
import com.raytheon.uf.viz.datadelivery.subscription.SubscriptionService.ForceApplyPromptResponse;

View file

@ -48,6 +48,7 @@ import com.raytheon.uf.common.datadelivery.registry.Utils.SubscriptionStatus;
import com.raytheon.uf.common.datadelivery.registry.handlers.IPendingSubscriptionHandler;
import com.raytheon.uf.common.datadelivery.registry.handlers.ISubscriptionHandler;
import com.raytheon.uf.common.datadelivery.request.DataDeliveryPermission;
import com.raytheon.uf.common.datadelivery.service.ISubscriptionNotificationService;
import com.raytheon.uf.common.registry.ebxml.RegistryUtil;
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
import com.raytheon.uf.common.registry.handler.RegistryObjectHandlers;
@ -62,7 +63,6 @@ import com.raytheon.uf.viz.core.localization.LocalizationManager;
import com.raytheon.uf.viz.datadelivery.services.DataDeliveryServices;
import com.raytheon.uf.viz.datadelivery.subscription.CancelForceApplyAndIncreaseLatencyDisplayText;
import com.raytheon.uf.viz.datadelivery.subscription.GroupDefinitionManager;
import com.raytheon.uf.viz.datadelivery.subscription.ISubscriptionNotificationService;
import com.raytheon.uf.viz.datadelivery.subscription.ISubscriptionService;
import com.raytheon.uf.viz.datadelivery.subscription.ISubscriptionService.ISubscriptionServiceResult;
import com.raytheon.uf.viz.datadelivery.subscription.view.ICreateSubscriptionDlgView;

View file

@ -1,5 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry exported="true" kind="lib" path="hamcrest-all-1.3.jar" sourcepath="hamcrest-all-1.3-sources.jar"/>
<classpathentry exported="true" kind="lib" path="junit-dep-4.11.jar" sourcepath="junit-4.11-src.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry exported="true" kind="lib" path="jmock-2.0.0.jar" sourcepath="org.junitsrc.zip"/>
@ -10,6 +12,5 @@
<classpathentry exported="true" kind="lib" path="mockito-all-1.9.0.jar"/>
<classpathentry exported="true" kind="lib" path="objenesis-1.2.jar"/>
<classpathentry exported="true" kind="lib" path="powermock-mockito-1.4.12-full.jar"/>
<classpathentry exported="true" kind="lib" path="junit-4.10.jar" sourcepath="junit-4.10-src.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -11,7 +11,8 @@ Bundle-ClassPath: jmock-2.0.0.jar,
mockito-all-1.9.0.jar,
objenesis-1.2.jar,
powermock-mockito-1.4.12-full.jar,
junit-4.10.jar
hamcrest-all-1.3.jar,
junit-dep-4.11.jar
Export-Package: javassist,
javassist.bytecode,
javassist.bytecode.analysis,
@ -43,8 +44,28 @@ Export-Package: javassist,
net.sf.cglib.transform.impl,
net.sf.cglib.util,
org.hamcrest,
org.hamcrest.beans,
org.hamcrest.collection,
org.hamcrest.core,
org.hamcrest.generator,
org.hamcrest.generator.config,
org.hamcrest.generator.qdox,
org.hamcrest.generator.qdox.ant,
org.hamcrest.generator.qdox.directorywalker,
org.hamcrest.generator.qdox.junit,
org.hamcrest.generator.qdox.model,
org.hamcrest.generator.qdox.model.annotation,
org.hamcrest.generator.qdox.model.util,
org.hamcrest.generator.qdox.parser,
org.hamcrest.generator.qdox.parser.impl,
org.hamcrest.generator.qdox.parser.structs,
org.hamcrest.generator.qdox.tools,
org.hamcrest.integration,
org.hamcrest.internal,
org.hamcrest.number,
org.hamcrest.object,
org.hamcrest.text,
org.hamcrest.xml,
org.jmock,
org.jmock.api,
org.jmock.example.qcon,

View file

@ -8,4 +8,5 @@ bin.includes = META-INF/,\
mockito-all-1.9.0.jar,\
objenesis-1.2.jar,\
powermock-mockito-1.4.12-full.jar,\
junit-4.10.jar
hamcrest-all-1.3.jar,\
junit-dep-4.11.jar

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

1
edexOsgi/build.edex/edex/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
dist/

View file

@ -23,7 +23,8 @@ Require-Bundle: com.raytheon.uf.common.registry.schemas.ebxml;bundle-version="1.
com.raytheon.uf.common.gridcoverage;bundle-version="1.0.0",
com.raytheon.uf.common.dataplugin;bundle-version="1.12.1174",
com.raytheon.uf.common.geospatial;bundle-version="1.12.1174",
javax.measure;bundle-version="1.0.0"
javax.measure;bundle-version="1.0.0",
com.raytheon.uf.common.datadelivery.request;bundle-version="1.0.0"
Export-Package: com.raytheon.uf.common.datadelivery.registry,
com.raytheon.uf.common.datadelivery.registry.ebxml,
com.raytheon.uf.common.datadelivery.registry.handlers

View file

@ -0,0 +1,85 @@
/**
* 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;
import com.raytheon.uf.common.auth.req.AbstractPrivilegedRequest;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
/**
* Service request for {@link GroupDefinition}s.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jan 18, 2013 1441 djohnson Initial creation
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
@DynamicSerialize
public class GroupDefinitionServiceRequest extends AbstractPrivilegedRequest {
public static enum Type {
DELETE;
}
@DynamicSerializeElement
private GroupDefinition group;
@DynamicSerializeElement
private Type type;
/**
* @return the type
*/
public Type getType() {
return type;
}
/**
* @param type
* the type to set
*/
public void setType(Type type) {
this.type = type;
}
/**
* @return the group
*/
public GroupDefinition getGroup() {
return group;
}
/**
* @param group
* the group to set
*/
public void setGroup(GroupDefinition group) {
this.group = group;
}
}

View file

@ -8,4 +8,5 @@ Require-Bundle: com.raytheon.uf.common.auth;bundle-version="1.12.1174",
com.raytheon.uf.common.serialization.comm;bundle-version="1.12.1174",
com.raytheon.uf.common.util;bundle-version="1.12.1174"
Export-Package: com.raytheon.uf.common.datadelivery.request;uses:="com.raytheon.uf.common.auth.req,com.raytheon.uf.common.serialization",
com.raytheon.uf.common.datadelivery.request.user;uses:="com.raytheon.uf.common.auth.user"
com.raytheon.uf.common.datadelivery.request.user;uses:="com.raytheon.uf.common.auth.user",
com.raytheon.uf.common.datadelivery.service

View file

@ -0,0 +1,69 @@
/**
* 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.service;
import java.rmi.RemoteException;
import com.raytheon.uf.common.auth.req.AbstractPrivilegedRequest;
import com.raytheon.uf.common.auth.resp.SuccessfulExecution;
import com.raytheon.uf.common.datadelivery.request.DataDeliveryConstants;
import com.raytheon.uf.common.serialization.ExceptionWrapper;
import com.raytheon.uf.common.serialization.comm.RequestRouter;
import com.raytheon.uf.common.serialization.comm.response.ServerErrorResponse;
/**
* Base class for services that send requests to the data delivery server.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jan 18, 2013 1441 djohnson Initial creation
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public class BaseDataDeliveryService<T extends AbstractPrivilegedRequest> {
/**
* Send a request to the data delivery server.
*
* @param request
* @return
* @throws Exception
*/
protected Object sendRequest(T request) throws Exception {
Object object = RequestRouter.route(request,
DataDeliveryConstants.DATA_DELIVERY_SERVER);
if (object instanceof SuccessfulExecution) {
SuccessfulExecution response = (SuccessfulExecution) object;
return response.getResponse();
} else {
throw new RemoteException("Error communicating with the server!",
ExceptionWrapper
.unwrapThrowable(((ServerErrorResponse) object)
.getException()));
}
}
}

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="res"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.raytheon.uf.common.datadelivery.service</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View file

@ -0,0 +1,8 @@
#Tue Feb 14 11:27:19 CST 2012
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6

View file

@ -0,0 +1,20 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: com.raytheon.uf.common.datadelivery.service
Bundle-SymbolicName: com.raytheon.uf.common.datadelivery.service
Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: RAYTHEON
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: javax.persistence
Require-Bundle:
com.raytheon.uf.common.serialization;bundle-version="1.12.1174",
com.raytheon.uf.common.serialization.comm;bundle-version="1.12.1174",
com.raytheon.uf.common.datadelivery.registry;bundle-version="1.0.0",
com.raytheon.uf.common.status;bundle-version="1.12.1174",
com.raytheon.uf.common.datadelivery.request;bundle-version="1.0.0",
com.raytheon.uf.common.registry.ebxml;bundle-version="1.0.0",
com.raytheon.uf.common.auth;bundle-version="1.12.1174"
Export-Package:
com.raytheon.uf.common.datadelivery.service

View file

@ -0,0 +1,6 @@
source.. = src/,\
res/
output.. = bin/
bin.includes = META-INF/,\
res/,\
.

View file

@ -0,0 +1,10 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-2.5.xsd">
<bean id="subscriptionNotificationService"
class="com.raytheon.uf.common.datadelivery.service.SendToServerSubscriptionNotificationService" />
</beans>

View file

@ -17,7 +17,7 @@
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.common.datadelivery.event.notification;
package com.raytheon.uf.common.datadelivery.service;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;

View file

@ -17,7 +17,7 @@
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.common.datadelivery.event.notification;
package com.raytheon.uf.common.datadelivery.service;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;

View file

@ -17,7 +17,7 @@
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.common.datadelivery.event.notification;
package com.raytheon.uf.common.datadelivery.service;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.serialization.ISerializableObject;

View file

@ -17,7 +17,7 @@
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.common.datadelivery.event.notification;
package com.raytheon.uf.common.datadelivery.service;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.datadelivery.registry.handlers.IBaseSubscriptionHandler;

View file

@ -17,7 +17,7 @@
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.common.datadelivery.event.notification;
package com.raytheon.uf.common.datadelivery.service;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;

View file

@ -17,7 +17,7 @@
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.common.datadelivery.event.notification;
package com.raytheon.uf.common.datadelivery.service;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;

View file

@ -0,0 +1,75 @@
/**
* 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.service;
import com.raytheon.uf.common.datadelivery.registry.GroupDefinition;
import com.raytheon.uf.common.datadelivery.registry.GroupDefinitionServiceRequest;
import com.raytheon.uf.common.datadelivery.registry.GroupDefinitionServiceRequest.Type;
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
/**
* Base implementation of {@link IGroupDefinitionService}.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jan 18, 2013 1441 djohnson Initial creation
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public class GroupDefinitionService extends
BaseDataDeliveryService<GroupDefinitionServiceRequest> implements
IGroupDefinitionService {
/**
* {@inheritDoc}
* @throws Exception
*/
@Override
public void deleteGroupDefinition(GroupDefinition group)
throws RegistryHandlerException {
GroupDefinitionServiceRequest request = new GroupDefinitionServiceRequest();
request.setGroup(group);
request.setType(Type.DELETE);
sendRequest(request);
}
/**
* {@inheritDoc}
*/
@Override
protected Object sendRequest(GroupDefinitionServiceRequest request)
throws RegistryHandlerException {
try {
return super.sendRequest(request);
} catch (Exception e) {
throw new RegistryHandlerException(e);
}
}
}

View file

@ -0,0 +1,52 @@
/**
* 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.service;
import com.raytheon.uf.common.datadelivery.registry.GroupDefinition;
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
/**
* Defines the service to interact with {@link GroupDefinition} objects.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jan 18, 2013 1441 djohnson Initial creation
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public interface IGroupDefinitionService {
/**
* Delete the group definition.
*
* @param group
* the group
* @throws RegistryHandlerException
*/
void deleteGroupDefinition(GroupDefinition group)
throws RegistryHandlerException;
}

View file

@ -17,7 +17,7 @@
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.datadelivery.subscription;
package com.raytheon.uf.common.datadelivery.service;
import com.raytheon.uf.common.datadelivery.registry.InitialPendingSubscription;
import com.raytheon.uf.common.datadelivery.registry.Subscription;

View file

@ -17,7 +17,7 @@
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.common.datadelivery.event.notification;
package com.raytheon.uf.common.datadelivery.service;
import com.raytheon.uf.common.datadelivery.registry.InitialPendingSubscription;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;

View file

@ -17,7 +17,7 @@
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.common.datadelivery.event.notification;
package com.raytheon.uf.common.datadelivery.service;
import com.raytheon.uf.common.datadelivery.registry.InitialPendingSubscription;
import com.raytheon.uf.common.datadelivery.registry.handlers.DataDeliveryHandlers;

View file

@ -17,13 +17,8 @@
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.datadelivery.subscription;
package com.raytheon.uf.common.datadelivery.service;
import com.raytheon.uf.common.datadelivery.event.notification.ApprovedPendingSubscriptionNotificationRequest;
import com.raytheon.uf.common.datadelivery.event.notification.BaseSubscriptionNotificationRequest;
import com.raytheon.uf.common.datadelivery.event.notification.DeniedPendingSubscriptionNotificationRequest;
import com.raytheon.uf.common.datadelivery.event.notification.PendingSubscriptionNotificationRequest;
import com.raytheon.uf.common.datadelivery.event.notification.SubscriptionNotificationRequest;
import com.raytheon.uf.common.datadelivery.registry.InitialPendingSubscription;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.datadelivery.request.DataDeliveryConstants;

View file

@ -17,7 +17,7 @@
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.common.datadelivery.event.notification;
package com.raytheon.uf.common.datadelivery.service;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;

View file

@ -17,7 +17,7 @@
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.common.datadelivery.event.notification;
package com.raytheon.uf.common.datadelivery.service;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.datadelivery.registry.handlers.DataDeliveryHandlers;

View file

@ -19,4 +19,5 @@ Require-Bundle: com.google.guava;bundle-version="1.0.0",
com.raytheon.uf.common.event;bundle-version="1.0.0",
com.raytheon.uf.common.datadelivery.registry;bundle-version="1.0.0",
com.raytheon.uf.common.registry.event;bundle-version="1.0.0",
com.raytheon.uf.common.registry.ebxml;bundle-version="1.0.0"
com.raytheon.uf.common.registry.ebxml;bundle-version="1.0.0",
com.raytheon.uf.common.datadelivery.service;bundle-version="1.0.0"

View file

@ -24,19 +24,19 @@
<constructor-arg type="java.lang.String" value="jms-generic:topic:notify.msg" />
</bean>
<bean factory-bean="handlerRegistry" factory-method="register">
<constructor-arg value="com.raytheon.uf.common.datadelivery.event.notification.SubscriptionNotificationRequest"/>
<constructor-arg value="com.raytheon.uf.common.datadelivery.service.SubscriptionNotificationRequest"/>
<constructor-arg ref="subscriptionNotificationHandler"/>
</bean>
<bean factory-bean="handlerRegistry" factory-method="register">
<constructor-arg value="com.raytheon.uf.common.datadelivery.event.notification.ApprovedPendingSubscriptionNotificationRequest"/>
<constructor-arg value="com.raytheon.uf.common.datadelivery.service.ApprovedPendingSubscriptionNotificationRequest"/>
<constructor-arg ref="subscriptionNotificationHandler"/>
</bean>
<bean factory-bean="handlerRegistry" factory-method="register">
<constructor-arg value="com.raytheon.uf.common.datadelivery.event.notification.DeniedPendingSubscriptionNotificationRequest"/>
<constructor-arg value="com.raytheon.uf.common.datadelivery.service.DeniedPendingSubscriptionNotificationRequest"/>
<constructor-arg ref="subscriptionNotificationHandler"/>
</bean>
<bean factory-bean="handlerRegistry" factory-method="register">
<constructor-arg value="com.raytheon.uf.common.datadelivery.event.notification.PendingSubscriptionNotificationRequest"/>
<constructor-arg value="com.raytheon.uf.common.datadelivery.service.PendingSubscriptionNotificationRequest"/>
<constructor-arg ref="subscriptionNotificationHandler"/>
</bean>

View file

@ -21,11 +21,11 @@ package com.raytheon.uf.edex.datadelivery.event.handler;
import java.util.Calendar;
import com.raytheon.uf.common.datadelivery.event.notification.BaseSubscriptionNotificationRequest;
import com.raytheon.uf.common.datadelivery.event.notification.BaseSubscriptionNotificationResponse;
import com.raytheon.uf.common.datadelivery.event.notification.NotificationRecord;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.datadelivery.registry.handlers.IBaseSubscriptionHandler;
import com.raytheon.uf.common.datadelivery.service.BaseSubscriptionNotificationRequest;
import com.raytheon.uf.common.datadelivery.service.BaseSubscriptionNotificationResponse;
import com.raytheon.uf.common.serialization.comm.IRequestHandler;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;

View file

@ -133,6 +133,13 @@
version="0.0.0"
unpack="false"/>
<plugin
id="com.raytheon.uf.common.datadelivery.service"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="com.raytheon.uf.edex.datadelivery.service"
download-size="0"

View file

@ -21,4 +21,5 @@ Require-Bundle: com.raytheon.uf.common.auth;bundle-version="1.12.1174",
com.raytheon.uf.common.registry.event;bundle-version="1.0.0",
com.raytheon.uf.common.event;bundle-version="1.0.0",
com.google.guava;bundle-version="1.0.0",
com.raytheon.uf.common.datadelivery.event;bundle-version="1.0.0"
com.raytheon.uf.common.datadelivery.event;bundle-version="1.0.0",
com.raytheon.uf.common.datadelivery.service;bundle-version="1.0.0"

View file

@ -12,13 +12,24 @@
<constructor-arg ref="datadeliveryAuthorization" />
</bean>
<bean id="subscriptionDeleteService"
<bean id="subscriptionDeleteServiceHandler"
class="com.raytheon.uf.edex.datadelivery.service.services.SubscriptionDeleteHandler" />
<bean id="groupDefinitionServiceHandler"
class="com.raytheon.uf.edex.datadelivery.service.services.GroupDefinitionServiceHandler">
<constructor-arg ref="subscriptionNotificationService" />
</bean>
<bean factory-bean="handlerRegistry" factory-method="register">
<constructor-arg
value="com.raytheon.uf.common.datadelivery.registry.SubscriptionDeleteRequest" />
<constructor-arg ref="subscriptionDeleteService" />
<constructor-arg ref="subscriptionDeleteServiceHandler" />
</bean>
<bean factory-bean="handlerRegistry" factory-method="register">
<constructor-arg
value="com.raytheon.uf.common.datadelivery.registry.GroupDefinitionServiceRequest" />
<constructor-arg ref="groupDefinitionServiceHandler" />
</bean>
</beans>

View file

@ -0,0 +1,131 @@
/**
* 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.services;
import java.util.List;
import com.raytheon.uf.common.auth.exception.AuthorizationException;
import com.raytheon.uf.common.auth.user.IUser;
import com.raytheon.uf.common.datadelivery.registry.GroupDefinition;
import com.raytheon.uf.common.datadelivery.registry.GroupDefinitionServiceRequest;
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.IGroupDefinitionService;
import com.raytheon.uf.common.datadelivery.service.ISubscriptionNotificationService;
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
import com.raytheon.uf.common.util.CollectionUtil;
import com.raytheon.uf.edex.auth.req.AbstractPrivilegedRequestHandler;
import com.raytheon.uf.edex.auth.resp.AuthorizationResponse;
/**
* Handles request from the {@link IGroupDefinitionService}.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jan 18, 2013 1441 djohnson Initial creation
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public class GroupDefinitionServiceHandler extends
AbstractPrivilegedRequestHandler<GroupDefinitionServiceRequest> {
private final ISubscriptionNotificationService notificationService;
/**
* Constructor.
*
* @param notificationService
* the subscription notification service
*/
public GroupDefinitionServiceHandler(
ISubscriptionNotificationService notificationService) {
this.notificationService = notificationService;
}
/**
* {@inheritDoc}
*/
@Override
public Object handleRequest(GroupDefinitionServiceRequest request)
throws Exception {
final IUser user = request.getUser();
switch (request.getType()) {
case DELETE:
handleDelete(request.getGroup(), user);
break;
}
return null;
}
/**
* Handles the delete of a group. First it updates any subscriptions in the
* group to not have a group, and then deletes the actual group.
*
* @param user
*
* @param groupDefinition
* @return
* @throws RegistryHandlerException
*/
private void handleDelete(GroupDefinition group, IUser user)
throws RegistryHandlerException {
ISubscriptionHandler handler = DataDeliveryHandlers
.getSubscriptionHandler();
List<Subscription> subsForGroup = handler.getByGroupName(group
.getGroupName());
if (!CollectionUtil.isNullOrEmpty(subsForGroup)) {
for (Subscription sub : subsForGroup) {
sub.setGroupName(GroupDefinition.NO_GROUP);
handler.update(sub);
// TODO: Would be nice to use a subset of the
// SubscriptionService functionality here so we didn't have to
// manually send the subscription updated notification
String username = user != null ? user.uniqueId().toString()
: "none";
notificationService.sendUpdatedSubscriptionNotification(sub,
username);
}
}
DataDeliveryHandlers.getGroupDefinitionHandler().delete(group);
}
/**
* {@inheritDoc}
*/
@Override
public AuthorizationResponse authorized(IUser user,
GroupDefinitionServiceRequest request)
throws AuthorizationException {
return new AuthorizationResponse(true);
}
}

View file

@ -68,5 +68,6 @@
<classpathentry combineaccessrules="false" kind="src" path="/com.raytheon.uf.edex.stats"/>
<classpathentry combineaccessrules="false" kind="src" path="/com.raytheon.uf.viz.plugin.nwsauth"/>
<classpathentry combineaccessrules="false" kind="src" path="/com.raytheon.uf.edex.plugin.nwsauth"/>
<classpathentry combineaccessrules="false" kind="src" path="/com.raytheon.uf.common.datadelivery.service"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -59,7 +59,6 @@ public class ParameterFixture extends AbstractFixture<Parameter> {
obj.setBaseType("baseType" + seedValue);
obj.setDataType(DataType.GRID);
obj.setDefinition("definition" + seedValue);
obj.setEnsemble(0);
obj.setFillValue("fillValue" + seedValue);
obj.setLevels(LevelsFixture.INSTANCE.get(seedValue));
obj.setLevelType(Arrays.asList(DataLevelTypeFixture.INSTANCE

View file

@ -0,0 +1,135 @@
/**
* 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 static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
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.Subscription;
import com.raytheon.uf.common.datadelivery.registry.SubscriptionBuilder;
import com.raytheon.uf.common.datadelivery.service.GroupDefinitionService;
import com.raytheon.uf.common.datadelivery.service.ISubscriptionNotificationService;
import com.raytheon.uf.common.registry.RegistryManagerTest;
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
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public class GroupDefinitionServiceTest {
private static final String GROUP_NAME = "someGroup";
private ISubscriptionHandler subscriptionHandler;
private IGroupDefinitionHandler groupHandler;
private final ISubscriptionNotificationService subscriptionNotificationService = mock(ISubscriptionNotificationService.class);
private final GroupDefinitionService service = new GroupDefinitionService() {
@Override
protected Object sendRequest(GroupDefinitionServiceRequest request)
throws RegistryHandlerException {
try {
return new GroupDefinitionServiceHandler(
subscriptionNotificationService).handleRequest(request);
} catch (Exception e) {
throw new RegistryHandlerException(e);
}
}
};
private final GroupDefinition group = new GroupDefinition();
@Before
public void setUp() throws RegistryHandlerException {
RegistryObjectHandlersUtil.initMemory();
RegistryManagerTest.setMockInstance();
subscriptionHandler = DataDeliveryHandlers.getSubscriptionHandler();
groupHandler = DataDeliveryHandlers.getGroupDefinitionHandler();
group.setGroupName(GROUP_NAME);
groupHandler.store(group);
Subscription subscription = new SubscriptionBuilder().withGroupName(
GROUP_NAME).build();
Subscription subscription2 = new Subscription(subscription, "sub2");
subscriptionHandler.store(subscription);
subscriptionHandler.store(subscription2);
}
@Test
public void deletingAGroupUpdatesSubscriptionsToNotHaveAGroupName()
throws RegistryHandlerException {
service.deleteGroupDefinition(group);
assertThat(subscriptionHandler.getByGroupName(GROUP_NAME),
is(emptyCollectionOf(Subscription.class)));
}
@Test
public void deletingAGroupNotifiesOfSubscriptionUpdates()
throws RegistryHandlerException {
service.deleteGroupDefinition(group);
verify(subscriptionNotificationService, times(2))
.sendUpdatedSubscriptionNotification(any(Subscription.class),
anyString());
}
@Test
public void deletingAGroupDeletesTheGroup() throws RegistryHandlerException {
service.deleteGroupDefinition(group);
assertNull(groupHandler.getByName(GROUP_NAME));
}
}

View file

@ -19,8 +19,13 @@
**/
package com.raytheon.uf.common.registry;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyList;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import org.junit.Ignore;
import org.mockito.Mockito;
/**
* Allows setting a specific {@link RegistryHandler} instance for test purposes.
@ -48,9 +53,23 @@ public class RegistryManagerTest {
*
* @return the mock {@link RegistryHandler}.
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
public static RegistryHandler setMockInstance() {
RegistryHandler mock = Mockito.mock(RegistryHandler.class);
RegistryHandler mock = mock(RegistryHandler.class);
RegistryManagerTest.setInstance(mock);
RegistryQueryResponse response = mock(RegistryQueryResponse.class);
when(response.getStatus()).thenReturn(OperationStatus.SUCCESS);
// Handles the responses for deletes, stores, and updates...
// TODO: Handle retrieving objects?
when(mock.removeObjects(any(RegistryQuery.class))).thenReturn(response);
when(mock.removeObjects(anyString(), anyList())).thenReturn(response);
when(mock.removeObjects(anyString(), any(RegistryQuery.class)))
.thenReturn(response);
when(mock.storeObject(any())).thenReturn(response);
when(mock.storeOrReplaceObject(any())).thenReturn(response);
when(mock.removeObjects(anyString(), any(RegistryQuery.class)))
.thenReturn(response);
return mock;
}

View file

@ -48,6 +48,7 @@ import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.datadelivery.registry.SubscriptionFixture;
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.registry.handler.RegistryHandlerException;
import com.raytheon.uf.common.registry.handler.RegistryObjectHandlersUtil;
import com.raytheon.uf.viz.datadelivery.subscription.ISubscriptionService.ISubscriptionServiceResult;

View file

@ -46,7 +46,7 @@ import com.raytheon.uf.viz.datadelivery.utils.TypeOperationItems;
* @author djohnson
* @version 1.0
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
@SuppressWarnings({ "rawtypes" })
public class OperatorAdapterTest {
@Test
@ -66,9 +66,9 @@ public class OperatorAdapterTest {
private void verifyOperatorsUnmarshalAsSameOperator(Operator... operators) {
for (Operator operator : operators) {
assertThat(operator,
is(sameInstance(OperatorAdapter.fromString(OperatorAdapter
.toString(operator)))));
Operator expected = OperatorAdapter.fromString(OperatorAdapter
.toString(operator));
assertThat(operator, is(sameInstance(expected)));
}
}