Commit f2a5c402 authored by Niels Charlier's avatar Niels Charlier
Browse files

GEOS-7335: org.geoserver.catalog.rest.CoverageStoreFileUploadTest fails on windows

parent e68bc90c
......@@ -428,7 +428,7 @@ public class Resources {
if (file.isAbsolute()) {
return Files.asResource(file);
} else {
return relativeDir.get(path);
return relativeDir.get(path.replace(File.separatorChar, '/'));
}
}
......
......@@ -7,6 +7,7 @@ package org.geoserver.catalog.rest;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
......@@ -150,29 +151,34 @@ public class CoverageStoreFileResource extends StoreFileResource {
String defaultRoot = "/data/" + workspace + "/" + coveragestore;
StringBuilder fileBuilder = new StringBuilder(Resources.find(uploadedFile).getAbsolutePath());
StringBuilder urlBuilder;
try {
urlBuilder = new StringBuilder(Resources.find(uploadedFile).toURI().toURL().toString());
} catch (MalformedURLException e) {
throw new RestletException("Error create building coverage URL", Status.SERVER_ERROR_INTERNAL, e);
}
String url;
if(uploadedFile.getType() == Type.DIRECTORY && uploadedFile.name().equals(coveragestore)) {
int def = fileBuilder.indexOf(defaultRoot);
int def = urlBuilder.indexOf(defaultRoot);
if(def >= 0){
url = "file:data/" + workspace + "/" + coveragestore;
}else{
url = fileBuilder.toString();
url = urlBuilder.toString();
}
} else {
int def = fileBuilder.indexOf(defaultRoot);
int def = urlBuilder.indexOf(defaultRoot);
if(def >= 0){
String itemPath = fileBuilder.substring(def + defaultRoot.length());
String itemPath = urlBuilder.substring(def + defaultRoot.length());
url = "file:data/" + workspace + "/" + coveragestore + itemPath;
}else{
url = fileBuilder.toString();
url = urlBuilder.toString();
}
}
if (url.contains("+")) {
......
......@@ -121,14 +121,8 @@ public abstract class StoreFileResource extends Resource {
|| (workspaceName != null && coverage.getWorkspace().getName()
.equalsIgnoreCase(workspaceName))) {
// If the coverage exists then the associated directory is defined by its URL
File dirFile = DataUtilities.urlToFile(new URL(coverage.getURL()));
// If the directory is relative and then the directory is searched inside the data directory
if (dirFile.isAbsolute()) {
directory = Files.asResource(dirFile);
} else {
directory = catalog.getResourceLoader().get(dirFile.getPath());
}
directory = Resources.fromPath(DataUtilities.urlToFile(new URL(coverage.getURL())).getPath(),
catalog.getResourceLoader().get(""));
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment