Skip to content

Commit

Permalink
Revert "[GEOS-7204] Integrated geofence odd path for db under Windows"
Browse files Browse the repository at this point in the history
This reverts commit 55ab5a5.
Not really working on windows, must revisit
  • Loading branch information
aaime committed Oct 16, 2015
1 parent 55ab5a5 commit 4f5e0df
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 166 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,78 +4,30 @@
*/
package org.geoserver.config;

import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Pattern;

import org.geoserver.ows.util.OwsUtils;
import org.geotools.util.logging.Logging;
import org.geoserver.config.GeoServerDataDirectory;
import org.springframework.beans.factory.config.PropertyOverrideConfigurer;
import org.springframework.core.io.FileSystemResource;
import org.springframework.core.io.Resource;
import org.springframework.core.io.UrlResource;

/**
*
* Allows the use of ${GEOSERVER_DATA_DIR} inside properties to refer to the data directory, irrespective of whether that system property has been set
* or not.
* Allows the use of ${GEOSERVER_DATA_DIR} inside properties to refer to the data directory,
* irrespective of whether that system property has been set or not.
*
* @author niels
*
*/
public class GeoServerPropertyOverrideConfigurer extends PropertyOverrideConfigurer {

private static final String DATA_DIR = "${GEOSERVER_DATA_DIR}";

private static final String DATA_DIR_PATTERN = Pattern.quote(DATA_DIR);

static final Logger LOGGER = Logging.getLogger(GeoServerPropertyOverrideConfigurer.class);


protected GeoServerDataDirectory data;

private String dataDirUnixPath;

public GeoServerPropertyOverrideConfigurer(GeoServerDataDirectory data) throws IOException {

public GeoServerPropertyOverrideConfigurer(GeoServerDataDirectory data) {
this.data = data;
this.dataDirUnixPath = data.root().getCanonicalFile().getAbsolutePath().replace("\\", "/");
}

@Override
public void setLocations(Resource[] locations) {
for (int i = 0; i < locations.length; i++) {
locations[i] = resolveDataDirectory(locations[i]);
}
}

@Override
public void setLocation(Resource location) {
Resource resolved = resolveDataDirectory(location);
super.setLocation(resolved);
}

private Resource resolveDataDirectory(Resource location) {
try {
if(OwsUtils.has(location, "path")) {
String path = (String) OwsUtils.get(location, "path");
if (path != null && path.contains(DATA_DIR)) {
String resolvedPath = path.replaceAll(DATA_DIR_PATTERN,
dataDirUnixPath);
location = new FileSystemResource(new File(resolvedPath));
}
}
} catch (Exception e) {
LOGGER.log(Level.FINE, "Error reading resource " + location, e);
}

return location;
}

@Override
protected String convertPropertyValue(String property) {
return property.replaceAll(DATA_DIR_PATTERN, dataDirUnixPath);
return property.replaceAll(Pattern.quote("${GEOSERVER_DATA_DIR}"), data.root().toString());
}

}

This file was deleted.

This file was deleted.

0 comments on commit 4f5e0df

Please sign in to comment.