Revision 32205

View differences:

trunk/extensions/extPublishMapserver/.classpath
12 12
	<classpathentry combineaccessrules="false" kind="src" path="/libFMap"/>
13 13
	<classpathentry combineaccessrules="false" kind="src" path="/appgvSIG"/>
14 14
	<classpathentry combineaccessrules="false" kind="src" path="/libUIComponent"/>
15
	<classpathentry combineaccessrules="false" kind="src" path="/libPublishUtil"/>
15 16
	<classpathentry kind="output" path="bin"/>
16 17
</classpath>
trunk/extensions/extPublishMapserver/src-test/org/gvsig/publish/mapserver/model/MapserverTest.java
48 48

  
49 49
import org.gvsig.publish.mapserver.model.wms.MapserverWMS;
50 50
import org.gvsig.publish.serversmodel.ServerTest;
51
import org.gvsig.publish.util.LocalResourcesTestUtilities;
51
import org.gvsig.publish.test.LocalResourcesTestUtilities;
52 52

  
53 53
public class MapserverTest extends ServerTest {
54 54

  
trunk/extensions/extPublishMapserver/src-test/org/gvsig/publish/mapserver/gui/Test_MapserverGUI.java
90 90
    private static void createModel() throws InvalidRemoteResourceException{
91 91
    	publication = new Publication();
92 92
    	server = new Mapserver();
93
    	try {
94
			server.setServerURL(new URL("http://localhost/cgi-bin/mapserv"));
95
		} catch (MalformedURLException e) {
96
			e.printStackTrace();
97
		}
93
    	server.setAddress("localhost");
94
		server.setPath("/cgi-bin/mapser");
95
		server.setPort(80);
98 96
		publication.setServer(server);
99 97
		service = new MapserverWMS((Mapserver)server);
100 98
		server.addService(service);
trunk/extensions/extPublishMapserver/config/text.properties
22 22

  
23 23
#publishms_mapserver_properties=Propiedades Servidor Mapserver
24 24
#publishms_mapserver_mapname=Nombre del mapa
25
#publishms_name=Nombre 
25
#publishms_name=Nombre 
26

  
27
#cambios en la 1.9
28
mapfile=MapFile
trunk/extensions/extPublishMapserver/config/config.xml
10 10
			active="true"
11 11
			priority="1">
12 12
		</extension>		
13
		<extension class-name="org.gvsig.publish.mapserver.ExportMapfileExtension"
14
			description="Extensión encargada de exportar una vista en formato de Mapserver."
15
			active="true">
16
			<menu text="Vista/export/mapfile"/>
17
		</extension>
18

  
13 19
	</extensions>
14 20
</plugin-config>
trunk/extensions/extPublishMapserver/src/org/gvsig/publish/mapserver/model/MapserverProcess.java
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
 * @author Jos? Vicente Hig?n (jvhigon@gvsig.org)
24
 */
25

  
26
package org.gvsig.publish.mapserver.model;
27

  
28
import java.io.File;
29
import java.io.FileNotFoundException;
30

  
31
import org.gvsig.publish.exceptions.PublishException;
32
import org.gvsig.publish.mapserver.conf.FontsFile;
33
import org.gvsig.publish.mapserver.conf.MapFile;
34
import org.gvsig.publish.mapserver.conf.SymbolsFile;
35
import org.gvsig.publish.mapserver.conf.MapFile.ConfigFile;
36
import org.gvsig.publish.serversmodel.Publication;
37
import org.gvsig.publish.serversmodel.PublicationProcess;
38
import org.gvsig.publish.serversmodel.Service;
39
import org.gvsig.publish.util.PublishUtilFactory;
40
import org.gvsig.publish.util.sync.ISynchronization;
41
import org.gvsig.publish.util.sync.SyncException;
42
import org.gvsig.publish.util.sync.SyncParameter;
43

  
44
import com.iver.utiles.FileUtils;
45
/**
46
 * Publication process implemented by Mapserver. 
47
 * @author jvhigon
48
 *
49
 */
50
public class MapserverProcess extends PublicationProcess {
51
	private Mapserver mapserver;
52
	private ConfigFile mapfile;
53
	private FontsFile.WellKnowFontsFile fonts;
54
	private File fontsfile;
55
	private SymbolsFile.WellKnowSymbolsFile symbols;
56
	private File symbolsfile;
57
	private String src_dir;
58
	/**
59
	 * Constructor
60
	 * 
61
	 * @param mapserver
62
	 */
63
	public MapserverProcess(Mapserver mapserver) {
64
		this.mapserver = mapserver;
65
		this.mapfile = mapserver.getConfigFile();
66
		//The mapfile always is created first in the home directory + publication.getTitle()
67
		this.src_dir = System.getProperty("user.home") + "/" + ".gvSIG-publish/" + mapserver.getPublication().getTitle() ;
68
	}
69
	/*
70
	 * (non-Javadoc)
71
	 * @see org.gvsig.publish.serversmodel.PublicationProcess#run()
72
	 */
73
	public void run() {
74
		try {
75
			File dir = new File(this.src_dir);
76
			if (dir.exists() == false){
77
				dir.mkdirs();
78
			}
79
			mapserver.setMapfileFile(new File(this.src_dir+ "/wms.map"));
80
			
81
			//check if there is anything to publish
82
			if (isCancelled()) return;
83
			notify("publish_checking_services", "", "0");
84
			Thread.sleep(500);
85
			checkServices();
86
			
87
			//creates the symbols file
88
			if (isCancelled()) return;
89
			notify("publish_creating_symbolsfile","", "20");
90
			Thread.sleep(500);
91
			createSymbolFile();
92
			
93
			//creates the fonts file
94
			if (isCancelled()) return;
95
			notify("publish_creating_fotsfile");
96
			Thread.sleep(500);
97
			createFontFile();
98
			
99
			//creates the mapfile
100
			if (isCancelled()) return;
101
			notify("publish_creating_mapfile");
102
			Thread.sleep(500);
103
			createMapfile();
104
			
105
			//generates MAP
106
			if (isCancelled()) return;
107
			notify("publish_generating_MAP");
108
			Thread.sleep(500);
109
			generateMapObject();
110
			
111
			//generates MAP-->WEB
112
			if (isCancelled()) return;
113
			notify("publish_generating_MAP-WEB");
114
			Thread.sleep(500);
115
			generateWebObject();
116
			
117
			//call publish() method publish of its services
118
			if (isCancelled()) return;
119
			notify("publish_publishing_services");
120
			Thread.sleep(500);
121
			publishServices();
122
			
123
			//write the configuration
124
			if (isCancelled()) return;
125
			notify("publish_writting_configuration");
126
			Thread.sleep(500);
127
			writeConfiguration();
128
			
129
			//synchronize
130
			if (isCancelled()) return;
131
			notify("publish_synchronizing_configuration", "90");
132
			Thread.sleep(500);
133
			
134
			synchronize();
135
			notify("publish_synchronizing_configuration", "100");
136
			
137
		} catch (InterruptedException e) {
138
			throw new PublishException("publish_mapserver_process_exception");
139
		}
140
	}
141
	/**
142
	 * TODO: Provisiona
143
	 * 	 
144
	 */
145
	private void synchronize() {
146
		if (mapserver.getPublication().getAccessFileMethod()!= Publication.RSYNC_OVER_SSH){
147
			return;
148
		}
149
		mapserver.getPublication().synchronizeDatasources();
150
		SyncParameter src = new SyncParameter();
151
		src.setPath(this.src_dir);
152
		SyncParameter dst = new SyncParameter();
153
		dst.setAddress(mapserver.getAddress());
154
		dst.setPassword(mapserver.getPublication().getPassword());
155
		dst.setUser(mapserver.getPublication().getUser());
156
		dst.setPath(mapserver.getPublication().getDstDir());
157
		ISynchronization sync = PublishUtilFactory.getInstance().getSynInstance();
158
		try {
159
			sync.sync(src, dst);
160
		} catch (SyncException e) {
161
			throw new PublishException("publish_sync_exception");
162
		}
163
	}
164
	private void writeConfiguration() {
165
		try {
166
			String aux = FileUtils.getFileWithoutExtension(mapserver.getMapfileFile());		
167

  
168
			symbolsfile = new File(aux+".sym");
169
			symbols.generate(symbolsfile.getAbsolutePath());
170
			fonts.generate(symbolsfile.getParent() + "/" + "fonts.txt");
171

  
172
			mapfile.generate(mapserver.getMapfileFile().getAbsolutePath(), "UTF-8");
173
		} catch (FileNotFoundException e) {
174
			throw new PublishException("publish_permission_denied"); 
175
		}
176
	}
177
	private void publishServices() {
178
		for(int i = 0; i < mapserver.getServicesCount(); i++){
179
			mapserver.getService(i).publish(this);
180
		}
181
	}
182
	private void generateWebObject() {
183
		if (mapserver.getImagePath()!=null){
184
			mapfile.web.imagepath = mapserver.getImagePath().getAbsolutePath();
185
		}
186

  
187
	}
188
	private void generateMapObject() {
189
		if(mapserver.getShapepath() !=null){
190
			mapfile.mapShapePath = mapserver.getShapepath();
191
		}
192
		mapfile.debug = mapserver.isDebug();
193
		//generates the mapfile object MAP
194
		//set the map name 
195
		mapfile.mapName = "map_generated_by_gvsig";		
196
		//TODO: I must create the method ProjectInfo.getBoundingBox() with the larger bbox (of all the views)
197
		//At the moment I'm using the bbox of the first view
198
		mapfile.extent = mapserver.getPublication().getProjectInfo().getViewsInfo()[0].getBBox();
199
		//set the relative path to symbolsfile
200

  
201
		mapfile.symbolset = symbolsfile.getName();
202
		mapfile.fontset = "fonts.txt";
203
		//set the absolute path to symbolsfile
204
		//getConfigFile().symbolset = symbolsfilename;
205
		//add projection object, the projection of the first view
206
		mapfile.projection = new MapFile.CRS(mapserver.getPublication().getProjectInfo().getViewsInfo()[0].getEPSG(),true);		
207
	}
208

  
209
	private void checkServices() {
210
		if (mapserver.getService(0) == null){
211
			throw new PublishException("publishms_no_services_defined");
212
		}
213
		if (mapserver.getService(0).getRemoteResourcesCount() == 0){
214
			throw new PublishException("publishms_nothing_to_publish");
215
		}
216
	}
217
	private void createFontFile() {
218
		fonts = new FontsFile.WellKnowFontsFile();
219
		fontsfile = new File("fonts.txt");
220
		fonts.generate(fontsfile.getAbsolutePath());
221
	}
222
	private void createSymbolFile() {
223
		symbols = new SymbolsFile.WellKnowSymbolsFile();
224
		String aux = FileUtils.getFileWithoutExtension(mapserver.getMapfileFile());		
225
		symbolsfile = new File(aux+".sym");
226
		symbols.generate(symbolsfile.getAbsolutePath());
227
	}
228
	private void createMapfile() {
229
		if (mapserver.getMapfileFile()==null){			
230
			throw new PublishException("publishms_the_mapfile_is_not_defined");
231
		}
232
		mapfile= new MapFile.ConfigFile();
233
		mapserver.setConfigFile(mapfile);
234
	}
235

  
236
}
trunk/extensions/extPublishMapserver/src/org/gvsig/publish/mapserver/model/Mapserver.java
48 48
import org.gvsig.publish.mapserver.conf.FontsFile;
49 49
import org.gvsig.publish.mapserver.conf.MapFile;
50 50
import org.gvsig.publish.mapserver.conf.SymbolsFile;
51
import org.gvsig.publish.mapserver.conf.MapFile.ConfigFile;
52
import org.gvsig.publish.serversmodel.PublicationProcess;
51 53
import org.gvsig.publish.serversmodel.Server;
52 54

  
53 55
import com.iver.utiles.FileUtils;
......
63 65
public class Mapserver extends Server {
64 66

  
65 67
	public static final String REGISTER_TAG="Mapserver 5.x";
66
	
68

  
69
	private MapserverProcess process =null;
67 70
	/*
68 71
	 * dependences
69 72
	 */
......
75 78
	//private String symbolsfilename = null;	
76 79
	private File imagepath_file = null;
77 80
	private String shapepath=null;
78
	
81

  
79 82
	private boolean debug=false;
80 83
	/**
81 84
	 * Constructor
......
83 86
	public Mapserver(){
84 87
		super();		
85 88
	}
86
		
89

  
87 90
	/**
88 91
	 * Generates the publication in Mapserver.  
89 92
	 * TODO: at the moment, you only can publish its first service
......
107 110
		if (getMapfileFile()==null){			
108 111
			throw new PublishException("publishms_the_mapfile_is_not_defined");
109 112
		}
110
		
113

  
111 114
		String aux = FileUtils.getFileWithoutExtension(getMapfileFile());		
112
		
115

  
113 116
		symbolsfile = new File(aux+".sym");
114 117
		symbolsconfig.generate(symbolsfile.getAbsolutePath());
115 118
		fontsconfig.generate(symbolsfile.getParent() + "/" + "fonts.txt");
116
		
119

  
117 120
		//creates IMAGEPATH
118 121
		if (getImagePath()!=null){
119 122
			config.web.imagepath = getImagePath().getAbsolutePath();
......
124 127
		}
125 128
		//debug 		
126 129
		config.debug = isDebug();
127
		
130

  
128 131
		//generates the mapfile object MAP
129 132
		generateMapObject();				
130
	
133

  
131 134
		//call publish() method publish of its services
132 135
		super.publish();
133 136
		//At the end write the configuration
......
149 152
		//At the moment I'm using the bbox of the first view
150 153
		getConfigFile().extent = getPublication().getProjectInfo().getViewsInfo()[0].getBBox();
151 154
		//set the relative path to symbolsfile
152
		
155

  
153 156
		getConfigFile().symbolset = symbolsfile.getName();
154 157
		getConfigFile().fontset = "fonts.txt";
155 158
		//set the absolute path to symbolsfile
......
157 160
		//add projection object, the projection of the first view
158 161
		getConfigFile().projection = new MapFile.CRS(getPublication().getProjectInfo().getViewsInfo()[0].getEPSG(),true);		
159 162
	}
160
	
161 163

  
164

  
162 165
	/**
163 166
	 * check compatible	 
164 167
	 * 
......
189 192
	public void setMapfileFile(File file){
190 193
		mapfile = file;
191 194
	}
192
	
195

  
193 196
	/**
194 197
	 * Gets the IMAGEPATH
195 198
	 * @return
......
204 207
	public void setImagePath(File imagepath_file) {
205 208
		this.imagepath_file = imagepath_file;
206 209
	}
207
	
208
	
210

  
211

  
209 212
	public String getClassName() {
210 213
		return "Mapserver";
211 214
	}		
......
252 255
		//put Mapserver properties
253 256
		if (getMapfileFile() != null)
254 257
			xml.putProperty("mapfile", getMapfileFile().getAbsolutePath());
255
			
258

  
256 259
		if (getImagePath() == null){
257 260
			xml.putProperty("imagepath", null);
258 261
		}else{
259 262
			xml.putProperty("imagepath", getImagePath().getAbsolutePath());
260 263
		}
261
		
264

  
262 265
		if (shapepath !=null){
263 266
			xml.putProperty("shapepath", shapepath);
264 267
		}
......
279 282
	 * @see org.gvsig.publish.serversmodel.Server#getId()
280 283
	 */
281 284
	public String getId() {
282
		
285

  
283 286
		return "mapserver_id";
284 287
	}
285 288

  
......
298 301
	public String getRegisterTag() {
299 302
		return REGISTER_TAG;
300 303
	}
301
	
304

  
302 305
	/*
303 306
	 * (non-Javadoc)
304 307
	 * @see java.lang.Object#toString()
......
318 321
	public void setDebug(boolean debug) {
319 322
		this.debug = debug;
320 323
	}
324
	/*
325
	 * (non-Javadoc)
326
	 * @see org.gvsig.publish.serversmodel.Server#getPublicationProcess()
327
	 */
328
	public PublicationProcess getPublicationProcess() {
329
		//if (process == null){
330
			process = new MapserverProcess(this);
331
		//}
332
		return process;
333
	}
321 334

  
335
	public void setConfigFile(ConfigFile mapfile2) {
336
		this.config = mapfile2;
337
	}
338

  
322 339
}
trunk/extensions/extPublishMapserver/src/org/gvsig/publish/mapserver/model/wms/MapserverWMSLayer.java
72 72
import org.gvsig.publish.mapserver.util.MapserverUtilities;
73 73
import org.gvsig.publish.ogcmetadata.IOGCLayerMetadata;
74 74
import org.gvsig.publish.ogcmetadata.OGCLayerMetadata;
75
import org.gvsig.publish.serversmodel.PublicationProcess;
75 76
import org.gvsig.publish.serversmodel.RemoteResource;
76 77

  
77 78
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
......
271 272
	 * 
272 273
	 */
273 274
	private void generateIntervalLegend(IIntervalLegendInfo legend, Layer lyr) throws PublishException{
274
		//check if is labeled
275
		boolean islabeled = false;
276
		if ( getLayerInfo().getLabeling().getLabelField() != null){
277
			islabeled = true;
278
		}
279

  
280 275
		String[] expressions = legend.getExpressions();
281 276
		for (int i=0 ; i<expressions.length ; i++){
282 277
			ISymbolInfo isymbol = legend.getSymbolByExpression(expressions[i]);
......
285 280
			//TODO: change in infoProject
286 281
			clase.expression = "(" + expressions[i] + ")";
287 282
			generateStyle(isymbol, clase);
288
			if (islabeled){
283
			if (getLayerInfo().isLabeled()){
289 284
				//generateSymbol(getLayerInfo().getLabeling().getSymbolInfo(), clase);
290 285
				throw new NotImplementedException();
291 286
			}
......
294 289
	}
295 290

  
296 291
	private void generateUniqueLegend(IUniqueValuesLegendInfo legend, Layer lyr) throws PublishException{
297
		//check if is labeled
298
		boolean islabeled = false;
299
		if ( getLayerInfo().getLabeling().getLabelField() != null){
300
			islabeled = true;
301
		}
302 292
		//put the CLASSITEM
303 293
		lyr.classitem = legend.getFilterItem();
304 294
		//create all CLASS
......
311 301
			//TODO: change in infoProject			
312 302
			clase.expression = "\"" +  uniqueValues[i] + "\"";
313 303
			generateStyle(isymbol, clase);
314
			if (islabeled){
304
			if (getLayerInfo().isLabeled()){
315 305
				//generateSymbol(getLayerInfo().getLabeling().getSymbolInfo(), clase);
316 306
				throw new NotImplementedException();
317 307
			}
......
574 564
	public void setSpecificParams(MapserverLayer specificParams) {
575 565
		this.specificParams = specificParams;
576 566
	}
567

  
568
	public void publish(PublicationProcess publicationProcess)
569
			throws PublishException {
570
		publish();
571
		publicationProcess.notify("publishing " + getTitle() );
572
	}
577 573
}
trunk/extensions/extPublishMapserver/src/org/gvsig/publish/mapserver/model/wms/MapserverWMS.java
41 41
package org.gvsig.publish.mapserver.model.wms;
42 42

  
43 43

  
44
import java.net.MalformedURLException;
44 45
import java.net.URL;
45 46
import java.util.HashSet;
46 47
import java.util.Iterator;
......
55 56
import org.gvsig.publish.mapserver.model.Mapserver;
56 57
import org.gvsig.publish.ogcmetadata.IOGCServiceMetadata;
57 58
import org.gvsig.publish.ogcmetadata.OGCServiceMetadata;
59
import org.gvsig.publish.serversmodel.PublicationProcess;
58 60
import org.gvsig.publish.serversmodel.RemoteResource;
59 61
import org.gvsig.publish.serversmodel.Service;
60 62

  
......
70 72
	public static final String REGISTER_TAG="WMS 1.1.1";
71 73
	private FilterProjectInfo filter;	 
72 74
	private OGCServiceMetadata wmsMetadata = null;
75
	private Mapserver mapserver;
76
	private ConfigFile mapfile;
77

  
73 78
	/**
74 79
	 * Constructor
75 80
	 *
......
79 84
		wmsMetadata = new OGCServiceMetadata();				
80 85
		//initializes de title with the server name and the service type
81 86
		setTitle("Mapserver WMS");		
82
		setName("OGC:WMS");		
83
		setOnlineResource(getMapServer().getServerURL());
87
		setName("OGC:WMS");
88
		this.mapserver = mapserver;
89
		this.mapfile = mapserver.getConfigFile();
90
		try {
91
			setOnlineResource(mapserver.getServerURL());
92
		} catch (MalformedURLException e) {
93
			// TODO Auto-generated catch block
94
			PublishLogger.getLog().error("publish_malformed_url", e);
95
		}
84 96
	}		
85
	private Mapserver getMapServer(){
86
		//Cast to Mapserver
87
		Mapserver mapserver = (Mapserver)getServer();
88
		return mapserver;
89
	}
97

  
90 98
	/**
91 99
	 * Preconditions:
100
	 * 
92 101
	 * the objects config file, map, map.web and map.web.metadata has been created
102
	 * @deprecated
93 103
	 */
94 104
	public void publish() throws PublishException{
95 105
		//publish all the remote resources
96 106
		super.publish();
97 107

  
98 108
		//gets the mapfile from the server
99
		ConfigFile mapfile = getMapServer().getConfigFile();
109
		ConfigFile mapfile = mapserver.getConfigFile();
100 110
		if (mapfile == null){
101 111
			throw new PublishException("mapfile_not_defined");
102 112
		}
......
112 122
		generateLegend();
113 123
	}
114 124

  
115
	private void generateSRS() {
116
		Set set = new HashSet();		
117
		for (int i= 0; i < getRemoteResourcesCount(); i++){
118
			RemoteResource r = getRemoteResource(i);
119
			IDataSourceInfo ds;
120
			ds = r.getLayerInfo().getDataSource();
121
			if (ds != null){
122
				String epsg = ds.getEPSG();			
123
				set.add(epsg);
124
			}			
125
		} 
126
		Iterator i = set.iterator();
127
		ConfigFile mapfile = getMapServer().getConfigFile();
128
		String aux="";
129
		while (i.hasNext()){
130
			aux = aux + " " + (String) i.next();			
131
		}		
132
		mapfile.web.metadata.wms_srs = aux; 
133
	}
134

  
135
	private void generateLegend(){
136
		ConfigFile mapfile = getMapServer().getConfigFile();
137
		mapfile.legend = new MapFile.Legend(); 
138
		mapfile.legend.status = "ON";
139
		mapfile.legend.imagecolor = new MapFile.RGB(-1,-1,-1); 
140
		mapfile.legend.transparent = "ON";
141
		mapfile.legend.legendlabel = new MapFile.Label();
142
		mapfile.legend.legendlabel.color = new MapFile.RGB(0,0,0);
143
		mapfile.legend.legendlabel.encoding = "UTF-8";
144
		mapfile.legend.legendlabel.font ="vera";
145
		mapfile.legend.legendlabel.type ="truetype";
146
		mapfile.legend.legendlabel.size = "8";
147
	}
148

  
149 125
	public String getClassName() {
150 126
		return "MapserverWMS";
151 127
	}
......
285 261
	public String toString(){
286 262
		return getRegisterTag();
287 263
	}
264
	/*
265
	 * (non-Javadoc)
266
	 * @see org.gvsig.publish.serversmodel.Service#publish(org.gvsig.publish.serversmodel.PublicationProcess)
267
	 */
268
	public void publish(PublicationProcess publicationProcess)throws PublishException {
269
		try {
270
			//publicationProcess.notify("publish_publishing_mapserver_wms", "publish_generating_mapfile", "preparing_mapfile", "0");
271
			prepareMapfile();
272
			publicationProcess.notify("generating_web_metadata");
273
			generateWebMetadata();
274
			Thread.sleep(500);
275
			publicationProcess.notify("generating_srs");
276
			generateSRS();
277
			Thread.sleep(500);
278
			publicationProcess.notify("generating_legend");
279
			generateLegend();
280
			Thread.sleep(500);
281
			publicationProcess.notify(mapfile.toString());
282
			Thread.sleep(500);
283
			//publishing all resources
284
			for (int i = 0; i < getRemoteResourcesCount(); i++){
285
				getRemoteResource(i).publish(publicationProcess);
286
			}
287
		} catch (InterruptedException e) {
288
			
289
			throw new PublishException("publish_interrupt_exception");
290
		}
291
	}
292
	/*
293
	 * gets the mapfile from de server
294
	 */
295
	private void prepareMapfile() throws PublishException{
296
		//gets the mapfile from the server
297
		mapfile = mapserver.getConfigFile();
298
		if (mapfile == null){
299
			throw new PublishException("mapfile_not_defined");
300
		}
301

  
302
	}
303
	/*
304
	 * generates the code into the MAP->WEB->METADATA 
305
	 */
306
	private void generateWebMetadata(){
307
		mapfile.web.metadata.wms_title = getTitle();
308
		mapfile.web.metadata.wms_abstract = getAbstract();		
309
		if (getOnlineResource() != null){
310
			//TODO: test for local publication
311
			mapfile.web.metadata.wms_onlineresource = getOnlineResource().toString() + "?map=" + getServer().getPublication().getDstDir() + "/" +getServer().getPublication().getTitle() + "/wms.map";
312
			
313
		}
314
		mapfile.web.metadata.wms_encoding ="UTF-8";
315
	}
316
	/*
317
	 * creates MAP-->WEB-->METADATA-->wms_srs
318
	 */
319
	private void generateSRS() {
320
		Set set = new HashSet();		
321
		for (int i= 0; i < getRemoteResourcesCount(); i++){
322
			RemoteResource r = getRemoteResource(i);
323
			IDataSourceInfo ds;
324
			ds = r.getLayerInfo().getDataSource();
325
			if (ds != null){
326
				String epsg = ds.getEPSG();			
327
				set.add(epsg);
328
			}			
329
		} 
330
		Iterator i = set.iterator();
331
		String aux="EPSG:4326";
332
		while (i.hasNext()){
333
			aux = aux + " " + (String) i.next();			
334
		}		
335
		mapfile.web.metadata.wms_srs = aux; 
336
	}
337
	/*
338
	 * creates MAP->LEGEND
339
	 */
340
	private void generateLegend(){
341
		mapfile.legend = new MapFile.Legend(); 
342
		mapfile.legend.status = "ON";
343
		mapfile.legend.imagecolor = new MapFile.RGB(-1,-1,-1); 
344
		mapfile.legend.transparent = "ON";
345
		mapfile.legend.legendlabel = new MapFile.Label();
346
		mapfile.legend.legendlabel.color = new MapFile.RGB(0,0,0);
347
		mapfile.legend.legendlabel.encoding = "UTF-8";
348
		mapfile.legend.legendlabel.font ="vera";
349
		mapfile.legend.legendlabel.type ="truetype";
350
		mapfile.legend.legendlabel.size = "8";
351
	}
352

  
288 353
}
trunk/extensions/extPublishMapserver/src/org/gvsig/publish/mapserver/gui/MSBasicPanel.java
42 42

  
43 43
import java.awt.event.ActionListener;
44 44
import java.io.File;
45
import java.net.MalformedURLException;
45 46
import java.util.EventListener;
46 47

  
47 48
import javax.swing.JPanel;
......
52 53
import org.gvsig.publish.mapserver.model.Mapserver;
53 54

  
54 55
import com.iver.andami.PluginServices;
56
import com.iver.andami.messages.NotificationManager;
55 57

  
56 58
public class MSBasicPanel extends JPanel implements IPublishPluginPanel {
57 59
	public final static String MAPFILE_CHOOSE_PATH_EVENT="mapfile_path_event";
......
67 69
		initComponents();
68 70
		initIcons();
69 71
		initLabels();
72
		fileButton.setVisible(false);
73
		mapfileField.setVisible(false);
74
		mapfileLabel.setVisible(false);
70 75
	}
71 76
	private void initLabels() {
72 77
		 urlLabel.setText(PluginServices.getText(this,"publishms_mapserver_url"));
......
195 200
		if (model_server.getMapfileFile() !=null){
196 201
			mapfileField.setText(model_server.getMapfileFile().getAbsolutePath());
197 202
		}
198
		urlField.setText(model_server.getServerURL().toString());		
203
		try {
204
			urlField.setText(model_server.getServerURL().toString());
205
		} catch (MalformedURLException e) {
206
			NotificationManager.showMessageError(PluginServices.getText(this,"publish_malformed_url"), e);
207
		}		
199 208
	}
200 209

  
201 210
}
trunk/extensions/extPublishMapserver/src/org/gvsig/publish/mapserver/gui/preferences/MapserverPreferencesPage.java
49 49
import org.gvsig.publish.PublishLogger;
50 50

  
51 51
import com.iver.andami.PluginServices;
52
import com.iver.andami.messages.NotificationManager;
52 53
import com.iver.andami.preferences.AbstractPreferencePage;
53 54
import com.iver.andami.preferences.StoreException;
54 55
import com.iver.utiles.swing.JComboBox;
......
94 95
	 * @see com.iver.andami.preferences.AbstractPreferencePage#setChangesApplied()
95 96
	 */
96 97
	public void setChangesApplied() {
97
		JOptionPane.showMessageDialog(this,
98
				PluginServices.getText(this,"publishms_restart"),
99
				PluginServices.getText(this,"publishms_change_view_properties"),				
100
				JOptionPane.INFORMATION_MESSAGE);
101 98
		persistence.setGUIControllerType(comboViews.getSelectedIndex());
102 99
	}
103 100

  
......
144 141
	}
145 142

  
146 143
	public boolean isValueChanged() {
144
		NotificationManager.showMessageInfo(PluginServices.getText(this,"publishms_restart"), null);
147 145
		return true;
148 146
	}
149 147

  
trunk/extensions/extPublishMapserver/src/org/gvsig/publish/mapserver/conf/SymbolsFile.java
101 101
			closeSymbolsFile();
102 102
		}
103 103
		void write(){
104
			toMapln("SYMBOLSET");
104 105
			//circle			
105 106
			toMapln("SYMBOL");
106 107
			tabIn();
......
286 287
			//toMapln("STYLE 1 15 1 15 END");
287 288
			tabOut();
288 289
			toMapln("END");
290
			
291
			toMapln("END");
289 292
		}		
290 293
	}
