Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.remoteclient / src / main / java / org / gvsig / remoteclient / ogc / OGCServiceInformation.java @ 40769

History | View | Annotate | Download (4.18 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
 
25
package org.gvsig.remoteclient.ogc;
26

    
27
import java.util.HashMap;
28
import java.util.Hashtable;
29
import java.util.Iterator;
30

    
31

    
32

    
33
public abstract class OGCServiceInformation {
34
        public String online_resource = null;
35
        protected HashMap operationsGet = new HashMap();
36
        protected HashMap operationsPost = new HashMap();
37
        
38

    
39
        /**
40
         * @return Returns the online_resource.
41
         */
42
         public String getOnline_resource() {
43
                return online_resource;
44
        }
45

    
46
         public abstract OGCClientOperation createOperation(String name);
47
         public abstract OGCClientOperation createOperation(String name, String onlineResource);
48
        /**
49
         * Add a new supported operation
50
         * @param operation
51
         * The operation to support
52
         * @param protocol
53
         * The HTTP protocol (Get or Post)
54
         */
55
        public void addOperation(String operation, int protocol){
56
                if (protocol == OGCClientOperation.PROTOCOL_GET){
57
                        operationsGet.put(operation, createOperation(operation));                        
58
                }else if (protocol == OGCClientOperation.PROTOCOL_POST){
59
                        operationsPost.put(operation, createOperation(operation));
60
                }
61
        }
62
        
63
        /**
64
         * Add a new supported operation
65
         * @param operation
66
         * The operation to support
67
         * @param protocol
68
         * The HTTP protocol (Get or Post)
69
         * @param onlineResource
70
         * The online resource
71
         */
72
        public void addOperation(String operation, int protocol, String onlineResource){
73
                if (protocol == OGCClientOperation.PROTOCOL_GET){
74
                        operationsGet.put(operation, createOperation(operation, onlineResource));
75
                }else if (protocol == OGCClientOperation.PROTOCOL_POST){
76
                        operationsPost.put(operation, createOperation(operation, onlineResource));
77
                }
78
        }
79
        
80
        /**
81
         * Gest the online resource for a concrete operation
82
         * @param operation
83
         * The operation
84
         * @param protocol
85
         * The HTTP protocol (Get or Post)
86
         * @return
87
         * The online resource
88
         */
89
        public String getOnlineResource(String operation, int protocol){
90
                OGCClientOperation op = null;
91
                if (protocol == OGCClientOperation.PROTOCOL_GET){
92
                        op = (OGCClientOperation)operationsGet.get(operation);
93
                }else if (protocol == OGCClientOperation.PROTOCOL_POST){
94
                        op = (OGCClientOperation)operationsPost.get(operation);
95
                }
96
                if ((op == null) ||
97
                                (op.getOnlineResource() == null) || 
98
                                (op.getOnlineResource().equals(""))){
99
                        return null;
100
                }
101
                return op.getOnlineResource();
102
        }
103
        
104
        /**
105
         * Gets the online resource for a concrete operation.
106
         * The default protocol is GET
107
         * @param operation
108
         * The operation
109
         * @return
110
         * The online resource
111
         */
112
        public String getOnlineResource(String operation){
113
                return getOnlineResource(operation, OGCClientOperation.PROTOCOL_GET);
114
        }
115
        
116
        /**
117
         * Get a hash map with the supported operations
118
         * @return
119
         */
120
        public Hashtable getSupportedOperationsByName(){
121
                Hashtable operations = new Hashtable();
122
                Iterator getIt = operationsGet.keySet().iterator();
123
                while (getIt.hasNext()){
124
                        String id = (String)getIt.next();
125
                        OGCClientOperation operation = (OGCClientOperation)operationsGet.get(id);
126
                        operations.put(operation.getOperationName(),
127
                                        operation.getOnlineResource());
128
                }
129
                return operations;
130
        }
131
        
132
        public boolean isOperationSupported(String operationName){
133
            if (operationsGet.containsKey(operationName)){
134
                return true;
135
            }
136
            if (operationsPost.containsKey(operationName)){
137
            return true;
138
        }
139
            return false;
140
        }        
141
}
142