Merge "Issue #2180 - Implement front end of ogc encryption, redesign DD system management dialog Peer review comments" into development

Former-commit-id: 6f1e633d57 [formerly b8d050a172 [formerly cb230698c8be8faef2441171f2270e41807f797d]]
Former-commit-id: b8d050a172
Former-commit-id: 23dca45a0c
This commit is contained in:
Lee Venable 2013-08-19 15:14:22 -05:00 committed by Gerrit Code Review
commit f666a24c75
19 changed files with 1457 additions and 799 deletions

View file

@ -36,9 +36,11 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.common.util.StringUtil;
import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryGUIUtils;
import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryUtils;
import com.raytheon.viz.ui.widgets.ApplyCancelComposite;
import com.raytheon.viz.ui.widgets.IApplyCancelAction;
/**
* Subscription overlap configuration.
* Bandwidth settings composite
*
* <pre>
*
@ -46,53 +48,58 @@ import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryUtils;
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 14, 2013 2000 djohnson Initial creation
* May 23, 2013 1650 djohnson Reword change bandwidth message.
* Jun 12, 2013 2064 mpduff Update label.
* Jul 11, 2013 2106 djohnson SystemRuleManager now returns names of subscriptions.
* Aug 6, 2013 2180 mpduff Initial creation
*
* </pre>
*
* @author djohnson
* @author mpduff
* @version 1.0
*/
public class BandwidthTab extends SystemApplyCancelTab {
public class BandwidthComposite extends Composite implements IApplyCancelAction {
/** Status Handler */
private final IUFStatusHandler statusHandler = UFStatus
.getHandler(BandwidthTab.class);
.getHandler(BandwidthComposite.class);
/** Available bandwidth spinner widget */
private Spinner availBandwidthSpinner;
/** The listener that should be used to signify changes were made **/
private final Runnable changesWereMade = new Runnable() {
@Override
public void run() {
buttonComp.enableButtons(true);
}
};
/** Button composite */
private ApplyCancelComposite buttonComp;
/**
* Constructor.
*
* @param parentComp
* The Composite holding these controls
* @param parent
* Parent Composite
* @param style
* Style bits
*/
public BandwidthTab(Composite parentComp) {
super(parentComp);
public BandwidthComposite(Composite parent, int style) {
super(parent, style);
init();
}
/**
* Get the tab text.
*
* @return the tab text
* Initialize the class
*/
@Override
public String getTabText() {
return "Bandwidth";
}
private void init() {
GridLayout gl = new GridLayout(1, true);
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
this.setLayout(gl);
this.setLayoutData(gd);
/**
* {@inheritDoc}
*/
@Override
protected void initializeTabComponents(Composite mainComp) {
GridLayout gl = new GridLayout(1, false);
GridData gd = new GridData(SWT.VERTICAL, SWT.DEFAULT, true, false);
Composite configurationComposite = new Composite(mainComp, SWT.NONE);
gl = new GridLayout(1, false);
gd = new GridData(SWT.VERTICAL, SWT.DEFAULT, true, false);
Composite configurationComposite = new Composite(this, SWT.NONE);
configurationComposite.setLayout(gl);
configurationComposite.setLayoutData(gd);
@ -122,13 +129,16 @@ public class BandwidthTab extends SystemApplyCancelTab {
availBandwidthSpinner.setToolTipText("Select bandwidth in Kilobytes");
this.availBandwidthSpinner = availBandwidthSpinner;
// Buttons
buttonComp = new ApplyCancelComposite(this, SWT.NONE, this);
loadConfiguration();
}
/**
* {@inheritDoc}
* Load the configuration
*/
@Override
protected void loadConfiguration() {
private void loadConfiguration() {
DataDeliveryGUIUtils.removeListeners(availBandwidthSpinner,
SWT.Selection, SWT.DefaultSelection);
@ -142,10 +152,11 @@ public class BandwidthTab extends SystemApplyCancelTab {
}
/**
* {@inheritDoc}
* Save the configuration.
*
* @return true if saved
*/
@Override
protected boolean saveConfiguration() {
private boolean saveConfiguration() {
boolean changesApplied = false;
final int bandwidth = availBandwidthSpinner.getSelection();
@ -163,8 +174,9 @@ public class BandwidthTab extends SystemApplyCancelTab {
subscriptionNames));
sb.append(StringUtil.NEWLINE).append(StringUtil.NEWLINE);
sb.append("Would you like to change the bandwidth anyway?");
int response = DataDeliveryUtils.showMessage(parentComp.getShell(),
SWT.YES | SWT.NO, "Bandwidth Amount", sb.toString());
int response = DataDeliveryUtils.showMessage(
getParent().getShell(), SWT.YES | SWT.NO,
"Bandwidth Amount", sb.toString());
if (response == SWT.YES) {
changesApplied = SystemRuleManager.forceSetAvailableBandwidth(
Network.OPSNET, bandwidth);
@ -183,4 +195,23 @@ public class BandwidthTab extends SystemApplyCancelTab {
return changesApplied;
}
}
/**
* {@inheritDoc}
*/
@Override
public boolean apply() {
if (saveConfiguration()) {
return true;
}
return false;
}
/**
* {@inheritDoc}
*/
@Override
public void cancel() {
loadConfiguration();
}
}

View file

@ -0,0 +1,371 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.datadelivery.system;
import java.util.Collections;
import java.util.List;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.KeyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import com.raytheon.uf.common.datadelivery.registry.Connection;
import com.raytheon.uf.common.datadelivery.registry.Encryption;
import com.raytheon.uf.common.datadelivery.registry.Encryption.Algorithim;
import com.raytheon.uf.common.datadelivery.registry.Encryption.Padding;
import com.raytheon.uf.common.datadelivery.registry.Provider;
import com.raytheon.uf.common.datadelivery.registry.ProviderKeyRequest;
import com.raytheon.uf.common.datadelivery.registry.ProviderKeyRequest.RequestType;
import com.raytheon.uf.common.datadelivery.registry.ProviderKeyRequest.Status;
import com.raytheon.uf.common.datadelivery.registry.handlers.DataDeliveryHandlers;
import com.raytheon.uf.common.datadelivery.registry.handlers.IProviderHandler;
import com.raytheon.uf.common.registry.RegistryConstants;
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
import com.raytheon.uf.common.serialization.comm.RequestRouter;
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.viz.ui.widgets.ApplyCancelComposite;
import com.raytheon.viz.ui.widgets.IApplyCancelAction;
/**
* Data Provider Password settings composite.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Aug 07, 2013 2180 mpduff Initial creation.
*
* </pre>
*
* @author mpduff
* @version 1.0
*/
public class DataProviderPasswordComposite extends Composite implements
IApplyCancelAction {
/** Status handler */
private final IUFStatusHandler statusHandler = UFStatus
.getHandler(DataProviderPasswordComposite.class);
/** Key text field */
private Text keyTxt;
/** Password text field */
private Text passTxt;
/** Username text field */
private Text userTxt;
/** Encryption type combo box */
private Combo encryptionCbo;
/** Button composite */
private ApplyCancelComposite buttonComp;
/** Provider name combo box */
private Combo providerCombo;
/** List of Provider objects */
private List<Provider> providerList = Collections.emptyList();
/** Provider object */
private Provider provider;
/**
* Constructor
*
* @param parent
* Parent Composite
* @param style
* Style bits
*/
public DataProviderPasswordComposite(Composite parent, int style) {
super(parent, style);
init();
}
/**
* Initialize class
*/
private void init() {
GridLayout gl = new GridLayout(1, true);
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
this.setLayout(gl);
this.setLayoutData(gd);
gl = new GridLayout(3, false);
gd = new GridData(SWT.VERTICAL, SWT.DEFAULT, true, false);
gl.marginTop = 15;
gl.marginLeft = 15;
Composite comp = new Composite(this, SWT.NONE);
comp.setLayout(gl);
comp.setLayoutData(gd);
Label providerLabel = new Label(comp, SWT.NONE);
providerLabel.setText("Provider:");
providerCombo = new Combo(comp, SWT.READ_ONLY);
providerCombo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
handleProviderSelection();
}
});
Label spacer = new Label(comp, SWT.NONE);
spacer.setText("");
Label userLabel = new Label(comp, SWT.NONE);
userLabel.setText("User Name:");
userTxt = new Text(comp, SWT.BORDER);
userTxt.setLayoutData(new GridData(150, SWT.DEFAULT));
userTxt.addKeyListener(new KeyListener() {
@Override
public void keyReleased(KeyEvent e) {
checkTextFields();
}
@Override
public void keyPressed(KeyEvent e) {
checkTextFields();
}
});
Label spacer2 = new Label(comp, SWT.NONE);
spacer2.setText("");
Label passLabel = new Label(comp, SWT.NONE);
passLabel.setText("Password:");
passTxt = new Text(comp, SWT.BORDER);
passTxt.setLayoutData(new GridData(150, SWT.DEFAULT));
passTxt.setEchoChar('*');
passTxt.addKeyListener(new KeyListener() {
@Override
public void keyReleased(KeyEvent e) {
checkTextFields();
}
@Override
public void keyPressed(KeyEvent e) {
checkTextFields();
}
});
final Button showPassChk = new Button(comp, SWT.CHECK);
showPassChk.setText("Show password text");
showPassChk.setSelection(false);
showPassChk.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (showPassChk.getSelection()) {
passTxt.setEchoChar('\0');
} else {
passTxt.setEchoChar('*');
}
}
});
Label keyLabel = new Label(comp, SWT.NONE);
keyLabel.setText("Encryption Key:");
keyTxt = new Text(comp, SWT.BORDER);
keyTxt.setLayoutData(new GridData(150, SWT.DEFAULT));
keyTxt.setEchoChar('*');
keyTxt.addKeyListener(new KeyListener() {
@Override
public void keyReleased(KeyEvent e) {
checkTextFields();
}
@Override
public void keyPressed(KeyEvent e) {
checkTextFields();
}
});
final Button showKeyChk = new Button(comp, SWT.CHECK);
showKeyChk.setText("Show encryption key text");
showKeyChk.setSelection(false);
showKeyChk.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (showKeyChk.getSelection()) {
keyTxt.setEchoChar('\0');
} else {
keyTxt.setEchoChar('*');
}
}
});
Label encryptionLabel = new Label(comp, SWT.NONE);
encryptionLabel.setText("Encryption Type:");
encryptionCbo = new Combo(comp, SWT.READ_ONLY);
encryptionCbo.add(Encryption.Algorithim.AES.toString());
encryptionCbo.add(Encryption.Algorithim.DES.toString());
encryptionCbo.select(0);
// Buttons
buttonComp = new ApplyCancelComposite(this, SWT.NONE, this);
load();
}
/**
* Load the settings info.
*/
public void load() {
IProviderHandler handler = DataDeliveryHandlers.getProviderHandler();
try {
providerList = handler.getAll();
} catch (RegistryHandlerException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
}
for (Provider p : providerList) {
providerCombo.add(p.getName());
}
}
/**
* Check the text fields to determine of buttons should be enabled or not
*/
private void checkTextFields() {
if ((!userTxt.getText().isEmpty() && !keyTxt.getText().isEmpty() && !passTxt
.getText().isEmpty()) && providerCombo.getSelectionIndex() > -1) {
buttonComp.enableButtons(true);
}
}
/**
* Provider selection handler
*/
private void handleProviderSelection() {
userTxt.setText("");
passTxt.setText("");
keyTxt.setText("");
String provider = providerCombo.getText();
for (Provider p : providerList) {
if (p.getName().equals(provider)) {
this.provider = p;
ProviderKeyRequest req = new ProviderKeyRequest();
req.setRequestType(RequestType.RETRIEVE);
req.setProvider(p);
ProviderKeyRequest resp;
try {
resp = (ProviderKeyRequest) RequestRouter.route(req,
RegistryConstants.EBXML_REGISTRY_SERVICE);
Connection conn = resp.getProvider().getConnection();
String userName = conn.getUnencryptedUsername();
String passwd = conn.getUnencryptedPassword();
String key = conn.getProviderKey();
if (userName != null) {
userTxt.setText(userName);
}
if (passwd != null) {
passTxt.setText(passwd);
}
if (key != null) {
keyTxt.setText(key);
}
} catch (Exception e) {
statusHandler.handle(Priority.PROBLEM,
"Error requesting provider information.", e);
}
}
}
}
/**
* {@inheritDoc}
*/
@Override
public boolean apply() {
ProviderKeyRequest req = new ProviderKeyRequest();
Connection conn = provider.getConnection();
conn.setPassword(passTxt.getText());
conn.setUserName(userTxt.getText());
conn.setProviderKey(keyTxt.getText());
conn.setEncryption(getEncryption(encryptionCbo.getText()));
provider.setConnection(conn);
req.setProvider(provider);
req.setRequestType(RequestType.SAVE);
req.setProviderKey(keyTxt.getText());
ProviderKeyRequest resp;
Status status = Status.FAILURE;
try {
resp = (ProviderKeyRequest) RequestRouter.route(req,
RegistryConstants.EBXML_REGISTRY_SERVICE);
status = resp.getStatus();
} catch (Exception e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
}
return status == Status.SUCCESS;
}
/**
* Get the encryption object
*
* @param text
* The encryption algorithm
* @return The Encryption object
*/
private Encryption getEncryption(String text) {
Encryption enc = null;
if (text.equals(Encryption.Algorithim.AES.toString())) {
enc = new Encryption();
enc.setAlgorithim(Algorithim.AES);
enc.setPadding(Padding.AES);
}
if (text.equals(Encryption.Algorithim.DES.toString())) {
enc = new Encryption();
enc.setAlgorithim(Algorithim.DES);
enc.setPadding(Padding.DES);
}
return enc;
}
/**
* {@inheritDoc}
*/
@Override
public void cancel() {
// This resets the fields
handleProviderSelection();
}
}

