use standard URL encoder
authorSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Mon, 6 Apr 2015 19:51:18 +0000 (22:51 +0300)
committerSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Mon, 6 Apr 2015 19:51:18 +0000 (22:51 +0300)
src/main/java/eu/svjatoslav/meviz/htmlindexer/WebIndexer.java

index acc1a28..213cfad 100644 (file)
@@ -3,8 +3,10 @@ package eu.svjatoslav.meviz.htmlindexer;
 import java.io.BufferedInputStream;
 import java.io.IOException;
 import java.io.ObjectInputStream;
+import java.io.UnsupportedEncodingException;
 import java.net.MalformedURLException;
 import java.net.URL;
+import java.net.URLEncoder;
 import java.util.List;
 
 import eu.svjatoslav.commons.network.UrlParamEncoder;
@@ -25,15 +27,27 @@ public class WebIndexer extends AbstractIndexer {
                this.jspPath = jspPath;
        }
 
+       @Override
+       public void compileHtml(final Layout layout,
+                       final DirectoryMetadata directory)
+                       throws UnsupportedEncodingException {
+               super.compileHtml(layout, directory);
+       }
+
        @Override
        public String getDirectoryUrl(final AbstractFile directory,
                        final IndexingContext context) {
-               return jspPath + context.getLocalUrl() + "/"
-                               + UrlParamEncoder.encode(directory.fileName);
+
+               try {
+                       return jspPath + context.getLocalUrl() + "/"
+                                       + URLEncoder.encode(directory.fileName, "UTF-8");
+               } catch (final UnsupportedEncodingException e) {
+                       throw new RuntimeException(e);
+               }
        }
 
        public String getHtml(String requestPath) throws MalformedURLException,
-       IOException, ClassNotFoundException {
+                       IOException, ClassNotFoundException {
 
                if (requestPath == null)
                        requestPath = "";
@@ -110,14 +124,14 @@ public class WebIndexer extends AbstractIndexer {
                // file path
                if (picture.getDimensions().equals(desiredDimension))
                        return context.getGlobalUrl() + context.getLocalUrl() + "/"
-                       + picture.fileName;
+                                       + picture.fileName;
 
                final String thumbnailFileName = picture
                                .getRelativeThumbnailFileName(desiredDimension);
 
                return context.getGlobalUrl() + context.getLocalUrl() + "/"
-               + Constants.THUMBNAILS_DIRECTORY_NAME + "/"
-               + UrlParamEncoder.encode(thumbnailFileName);
+                               + Constants.THUMBNAILS_DIRECTORY_NAME + "/"
+                               + UrlParamEncoder.encode(thumbnailFileName);
        }
 
 }