use latest svjatoslavcommons
authorSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Wed, 10 Jun 2015 19:56:14 +0000 (22:56 +0300)
committerSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Wed, 10 Jun 2015 19:56:14 +0000 (22:56 +0300)
pom.xml
src/main/java/eu/svjatoslav/meviz/htmlindexer/FilesystemIndexer.java
src/main/java/eu/svjatoslav/meviz/htmlindexer/Utils.java
src/main/java/eu/svjatoslav/meviz/htmlindexer/WebIndexer.java
src/main/java/eu/svjatoslav/meviz/htmlindexer/layouts/MixedLayout.java

diff --git a/pom.xml b/pom.xml
index 233913b..9886233 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -17,7 +17,7 @@
                <dependency>
                        <groupId>eu.svjatoslav</groupId>
                        <artifactId>svjatoslavcommons</artifactId>
-                       <version>1.4-SNAPSHOT</version>
+                       <version>1.5-SNAPSHOT</version>
                </dependency>
 
                <dependency>
index 061163e..d13306c 100755 (executable)
@@ -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() {
index 6200e06..4455992 100755 (executable)
@@ -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);
+               }
+       }
+
 }
index 213cfad..7cf1d20 100644 (file)
@@ -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);
        }
 
 }
index f721ba6..cf1285e 100755 (executable)
@@ -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("<div style=\"clear: both;\"><a href=\""
                                + indexingContext.getGlobalUrl()
-                               + UrlParamEncoder.encode(indexingContext.getLocalUrl() + "/"
+                               + Utils.urlEncode(indexingContext.getLocalUrl() + "/"
                                                + fullFileName) + "\">" + fullFileName + "</a>\n");
                filesHtml.append("&nbsp;&nbsp;("
                                + FilePathParser.getFileSizeDescription(file.getFileLength())
@@ -115,8 +115,9 @@ public class MixedLayout implements Layout {
                // clickable image thumbnail
                filesHtml.append("<a href=\""
                                + indexingContext.getGlobalUrl()
-                               + UrlParamEncoder.encode(indexingContext.getLocalUrl() + "/"
+                               + Utils.urlEncode(indexingContext.getLocalUrl() + "/"
                                                + picture.fileName) + "\">\n");
+
                filesHtml.append("<img border=\"0\" src=\""
                                + getImageThumbnailUrl(picture) + "\"/></a><br/>\n");
 
@@ -147,8 +148,8 @@ public class MixedLayout implements Layout {
                filesHtml
                                .append("<source type=\"video/ogg\" codecs=\"theora, vorbis\" src=\""
                                                + indexingContext.getGlobalUrl()
-                                               + UrlParamEncoder.encode(indexingContext.getLocalUrl()
-                                                               + "/" + file.fileName) + "\">\n");
+                                               + Utils.urlEncode(indexingContext.getLocalUrl() + "/"
+                                                               + file.fileName) + "\">\n");
                filesHtml.append("</source>\n");
                filesHtml.append("</video>\n");
                filesHtml.append("<br/>\n");
@@ -163,7 +164,7 @@ public class MixedLayout implements Layout {
                // video download link
                filesHtml.append("<a href=\""
                                + indexingContext.getGlobalUrl()
-                               + UrlParamEncoder.encode(indexingContext.getLocalUrl() + "/"
+                               + Utils.urlEncode(indexingContext.getLocalUrl() + "/"
                                                + file.fileName) + "\">download as OGV file</a>");
 
                filesHtml.append("</div>\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("<video controls>\n");
@@ -301,7 +302,7 @@ public class MixedLayout implements Layout {
                // video download link
                filesHtml.append("<a href=\""
                                + indexingContext.getGlobalUrl()
-                               + UrlParamEncoder.encode(indexingContext.getLocalUrl() + "/"
+                               + Utils.urlEncode(indexingContext.getLocalUrl() + "/"
                                                + file.fileName) + "\">download as WebM file</a>");
 
                filesHtml.append("</div>\n");