projects
/
meviz.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
use latest svjatoslavcommons
[meviz.git]
/
src
/
main
/
java
/
eu
/
svjatoslav
/
meviz
/
htmlindexer
/
Utils.java
diff --git
a/src/main/java/eu/svjatoslav/meviz/htmlindexer/Utils.java
b/src/main/java/eu/svjatoslav/meviz/htmlindexer/Utils.java
index
f8c82fa
..
4455992
100755
(executable)
--- a/
src/main/java/eu/svjatoslav/meviz/htmlindexer/Utils.java
+++ b/
src/main/java/eu/svjatoslav/meviz/htmlindexer/Utils.java
@@
-1,7
+1,7
@@
/*
* Meviz - Various tools collection to work with multimedia.
* Copyright (C) 2012, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
/*
* Meviz - Various tools collection to work with multimedia.
* Copyright (C) 2012, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
- *
+ *
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU General Public License
* as published by the Free Software Foundation.
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU General Public License
* as published by the Free Software Foundation.
@@
-15,6
+15,8
@@
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
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;
import java.util.HashSet;
import java.util.zip.CRC32;
@@
-25,13
+27,14
@@
import eu.svjatoslav.meviz.htmlindexer.layouts.MixedLayout;
public class Utils {
private static File lastLoadedFile;
public class Utils {
private static File lastLoadedFile;
+ private static final String UTF_8 = "UTF-8";
private static BufferedImage lastLoadedBufferedImage;
/**
* Load image into {@link BufferedImage} and return it. Caches last loaded
* image to speed up subsequent loading attempts.
private static BufferedImage lastLoadedBufferedImage;
/**
* Load image into {@link BufferedImage} and return it. Caches last loaded
* image to speed up subsequent loading attempts.
- *
+ *
* @throws ImageFormatError
* @throws IOException
*/
* @throws ImageFormatError
* @throws IOException
*/
@@
-44,10
+47,13
@@
public class Utils {
lastLoadedBufferedImage = ImageIO.read(file);
lastLoadedFile = file;
lastLoadedBufferedImage = ImageIO.read(file);
lastLoadedFile = file;
- if (lastLoadedBufferedImage == null)
+ if (lastLoadedBufferedImage == null) {
+ System.out.println("Error reading image: " + file);
throw new ImageFormatError("File: " + file
+ " is not a valid image.");
throw new ImageFormatError("File: " + file
+ " is not a valid image.");
+ }
+
return lastLoadedBufferedImage;
}
return lastLoadedBufferedImage;
}
@@
-87,8
+93,12
@@
public class Utils {
}
public static File getThumbnailsDirectory(final File directoryToIndex) {
}
public static File getThumbnailsDirectory(final File directoryToIndex) {
- return new File(directoryToIndex.getAbsolutePath() + "/"
- + Constants.THUMBNAILS_DIRECTORY_NAME + "/");
+ return new File(getThumbnailsDirectoryPath(directoryToIndex));
+ }
+
+ public static String getThumbnailsDirectoryPath(final File directoryToIndex) {
+ return directoryToIndex.getAbsolutePath() + "/"
+ + Constants.THUMBNAILS_DIRECTORY_NAME + "/";
}
public static boolean isMevizGeneratedIndexFile(final File indexFile)
}
public static boolean isMevizGeneratedIndexFile(final File indexFile)
@@
-118,4
+128,12
@@
public class Utils {
return isMevizFile;
}
return isMevizFile;
}
+ public static String urlEncode(String string) {
+ try {
+ return URLEncoder.encode(string, UTF_8);
+ } catch (UnsupportedEncodingException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
}
}