View file

@ -19,10 +19,8 @@
**/
package com.raytheon.uf.viz.datadelivery.system;
import org.eclipse.swt.widgets.Composite;
/**
* Base class for system management tabs.
* New/Edit/Delete button action interface.
*
* <pre>
*
@ -30,44 +28,33 @@ import org.eclipse.swt.widgets.Composite;
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 17, 2013 2000 djohnson Initial creation
* Aug 7, 2013 2180 mpduff Initial creation
*
* </pre>
*
* @author djohnson
* @author mpduff
* @version 1.0
*/
public abstract class SystemTab {
/** Parent Composite */
protected final Composite parentComp;
public interface INewEditDeleteAction {
/**
* @return the parentComp
*/
public Composite getParentComp() {
return parentComp;
}
/**
* Constructor.
* New action.
*
* @param parentComp
* @return true if successfully created
*/
protected SystemTab(Composite parentComp) {
this.parentComp = parentComp;
}
boolean newAction();
/**
* Initialize the tab.
*/
public abstract void init();
/**
* Get the tab's title text.
* Edit action.
*
* @return the title text
* @return true if successfully edited
*/
public abstract String getTabText();
boolean editAction();
/**
* Delete action.
*
* @return true if successfully deleted
*/
boolean deleteAction();
}

View file

@ -0,0 +1,152 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.datadelivery.system;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import com.raytheon.viz.ui.widgets.IEnableAction;
/**
* New/Edit/Delete Button composite.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Aug 07, 2013 2180 mpduff Initial creation
*
* </pre>
*
* @author mpduff
* @version 1.0
*/
public class NewEditDeleteComposite extends Composite implements IEnableAction {
/** Button Width. */
private final int buttonWidth = 70;
/** Edit button. */
private Button editBtn;
/** New button. */
private Button newBtn;
/** Delete button. */
private Button deleteBtn;
/** Flag for create and edit. */
private boolean create;
/** Button callback action */
private final INewEditDeleteAction callback;
/**
* Constructor.
*
* @param parent
* Parent composite
* @param style
* style bits
* @param callback
* button action callback
*/
public NewEditDeleteComposite(Composite parent, int style,
INewEditDeleteAction callback) {
super(parent, style);
this.callback = callback;
init();
}
/**
* Initialize class
*/
private void init() {
GridLayout gl = new GridLayout(1, false);
GridData gd = new GridData(SWT.RIGHT, SWT.DEFAULT, true, false);
this.setLayout(gl);
this.setLayoutData(gd);
GridData actionData = new GridData(SWT.DEFAULT, SWT.BOTTOM, false, true);
GridLayout actionLayout = new GridLayout(3, false);
Composite actionComp = new Composite(this, SWT.NONE);
actionComp.setLayout(actionLayout);
actionComp.setLayoutData(actionData);
GridData btnData = new GridData(buttonWidth, SWT.DEFAULT);
btnData.horizontalAlignment = SWT.RIGHT;
newBtn = new Button(actionComp, SWT.PUSH);
newBtn.setText("New...");
newBtn.setLayoutData(btnData);
newBtn.setEnabled(true);
newBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
callback.newAction();
}
});
btnData = new GridData(buttonWidth, SWT.DEFAULT);
btnData.widthHint = buttonWidth;
btnData.heightHint = SWT.DEFAULT;
editBtn = new Button(actionComp, SWT.PUSH);
editBtn.setText("Edit...");
editBtn.setLayoutData(btnData);
editBtn.setEnabled(false);
editBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
callback.editAction();
}
});
btnData = new GridData(buttonWidth, SWT.DEFAULT);
btnData.widthHint = buttonWidth;
btnData.heightHint = SWT.DEFAULT;
deleteBtn = new Button(actionComp, SWT.PUSH);
deleteBtn.setText("Delete");
deleteBtn.setLayoutData(btnData);
deleteBtn.setEnabled(false);
deleteBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
callback.deleteAction();
}
});
}
/**
* {@inheritDoc}
*/
@Override
public void enableButtons(boolean enabled) {
editBtn.setEnabled(enabled);
deleteBtn.setEnabled(enabled);
}
}

View file

