Issue #1643 Standardize access for EDEX service requests, separate router code into its own Spring file.
Change-Id: Ic32df9138b270d1e2c3a9d137d2ad292706ab5b7 Former-commit-id: 6ab17d82c5e4961e662acf80e26d23f3bbfaada2
This commit is contained in:
parent
9cf3ca07b7
commit
7852f88352
18 changed files with 339 additions and 136 deletions
|
@ -30,7 +30,6 @@ 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;
|
||||
|
@ -51,6 +50,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 2, 2013 1441 djohnson Initial creation
|
||||
* Jan 18, 2013 1441 djohnson Use group definition service.
|
||||
* Feb 26, 2013 1643 djohnson Catch any exception.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -157,7 +157,7 @@ public class DeleteGroupDlg extends CaveSWTDialog {
|
|||
.getByName(groupName));
|
||||
groupAction.loadGroupNames();
|
||||
return true;
|
||||
} catch (RegistryHandlerException e) {
|
||||
} catch (Exception e) {
|
||||
statusHandler.handle(Priority.ERROR,
|
||||
"Unable to delete a group.", e);
|
||||
}
|
||||
|
|
|
@ -19,13 +19,13 @@
|
|||
**/
|
||||
package com.raytheon.uf.viz.datadelivery.subscription;
|
||||
|
||||
import com.raytheon.uf.common.auth.resp.SuccessfulExecution;
|
||||
import java.rmi.RemoteException;
|
||||
|
||||
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.common.datadelivery.service.BasePrivilegedDataDeliveryService;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
|
||||
/**
|
||||
|
@ -40,6 +40,7 @@ import com.raytheon.uf.viz.core.exception.VizException;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 04, 2013 1441 djohnson Initial creation
|
||||
* Jan 21, 2013 1441 djohnson Use RequestRouter.
|
||||
* Feb 26, 2013 1643 djohnson Extends base class.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -47,7 +48,9 @@ import com.raytheon.uf.viz.core.exception.VizException;
|
|||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class RequestFromServerPermissionsService implements IPermissionsService {
|
||||
public class RequestFromServerPermissionsService extends
|
||||
BasePrivilegedDataDeliveryService<DataDeliveryAuthRequest> implements
|
||||
IPermissionsService {
|
||||
|
||||
/**
|
||||
* Adapts the {@link DataDeliveryAuthRequestAdapter} to match the
|
||||
|
@ -84,27 +87,6 @@ public class RequestFromServerPermissionsService implements IPermissionsService
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send an authorization request. Private because the method of constructing
|
||||
* an authorization request and processing the response should remain
|
||||
* isolated to this utility class.
|
||||
*
|
||||
* @param request
|
||||
* The request object
|
||||
* @return DataDeliveryAuthReqeust object
|
||||
* @throws VizException
|
||||
*/
|
||||
private DataDeliveryAuthRequest sendAuthorizationRequest(
|
||||
DataDeliveryAuthRequest request) throws VizException {
|
||||
try {
|
||||
return (DataDeliveryAuthRequest) ((SuccessfulExecution) RequestRouter
|
||||
.route(request, DataDeliveryConstants.DATA_DELIVERY_SERVER))
|
||||
.getResponse();
|
||||
} catch (Exception e) {
|
||||
throw new VizException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
@ -165,8 +147,13 @@ public class RequestFromServerPermissionsService implements IPermissionsService
|
|||
request.addRequestedPermissions(permissions);
|
||||
request.setNotAuthorizedMessage(notAuthorizedMessage);
|
||||
|
||||
DataDeliveryAuthRequest r = sendAuthorizationRequest(request);
|
||||
|
||||
return new DataDeliveryAuthRequestAdapter(r);
|
||||
try {
|
||||
DataDeliveryAuthRequest r = sendRequest(request,
|
||||
DataDeliveryAuthRequest.class);
|
||||
return new DataDeliveryAuthRequestAdapter(r);
|
||||
} catch (RemoteException e) {
|
||||
throw new VizException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,8 @@ Bundle-Vendor: RAYTHEON
|
|||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||
Require-Bundle: com.raytheon.uf.common.serialization;bundle-version="1.11.31",
|
||||
com.raytheon.uf.common.serialization.comm;bundle-version="1.11.31",
|
||||
org.apache.commons.lang;bundle-version="2.3.0"
|
||||
org.apache.commons.lang;bundle-version="2.3.0",
|
||||
com.raytheon.uf.common.status;bundle-version="1.12.1174"
|
||||
Export-Package: com.raytheon.uf.common.auth,
|
||||
com.raytheon.uf.common.auth.exception,
|
||||
com.raytheon.uf.common.auth.req,
|
||||
|
|
|
@ -0,0 +1,85 @@
|
|||
package com.raytheon.uf.common.auth.req;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
**/
|
||||
|
||||
import java.rmi.RemoteException;
|
||||
|
||||
import com.raytheon.uf.common.auth.resp.SuccessfulExecution;
|
||||
import com.raytheon.uf.common.serialization.ExceptionWrapper;
|
||||
import com.raytheon.uf.common.serialization.comm.response.ServerErrorResponse;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
|
||||
/**
|
||||
* Send requests to a privileged service on the server.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 23, 2013 1643 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
public class BasePrivilegedServerService<T extends AbstractPrivilegedRequest>
|
||||
extends BaseServerService<T> {
|
||||
|
||||
private static final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(BasePrivilegedServerService.class);
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param serviceKey
|
||||
*/
|
||||
protected BasePrivilegedServerService(String serviceKey) {
|
||||
super(serviceKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <U> U unwrapResponse(Class<U> responseType, Object object)
|
||||
throws RemoteException {
|
||||
if (object instanceof SuccessfulExecution) {
|
||||
SuccessfulExecution response = (SuccessfulExecution) object;
|
||||
return super.unwrapResponse(responseType, response.getResponse());
|
||||
} else if (object instanceof ServerErrorResponse) {
|
||||
throw new RemoteException("Error communicating with the server!",
|
||||
ExceptionWrapper
|
||||
.unwrapThrowable(((ServerErrorResponse) object)
|
||||
.getException()));
|
||||
} else {
|
||||
statusHandler
|
||||
.warn(String
|
||||
.format("Expected a %s or %s response type from a privileged request, but received a payload of %s. "
|
||||
+ "Attempting to cast to the expected return type, but this is a configuration error because "
|
||||
+ "privileged requests do not seem to be correctly processed!",
|
||||
SuccessfulExecution.class.getSimpleName(),
|
||||
ServerErrorResponse.class.getSimpleName(),
|
||||
responseType.getName()));
|
||||
return super.unwrapResponse(responseType, object);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,105 @@
|
|||
package com.raytheon.uf.common.auth.req;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
**/
|
||||
|
||||
import java.rmi.RemoteException;
|
||||
|
||||
import com.raytheon.uf.common.serialization.comm.IServerRequest;
|
||||
import com.raytheon.uf.common.serialization.comm.RequestRouter;
|
||||
|
||||
/**
|
||||
* Base class for services that send requests to a server.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 23, 2013 1643 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
public class BaseServerService<T extends IServerRequest> {
|
||||
|
||||
protected final String serviceKey;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param serviceKey
|
||||
* the service key
|
||||
*/
|
||||
protected BaseServerService(String serviceKey) {
|
||||
this.serviceKey = serviceKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a request to the server.
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
protected final <U> U sendRequest(T request, Class<U> responseType)
|
||||
throws RemoteException {
|
||||
Object object;
|
||||
try {
|
||||
object = getResponseFromServer(request);
|
||||
} catch (Exception e) {
|
||||
throw new RemoteException(
|
||||
"An exception occurred while communicating with the server",
|
||||
e);
|
||||
}
|
||||
return unwrapResponse(responseType, object);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a request to the server.
|
||||
*
|
||||
* @param request
|
||||
* the request
|
||||
* @throws Exception
|
||||
*/
|
||||
protected final void sendRequest(T request) throws RemoteException {
|
||||
sendRequest(request, Void.class);
|
||||
}
|
||||
|
||||
protected Object getResponseFromServer(T request) throws Exception {
|
||||
return RequestRouter.route(request, serviceKey);
|
||||
}
|
||||
|
||||
protected <U> U unwrapResponse(Class<U> responseType, Object object)
|
||||
throws RemoteException {
|
||||
if (object != null) {
|
||||
final Class<? extends Object> objectClass = object.getClass();
|
||||
if (!responseType.isAssignableFrom(objectClass)) {
|
||||
throw new RemoteException(
|
||||
"Received an unexpected object type of "
|
||||
+ objectClass.getName() + " from the server!");
|
||||
}
|
||||
}
|
||||
return responseType.cast(object);
|
||||
}
|
||||
}
|
|
@ -19,24 +19,18 @@
|
|||
**/
|
||||
package com.raytheon.uf.common.datadelivery.bandwidth;
|
||||
|
||||
import java.rmi.RemoteException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.raytheon.uf.common.auth.resp.SuccessfulExecution;
|
||||
import com.raytheon.uf.common.datadelivery.bandwidth.IBandwidthRequest.RequestType;
|
||||
import com.raytheon.uf.common.datadelivery.bandwidth.data.BandwidthGraphData;
|
||||
import com.raytheon.uf.common.datadelivery.registry.AdhocSubscription;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Network;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Subscription;
|
||||
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;
|
||||
import com.raytheon.uf.common.datadelivery.service.BasePrivilegedDataDeliveryService;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
|
@ -61,7 +55,9 @@ import com.raytheon.uf.common.util.LogUtil;
|
|||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
public class BandwidthService implements IBandwidthService {
|
||||
public class BandwidthService extends
|
||||
BasePrivilegedDataDeliveryService<IBandwidthRequest> implements
|
||||
IBandwidthService {
|
||||
|
||||
private static final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(BandwidthService.class);
|
||||
|
@ -76,7 +72,7 @@ public class BandwidthService implements IBandwidthService {
|
|||
request.setNetwork(network);
|
||||
|
||||
try {
|
||||
return ((Integer) sendRequest(request)).intValue();
|
||||
return sendRequest(request, Integer.class).intValue();
|
||||
} catch (Exception e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Unable to set available bandwidth for network [" + network
|
||||
|
@ -98,7 +94,7 @@ public class BandwidthService implements IBandwidthService {
|
|||
request.setBandwidth(bandwidth);
|
||||
|
||||
try {
|
||||
return ((Set<Subscription>) sendRequest(request));
|
||||
return sendRequest(request, Set.class);
|
||||
} catch (Exception e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Unable to set available bandwidth for network [" + network
|
||||
|
@ -119,7 +115,7 @@ public class BandwidthService implements IBandwidthService {
|
|||
request.setBandwidth(bandwidth);
|
||||
|
||||
try {
|
||||
return ((Boolean) sendRequest(request)).booleanValue();
|
||||
return sendRequest(request, Boolean.class).booleanValue();
|
||||
} catch (Exception e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Unable to set available bandwidth for network [" + network
|
||||
|
@ -153,7 +149,7 @@ public class BandwidthService implements IBandwidthService {
|
|||
|
||||
try {
|
||||
@SuppressWarnings("unchecked")
|
||||
Set<String> retVal = (Set<String>) sendRequest(request);
|
||||
Set<String> retVal = sendRequest(request, Set.class);
|
||||
return retVal;
|
||||
} catch (Exception e) {
|
||||
LogUtil.logIterable(
|
||||
|
@ -184,7 +180,7 @@ public class BandwidthService implements IBandwidthService {
|
|||
request.setSubscriptions(subscriptions);
|
||||
|
||||
try {
|
||||
return (IProposeScheduleResponse) sendRequest(request);
|
||||
return sendRequest(request, IProposeScheduleResponse.class);
|
||||
} catch (Exception e) {
|
||||
LogUtil.logIterable(
|
||||
statusHandler,
|
||||
|
@ -220,7 +216,7 @@ public class BandwidthService implements IBandwidthService {
|
|||
request.setSubscriptions(Arrays.<Subscription> asList(sub));
|
||||
request.setRequestType(RequestType.GET_ESTIMATED_COMPLETION);
|
||||
try {
|
||||
return (Date) sendRequest(request);
|
||||
return sendRequest(request, Date.class);
|
||||
} catch (Exception e) {
|
||||
statusHandler
|
||||
.handle(Priority.PROBLEM,
|
||||
|
@ -239,7 +235,7 @@ public class BandwidthService implements IBandwidthService {
|
|||
IBandwidthRequest request = new IBandwidthRequest();
|
||||
request.setRequestType(RequestType.GET_BANDWIDTH_GRAPH_DATA);
|
||||
try {
|
||||
return (BandwidthGraphData) sendRequest(request);
|
||||
return sendRequest(request, BandwidthGraphData.class);
|
||||
} catch (Exception e) {
|
||||
statusHandler
|
||||
.handle(Priority.PROBLEM,
|
||||
|
@ -248,23 +244,4 @@ public class BandwidthService implements IBandwidthService {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@VisibleForTesting
|
||||
protected Object sendRequest(IBandwidthRequest 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 bandwidth service!",
|
||||
ExceptionWrapper
|
||||
.unwrapThrowable(((ServerErrorResponse) object)
|
||||
.getException()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,8 @@ Bundle-Version: 1.0.0.qualifier
|
|||
Require-Bundle: com.raytheon.uf.common.auth;bundle-version="1.12.1174",
|
||||
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.util;bundle-version="1.12.1174"
|
||||
com.raytheon.uf.common.util;bundle-version="1.12.1174",
|
||||
com.raytheon.uf.common.status;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.service
|
||||
|
|
|
@ -19,14 +19,9 @@
|
|||
**/
|
||||
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.auth.req.BaseServerService;
|
||||
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;
|
||||
import com.raytheon.uf.common.serialization.comm.IServerRequest;
|
||||
|
||||
/**
|
||||
* Base class for services that send requests to the data delivery server.
|
||||
|
@ -38,32 +33,21 @@ import com.raytheon.uf.common.serialization.comm.response.ServerErrorResponse;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 18, 2013 1441 djohnson Initial creation
|
||||
* Jan 23, 2013 1643 djohnson Break out reusable service handler code.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
public class BaseDataDeliveryService<T extends AbstractPrivilegedRequest> {
|
||||
public class BaseDataDeliveryService<T extends IServerRequest> extends
|
||||
BaseServerService<T> {
|
||||
|
||||
/**
|
||||
* Send a request to the data delivery server.
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
* @throws Exception
|
||||
* Constructor.
|
||||
*/
|
||||
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()));
|
||||
}
|
||||
protected BaseDataDeliveryService() {
|
||||
super(DataDeliveryConstants.DATA_DELIVERY_SERVER);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
/**
|
||||
* 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.auth.req.AbstractPrivilegedRequest;
|
||||
import com.raytheon.uf.common.auth.req.BasePrivilegedServerService;
|
||||
import com.raytheon.uf.common.datadelivery.request.DataDeliveryConstants;
|
||||
|
||||
/**
|
||||
* Base class for services that are privileged.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 23, 2013 1643 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class BasePrivilegedDataDeliveryService<T extends AbstractPrivilegedRequest>
|
||||
extends BasePrivilegedServerService<T> {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
protected BasePrivilegedDataDeliveryService() {
|
||||
super(DataDeliveryConstants.DATA_DELIVERY_SERVER);
|
||||
}
|
||||
|
||||
}
|
|
@ -19,10 +19,11 @@
|
|||
**/
|
||||
package com.raytheon.uf.common.datadelivery.service;
|
||||
|
||||
import java.rmi.RemoteException;
|
||||
|
||||
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}.
|
||||
|
@ -34,6 +35,7 @@ import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 18, 2013 1441 djohnson Initial creation
|
||||
* Feb 26, 2013 1643 djohnson Extend server request class.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -42,16 +44,17 @@ import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
|
|||
*/
|
||||
|
||||
public class GroupDefinitionService extends
|
||||
BaseDataDeliveryService<GroupDefinitionServiceRequest> implements
|
||||
IGroupDefinitionService {
|
||||
BasePrivilegedDataDeliveryService<GroupDefinitionServiceRequest>
|
||||
implements IGroupDefinitionService {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @throws Exception
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public void deleteGroupDefinition(GroupDefinition group)
|
||||
throws RegistryHandlerException {
|
||||
throws RemoteException {
|
||||
GroupDefinitionServiceRequest request = new GroupDefinitionServiceRequest();
|
||||
request.setGroup(group);
|
||||
request.setType(Type.DELETE);
|
||||
|
@ -59,17 +62,4 @@ public class GroupDefinitionService extends
|
|||
sendRequest(request);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected Object sendRequest(GroupDefinitionServiceRequest request)
|
||||
throws RegistryHandlerException {
|
||||
try {
|
||||
return super.sendRequest(request);
|
||||
} catch (Exception e) {
|
||||
throw new RegistryHandlerException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,8 +19,9 @@
|
|||
**/
|
||||
package com.raytheon.uf.common.datadelivery.service;
|
||||
|
||||
import java.rmi.RemoteException;
|
||||
|
||||
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.
|
||||
|
@ -32,6 +33,7 @@ import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 18, 2013 1441 djohnson Initial creation
|
||||
* Feb 26, 2013 1643 djohnson Change exception type thrown.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -45,8 +47,7 @@ public interface IGroupDefinitionService {
|
|||
*
|
||||
* @param group
|
||||
* the group
|
||||
* @throws RegistryHandlerException
|
||||
* @throws RemoteException
|
||||
*/
|
||||
void deleteGroupDefinition(GroupDefinition group)
|
||||
throws RegistryHandlerException;
|
||||
void deleteGroupDefinition(GroupDefinition group) throws RemoteException;
|
||||
}
|
||||
|
|
|
@ -41,12 +41,6 @@
|
|||
<entry key="Retrievals-5" value-ref="subscriptionRetrievalAgentPrototype" />
|
||||
</util:map>
|
||||
|
||||
<bean id="registerNcfBandwidthManagerServiceRouter" factory-bean="requestRouterRegistry"
|
||||
factory-method="register">
|
||||
<constructor-arg ref="ncfBandwidthManagerServiceKey" />
|
||||
<constructor-arg ref="ncfBandwidthManagerServiceRouter" />
|
||||
</bean>
|
||||
|
||||
<camelContext id="BandwidthManager-context"
|
||||
xmlns="http://camel.apache.org/schema/spring" errorHandlerRef="errorHandler">
|
||||
|
||||
|
|
|
@ -6,6 +6,4 @@
|
|||
<bean id="bandwidthManagerCreator"
|
||||
class="com.raytheon.uf.edex.datadelivery.bandwidth.NcfBandwidthManagerCreator" />
|
||||
|
||||
<bean id="ncfBandwidthManagerServiceRouter" class="com.raytheon.uf.edex.auth.ServerRequestRouter" />
|
||||
|
||||
</beans>
|
|
@ -0,0 +1,14 @@
|
|||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:util="http://www.springframework.org/schema/util" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
|
||||
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd">
|
||||
|
||||
<bean id="ncfBandwidthManagerServiceRouter" class="com.raytheon.uf.edex.auth.ServerRequestRouter" />
|
||||
|
||||
<bean id="registerNcfBandwidthManagerServiceRouter"
|
||||
factory-bean="requestRouterRegistry" factory-method="register">
|
||||
<constructor-arg ref="ncfBandwidthManagerServiceKey" />
|
||||
<constructor-arg ref="ncfBandwidthManagerServiceRouter" />
|
||||
</bean>
|
||||
|
||||
</beans>
|
|
@ -6,8 +6,4 @@
|
|||
<bean id="bandwidthManagerCreator"
|
||||
class="com.raytheon.uf.edex.datadelivery.bandwidth.WfoBandwidthManagerCreator" />
|
||||
|
||||
<bean id="ncfBandwidthManagerServiceRouter" class="com.raytheon.uf.edex.auth.RemoteServerRequestRouter">
|
||||
<constructor-arg value="${ncf.bandwidth.manager.service}" />
|
||||
</bean>
|
||||
|
||||
</beans>
|
|
@ -0,0 +1,16 @@
|
|||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:util="http://www.springframework.org/schema/util" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
|
||||
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd">
|
||||
|
||||
<bean id="ncfBandwidthManagerServiceRouter" class="com.raytheon.uf.edex.auth.RemoteServerRequestRouter">
|
||||
<constructor-arg value="${ncf.bandwidth.manager.service}" />
|
||||
</bean>
|
||||
|
||||
<bean id="registerNcfBandwidthManagerServiceRouter"
|
||||
factory-bean="requestRouterRegistry" factory-method="register">
|
||||
<constructor-arg ref="ncfBandwidthManagerServiceKey" />
|
||||
<constructor-arg ref="ncfBandwidthManagerServiceRouter" />
|
||||
</bean>
|
||||
|
||||
</beans>
|
|
@ -76,6 +76,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil;
|
|||
* 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.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -97,7 +98,7 @@ public class BandwidthServiceIntTest extends AbstractBandwidthManagerIntTest {
|
|||
|
||||
private final BandwidthService service = new BandwidthService() {
|
||||
@Override
|
||||
protected Object sendRequest(IBandwidthRequest request)
|
||||
protected Object getResponseFromServer(IBandwidthRequest request)
|
||||
throws Exception {
|
||||
// Serialize and deserialize each call, this makes sure the dynamic
|
||||
// serialize annotations are correct as well
|
||||
|
|
|
@ -29,6 +29,8 @@ import static org.mockito.Mockito.mock;
|
|||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import java.rmi.RemoteException;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -53,6 +55,7 @@ import com.raytheon.uf.edex.datadelivery.service.services.GroupDefinitionService
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 18, 2013 1441 djohnson Initial creation
|
||||
* Feb 26, 2013 1643 djohnson Change exception type thrown.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -72,14 +75,10 @@ public class GroupDefinitionServiceTest {
|
|||
|
||||
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);
|
||||
}
|
||||
protected Object getResponseFromServer(
|
||||
GroupDefinitionServiceRequest request) throws Exception {
|
||||
return new GroupDefinitionServiceHandler(
|
||||
subscriptionNotificationService).handleRequest(request);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -106,7 +105,7 @@ public class GroupDefinitionServiceTest {
|
|||
|
||||
@Test
|
||||
public void deletingAGroupUpdatesSubscriptionsToNotHaveAGroupName()
|
||||
throws RegistryHandlerException {
|
||||
throws RemoteException, RegistryHandlerException {
|
||||
|
||||
service.deleteGroupDefinition(group);
|
||||
|
||||
|
@ -116,7 +115,7 @@ public class GroupDefinitionServiceTest {
|
|||
|
||||
@Test
|
||||
public void deletingAGroupNotifiesOfSubscriptionUpdates()
|
||||
throws RegistryHandlerException {
|
||||
throws RemoteException, RegistryHandlerException {
|
||||
service.deleteGroupDefinition(group);
|
||||
|
||||
verify(subscriptionNotificationService, times(2))
|
||||
|
@ -125,7 +124,8 @@ public class GroupDefinitionServiceTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void deletingAGroupDeletesTheGroup() throws RegistryHandlerException {
|
||||
public void deletingAGroupDeletesTheGroup() throws RemoteException,
|
||||
RegistryHandlerException {
|
||||
|
||||
service.deleteGroupDefinition(group);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue