Skip to content

Commit

Permalink
GEOS-7335: org.geoserver.catalog.rest.CoverageStoreFileUploadTest fai…
Browse files Browse the repository at this point in the history
…ls on windows
  • Loading branch information
NielsCharlier committed Dec 4, 2015
1 parent e68bc90 commit f2a5c40
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
Expand Up @@ -428,7 +428,7 @@ public static org.geoserver.platform.resource.Resource fromPath(String path,
if (file.isAbsolute()) { if (file.isAbsolute()) {
return Files.asResource(file); return Files.asResource(file);
} else { } else {
return relativeDir.get(path); return relativeDir.get(path.replace(File.separatorChar, '/'));
} }
} }


Expand Down
Expand Up @@ -7,6 +7,7 @@


import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
Expand Down Expand Up @@ -150,29 +151,34 @@ public void handlePut() {


String defaultRoot = "/data/" + workspace + "/" + coveragestore; 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; String url;
if(uploadedFile.getType() == Type.DIRECTORY && uploadedFile.name().equals(coveragestore)) { if(uploadedFile.getType() == Type.DIRECTORY && uploadedFile.name().equals(coveragestore)) {


int def = fileBuilder.indexOf(defaultRoot); int def = urlBuilder.indexOf(defaultRoot);


if(def >= 0){ if(def >= 0){
url = "file:data/" + workspace + "/" + coveragestore; url = "file:data/" + workspace + "/" + coveragestore;
}else{ }else{
url = fileBuilder.toString(); url = urlBuilder.toString();
} }
} else { } else {


int def = fileBuilder.indexOf(defaultRoot); int def = urlBuilder.indexOf(defaultRoot);


if(def >= 0){ if(def >= 0){


String itemPath = fileBuilder.substring(def + defaultRoot.length()); String itemPath = urlBuilder.substring(def + defaultRoot.length());


url = "file:data/" + workspace + "/" + coveragestore + itemPath; url = "file:data/" + workspace + "/" + coveragestore + itemPath;
}else{ }else{
url = fileBuilder.toString(); url = urlBuilder.toString();
} }
} }
if (url.contains("+")) { if (url.contains("+")) {
Expand Down
Expand Up @@ -121,14 +121,8 @@ private org.geoserver.platform.resource.Resource createFinalRoot(String workspac
|| (workspaceName != null && coverage.getWorkspace().getName() || (workspaceName != null && coverage.getWorkspace().getName()
.equalsIgnoreCase(workspaceName))) { .equalsIgnoreCase(workspaceName))) {
// If the coverage exists then the associated directory is defined by its URL // If the coverage exists then the associated directory is defined by its URL
File dirFile = DataUtilities.urlToFile(new URL(coverage.getURL())); directory = Resources.fromPath(DataUtilities.urlToFile(new URL(coverage.getURL())).getPath(),

catalog.getResourceLoader().get(""));
// 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());
}
} }
} }
} }
Expand Down

0 comments on commit f2a5c40

Please sign in to comment.