148 |
* .properties line. @see #parsePropertiesString |
* .properties line. @see #parsePropertiesString |
149 |
* @throws MalformedURLException |
* @throws MalformedURLException |
150 |
*/ |
*/ |
151 |
public static DbServerSettings parsePropertiesString(String propString) |
@Override |
152 |
|
public boolean parsePropertiesString(String propString) |
153 |
throws MalformedURLException { |
throws MalformedURLException { |
154 |
|
|
155 |
if (propString == null || propString.isEmpty()) |
if (propString == null || propString.isEmpty()) |
159 |
String[] split = propString.split(Pattern.quote(DELIMITER)); |
String[] split = propString.split(Pattern.quote(DELIMITER)); |
160 |
|
|
161 |
int i = 0; |
int i = 0; |
162 |
DbServerSettings dbServer = new DbServerSettings( |
setDbType( DbType.valueOf(split[i++])); |
163 |
DbType.valueOf(split[i++])); |
// DbServerSettings dbServer = new DbServerSettings( |
164 |
|
// DbType.valueOf(split[i++]) |
165 |
|
// ); |
166 |
|
|
167 |
|
setTitle(split[i++]); |
168 |
|
setHost(split[i++]); |
169 |
|
setPort(java.lang.Integer.valueOf(split[i++])); |
170 |
|
setUsername(StringUtils.stripToNull(split[i++])); |
171 |
|
setPassword(split[i++]); |
172 |
|
setDatabase(split[i++]); |
173 |
|
setExposePrimaryKey(Boolean.valueOf(split[i++])); |
174 |
|
setSchema(stringOrNull(split[i++])); |
175 |
|
|
176 |
dbServer.setTitle(split[i++]); |
return true; |
|
dbServer.setHost(split[i++]); |
|
|
dbServer.setPort(java.lang.Integer.valueOf(split[i++])); |
|
|
dbServer.setUsername(StringUtils.stripToNull(split[i++])); |
|
|
dbServer.setPassword(split[i++]); |
|
|
dbServer.setDatabase(split[i++]); |
|
|
dbServer.setExposePrimaryKey(Boolean.valueOf(split[i++])); |
|
|
dbServer.setSchema(stringOrNull(split[i++])); |
|
|
|
|
|
return dbServer; |
|
177 |
} catch (Exception e) { |
} catch (Exception e) { |
178 |
Log.warn("couldn't parse " + propString, e); |
Log.warn("couldn't parse " + propString, e); |
179 |
return null; |
return false; |
180 |
} |
} |
181 |
} |
} |
182 |
|
|
185 |
|
|
186 |
public DbServerSettings() { |
public DbServerSettings() { |
187 |
this(DbType.postgis); |
this(DbType.postgis); |
188 |
|
|
189 |
} |
} |
190 |
|
|
191 |
public DbServerSettings(DbType dbType) { |
public DbServerSettings(DbType dbType) { |
195 |
put(JDBCDataStoreFactory.PK_METADATA_TABLE.key, null); |
put(JDBCDataStoreFactory.PK_METADATA_TABLE.key, null); |
196 |
} |
} |
197 |
|
|
198 |
|
public DbServerSettings(String propertiesString) { |
199 |
|
try { |
200 |
|
parsePropertiesString(propertiesString); |
201 |
|
} catch (MalformedURLException e) { |
202 |
|
throw new RuntimeException(e); |
203 |
|
} |
204 |
|
} |
205 |
|
|
206 |
public String[] getCachedTypeNames() { |
public String[] getCachedTypeNames() { |
207 |
return cachedTypeNames; |
return cachedTypeNames; |
208 |
} |
} |