291 294
}
trunk/extensions/extPublish/src/org/gvsig/publish/ProjectPublication.java
89 89
	 */
90 90
	private Publication getPublication(){
91 91
		if (publication == null){
92
			publication = new Publication();
92
			publication = new Publication(getName());
93 93
		}
94 94
		return publication;
95 95
	}
trunk/extensions/extPublish/src/org/gvsig/publish/infoproject/symbols/IMarkerSymbolInfo.java
46 46

  
47 47

  
48 48
public interface IMarkerSymbolInfo extends ISymbolInfo{
49
	public final String WELLKNOWMARKER_CIRCLE="circle";
50
	public final String WELLKNOWMARKER_CROSS ="cross";
51
	public final String WELLKNOWMARKER_SQUARE ="square";
52
	public final String WELLKNOWMARKER_TRIANGLE = "triangle";
49
	final String WELLKNOWMARKER_CIRCLE="circle";
50
	final String WELLKNOWMARKER_CROSS ="cross";
51
	final String WELLKNOWMARKER_SQUARE ="square";
52
	final String WELLKNOWMARKER_TRIANGLE = "triangle";
53 53
	abstract int getSize();	
54 54
	abstract String getWellKnowMarkerName();
55 55
	abstract File getImageIconFile();
trunk/extensions/extPublish/src/org/gvsig/publish/infoproject/gvsig19/MarkerSymbolInfo.java
1 1
package org.gvsig.publish.infoproject.gvsig19;
2 2

  
3 3
import java.awt.Color;
4
import java.io.File;
5
import java.net.MalformedURLException;
6
import java.net.URL;
4 7

  
8
import org.gvsig.publish.PublishLogger;
5 9
import org.gvsig.publish.infoproject.ISymbolInfo;
10
import org.gvsig.publish.infoproject.symbols.IMarkerSymbolInfo;
11
import org.gvsig.symbology.fmap.symbols.PictureMarkerSymbol;
6 12

  
13
import com.iver.cit.gvsig.fmap.MapContext;
7 14
import com.iver.cit.gvsig.fmap.core.symbols.IMarkerSymbol;
8

  
9
public class MarkerSymbolInfo implements ISymbolInfo {
10

  
15
/**
16
 * Marker symbol from gvSIG-1.9 
17
 * 
18
 * @author jvhigon
19
 *
20
 */
21
public class MarkerSymbolInfo implements IMarkerSymbolInfo {
22
	IMarkerSymbol marker = null;
23
	/**
24
	 * Constructor
25
	 * @param symbol interface for markers in gvSIG 1.9
26
	 */
11 27
	public MarkerSymbolInfo(IMarkerSymbol symbol) {
12
		// TODO Auto-generated constructor stub
28
		this.marker = symbol;
13 29
	}
14

  
15
	public Color getColor() {
16
		// TODO Auto-generated method stub
17
		return null;
30
	/*
31
	 * (non-Javadoc)
32
	 * @see org.gvsig.publish.infoproject.ISymbolInfo#getColor()
33
	 */
34
	public Color getColor() {		
35
		return marker.getColor();
18 36
	}
19

  
37
	/*
38
	 * (non-Javadoc)
39
	 * @see org.gvsig.publish.infoproject.ISymbolInfo#getTitle()
40
	 */
20 41
	public String getTitle() {
21
		// TODO Auto-generated method stub
22
		return null;
42
		return marker.getDescription();
23 43
	}
24

  
44
	/*
45
	 * (non-Javadoc)
46
	 * @see org.gvsig.publish.infoproject.ISymbolInfo#getTranparency()
47
	 */
25 48
	public int getTranparency() {
26
		// TODO Auto-generated method stub
27
		return 0;
49
		return marker.getColor().getAlpha();
28 50
	}
29

  
51
	/*
52
	 * (non-Javadoc)
53
	 * @see org.gvsig.publish.infoproject.ISymbolInfo#getUnits()
54
	 */
30 55
	public String getUnits() {
31
		// TODO Auto-generated method stub
32
		return null;
56
		int u = marker.getUnit();
57
		//TODO
58
		//MapContext.CHANGE
59
		return ISymbolInfo.PIXELS;
33 60
	}
61
	/*
62
	 * (non-Javadoc)
63
	 * @see org.gvsig.publish.infoproject.symbols.IMarkerSymbolInfo#getImageIconFile()
64
	 */
65
	public File getImageIconFile() {
66
		File aux = null;
67
		if (marker instanceof PictureMarkerSymbol ){
68
			PictureMarkerSymbol picture= (PictureMarkerSymbol)marker;
69
			try {
70
				aux = new File(new URL(picture.getImagePath()).getFile());
71
			} catch (MalformedURLException e) {
72
				PublishLogger.getLog().error("MarkerSymbolInfo.getImageIconFile(", e);
73
			}
74
		}
75
		return aux;
76
	}
77
	/*
78
	 * (non-Javadoc)
79
	 * @see org.gvsig.publish.infoproject.symbols.IMarkerSymbolInfo#getSize()
80
	 */
81
	public int getSize() {
82
		int aux = new Double(marker.getSize()).intValue();
83
		return aux;
84
	}
85
	/*
86
	 * (non-Javadoc)
87
	 * @see org.gvsig.publish.infoproject.symbols.IMarkerSymbolInfo#getWellKnowMarkerName()
88
	 */
89
	public String getWellKnowMarkerName() {
90
		 //TODO
91
		return IMarkerSymbolInfo.WELLKNOWMARKER_CIRCLE;
92
	}
34 93

  
35 94
}
trunk/extensions/extPublish/src/org/gvsig/publish/infoproject/gvsig19/LayerInfo.java
349 349
	public String getClassName() {
350 350
		return "LayerInfo";
351 351
	}
352

  
353

  
352
	/*
353
	 * (non-Javadoc)
354
	 * @see org.gvsig.publish.infoproject.ILayerInfo#isLabeled()
355
	 */
356
	public boolean isLabeled() {
357
		if (layer instanceof FLyrVect){
358
			FLyrVect v = (FLyrVect)layer;
359
			return v.isLabeled();
360
		}else{
361
			throw new NotImplementedException();
362
		}
363
	}
354 364
}
trunk/extensions/extPublish/src/org/gvsig/publish/infoproject/gvsig19/PostGISTableInfo.java
53 53
import org.gvsig.publish.infoproject.datasources.IDataBaseInfo;
54 54

  
55 55
import com.hardcode.gdbms.driver.exceptions.ReadDriverException;
56
import com.iver.cit.gvsig.fmap.core.FShape;
56 57
import com.iver.cit.gvsig.fmap.crs.CRSFactory;
57 58
import com.iver.cit.gvsig.fmap.drivers.ConnectionJDBC;
58 59
import com.iver.cit.gvsig.fmap.drivers.DBLayerDefinition;
......
174 175
	 * TODO: MAybe already exists this implementation, but I couldn't find it
175 176
	 */
176 177
	public String getEPSG() {
177
		try {
178
			String sql = "SELECT srid FROM geometry_columns WHERE f_table_name = '" + getTableName() + "' AND f_geometry_column = '" + getGeometryColumn() + "'";
179
			Statement st = connection.getConnection().createStatement();
180
			ResultSet rs =  st.executeQuery(sql);
181
			if (rs.first()){
182
				int aux = rs.getInt("srid"); 
183
				return "EPSG:" + aux;
184
			}
185
		} catch (SQLException e) {			
186
			PublishLogger.getLog().error("ERROR PostGISTableInfo : SQL exception getting the EPSG",e);
178
		return this.adapter.getProjection().getAbrev();
187 179
		}
188
		return null;
189
		//TODO: I can't get the datasource CRS !!		
190
		//return this.driver.getDestProjection();
191
		//return "EPSG:23030";
192
	}
193 180
	/*
194 181
	 * (non-Javadoc)
195 182
	 * @see org.gvsig.publish.infoProject.IDataSourceInfo#getDataType()
196
	 * TODO: MAybe already exists this implementation, but I couldn't find it 
183
	 * TODO: Deal with the exception
197 184
	 */
198 185
	public String getGeomType() {
199
		String geomtype = null;
186
		int type;
200 187
		try {
201
			String sql = "SELECT type FROM geometry_columns WHERE f_table_name = '" + getTableName() + "' AND f_geometry_column = '" + getGeometryColumn() + "'";
202
			Statement st = connection.getConnection().createStatement();
203
			ResultSet rs =  st.executeQuery(sql);
204
			if (rs.first()){
205
				geomtype = rs.getString("type"); 
206
			}
207
		} catch (SQLException e) {			
208
			PublishLogger.getLog().error("ERROR PostGISTableInfo : SQL exception getting the geometry type",e);
188
			type = this.adapter.getShapeType();
189
		} catch (ReadDriverException e) {
190
			// TODO Auto-generated catch block
191
			e.printStackTrace();
192
			return null;
209 193
		}
210
	
211
		if (geomtype.equals("POINT") || geomtype.equals("MULTIPOINT")){
194
		
195
		if (type == FShape.POINT || type == FShape.MULTIPOINT){
212 196
			return IDataSourceInfo.POINT;
213 197
		}
214
		if (geomtype.equals("LINESTRING") || geomtype.equals("MULTILINESTRING")){
198
		if (type == FShape.LINE){
215 199
			return IDataSourceInfo.LINE;
216 200
		}
217
		if (geomtype.equals("POLYGON") || geomtype.equals("MULTIPOLYGON")){
201
		if (type == FShape.POLYGON){
218 202
			return IDataSourceInfo.POLYGON;
219 203
		}		
220 204
		return null;
trunk/extensions/extPublish/src/org/gvsig/publish/infoproject/ILayerInfo.java
126 126
	abstract IViewInfo getViewInfo();
127 127
	/**
128 128
	 * 
129
	 * @return information about the layer labeling. It cannot be be null.
129
	 * @return information about the layer labeling. It can be null if isLabeled() is false.
130 130
	 */
131 131
	abstract ILabelingInfo getLabeling();
132
	
133 132
	/**
133
	 * @return true if the layer is labeled
134
	 */
135
	abstract boolean isLabeled();
136
	/**
134 137
	 * 
135 138
	 * @return the opacity percentage, 0 is transparent, 100 is opaque
136 139
	 */
trunk/extensions/extPublish/src/org/gvsig/publish/gui/properties/rsync/RsyncPropertiesPanelHandler.java
56 56
	public void actionPerformed(ActionEvent e) {
57 57
		if (e.getActionCommand().equals(ACCEPT_COMMAND)){			
58 58
			publication.setUser(window.getUserField().getText());
59
			publication.setPassword(window.getPasswordField().getPassword().toString());
59
			char[] aux = window.getPasswordField().getPassword();
60
			publication.setPassword(new String(aux));
60 61
			publication.setDstDir(window.getDstDirTextField().getText());
61 62
			window.closeWindow();
62 63
			return;
trunk/extensions/extPublish/src/org/gvsig/publish/gui/properties/rsync/RsyncPropertiesWindow.java
67 67
		getUserField().setText(p.getUser());
68 68
		getPasswordField().setText(p.getPassword());
69 69
		if (p.getDstDir() == null){
70
			getDstDirTextField().setText("~/.gvSIG-publish");
70
			getDstDirTextField().setText("$HOME/.gvSIG-publish");
71 71
		}else{
72
			getDstDirTextField().setText(p.getDstDir());
72
			String aux = p.getDstDir().replaceFirst("$HOME","/home/"+ p.getUser());
73
			getDstDirTextField().setText(aux);
73 74
		}
74 75
		//set listener
75 76
		handler = new RsyncPropertiesPanelHandler(p, this);
trunk/extensions/extPublish/src/org/gvsig/publish/serversmodel/Publication.java
86 86
	private String user;
87 87
	private String password;
88 88
	private String dstDir;
89

  
89
	/**
90
	 * Constructor
91
	 * @param title of the Publication
92
	 */
93
	public Publication(String title) {
94
		this.title = title;
95
	}
90 96
	public String getDstDir() {
97
		if (dstDir ==null || getAccessFileMethod()==LOCAL_ACCESS){
98
			dstDir = System.getProperty("user.home") + "/" + ".gvSIG-publish";
99
		}
91 100
		return dstDir;
92 101
	}
93 102
	public void setDstDir(String dstDir) {

Also available in: Unified diff