svn-gvsig-desktop / tags / v2_0_0_Build_2020 / libraries / libRemoteServices / src / org / gvsig / remoteclient / ogc / OGCServiceInformation.java @ 33910
History | View | Annotate | Download (3.93 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 |
|
23 |
/*
|
24 |
* AUTHORS (In addition to CIT):
|
25 |
* 2009 Iver T.I. {{Task}}
|
26 |
*/
|
27 |
|
28 |
package org.gvsig.remoteclient.ogc; |
29 |
|
30 |
import java.util.HashMap; |
31 |
import java.util.Hashtable; |
32 |
import java.util.Iterator; |
33 |
|
34 |
|
35 |
|
36 |
public abstract class OGCServiceInformation { |
37 |
public String online_resource = null; |
38 |
protected HashMap operationsGet = new HashMap(); |
39 |
protected HashMap operationsPost = new HashMap(); |
40 |
|
41 |
|
42 |
/**
|
43 |
* @return Returns the online_resource.
|
44 |
*/
|
45 |
public String getOnline_resource() { |
46 |
return online_resource;
|
47 |
} |
48 |
|
49 |
public abstract OGCClientOperation createOperation(String name); |
50 |
public abstract OGCClientOperation createOperation(String name, String onlineResource); |
51 |
/**
|
52 |
* Add a new supported operation
|
53 |
* @param operation
|
54 |
* The operation to support
|
55 |
* @param protocol
|
56 |
* The HTTP protocol (Get or Post)
|
57 |
*/
|
58 |
public void addOperation(String operation, int protocol){ |
59 |
if (protocol == OGCClientOperation.PROTOCOL_GET){
|
60 |
operationsGet.put(operation, createOperation(operation)); |
61 |
}else if (protocol == OGCClientOperation.PROTOCOL_POST){ |
62 |
operationsPost.put(operation, createOperation(operation)); |
63 |
} |
64 |
} |
65 |
|
66 |
/**
|
67 |
* Add a new supported operation
|
68 |
* @param operation
|
69 |
* The operation to support
|
70 |
* @param protocol
|
71 |
* The HTTP protocol (Get or Post)
|
72 |
* @param onlineResource
|
73 |
* The online resource
|
74 |
*/
|
75 |
public void addOperation(String operation, int protocol, String onlineResource){ |
76 |
if (protocol == OGCClientOperation.PROTOCOL_GET){
|
77 |
operationsGet.put(operation, createOperation(operation, onlineResource)); |
78 |
}else if (protocol == OGCClientOperation.PROTOCOL_POST){ |
79 |
operationsPost.put(operation, createOperation(operation, onlineResource)); |
80 |
} |
81 |
} |
82 |
|
83 |
/**
|
84 |
* Gest the online resource for a concrete operation
|
85 |
* @param operation
|
86 |
* The operation
|
87 |
* @param protocol
|
88 |
* The HTTP protocol (Get or Post)
|
89 |
* @return
|
90 |
* The online resource
|
91 |
*/
|
92 |
public String getOnlineResource(String operation, int protocol){ |
93 |
OGCClientOperation op = null;
|
94 |
if (protocol == OGCClientOperation.PROTOCOL_GET){
|
95 |
op = (OGCClientOperation)operationsGet.get(operation); |
96 |
}else if (protocol == OGCClientOperation.PROTOCOL_POST){ |
97 |
op = (OGCClientOperation)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 |
/**
|
108 |
* Gets the online resource for a concrete operation.
|
109 |
* The default protocol is GET
|
110 |
* @param operation
|
111 |
* The operation
|
112 |
* @return
|
113 |
* The online resource
|
114 |
*/
|
115 |
public String getOnlineResource(String operation){ |
116 |
return getOnlineResource(operation, OGCClientOperation.PROTOCOL_GET);
|
117 |
} |
118 |
|
119 |
/**
|
120 |
* Get a hash map with the supported operations
|
121 |
* @return
|
122 |
*/
|
123 |
public Hashtable getSupportedOperationsByName(){ |
124 |
Hashtable operations = new Hashtable(); |
125 |
Iterator getIt = operationsGet.keySet().iterator();
|
126 |
while (getIt.hasNext()){
|
127 |
String id = (String)getIt.next(); |
128 |
OGCClientOperation operation = (OGCClientOperation)operationsGet.get(id); |
129 |
operations.put(operation.getOperationName(), |
130 |
operation.getOnlineResource()); |
131 |
} |
132 |
return operations;
|
133 |
} |
134 |
|
135 |
} |
136 |
|