[Schmitzm-commits] r1291 - in trunk: src/skrueger/geotools/io src_junit/skrueger/geotools/io

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Mon Nov 22 02:18:17 CET 2010


Author: alfonx
Date: 2010-11-22 02:18:13 +0100 (Mon, 22 Nov 2010)
New Revision: 1291

Added:
   trunk/src/skrueger/geotools/io/GsServerSettings.java
Modified:
   trunk/src/skrueger/geotools/io/DbServerList.java
   trunk/src/skrueger/geotools/io/DbServerSettings.java
   trunk/src/skrueger/geotools/io/ServerSettings.java
   trunk/src/skrueger/geotools/io/WfsServerList.java
   trunk/src/skrueger/geotools/io/WfsServerSettings.java
   trunk/src_junit/skrueger/geotools/io/DbServerSettingsTest.java
   trunk/src_junit/skrueger/geotools/io/WfsServerSettingsTest.java
Log:
Preparing GP export to GS

Modified: trunk/src/skrueger/geotools/io/DbServerList.java
===================================================================
--- trunk/src/skrueger/geotools/io/DbServerList.java	2010-11-21 20:58:12 UTC (rev 1290)
+++ trunk/src/skrueger/geotools/io/DbServerList.java	2010-11-22 01:18:13 UTC (rev 1291)
@@ -53,8 +53,7 @@
 
 		for (String s : split) {
 			try {
-				DbServerSettings dbServer = DbServerSettings
-						.parsePropertiesString(s);
+				DbServerSettings dbServer = new DbServerSettings(s);
 				if (dbServer == null) {
 					Log.error(
 							"Could not import a "

Modified: trunk/src/skrueger/geotools/io/DbServerSettings.java
===================================================================
--- trunk/src/skrueger/geotools/io/DbServerSettings.java	2010-11-21 20:58:12 UTC (rev 1290)
+++ trunk/src/skrueger/geotools/io/DbServerSettings.java	2010-11-22 01:18:13 UTC (rev 1291)
@@ -8,6 +8,8 @@
 import java.util.HashMap;
 import java.util.regex.Pattern;
 
+import javax.management.RuntimeErrorException;
+
 import org.apache.commons.lang.ArrayUtils;
 import org.apache.commons.lang.StringUtils;
 import org.apache.log4j.Logger;
@@ -148,7 +150,8 @@
 	 *         .properties line. @see #parsePropertiesString
 	 * @throws MalformedURLException
 	 */
-	public static DbServerSettings parsePropertiesString(String propString)
+	@Override
+	public DbServerSettings parsePropertiesString(String propString)
 			throws MalformedURLException {
 
 		if (propString == null || propString.isEmpty())
@@ -182,6 +185,7 @@
 
 	public DbServerSettings() {
 		this(DbType.postgis);
+		
 	}
 
 	public DbServerSettings(DbType dbType) {
@@ -191,6 +195,14 @@
 		put(JDBCDataStoreFactory.PK_METADATA_TABLE.key, null);
 	}
 
+	public DbServerSettings(String propertiesString) {
+		try {
+			parsePropertiesString(propertiesString);
+		} catch (MalformedURLException e) {
+			throw new RuntimeException(e);
+		}
+	}
+
 	public String[] getCachedTypeNames() {
 		return cachedTypeNames;
 	}

Added: trunk/src/skrueger/geotools/io/GsServerSettings.java
===================================================================
--- trunk/src/skrueger/geotools/io/GsServerSettings.java	2010-11-21 20:58:12 UTC (rev 1290)
+++ trunk/src/skrueger/geotools/io/GsServerSettings.java	2010-11-22 01:18:13 UTC (rev 1291)
@@ -0,0 +1,60 @@
+package skrueger.geotools.io;
+
+import java.net.MalformedURLException;
+import java.util.HashMap;
+
+/**
+ * This class describes all settings needed to connect to a Geoserver server via REST configuration. This
+ * class extends a {@link HashMap} and contains two groups of keys:<br/>
+ * The first group of keys, are all keys provided by Geotools to create a WFS
+ * <br/>
+ * This class can serialize all important parameters needed to define the
+ * connection into a {@link String} with {@link #toPropertiesString()} and
+ * re-import the String with {@link #parsePropertiesString(String)}.
+ */
+public class GsServerSettings extends ServerSettings<Void, Void> {
+
+	@Override
+	public String toPropertiesString() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public ServerSettings parsePropertiesString(String propString)
+			throws MalformedURLException {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	
+	String url;
+	public String getUrl() {
+		return url;
+	}
+
+	public void setUrl(String url) {
+		this.url = url;
+	}
+
+	public String getUsername() {
+		return username;
+	}
+
+	public void setUsername(String username) {
+		this.username = username;
+	}
+
+	public String getPassword() {
+		return password;
+	}
+
+	public void setPassword(String password) {
+		this.password = password;
+	}
+
+
+	String username;
+	String password;
+
+}


Property changes on: trunk/src/skrueger/geotools/io/GsServerSettings.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: trunk/src/skrueger/geotools/io/ServerSettings.java
===================================================================
--- trunk/src/skrueger/geotools/io/ServerSettings.java	2010-11-21 20:58:12 UTC (rev 1290)
+++ trunk/src/skrueger/geotools/io/ServerSettings.java	2010-11-22 01:18:13 UTC (rev 1291)
@@ -1,5 +1,6 @@
 package skrueger.geotools.io;
 
+import java.net.MalformedURLException;
 import java.util.HashMap;
 
 public abstract class ServerSettings<T1, T2> extends HashMap<T1, T2> {
@@ -48,4 +49,7 @@
 		return title;
 	}
 
+	abstract public ServerSettings parsePropertiesString(String propString)
+			throws MalformedURLException ;
+
 }

Modified: trunk/src/skrueger/geotools/io/WfsServerList.java
===================================================================
--- trunk/src/skrueger/geotools/io/WfsServerList.java	2010-11-21 20:58:12 UTC (rev 1290)
+++ trunk/src/skrueger/geotools/io/WfsServerList.java	2010-11-22 01:18:13 UTC (rev 1291)
@@ -53,8 +53,7 @@
 
 		for (String s : split) {
 			try {
-				WfsServerSettings parsedWfsServer = WfsServerSettings
-						.parsePropertiesString(s);
+				WfsServerSettings parsedWfsServer = new WfsServerSettings(s);
 				if (parsedWfsServer == null) {
 					Log.error("Could not import a "
 							+ WfsServerSettings.class.getSimpleName()

Modified: trunk/src/skrueger/geotools/io/WfsServerSettings.java
===================================================================
--- trunk/src/skrueger/geotools/io/WfsServerSettings.java	2010-11-21 20:58:12 UTC (rev 1290)
+++ trunk/src/skrueger/geotools/io/WfsServerSettings.java	2010-11-22 01:18:13 UTC (rev 1291)
@@ -198,7 +198,8 @@
 	 *         .properties line. @see #parsePropertiesString
 	 * @throws MalformedURLException
 	 */
-	public static WfsServerSettings parsePropertiesString(String propString)
+	@Override
+	public WfsServerSettings parsePropertiesString(String propString)
 			throws MalformedURLException {
 
 		try {
@@ -239,6 +240,14 @@
 		setLenient(false);
 	}
 
+	public WfsServerSettings(String s) {
+		try {
+			parsePropertiesString(s);
+		} catch (MalformedURLException e) {
+			throw new RuntimeException(e);
+		}
+	}
+
 	public URL getBaseUrl() {
 		return (URL) get(Key.BASE_URL);
 	}

Modified: trunk/src_junit/skrueger/geotools/io/DbServerSettingsTest.java
===================================================================
--- trunk/src_junit/skrueger/geotools/io/DbServerSettingsTest.java	2010-11-21 20:58:12 UTC (rev 1290)
+++ trunk/src_junit/skrueger/geotools/io/DbServerSettingsTest.java	2010-11-22 01:18:13 UTC (rev 1291)
@@ -12,7 +12,7 @@
 public class DbServerSettingsTest {
 
 	@Test
-	public void testParseAndSerialize1() throws MalformedURLException {
+	public void testParseAndSerialize1()  {
 		DbServerSettings dbStore1 = new DbServerSettings(DbType.postgis);
 		dbStore1.setUsername("postgres");
 		dbStore1.setPassword("secret");
@@ -24,9 +24,9 @@
 
 		dbStore1.toPropertiesString();
 
-		DbServerSettings dbStore2 = DbServerSettings
-				.parsePropertiesString(dbStore1.toPropertiesString());
+		DbServerSettings dbStore2 = new DbServerSettings(dbStore1.toPropertiesString()); 
 
+
 		assertEquals(dbStore1.getDbType(), dbStore2.getDbType());
 
 		assertEquals(dbStore1.isWellDefined(), dbStore2.isWellDefined());

Modified: trunk/src_junit/skrueger/geotools/io/WfsServerSettingsTest.java
===================================================================
--- trunk/src_junit/skrueger/geotools/io/WfsServerSettingsTest.java	2010-11-21 20:58:12 UTC (rev 1290)
+++ trunk/src_junit/skrueger/geotools/io/WfsServerSettingsTest.java	2010-11-22 01:18:13 UTC (rev 1291)
@@ -21,7 +21,7 @@
 
 		assertTrue(wfs1.isWellDefined());
 
-		WfsServerSettings wfs2 = WfsServerSettings.parsePropertiesString(wfs1
+		WfsServerSettings wfs2 = new WfsServerSettings(wfs1
 				.toPropertiesString());
 
 		assertEquals(wfs1.getBaseUrl(), wfs2.getBaseUrl());
@@ -43,7 +43,7 @@
 		wfs1.setMaxFeatures(54321);
 		wfs1.setTitle("sweety");
 
-		WfsServerSettings wfs2 = WfsServerSettings.parsePropertiesString(wfs1
+		WfsServerSettings wfs2 = new WfsServerSettings(wfs1
 				.toPropertiesString());
 
 		assertEquals(wfs1.getBaseUrl(), wfs2.getBaseUrl());



More information about the Schmitzm-commits mailing list