Statistics
| Revision:

root / branches / v10 / extensions / extPublish / src / org / gvsig / publish / ogcmetadata / OGCServiceMetadata.java @ 21390

History | View | Annotate | Download (4.27 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004-2006 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *   Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Iba?ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *   +34 963862235
28
 *   gvsig@gva.es
29
 *   www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package org.gvsig.publish.ogcmetadata;
42

    
43
import java.net.MalformedURLException;
44
import java.net.URL;
45

    
46
import org.gvsig.publish.IPublishPersistence;
47
import org.gvsig.publish.PublishLogger;
48

    
49
import com.iver.utiles.XMLEntity;
50

    
51
/**
52
 * This class represents a service wms 1.1.1 metadata 
53
 * 
54
 * @author Jos? Vicente Hig?n (josevicente.higon@iver.es)
55
 *
56
 */
57
public class OGCServiceMetadata implements IPublishPersistence, IOGCServiceMetadata {
58

    
59
        private OGCCommonMetadata common = new OGCCommonMetadata(); 
60
        private URL onlineresource = null;        
61
        /*
62
         * (non-Javadoc)
63
         * @see org.gvsig.publish.IPublishPersistence#getVersion()
64
         */
65
        public int getVersion(){
66
                return 1; 
67
        }
68

    
69
        /*
70
         * (non-Javadoc)
71
         * @see com.iver.utiles.IPersistance#setXMLEntity(com.iver.utiles.XMLEntity)
72
         */        
73
        public void setXMLEntity(XMLEntity xml) {
74
                //check version
75
                int version = xml.getIntProperty("version");
76
                if (version != getVersion()){
77
                        PublishLogger.getLog().error("ERROR: " + getVersion() + ": the version doesn't match!");
78
                        return;
79
                }        
80
                //set properties
81
//                try{
82
//                        String onlineresource = xml.getStringProperty("onlineresource");                
83
//                        URL url=null;
84
//                        URL aux=null;
85
//                        try {
86
//                                url = new URL(onlineresource);
87
//                                //auxiliary well formed url
88
//                                aux = new URL("http://");
89
//                        } catch (MalformedURLException e1) {
90
//                                PublishLogger.getLog().error("ERROR: ServiceWMS111: malformed url setting the onlineresource from persistence");
91
//                                setOnlineResource(aux);
92
//                        }
93
//                        setOnlineResource(url);
94
//                }catch(NotExistInXMLEntity e){
95
//                        PublishLogger.getLog().warn("WARNING:" + getClassName() + ": missing onlineresource in persistence", e);
96
//                }
97
                String online = xml.getStringProperty("onlineresource");
98
                if (onlineresource != null){
99
                        URL url = null;
100
                        try {
101
                                url = new URL(online);
102
                                setOnlineResource(url);
103
                        } catch (MalformedURLException e) {
104
                                PublishLogger.getLog().error("WARNING " + getClassName() + " :malformed url setting the onlineresource from persistence");
105
                                setOnlineResource(null);
106
                        }
107
                }
108
                //set associations
109
                common.setXMLEntity(xml.getChild(0));
110
        }
111

    
112

    
113
        public String getClassName() {
114
                return "OGCServiceMetadata";
115
        }
116

    
117

    
118
        public XMLEntity getXMLEntity() {
119
                XMLEntity xml=new XMLEntity();
120
                //put version and name
121
                xml.setName(getClassName());
122
                xml.putProperty("version", getVersion());
123
                //put properties
124
                if (getOnlineResource() != null){
125
                        xml.putProperty("onlineresource", getOnlineResource().toString());
126
                }else{
127
                        xml.putProperty("onlineresource",null);
128
                }
129
                //put associations
130
                xml.addChild(common.getXMLEntity());
131
                return xml;
132
        }
133

    
134

    
135
        public URL getOnlineResource() {
136
                return onlineresource;
137
        }
138

    
139

    
140
        public void setOnlineResource(URL url) {
141
                this.onlineresource = url;
142
        }
143

    
144

    
145
        public String getAbstract() {
146
                return common.getAbstract();
147
        }
148

    
149

    
150
        public String getName() {
151
                return common.getName();
152
        }
153

    
154

    
155
        public String getTitle() {
156
                return common.getTitle();
157
        }
158

    
159
        public void setAbstract(String description) {
160
                this.common.setAbstract(description);
161
        }
162

    
163
        public void setName(String name) {
164
                this.common.setName(name);
165
        }
166

    
167
        public void setTitle(String title) {
168
                this.common.setTitle(title);
169
        }
170

    
171
}