From 99240fb3b40e8dd7e3759d2b81ae9a4b05fae1b5 Mon Sep 17 00:00:00 2001 From: Svjatoslav Agejenko Date: Wed, 10 Jun 2015 22:56:14 +0300 Subject: [PATCH] use latest svjatoslavcommons --- pom.xml | 2 +- .../meviz/htmlindexer/FilesystemIndexer.java | 3 +-- .../eu/svjatoslav/meviz/htmlindexer/Utils.java | 11 +++++++++++ .../meviz/htmlindexer/WebIndexer.java | 5 ++--- .../meviz/htmlindexer/layouts/MixedLayout.java | 17 +++++++++-------- 5 files changed, 24 insertions(+), 14 deletions(-) diff --git a/pom.xml b/pom.xml index 233913b..9886233 100644 --- a/pom.xml +++ b/pom.xml @@ -17,7 +17,7 @@ eu.svjatoslav svjatoslavcommons - 1.4-SNAPSHOT + 1.5-SNAPSHOT diff --git a/src/main/java/eu/svjatoslav/meviz/htmlindexer/FilesystemIndexer.java b/src/main/java/eu/svjatoslav/meviz/htmlindexer/FilesystemIndexer.java index 061163e..d13306c 100755 --- a/src/main/java/eu/svjatoslav/meviz/htmlindexer/FilesystemIndexer.java +++ b/src/main/java/eu/svjatoslav/meviz/htmlindexer/FilesystemIndexer.java @@ -19,7 +19,6 @@ import java.util.List; import org.apache.log4j.Logger; import eu.svjatoslav.commons.file.IOHelper; -import eu.svjatoslav.commons.network.UrlParamEncoder; import eu.svjatoslav.meviz.htmlindexer.metadata.Dimension; import eu.svjatoslav.meviz.htmlindexer.metadata.DirectoryMetadata; import eu.svjatoslav.meviz.htmlindexer.metadata.MetadadaHelper; @@ -156,7 +155,7 @@ public class FilesystemIndexer extends AbstractIndexer { desiredDimension.getAwtDimension()); } return Constants.THUMBNAILS_DIRECTORY_NAME + "/" - + UrlParamEncoder.encode(thumbnailFileName); + + Utils.urlEncode(thumbnailFileName); } public void initializeLayouts() { diff --git a/src/main/java/eu/svjatoslav/meviz/htmlindexer/Utils.java b/src/main/java/eu/svjatoslav/meviz/htmlindexer/Utils.java index 6200e06..4455992 100755 --- a/src/main/java/eu/svjatoslav/meviz/htmlindexer/Utils.java +++ b/src/main/java/eu/svjatoslav/meviz/htmlindexer/Utils.java @@ -15,6 +15,8 @@ import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; import java.util.HashSet; import java.util.zip.CRC32; @@ -25,6 +27,7 @@ import eu.svjatoslav.meviz.htmlindexer.layouts.MixedLayout; public class Utils { private static File lastLoadedFile; + private static final String UTF_8 = "UTF-8"; private static BufferedImage lastLoadedBufferedImage; @@ -125,4 +128,12 @@ public class Utils { return isMevizFile; } + public static String urlEncode(String string) { + try { + return URLEncoder.encode(string, UTF_8); + } catch (UnsupportedEncodingException e) { + throw new RuntimeException(e); + } + } + } diff --git a/src/main/java/eu/svjatoslav/meviz/htmlindexer/WebIndexer.java b/src/main/java/eu/svjatoslav/meviz/htmlindexer/WebIndexer.java index 213cfad..7cf1d20 100644 --- a/src/main/java/eu/svjatoslav/meviz/htmlindexer/WebIndexer.java +++ b/src/main/java/eu/svjatoslav/meviz/htmlindexer/WebIndexer.java @@ -9,7 +9,6 @@ import java.net.URL; import java.net.URLEncoder; import java.util.List; -import eu.svjatoslav.commons.network.UrlParamEncoder; import eu.svjatoslav.meviz.htmlindexer.layouts.MixedLayout; import eu.svjatoslav.meviz.htmlindexer.metadata.Dimension; import eu.svjatoslav.meviz.htmlindexer.metadata.DirectoryMetadata; @@ -73,7 +72,7 @@ public class WebIndexer extends AbstractIndexer { final StringBuffer urlStringBuffer = new StringBuffer(); urlStringBuffer.append(globalPrefix); - urlStringBuffer.append(UrlParamEncoder.encode(requestPath)); + urlStringBuffer.append(Utils.urlEncode(requestPath)); urlStringBuffer.append("/.thumbnails/metadata_6.dat"); final String urlString = urlStringBuffer.toString(); @@ -131,7 +130,7 @@ public class WebIndexer extends AbstractIndexer { return context.getGlobalUrl() + context.getLocalUrl() + "/" + Constants.THUMBNAILS_DIRECTORY_NAME + "/" - + UrlParamEncoder.encode(thumbnailFileName); + + Utils.urlEncode(thumbnailFileName); } } diff --git a/src/main/java/eu/svjatoslav/meviz/htmlindexer/layouts/MixedLayout.java b/src/main/java/eu/svjatoslav/meviz/htmlindexer/layouts/MixedLayout.java index f721ba6..cf1285e 100755 --- a/src/main/java/eu/svjatoslav/meviz/htmlindexer/layouts/MixedLayout.java +++ b/src/main/java/eu/svjatoslav/meviz/htmlindexer/layouts/MixedLayout.java @@ -16,11 +16,11 @@ import java.util.List; import org.apache.log4j.Logger; import eu.svjatoslav.commons.file.FilePathParser; -import eu.svjatoslav.commons.network.UrlParamEncoder; import eu.svjatoslav.meviz.htmlindexer.AbstractIndexer; import eu.svjatoslav.meviz.htmlindexer.Constants; import eu.svjatoslav.meviz.htmlindexer.IndexingContext; import eu.svjatoslav.meviz.htmlindexer.Layout; +import eu.svjatoslav.meviz.htmlindexer.Utils; import eu.svjatoslav.meviz.htmlindexer.metadata.Dimension; import eu.svjatoslav.meviz.htmlindexer.metadata.DirectoryMetadata; import eu.svjatoslav.meviz.htmlindexer.metadata.fileTypes.AbstractFile; @@ -64,7 +64,7 @@ public class MixedLayout implements Layout { filesHtml.append("
" + fullFileName + "\n"); filesHtml.append("  (" + FilePathParser.getFileSizeDescription(file.getFileLength()) @@ -115,8 +115,9 @@ public class MixedLayout implements Layout { // clickable image thumbnail filesHtml.append("\n"); + filesHtml.append("
\n"); @@ -147,8 +148,8 @@ public class MixedLayout implements Layout { filesHtml .append("\n"); + + Utils.urlEncode(indexingContext.getLocalUrl() + "/" + + file.fileName) + "\">\n"); filesHtml.append("\n"); filesHtml.append("\n"); filesHtml.append("
\n"); @@ -163,7 +164,7 @@ public class MixedLayout implements Layout { // video download link filesHtml.append("download as OGV file"); filesHtml.append("
\n"); @@ -282,7 +283,7 @@ public class MixedLayout implements Layout { // watchable video String fileUrl = indexingContext.getGlobalUrl() - + UrlParamEncoder.encode(indexingContext.getLocalUrl() + "/" + + Utils.urlEncode(indexingContext.getLocalUrl() + "/" + file.fileName); filesHtml.append("