Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Frost2012-09-27 10:45:18 -0400
committerChristopher Frost2012-09-27 10:45:18 -0400
commit61aee20325e5ba01540c33abd2cc0bc7bd4bc0ad (patch)
tree12b0b833efee5d1b361c12d54f2f44110724a705
parent427f3cc1d7f1a613238a7ff4b6b8db2ffb15e49a (diff)
downloadorg.eclipse.virgo.kernel-61aee20325e5ba01540c33abd2cc0bc7bd4bc0ad.tar.gz
org.eclipse.virgo.kernel-61aee20325e5ba01540c33abd2cc0bc7bd4bc0ad.tar.xz
org.eclipse.virgo.kernel-61aee20325e5ba01540c33abd2cc0bc7bd4bc0ad.zip
388436 Using absolute paths whenever possible in an attempt to avoid the crapness of the windows file system
-rw-r--r--org.eclipse.virgo.management.console/src/main/java/org/eclipse/virgo/management/console/UploadServlet.java9
1 files changed, 5 insertions, 4 deletions
diff --git a/org.eclipse.virgo.management.console/src/main/java/org/eclipse/virgo/management/console/UploadServlet.java b/org.eclipse.virgo.management.console/src/main/java/org/eclipse/virgo/management/console/UploadServlet.java
index f8923ea8..df5e9e3e 100644
--- a/org.eclipse.virgo.management.console/src/main/java/org/eclipse/virgo/management/console/UploadServlet.java
+++ b/org.eclipse.virgo.management.console/src/main/java/org/eclipse/virgo/management/console/UploadServlet.java
@@ -69,7 +69,7 @@ public class UploadServlet extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
try {
- createStagingDirectory();
+ File stagingDir = createStagingDirectory();
FileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload upload = new ServletFileUpload(factory);
response.setContentType("text/html");
@@ -81,7 +81,7 @@ public class UploadServlet extends HttpServlet {
if (!fileItem.isFormField()) {
String name = fileItem.getName();
if(name != null && name.length() > 0){
- File uploadedFile = new File(String.format("%s%s/%s", this.serverHome, STAGING_DIR, name));
+ File uploadedFile = new File(stagingDir, name);
fileItem.write(uploadedFile);
log.info(String.format("Uploaded artifact of size (%db) to %s", fileItem.getSize(), uploadedFile.getPath()));
writer.append("<li>" + uploadedFile.getAbsolutePath() + "</li>");
@@ -96,13 +96,14 @@ public class UploadServlet extends HttpServlet {
}
}
- private void createStagingDirectory() throws IOException {
+ private File createStagingDirectory() throws IOException {
File pathReference = new File(String.format("%s%s", this.serverHome, STAGING_DIR));
if (!pathReference.exists()) {
if (!pathReference.mkdirs()) {
- throw new IOException("Unable to create directory " + pathReference.getPath());
+ throw new IOException("Unable to create directory " + pathReference.getAbsolutePath());
}
}
+ return pathReference.getAbsoluteFile();
}
}

Back to the top