gvsig-raster / org.gvsig.raster.wmts / trunk / org.gvsig.raster.wmts / org.gvsig.raster.wmts.ogc / org.gvsig.raster.wmts.ogc.impl / src / main / java / org / gvsig / raster / wmts / ogc / impl / struct / WMTSOperationsMetadataImpl.java @ 1961
History | View | Annotate | Download (4.18 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
*/
|
22 |
package org.gvsig.raster.wmts.ogc.impl.struct; |
23 |
|
24 |
import java.util.HashMap; |
25 |
import java.util.Hashtable; |
26 |
import java.util.Iterator; |
27 |
|
28 |
import org.gvsig.raster.wmts.ogc.impl.Tags; |
29 |
import org.gvsig.raster.wmts.ogc.impl.base.WMTSOperation; |
30 |
import org.gvsig.raster.wmts.ogc.struct.WMTSOperationsMetadata; |
31 |
|
32 |
|
33 |
|
34 |
/**
|
35 |
* Metadata about the operations specified by this service and
|
36 |
* implemented by the current server, including the URLs for operation request.
|
37 |
*
|
38 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
39 |
*/
|
40 |
public abstract class WMTSOperationsMetadataImpl extends WMTSBaseStruct implements WMTSOperationsMetadata { |
41 |
public String online_resource = null; |
42 |
protected HashMap<String, WMTSOperation> operationsGet = new HashMap<String, WMTSOperation>(); |
43 |
protected HashMap<String, WMTSOperation> operationsPost = new HashMap<String, WMTSOperation>(); |
44 |
|
45 |
/**
|
46 |
* @return Returns the online_resource.
|
47 |
*/
|
48 |
public String getOnline_resource() { |
49 |
return online_resource;
|
50 |
} |
51 |
|
52 |
public WMTSOperation createOperation(String name) { |
53 |
return new WMTSOperation(name); |
54 |
} |
55 |
|
56 |
public WMTSOperation createOperation(String name, String onlineResource) { |
57 |
return new WMTSOperation(name, onlineResource); |
58 |
} |
59 |
|
60 |
/**
|
61 |
* Add a new supported operation
|
62 |
* @param operation
|
63 |
* The operation to support
|
64 |
* @param protocol
|
65 |
* The HTTP protocol (Get or Post)
|
66 |
*/
|
67 |
public void addOperation(String operation, int protocol) { |
68 |
if (protocol == Tags.PROTOCOL_GET) {
|
69 |
operationsGet.put(operation, createOperation(operation)); |
70 |
} else if (protocol == Tags.PROTOCOL_POST) { |
71 |
operationsPost.put(operation, createOperation(operation)); |
72 |
} |
73 |
} |
74 |
|
75 |
/**
|
76 |
* Add a new supported operation
|
77 |
* @param operation
|
78 |
* The operation to support
|
79 |
* @param protocol
|
80 |
* The HTTP protocol (Get or Post)
|
81 |
* @param onlineResource
|
82 |
* The online resource
|
83 |
*/
|
84 |
public void addOperation(String operation, int protocol, String onlineResource) { |
85 |
if (protocol == Tags.PROTOCOL_GET) {
|
86 |
operationsGet.put(operation, createOperation(operation, onlineResource)); |
87 |
}else if (protocol == Tags.PROTOCOL_POST){ |
88 |
operationsPost.put(operation, createOperation(operation, onlineResource)); |
89 |
} |
90 |
} |
91 |
|
92 |
public String getOnlineResource(String operation, int protocol) { |
93 |
WMTSOperation op = null;
|
94 |
if (protocol == Tags.PROTOCOL_GET) {
|
95 |
op = (WMTSOperation)operationsGet.get(operation); |
96 |
} else if (protocol == Tags.PROTOCOL_POST) { |
97 |
op = (WMTSOperation)operationsPost.get(operation); |
98 |
} |
99 |
if ((op == null) || |
100 |
(op.getOnlineResource() == null) ||
|
101 |
(op.getOnlineResource().equals(""))) {
|
102 |
return null; |
103 |
} |
104 |
return op.getOnlineResource();
|
105 |
} |
106 |
|
107 |
public String getOnlineResource(String operation) { |
108 |
return getOnlineResource(operation, Tags.PROTOCOL_GET);
|
109 |
} |
110 |
|
111 |
public Hashtable<String, String> getSupportedOperationsByName() { |
112 |
Hashtable<String, String> operations = new Hashtable<String, String>(); |
113 |
Iterator<String> getIt = operationsGet.keySet().iterator(); |
114 |
while (getIt.hasNext()) {
|
115 |
String id = (String)getIt.next(); |
116 |
WMTSOperation operation = (WMTSOperation)operationsGet.get(id); |
117 |
operations.put(operation.getOperationName(), |
118 |
operation.getOnlineResource()); |
119 |
} |
120 |
return operations;
|
121 |
} |
122 |
|
123 |
public boolean isOperationSupported(String operationName) { |
124 |
if (operationsGet.containsKey(operationName)) {
|
125 |
return true; |
126 |
} |
127 |
if (operationsPost.containsKey(operationName)) {
|
128 |
return true; |
129 |
} |
130 |
return false; |
131 |
} |
132 |
} |