Revision 22616

View differences:

branches/v10/extensions/extPublishGeoserver/src/org/gvsig/publish/geoserver/model/GeoserverFeature.java
47 47
import java.net.URL;
48 48

  
49 49
import org.gvsig.publish.PublishLogger;
50
import org.gvsig.publish.exceptions.LayerInfoNotAvailableException;
51 50
import org.gvsig.publish.exceptions.PublishException;
52 51
import org.gvsig.publish.geoserver.conf.GSDatastore;
53 52
import org.gvsig.publish.geoserver.conf.GSFeature;
......
76 75
	private String namespacePrefix =null;
77 76
	public static final String REGISTER_TAG="geoserver_feature";
78 77
	private boolean cacheEnabled=true;
79
    private int cacheMaxage=3600;
80
    private int numDecimals=0;
81
    
78
	private int cacheMaxage=3600;
79
	private int numDecimals=0;
80

  
82 81
	/**
83 82
	 * constructor
84 83
	 * @param service
......
93 92
	 * Also overrides the method in order to avoid the creation of nested resources 
94 93
	 * @see org.gvsig.publish.serversmodel.RemoteResource#setLayerInfo(org.gvsig.publish.infoproject.ILayerInfo)
95 94
	 */
96
	
95

  
97 96
	public void setLayerInfo(ILayerInfo ilayer) {
98 97
		super.setLayerInfo(ilayer);
99
		try {
100
			setNamespacePrefix(getLayerInfo().getDataSource().getNamespacePrefix());
101
			setName(getFeatureTypeName());
102
			setTitle(getLayerInfo().getTitle());
103
			setAbstract("generated by gvSIG");
104
		} catch (LayerInfoNotAvailableException e) {
105
			PublishLogger.getLog().error("ERROR " + getClassName() + " :Cannot initialize the Remote resurce" , e);
106
		}
107
		
98
		setNamespacePrefix(getLayerInfo().getDataSource().getNamespacePrefix());
99
		setName(getFeatureTypeName());
100
		setTitle(getLayerInfo().getTitle());
101
		setAbstract("generated by gvSIG");
108 102
	}
109 103
	/**
110 104
	 * 
111 105
	 * @return feature name in Geoserver. It's the filename without extension for files or tablename for databases
112
	 * @throws LayerInfoNotAvailableException 
106
	 * 
113 107
	 */
