diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/comm/CaveHttpsCredentialsHandler.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/comm/CaveHttpsCredentialsHandler.java index 2036322469..bd3d0e4c1c 100644 --- a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/comm/CaveHttpsCredentialsHandler.java +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/comm/CaveHttpsCredentialsHandler.java @@ -19,6 +19,10 @@ **/ package com.raytheon.uf.viz.core.comm; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; + import com.raytheon.uf.common.comm.IHttpsCredentialsHandler; import com.raytheon.uf.viz.core.auth.UserController; @@ -34,6 +38,7 @@ import com.raytheon.uf.viz.core.auth.UserController; * ------------ ---------- ----------- -------------------------- * Mar 04, 2013 1786 mpduff Initial creation. * Jun 07, 2013 1981 mpduff Save user's username in UserController. + * Feb 10, 2014 2704 njensen Added credentialsFailed() * * * @@ -59,4 +64,11 @@ public class CaveHttpsCredentialsHandler implements IHttpsCredentialsHandler { UserController.updateUserData(credentials[0]); return credentials; } + + @Override + public void credentialsFailed() { + MessageDialog.openError(new Shell(Display.getDefault()), + "Login failed", + "Invalid username and/or password. Please try again."); + } } diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/comm/ConnectivityManager.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/comm/ConnectivityManager.java index cca57dcbd6..06487a3c09 100644 --- a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/comm/ConnectivityManager.java +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/comm/ConnectivityManager.java @@ -20,9 +20,7 @@ package com.raytheon.uf.viz.core.comm; import java.net.URI; -import java.text.SimpleDateFormat; import java.util.Collections; -import java.util.Date; import java.util.HashMap; import java.util.Map; @@ -55,7 +53,8 @@ import com.raytheon.uf.viz.core.requests.ThriftClient; * Mar 22, 2013 1786 mpduff Changed to use HttpClient for * connectivity. * Aug 02, 2013 2202 bsteffen Add edex specific connectivity checking. - * Jan 15, 2013 njensen Added printConnectivityProblems() + * Jan 15, 2014 njensen Added printConnectivityProblems() + * Feb 04, 2014 2704 njensen Check JMS capability, return exceptions with results * * * @@ -77,9 +76,16 @@ public class ConnectivityManager { public String server; + public Exception exception; + public ConnectivityResult(boolean hc, String server) { + this(hc, server, null); + } + + public ConnectivityResult(boolean hc, String server, Exception e) { this.hasConnectivity = hc; this.server = server; + this.exception = e; } } @@ -94,6 +100,7 @@ public class ConnectivityManager { public static void checkHttpServer(String server, IConnectivityCallback callback) { boolean good = false; + Exception exc = null; try { HttpClient client = HttpClient.getInstance(); HttpGet request = new HttpGet(); @@ -101,9 +108,9 @@ public class ConnectivityManager { client.executeRequest(request); good = true; } catch (Exception e) { - printConnectivityProblem(server, "http", e); + exc = e; } - callback.connectionChecked(new ConnectivityResult(good, server)); + callback.connectionChecked(new ConnectivityResult(good, server, exc)); } /** @@ -115,12 +122,13 @@ public class ConnectivityManager { public static void checkLocalizationServer(String server, IConnectivityCallback callback) { boolean good = false; + Exception exc = null; try { good = checkLocalizationServer(server, true) != null; } catch (Exception e) { - printConnectivityProblem(server, "localization", e); + exc = e; } - callback.connectionChecked(new ConnectivityResult(good, server)); + callback.connectionChecked(new ConnectivityResult(good, server, exc)); } /** @@ -142,47 +150,49 @@ public class ConnectivityManager { .sendRequest(req, server); getServersResponseCache.put(server, resp); return resp; - } /** - * Checks the connectivity of the given server + * Checks the connectivity of the given alert service * * @param server * server to check * @return whether quit was selected. TODO: need to return two booleans, one * for quit and one for connectivity */ - public static void checkJmsServer(String server, + public static void checkAlertService(String server, IConnectivityCallback callback) { boolean good = true; + Exception exc = null; try { ActiveMQConnectionFactory f = new ActiveMQConnectionFactory(server); f.createConnection().close(); } catch (JMSException e) { - printConnectivityProblem(server, "JMS", e); + exc = e; good = false; } - callback.connectionChecked(new ConnectivityResult(good, server)); + callback.connectionChecked(new ConnectivityResult(good, server, exc)); } /** - * Prints the connectivity exception to the console, to help with diagnosing - * connection issues + * Checks the connectivity of the given JMS server * - * @param server - * the server address it attempted to connect to - * @param serverType - * the type of server it attempted to connect to - * @param e - * the exception that occurred + * @param connectionString + * @param callback */ - private static void printConnectivityProblem(String server, - String serverType, Exception e) { - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - System.out.println(sdf.format(new Date()) + " MAY NOT BE AN ERROR:"); - System.out.println("Couldn't connect to " + serverType + " server at " - + server); - e.printStackTrace(System.out); + public static void checkJmsServer(String connectionString, + IConnectivityCallback callback) { + boolean good = true; + Exception exc = null; + try { + JMSConnection jms = new JMSConnection(connectionString); + jms.getFactory().createConnection().close(); + } catch (JMSException e) { + exc = e; + good = false; + } + callback.connectionChecked(new ConnectivityResult(good, + connectionString, exc)); } + } diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/comm/HttpsLoginDlg.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/comm/HttpsLoginDlg.java index 2d6c94edbc..ff471e271d 100644 --- a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/comm/HttpsLoginDlg.java +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/comm/HttpsLoginDlg.java @@ -42,7 +42,8 @@ import org.eclipse.ui.PlatformUI; * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Mar 6, 2013 1786 mpduff Initial creation + * Mar 06, 2013 1786 mpduff Initial creation + * Feb 10, 2014 2704 njensen Allow message to expand size of dialog * * * @@ -50,6 +51,7 @@ import org.eclipse.ui.PlatformUI; * @version 1.0 */ public class HttpsLoginDlg extends Dialog { + private static final long serialVersionUID = 1L; private Shell shell; @@ -76,7 +78,7 @@ public class HttpsLoginDlg extends Dialog { */ public HttpsLoginDlg(String message) { super(new Shell(Display.getDefault(), SWT.TITLE)); - this.message = message; + this.message = message.replace("\"", ""); } /** @@ -112,7 +114,9 @@ public class HttpsLoginDlg extends Dialog { comp.setLayout(new GridLayout(2, false)); GridData gd = new GridData(SWT.RIGHT, SWT.None, true, true); - gd.widthHint = 500; + if (message == null || message.length() < 50) { + gd.widthHint = 500; + } gd.horizontalSpan = 2; Label authMessage = new Label(comp, SWT.CENTER); diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/localization/ConnectivityPreferenceDialog.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/localization/ConnectivityPreferenceDialog.java index 5d9cb067aa..13b359cdeb 100644 --- a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/localization/ConnectivityPreferenceDialog.java +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/localization/ConnectivityPreferenceDialog.java @@ -19,11 +19,17 @@ **/ package com.raytheon.uf.viz.core.localization; +import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.io.PrintStream; +import java.net.UnknownHostException; +import java.util.regex.Pattern; +import org.apache.http.conn.HttpHostConnectException; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.preference.IPersistentPreferenceStore; import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.StyledText; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.VerifyEvent; @@ -41,6 +47,8 @@ import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; +import com.raytheon.uf.common.comm.HttpServerException; +import com.raytheon.uf.common.comm.InvalidURIException; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; @@ -58,6 +66,8 @@ import com.raytheon.uf.viz.core.comm.IConnectivityCallback; * ------------ ---------- ----------- -------------------------- * Aug 05, 2009 mschenke Initial creation * Aug 02, 2013 2202 bsteffen Add edex specific connectivity checking. + * Feb 04, 2014 2704 njensen Shifted some private fields/methods to protected, + * Added status and details, better site validation * * * @@ -66,16 +76,23 @@ import com.raytheon.uf.viz.core.comm.IConnectivityCallback; */ public class ConnectivityPreferenceDialog extends Dialog { + private static final transient IUFStatusHandler statusHandler = UFStatus .getHandler(ConnectivityPreferenceDialog.class, "CAVE"); + protected static final Pattern VALID_SITENAME = Pattern + .compile("^[A-Za-z0-9._-]+$"); + private class LocalizationCallback implements IConnectivityCallback { @Override public void connectionChecked(ConnectivityResult results) { localizationGood = results.hasConnectivity; + appendDetails(buildDetails(results)); + if (!results.hasConnectivity && status == null) { + status = buildErrorMessage(results); + } } - } private class AlertVizCallback implements IConnectivityCallback { @@ -83,19 +100,20 @@ public class ConnectivityPreferenceDialog extends Dialog { @Override public void connectionChecked(ConnectivityResult results) { alertVizGood = results.hasConnectivity; + appendDetails(buildDetails(results)); + if (!results.hasConnectivity && status == null) { + status = buildErrorMessage(results); + } } } - /** - * Set time dialog shell - */ private Shell shell; /** * Display component */ - private Display display; + protected Display display; private Label localizationLabel; @@ -115,10 +133,16 @@ public class ConnectivityPreferenceDialog extends Dialog { private String site = ""; - private Text siteText; + protected Text siteText; + + private Label statusLabel; private boolean canceled = false; + private Composite detailsComp; + + private StyledText detailsText; + private IConnectivityCallback localizationCallback = new LocalizationCallback(); private IConnectivityCallback alertCallback = new AlertVizCallback(); @@ -126,14 +150,20 @@ public class ConnectivityPreferenceDialog extends Dialog { /** * Title of the dialog. */ - private static final String dialogTitle = "Connectivity Preferences"; + private String title; - public ConnectivityPreferenceDialog(boolean checkAlertViz) { - this(new Shell(Display.getDefault()), checkAlertViz); + protected String status; + + protected String details; + + public ConnectivityPreferenceDialog(boolean checkAlertViz, String title) { + this(new Shell(Display.getDefault()), checkAlertViz, title); } - public ConnectivityPreferenceDialog(Shell parentShell, boolean checkAlertViz) { + public ConnectivityPreferenceDialog(Shell parentShell, + boolean checkAlertViz, String title) { super(parentShell); + this.title = title; localization = LocalizationManager.getInstance() .getLocalizationServer(); site = LocalizationManager.getInstance().getSite(); @@ -155,8 +185,8 @@ public class ConnectivityPreferenceDialog extends Dialog { if (!validate()) { Shell parent = getParent(); display = parent.getDisplay(); - shell = new Shell(parent, SWT.DIALOG_TRIM); - shell.setText(dialogTitle); + shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE); + shell.setText(title); // Create the main layout for the shell. GridLayout mainLayout = new GridLayout(1, true); @@ -165,6 +195,9 @@ public class ConnectivityPreferenceDialog extends Dialog { initializeComponents(); shell.pack(); + shell.setMinimumSize(shell.getBounds().width, + shell.getBounds().height); + updateStatus(false, status, details); shell.open(); while (!shell.isDisposed()) { @@ -177,16 +210,69 @@ public class ConnectivityPreferenceDialog extends Dialog { } private void initializeComponents() { - createErrorText(); Composite textBoxComp = new Composite(shell, SWT.NONE); textBoxComp.setLayout(new GridLayout(2, false)); createTextBoxes(textBoxComp); + createStatusText(); createBottomButtons(); } - private void createErrorText() { - Label label = new Label(shell, SWT.CENTER); - label.setText("Error: Unable to connect to localization server"); + /** + * Creates the status label, text, and details button + */ + protected void createStatusText() { + Composite comp = new Composite(shell, SWT.NONE); + comp.setLayout(new GridLayout(3, false)); + comp.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false)); + + Label lbl = new Label(comp, SWT.NONE); + lbl.setText("Status:"); + + GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false); + statusLabel = new Label(comp, SWT.BORDER); + statusLabel.setLayoutData(gd); + statusLabel.setText(""); + + final Button detailsButton = new Button(comp, SWT.TOGGLE); + detailsButton.setText("Details"); + detailsButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + if (detailsComp.isVisible()) { + ((GridData) detailsComp.getLayoutData()).exclude = true; + detailsComp.setVisible(false); + shell.pack(); + } else { + ((GridData) detailsComp.getLayoutData()).exclude = false; + ((GridData) detailsComp.getLayoutData()).widthHint = detailsComp + .getBounds().width; + detailsComp.setVisible(true); + shell.pack(); + } + } + }); + createDetailsText(); + } + + /** + * Creates the expanding details text + */ + protected void createDetailsText() { + detailsComp = new Composite(shell, SWT.NONE); + detailsComp.setLayout(new GridLayout(1, false)); + detailsComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); + gd.heightHint = 150; + detailsText = new StyledText(detailsComp, SWT.BORDER | SWT.MULTI + | SWT.H_SCROLL | SWT.V_SCROLL); + detailsText.setText(""); + detailsText.setLayoutData(gd); + + /* + * Hide the composite + */ + ((GridData) detailsComp.getLayoutData()).exclude = true; + detailsComp.setVisible(false); } protected void createTextBoxes(Composite textBoxComp) { @@ -194,12 +280,12 @@ public class ConnectivityPreferenceDialog extends Dialog { localizationLabel = new Label(textBoxComp, SWT.RIGHT); localizationLabel.setText("Localization Server:"); - GridData gd = new GridData(SWT.RIGHT, SWT.None, true, true); + GridData gd = new GridData(SWT.RIGHT, SWT.CENTER, true, true); gd.widthHint = 150; localizationLabel.setLayoutData(gd); - localizationText = new Text(textBoxComp, SWT.NONE); - gd = new GridData(SWT.RIGHT, SWT.None, true, true); + localizationText = new Text(textBoxComp, SWT.BORDER); + gd = new GridData(SWT.LEFT, SWT.None, true, true); gd.widthHint = 300; localizationText.setLayoutData(gd); localizationText.setText(localization == null ? "" : localization); @@ -207,17 +293,18 @@ public class ConnectivityPreferenceDialog extends Dialog { Label label = new Label(textBoxComp, SWT.RIGHT); label.setText("Site:"); - gd = new GridData(SWT.RIGHT, SWT.None, true, true); + gd = new GridData(SWT.RIGHT, SWT.CENTER, true, true); gd.widthHint = 150; label.setLayoutData(gd); - siteText = new Text(textBoxComp, SWT.NONE); + siteText = new Text(textBoxComp, SWT.BORDER); siteText.addVerifyListener(new VerifyListener() { + @Override public void verifyText(VerifyEvent e) { e.text = e.text.toUpperCase(); } }); - gd = new GridData(SWT.RIGHT, SWT.None, true, true); + gd = new GridData(SWT.LEFT, SWT.None, true, true); gd.widthHint = 300; siteText.setLayoutData(gd); siteText.setText(site == null ? "" : site); @@ -299,7 +386,7 @@ public class ConnectivityPreferenceDialog extends Dialog { shell.setVisible(false); MessageDialog .openError( - null, + shell, "Connectivity Error", "Unable to validate localization preferences, please enter valid options or quit the application"); shell.setVisible(true); @@ -327,6 +414,8 @@ public class ConnectivityPreferenceDialog extends Dialog { } public boolean validate() { + status = null; + details = null; if (localizationText != null && !localizationText.isDisposed() && localizationText.isEnabled()) { String localization = localizationText.getText().trim(); @@ -360,20 +449,28 @@ public class ConnectivityPreferenceDialog extends Dialog { } else { validateSite(); } - return siteGood && localizationGood && alertVizGood; + + boolean everythingGood = siteGood && localizationGood && alertVizGood; + updateStatus(everythingGood, status, details); + return everythingGood; } private void validateLocalization() { - ConnectivityManager.checkLocalizationServer(localization, localizationCallback); + ConnectivityManager.checkLocalizationServer(localization, + localizationCallback); } private void validateAlertviz() { - ConnectivityManager.checkJmsServer(alertVizServer, alertCallback); + ConnectivityManager.checkAlertService(alertVizServer, alertCallback); } - private void validateSite() { - if (site == null || site.trim().equals("")) { + protected void validateSite() { + if (site == null || site.trim().length() == 0 + || !VALID_SITENAME.matcher(site).find()) { siteGood = false; + if (status == null) { + status = "Invalid Site ID"; + } } else { siteGood = true; } @@ -387,6 +484,20 @@ public class ConnectivityPreferenceDialog extends Dialog { } } + /** + * Gets the color for the status label + * + * @param isGood + * @return + */ + protected Color getForegroundColor(boolean isGood) { + if (isGood) { + return display.getSystemColor(SWT.COLOR_DARK_GREEN); + } else { + return display.getSystemColor(SWT.COLOR_DARK_RED); + } + } + public String getLocalization() { return localization; } @@ -438,4 +549,118 @@ public class ConnectivityPreferenceDialog extends Dialog { localizationText.setEnabled(enabled); } } + + /** + * Builds a details string based on a stacktrace of connectivity results. If + * there is no exception with the results, this returns the empty string. + * + * @param results + * @return + */ + protected String buildDetails(ConnectivityResult results) { + StringBuilder sb = new StringBuilder(); + if (results.exception != null) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + PrintStream ps = new PrintStream(baos); + results.exception.printStackTrace(ps); + String stack = baos.toString(); + ps.close(); + sb.append(stack); + } + return sb.toString(); + } + + /** + * Adds new details to the details field without overwriting it + * + * @param newDetails + */ + protected void appendDetails(String newDetails) { + if (details == null) { + details = ""; + } + if (details.length() > 0) { + details += "\n\n\n"; + } + details += newDetails; + } + + /** + * Creates an error message for the status label by attempting to find the + * most relevant error message from the exception's stacktrace. + * + * @param result + * @return + */ + protected String buildErrorMessage(ConnectivityResult result) { + StringBuilder sb = new StringBuilder(); + Exception prettyErrExc = result.exception; + /* + * Loop through the Caused Bys and try to find one that is the most + * useful for the label. This is totally arbitrary and corresponds to + * what njensen predicted would be most useful. + */ + while (prettyErrExc != null) { + if (prettyErrExc instanceof HttpHostConnectException + || prettyErrExc instanceof InvalidURIException) { + sb.append(prettyErrExc.getMessage()); + break; + } + if (prettyErrExc instanceof UnknownHostException) { + sb.append("Unknown host: " + prettyErrExc.getMessage()); + break; + } else if (prettyErrExc instanceof HttpServerException) { + sb.append("Server returned Error "); + String emsg = prettyErrExc.getMessage(); + int titleIndex = emsg.indexOf("
+ * + * SOFTWARE HISTORY + * + * Date Ticket# Engineer Description + * ------------ ---------- ----------- -------------------------- + * Feb 3, 2014 njensen Initial creation + * + *+ * + * @author njensen + * @version 1.0 + */ + +public class ThinClientUriUtil { + + private static String services = "services"; + + private static String pypies = "pypies"; + + static { + services = System.getProperty("thinclient.proxy.services", services); + pypies = System.getProperty("thinclient.proxy.pypies", pypies); + } + + private ThinClientUriUtil() { + + } + + /** + * Returns the address to connect to EDEX services when going through the + * thin client proxy + * + * @param proxyAddress + * the address of the proxy server + * @return + */ + public static String getServicesAddress(String proxyAddress) { + return appendTrailingSlash(proxyAddress) + services; + } + + /** + * Returns the address to connect to PyPIES when going through the thin + * client proxy + * + * @param proxyAddress + * the address of the proxy server + * @return + */ + public static String getPypiesAddress(String proxyAddress) { + return appendTrailingSlash(proxyAddress) + pypies; + } + + /** + * Appends a trailing slash to an address if the address does not have one + * + * @param proxyAddress + * @return + */ + private static String appendTrailingSlash(String proxyAddress) { + if (!proxyAddress.endsWith("/")) { + proxyAddress += "/"; + } + return proxyAddress; + } + +} diff --git a/cave/com.raytheon.uf.viz.thinclient/src/com/raytheon/uf/viz/thinclient/localization/ThinClientLocalizationInitializer.java b/cave/com.raytheon.uf.viz.thinclient/src/com/raytheon/uf/viz/thinclient/localization/ThinClientLocalizationInitializer.java index 04dc217a20..cd6577b353 100644 --- a/cave/com.raytheon.uf.viz.thinclient/src/com/raytheon/uf/viz/thinclient/localization/ThinClientLocalizationInitializer.java +++ b/cave/com.raytheon.uf.viz.thinclient/src/com/raytheon/uf/viz/thinclient/localization/ThinClientLocalizationInitializer.java @@ -25,15 +25,15 @@ import org.apache.commons.collections.map.DefaultedMap; import org.eclipse.jface.preference.IPreferenceStore; import com.raytheon.uf.common.comm.HttpClient; -import com.raytheon.uf.common.localization.msgs.GetServersRequest; import com.raytheon.uf.common.localization.msgs.GetServersResponse; import com.raytheon.uf.viz.core.VizApp; import com.raytheon.uf.viz.core.VizServers; +import com.raytheon.uf.viz.core.comm.ConnectivityManager; import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.localization.LocalizationInitializer; import com.raytheon.uf.viz.core.localization.LocalizationManager; -import com.raytheon.uf.viz.core.requests.ThriftClient; import com.raytheon.uf.viz.thinclient.Activator; +import com.raytheon.uf.viz.thinclient.ThinClientUriUtil; import com.raytheon.uf.viz.thinclient.preferences.ThinClientPreferenceConstants; import com.raytheon.uf.viz.thinclient.ui.ThinClientConnectivityDialog; @@ -51,8 +51,9 @@ import com.raytheon.uf.viz.thinclient.ui.ThinClientConnectivityDialog; * Dec 06, 2012 1396 njensen Added setting VizServers * Jan 14, 2013 1469 bkowal Removed setting the hdf5 data directory * Aug 02, 2013 2202 bsteffen Add edex specific connectivity checking. - * Aug 27, 2013 2295 bkowal The entire jms connection string is + * Aug 27, 2013 2295 bkowal The entire jms connection string is * now provided by EDEX. + * Feb 04, 2014 2704 njensen Single proxy address/preference * * * @@ -87,20 +88,25 @@ public class ThinClientLocalizationInitializer extends LocalizationInitializer { .getBoolean(ThinClientPreferenceConstants.P_DISABLE_JMS); if (store.getBoolean(ThinClientPreferenceConstants.P_USE_PROXIES)) { - String servicesProxy = store - .getString(ThinClientPreferenceConstants.P_SERVICES_PROXY); - LocalizationManager.getInstance().setCurrentServer(servicesProxy); + String proxyAddr = store + .getString(ThinClientPreferenceConstants.P_PROXY_ADDRESS); + String servicesProxy = ThinClientUriUtil + .getServicesAddress(proxyAddr); + LocalizationManager.getInstance().setCurrentServer(servicesProxy, + false); + VizApp.setHttpServer(servicesProxy); + if (!disableJMS) { - GetServersRequest req = new GetServersRequest(); - GetServersResponse resp = (GetServersResponse) ThriftClient - .sendLocalizationRequest(req); + GetServersResponse resp = ConnectivityManager + .checkLocalizationServer(servicesProxy, false); if (!disableJMS) { VizApp.setJmsConnectionString(resp.getJmsConnectionString()); } } - VizApp.setHttpServer(servicesProxy); - VizApp.setPypiesServer(store - .getString(ThinClientPreferenceConstants.P_PYPIES_PROXY)); + + String pypiesProxy = ThinClientUriUtil + .getPypiesAddress(proxyAddr); + VizApp.setPypiesServer(pypiesProxy); boolean compressRequests = store .getBoolean(ThinClientPreferenceConstants.P_ENABLE_REQUEST_COMPRESSION); HttpClient.getInstance().setCompressRequests(compressRequests); diff --git a/cave/com.raytheon.uf.viz.thinclient/src/com/raytheon/uf/viz/thinclient/preferences/ThinClientPreferenceConstants.java b/cave/com.raytheon.uf.viz.thinclient/src/com/raytheon/uf/viz/thinclient/preferences/ThinClientPreferenceConstants.java index cd79aefbcb..5376f0fea7 100644 --- a/cave/com.raytheon.uf.viz.thinclient/src/com/raytheon/uf/viz/thinclient/preferences/ThinClientPreferenceConstants.java +++ b/cave/com.raytheon.uf.viz.thinclient/src/com/raytheon/uf/viz/thinclient/preferences/ThinClientPreferenceConstants.java @@ -30,6 +30,7 @@ package com.raytheon.uf.viz.thinclient.preferences; * ------------ ---------- ----------- -------------------------- * Oct 20, 2011 mschenke Initial creation * Jan 14, 2013 1469 bkowal The hdf5 data directory is no longer a preference constant. + * Feb 04, 2014 2704 njensen Single proxy preference constant * * * @@ -47,10 +48,6 @@ public class ThinClientPreferenceConstants { public static String P_USE_PROXIES = "useHttpProxy"; - public static String P_SERVICES_PROXY = "servicesProxyAddress"; - - public static String P_PYPIES_PROXY = "pypiesProxyAddress"; - public static String P_MENU_TIME_UPDATE_INTERVALS = "menuTimeUpdateInterval"; public static String P_DATA_UPDATE_INTERVALS = "dataUpdateInterval"; @@ -70,4 +67,6 @@ public class ThinClientPreferenceConstants { public static String P_ENABLE_REQUEST_COMPRESSION = "enableRequestCompression"; public static String P_PREFERENCE_PLACEHOLDER = "placeholderPreference"; + + public static String P_PROXY_ADDRESS = "proxyAddress"; } diff --git a/cave/com.raytheon.uf.viz.thinclient/src/com/raytheon/uf/viz/thinclient/ui/ThinClientConnectivityDialog.java b/cave/com.raytheon.uf.viz.thinclient/src/com/raytheon/uf/viz/thinclient/ui/ThinClientConnectivityDialog.java index 25577da212..b175c5a886 100644 --- a/cave/com.raytheon.uf.viz.thinclient/src/com/raytheon/uf/viz/thinclient/ui/ThinClientConnectivityDialog.java +++ b/cave/com.raytheon.uf.viz.thinclient/src/com/raytheon/uf/viz/thinclient/ui/ThinClientConnectivityDialog.java @@ -27,25 +27,30 @@ 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 org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; +import com.raytheon.uf.common.localization.msgs.GetServersResponse; 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.core.comm.ConnectivityManager; import com.raytheon.uf.viz.core.comm.ConnectivityManager.ConnectivityResult; import com.raytheon.uf.viz.core.comm.IConnectivityCallback; +import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.localization.ConnectivityPreferenceDialog; import com.raytheon.uf.viz.core.localization.LocalizationConstants; import com.raytheon.uf.viz.core.localization.LocalizationManager; import com.raytheon.uf.viz.thinclient.Activator; +import com.raytheon.uf.viz.thinclient.ThinClientUriUtil; import com.raytheon.uf.viz.thinclient.preferences.ThinClientPreferenceConstants; /** - * TODO Add Description + * Connectivity dialog for launching thinclient or thinalertviz. Contains extra + * options not available when connecting with a normal CAVE. * *
* @@ -55,6 +60,7 @@ import com.raytheon.uf.viz.thinclient.preferences.ThinClientPreferenceConstants; * ------------ ---------- ----------- -------------------------- * Nov 23, 2011 bsteffen Initial creation * Aug 02, 2013 2202 bsteffen Add edex specific connectivity checking. + * Feb 04, 2014 2704 njensen Refactored * ** @@ -71,8 +77,11 @@ public class ThinClientConnectivityDialog extends ConnectivityPreferenceDialog { @Override public void connectionChecked(ConnectivityResult results) { servicesGood = results.hasConnectivity; + appendDetails(buildDetails(results)); + if (!results.hasConnectivity && status == null) { + status = buildErrorMessage(results); + } } - } private class PypiesCallback implements IConnectivityCallback { @@ -80,26 +89,30 @@ public class ThinClientConnectivityDialog extends ConnectivityPreferenceDialog { @Override public void connectionChecked(ConnectivityResult results) { pypiesGood = results.hasConnectivity; + appendDetails(buildDetails(results)); + if (!results.hasConnectivity && status == null) { + status = buildErrorMessage(results); + } + } + } + + private class JmsCallback implements IConnectivityCallback { + + @Override + public void connectionChecked(ConnectivityResult results) { + jmsGood = results.hasConnectivity; + appendDetails(buildDetails(results)); + if (!results.hasConnectivity && status == null) { + status = buildErrorMessage(results); + } } } - private Label servicesLabel; - - private Text servicesText; - - private String services = ""; - private boolean servicesGood = false; private IConnectivityCallback servicesCallback = new ServicesCallback(); - private Label pypiesLabel; - - private Text pypiesText; - - private String pypies = ""; - private boolean pypiesGood = false; private IConnectivityCallback pypiesCallback = new PypiesCallback(); @@ -108,15 +121,29 @@ public class ThinClientConnectivityDialog extends ConnectivityPreferenceDialog { private boolean useProxy = false; + private Button disableJmsCheck; + + private boolean disableJms = false; + + private boolean jmsGood = false; + + private Label jmsErrorLabel; + + private IConnectivityCallback jmsCallback = new JmsCallback(); + + private Text proxyText; + + private String proxyAddress; + public ThinClientConnectivityDialog(boolean checkAlertViz) { - super(checkAlertViz); + super(checkAlertViz, "Thin Client Connectivity Preferences"); IPreferenceStore store = Activator.getDefault().getPreferenceStore(); useProxy = store .getBoolean(ThinClientPreferenceConstants.P_USE_PROXIES); - services = store - .getString(ThinClientPreferenceConstants.P_SERVICES_PROXY); - pypies = store.getString(ThinClientPreferenceConstants.P_PYPIES_PROXY); - + disableJms = store + .getBoolean(ThinClientPreferenceConstants.P_DISABLE_JMS); + proxyAddress = store + .getString(ThinClientPreferenceConstants.P_PROXY_ADDRESS); } @Override @@ -124,66 +151,75 @@ public class ThinClientConnectivityDialog extends ConnectivityPreferenceDialog { super.createTextBoxes(textBoxComp); Label label = new Label(textBoxComp, SWT.RIGHT); - label.setText("Use Proxy Servers:"); - GridData gd = new GridData(SWT.RIGHT, SWT.None, true, true); + label.setText("Disable JMS:"); + GridData gd = new GridData(SWT.RIGHT, SWT.CENTER, true, true); gd.widthHint = 150; label.setLayoutData(gd); - useProxyCheck = new Button(textBoxComp, SWT.CHECK | SWT.LEFT); + Composite jmsComp = new Composite(textBoxComp, SWT.NONE); + GridLayout gl = new GridLayout(2, false); + gl.marginHeight = 0; + gl.marginWidth = 0; + jmsComp.setLayout(gl); + gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); + jmsComp.setLayoutData(gd); + + disableJmsCheck = new Button(jmsComp, SWT.CHECK | SWT.LEFT); + disableJmsCheck.setSelection(disableJms); + disableJmsCheck.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + disableJms = disableJmsCheck.getSelection(); + validate(); + } + }); + jmsErrorLabel = new Label(jmsComp, SWT.LEFT); + jmsErrorLabel.setText("Error connecting to JMS"); + jmsErrorLabel.setForeground(display.getSystemColor(SWT.COLOR_RED)); + jmsErrorLabel.setVisible(false); + + label = new Label(textBoxComp, SWT.RIGHT); + label.setText("Use Proxy Server:"); + gd = new GridData(SWT.RIGHT, SWT.CENTER, true, true); + gd.widthHint = 150; + label.setLayoutData(gd); + + Composite proxyComp = new Composite(textBoxComp, SWT.NONE); + gl = new GridLayout(2, false); + gl.marginHeight = 0; + gl.marginWidth = 0; + proxyComp.setLayout(gl); + gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); + proxyComp.setLayoutData(gd); + + useProxyCheck = new Button(proxyComp, SWT.CHECK | SWT.LEFT); useProxyCheck.setSelection(useProxy); useProxyCheck.addSelectionListener(new SelectionAdapter() { - @Override public void widgetSelected(SelectionEvent e) { updateProxyEnabled(); } - }); - servicesLabel = new Label(textBoxComp, SWT.RIGHT); - servicesLabel.setText("Services Proxy Address:"); - gd = new GridData(SWT.RIGHT, SWT.None, true, true); - gd.widthHint = 150; - servicesLabel.setLayoutData(gd); + proxyText = new Text(proxyComp, SWT.NONE | SWT.BORDER); + gd = new GridData(SWT.FILL, SWT.None, true, true); + proxyText.setLayoutData(gd); + proxyText.setText(proxyAddress == null ? "" : proxyAddress); + proxyText.setBackground(getTextColor(servicesGood && pypiesGood)); - servicesText = new Text(textBoxComp, SWT.NONE); - gd = new GridData(SWT.RIGHT, SWT.None, true, true); - gd.widthHint = 300; - servicesText.setLayoutData(gd); - servicesText.setText(services); - if (!servicesGood) { - servicesText.setBackground(textBoxComp.getDisplay().getSystemColor( - SWT.COLOR_RED)); - } - - pypiesLabel = new Label(textBoxComp, SWT.RIGHT); - pypiesLabel.setText("Pypies Proxy Address:"); - gd = new GridData(SWT.RIGHT, SWT.None, true, true); - gd.widthHint = 150; - pypiesLabel.setLayoutData(gd); - - pypiesText = new Text(textBoxComp, SWT.NONE); - gd = new GridData(SWT.RIGHT, SWT.None, true, true); - gd.widthHint = 300; - pypiesText.setLayoutData(gd); - pypiesText.setText(pypies); - if (!pypiesGood) { - pypiesText.setBackground(textBoxComp.getDisplay().getSystemColor( - SWT.COLOR_RED)); - } updateProxyEnabled(); } @Override protected void applySettings() { IPreferenceStore store = Activator.getDefault().getPreferenceStore(); - store.setValue(ThinClientPreferenceConstants.P_USE_PROXIES, useProxy); + store.setValue(ThinClientPreferenceConstants.P_DISABLE_JMS, disableJms); if (useProxy) { - store.setValue(ThinClientPreferenceConstants.P_SERVICES_PROXY, - services); - store.setValue(ThinClientPreferenceConstants.P_PYPIES_PROXY, pypies); - // Set the site and alertViz server for super. - LocalizationManager.getInstance().setCurrentSite(getSite()); + store.setValue(ThinClientPreferenceConstants.P_USE_PROXIES, + useProxy); + store.setValue(ThinClientPreferenceConstants.P_PROXY_ADDRESS, + proxyAddress); + if (getAlertVizServer() != null) { LocalizationManager .getInstance() @@ -191,11 +227,11 @@ public class ThinClientConnectivityDialog extends ConnectivityPreferenceDialog { .setValue(LocalizationConstants.P_ALERT_SERVER, getAlertVizServer()); } + // setting the site will save the preference store + LocalizationManager.getInstance().setCurrentSite(getSite()); try { ((IPersistentPreferenceStore) store).save(); - ((IPersistentPreferenceStore) LocalizationManager.getInstance() - .getLocalizationStore()).save(); } catch (IOException e) { statusHandler.handle(Priority.SIGNIFICANT, "Unable to persist localization preference store", e); @@ -208,50 +244,88 @@ public class ThinClientConnectivityDialog extends ConnectivityPreferenceDialog { @Override public boolean validate() { - boolean superValid = super.validate(); if (!useProxy) { - return superValid; + return super.validate(); } - if (servicesText != null && !servicesText.isDisposed() - && servicesText.isEnabled()) { - String services = servicesText.getText().trim(); - if (!servicesGood || !this.services.equals(services)) { - this.services = services; - validateServices(); - servicesText.setBackground(getTextColor(servicesGood)); - } - } else { + + status = null; + details = null; + + // validate proxy + if (proxyText != null && !proxyText.isDisposed() + && proxyText.isEnabled()) { + proxyAddress = proxyText.getText(); + } + if (proxyAddress != null && proxyAddress.length() > 0) { validateServices(); - } - if (pypiesText != null && !pypiesText.isDisposed() - && pypiesText.isEnabled()) { - String pypies = pypiesText.getText().trim(); - if (!pypiesGood || !this.pypies.equals(pypies)) { - this.pypies = pypies; - validatePypies(); - pypiesText.setBackground(getTextColor(pypiesGood)); - } - } else { validatePypies(); + } else { + status = "Please enter a thin client proxy server address"; } - return servicesGood && pypiesGood && isSiteGood() && isAlertVizGood(); + if (proxyText != null && !proxyText.isDisposed()) { + proxyText.setBackground(getTextColor(servicesGood && pypiesGood)); + } + + // only check Jms if it's enabled and we can connect to the services + if (!disableJms) { + if (servicesGood) { + try { + GetServersResponse response = ConnectivityManager + .checkLocalizationServer(ThinClientUriUtil + .getServicesAddress(proxyAddress), false); + ConnectivityManager.checkJmsServer( + response.getJmsConnectionString(), jmsCallback); + } catch (VizException e) { + if (status == null) { + status = "Error connecting to JMS"; + } + appendDetails(buildDetails(new ConnectivityResult(false, + null, e))); + jmsGood = false; + } + } else { + // JMS can't be good if services fail cause then we don't + // even know where to connect JMS to + jmsGood = false; + } + } + jmsGood = (jmsGood || disableJms); + if (jmsErrorLabel != null && !jmsErrorLabel.isDisposed()) { + jmsErrorLabel.setVisible(!jmsGood); + } + + // validate site + if (siteText != null && !siteText.isDisposed()) { + super.setSite(siteText.getText()); + } + super.validateSite(); + if (siteText != null && !siteText.isDisposed()) { + siteText.setBackground(getTextColor(isSiteGood())); + } + + boolean everythingGood = servicesGood && pypiesGood && isSiteGood() + && isAlertVizGood() && jmsGood; + updateStatus(everythingGood, status, details); + + return everythingGood; } private void validateServices() { - ConnectivityManager.checkLocalizationServer(services, servicesCallback); + ConnectivityManager.checkLocalizationServer( + ThinClientUriUtil.getServicesAddress(proxyAddress), + servicesCallback); } private void validatePypies() { - ConnectivityManager.checkHttpServer(pypies, pypiesCallback); + ConnectivityManager.checkHttpServer( + ThinClientUriUtil.getPypiesAddress(proxyAddress), + pypiesCallback); } private void updateProxyEnabled() { useProxy = useProxyCheck.getSelection(); - servicesLabel.setEnabled(useProxy); - servicesText.setEnabled(useProxy); - pypiesLabel.setEnabled(useProxy); - pypiesText.setEnabled(useProxy); - setLocalizationEnabled(!useProxy); + proxyText.setEnabled(useProxy); + super.setLocalizationEnabled(!useProxy); validate(); } diff --git a/edexOsgi/com.raytheon.uf.common.comm/src/com/raytheon/uf/common/comm/HttpClient.java b/edexOsgi/com.raytheon.uf.common.comm/src/com/raytheon/uf/common/comm/HttpClient.java index c976047937..4b3953bd06 100644 --- a/edexOsgi/com.raytheon.uf.common.comm/src/com/raytheon/uf/common/comm/HttpClient.java +++ b/edexOsgi/com.raytheon.uf.common.comm/src/com/raytheon/uf/common/comm/HttpClient.java @@ -104,6 +104,8 @@ import com.raytheon.uf.common.util.ByteArrayOutputStreamPool.ByteArrayOutputStre * Mar 11, 2013 1786 mpduff Add https capability. * Jun 12, 2013 2102 njensen Better error handling when using * DynamicSerializeStreamHandler + * Feb 04, 2014 2704 njensen Better error message with bad address + * Https authentication failures notify handler * * * @@ -400,7 +402,6 @@ public class HttpClient { private HttpClient() { } - private org.apache.http.client.HttpClient getHttpsInstance() { return HttpsHolder.sslClient; } @@ -539,6 +540,14 @@ public class HttpClient { "Error retrying http request", e); return resp; } + + if (resp.getStatusLine().getStatusCode() == 401) { + // obtained credentials and they failed! + if (handler != null) { + handler.credentialsFailed(); + } + } + } } else { resp = getHttpInstance().execute(put); @@ -589,6 +598,10 @@ public class HttpClient { try { String host = put.getURI().getHost(); + if (host == null) { + throw new InvalidURIException("Invalid URI: " + + put.getURI().toString()); + } ongoing = currentRequestsCount.get(host); if (ongoing == null) { ongoing = new AtomicInteger(); @@ -651,21 +664,21 @@ public class HttpClient { // so we only want to error off here if we're using a // DynamicSerializeStreamHandler because deserializing will fail // badly - String exceptionMsg = "HTTP server returned error code: " - + resp.getStatusLine().getStatusCode(); + int statusCode = resp.getStatusLine().getStatusCode(); DefaultInternalStreamHandler errorHandler = new DefaultInternalStreamHandler(); - String serverErrorMsg = null; + String exceptionMsg = null; try { errorHandler.handleStream(resp.getEntity().getContent()); - serverErrorMsg = new String(errorHandler.byteResult); + exceptionMsg = new String(errorHandler.byteResult); } catch (IOException e) { statusHandler .warn("Error reading the server's error message"); } - if (serverErrorMsg != null) { - exceptionMsg += "\n" + serverErrorMsg; + if (exceptionMsg == null) { + exceptionMsg = "HTTP server returned error code: " + + statusCode; } - throw new CommunicationException(exceptionMsg); + throw new HttpServerException(exceptionMsg, statusCode); } // should only be able to get here if we didn't encounter the @@ -720,7 +733,7 @@ public class HttpClient { // if there was an error reading the input stream, // notify but continue statusHandler.handle(Priority.EVENTB, - "Error reading InputStream, assuming closed", e); + "Error reading InputStream, assuming closed"); } try { SafeGzipDecompressingEntity.close(); @@ -1173,7 +1186,7 @@ public class HttpClient { new AuthScope(host, port), new UsernamePasswordCredentials(username, password)); } - + /** * @param httpsConfiguration * the httpsConfiguration to set @@ -1188,5 +1201,5 @@ public class HttpClient { public IHttpsConfiguration getHttpsConfiguration() { return httpsConfiguration; } - + } diff --git a/edexOsgi/com.raytheon.uf.common.comm/src/com/raytheon/uf/common/comm/HttpServerException.java b/edexOsgi/com.raytheon.uf.common.comm/src/com/raytheon/uf/common/comm/HttpServerException.java new file mode 100644 index 0000000000..2e9ac330dd --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.comm/src/com/raytheon/uf/common/comm/HttpServerException.java @@ -0,0 +1,71 @@ +/** + * 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.comm; + +/** + * A communication exception corresponding to an error returned from an http + * server and including the http status code. + * + *
+ * + * SOFTWARE HISTORY + * + * Date Ticket# Engineer Description + * ------------ ---------- ----------- -------------------------- + * Feb 6, 2014 njensen Initial creation + * + *+ * + * @author njensen + * @version 1.0 + */ + +public class HttpServerException extends CommunicationException { + + private static final long serialVersionUID = 1L; + + private int statusCode; + + public HttpServerException() { + super(); + } + + public HttpServerException(String message, Throwable cause) { + super(message, cause); + } + + public HttpServerException(String message) { + super(message); + } + + public HttpServerException(Throwable cause) { + super(cause); + } + + public HttpServerException(String message, int statusCode) { + super(message); + this.statusCode = statusCode; + } + + public int getStatusCode() { + return statusCode; + } + +} diff --git a/edexOsgi/com.raytheon.uf.common.comm/src/com/raytheon/uf/common/comm/IHttpsCredentialsHandler.java b/edexOsgi/com.raytheon.uf.common.comm/src/com/raytheon/uf/common/comm/IHttpsCredentialsHandler.java index 5e60cbc7f8..6bb6da670a 100644 --- a/edexOsgi/com.raytheon.uf.common.comm/src/com/raytheon/uf/common/comm/IHttpsCredentialsHandler.java +++ b/edexOsgi/com.raytheon.uf.common.comm/src/com/raytheon/uf/common/comm/IHttpsCredentialsHandler.java @@ -28,7 +28,9 @@ package com.raytheon.uf.common.comm; * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Mar 4, 2013 1786 mpduff Initial creation + * Mar 04, 2013 1786 mpduff Initial creation + * Feb 10, 2014 2704 njensen Added credentialsFailed() + * * * * @@ -48,4 +50,6 @@ public interface IHttpsCredentialsHandler { * @return String Array, username and password */ String[] getCredentials(String authValue); + + void credentialsFailed(); } diff --git a/edexOsgi/com.raytheon.uf.common.comm/src/com/raytheon/uf/common/comm/InvalidURIException.java b/edexOsgi/com.raytheon.uf.common.comm/src/com/raytheon/uf/common/comm/InvalidURIException.java new file mode 100644 index 0000000000..7c6ee49e9b --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.comm/src/com/raytheon/uf/common/comm/InvalidURIException.java @@ -0,0 +1,60 @@ +/** + * 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.comm; + +/** + * A communication exception specific to an invalid URI, such as + * http//someAddress (instead of http://someAddress) + * + *
+ * + * SOFTWARE HISTORY + * + * Date Ticket# Engineer Description + * ------------ ---------- ----------- -------------------------- + * Feb 6, 2014 njensen Initial creation + * + *+ * + * @author njensen + * @version 1.0 + */ + +public class InvalidURIException extends CommunicationException { + + private static final long serialVersionUID = 1L; + + public InvalidURIException() { + super(); + } + + public InvalidURIException(String message, Throwable cause) { + super(message, cause); + } + + public InvalidURIException(String message) { + super(message); + } + + public InvalidURIException(Throwable cause) { + super(cause); + } + +} diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/util/WfsConnectionUtil.java b/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/util/WfsConnectionUtil.java index c3c6878915..88e242cb85 100644 --- a/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/util/WfsConnectionUtil.java +++ b/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/util/WfsConnectionUtil.java @@ -47,7 +47,7 @@ public class WfsConnectionUtil { private static final IUFStatusHandler statusHandler = UFStatus .getHandler(WfsConnectionUtil.class); - + private static final Pattern COMMA_PATTERN = Pattern.compile(","); /** @@ -119,6 +119,7 @@ public class WfsConnectionUtil { * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Jun 19, 2013 2120 dhladky Initial creation + * Feb 10, 2014 2704 njensen Added credentialsFailed() * * * @@ -141,6 +142,12 @@ public class WfsConnectionUtil { this.password = password; this.username = username; } + + @Override + public void credentialsFailed() { + statusHandler + .error("Failed to authenticate with supplied username and password"); + } } /** @@ -196,9 +203,11 @@ public class WfsConnectionUtil { return httpPort; } } - + /** - * Removes un-needed unique Identifier from PointDataSetMetaData derived URL's + * Removes un-needed unique Identifier from PointDataSetMetaData derived + * URL's + * * @param rootUrl * @return */ diff --git a/tests/unit/com/raytheon/uf/common/comm/TestHttpsCredentialsHandler.java b/tests/unit/com/raytheon/uf/common/comm/TestHttpsCredentialsHandler.java index 1c2b63400b..282d8e2fd1 100644 --- a/tests/unit/com/raytheon/uf/common/comm/TestHttpsCredentialsHandler.java +++ b/tests/unit/com/raytheon/uf/common/comm/TestHttpsCredentialsHandler.java @@ -46,4 +46,10 @@ public class TestHttpsCredentialsHandler implements IHttpsCredentialsHandler { return new String[] { HttpTestConstants.USERNAME, HttpTestConstants.PASSWD }; } + + @Override + public void credentialsFailed() { + // TODO Auto-generated method stub + + } } diff --git a/tests/unit/com/raytheon/uf/common/comm/TestProxyHttpsCredentialsHandler.java b/tests/unit/com/raytheon/uf/common/comm/TestProxyHttpsCredentialsHandler.java index df60588e32..03aa73aa17 100644 --- a/tests/unit/com/raytheon/uf/common/comm/TestProxyHttpsCredentialsHandler.java +++ b/tests/unit/com/raytheon/uf/common/comm/TestProxyHttpsCredentialsHandler.java @@ -37,11 +37,18 @@ package com.raytheon.uf.common.comm; * @version 1.0 */ -public class TestProxyHttpsCredentialsHandler implements IHttpsCredentialsHandler { +public class TestProxyHttpsCredentialsHandler implements + IHttpsCredentialsHandler { @Override public String[] getCredentials(String message) { return new String[] { HttpTestConstants.USERNAME, HttpTestConstants.PASSWD }; } + + @Override + public void credentialsFailed() { + // TODO Auto-generated method stub + + } }