@ -40,7 +40,7 @@ import com.raytheon.uf.viz.core.image.StatusImages;
import com.raytheon.uf.viz.core.image.StatusImages.StatusImage;
/**
* Data Delivery Status Tab
* Data Delivery system status composite.
*
* <pre>
*
@ -48,17 +48,16 @@ import com.raytheon.uf.viz.core.image.StatusImages.StatusImage;
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jun 17, 2013 1655 mpduff Initial creation.
* Aug 07, 2013 2180 mpduff Initial creation
*
* </pre>
*
* @author mpduff
* @version 1.0
*/
public class StatusTab extends SystemTab {
public class StatusComposite extends Composite {
private final IUFStatusHandler statusHandler = UFStatus
.getHandler(StatusTab.class);
.getHandler(StatusComposite.class);
/** Provider Group */
private Composite providerComp;
@ -66,31 +65,38 @@ public class StatusTab extends SystemTab {
/** Registry Group */
private Composite registryComp;
/** Status images */
private StatusImages images;
/**
* Constructor.
*
* @param parentComp
* The Composite holding these
* controlsDataDeliverySystemStatusDefinition
* @param parent
* Parent Composite
* @param style
* Style Bits
*/
public StatusTab(Composite parentComp) {
super(parentComp);
public StatusComposite(Composite parent, int style) {
super(parent, style);
init();
}
/**
* {@inheritDoc}
* Initialize class
*/
@Override
public void init() {
images = new StatusImages(getParentComp().getShell());
private void init() {
images = new StatusImages(this.getShell());
GridLayout gl = new GridLayout(2, true);
GridLayout gl = new GridLayout(1, true);
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
this.setLayout(gl);
this.setLayoutData(gd);
gl = new GridLayout(2, true);
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
gl.marginWidth = 0;
Composite sysComp = new Composite(parentComp, SWT.NONE);
Composite sysComp = new Composite(this, SWT.NONE);
sysComp.setLayout(gl);
sysComp.setLayoutData(gd);
@ -102,7 +108,7 @@ public class StatusTab extends SystemTab {
registryGrp.setLayoutData(gd);
gl = new GridLayout(1, true);
gd = new GridData(SWT.FILL, SWT.DEFAULT, false, false);
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
registryComp = new Composite(registryGrp, SWT.NONE);
registryComp.setLayout(gl);
registryComp.setLayoutData(gd);
@ -115,7 +121,7 @@ public class StatusTab extends SystemTab {
providerGroup.setLayoutData(gd);
gl = new GridLayout(1, true);
gd = new GridData(SWT.FILL, SWT.DEFAULT, false, false);
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
providerComp = new Composite(providerGroup, SWT.NONE);
providerComp.setLayout(gl);
providerComp.setLayoutData(gd);
@ -123,7 +129,7 @@ public class StatusTab extends SystemTab {
// Legend
gl = new GridLayout(8, false);
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
Group legendGrp = new Group(parentComp, SWT.NONE);
Group legendGrp = new Group(this, SWT.NONE);
legendGrp.setText(" Legend ");
legendGrp.setLayout(gl);
legendGrp.setLayoutData(gd);
@ -157,7 +163,7 @@ public class StatusTab extends SystemTab {
}
/**
* Populate this tab.
* Populate this composite.
*/
private void populate() {
try {
@ -249,12 +255,4 @@ public class StatusTab extends SystemTab {
nameLbl.setText(status.getKey().getName());
}
}
/**
* {@inheritDoc}
*/
@Override
public String getTabText() {
return "System Status";
}
}

View file

@ -39,9 +39,11 @@ import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.viz.datadelivery.services.DataDeliveryServices;
import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryGUIUtils;
import com.raytheon.viz.ui.widgets.ApplyCancelComposite;
import com.raytheon.viz.ui.widgets.IApplyCancelAction;
/**
* Subscription overlap configuration.
* Subscription settings composite.
*
* <pre>
*
@ -49,15 +51,19 @@ import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryGUIUtils;
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 14, 2013 2000 djohnson Initial creation
* Aug 07, 2013 2180 mpduff Initial creation.
*
* </pre>
*
* @author djohnson
* @author mpduff
* @version 1.0
*/
public class SubscriptionTab extends SystemApplyCancelTab {
public class SubscriptionComposite extends Composite implements
IApplyCancelAction {
/**
* Overlap Spinners enum.
*/
private static enum OverlapSpinners {
PARAMETERS("Parameters:") {
@Override
@ -133,8 +139,9 @@ public class SubscriptionTab extends SystemApplyCancelTab {
/** Status Handler */
private final IUFStatusHandler statusHandler = UFStatus
.getHandler(SubscriptionTab.class);
.getHandler(SubscriptionComposite.class);
/** Subscription overlap service */
private final ISubscriptionOverlapService overlapService = DataDeliveryServices
.getSubscriptionOverlapService();
@ -142,71 +149,48 @@ public class SubscriptionTab extends SystemApplyCancelTab {
private Combo matchStrategyCombo;
/** Associates the enum spinner configuration to its spinner */
private final EnumMap<OverlapSpinners, Spinner> spinnerMap = new EnumMap<SubscriptionTab.OverlapSpinners, Spinner>(
private final EnumMap<OverlapSpinners, Spinner> spinnerMap = new EnumMap<SubscriptionComposite.OverlapSpinners, Spinner>(
OverlapSpinners.class);
/** The listener that should be used to signify changes were made **/
private final Runnable changesWereMade = new Runnable() {
@Override
public void run() {
buttonComp.enableButtons(true);
}
};
/** Button composite */
private ApplyCancelComposite buttonComp;
/**
* Constructor.
*
* @param parentComp
* The Composite holding these controls
* @param parent
* Parent Composite
* @param style
* Style bits
*/
public SubscriptionTab(Composite parentComp) {
super(parentComp);
public SubscriptionComposite(Composite parent, int style) {
super(parent, style);
init();
}
/**
* {@inheritDoc}
* Initialize class.
*/
@Override
protected void loadConfiguration() {
SubscriptionOverlapConfig config;
try {
config = overlapService.readConfig();
} catch (LocalizationException e) {
statusHandler
.handle(Priority.ERROR,
"Unable to load the subscription overlap rules. "
+ "Defaulting to configuration that will never overlap.",
e);
config = SubscriptionOverlapConfig.NEVER_OVERLAPS;
}
private void init() {
GridLayout gl = new GridLayout(1, true);
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
this.setLayout(gl);
this.setLayoutData(gd);
for (Entry<OverlapSpinners, Spinner> entry : spinnerMap.entrySet()) {
final Spinner spinner = entry.getValue();
final int initialValue = entry.getKey().getValue(config);
DataDeliveryGUIUtils.removeListeners(spinner, SWT.Selection,
SWT.DefaultSelection);
spinner.setSelection(initialValue);
spinner.addSelectionListener(DataDeliveryGUIUtils
.addValueChangedSelectionListener(initialValue, spinner,
changesWereMade));
}
DataDeliveryGUIUtils.removeListeners(matchStrategyCombo, SWT.Selection,
SWT.DefaultSelection);
final int indexOfConfigValue = matchStrategyCombo.indexOf(config
.getMatchStrategy().getDisplayString());
matchStrategyCombo.select(indexOfConfigValue);
matchStrategyCombo.addSelectionListener(DataDeliveryGUIUtils
.addValueChangedSelectionListener(indexOfConfigValue,
matchStrategyCombo, changesWereMade));
}
/**
* {@inheritDoc}
*/
@Override
protected void initializeTabComponents(Composite mainComp) {
GridLayout gl = new GridLayout(1, false);
Composite configurationComposite = new Composite(mainComp, SWT.NONE);
gl = new GridLayout(1, false);
Composite configurationComposite = new Composite(this, SWT.NONE);
configurationComposite.setLayout(gl);
// Label for directions
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, false, false);
gd = new GridData(SWT.FILL, SWT.DEFAULT, false, false);
Label directionsLabel = new Label(configurationComposite, SWT.NONE);
directionsLabel.setLayoutData(gd);
directionsLabel
@ -260,13 +244,60 @@ public class SubscriptionTab extends SystemApplyCancelTab {
.values()) {
matchStrategyCombo.add(matchStrategy.getDisplayString());
}
// Buttons
buttonComp = new ApplyCancelComposite(this, SWT.NONE, this);
loadConfiguration();
}
/**
* {@inheritDoc}
* Load configuration data
*/
@Override
protected boolean saveConfiguration() throws LocalizationException {
private void loadConfiguration() {
SubscriptionOverlapConfig config;
try {
config = overlapService.readConfig();
} catch (LocalizationException e) {
statusHandler
.handle(Priority.ERROR,
"Unable to load the subscription overlap rules. "
+ "Defaulting to configuration that will never overlap.",
e);
config = SubscriptionOverlapConfig.NEVER_OVERLAPS;
}
for (Entry<OverlapSpinners, Spinner> entry : spinnerMap.entrySet()) {
final Spinner spinner = entry.getValue();
final int initialValue = entry.getKey().getValue(config);
DataDeliveryGUIUtils.removeListeners(spinner, SWT.Selection,
SWT.DefaultSelection);
spinner.setSelection(initialValue);
spinner.addSelectionListener(DataDeliveryGUIUtils
.addValueChangedSelectionListener(initialValue, spinner,
changesWereMade));
}
DataDeliveryGUIUtils.removeListeners(matchStrategyCombo, SWT.Selection,
SWT.DefaultSelection);
final int indexOfConfigValue = matchStrategyCombo.indexOf(config
.getMatchStrategy().getDisplayString());
matchStrategyCombo.select(indexOfConfigValue);
matchStrategyCombo.addSelectionListener(DataDeliveryGUIUtils
.addValueChangedSelectionListener(indexOfConfigValue,
matchStrategyCombo, changesWereMade));
}
/**
* Save configuration data
*
* @return true if saved
* @throws LocalizationException
*/
private boolean saveConfiguration() throws LocalizationException {
SubscriptionOverlapConfig config = new SubscriptionOverlapConfig();
for (Entry<OverlapSpinners, Spinner> entry : spinnerMap.entrySet()) {
@ -283,12 +314,25 @@ public class SubscriptionTab extends SystemApplyCancelTab {
}
/**
* Get the tab text.
*
* @return the tab text
* {@inheritDoc}
*/
@Override
public String getTabText() {
return "Subscription Rules";
public boolean apply() {
try {
return saveConfiguration();
} catch (LocalizationException e) {
statusHandler.handle(Priority.ERROR,
"Unable to save configuration changes.", e);
}
return false;
}
/**
* {@inheritDoc}
*/
@Override
public void cancel() {
loadConfiguration();
}
}

View file

@ -1,220 +0,0 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.datadelivery.system;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
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.utils.DataDeliveryUtils;
/**
* Base class for a System Management tab that has an apply/cancel button
* combination.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 17, 2013 2000 djohnson Initial creation
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public abstract class SystemApplyCancelTab extends SystemTab {
/** Status Handler */
private final IUFStatusHandler statusHandler = UFStatus
.getHandler(SubscriptionTab.class);
/** Priority Composite */
private Composite mainComp;
/** Apply changes button. */
protected Button applyButton;
/** Cancel changes button. */
protected Button cancelButton;
/** Button Height. */
private final int buttonHeight = SWT.DEFAULT;
/** Button Width. */
private final int buttonWidth = 70;
/** The listener that should be used to signify changes were made **/
protected final Runnable changesWereMade = new Runnable() {
@Override
public void run() {
enableButtons();
}
};
/**
* Constructor.
*
* @param parentComp
*/
protected SystemApplyCancelTab(Composite parentComp) {
super(parentComp);
}
/**
* Initialize the tab.
*/
@Override
public void init() {
createBaseTab();
createSideButtons();
loadConfiguration();
}
/**
* Create the base tab.
*/
private void createBaseTab() {
GridLayout gl = new GridLayout(2, false);
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
mainComp = new Composite(parentComp, SWT.NONE);
mainComp.setLayout(gl);
mainComp.setLayoutData(gd);
initializeTabComponents(mainComp);
}
/**
* Create the move up/down controls
*/
private void createSideButtons() {
GridData actionData = new GridData(SWT.DEFAULT, SWT.CENTER, false, true);
GridLayout actionLayout = new GridLayout(1, false);
Composite actionComp = new Composite(mainComp, SWT.NONE);
actionComp.setLayout(actionLayout);
actionComp.setLayoutData(actionData);
GridData btnData = new GridData(buttonWidth, buttonHeight);
btnData.horizontalAlignment = SWT.RIGHT;
applyButton = new Button(actionComp, SWT.PUSH);
applyButton.setText("Apply");
applyButton.setLayoutData(btnData);
applyButton.setToolTipText("Apply changes");
applyButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
if (saveConfigurationChanges()) {
disableButtons();
}
}
});
btnData = new GridData(buttonWidth, buttonHeight);
btnData.horizontalAlignment = SWT.RIGHT;
cancelButton = new Button(actionComp, SWT.PUSH);
cancelButton.setText("Cancel");
cancelButton.setLayoutData(btnData);
cancelButton.setToolTipText("Cancel any changes");
cancelButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
loadConfiguration();
disableButtons();
}
});
btnData = new GridData(buttonWidth, buttonHeight);
btnData.horizontalAlignment = SWT.RIGHT;
Button invisibleButtonToAlignWithThreeButtonTabs = new Button(actionComp, SWT.PUSH);
invisibleButtonToAlignWithThreeButtonTabs.setText("");
invisibleButtonToAlignWithThreeButtonTabs.setLayoutData(btnData);
invisibleButtonToAlignWithThreeButtonTabs.setVisible(false);
disableButtons();
}
/**
* Save the configuration changes.
*
* @return true if the configuration changes were saved
*/
private boolean saveConfigurationChanges() {
boolean configurationSaved = false;
try {
configurationSaved = saveConfiguration();
if (configurationSaved) {
DataDeliveryUtils.showChangesWereAppliedMessage(parentComp
.getShell());
}
} catch (Exception e) {
statusHandler.handle(Priority.ERROR,
"Unable to save configuration changes.", e);
}
return configurationSaved;
}
private void enableButtons() {
applyButton.setEnabled(true);
cancelButton.setEnabled(true);
}
private void disableButtons() {
applyButton.setEnabled(false);
cancelButton.setEnabled(false);
}
/**
* Create the main tab components
*
* @param mainComp
* the main tab composite
*/
protected abstract void initializeTabComponents(Composite mainComp);
/**
* Load the configuration.
*/
protected abstract void loadConfiguration();
/**
* Save the user's configuration changes.
*
* @return true if the configuration was actually saved
*
* @throws Exception
* if the configuration cannot be saved
*/
protected abstract boolean saveConfiguration() throws Exception;
}

View file

@ -23,10 +23,8 @@ import java.util.List;
import org.eclipse.swt.widgets.Composite;
import com.raytheon.uf.common.datadelivery.request.DataDeliveryPermission;
/**
* System Management Main Dialog.
* System Latency Rules composite.
*
* <pre>
*
@ -34,40 +32,25 @@ import com.raytheon.uf.common.datadelivery.request.DataDeliveryPermission;
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Sep 17, 2012 730 jpiatt Initial creation.
* Oct 03, 2012 1241 djohnson Use {@link DataDeliveryPermission} and registry handlers.
* Jan 04, 2012 1420 mpduff Add delete rule function.
* Jan 14, 2013 1286 djohnson Rule list is single item selectable.
* May 17, 2013 2000 djohnson Consolidate duplicate code into {@link SystemRulesTab}.
* Aug 07, 2013 2180 mpduff Initial creation.
*
* </pre>
*
* @author jpiatt
* @author mpduff
* @version 1.0
*/
public class SystemLatencyTab extends SystemRulesTab {
/** Rule type constant */
private static final String LATENCY_TYPE = "latency";
public class SystemLatencyComposite extends SystemRulesComposite {
/**
* Constructor.
* Constructor
*
* @param parentComp
* the parent comp
* @param parent
* Parent Composite
* @param style
* Style bits
*/
public SystemLatencyTab(Composite parentComp) {
super(parentComp, LATENCY_TYPE);
}
/**
* Get the tab text.
*
* @return the tab text
*/
@Override
public String getTabText() {
return "Latency Rules";
public SystemLatencyComposite(Composite parent, int style) {
super(parent, style, "latency");
}
/**

View file

@ -19,9 +19,12 @@
**/
package com.raytheon.uf.viz.datadelivery.system;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StackLayout;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
@ -30,8 +33,8 @@ import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Layout;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.viz.core.VizApp;
@ -58,6 +61,7 @@ import com.raytheon.viz.ui.presenter.IDisplay;
* and check whether changes have already been applied when OK is pressed.
* May 17, 2013 2000 djohnson Move bandwidth configuration into its own tab, add subscription overlap rules.
* Jul 16, 2013 1655 mpduff Add system status tab.
* Aug 08, 2013 2180 mpduff Redesigned UI.
*
* </pre>
*
@ -67,26 +71,62 @@ import com.raytheon.viz.ui.presenter.IDisplay;
public class SystemManagementDlg extends CaveSWTDialog implements IDisplay,
IForceApplyPromptDisplayText, IRulesUpdateListener {
/** TabFolder object */
private TabFolder tabFolder;
private enum SystemManagementSettings {
PRIORITY_RULES("Priority Rules"), LATENCY_RULES("Latency Rules"), SUBSCRIPTION_RULES(
"Subscription Rules"), BANDWIDTH("Bandwidth"), DATA_PROVIDER_PASSWORD(
"Data Provider Password"), REGISTRY_PROVIDER_STATUS(
"Registry/Provider Status");
/** OK button */
private final String name;
private SystemManagementSettings(String name) {
this.name = name;
}
public String getName() {
return name;
}
}
/**
* The Stack Layout.
*/
private final StackLayout stackLayout = new StackLayout();
/**
* Tree Composite
*/
private Composite treeComp;
/** Tree */
private Tree tree;
/** Priority rules composite */
private SystemPriorityComposite systemPriorityComp;
/** System status composite */
private StatusComposite systemStatusComp;
/** Latency rules composite */
private SystemLatencyComposite systemLatencyComp;
/** Bandwith settings composite */
private BandwidthComposite bandwidthComp;
/** Composite map */
private final Map<String, Composite> compMap = new HashMap<String, Composite>();
/** Close button */
private Button closeBtn;
/** The system latency tab */
private SystemLatencyTab lTab;
/** Stack Composite */
private Composite stackComp;
/** The system priority tab */
private SystemPriorityTab pTab;
/** Data Provider username password composite */
private DataProviderPasswordComposite passwdComp;
/** The subscription tab */
private SubscriptionTab sTab;
/** The bandwidth tab */
private BandwidthTab bTab;
/** The status tab */
private StatusTab statusTab;
/** Subscription rules composite */
private SubscriptionComposite subComp;
/**
* Constructor.
@ -98,7 +138,6 @@ public class SystemManagementDlg extends CaveSWTDialog implements IDisplay,
super(parent, SWT.DIALOG_TRIM, CAVE.NONE);
setText("Data Delivery System Management");
SystemRuleManager.getInstance().registerAsListener(this);
}
/*
@ -108,12 +147,18 @@ public class SystemManagementDlg extends CaveSWTDialog implements IDisplay,
*/
@Override
protected Layout constructShellLayout() {
// Create the main layout for the shell.
GridLayout mainLayout = new GridLayout(1, false);
mainLayout.marginHeight = 3;
mainLayout.marginWidth = 3;
return new GridLayout(1, false);
}
return mainLayout;
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#constructShellLayoutData()
*/
@Override
protected Object constructShellLayoutData() {
return new GridData(SWT.FILL, SWT.FILL, true, true);
}
/*
@ -125,12 +170,158 @@ public class SystemManagementDlg extends CaveSWTDialog implements IDisplay,
*/
@Override
protected void initializeComponents(Shell shell) {
GridLayout gl = new GridLayout(2, false);
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
Composite comp = new Composite(shell, SWT.NONE);
comp.setLayout(gl);
comp.setLayoutData(gd);
createTabFolder();
createSystemTabs(tabFolder);
gl = new GridLayout(1, false);
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
gd.minimumWidth = 220;
treeComp = new Composite(comp, SWT.BORDER);
treeComp.setLayout(gl);
treeComp.setLayoutData(gd);
gl = new GridLayout(1, false);
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
tree = new Tree(treeComp, SWT.BORDER);
tree.setLayout(gl);
tree.setLayoutData(gd);
populateTree();
gl = new GridLayout(1, false);
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
Composite c = new Composite(comp, SWT.BORDER);
c.setLayout(gl);
c.setLayoutData(gd);
stackComp = new Composite(c, SWT.NONE);
stackComp.setLayout(stackLayout);
createComposites();
createBottomButtons();
}
/**
* Populate the tree.
*/
private void populateTree() {
tree.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
handleSelection(event);
}
});
final TreeItem ruleNode = new TreeItem(tree, 0);
ruleNode.setText("Rules");
TreeItem priorityRule = new TreeItem(ruleNode, 0);
priorityRule.setText(SystemManagementSettings.PRIORITY_RULES.getName());
TreeItem latencyRule = new TreeItem(ruleNode, 1);
latencyRule.setText(SystemManagementSettings.LATENCY_RULES.getName());
TreeItem subscriptionRule = new TreeItem(ruleNode, 2);
subscriptionRule.setText(SystemManagementSettings.SUBSCRIPTION_RULES
.getName());
TreeItem settingsNode = new TreeItem(tree, 1);
settingsNode.setText("Settings");
TreeItem bandwidthSetting = new TreeItem(settingsNode, 0);
bandwidthSetting.setText(SystemManagementSettings.BANDWIDTH.getName());
TreeItem providerPassword = new TreeItem(settingsNode, 1);
providerPassword
.setText(SystemManagementSettings.DATA_PROVIDER_PASSWORD
.getName());
TreeItem statusNode = new TreeItem(tree, 2);
statusNode.setText("Status");
TreeItem registryProviderStatus = new TreeItem(statusNode, 0);
registryProviderStatus
.setText(SystemManagementSettings.REGISTRY_PROVIDER_STATUS
.getName());
}
/**
* Handle tree selection
*
* @param event
* The selection event
*/
private void handleSelection(SelectionEvent event) {
TreeItem item = (TreeItem) event.item;
for (String key : compMap.keySet()) {
if (item.getText().equals(key)) {
stackLayout.topControl = compMap.get(key);
stackComp.layout();
return;
}
}
item.setExpanded(!item.getExpanded());
}
/**
* Create the composites that make up the stack
*/
private void createComposites() {
GridLayout gl = new GridLayout(1, false);
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
systemStatusComp = new StatusComposite(stackComp, SWT.BORDER);
systemStatusComp.setLayout(gl);
systemStatusComp.setLayoutData(gd);
compMap.put(
SystemManagementSettings.REGISTRY_PROVIDER_STATUS.getName(),
systemStatusComp);
gl = new GridLayout(1, false);
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
bandwidthComp = new BandwidthComposite(stackComp, SWT.BORDER);
bandwidthComp.setLayout(gl);
bandwidthComp.setLayoutData(gd);
compMap.put(SystemManagementSettings.BANDWIDTH.getName(), bandwidthComp);
gl = new GridLayout(1, false);
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
systemLatencyComp = new SystemLatencyComposite(stackComp, SWT.BORDER);
systemLatencyComp.setLayout(gl);
systemLatencyComp.setLayoutData(gd);
compMap.put(SystemManagementSettings.LATENCY_RULES.getName(),
systemLatencyComp);
gl = new GridLayout(1, false);
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
systemPriorityComp = new SystemPriorityComposite(stackComp, SWT.BORDER);
systemPriorityComp.setLayout(gl);
systemPriorityComp.setLayoutData(gd);
compMap.put(SystemManagementSettings.PRIORITY_RULES.getName(),
systemPriorityComp);
gl = new GridLayout(1, false);
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
passwdComp = new DataProviderPasswordComposite(stackComp, SWT.BORDER);
passwdComp.setLayout(gl);
passwdComp.setLayoutData(gd);
compMap.put(SystemManagementSettings.DATA_PROVIDER_PASSWORD.getName(),
passwdComp);
gl = new GridLayout(1, false);
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
subComp = new SubscriptionComposite(stackComp, SWT.BORDER);
subComp.setLayout(gl);
subComp.setLayoutData(gd);
compMap.put(SystemManagementSettings.SUBSCRIPTION_RULES.getName(),
subComp);
TreeItem ti = tree.getItem(0);
tree.select(ti);
}
/*
@ -144,79 +335,12 @@ public class SystemManagementDlg extends CaveSWTDialog implements IDisplay,
SystemRuleManager.getInstance().deregisterAsListener(this);
}
/**
* Create tabs.
*/
private void createSystemTabs(TabFolder tabFolder) {
// Priority Tab
pTab = new SystemPriorityTab(getTabComposite(tabFolder));
createTabItem(tabFolder, pTab);
pTab.init();
// Latency Tab
lTab = new SystemLatencyTab(getTabComposite(tabFolder));
createTabItem(tabFolder, lTab);
lTab.init();
// Subscription Tab
sTab = new SubscriptionTab(getTabComposite(tabFolder));
createTabItem(tabFolder, sTab);
sTab.init();
// Bandwidth Tab
bTab = new BandwidthTab(getTabComposite(tabFolder));
createTabItem(tabFolder, bTab);
bTab.init();
statusTab = new StatusTab(getTabComposite(tabFolder));
createTabItem(tabFolder, statusTab);
statusTab.init();
lTab.loadList();
pTab.loadList();
}
/**
* Create the tab composite.
*
* @param tabFolder
* the
* @return
*/
private Composite getTabComposite(TabFolder tabFolder) {
GridData gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false);
GridLayout gl = new GridLayout(1, false);
Composite composite = new Composite(tabFolder, SWT.NONE);
composite.setLayout(gl);
composite.setLayoutData(gd);
return composite;
}
/**
* Create a {@link TabItem} for the given tab.
*
* @param tabFolder
* the tab folder
* @param tab
* the tab
* @return the tab item
*/
private TabItem createTabItem(TabFolder tabFolder, SystemTab tab) {
TabItem tabItem = new TabItem(tabFolder, SWT.NONE);
tabItem.setControl(tab.getParentComp());
tabItem.setText(tab.getTabText());
return tabItem;
}
/**
* Create the bottom buttons.
*/
private void createBottomButtons() {
GridData gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false);
GridLayout gl = new GridLayout(3, false);
GridLayout gl = new GridLayout(1, false);
Composite bottomComp = new Composite(shell, SWT.NONE);
bottomComp.setLayout(gl);
@ -234,19 +358,6 @@ public class SystemManagementDlg extends CaveSWTDialog implements IDisplay,
close();
}
});
}
/**
* Create tab folder.
*/
private void createTabFolder() {
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
tabFolder = new TabFolder(shell, SWT.NONE);
tabFolder.setLayoutData(gd);
tabFolder.pack();
}
/**
@ -293,8 +404,8 @@ public class SystemManagementDlg extends CaveSWTDialog implements IDisplay,
@Override
public void run() {
if (!shell.isDisposed()) {
lTab.loadList();
pTab.loadList();
systemLatencyComp.loadList();
systemPriorityComp.loadList();
}
}
});

View file

@ -23,10 +23,8 @@ import java.util.List;
import org.eclipse.swt.widgets.Composite;
import com.raytheon.uf.common.datadelivery.request.DataDeliveryPermission;
/**
* System Management Priority tab.
* Priority Rules composite.
*
* <pre>
*
@ -34,39 +32,26 @@ import com.raytheon.uf.common.datadelivery.request.DataDeliveryPermission;
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Sep 17, 2012 730 jpiatt Initial creation.
* Oct 03, 2012 1241 djohnson Use {@link DataDeliveryPermission} and registry handlers.
* Jan 04, 2013 1420 mpduff Add delete function.
* May 17, 2013 2000 djohnson Consolidate duplicate code into {@link SystemRulesTab}.
* Aug 07, 2013 2180 mpduff Initial creation
*
* </pre>
*
* @author jpiatt
* @author mpduff
* @version 1.0
*/
public class SystemPriorityTab extends SystemRulesTab {
/** Rule type constant */
private static final String PRIORITY_TYPE = "priority";
public class SystemPriorityComposite extends SystemRulesComposite {
/**
* Constructor.
*
* @param parentComp
* @param parent
* Parent composite
* @param style
* style bits
*/
public SystemPriorityTab(Composite parentComp) {
super(parentComp, PRIORITY_TYPE);
}
/**
* Get the tab text.
*
* @return the tab text
*/
@Override
public String getTabText() {
return "Priority Rules";
public SystemPriorityComposite(Composite parent, int style) {
super(parent, style, "priority");
}
/**

View file

@ -26,7 +26,6 @@ import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.List;
@ -41,7 +40,7 @@ import com.raytheon.uf.viz.datadelivery.services.DataDeliveryServices;
import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryUtils;
/**
* Abstract System Management Rules Dialog.
* System Rules Composite base class
*
* <pre>
*
@ -49,189 +48,197 @@ import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryUtils;
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 17, 2013 2000 djohnson Consolidate duplicate code from latency and priority versions.
* Jul 26, 2031 2232 mpduff Refactored Data Delivery permissions.
* Aug 07, 2013 2180 mpduff Initial creation
*
* </pre>
*
* @author jpiatt
* @author mpduff
* @version 1.0
*/
public abstract class SystemRulesTab extends SystemTab {
public abstract class SystemRulesComposite extends Composite implements
INewEditDeleteAction {
/** Status Handler */
private final IUFStatusHandler statusHandler = UFStatus
.getHandler(SystemRulesTab.class);
.getHandler(SystemRulesComposite.class);
/** Not authorized message */
private final String notAuthorizedMsg = " is not authorized to create, edit, or delete rules using the Data Delivery System Management\nPermission: ";
/** Priority Composite */
/** Rule type */
private final String ruleType;
/** List composite */
private Composite listComp;
/** Rules list */
private List rulesList;
/** Create/edit rule flag */
private boolean create;
/** Button composite */
private NewEditDeleteComposite buttonComp;
/** Create and edit rule dialog */
private CreateEditRuleDlg ruleDlg;
/** Available List widget */
private List rulesList;
/** Flag for create and edit. */
private boolean create;
/** Edit rule button. */
private Button editBtn;
/** New rule button. */
private Button newBtn;
/** Delete rule button. */
private Button deleteBtn;
/** Button Height. */
private final int buttonHeight = SWT.DEFAULT;
/** Button Width. */
private final int buttonWidth = 70;
private final String ruleType;
/**
* Constructor.
*
* @param parentComp
* The Composite holding these controls
* @param parent
* Parent composite
* @param style
* Style bits
* @param ruleType
* The rule type
*/
public SystemRulesTab(Composite parentComp, String ruleType) {
super(parentComp);
public SystemRulesComposite(Composite parent, int style, String ruleType) {
super(parent, style);
this.ruleType = ruleType;
init();
}
/**
* Initialize the tab.
* Initialize
*/
@Override
public void init() {
createRulesTab();
createSideButtons();
}
/**
* Create the bar that may be expanded depending on item count.
*/
private void createRulesTab() {
private void init() {
GridLayout gl = new GridLayout(1, true);
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
GridLayout gl = new GridLayout(2, false);
this.setLayout(gl);
this.setLayoutData(gd);
listComp = new Composite(parentComp, SWT.NONE);
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
gl = new GridLayout(1, false);
listComp = new Composite(this, SWT.NONE);
listComp.setLayout(gl);
listComp.setLayoutData(gd);
gd = new GridData(SWT.DEFAULT, SWT.CENTER, true, true);
gd.widthHint = 375;
gd.heightHint = 200;
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
rulesList = new List(listComp, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL
| SWT.H_SCROLL | SWT.SINGLE);
rulesList.setLayoutData(gd);
rulesList.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
enableButtons(rulesList.getSelectionCount() > 0);
buttonComp.enableButtons(rulesList.getSelectionCount() > 0);
}
});
// Buttons
buttonComp = new NewEditDeleteComposite(this, SWT.NONE, this);
loadList();
}
/**
* Create the move up/down controls
* Load the rule list.
*/
private void createSideButtons() {
GridData actionData = new GridData(SWT.RIGHT, SWT.CENTER, true, true);
GridLayout actionLayout = new GridLayout(1, false);
Composite actionComp = new Composite(listComp, SWT.NONE);
actionComp.setLayout(actionLayout);
actionComp.setLayoutData(actionData);
public void loadList() {
rulesList.removeAll();
final int horizAlign = SWT.LEFT;
final int verticalAlign = SWT.DEFAULT;
boolean horizExcess = true;
boolean verticalExcess = false;
// Get the list of latency rule names
java.util.List<String> rules = getRuleNames();
GridData btnData = new GridData(horizAlign, verticalAlign, horizExcess,
verticalExcess);
btnData.widthHint = buttonWidth;
btnData.heightHint = buttonHeight;
Collections.sort(rules, String.CASE_INSENSITIVE_ORDER);
rulesList.setItems(rules.toArray(new String[rules.size()]));
}
newBtn = new Button(actionComp, SWT.PUSH);
newBtn.setText("New...");
newBtn.setLayoutData(btnData);
newBtn.setEnabled(true);
newBtn.setToolTipText("Create a new rule");
newBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
create = true;
handleRule();
if (rulesList.getItemCount() > 0) {
rulesList.select(0);
enableButtons(true);
} else {
enableButtons(false);
}
}
});
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.datadelivery.system.INewEditDeleteAction#newAction()
*/
@Override
public boolean newAction() {
create = true;
handleRule();
loadList();
if (rulesList.getItemCount() > 0) {
rulesList.select(0);
buttonComp.enableButtons(true);
return true;
}
btnData = new GridData(horizAlign, verticalAlign, horizExcess,
verticalExcess);
btnData.widthHint = buttonWidth;
btnData.heightHint = buttonHeight;
editBtn = new Button(actionComp, SWT.PUSH);
editBtn.setText("Edit...");
editBtn.setLayoutData(btnData);
editBtn.setEnabled(false);
editBtn.setToolTipText("Edit item selected in the list");
editBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
create = false;
int idx = rulesList.getSelectionIndex();
handleRule();
if (!rulesList.isDisposed()) {
rulesList.select(idx);
}
}
});
buttonComp.enableButtons(false);
return false;
}
btnData = new GridData(horizAlign, verticalAlign, horizExcess,
verticalExcess);
btnData.widthHint = buttonWidth;
btnData.heightHint = buttonHeight;
deleteBtn = new Button(actionComp, SWT.PUSH);
deleteBtn.setText("Delete");
deleteBtn.setLayoutData(btnData);
deleteBtn.setEnabled(false);
deleteBtn.setToolTipText("Delete item selected in the list");
deleteBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
handleDeleteRule();
if (rulesList.getItemCount() > 0) {
rulesList.select(0);
}
}
});
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.datadelivery.system.INewEditDeleteAction#editAction
* ()deleteAction
*/
@Override
public boolean editAction() {
create = false;
int idx = rulesList.getSelectionIndex();
handleRule();
if (!rulesList.isDisposed()) {
rulesList.select(idx);
}
return false;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.datadelivery.system.INewEditDeleteAction#deleteAction
* ()
*/
@Override
public boolean deleteAction() {
handleDeleteRule();
if (rulesList.getItemCount() > 0) {
rulesList.select(0);
}
return false;
}
/**
* Enable the buttons?
*
* @param enable
* setting for the buttons
* Delete rule action handler
*/
private void enableButtons(boolean enable) {
deleteBtn.setEnabled(enable);
editBtn.setEnabled(enable);
private void handleDeleteRule() {
final String permission = DataDeliveryPermission.SYSTEM_MANAGEMENT_CREATE
.toString();
IUser user = UserController.getUserObject();
String msg = user.uniqueId() + notAuthorizedMsg + permission;
try {
if (DataDeliveryServices.getPermissionsService()
.checkPermission(user, msg, permission).isAuthorized()) {
String ruleName = null;
int selectedIdx = rulesList.getSelectionIndex();
if (selectedIdx > -1) {
int answer = DataDeliveryUtils.showYesNoMessage(getShell(),
"Delete?",
"Are you sure you want to delete this rule?");
if (answer == SWT.YES) {
ruleName = rulesList.getItem(selectedIdx);
deleteRule(ruleName);
loadList();
if (rulesList.getItemCount() == 0) {
buttonComp.enableButtons(false);
}
}
} else {
DataDeliveryUtils.showMessage(getShell(), SWT.ERROR,
"Select Rule", "Please select a rule for delete.");
return;
}
}
} catch (AuthException e) {
statusHandler.handle(Priority.PROBLEM,
"Error occurred in authorization request", e);
}
}
/**
@ -251,8 +258,8 @@ public abstract class SystemRulesTab extends SystemTab {
// New
if (create) {
ruleDlg = new CreateEditRuleDlg(parentComp.getShell(),
create, ruleType);
ruleDlg = new CreateEditRuleDlg(getShell(), create,
ruleType);
} else {
// Edit
String ruleName = null;
@ -260,19 +267,18 @@ public abstract class SystemRulesTab extends SystemTab {
if (selectedIdx > -1) {
ruleName = rulesList.getItem(selectedIdx);
} else if (rulesList.getItemCount() <= 0) {
DataDeliveryUtils.showMessage(
parentComp.getShell(), SWT.ERROR,
"Create Rule", "Please create a rule.");
DataDeliveryUtils.showMessage(getShell(),
SWT.ERROR, "Create Rule",
"Please create a rule.");
return;
} else {
DataDeliveryUtils.showMessage(
parentComp.getShell(), SWT.ERROR,
"Select Rule",
DataDeliveryUtils.showMessage(getShell(),
SWT.ERROR, "Select Rule",
"Please select a rule to edit.");
return;
}
ruleDlg = new CreateEditRuleDlg(parentComp.getShell(),
create, ruleName, ruleType);
ruleDlg = new CreateEditRuleDlg(getShell(), create,
ruleName, ruleType);
}
ruleDlg.open();
} else {
@ -286,60 +292,6 @@ public abstract class SystemRulesTab extends SystemTab {
}
}
/**
* Delete rule action handler.
*/
private void handleDeleteRule() {
final String permission = DataDeliveryPermission.SYSTEM_MANAGEMENT_CREATE
.toString();
IUser user = UserController.getUserObject();
String msg = user.uniqueId() + notAuthorizedMsg + permission;
try {
if (DataDeliveryServices.getPermissionsService()
.checkPermission(user, msg, permission).isAuthorized()) {
String ruleName = null;
int selectedIdx = rulesList.getSelectionIndex();
if (selectedIdx > -1) {
int answer = DataDeliveryUtils.showYesNoMessage(
parentComp.getShell(), "Delete?",
"Are you sure you want to delete this rule?");
if (answer == SWT.YES) {
ruleName = rulesList.getItem(selectedIdx);
deleteRule(ruleName);
loadList();
if (rulesList.getItemCount() == 0) {
enableButtons(false);
}
}
} else {
DataDeliveryUtils.showMessage(parentComp.getShell(),
SWT.ERROR, "Select Rule",
"Please select a rule for delete.");
return;
}
}
} catch (AuthException e) {
statusHandler.handle(Priority.PROBLEM,
"Error occurred in authorization request", e);
}
}
/**
* Load the rule list.
*/
public void loadList() {
rulesList.removeAll();
// Get the list of latency rule names
java.util.List<String> rules = null;
rules = getRuleNames();
Collections.sort(rules, String.CASE_INSENSITIVE_ORDER);
rulesList.setItems(rules.toArray(new String[rules.size()]));
}
/**
* Get the rule names.
*
@ -354,4 +306,4 @@ public abstract class SystemRulesTab extends SystemTab {
* the rule name
*/
protected abstract void deleteRule(String ruleName);
}
}

View file

@ -0,0 +1,132 @@
/**
* 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.viz.ui.widgets;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
/**
* Composite holding the apply and cancel buttons.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Aug 7, 2013 2180 mpduff Initial creation.
*
* </pre>
*
* @author mpduff
* @version 1.0
*/
public class ApplyCancelComposite extends Composite implements IEnableAction {
/** Button Width. */
private final int buttonWidth = 70;
/** Apply button */
private Button applyButton;
/** Cancel button */
private Button cancelButton;
/** Action callback */
private final IApplyCancelAction callback;
/**
* Constructor.
*
* @param parent
* Parent Composite
* @param style
* Style bits
* @param callback
* Callback action
*/
public ApplyCancelComposite(Composite parent, int style,
IApplyCancelAction callback) {
super(parent, style);
this.callback = callback;
init();
}
/**
* Initialize the class
*/
private void init() {
GridLayout gl = new GridLayout(1, false);
GridData gd = new GridData(SWT.RIGHT, SWT.FILL, true, true);
this.setLayout(gl);
this.setLayoutData(gd);
GridData actionData = new GridData(SWT.DEFAULT, SWT.BOTTOM, false, true);
GridLayout actionLayout = new GridLayout(2, false);
Composite actionComp = new Composite(this, SWT.NONE);
actionComp.setLayout(actionLayout);
actionComp.setLayoutData(actionData);
GridData btnData = new GridData(buttonWidth, SWT.DEFAULT);
btnData.horizontalAlignment = SWT.RIGHT;
applyButton = new Button(actionComp, SWT.PUSH);
applyButton.setText("Apply");
applyButton.setLayoutData(btnData);
applyButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
if (callback.apply()) {
enableButtons(false);
}
}
});
btnData = new GridData(buttonWidth, SWT.DEFAULT);
btnData.horizontalAlignment = SWT.RIGHT;
cancelButton = new Button(actionComp, SWT.PUSH);
cancelButton.setText("Cancel");
cancelButton.setLayoutData(btnData);
cancelButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
callback.cancel();
enableButtons(false);
}
});
enableButtons(false);
}
/**
* {@inheritDoc}
*/
@Override
public void enableButtons(boolean enabled) {
applyButton.setEnabled(enabled);
cancelButton.setEnabled(enabled);
}
}

