Revision: 6392
          http://sourceforge.net/p/jump-pilot/code/6392
Author:   edso
Date:     2020-08-27 13:49:49 +0000 (Thu, 27 Aug 2020)
Log Message:
-----------
bugfix #491 WMS getCapability without title

Modified Paths:
--------------
    core/trunk/ChangeLog
    core/trunk/src/com/vividsolutions/wms/AbstractParser.java
    core/trunk/src/com/vividsolutions/wms/AbstractWMSRequest.java
    core/trunk/src/com/vividsolutions/wms/Parser.java

Modified: core/trunk/ChangeLog
===================================================================
--- core/trunk/ChangeLog        2020-08-27 08:07:43 UTC (rev 6391)
+++ core/trunk/ChangeLog        2020-08-27 13:49:49 UTC (rev 6392)
@@ -4,6 +4,9 @@
 # 3. be concise but convey the change in a way that ordinary users understand
 #<-------------------------------- 80 chars 
---------------------------------->#
 
+2020-08-27 ede
+  * bugfix #491 WMS getCapability without title
+
 2020-08-26 ede
   * reworked FlexDateParser speedup to enable caching selectively
 

Modified: core/trunk/src/com/vividsolutions/wms/AbstractParser.java
===================================================================
--- core/trunk/src/com/vividsolutions/wms/AbstractParser.java   2020-08-27 
08:07:43 UTC (rev 6391)
+++ core/trunk/src/com/vividsolutions/wms/AbstractParser.java   2020-08-27 
13:49:49 UTC (rev 6392)
@@ -129,17 +129,19 @@
     }
     
     protected String getTitle(Document doc) throws IOException {
-        String title = "Untitled";
+        String title = "";
         try {
             title = ((CharacterData)XMLTools.simpleXPath(doc, 
getTitlePath()).getFirstChild()).getData();
-        } catch (NullPointerException e) {
-            // possible NullPointerException if there is no firstChild()
-            // also possible miscast causing an Exception
-            // [uwe dalluege]
-            showMessageDialog(null,
-                    
I18N.getMessage("com.vividsolutions.wms.AbstractParser.wms-parser-not-found", 
getTitlePath()),
-                    null, JOptionPane.INFORMATION_MESSAGE);
-            //throw new IOException( "Element <" + getTitlePath() + "> not 
found, maybe a WMS version problem! " );
+        } catch (Exception e) {
+          // [ede 2020/08] disabled to allow empty service  title tags as 
requested in bug #491
+          Logger.warn("service <Title/> unset or empty.", e);
+          // possible NullPointerException if there is no firstChild()
+          // also possible miscast causing an Exception
+          // [uwe dalluege]
+          //  showMessageDialog(null,
+          //          
I18N.getMessage("com.vividsolutions.wms.AbstractParser.wms-parser-not-found", 
getTitlePath()),
+          //          null, JOptionPane.INFORMATION_MESSAGE);
+          //throw new IOException( "Element <" + getTitlePath() + "> not 
found, maybe a WMS version problem! " );
         }
         return title;
     }

Modified: core/trunk/src/com/vividsolutions/wms/AbstractWMSRequest.java
===================================================================
--- core/trunk/src/com/vividsolutions/wms/AbstractWMSRequest.java       
2020-08-27 08:07:43 UTC (rev 6391)
+++ core/trunk/src/com/vividsolutions/wms/AbstractWMSRequest.java       
2020-08-27 13:49:49 UTC (rev 6392)
@@ -167,6 +167,8 @@
     // get correct stream
     InputStream in = httpOk ? con.getInputStream() : con.getErrorStream();
 
+    //Logger.trace(con.getURL().toString());
+
     String contentType = con.getContentType();
     Charset charset = Charset.forName("UTF-8");
     try {

Modified: core/trunk/src/com/vividsolutions/wms/Parser.java
===================================================================
--- core/trunk/src/com/vividsolutions/wms/Parser.java   2020-08-27 08:07:43 UTC 
(rev 6391)
+++ core/trunk/src/com/vividsolutions/wms/Parser.java   2020-08-27 13:49:49 UTC 
(rev 6392)
@@ -1,7 +1,3 @@
-
-
-
-
 /*
  * The Unified Mapping Platform (JUMP) is an extensible, interactive GUI 
  * for visualizing and manipulating spatial features with geometry and 
attributes.
@@ -68,6 +64,8 @@
 /**
  * Pulls WMS objects out of the XML
  * @author Chris Hodgson chodg...@refractions.net
+ * 
+ * @deprecated unused and can probably be deleted, kept for reference only
  */
 public class Parser {
 
@@ -274,7 +272,7 @@
   }
   private Capabilities parseCapabilities_1_0_0( WMService service, InputStream 
inStream ) throws IOException {
       MapLayer topLayer = null;
-      String title = null;
+      String title = "";
       LinkedList<String> formatList = new LinkedList<String>();
       Document doc;
       
@@ -294,9 +292,11 @@
       } catch (Exception e) {
         // possible NullPointerException if there is no firstChild()
         // also possible miscast causing an Exception
-       
-          //   [uwe dalluege]
-          throw new IOException( "Maybe wrong Capabilities Version! " );
+      
+        // [ede 2020/08] disabled to allow empty title tags as requested in 
bug #491
+        //throw new IOException( "Maybe wrong Capabilities Version! " );
+        
+        Logger.warn("<Title/> unset or empty.", e);
       }
       
       // get the supported file formats
@@ -321,7 +321,7 @@
   
   private Capabilities parseCapabilities_1_1_1( WMService service, InputStream 
inStream ) throws IOException {
       MapLayer topLayer = null;
-      String title = null;
+      String title = "";
       String getMapURL, getFeatureInfoURL;
       LinkedList<String> formatList = new LinkedList<String>();
       Document doc;
@@ -362,14 +362,15 @@
         }
         throw new WMSException("Unexpected answer from server. Missing node 
<WMT_MS_Capabilities>.", str);
       }
-      
+
       // get the title
       try {
         title = ((CharacterData)XMLTools.simpleXPath( doc, 
"WMT_MS_Capabilities/Service/Title" ).getFirstChild()).getData();
       } catch (Exception e) {
-        title = "not available";
+        // eat it, not set or empty
+        Logger.warn("<Title/> unset or empty.", e);
       }
-      
+
       // get the supported file formats                        // UT was 
"WMT_MS_Capabilities/Capability/Request/Map/Format"
       final Node formatNode = XMLTools.simpleXPath( doc, 
"WMT_MS_Capabilities/Capability/Request/GetMap" );
 



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

Reply via email to