114
	private String getFeatureTypeName() throws LayerInfoNotAvailableException{
108
	private String getFeatureTypeName() {
115 109
		String aux="unknowfeature";
116 110
		IDataSourceInfo ds = getLayerInfo().getDataSource();
117 111
		if (ds instanceof IFileInfo){
......
132 126
	public String getClassName() {		
133 127
		return "GeoserverFeature";
134 128
	}
135
		
129

  
136 130
	/**
137 131
	 * 
138 132
	 * @see org.gvsig.publish.serversmodel.RemoteResource#publish()
139 133
	 */
140 134
	public void publish() throws PublishException{		
141
		//adds this feature to the server configuration
142
		try {
143
			addFeatureToConfig();
144
		} catch (LayerInfoNotAvailableException e) {			
145
			remove();
146
			throw new PublishException("publish_infolayer_not_available");			
147
		}
135
		//adds this feature to the server configuration		
136
		addFeatureToConfig(); 
148 137
		//adds its childs to the server configuration
149 138
		super.publish();
150 139
	}
151 140
	/**
152 141
	 * Adds this remote resource into the server configuration
153
	 * @throws PublishException 
154
	 * @throws LayerInfoNotAvailableException 
142
	 * @throws PublishException  
155 143
	 */
156
	private void addFeatureToConfig() throws PublishException, LayerInfoNotAvailableException {
144
	private void addFeatureToConfig() throws PublishException{
157 145
		GSFeature config = new GSFeature(this);
158 146
		//create namespace
159 147
		GSNamespace ns = create_namespace();
......
165 153
		config.setDatastore(ds);
166 154
		config.setNamespace(ns);
167 155
		config.setStyle(st);
168
		
156

  
169 157
		//adds feature
170 158
		Geoserver server= (Geoserver) getService().getServer();
171
		
159

  
172 160
		boolean isadded = server.getConfiguration().addFeatureType(config);
173 161
		if (isadded == false && getLayerInfo().getDataSource().getType()==IDataSourceInfo.SHAPE_TYPE){
174 162
			PublishLogger.getLog().error("ERROR GeoserverFeature: cannot add a feature because you can't have two features with the same shapefile in the same namespace");
......
195 183
	 * 
196 184
	 * @param ns
197 185
	 * @return
198
	 * @throws LayerInfoNotAvailableException 
199 186
	 */
200
	private GSDatastore create_datastore(GSFeature feature, GSNamespace ns) throws LayerInfoNotAvailableException{
187
	private GSDatastore create_datastore(GSFeature feature, GSNamespace ns) {
201 188
		GSDatastore ds = new GSDatastore();
202 189
		ds.setNamespace(ns);
203 190
		IDataSourceInfo dataSrc = getLayerInfo().getDataSource();		
......
209 196
		}
210 197
		return ds;
211 198
	}
212
	
213
	private void config_datastore_postgis(GSFeature feature, GSDatastore ds) throws LayerInfoNotAvailableException {
199
	/**
200
	 * Creates the datastore configuration for Geoserver
201
	 * 
202
	 * @param feature
203
	 * @param ds
204
	 */
205
	private void config_datastore_postgis(GSFeature feature, GSDatastore ds) {
214 206
		String ds_id  = ((IDataBaseInfo)getLayerInfo().getDataSource()).getConnectionName();
215 207
		ds_id  = ds_id + "_" + ((IDataBaseInfo)getLayerInfo().getDataSource()).getSchemaName();
216 208
		ds.setId(ds_id);
......
228 220
		String id = getLayerInfo().getDataSource().getNamespacePrefix() + "_" + ((IDataBaseInfo)getLayerInfo().getDataSource()).getTableName();
229 221
		feature.setId(id);
230 222
	}
231
	private void config_datastore_shape(GSFeature feature, GSDatastore ds) throws LayerInfoNotAvailableException {
232
		
223
	/**
224
	 * Creates the datastore configuration for Geoserver
225
	 * @param feature
226
	 * @param ds
227
	 * 
228
	 */
229
	private void config_datastore_shape(GSFeature feature, GSDatastore ds) {
230

  
233 231
		ds.setId(((IFileInfo)getLayerInfo().getDataSource()).getFilenameWithoutExtension());
234 232
		//TODO: get this from IDatasourceInfo
235 233
		ds.setCharset("UTF-8");		
......
245 243
		feature.setId(id);
246 244
	}
247 245
	/**
246
	 * Creates the style configuration for Geoserver 
248 247
	 * 
249 248
	 * @return
250
	 * @throws LayerInfoNotAvailableException 
249
	 * 
251 250
	 */
252
	private GSStyle create_style() throws LayerInfoNotAvailableException{
251
	private GSStyle create_style(){
253 252
		//create style
254 253
		GSStyle st = new GSStyle();
255 254
		st.setId(getId());
......
258 257
		}
259 258
		return st;
260 259
	}
261
	
260

  
262 261
	/*
263 262
	 * (non-Javadoc)
264 263
	 * @see org.gvsig.publish.serversmodel.RemoteResource#getRegisterTag()
265 264
	 */
266 265
	public String getRegisterTag() {
267
		
266

  
268 267
		return REGISTER_TAG;
269 268
	}
270 269
	/*
......
272 271
	 * @see org.gvsig.publish.ogcmetadata.IOGCCommonMetadata#getAbstract()
273 272
	 */
274 273
	public String getAbstract() {
275
		
274

  
276 275
		return ogcMetadata.getAbstract();
277 276
	}
278 277
	/*
......
280 279
	 * @see org.gvsig.publish.ogcmetadata.IOGCCommonMetadata#getName()
281 280
	 */
282 281
	public String getName() {
283
		
282

  
284 283
		return ogcMetadata.getName();
285 284
	}
286 285
	/*
......
288 287
	 * @see org.gvsig.publish.ogcmetadata.IOGCCommonMetadata#getTitle()
289 288
	 */
290 289
	public String getTitle() {
291
		
290

  
292 291
		return ogcMetadata.getTitle();
293 292
	}
294 293
	/*
......
304 303
	 */
305 304
	public void setName(String name) {
306 305
		ogcMetadata.setName(name);
307
		
306

  
308 307
	}
309 308
	/*
310 309
	 * (non-Javadoc)
......
324 323
	 * (non-Javadoc)
325 324
	 * @see java.lang.Object#toString()
326 325
	 */
327
    public String toString(){
328
    	return getTitle();
329
    }
330
    /* (non-Javadoc)
326
	public String toString(){
327
		return getTitle();
328
	}
329
	/* (non-Javadoc)
331 330
	 * @see org.gvsig.publish.serversmodel.RemoteResource#getXMLEntity()
332 331
	 */
333
	
332

  
334 333
	public XMLEntity getXMLEntity() {
335 334
		XMLEntity xml=super.getXMLEntity();
336 335
		//put version and name
......
351 350
	/* (non-Javadoc)
352 351
	 * @see org.gvsig.publish.serversmodel.RemoteResource#setXMLEntity(com.iver.utiles.XMLEntity)
353 352
	 */
354
	
353

  
355 354
	public void setXMLEntity(XMLEntity xml) {
356 355
		//check version
357 356
		int version = xml.getIntProperty("version");
......
368 367
		setCacheEnabled(xml.getBooleanProperty("is_cached"));
369 368
		setCacheMaxage(xml.getIntProperty("cache_maxage"));
370 369
	}
371
	
370

  
372 371
	/**
373 372
	 * @return the cacheEnabled
374 373
	 */
......
424 423
	public void setNamespacePrefix(String namespacePrefix) {
425 424
		this.namespacePrefix = namespacePrefix;
426 425
	}
427
		
426

  
428 427
}
branches/v10/extensions/extPublishGeoserver/src/org/gvsig/publish/geoserver/model/Geoserver.java
43 43
import java.io.File;
44 44

  
45 45
import org.gvsig.publish.PublishLogger;
46
import org.gvsig.publish.exceptions.LayerInfoNotAvailableException;
47 46
import org.gvsig.publish.exceptions.PublishException;
48 47
import org.gvsig.publish.geoserver.conf.GSConfiguration;
49 48
import org.gvsig.publish.serversmodel.Server;
......
134 133
		//generate services configuration
135 134
		super.publish();
136 135
		//write configuration
137
		try {
138
			configuration.toXML();
139
		} catch (LayerInfoNotAvailableException e) {
140
			throw new PublishException("publish_infolayer_not_available");
141
		}
136
		configuration.toXML();
142 137
		return "publishgs_publish_message";
143 138
	}
144 139
	/**
branches/v10/extensions/extPublishGeoserver/src/org/gvsig/publish/geoserver/conf/GSConfiguration.java
52 52
import java.util.Map;
53 53

  
54 54
import org.gvsig.publish.PublishLogger;
55
import org.gvsig.publish.exceptions.LayerInfoNotAvailableException;
56 55
import org.gvsig.publish.geoserver.model.Geoserver;
57 56

  
58 57
/**
......
158 157

  
159 158
	/**
160 159
	 * Writes the Geoserver config files
161
	 * @throws LayerInfoNotAvailableException 
162 160
	 * 
163 161
	 */
164
	public void toXML() throws LayerInfoNotAvailableException {        
162
	public void toXML(){        
165 163
		File dir = model.getConfigDirectory();
166 164
		//generates catalog.xml
167 165
		File catalog_xml = new File(dir.getAbsolutePath() + File.separator +"catalog.xml");
branches/v10/extensions/extPublishGeoserver/src/org/gvsig/publish/geoserver/conf/GSFeature.java
50 50
import javax.xml.parsers.ParserConfigurationException;
51 51

  
52 52
import org.gvsig.publish.PublishLogger;
53
import org.gvsig.publish.exceptions.LayerInfoNotAvailableException;
54 53
import org.gvsig.publish.geoserver.model.GeoserverFeature;
55 54
import org.w3c.dom.Document;
56 55
import org.w3c.dom.Element;
......
133 132
	 * It creates a directory with the name "datastore_feature" and puts the info.xml inside of it. 
134 133
	 * 
135 134
	 * @param dir directory where are placed all the feature's configurations 
136
	 * @throws LayerInfoNotAvailableException 
135
	 *  
137 136
	 * 
138 137
	 */
139
    public void toXML(File dir) throws LayerInfoNotAvailableException{    	
138
    public void toXML(File dir){    	
140 139
    	String aux = getId();
141 140
    	//String aux = getDatastore().getId() + "_" + getId();
142 141
    	//String aux = getNamespace().getPrefix() + "_" + getId();
branches/v10/extensions/extPublishGeoserver/src-test/org/gvsig/publish/geoserver/conf/GSConfigurationTest.java
46 46

  
47 47
import junit.framework.TestCase;
48 48

  
49
import org.gvsig.publish.exceptions.LayerInfoNotAvailableException;
50 49
import org.gvsig.publish.exceptions.PublishException;
51 50
import org.gvsig.publish.geoserver.model.Geoserver;
52 51
import org.gvsig.publish.geoserver.model.GeoserverWFSService;
......
81 80
	 * Writes global configuration
82 81
	 * @throws LayerInfoNotAvailableException 
83 82
	 */
84
	public void test_generateGlobalConfiguration() throws LayerInfoNotAvailableException{
83
	public void test_generateGlobalConfiguration() {
85 84
		GSConfiguration conf = new GSConfiguration(geoserver);				
86 85
		conf.toXML();
87 86
	}
......
89 88
	 * Writes wfs configuration
90 89
	 * @throws LayerInfoNotAvailableException 
91 90
	 */
92
	public void test_generateWFSConfiguration() throws LayerInfoNotAvailableException{
91
	public void test_generateWFSConfiguration() {
93 92
		GSConfiguration conf = new GSConfiguration(geoserver);		
94 93
		conf.getGlobals().setWFSService(geoserverwfs);
95 94
		conf.toXML();
branches/v10/extensions/extPublishMapserver/src/org/gvsig/publish/mapserver/model/wcs/MapserverWCSLayer.java
41 41
package org.gvsig.publish.mapserver.model.wcs;
42 42

  
43 43
import org.gvsig.publish.PublishLogger;
44
import org.gvsig.publish.exceptions.LayerInfoNotAvailableException;
45 44
import org.gvsig.publish.exceptions.PublishException;
46 45
import org.gvsig.publish.infoproject.IDataSourceInfo;
47 46
import org.gvsig.publish.infoproject.ILayerInfo;
......
79 78
	 */
80 79
	public void setLayerInfo(ILayerInfo layerInfo) {
81 80
		super.setLayerInfo(layerInfo);		
82
		try {
83
			setName(getLayerInfo().getName());
84
			setTitle(getLayerInfo().getTitle());
85
			setAbstract("generated by gvSIG");
86
		} catch (LayerInfoNotAvailableException e) {
87
			PublishLogger.getLog().error("ERROR " + getClassName() + " : Cannot initialize layer info", e);
88
		}
89
		
81
		setName(getLayerInfo().getName());
82
		setTitle(getLayerInfo().getTitle());
83
		setAbstract("generated by gvSIG");
90 84
	}
91 85
	private Mapserver getMapServer(){
92 86
		//Cast to Mapserver
93 87
		Mapserver mapserver = (Mapserver)getService().getServer();
94 88
		return mapserver;
95 89
	}
96
	
90

  
97 91
	/**
98 92
	 * Generates a new layer configuration in the mapfile when is invoked
99 93
	 * @see org.gvsig.publish.serversmodel.RemoteResource#publish()
......
101 95
	public void publish() throws PublishException {	
102 96
		config = new MapFile.Layer();
103 97
		getMapServer().getConfigFile().add(config);
104
		try {
105
			generateLayerSection();
106
		} catch (LayerInfoNotAvailableException e) {
107
			throw new PublishException("publish_infolayer_not_available");
108
		}
98

  
99
		generateLayerSection();
100

  
109 101
		//publish all its childs		
110 102
		super.publish();
111 103
	}
112
	private void generateLayerSection() throws PublishException, LayerInfoNotAvailableException{
104
	private void generateLayerSection() throws PublishException{
113 105
		//LAYER
114 106
		config.name = getName();
115 107
		config.status = "ON";
......
120 112
		config.connection = MapserverUtilities.getConnectionParameter(getLayerInfo().getDataSource());
121 113
		config.transparency = getLayerInfo().getOpacityPercent();
122 114
		config.dump = true;		
123
						
115

  
124 116
		//PROJECTION 		
125 117
		config.layercrs = new CRS(getLayerInfo().getDataSource().getEPSG(),true);				
126 118
		//METADATA
......
129 121
	}
130 122
	/**
131 123
	 * Generates the LAYER->DATA parameter 
132
	 * @throws LayerInfoNotAvailableException 
124
	 * 
133 125
	 */
134
	private void generateDataParameter() throws LayerInfoNotAvailableException {
126
	private void generateDataParameter() {
135 127
		IDataSourceInfo ds = getLayerInfo().getDataSource();
136 128
		if (ds.getType() == IDataSourceInfo.POSTGIS_TYPE){
137 129
			IDataBaseInfo db = (IDataBaseInfo)ds;
......
142 134
		}				
143 135
	}
144 136

  
145
	
137

  
146 138
	/**
147 139
	 * Generates the METADATA object
148 140
	 * @param mapLayer
149 141
	 * @throws LayerInfoNotAvailableException 
150 142
	 */
151
	private void generateMetadata(Layer mapLayer) throws LayerInfoNotAvailableException{
143
	private void generateMetadata(Layer mapLayer) {
152 144
		//add metadata
153 145
		mapLayer.metadata.wcs_name = getName();
154 146
		mapLayer.metadata.wcs_label =getTitle();
......
162 154
		mapLayer.metadata.wcs_nativeformat = MapserverUtilities.getOutputformatName(ds);
163 155
		mapLayer.metadata.wcs_rangeset_axes = "bands";
164 156
	}
165
	
157

  
166 158
	public String getClassName() {
167 159
		return "MapserverWCSLayer";
168 160
	}
......
191 183
		XMLEntity child = xml.firstChild("name","ogcmetadata");
192 184
		ogcMetadata.setXMLEntity(child.getChild(0));		
193 185
	}
194
	
186

  
195 187
	/*
196 188
	 * (non-Javadoc)
197 189
	 * @see org.gvsig.publish.serversmodel.RemoteResource#getRegisterTag()
......
204 196
	 * @see org.gvsig.publish.ogcmetadata.IOGCCommonMetadata#getAbstract()
205 197
	 */
206 198
	public String getAbstract() {
207
		
199

  
208 200
		return ogcMetadata.getAbstract();
209 201
	}
210 202
	/*
......
212 204
	 * @see org.gvsig.publish.ogcmetadata.IOGCCommonMetadata#getName()
213 205
	 */
214 206
	public String getName() {
215
		
207

  
216 208
		return ogcMetadata.getName();
217 209
	}
218 210
	/*
......
220 212
	 * @see org.gvsig.publish.ogcmetadata.IOGCCommonMetadata#getTitle()
221 213
	 */
222 214
	public String getTitle() {
223
		
215

  
224 216
		return ogcMetadata.getTitle();
225 217
	}
226 218
	/*
branches/v10/extensions/extPublishMapserver/src/org/gvsig/publish/mapserver/model/wcs/MapserverWCS.java
45 45
import java.util.Hashtable;
46 46

  
47 47
import org.gvsig.publish.PublishLogger;
48
import org.gvsig.publish.exceptions.LayerInfoNotAvailableException;
49 48
import org.gvsig.publish.exceptions.PublishException;
50 49
import org.gvsig.publish.infoproject.FilterProjectInfo;
51 50
import org.gvsig.publish.infoproject.IDataSourceInfo;
......
67 66
 */
68 67
public class MapserverWCS extends Service implements IOGCServiceMetadata{
69 68
	public static String REGISTER_TAG="WCS 1.0.0";
70
	
69

  
71 70
	//Associations
72 71
	private OGCServiceMetadata ogcMetadata= null;
73 72

  
......
90 89
	public void publish() throws PublishException {
91 90
		//publish all the remote resources
92 91
		super.publish();
93
		
94 92
		//gets the mapfile from the server
95 93
		ConfigFile mapfile = getMapServer().getConfigFile();
96 94
		//generate outputformats
97
		try {
98
			generateOutputformats();
99
		} catch (LayerInfoNotAvailableException e) {
100
			throw new PublishException("publish_infolayer_not_available");
101
		}
102
		
95
		generateOutputformats();
103 96
		//generates the code into the MAP->WEB->METADATA
104 97
		mapfile.web.metadata.wcs_label = getTitle();
105 98
		mapfile.web.metadata.wcs_description = getAbstract();
......
107 100
		mapfile.web.metadata.wcs_encoding ="utf8";				
108 101
	}
109 102

  
110
	
103

  
111 104
	/**
112 105
	 * Generate the outputformat objects in the mapfile.
113 106
	 * <p>
114 107
	 * we put the datasources in a hashmap in order to avoid duplicated outputformats 
115
	 * @throws LayerInfoNotAvailableException 
108
	 *  
116 109
	 */
117
	private void generateOutputformats() throws LayerInfoNotAvailableException {
110
	private void generateOutputformats() {
118 111
		Hashtable table = new Hashtable();
119 112
		for (int i= 0; i < getRemoteResourcesCount(); i++){
120 113
			RemoteResource r = getRemoteResource(i);
......
130 123
			String mimetype = MapserverUtilities.getOutputformatMimetype(ds);
131 124
			String imagemode = MapserverUtilities.getOutputformatImageMode(ds);
132 125
			String extension = MapserverUtilities.getOuputformatExtension(ds);			
133
			
126

  
134 127
			if (name !=null && driver !=null){
135 128
				OutputFormat of = new OutputFormat(name,driver,imagemode,extension,mimetype);
136 129
				getMapServer().getConfigFile().add(of);
137 130
			}						
138
				
131

  
139 132
		}
140 133

  
141 134
	}	
......
174 167
		//put version and name 
175 168
		xml.setName(getClassName());
176 169
		xml.putProperty("version", getVersion());
177
		
170

  
178 171
		//p?t its associations
179 172
		XMLEntity child = new XMLEntity();
180 173
		child.setName("ogcmetadata");
......
200 193
	 * @see org.gvsig.publish.serversmodel.Service#getId()
201 194
	 */
202 195
	public String getId() {
203
		
196

  
204 197
		return "mapserver_wcs";
205 198
	}
206 199

  
......
209 202
	 * @see org.gvsig.publish.serversmodel.Service#getRegisterTag()
210 203
	 */
211 204
	public String getRegisterTag() {
212
		
205

  
213 206
		return REGISTER_TAG;
214 207
	}
215 208
	/*
......
217 210
	 * @see org.gvsig.publish.ogcmetadata.IOGCServiceMetadata#getOnlineResource()
218 211
	 */
219 212
	public URL getOnlineResource() {
220
		
213

  
221 214
		return ogcMetadata.getOnlineResource();
222 215
	}
223 216
	/*
......
226 219
	 */
227 220
	public void setOnlineResource(URL url) {
228 221
		ogcMetadata.setOnlineResource(url);
229
		
222

  
230 223
	}
231 224
	/*
232 225
	 * (non-Javadoc)
......
255 248
	 */
256 249
	public void setName(String name) {
257 250
		ogcMetadata.setName(name);
258
		
251

  
259 252
	}
260 253
	/*
261 254
	 * (non-Javadoc)
......
263 256
	 */
264 257
	public void setTitle(String title) {
265 258
		ogcMetadata.setTitle(title);
266
		
259

  
267 260
	}
268 261
	/*
269 262
	 * (non-Javadoc)
......
279 272
	 * @see org.gvsig.publish.ogcmetadata.IOGCCommonMetadata#getTitle()
280 273
	 */
281 274
	public String getTitle() {
282
		
275

  
283 276
		return ogcMetadata.getTitle();
284 277
	}
285 278
	/*
branches/v10/extensions/extPublishMapserver/src/org/gvsig/publish/mapserver/model/wfs/MapserverWFSLayer.java
43 43
import java.awt.geom.Rectangle2D;
44 44

  
45 45
import org.gvsig.publish.PublishLogger;
46
import org.gvsig.publish.exceptions.LayerInfoNotAvailableException;
47 46
import org.gvsig.publish.exceptions.PublishException;
48 47
import org.gvsig.publish.infoproject.IDataSourceInfo;
49 48
import org.gvsig.publish.infoproject.ILayerInfo;
......
74 73
		super(service);
75 74
		ogcMetadata = new OGCCommonMetadata();		
76 75
	}
77
	
76

  
78 77
	/**
79 78
	 * Initializes the remote resource name and title with the name and title of the layer
80 79
	 *
......
82 81
	 */
83 82
	public void setLayerInfo(ILayerInfo layerInfo) {
84 83
		super.setLayerInfo(layerInfo);
85
		try {
86
			setName(getLayerInfo().getName());
87
			setTitle(getLayerInfo().getTitle());
88
			setAbstract("generated by gvSIG");
89
		} catch (LayerInfoNotAvailableException e) {
90
			PublishLogger.getLog().error("ERROR " + getClassName() + " : Cannot initialize layer info", e);
91
		}
92
		
84
		setName(getLayerInfo().getName());
85
		setTitle(getLayerInfo().getTitle());
86
		setAbstract("generated by gvSIG");	
93 87
	}
94 88

  
95 89
	/**
......
99 93
	public void publish() throws PublishException {
100 94
		config = new MapFile.Layer();
101 95
		getMapServer().getConfigFile().add(config);
102
		try {
103
			generateLayerSection();
104
		} catch (LayerInfoNotAvailableException e) {
105
			throw new PublishException("publish_infolayer_not_available");
106
		}
96
		generateLayerSection();
107 97
		//publish all its childs		
108 98
		super.publish();
109

  
110 99
	}
111
	private void generateLayerSection() throws PublishException, LayerInfoNotAvailableException{
100
	/**
101
	 * Creates the object MAP->LAYER
102
	 * @throws PublishException
103
	 */
104
	private void generateLayerSection() throws PublishException{
112 105
		//LAYER
113 106
		config.name = getName();
114 107
		config.status = "ON";
......
118 111
		config.connectiontype = MapserverUtilities.getConnectionTypeParameter(getLayerInfo().getDataSource());
119 112
		config.connection = MapserverUtilities.getConnectionParameter(getLayerInfo().getDataSource());		
120 113
		config.dump = true;		
121
						
114

  
122 115
		//PROJECTION 		
123 116
		config.layercrs = new CRS(getLayerInfo().getDataSource().getEPSG(),true);				
124 117
		//METADATA
......
127 120
	}
128 121
	/**
129 122
	 * Generates the LAYER->DATA parameter 
130
	 * @throws LayerInfoNotAvailableException 
123
	 *  
131 124
	 */
132
	private void generateDataParameter() throws LayerInfoNotAvailableException {
125
	private void generateDataParameter(){
133 126
		IDataSourceInfo ds = getLayerInfo().getDataSource();
134 127
		if (ds.getType() == IDataSourceInfo.POSTGIS_TYPE){
135 128
			IDataBaseInfo db = (IDataBaseInfo)ds;
......
149 142
		Mapserver mapserver = (Mapserver)getService().getServer();
150 143
		return mapserver;
151 144
	}
152
		/**
145
	/**
153 146
	 * Generates the METADATA object
154 147
	 * @param mapLayer
155
		 * @throws LayerInfoNotAvailableException 
156 148
	 */
157
	private void generateMetadata(Layer mapLayer) throws LayerInfoNotAvailableException{
149
	private void generateMetadata(Layer mapLayer){
158 150
		//add metadata
159 151
		mapLayer.metadata.wfs_name = getName();
160 152
		mapLayer.metadata.wfs_title = getTitle();
......
209 201
		ogcMetadata.setXMLEntity(child.getChild(0));		
210 202
//		child = xml.firstChild("name","mapserverlayer");
211 203
//		layerMapserver.setXMLEntity(child.getChild(0));
212
		
204

  
213 205
	}
214
	
206

  
215 207
	/*
216 208
	 * (non-Javadoc)
217 209
	 * @see org.gvsig.publish.serversmodel.RemoteResource#getRegisterTag()
branches/v10/extensions/extPublishMapserver/src/org/gvsig/publish/mapserver/model/wms/MapserverWMSLayer.java
46 46
import java.io.IOException;
47 47

  
48 48
import org.gvsig.publish.PublishLogger;
49
import org.gvsig.publish.exceptions.LayerInfoNotAvailableException;
50 49
import org.gvsig.publish.exceptions.PublishException;
51 50
import org.gvsig.publish.infoproject.IDataSourceInfo;
52 51
import org.gvsig.publish.infoproject.ILayerInfo;
......
118 117
	 */
119 118
	public void setLayerInfo(ILayerInfo layerInfo) {
120 119
		super.setLayerInfo(layerInfo);
121
		try {
122
			setName(getLayerInfo().getName());
123
			setTitle(getLayerInfo().getTitle());
124
			setAbstract("generated by gvSIG");
125
		} catch (LayerInfoNotAvailableException e) {
126
			PublishLogger.getLog().error("ERROR " + getClassName() + " : Cannot initialize layer info", e);
127
		}
128
		
120
		setName(getLayerInfo().getName());
121
		setTitle(getLayerInfo().getTitle());
122
		setAbstract("generated by gvSIG");
129 123
	}
130
	
124

  
131 125
	private Mapserver getMapServer(){
132 126
		//Cast to Mapserver
133 127
		Mapserver mapserver = (Mapserver)getService().getServer();
......
140 134
	public void publish() throws PublishException{
141 135
		//only for no group layers
142 136
		//TODO: wms_group_abstract ...
143
		try {
144
			if (getLayerInfo().getDataSource() != null){
145
				config = new MapFile.Layer();
146
				getMapfile().add(config);
147
				generateLayerSection();
148
			}
149
		} catch (LayerInfoNotAvailableException e) {		
150
			throw new PublishException("publish_infolayer_not_available");
151
		}
152 137

  
138
		if (getLayerInfo().getDataSource() != null){
139
			config = new MapFile.Layer();
140
			getMapfile().add(config);
141
			generateLayerSection();
142
		}
153 143
		//publish all its childs		
154 144
		super.publish();
155 145
	}
156
	
157
	private void generateLayerSection() throws PublishException, LayerInfoNotAvailableException{		
158
		
146

  
147
	private void generateLayerSection() throws PublishException{		
148

  
159 149
		config.name = getName();
160 150
		config.status = "ON";
161 151
		config.debug = getMapServer().isDebug();
......
167 157
		config.minscale = new Double(getLayerInfo().getMinscale()).toString();
168 158
		config.transparency = getLayerInfo().getOpacityPercent();
169 159
		config.dump = isQueryable();		
170
		
160

  
171 161
		//mosaic 
172 162
		generateMosaicSection();
173 163
		//labeling
......
175 165
		//PROJECTION (I must query the layer to know the shape projection)
176 166
		//lyr.layercrs = new CRS(getLayerInfo().getEPSG(),true);
177 167
		config.layercrs = new CRS(getLayerInfo().getDataSource().getEPSG(),true);
178
		
168

  
179 169
		//CLASS
180 170
		generateClassSection();
181 171
		//METADATA
......
184 174
	}
185 175
	/**
186 176
	 * Generates the LAYER->DATA parameter 
187
	 * @throws LayerInfoNotAvailableException 
177
	 *  
188 178
	 */
189
	private void generateDataParameter() throws LayerInfoNotAvailableException {
179
	private void generateDataParameter(){
190 180
		IDataSourceInfo ds = getLayerInfo().getDataSource();
191 181
		if (ds.getType() == IDataSourceInfo.POSTGIS_TYPE){
192 182
			IDataBaseInfo db = (IDataBaseInfo)ds;
......
201 191
		}				
202 192
	}
203 193

  
204
	private void generateMosaicSection() throws LayerInfoNotAvailableException {
194
	private void generateMosaicSection(){
205 195
		if (getSpecificParams().isMosaic()){
206 196
			config.type = "RASTER";
207 197
			config.tileIndex = getService().getServer().getPublication().getServerSideFilePath(getLayerInfo().getDataSource());
208 198
			config.data = null;
209 199
			config.classList.clear();
210 200
			config.tileItem="location";
211
		}
212
		
201
		}		
213 202
	}
214 203

  
215 204
	/**
216 205
	 * TODO:
217 206
	 * lyr.labelsizeitem = getLayerInfo().getLabeling().getLabelHeightField();
218 207
	 * lyr.labelangleitem = getLayerInfo().getLabeling().getLabelRotationField();
219
	 * @throws LayerInfoNotAvailableException 
208
	 *  
220 209
	 */
221
	private void generateLabelingSection() throws LayerInfoNotAvailableException{
210
	private void generateLabelingSection(){
222 211
		if (getLayerInfo().getLabeling() != null){
223
			config.labelitem = getLayerInfo().getLabeling().getLabelField();
224
			
212
			config.labelitem = getLayerInfo().getLabeling().getLabelField();			
225 213
		}		
226 214
	}
227
	private void generateClassSection() throws PublishException, LayerInfoNotAvailableException{
215
	/**
216
	 * Generates object MAP->LAYER->CLASS
217
	 * @throws PublishException 
218
	 * 
219
	 */
220
	private void generateClassSection() throws PublishException{
228 221
		//CLASS
229 222
		Object source = getLayerInfo().getLegend();		
230 223
		if(source instanceof ISingleSymbolLegendInfo){
......
241 234
		}
242 235
	}
243 236

  
244
	private void generateSingleLegend(ISingleSymbolLegendInfo legend, Layer lyr) throws PublishException, LayerInfoNotAvailableException {
237
	private void generateSingleLegend(ISingleSymbolLegendInfo legend, Layer lyr) throws PublishException{
245 238
		ISymbolInfo isymbol =  legend.getSymbolInfo();		
246 239
		lyr.classList.clear();
247 240
		MapClass clase = new MapClass();		
......
254 247
		//put labeling if exists
255 248
		if ( getLayerInfo().getLabeling().getLabelField() != null){
256 249
			generateSymbol(getLayerInfo().getLabeling().getSymbolInfo(), clase);
257
			
250

  
258 251
		}
259 252
		//add the class into the layer
260 253
		lyr.addClass(clase);		
......
268 261
	 * @param lyr
269 262
	 * The layer
270 263
	 * @throws PublishException 
271
	 * @throws LayerInfoNotAvailableException 
264
	 * 
265
	 * 
272 266
	 */
273
	private void generateIntervalLegend(IIntervalLegendInfo legend, Layer lyr) throws PublishException, LayerInfoNotAvailableException {
267
	private void generateIntervalLegend(IIntervalLegendInfo legend, Layer lyr) throws PublishException{
274 268
		//check if is labeled
275 269
		boolean islabeled = false;
276 270
		if ( getLayerInfo().getLabeling().getLabelField() != null){
277 271
			islabeled = true;
278 272
		}
279
		
273

  
280 274
		String[] expressions = legend.getExpressions();
281 275
		for (int i=0 ; i<expressions.length ; i++){
282 276
			ISymbolInfo isymbol = legend.getSymbolByExpression(expressions[i]);
......
292 286
		}
293 287
	}
294 288

  
295
	private void generateUniqueLegend(IUniqueValuesLegendInfo legend, Layer lyr) throws PublishException, LayerInfoNotAvailableException {
289
	private void generateUniqueLegend(IUniqueValuesLegendInfo legend, Layer lyr) throws PublishException{
296 290
		//check if is labeled
297 291
		boolean islabeled = false;
298 292
		if ( getLayerInfo().getLabeling().getLabelField() != null){
......
318 312
		}
319 313
	}
320 314

  
321
	private void generateStyle(ISymbolInfo isymbol, MapClass clase) throws PublishException, LayerInfoNotAvailableException{		
315
	private void generateStyle(ISymbolInfo isymbol, MapClass clase) throws PublishException{		
322 316
		if (getLayerInfo().getDataSource().getDataType() == IDataSourceInfo.POINT_DATA){
323 317
			//I can do a cast to Marker Symbol
324 318
			IMarkerSymbolInfo pointSymbol = (IMarkerSymbolInfo)isymbol;
......
337 331

  
338 332
	}
339 333

  
340
	private void generateSymbol(ITextSymbolInfo textSymbol, MapClass clase) throws LayerInfoNotAvailableException{
334
	private void generateSymbol(ITextSymbolInfo textSymbol, MapClass clase){
341 335
		clase.etiqueta = new Label();
342 336
		//TODO: change by getColor()
343 337
		Color c = textSymbol.getFontColor();
......
369 363
			Mapserver m = (Mapserver)getService().getServer();
370 364
			String s = m.getMapfileFile().getParentFile().getAbsolutePath();
371 365
			File dst = new File(s+ File.separator+ icon.getName());
372
			
366

  
373 367
			try {
374 368
				FileUtils.copy(icon, dst);
375 369
			} catch (IOException e) {			
376 370
				throw new PublishException("cannot_copy_icons");			
377 371
			}
378 372
		}
379
		
373

  
380 374
	}
381 375
	/**
382 376
	 * In Mapserver is impossible to have a dashed outline 
......
409 403
	/**
410 404
	 * Generates the METADATA object
411 405
	 * @param mapLayer
412
	 * @throws LayerInfoNotAvailableException 
406
	 * 
413 407
	 */
414
	private void generateMetadata(Layer mapLayer) throws LayerInfoNotAvailableException{
408
	private void generateMetadata(Layer mapLayer){
415 409
		//add metadata
416 410
		mapLayer.metadata.wms_name = getName();
417 411
		mapLayer.metadata.wms_title =getTitle();
......
421 415
		mapLayer.metadata.wms_extent = bbox;
422 416
		mapLayer.metadata.gml_include_items = "all";	 
423 417
		//adding layer_group
424
	
418

  
425 419
		if (getLayerInfo().getPathString().equals("/")==false){
426 420
			String aux2 = getLayerInfo().getPathString();
427 421
			mapLayer.metadata.wms_layer_group = aux2.substring(0,aux2.length()-1);
428 422
		}
429 423
	}
430
	
424

  
431 425
	/*
432 426
	 * (non-Javadoc)
433 427
	 * @see com.iver.utiles.IPersistance#getClassName()
branches/v10/extensions/extPublishMapserver/src/org/gvsig/publish/mapserver/model/wms/MapserverWMS.java
47 47
import java.util.Set;
48 48

  
49 49
import org.gvsig.publish.PublishLogger;
50
import org.gvsig.publish.exceptions.LayerInfoNotAvailableException;
51 50
import org.gvsig.publish.exceptions.PublishException;
52 51
import org.gvsig.publish.infoproject.FilterProjectInfo;
53 52
import org.gvsig.publish.infoproject.IDataSourceInfo;
......
118 117
		for (int i= 0; i < getRemoteResourcesCount(); i++){
119 118
			RemoteResource r = getRemoteResource(i);
120 119
			IDataSourceInfo ds;
121
			try {
122
				ds = r.getLayerInfo().getDataSource();
123
				if (ds != null){
124
					String epsg = ds.getEPSG();			
125
					set.add(epsg);
126
				}			
127
			} catch (LayerInfoNotAvailableException e) {
128
				
129
			}
120
			ds = r.getLayerInfo().getDataSource();
121
			if (ds != null){
122
				String epsg = ds.getEPSG();			
123
				set.add(epsg);
124
			}			
130 125
		} 
131 126
		Iterator i = set.iterator();
132 127
		ConfigFile mapfile = getMapServer().getConfigFile();
branches/v10/extensions/extPublishMapserver/src/org/gvsig/publish/mapserver/gui/wms/MSWMSLayerAdvancedPanel.java
44 44

  
45 45
import javax.swing.JPanel;
46 46

  
47
import org.gvsig.publish.exceptions.LayerInfoNotAvailableException;
48 47
import org.gvsig.publish.gui.publish.IPublishPluginPanel;
49 48
import org.gvsig.publish.infoproject.IDataSourceInfo;
50 49
import org.gvsig.publish.mapserver.model.wms.MapserverWMSLayer;
......
60 59
		initComponents();
61 60
		initLabels();
62 61
	}
63
    private void initLabels() {
62
	private void initLabels() {
64 63
		// 
65
		
64

  
66 65
	}
67
    private void initComponents() {
68
        java.awt.GridBagConstraints gridBagConstraints;
66
	private void initComponents() {
67
		java.awt.GridBagConstraints gridBagConstraints;
69 68

  
70
        jSeparator1 = new javax.swing.JSeparator();
71
        ogcpanel = new org.gvsig.publish.gui.ogcMetadata.OGCLayerMetadataPanel();
72
        mapserverpanel = new org.gvsig.publish.mapserver.gui.common.MapserverLayerPanel();
69
		jSeparator1 = new javax.swing.JSeparator();
70
		ogcpanel = new org.gvsig.publish.gui.ogcMetadata.OGCLayerMetadataPanel();
71
		mapserverpanel = new org.gvsig.publish.mapserver.gui.common.MapserverLayerPanel();
73 72

  
74
        setLayout(new java.awt.GridBagLayout());
75
        gridBagConstraints = new java.awt.GridBagConstraints();
76
        gridBagConstraints.gridx = 0;
77
        gridBagConstraints.gridy = 1;
78
        gridBagConstraints.gridwidth = 3;
79
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
80
        gridBagConstraints.weightx = 1.0;
81
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
82
        add(jSeparator1, gridBagConstraints);
83
        gridBagConstraints = new java.awt.GridBagConstraints();
84
        gridBagConstraints.gridx = 0;
85
        gridBagConstraints.gridy = 2;
86
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
87
        gridBagConstraints.weightx = 1.0;
88
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
89
        add(ogcpanel, gridBagConstraints);
90
        gridBagConstraints = new java.awt.GridBagConstraints();
91
        gridBagConstraints.gridx = 0;
92
        gridBagConstraints.gridy = 3;
93
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
94
        gridBagConstraints.weightx = 1.0;
95
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
96
        add(mapserverpanel, gridBagConstraints);
97
    }// </editor-fold>
98
    
99
    
100
    // Variables declaration - do not modify
101
    private javax.swing.JSeparator jSeparator1;
102
    private org.gvsig.publish.mapserver.gui.common.MapserverLayerPanel mapserverpanel;
103
    private org.gvsig.publish.gui.ogcMetadata.OGCLayerMetadataPanel ogcpanel;
104
    // End of variables declaration
105
    
106
    /*
107
     * (non-Javadoc)
108
     * @see org.gvsig.publish.gui.publish.IPublishPluginPanel#getModel()
109
     */
73
		setLayout(new java.awt.GridBagLayout());
74
		gridBagConstraints = new java.awt.GridBagConstraints();
75
		gridBagConstraints.gridx = 0;
76
		gridBagConstraints.gridy = 1;
77
		gridBagConstraints.gridwidth = 3;
78
		gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
79
		gridBagConstraints.weightx = 1.0;
80
		gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
81
		add(jSeparator1, gridBagConstraints);
82
		gridBagConstraints = new java.awt.GridBagConstraints();
83
		gridBagConstraints.gridx = 0;
84
		gridBagConstraints.gridy = 2;
85
		gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
86
		gridBagConstraints.weightx = 1.0;
87
		gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
88
		add(ogcpanel, gridBagConstraints);
89
		gridBagConstraints = new java.awt.GridBagConstraints();
90
		gridBagConstraints.gridx = 0;
91
		gridBagConstraints.gridy = 3;
92
		gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
93
		gridBagConstraints.weightx = 1.0;
94
		gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
95
		add(mapserverpanel, gridBagConstraints);
96
	}// </editor-fold>
97

  
98

  
99
	// Variables declaration - do not modify
100
	private javax.swing.JSeparator jSeparator1;
101
	private org.gvsig.publish.mapserver.gui.common.MapserverLayerPanel mapserverpanel;
102
	private org.gvsig.publish.gui.ogcMetadata.OGCLayerMetadataPanel ogcpanel;
103
	// End of variables declaration
104

  
105
	/*
106
	 * (non-Javadoc)
107
	 * @see org.gvsig.publish.gui.publish.IPublishPluginPanel#getModel()
108
	 */
110 109
	public Object getModel() {
111 110
		mapserverpanel.getModel();
112 111
		ogcpanel.getModel();		
......
127 126
	public void setModel(Object entityModel) {
128 127
		// cast
129 128
		model = (MapserverWMSLayer)entityModel;
130
		try {
131
			if (model.getLayerInfo().getDataSource().getType() == IDataSourceInfo.SHAPE_TYPE ){
132
				mapserverpanel.enableMosaicCheckbox(true);
133
			}else{
134
				mapserverpanel.enableMosaicCheckbox(false);
135
			}
136
		} catch (LayerInfoNotAvailableException e) {
137
			model.remove();
138
			return;
129

  
130
		if (model.getLayerInfo().getDataSource().getType() == IDataSourceInfo.SHAPE_TYPE ){
131
			mapserverpanel.enableMosaicCheckbox(true);
132
		}else{
133
			mapserverpanel.enableMosaicCheckbox(false);
139 134
		}
135

  
140 136
		mapserverpanel.setModel(model.getSpecificParams());
141 137
		ogcpanel.setModel(model);
142 138
	}
branches/v10/extensions/extPublish/src-test/org/gvsig/publish/serversmodel/RemoteResourceTest.java
47 47

  
48 48
import org.gvsig.publish.PublishRegister;
49 49
import org.gvsig.publish.exceptions.InvalidRemoteResourceException;
50
import org.gvsig.publish.exceptions.LayerInfoNotAvailableException;
51 50
import org.gvsig.publish.exceptions.PublishException;
52 51
import org.gvsig.publish.infoproject.ILayerInfo;
53 52
import org.gvsig.publish.infoproject.IProjectInfo;
......
136 135
		assertNotNull(parent.getService());
137 136
	}
138 137

  
139
	public void testGetLayerInfo() throws LayerInfoNotAvailableException {
138
	public void testGetLayerInfo() { 
140 139
		assertNotNull(parent.getLayerInfo());
141 140
	}
142 141

  
branches/v10/extensions/extPublish/config/text.properties
22 22
publish_add_resource=A?adir recurso
23 23
#publish 
24 24
publish_publish=Publicar
25
publish_publication_has_changed=La publicaci?n ha cambiado
26
publish_layerinfo_not_available=Algunas capas han sido renombradas o eliminadas de una vista y se han eliminado de la publicaci?n:
25 27
#common metadata
26 28
publish_name=Nombre
27 29
publish_title=T?tulo
branches/v10/extensions/extPublish/config/text_en.properties
39 39
publish_online_resource=Onlineresource
40 40
#layer wms
41 41
publish_layer_wms111=WMS 1.1.1 Layer properties
42
publish_is_queryable=Queryable
42
publish_is_queryable=Queryable
43
publish_publication_has_changed=Publication modified
44
publish_layerinfo_not_available=Some layers have been renamed or removed from some view and they are been removed from the publication
branches/v10/extensions/extPublish/build.number
1 1
#Build Number for ANT. Do not edit!
2
#Fri Jul 25 09:51:10 GMT+01:00 2008
3
build.number=12
2
#Tue Jul 29 08:11:09 GMT+01:00 2008
3
build.number=13
branches/v10/extensions/extPublish/src/org/gvsig/publish/gui/publish/PublishController.java
68 68
 *
69 69
 */
70 70
public class PublishController implements ActionListener, Observer {
71
	/*
72
	 * Events 
73
	 */
71
	//events
74 72
	public static final String PUBLISH_EVENT_ACCEPT="accept_publish";
75 73
	public static final String PUBLISH_EVENT_CANCEL="cancel_publish";
76

  
77
	/*
78
	 * Main window
79
	 */
74
	//associations
80 75
	private PublishWindow window = null;
81
	/*
82
	 * Active publication
83
	 */	
84 76
	private Publication publication = null;
85
	/*
86
	 * Plugin controller
87
	 */
88
	IPublishPluginController pluginCtrl = null;
77
	private IPublishPluginController pluginCtrl = null;
78
	private String initialMessage=null;
79
	
80
	
89 81
	/**
90 82
	 * Constructor
91 83
	 */
......
105 97
	 * @return IWindow 
106 98
	 */
107 99
	public PublishWindow getWindow(){
100
		if (getInitialMessage() != null){
101
			JOptionPane.showMessageDialog(window,				
102
				getInitialMessage(),
103
				PluginServices.getText(this,"publish_publication_has_changed"),
104
				JOptionPane.WARNING_MESSAGE);
105
		}
108 106
		updateWindow();
109 107
		return window;
110 108
	}
......
112 110
	 * Shown the controller's window.
113 111
	 * Preconditions: first you must call setPublication
114 112
	 */
115
	public void showWindow(){
113
	public void showWindow(){		
116 114
		window.showWindow();
117 115
	}	
118 116
	/**
......
200 198
			PublishLogger.getLog().error("ERROR Publish Controller",e);
201 199
		}	
202 200
		window.setPublicationPanel(panel);
203
	}	
201
	}
202
	/**
203
	 * @return the initialMessage
204
	 */
205
	public String getInitialMessage() {
206
		return initialMessage;
207
	}
208
	/**
209
	 * @param initialMessage the initialMessage to set
210
	 */
211
	public void setInitialMessage(String initialMessage) {
212
		this.initialMessage = initialMessage;
213
	}
204 214

  
205 215
}
branches/v10/extensions/extPublish/src/org/gvsig/publish/gui/addResource/AddResourceController.java
56 56
import org.gvsig.publish.infoproject.ILayerInfo;
57 57
import org.gvsig.publish.infoproject.IProjectInfo;
58 58
import org.gvsig.publish.infoproject.IViewInfo;
59
import org.gvsig.publish.infoproject.ProjectInfo;
60 59
import org.gvsig.publish.serversmodel.Publication;
61 60

  
62 61
import com.iver.andami.PluginServices;
branches/v10/extensions/extPublish/src/org/gvsig/publish/serversmodel/RemoteResource.java
48 48
import org.gvsig.publish.IPublishPersistence;
49 49
import org.gvsig.publish.PublishLogger;
50 50
import org.gvsig.publish.PublishRegister;
51
import org.gvsig.publish.exceptions.LayerInfoNotAvailableException;
52 51
import org.gvsig.publish.exceptions.PublishException;
53 52
import org.gvsig.publish.infoproject.ILayerInfo;
54 53

  
......
84 83
	 * 
85 84
	 */
86 85
	public String getId(){
87
		if (id == null){
88
			try {
89
				this.id = getLayerInfo().getName();
90
			} catch (LayerInfoNotAvailableException e) {
91
				PublishLogger.getLog().error("ERROR " + getClassName() + "Cannot generate a unique identifier", e);
92
			}
86
		if (id == null){			
87
				this.id = getLayerInfo().getName();			
93 88
		}
94 89
		return id;
95 90
	}
......
110 105
		return this.service;
111 106
	}
112 107
	/**
108
	 * Preconditions: exists information about the layer. The availability of the information is checked when a 
109
	 * project information is set to the publication 
113 110
	 * 
114 111
	 * @return the layer which represents this remote resource. I can be null if the remote resource has not a layerinfo associated.
115
	 * @throws LayerInfoNotAvailableException 
116
	 * 
112
	 *   
117 113
	 */
118
	public ILayerInfo getLayerInfo() throws LayerInfoNotAvailableException{
114
	public ILayerInfo getLayerInfo() {
119 115
		if (layerInfo == null){
120
			layerInfo = getService().getServer().getPublication().getProjectInfo().findLayer(getId());
116
			layerInfo = getService().getServer().getPublication().getProjectInfo().findLayer(getId());			
121 117
		}
122 118
		return this.layerInfo;
123 119
	}
branches/v10/extensions/extPublish/src/org/gvsig/publish/serversmodel/Publication.java
41 41
package org.gvsig.publish.serversmodel;
42 42

  
43 43
import java.io.File;
44
import java.util.ArrayList;
44 45
import java.util.Observable;
45 46
import java.util.Observer;
46 47

  
......
48 49
import org.gvsig.publish.PublishLogger;
49 50
import org.gvsig.publish.PublishRegister;
50 51
import org.gvsig.publish.infoproject.IDataSourceInfo;
52
import org.gvsig.publish.infoproject.ILayerInfo;
51 53
import org.gvsig.publish.infoproject.IProjectInfo;
52 54
import org.gvsig.publish.infoproject.datasources.IFileInfo;
53 55

  
......
75 77
	private int accessFileMethod = LOCAL_ACCESS;
76 78
	private String localMountPoint;
77 79
	private String remoteMountPoint;
78
	
80

  
79 81
	/**
80 82
	 * Sets the name of the publication
81 83
	 * @param name
......
128 130
	}
129 131

  
130 132
	/**
131
	 * Sets the information about the project to publish
133
	 * Sets the information about the project to publish.
134
	 * If a remote resource hasn't layerinfo it will be 
135
	 * removed from the publication
136
	 * 
132 137
	 * @param projectInfo
138
	 * @return an array of strings with the name of the layers 
139
	 * that have been renamed or deleted
133 140
	 */
134
	public void setProjectInfo(IProjectInfo projectInfo) {
135
		iproject = projectInfo;		
141
	public ArrayList setProjectInfo(IProjectInfo projectInfo) {
142
		iproject = projectInfo;
143
		ArrayList aux = new ArrayList();
144
		Server s = getServer();
145
		if (s !=null){
146
			for (int i = 0; i < s.getServicesCount(); i++){
147
				Service ss = s.getService(i);
148
				for (int j = 0; j < ss.getRemoteResourcesCount(); j++ ){
149
					RemoteResource rr = ss.getRemoteResource(j);
150
					ILayerInfo ilayerinfo=null;				
151
					ilayerinfo = projectInfo.findLayer(rr.getId());				
152
					if (ilayerinfo == null){						
153
						aux.add(rr.getId());
154
						rr.remove();
155
						PublishLogger.getLog().error("Cannot find the layer with name " + rr.getId());
156
					}
157
				}
158
			}
159
		}
160
		return aux;
136 161
	}
137 162
	/**
138 163
	 * 
......
168 193
		xml.putProperty("accessfilemethod", getAccessFileMethod());
169 194
		xml.putProperty("localmountpoint", getLocalMountPoint());
170 195
		xml.putProperty("remotemountpoint", getRemoteMountPoint());
171
		
196

  
172 197
		if (getServer() != null){
173 198
			xml.addChild(getServer().getXMLEntity());
174 199
		}
......
202 227
				setServer(s);
203 228
			}	
204 229
		}
205
						
230

  
206 231
	}
207 232
	/*
208 233
	 * (non-Javadoc)
......
238 263
	public void setAccessFileMethod(int accessFileMethod) {		
239 264
		this.accessFileMethod = accessFileMethod;
240 265
//		if (accessFileMethod == LOCAL_ACCESS){
241
//			setLocalMountPoint(null);
242
//			setRemoteMountPoint(null);
266
//		setLocalMountPoint(null);
267
//		setRemoteMountPoint(null);
243 268
//		}
244 269
		setChanged();
245 270
	}
246
	
271

  
247 272
	/**
248 273
	 * If the publication uses a REMOTE_MOUNT_POINT_ACCESS, this method change the path to a file in order
249 274
	 * to be accessible by a server. 
......
270 295
		}	
271 296
		return  path;		
272 297
	}
273
	
298

  
274 299
	/**
275 300
	 * @param localMountPoint the localMountPoint to set
276 301
	 */
branches/v10/extensions/extPublish/src/org/gvsig/publish/ProjectPublication.java
40 40
 */
41 41
package org.gvsig.publish;
42 42

  
43
import java.util.Iterator;
44

  
43 45
import org.gvsig.publish.gui.properties.PublicationPropertiesController;
44 46
import org.gvsig.publish.gui.publish.PublishController;
45 47
import org.gvsig.publish.gui.selectServer.SelectServerController;
......
47 49
import org.gvsig.publish.infoproject.ProjectInfoFactory;
48 50
import org.gvsig.publish.serversmodel.Publication;
49 51

  
52
import com.iver.andami.PluginServices;
50 53
import com.iver.andami.ui.mdiManager.IWindow;
51 54
import com.iver.cit.gvsig.fmap.DriverException;
52 55
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
......
113 116
	public IWindow createWindow() {
114 117
				 
115 118
		IProjectInfo projectInfo = ProjectInfoFactory.getProjectInfo(getProject());
116
		getPublication().setProjectInfo(projectInfo);
117
		
118
		//Creates the controllers
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff