Revision: 6134
          http://sourceforge.net/p/jump-pilot/code/6134
Author:   michaudm
Date:     2019-02-22 07:35:16 +0000 (Fri, 22 Feb 2019)
Log Message:
-----------
Fix bad error management introduced in last commit

Modified Paths:
--------------
    core/trunk/src/com/vividsolutions/jump/workbench/model/WMSLayer.java
    
core/trunk/src/com/vividsolutions/jump/workbench/ui/plugin/wms/URLWizardPanel.java
    core/trunk/src/com/vividsolutions/wms/AbstractWMSRequest.java
    core/trunk/src/com/vividsolutions/wms/FeatureInfoRequest.java
    core/trunk/src/com/vividsolutions/wms/WMSRequest.java
    core/trunk/src/com/vividsolutions/wms/WMService.java
    core/trunk/src/com/vividsolutions/wms/ui/WMSViewer.java
    core/trunk/src/org/openjump/core/ui/plugin/wms/WMSLegendPlugIn.java

Modified: core/trunk/src/com/vividsolutions/jump/workbench/model/WMSLayer.java
===================================================================
--- core/trunk/src/com/vividsolutions/jump/workbench/model/WMSLayer.java        
2019-02-21 07:21:47 UTC (rev 6133)
+++ core/trunk/src/com/vividsolutions/jump/workbench/model/WMSLayer.java        
2019-02-22 07:35:16 UTC (rev 6134)
@@ -38,8 +38,6 @@
 import java.lang.ref.Reference;
 import java.lang.ref.SoftReference;
 import java.net.URL;
-import java.security.KeyManagementException;
-import java.security.NoSuchAlgorithmException;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
@@ -86,13 +84,13 @@
   }
 
   public WMSLayer(LayerManager layerManager, String serverURL, String srs,
-      List<String> layerNames, String format, String version) throws 
IOException, KeyManagementException, NoSuchAlgorithmException {
+      List<String> layerNames, String format, String version) throws 
IOException {
     this(layerManager, initializedService(serverURL, version), srs, layerNames,
         format);
   }
 
   private static WMService initializedService(String serverURL, String version)
