Issue #1794 Add flag to check whether phase3 data delivery code is available, crude ability to create a shared subscription

Amend:
  Add constant for "CAVE".
  Add preconditions on creating a subscription.

Change-Id: Icdd2bc0ebd1613724cea3a89d335415995e18cae

Former-commit-id: c4d4e37cad [formerly f8870c8946 [formerly 9a3bf6b1e59acea76f7f7973a599bc32c0d395f2]]
Former-commit-id: f8870c8946
Former-commit-id: bd58534855
This commit is contained in:
Dustin Johnson 2013-03-21 10:51:49 -05:00
parent 9818775763
commit ace2e517d5
12 changed files with 164 additions and 39 deletions

View file

@ -54,4 +54,6 @@ public class VizConstants {
public static final String LOADMODE_ID = "loadmode";
public static final String LOOPING_ID = "looping";
public static final String CAVE = "CAVE";
}

View file

@ -39,6 +39,7 @@ 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.common.util.ServiceLoaderUtil;
import com.raytheon.uf.viz.core.VizConstants;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.requests.INotAuthHandler;
@ -53,6 +54,7 @@ import com.raytheon.uf.viz.core.requests.INotAuthHandler;
* May 21, 2010 mschenke Initial creation
* Nov 06, 2012 1302 djohnson Add ability to retrieve the {@link IUserManager}.
* Jan 04, 2013 1451 djohnson Move static block code to an implementation of an interface.
* Mar 21, 2013 1794 djohnson ServiceLoaderUtil now requires the requesting class.
*
* </pre>
*
@ -68,14 +70,15 @@ public class UserController {
*/
private static class ExtensionPointManagerLoader implements
IUserManagerLoader {
private static final IUFStatusHandler statusHandler = UFStatus.getHandler(
ExtensionPointManagerLoader.class, "CAVE");
private static final IUFStatusHandler statusHandler = UFStatus
.getHandler(ExtensionPointManagerLoader.class,
VizConstants.CAVE);
private static final String EXTENSION_POINT = "com.raytheon.uf.viz.core.userManager";
private static final ExtensionPointManagerLoader INSTANCE = new ExtensionPointManagerLoader();
private ExtensionPointManagerLoader() {
}
@ -176,13 +179,13 @@ public class UserController {
// If a service loader config file for the interface is present on the
// classpath, it can change the implementation, such as in a test case
IUserManagerLoader userManagerLoader = ServiceLoaderUtil.load(
IUserManagerLoader.class, ExtensionPointManagerLoader.INSTANCE);
UserController.class, IUserManagerLoader.class,
ExtensionPointManagerLoader.INSTANCE);
// manager is now final, it can't be changed once it is initialized
manager = userManagerLoader.getUserManager();
}
public static IUser getUserObject() {
return manager.getUserObject();
}

View file

@ -49,6 +49,7 @@ import com.raytheon.uf.common.datadelivery.registry.DataSetMetaData;
import com.raytheon.uf.common.datadelivery.registry.Ensemble;
import com.raytheon.uf.common.datadelivery.registry.GriddedDataSet;
import com.raytheon.uf.common.datadelivery.registry.GriddedDataSetMetaData;
import com.raytheon.uf.common.datadelivery.registry.Network;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.datadelivery.registry.Time;
import com.raytheon.uf.common.datadelivery.registry.handlers.DataDeliveryHandlers;
@ -85,6 +86,8 @@ import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryUtils;
* Jan 04, 2013 1420 mpduff Pass cycles in for rules.
* Jan 18, 2013 1414 bsteffen Add ensemble tab.
* Jan 28, 2013 1533 djohnson Update the calculated dataset size after loading subset xml.
* Mar 21, 2013 1794 djohnson Add option to create a shared subscription, if phase3 code is available.
*
*
* </pre>
*
@ -253,8 +256,9 @@ public class GriddedSubsetManagerDlg
* {@inheritDoc}
*/
@Override
protected <T extends Subscription> T createSubscription(T sub) {
T subscription = super.createSubscription(sub);
protected <T extends Subscription> T createSubscription(T sub,
Network defaultRoute) {
T subscription = super.createSubscription(sub, defaultRoute);
if (subscription == null) {
return null;
}

View file

@ -46,6 +46,7 @@ import org.geotools.geometry.jts.ReferencedEnvelope;
import org.opengis.geometry.Envelope;
import org.opengis.referencing.operation.TransformException;
import com.google.common.base.Preconditions;
import com.raytheon.uf.common.datadelivery.registry.AdhocSubscription;
import com.raytheon.uf.common.datadelivery.registry.DataLevelType;
import com.raytheon.uf.common.datadelivery.registry.DataSet;
@ -53,9 +54,11 @@ import com.raytheon.uf.common.datadelivery.registry.DataType;
import com.raytheon.uf.common.datadelivery.registry.GriddedCoverage;
import com.raytheon.uf.common.datadelivery.registry.GriddedDataSet;
import com.raytheon.uf.common.datadelivery.registry.Levels;
import com.raytheon.uf.common.datadelivery.registry.Network;
import com.raytheon.uf.common.datadelivery.registry.Parameter;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.datadelivery.registry.Time;
import com.raytheon.uf.common.datadelivery.request.DataDeliveryConstants;
import com.raytheon.uf.common.datadelivery.request.DataDeliveryPermission;
import com.raytheon.uf.common.datadelivery.retrieval.util.DataSizeUtils;
import com.raytheon.uf.common.geospatial.MapUtil;
@ -127,6 +130,7 @@ import com.raytheon.viz.ui.presenter.IDisplay;
* Jan 10, 2013 1444 mpduff Fix the loading of saved subsets from the saved subset tab.
* Jan 28, 2013 1530 djohnson Break out long method chaining into local variables for debugging.
* Jan 30, 2013 1543 djohnson Use List instead of ArrayList.
* Mar 21, 2013 1794 djohnson Add option to create a shared subscription, if phase3 code is available.
* </pre>
*
* @author mpduff
@ -442,7 +446,8 @@ public abstract class SubsetManagerDlg<DATASET extends DataSet, PRESENTER extend
/** Create the buttons */
private void createButtons() {
GridData gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false);
GridLayout gl = new GridLayout(3, false);
final int numColumns = (DataDeliveryConstants.PHASE3_ENABLED) ? 4 : 3;
GridLayout gl = new GridLayout(numColumns, false);
Composite bottomComp = new Composite(shell, SWT.NONE);
bottomComp.setLayout(gl);
@ -451,27 +456,40 @@ public abstract class SubsetManagerDlg<DATASET extends DataSet, PRESENTER extend
int buttonWidth = 87;
GridData btnData = new GridData(buttonWidth, SWT.DEFAULT);
Button okBtn = new Button(bottomComp, SWT.PUSH);
Button subscribeBtn = new Button(bottomComp, SWT.PUSH);
if (!create) {
okBtn.setText("Continue...");
okBtn.setToolTipText("Click to continue editing");
subscribeBtn.setText("Continue...");
subscribeBtn.setToolTipText("Click to continue editing");
} else {
okBtn.setText("Subscribe...");
okBtn.setToolTipText("Click to subscribe to subset");
subscribeBtn.setText("Subscribe...");
subscribeBtn
.setToolTipText("Click to create a subscription to a subset");
}
okBtn.setLayoutData(btnData);
okBtn.addSelectionListener(new SelectionAdapter() {
subscribeBtn.setLayoutData(btnData);
subscribeBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
DataDeliveryGUIUtils.markBusyInUIThread(shell);
if (handleOK()) {
close();
} else {
DataDeliveryGUIUtils.markNotBusyInUIThread(shell);
}
launchCreateSubscriptionGui(Network.OPSNET);
}
});
if (create) {
if (DataDeliveryConstants.PHASE3_ENABLED) {
btnData = new GridData(buttonWidth, SWT.DEFAULT);
Button sharedSubscribeBtn = new Button(bottomComp, SWT.PUSH);
sharedSubscribeBtn.setText("Shared...");
sharedSubscribeBtn
.setToolTipText("Click to create a shared subscription to a subset");
sharedSubscribeBtn.setLayoutData(btnData);
sharedSubscribeBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
launchCreateSubscriptionGui(Network.SBN);
}
});
}
}
btnData = new GridData(buttonWidth, SWT.DEFAULT);
Button queryBtn = new Button(bottomComp, SWT.PUSH);
queryBtn.setText("Query");
@ -495,16 +513,29 @@ public abstract class SubsetManagerDlg<DATASET extends DataSet, PRESENTER extend
}
});
}
private void launchCreateSubscriptionGui(Network defaultRoute) {
DataDeliveryGUIUtils.markBusyInUIThread(shell);
if (handleOK(defaultRoute)) {
close();
} else {
DataDeliveryGUIUtils.markNotBusyInUIThread(shell);
}
}
/**
* OK button action handler
*
* @param defaultRoute
*
* @return true if data are valid
*/
private boolean handleOK() {
private boolean handleOK(Network defaultRoute) {
if (this.validated(true)) {
Subscription sub = createSubscription(new Subscription());
Subscription sub = createSubscription(new Subscription(),
defaultRoute);
if (subDlg != null && !subDlg.isDisposed()) {
subDlg.setSubscriptionData(sub);
subDlg.bringToTop();
@ -529,7 +560,8 @@ public abstract class SubsetManagerDlg<DATASET extends DataSet, PRESENTER extend
if (valid) {
AdhocSubscription as = createSubscription(new AdhocSubscription());
AdhocSubscription as = createSubscription(new AdhocSubscription(),
Network.OPSNET);
// null means the user hit cancel on the date/cycle selection dialog
if (as == null) {
return;
@ -556,12 +588,21 @@ public abstract class SubsetManagerDlg<DATASET extends DataSet, PRESENTER extend
* The subscription object reference type
* @param sub
* The subscription to populate
* @param the
* route for the subscription
*
* @return the populated subscription
*/
protected <T extends Subscription> T createSubscription(T sub) {
protected <T extends Subscription> T createSubscription(T sub,
Network defaultRoute) {
Preconditions.checkNotNull(sub, "A subscription must be provided.");
Preconditions.checkNotNull(defaultRoute,
"A defaultRoute must be provided.");
ArrayList<Parameter> selectedParameterObjs = vTab.getParameters();
sub.setRoute(defaultRoute);
sub.setName(nameText.getText());
sub.setOfficeID(LocalizationManager.getInstance().getCurrentSite());
if (create) {
@ -915,8 +956,7 @@ public abstract class SubsetManagerDlg<DATASET extends DataSet, PRESENTER extend
final List<Integer> selectedLevelIndices = levels
.getSelectedLevelIndices();
for (int index : selectedLevelIndices) {
v.addLevel(String.valueOf(levels.getLevel()
.get(index)));
v.addLevel(String.valueOf(levels.getLevel().get(index)));
}
}
}

View file

@ -1,6 +1,7 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Request
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-SymbolicName: com.raytheon.uf.common.datadelivery.request
Bundle-Version: 1.0.0.qualifier
Require-Bundle: com.raytheon.uf.common.auth;bundle-version="1.12.1174",
@ -11,3 +12,4 @@ Require-Bundle: com.raytheon.uf.common.auth;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
Eclipse-BuddyPolicy: ext, registered, global

View file

@ -19,6 +19,8 @@
**/
package com.raytheon.uf.common.datadelivery.request;
import com.raytheon.uf.common.util.ServiceLoaderUtil;
/**
* Consolidates data delivery server constants.
*
@ -31,6 +33,7 @@ package com.raytheon.uf.common.datadelivery.request;
* Nov 14, 2012 1286 djohnson Initial creation
* Dec 03, 2012 1379 djohnson Separate registry service keys.
* Feb 26, 2013 1643 djohnson Add NCF_BANDWIDTH_MANAGER_SERVICE.
* Mar 21, 2013 1794 djohnson Add flag denoting whether phase3 code is enabled.
*
* </pre>
*
@ -43,6 +46,19 @@ public final class DataDeliveryConstants {
public static final String NCF_BANDWIDTH_MANAGER_SERVICE = "ncf.bandwidth.manager.service";
/**
* Denotes whether or not the phase 3 code is enabled. Will only return true
* if components from the 5-Data_Delivery repository are installed.
*/
public static final boolean PHASE3_ENABLED = ServiceLoaderUtil.load(
DataDeliveryConstants.class, IPhase3Initializer.class,
new IPhase3Initializer() {
@Override
public boolean isPhase3CodeEnabled() {
return false;
}
}).isPhase3CodeEnabled();
/**
* Private constructor.
*/

View file

@ -0,0 +1,48 @@
/**
* 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.request;
/**
* Interface defining a way to check if phase3 code is enabled.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 21, 2013 1794 djohnson Initial creation.
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public interface IPhase3Initializer {
/**
* Checks whether or not the phase 3 code is enabled at runtime. Should only
* return true if components from the 5-Data_Delivery repository are
* installed.
*
* @return true if the phase 3 code is enabled
*/
boolean isPhase3CodeEnabled();
}

View file

@ -45,7 +45,6 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.common.util.CollectionUtil;
import com.raytheon.uf.common.util.ServiceLoaderUtil;
/**
* Lookup table manager
*
@ -57,6 +56,7 @@ import com.raytheon.uf.common.util.ServiceLoaderUtil;
* Mar 7, 2011 357 dhladky Initial creation
* Oct 27, 2012 1163 dhladky Improved, dynamically create files, Added Units
* Jan 18, 2013 1513 dhladky Level lookup refit.
* Mar 21, 2013 1794 djohnson ServiceLoaderUtil now requires the requesting class.
*
* </pre>
*
@ -140,10 +140,12 @@ public class LookupManager {
private UnitLookup unitLookup = null;
private final LevelXmlWriter levelXmlWriter = ServiceLoaderUtil.load(
LookupManager.class,
LevelXmlWriter.class, new LocalizationXmlWriter());
private final ParameterXmlWriter parameterXmlWriter = ServiceLoaderUtil
.load(ParameterXmlWriter.class, new LocalizationXmlWriter());
.load(LookupManager.class, ParameterXmlWriter.class,
new LocalizationXmlWriter());
/* Private Constructor */
private LookupManager() {

View file

@ -45,6 +45,7 @@ import com.raytheon.uf.common.util.ServiceLoaderUtil;
* to accept class parameter, deprecate old versions. Improve performance
* of getJaxbManager().
* Feb 07, 2013 1543 djohnson Use ServiceLoader to find how to load jaxbable classes, defaulting to SerializableManager.
* Mar 21, 2013 1794 djohnson ServiceLoaderUtil now requires the requesting class.
*
* </pre>
*
@ -55,7 +56,7 @@ import com.raytheon.uf.common.util.ServiceLoaderUtil;
public final class SerializationUtil {
private static final IJaxbableClassesLocator jaxbableClassesLocator = ServiceLoaderUtil
.load(IJaxbableClassesLocator.class,
.load(SerializationUtil.class, IJaxbableClassesLocator.class,
SerializableManager.getInstance());
private static volatile JAXBManager jaxbManager;

View file

@ -32,6 +32,7 @@ import java.util.ServiceLoader;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jan 04, 2013 1451 djohnson Initial creation
* Mar 21, 2013 1794 djohnson Requires the requesting class, for osgi support.
*
* </pre>
*
@ -51,6 +52,8 @@ public final class ServiceLoaderUtil {
* {@link ServiceLoader}. If no results are found, will return the provided
* default implementation.
*
* @param requestingClass
* the class to use the classloader from
* @param interfaceClass
* the class instance to search for a service loader
* implementation of
@ -59,8 +62,10 @@ public final class ServiceLoaderUtil {
* @return the loaded implementation, or the default implementation is no
* configuration file found
*/
public static <T> T load(Class<T> interfaceClass, T defaultImplementation) {
ServiceLoader<T> overridden = ServiceLoader.load(interfaceClass);
public static <T> T load(Class<?> requestingClass, Class<T> interfaceClass,
T defaultImplementation) {
ServiceLoader<T> overridden = ServiceLoader.load(interfaceClass,
requestingClass.getClassLoader());
final Iterator<T> iter = overridden.iterator();
if (iter.hasNext()) {

View file

@ -39,6 +39,7 @@ import com.raytheon.uf.edex.datadelivery.retrieval.wxxm.WxxmServiceFactory;
* ------------ ---------- ----------- --------------------------
* Jul 24, 2012 955 djohnson Initial creation
* Nov 19, 2012 1166 djohnson Clean up JAXB representation of registry objects.
* Mar 21, 2013 1794 djohnson ServiceLoaderUtil now requires the requesting class.
*
* </pre>
*
@ -47,7 +48,7 @@ import com.raytheon.uf.edex.datadelivery.retrieval.wxxm.WxxmServiceFactory;
*/
public final class ServiceTypeFactory {
/**
* Default {@link IServiceFactoryLookup} to be used in production code.
*/
@ -74,7 +75,7 @@ public final class ServiceTypeFactory {
}
private static final IServiceFactoryLookup SERVICE_FACTORY_LOOKUP = ServiceLoaderUtil
.load(IServiceFactoryLookup.class,
.load(ServiceTypeFactory.class, IServiceFactoryLookup.class,
new ServiceTypeFactoryLookup());
private ServiceTypeFactory() {

View file

@ -36,7 +36,8 @@ import org.junit.Test;
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jan 04, 2013 1441 djohnson Initial creation
* Jan 04, 2013 1441 djohnson Initial creation
* Mar 21, 2013 1794 djohnson ServiceLoaderUtil now requires the requesting class.
*
* </pre>
*
@ -55,7 +56,7 @@ public class ServiceLoaderUtilTest {
};
NoServiceLoaderConfigFile loaded = ServiceLoaderUtil.load(
NoServiceLoaderConfigFile.class,
ServiceLoaderUtilTest.class, NoServiceLoaderConfigFile.class,
defaultImplementation);
assertThat(loaded, is(sameInstance(defaultImplementation)));
@ -67,7 +68,7 @@ public class ServiceLoaderUtilTest {
};
HasServiceLoaderConfigFile loaded = ServiceLoaderUtil.load(
HasServiceLoaderConfigFile.class,
ServiceLoaderUtilTest.class, HasServiceLoaderConfigFile.class,
defaultImplementation);
assertThat(loaded, is(not(sameInstance(defaultImplementation))));