Source Code Cross Referenced for WMSServiceExtension.java in  » GIS » udig-1.1 » net » refractions » udig » catalog » internal » wms » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » GIS » udig 1.1 » net.refractions.udig.catalog.internal.wms 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *    uDig - User Friendly Desktop Internet GIS client
003:         *    http://udig.refractions.net
004:         *    (C) 2004, Refractions Research Inc.
005:         *
006:         *    This library is free software; you can redistribute it and/or
007:         *    modify it under the terms of the GNU Lesser General Public
008:         *    License as published by the Free Software Foundation;
009:         *    version 2.1 of the License.
010:         *
011:         *    This library is distributed in the hope that it will be useful,
012:         *    but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         *    Lesser General Public License for more details.
015:         *
016:         */
017:        package net.refractions.udig.catalog.internal.wms;
018:
019:        import java.io.Serializable;
020:        import java.net.MalformedURLException;
021:        import java.net.URL;
022:        import java.util.HashMap;
023:        import java.util.Map;
024:
025:        import net.refractions.udig.catalog.IService;
026:        import net.refractions.udig.catalog.ServiceExtension2;
027:        import net.refractions.udig.catalog.wms.internal.Messages;
028:
029:        /**
030:         * A service extension for creating WMS Services
031:         * 
032:         * @author David Zwiers, Refractions Research
033:         * @since 0.6
034:         */
035:        public class WMSServiceExtension implements  ServiceExtension2 {
036:
037:            public IService createService(URL id,
038:                    Map<String, Serializable> params) {
039:                if (params == null)
040:                    return null;
041:
042:                if ((!params.containsKey(WMSServiceImpl.WMS_URL_KEY) && id == null)
043:                        && !params.containsKey(WMSServiceImpl.WMS_WMS_KEY)) {
044:                    return null; // nope we don't have a WMS_URL_KEY
045:                }
046:
047:                URL extractedId = extractId(params);
048:                if (extractedId != null) {
049:                    if (id != null)
050:                        return new WMSServiceImpl(id, params);
051:                    else
052:                        return new WMSServiceImpl(extractedId, params);
053:                }
054:
055:                return null;
056:            }
057:
058:            private URL extractId(Map<String, Serializable> params) {
059:                if (params.containsKey(WMSServiceImpl.WMS_URL_KEY)) {
060:                    URL base = null; // base url for service
061:
062:                    if (params.get(WMSServiceImpl.WMS_URL_KEY) instanceof  URL) {
063:                        base = (URL) params.get(WMSServiceImpl.WMS_URL_KEY); // use provided url for base
064:                    } else {
065:                        try {
066:                            base = new URL((String) params
067:                                    .get(WMSServiceImpl.WMS_URL_KEY)); // upcoverting
068:                            // string to
069:                            // url for
070:                            // base
071:                        } catch (MalformedURLException e1) {
072:                            // log this?
073:                            e1.printStackTrace();
074:                            return null;
075:                        }
076:                        params.remove(params.get(WMSServiceImpl.WMS_URL_KEY));
077:                        params.put(WMSServiceImpl.WMS_URL_KEY, base);
078:                    }
079:                    // params now has a valid url
080:
081:                    return base;
082:                }
083:                return null;
084:            }
085:
086:            public Map<String, Serializable> createParams(URL url) {
087:                if (!isWMS(url)) {
088:                    return null;
089:                }
090:
091:                // wms check
092:                Map<String, Serializable> params2 = new HashMap<String, Serializable>();
093:                params2.put(WMSServiceImpl.WMS_URL_KEY, url);
094:
095:                return params2;
096:            }
097:
098:            public static boolean isWMS(URL url) {
099:                return processURL(url) == null;
100:            }
101:
102:            public String reasonForFailure(Map<String, Serializable> params) {
103:                URL id = extractId(params);
104:                if (id == null)
105:                    return Messages.WMSServiceExtension_needsKey
106:                            + WMSServiceImpl.WMS_URL_KEY
107:                            + Messages.WMSServiceExtension_nullValue;
108:                return reasonForFailure(id);
109:            }
110:
111:            public String reasonForFailure(URL url) {
112:                return processURL(url);
113:            }
114:
115:            private static String processURL(URL url) {
116:                if (url == null) {
117:                    return Messages.WMSServiceExtension_nullURL;
118:                }
119:
120:                String PATH = url.getPath();
121:                String QUERY = url.getQuery();
122:                String PROTOCOL = url.getProtocol();
123:                if (PROTOCOL == null || PROTOCOL.indexOf("http") == -1) { //$NON-NLS-1$ supports 'https' too.
124:                    return Messages.WMSServiceExtension_protocol
125:                            + "'" + PROTOCOL + "'"; //$NON-NLS-1$ //$NON-NLS-2$
126:                }
127:                if (QUERY != null
128:                        && QUERY.toUpperCase().indexOf("SERVICE=") != -1) { //$NON-NLS-1$
129:                    int indexOf = QUERY.toUpperCase().indexOf("SERVICE="); //$NON-NLS-1$
130:                    // we have a service! it better be wfs            
131:                    if (QUERY.toUpperCase().indexOf("SERVICE=WMS") == -1) { //$NON-NLS-1$
132:                        int endOfExp = QUERY.indexOf('&', indexOf);
133:                        if (endOfExp == -1)
134:                            endOfExp = QUERY.length();
135:                        if (endOfExp > indexOf + 8)
136:                            return Messages.WMSServiceExtension_badService
137:                                    + QUERY.substring(indexOf + 8, endOfExp);
138:                        else {
139:                            return Messages.WMSServiceExtension_badService + ""; //$NON-NLS-1$
140:                        }
141:                    }
142:                } else if (PATH != null
143:                        && PATH.toUpperCase().indexOf("GEOSERVER/WMS") != -1) { //$NON-NLS-1$
144:                    return null;
145:                }
146:                return null; // try it anyway
147:            }
148:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.