-      throws IOException, KeyManagementException, NoSuchAlgorithmException {
+      throws IOException {
     WMService initializedService = new WMService(serverURL, version);
     initializedService.initialize();
     return initializedService;
@@ -152,7 +150,7 @@
     this.alpha = alpha;
   }
 
-  public Image createImage(LayerViewPanel panel) throws IOException, 
KeyManagementException, NoSuchAlgorithmException {
+  public Image createImage(LayerViewPanel panel) throws IOException {
 
     MapRequest request = createRequest(panel);
     URL newURL = request.getURL();
@@ -183,7 +181,7 @@
     return new BoundingBox(srs, e);
   }
 
-  public MapRequest createRequest(LayerViewPanel panel) throws IOException, 
KeyManagementException, NoSuchAlgorithmException {
+  public MapRequest createRequest(LayerViewPanel panel) throws IOException {
     MapRequest request = getService().createMapRequest();
     request.setBoundingBox(toBoundingBox(srs, panel.getViewport()
         .getEnvelopeInModelCoordinates()));
@@ -243,7 +241,7 @@
     return blackboard;
   }
 
-  public WMService getService() throws IOException, KeyManagementException, 
NoSuchAlgorithmException {
+  public WMService getService() throws IOException {
     if (service == null) {
       Assert.isTrue(serverURL != null);
       setService(initializedService(serverURL, wmsVersion));
@@ -283,7 +281,7 @@
           envelope.expandToInclude(bb.getEnvelope());
         }
       }
-    } catch (IOException|KeyManagementException|NoSuchAlgorithmException e) {
+    } catch (IOException e) {
       Logger
           .error(
               "WMSLayer envelope calculation failed."

Modified: 
core/trunk/src/com/vividsolutions/jump/workbench/ui/plugin/wms/URLWizardPanel.java
===================================================================
--- 
core/trunk/src/com/vividsolutions/jump/workbench/ui/plugin/wms/URLWizardPanel.java
  2019-02-21 07:21:47 UTC (rev 6133)
+++ 
core/trunk/src/com/vividsolutions/jump/workbench/ui/plugin/wms/URLWizardPanel.java
  2019-02-22 07:35:16 UTC (rev 6134)
@@ -40,8 +40,6 @@
 import java.awt.event.ActionListener;
 import java.io.IOException;
 import java.net.URL;
-import java.security.KeyManagementException;
-import java.security.NoSuchAlgorithmException;
 import java.util.Arrays;
 import java.util.LinkedHashMap;
 import java.util.LinkedHashSet;
@@ -54,7 +52,6 @@
 import javax.swing.JPanel;
 import javax.swing.JRadioButton;
 
-import org.deegree.security.drm.ManagementException;
 import org.openjump.core.ui.plugin.wms.AddWmsLayerWizard;
 import org.openjump.util.UriUtil;
 
@@ -66,7 +63,6 @@
 import com.vividsolutions.jump.workbench.ui.wizard.CancelNextException;
 import com.vividsolutions.jump.workbench.ui.wizard.WizardPanelV2;
 import com.vividsolutions.wms.MapImageFormatChooser;
-import com.vividsolutions.wms.WMSException;
 import com.vividsolutions.wms.WMService;
 
 public class URLWizardPanel extends JPanel implements WizardPanelV2 {
@@ -160,7 +156,7 @@
     return I18N.get(I18N_PREFIX + "please-enter-the-url-of-the-wms-server");
   }
 
-  public void exitingToRight() throws WorkbenchException, 
NoSuchAlgorithmException, KeyManagementException {
+  public void exitingToRight() throws WorkbenchException {
     try {
       String url = urlPanel.getUrl();
       url = UriUtil.urlAddCredentials(url, urlPanel.getUser(), 
urlPanel.getPass());
@@ -203,8 +199,6 @@
       dataMap.put(FORMAT_KEY, format);
       dataMap.put(MapLayerWizardPanel.INITIAL_LAYER_NAMES_KEY, null);
       dataMap.put(VERSION_KEY, wmsVersion);
-    } catch (WMSException e) {
-      throw new CancelNextException(e);
     } catch (IOException e) {
       throw new CancelNextException(e);
     }

Modified: core/trunk/src/com/vividsolutions/wms/AbstractWMSRequest.java
===================================================================
--- core/trunk/src/com/vividsolutions/wms/AbstractWMSRequest.java       
2019-02-21 07:21:47 UTC (rev 6133)
+++ core/trunk/src/com/vividsolutions/wms/AbstractWMSRequest.java       
2019-02-22 07:35:16 UTC (rev 6134)
@@ -1,7 +1,5 @@
 package com.vividsolutions.wms;
 
-import com.vividsolutions.jump.coordsys.CoordinateSystemRegistry;
-import com.vividsolutions.jump.util.Blackboard;
 import java.awt.Image;
 import java.io.IOException;
 import java.io.InputStream;
@@ -9,8 +7,6 @@
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.nio.charset.Charset;
-import java.security.KeyManagementException;
-import java.security.NoSuchAlgorithmException;
 import java.util.List;
 import java.util.Map.Entry;
 
@@ -25,12 +21,11 @@
 import com.vividsolutions.jump.util.FileUtil;
 import com.vividsolutions.jump.workbench.Logger;
 import com.vividsolutions.jump.workbench.ui.network.ProxySettingsOptionsPanel;
-import com.vividsolutions.jump.workbench.ui.plugin.PersistentBlackboardPlugIn;
 
 abstract public class AbstractWMSRequest implements WMSRequest {
 
   protected WMService service;
-  protected String version = WMService.WMS_1_1_1;
+  protected String version;
   protected HttpURLConnection con = null;
 
   protected AbstractWMSRequest(WMService service) {
@@ -64,7 +59,7 @@
    * @return URL
    * @throws MalformedURLException
    */
-  abstract public URL getURL() throws MalformedURLException, 
KeyManagementException, NoSuchAlgorithmException;
+  abstract public URL getURL() throws MalformedURLException;
 
   /**
    * unified way to create a url connection, may be overwritten and modified
@@ -72,7 +67,7 @@
    * @return
    * @throws IOException
    */
-  protected HttpURLConnection prepareConnection() throws IOException, 
KeyManagementException, NoSuchAlgorithmException {
+  protected HttpURLConnection prepareConnection() throws IOException {
     URL requestUrl = getURL();
     con = (HttpURLConnection) requestUrl.openConnection();
 
@@ -102,7 +97,7 @@
    * 
    * @Override
    */
-  public HttpURLConnection getConnection() throws IOException, 
KeyManagementException, NoSuchAlgorithmException {
+  public HttpURLConnection getConnection() throws IOException {
     if (con == null)
       con = prepareConnection();
     return con;
@@ -113,7 +108,7 @@
    * 
    * @return the retrieved map Image
    */
-  public Image getImage() throws IOException, KeyManagementException, 
NoSuchAlgorithmException {
+  public Image getImage() throws IOException {
     HttpURLConnection con = getConnection();
 
     boolean httpOk = con.getResponseCode() == HttpURLConnection.HTTP_OK;
@@ -149,7 +144,7 @@
    * @return
    * @throws IOException
    */
-  public String getText() throws IOException, KeyManagementException, 
NoSuchAlgorithmException {
+  public String getText() throws IOException {
     HttpURLConnection con = getConnection();
     return readConnection(con, 0, false);
   }

Modified: core/trunk/src/com/vividsolutions/wms/FeatureInfoRequest.java
===================================================================
--- core/trunk/src/com/vividsolutions/wms/FeatureInfoRequest.java       
2019-02-21 07:21:47 UTC (rev 6133)
+++ core/trunk/src/com/vividsolutions/wms/FeatureInfoRequest.java       
2019-02-22 07:35:16 UTC (rev 6134)
@@ -5,8 +5,6 @@
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLEncoder;
-import java.security.KeyManagementException;
-import java.security.NoSuchAlgorithmException;
 import java.util.List;
 
 import com.vividsolutions.jts.geom.Envelope;
@@ -25,7 +23,7 @@
   private BoundingBox bbox;
   private int height, width;
 
-  public FeatureInfoRequest(WMSLayer layer) throws IOException, 
KeyManagementException, NoSuchAlgorithmException {
+  public FeatureInfoRequest(WMSLayer layer) throws IOException {
     super(layer.getService());
     this.wmsLayer = layer;
   }
@@ -47,7 +45,7 @@
   }
 
   @Override
-  public URL getURL() throws MalformedURLException, KeyManagementException, 
NoSuchAlgorithmException {
+  public URL getURL() throws MalformedURLException {
     String featInfoUrl = service.getCapabilities().getFeatureInfoURL();
 
     if (featInfoUrl.contains("?")) {
@@ -103,7 +101,7 @@
     String names = "";
     List<String> layerNames = selLayer.getLayerNames();
     for (i = 0; i < layerNames.size(); ++i) {
-      String name = (String) layerNames.get(i);
+      String name = layerNames.get(i);
       try {
         name = URLEncoder.encode(name, "UTF-8");
       } catch (Exception ignored) {

Modified: core/trunk/src/com/vividsolutions/wms/WMSRequest.java
===================================================================
--- core/trunk/src/com/vividsolutions/wms/WMSRequest.java       2019-02-21 
07:21:47 UTC (rev 6133)
+++ core/trunk/src/com/vividsolutions/wms/WMSRequest.java       2019-02-22 
07:35:16 UTC (rev 6134)
@@ -4,16 +4,14 @@
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLConnection;
-import java.security.KeyManagementException;
-import java.security.NoSuchAlgorithmException;
 
 public interface WMSRequest {
 
-  public WMService getService();
+  WMService getService();
   
-  public void setWMSVersion( String wmsVersion );
+  void setWMSVersion( String wmsVersion );
   
-  public URL getURL() throws MalformedURLException, KeyManagementException, 
NoSuchAlgorithmException;
+  URL getURL() throws MalformedURLException;
   
-  public URLConnection getConnection() throws IOException, 
KeyManagementException, NoSuchAlgorithmException;
+  URLConnection getConnection() throws IOException;
 }

Modified: core/trunk/src/com/vividsolutions/wms/WMService.java
===================================================================
--- core/trunk/src/com/vividsolutions/wms/WMService.java        2019-02-21 
07:21:47 UTC (rev 6133)
+++ core/trunk/src/com/vividsolutions/wms/WMService.java        2019-02-22 
07:35:16 UTC (rev 6134)
@@ -81,6 +81,7 @@
    * @param serverUrl
    *          the URL of the WMS server
    * @param wmsVersion
+   *          the WMS version
    */
   public WMService(String serverUrl, String wmsVersion) {
     try {
@@ -105,9 +106,9 @@
   }
 
   /**
-   * @throws IOException
+   * @throws IOException if an error occurs during connection initialization
    */
-  public void initialize() throws IOException, KeyManagementException, 
NoSuchAlgorithmException {
+  public void initialize() throws IOException {
     initialize(false);
   }
 
@@ -121,9 +122,9 @@
    * 
    * @param alertDifferingURL
    *          alert the user if a different GetMap URL is available
-   * @throws IOException
+   * @throws IOException if an error occurs during connection initialization
    */
-  public void initialize(boolean alertDifferingURL) throws IOException, 
NoSuchAlgorithmException, KeyManagementException {
+  public void initialize(boolean alertDifferingURL) throws IOException {
     // [UT]
     String req = "request=capabilities&WMTVER=1.0";
     IParser parser = new ParserWMS1_1();
@@ -157,9 +158,11 @@
       // if the difference is only in credentials then use url1 else ask from
       // user
       if (!compare_url1.equals(compare_url2) && alertDifferingURL) {
-        int resp = showConfirmDialog(null, I18N.getMessage(
-                "com.vididsolutions.wms.WMService.Other-GetMap-URL-Found",
-                new Object[]{url2}), null, YES_NO_OPTION);
+        int resp = showConfirmDialog(
+                null,
+                
I18N.getMessage("com.vididsolutions.wms.WMService.Other-GetMap-URL-Found", 
url2),
+                null,
+                YES_NO_OPTION);
         // nope. user wants to keep the initial url
         if (resp == NO_OPTION) {
           cap.setGetMapURL(url1);
@@ -178,24 +181,24 @@
         cap.setGetMapURL(url1);
       }
     } catch(SSLHandshakeException ex) {
-      int r = JOptionPane.showConfirmDialog(null,
-              
I18N.getMessage("com.vididsolutions.wms.WMService.UnverifiedCertificate", new 
Object[]{
+      int r = JOptionPane.showConfirmDialog(
+              null,
+              
I18N.getMessage("com.vididsolutions.wms.WMService.UnverifiedCertificate",
                       // create a new URL to hide user/password
                       new URL(serverUrl.getProtocol(), serverUrl.getHost(), 
serverUrl.getPort(), serverUrl.getFile())
-              }),
+              ),
               "Confirmation dialog",
-              YES_NO_OPTION,JOptionPane.WARNING_MESSAGE);
+              YES_NO_OPTION,
+              JOptionPane.WARNING_MESSAGE);
 
       if (r==JOptionPane.YES_OPTION) {
-        setTrustOption(true, serverUrl);
+        try {
+          setTrustOption(true, serverUrl);
+        } catch(KeyManagementException|NoSuchAlgorithmException ex2) {
+          throw new IOException(ex2);
+        }
         initialize(alertDifferingURL);
-      } else throw ex;
-      //null, I18N.getMessage(
-//          "com.vividsolutions.wms.WMService.WMS-Not-Found",
-//          new Object[] { e.getLocalizedMessage() }), I18N
-//          .get("com.vividsolutions.wms.WMService.Error"),
-//          JOptionPane.ERROR_MESSAGE);
-//      throw e;
+      } else throw new IOException(ex);
     }
 
     // [2016.01 ede] deactivated the error handling here as it leads to an
@@ -222,12 +225,12 @@
 //    }
   }
 
-  TrustManager trm = new X509TrustManager() {
+  private TrustManager trm = new X509TrustManager() {
     public X509Certificate[] getAcceptedIssuers() { return null; }
     public void checkClientTrusted(X509Certificate[] certs, String authType) { 
}
     public void checkServerTrusted(X509Certificate[] certs, String authType) { 
}
   };
-  Set<URL> trustedURLs = new HashSet<>();
+  private Set<URL> trustedURLs = new HashSet<>();
 
   private void setTrustOption(boolean trust, URL url)
           throws KeyManagementException, NoSuchAlgorithmException {

Modified: core/trunk/src/com/vividsolutions/wms/ui/WMSViewer.java
===================================================================
--- core/trunk/src/com/vividsolutions/wms/ui/WMSViewer.java     2019-02-21 
07:21:47 UTC (rev 6133)
+++ core/trunk/src/com/vividsolutions/wms/ui/WMSViewer.java     2019-02-22 
07:35:16 UTC (rev 6134)
@@ -1,7 +1,3 @@
-
-
-
-
 /*
  * The Unified Mapping Platform (JUMP) is an extensible, interactive GUI 
  * for visualizing and manipulating spatial features with geometry and 
attributes.
@@ -39,10 +35,7 @@
 import java.awt.*;
 import java.awt.event.*;
 import java.io.IOException;
-import java.security.KeyManagementException;
-import java.security.NoSuchAlgorithmException;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Iterator;
 
 import javax.swing.*;
@@ -213,7 +206,7 @@
         disconnectButton.setEnabled( true );
         getImageButton.setEnabled( true );
         connected = true;
-      } catch( IOException| KeyManagementException| NoSuchAlgorithmException 
ioe ) {
+      } catch( IOException ioe ) {
         // failed to connect and retrieve capabilities
 
       }

Modified: core/trunk/src/org/openjump/core/ui/plugin/wms/WMSLegendPlugIn.java
===================================================================
--- core/trunk/src/org/openjump/core/ui/plugin/wms/WMSLegendPlugIn.java 
2019-02-21 07:21:47 UTC (rev 6133)
+++ core/trunk/src/org/openjump/core/ui/plugin/wms/WMSLegendPlugIn.java 
2019-02-22 07:35:16 UTC (rev 6134)
@@ -13,8 +13,6 @@
 import java.io.IOException;
 import java.net.MalformedURLException;
 import java.net.URL;
-import java.security.KeyManagementException;
-import java.security.NoSuchAlgorithmException;
 import java.util.List;
 
 import javax.imageio.ImageIO;
@@ -107,19 +105,13 @@
             @Override
             public void actionPerformed(ActionEvent e) {
                 save(scrollPane);
-                // frame.dispose();
-                return;
             }
         });
 
         closeButton.addActionListener(new java.awt.event.ActionListener() {
-
             @Override
             public void actionPerformed(ActionEvent e) {
-
                 frame.dispose();
-
-                return;
             }
         });
 
@@ -249,7 +241,7 @@
     private final String CLOSE = I18N
             .get("ui.plugin.imagery.ImageLayerManagerDialog.Close");
 
-    public JPanel getLegendPanel(PlugInContext context) throws IOException, 
KeyManagementException, NoSuchAlgorithmException {
+    public JPanel getLegendPanel(PlugInContext context) throws IOException {
 
         final JPanel mainPanel = new JPanel(new GridBagLayout());
         final WMSLayer layer = (WMSLayer) LayerTools.getSelectedLayerable(
@@ -267,7 +259,7 @@
             final JLabel nameLabel = new JLabel(
                     I18N.getMessage(
                             
"org.openjump.core.ui.plugin.queries.SimpleQuery.layer" + ": {0}", //$NON-NLS-1$
-                            new Object[] { layerTitle }));
+                            layerTitle));
             nameLabel.setHorizontalAlignment(JLabel.CENTER);
 
             nameLabel.setFont(new Font("Verdana", Font.BOLD, 16));
@@ -283,7 +275,7 @@
             final Image image = req.getImage();
             final ImageIcon legendIcon = new ImageIcon(image);
 
-            if (/* getStyles(context, layerName) != null && */legendIcon != 
null) {
+            if (legendIcon != null) {
                 final JLabel labelIcon = new JLabel(legendIcon, JLabel.CENTER);
                 mainPanel.add(labelIcon, BorderLayout.SOUTH);
             } else {



_______________________________________________
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel

Reply via email to