View file

@ -0,0 +1,51 @@
/**
* 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.viz.ui.widgets;
/**
* Apply and Cancel button composite action interface.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Aug 7, 2013 2180 mpduff Initial creation
*
* </pre>
*
* @author mpduff
* @version 1.0
*/
public interface IApplyCancelAction {
/**
* Apply action.
*
* @return true if successfully applied
*/
boolean apply();
/**
* Cancel action.
*/
void cancel();
}

View file

@ -0,0 +1,47 @@
/**
* 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.viz.ui.widgets;
/**
* Enable button action interface.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Aug 7, 2013 2180 mpduff Initial creation.
*
* </pre>
*
* @author mpduff
* @version 1.0
*/
public interface IEnableAction {
/**
* Enable the buttons.
*
* @param enabled
* true to enable the buttons
*/
void enableButtons(boolean enabled);
}

View file

@ -26,3 +26,4 @@ com.raytheon.uf.common.datadelivery.registry.Provider
com.raytheon.uf.common.datadelivery.registry.Time
com.raytheon.uf.common.datadelivery.registry.PointTime
com.raytheon.uf.common.datadelivery.registry.GriddedTime
com.raytheon.uf.common.datadelivery.registry.ProviderKeyRequest

View file

@ -46,7 +46,7 @@ import com.raytheon.uf.common.status.UFStatus;
* Jul 24, 2012 955 djohnson Add copy constructor.
* Jun 11, 2013 1763 dhladky Added Encryption type
* Jun 17, 2013 2106 djohnson Check for encryption to not be null, getPassword() must be left alone for dynamic serialize.
*
* Aug 08, 2013 2108 mpduff Serialize the provider key.
* </pre>
*
* @author dhladky
@ -58,7 +58,7 @@ import com.raytheon.uf.common.status.UFStatus;
public class Connection implements ISerializableObject, Serializable {
private static final long serialVersionUID = 8223819912383198409L;
private static final IUFStatusHandler statusHandler = UFStatus
.getHandler(Connection.class);
@ -87,8 +87,9 @@ public class Connection implements ISerializableObject, Serializable {
@DynamicSerializeElement
private String password;
@DynamicSerializeElement
private String providerKey;
@XmlElement(name = "encryption")
@DynamicSerializeElement
private Encryption encryption;
@ -118,34 +119,31 @@ public class Connection implements ISerializableObject, Serializable {
}
/**
* You pass in the providerKey to the local DD client
* The reason for this is you don't want the key and
* password ever stored in the same place. providerKey is kept
* in the registry at the WFO & NCF. The password is stored
* encrypted in a connection object file stored in localization.
* You can only decrypt when they come together in code here.
*
* You pass in the providerKey to the local DD client The reason for this is
* you don't want the key and password ever stored in the same place.
* providerKey is kept in the metadata database at the WFO. The password is
* stored encrypted in a connection object file stored in localization. You
*
* @param providerKey
* @return
*/
public String getUnencryptedPassword() {
if (password != null && providerKey != null) {
try {
return encryption.decrypt(providerKey, password);
} catch (Exception e) {
statusHandler.error("Unable to decrypt password!"+e);
statusHandler.error("Unable to decrypt password!", e);
}
}
return null;
}
/**
* encrypt password with providerKey
*
*
*
* @param providerKey
* @return
@ -160,40 +158,39 @@ public class Connection implements ISerializableObject, Serializable {
encryptPassword = encryption.encrypt(providerKey, password);
setPassword(encryptPassword);
} catch (Exception e) {
statusHandler.error("Unable to crypt password!" + e);
statusHandler.error("Unable to crypt password!", e);
}
}
}
/**
* You pass in the providerKey to the local DD client
* The reason for this is you don't want the key and
* password ever stored in the same place. providerKey is kept
* in the registry at the WFO & NCF. The password is stored
* encrypted in a connection object file stored in localization.
* You can only decrypt when they come together in code here.
* You pass in the providerKey to the local DD client The reason for this is
* you don't want the key and password ever stored in the same place.
* providerKey is kept in the metadata database at the WFO. The password is
* stored encrypted in a connection object file stored in localization. You
* can only decrypt when they come together in code here.
*
*
* @param providerKey
* @return
*/
public String getUnencryptedUsername() {
if (userName != null && providerKey != null) {
try {
return encryption.decrypt(providerKey, userName);
} catch (Exception e) {
statusHandler.error("Unable to decrypt userName!"+e);
statusHandler.error("Unable to decrypt userName!", e);
}
}
return null;
}
/**
* encrypt userName with providerKey
*
*
*
* @param providerKey
* @return
@ -208,7 +205,7 @@ public class Connection implements ISerializableObject, Serializable {
encryptUserName = encryption.encrypt(providerKey, userName);
setUserName(encryptUserName);
} catch (Exception e) {
statusHandler.error("Unable to crypt userName!" + e);
statusHandler.error("Unable to crypt userName!", e);
}
}
}
@ -216,7 +213,7 @@ public class Connection implements ISerializableObject, Serializable {
public void setUserName(String userName) {
this.userName = userName;
}
public Encryption getEncryption() {
return encryption;
}

View file

@ -1,4 +1,5 @@
package com.raytheon.uf.common.datadelivery.registry;
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
@ -18,8 +19,14 @@ package com.raytheon.uf.common.datadelivery.registry;
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlEnumValue;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
import com.raytheon.uf.common.serialization.comm.IServerRequest;
/**
* A request providerKey.
*
@ -29,30 +36,33 @@ import com.raytheon.uf.common.serialization.comm.IServerRequest;
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* July 14, 2013 2184 dhladky Initial creation
*
* Jul 14, 2013 2184 dhladky Initial creation.
* Aug 08, 2013 2180 mpduff Made serializable.
* @author dhladky
* @version 1.0
*/
@XmlAccessorType(XmlAccessType.NONE)
@DynamicSerialize
public class ProviderKeyRequest implements IServerRequest {
@DynamicSerializeElement
private Provider provider;
@DynamicSerializeElement
private String providerKey;
@DynamicSerializeElement
private RequestType requestType;
@DynamicSerializeElement
private Status status;
public ProviderKeyRequest() {
}
public ProviderKeyRequest(String providerKey, Provider provider, RequestType requestType) {
public ProviderKeyRequest(String providerKey, Provider provider,
RequestType requestType) {
this.providerKey = providerKey;
this.provider = provider;
this.requestType = requestType;
@ -73,15 +83,15 @@ public class ProviderKeyRequest implements IServerRequest {
public void setProviderKey(String providerKey) {
this.providerKey = providerKey;
}
public RequestType getRequestType() {
return requestType;
}
public void setRequestType(RequestType requestType) {
this.requestType = requestType;
}
/**
* Request Type
*
@ -99,22 +109,27 @@ public class ProviderKeyRequest implements IServerRequest {
* @version 1.0
*/
public enum RequestType {
@XmlEnumValue(RequestType.save)
SAVE("SAVE"), @XmlEnumValue(RequestType.retrieve)
RETRIEVE("RETRIEVE");
private static final String save = "SAVE";
private static final String retrieve = "RETRIEVE";
SAVE("SAVE"), RETRIEVE("RETRIEVE");
private final String requestType;
private RequestType(String name) {
requestType = name;
}
@Override
public String toString() {
return requestType;
}
}
/**
* Transaction Status
*
@ -132,15 +147,20 @@ public class ProviderKeyRequest implements IServerRequest {
* @version 1.0
*/
public enum Status {
@XmlEnumValue(Status.success)
SUCCESS("SUCCESS"), @XmlEnumValue(Status.fail)
FAILURE("FAILURE");
private static final String success = "SUCCESS";
private static final String fail = "FAILURE";
SUCCESS("SUCCESS"), FAILURE("FAILURE");
private final String status;
private Status(String name) {
status = name;
}
@Override
public String toString() {
return status;

View file

@ -40,7 +40,8 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jul 13, 2012 2180 dhladky Provider Key storage
* Jul 13, 2012 2180 dhladky Provider Key storage
* Aug 08, 2013 2180 mpduff Added default constructor for serialization
*
* </pre>
*
@ -62,12 +63,16 @@ public class ProviderKeyRecord implements IPersistableDataObject<String>,
@Column(nullable = false)
@DynamicSerializeElement
private String providerKey;
public ProviderKeyRecord() {
}
public ProviderKeyRecord(String providerName, String providerKey) {
this.providerName = providerName;
this.providerKey = providerKey;
}
public String getProviderKey() {
return providerKey;
}

View file

@ -16,6 +16,7 @@ import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.edex.datadelivery.retrieval.db.ProviderKeyDao;
import com.raytheon.uf.edex.datadelivery.retrieval.db.ProviderKeyRecord;
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
@ -47,6 +48,7 @@ import com.raytheon.uf.edex.datadelivery.retrieval.db.ProviderKeyRecord;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jul 10, 2013 2180 dhladky Initial
* Aug 08, 2013 2180 mpduff Corrected the filename and blanked the key before saving
*
* </pre>
*
@ -55,18 +57,20 @@ import com.raytheon.uf.edex.datadelivery.retrieval.db.ProviderKeyRecord;
*/
public class ProviderCredentialsUtil {
private static final IUFStatusHandler statusHandler = UFStatus
.getHandler(ProviderCredentialsUtil.class);
private static final String CONNECTION_FILE_PREFIX = "datadelivery"
+ IPathManager.SEPARATOR + "connection" + IPathManager.SEPARATOR;
private static final String CONNECTION_FILE_SUFFIX = "-connection.xml";
/**
* Saves the connection for the provider encrypted to Localization by providerKey
* This will be used by the SSMI to update userName and password stores
* Saves the connection for the provider encrypted to Localization by
* providerKey This will be used by the SSMI to update userName and password
* stores
*
* @param providerKey
* @param conn
*/
@ -87,7 +91,8 @@ public class ProviderCredentialsUtil {
}
try {
ProviderKeyRecord pkr = new ProviderKeyRecord(provider.getName(), providerKey);
ProviderKeyRecord pkr = new ProviderKeyRecord(provider.getName(),
providerKey);
ProviderKeyDao pkd = new ProviderKeyDao();
pkd.addOrUpdateRecord(pkr);
} catch (Exception e) {
@ -98,7 +103,7 @@ public class ProviderCredentialsUtil {
if (conn != null && providerKey != null) {
try {
storeConnection(conn, providerKey);
storeConnection(conn, provider.getName());
} catch (Exception e) {
statusHandler
.handle(Priority.ERROR,
@ -107,10 +112,10 @@ public class ProviderCredentialsUtil {
return false;
}
}
return true;
}
/**
* Gets the encrypted credentials connection object stored locally
*
@ -142,7 +147,8 @@ public class ProviderCredentialsUtil {
* @param providerName
* @return
*/
private static Connection getConnection(String providerName) throws Exception {
private static Connection getConnection(String providerName)
throws Exception {
IPathManager pm = PathManagerFactory.getPathManager();
LocalizationContext lc = pm.getContext(LocalizationType.COMMON_STATIC,
@ -189,6 +195,11 @@ public class ProviderCredentialsUtil {
LocalizationFile lf = pm.getLocalizationFile(lc, connectionFileName);
File file = lf.getFile();
/*
* Nulling the providerKey for security reasons. You never want the
* providerKey and encrypted username and password stored together
*/
conn.setProviderKey(null);
SerializationUtil.jaxbMarshalToXmlFile(conn, file.getAbsolutePath());
}