1 package eu.svjatoslav.meviz.htmlindexer;
3 import java.io.BufferedInputStream;
4 import java.io.IOException;
5 import java.io.ObjectInputStream;
6 import java.net.MalformedURLException;
9 import eu.svjatoslav.meviz.htmlindexer.layouts.MixedLayout;
10 import eu.svjatoslav.meviz.htmlindexer.metadata.Dimension;
11 import eu.svjatoslav.meviz.htmlindexer.metadata.DirectoryMetadata;
12 import eu.svjatoslav.meviz.htmlindexer.metadata.fileTypes.AbstractFile;
13 import eu.svjatoslav.meviz.htmlindexer.metadata.fileTypes.Picture;
15 public class WebIndexer extends AbstractIndexer {
17 private final MixedLayout layout = new MixedLayout();
18 private final String localPrefix;
19 private final String globalPrefix;
21 public WebIndexer(final String globalPrefix, final String localPrefix) {
22 this.globalPrefix = globalPrefix;
23 this.localPrefix = localPrefix;
27 public String getDirectoryUrl(final AbstractFile directory) {
28 return "photos.jsp?path=/" + directory.fileName;
31 public String getHtml(final String path) throws MalformedURLException,
32 IOException, ClassNotFoundException {
34 layout.init("Photos", new String[] {}, this, localPrefix);
36 final DirectoryMetadata metadata = getMetadataForPath();
38 compileHtml(layout, metadata);
40 return layout.getHtml();
43 public DirectoryMetadata getMetadataForPath() throws IOException,
44 MalformedURLException, ClassNotFoundException {
46 final BufferedInputStream in = new BufferedInputStream(
47 new URL(globalPrefix + localPrefix
48 + ".thumbnails/metadata_6.dat").openStream());
50 final ObjectInputStream oin = new ObjectInputStream(in);
51 final DirectoryMetadata directory = (DirectoryMetadata) oin
59 public String getThumbnailPath(final Picture picture,
60 final Dimension desiredDimension) {
62 // in case thumbnail size was equal to original, then return original
64 if (picture.getDimensions().equals(desiredDimension))
65 return localPrefix + picture.fileName;
67 final String thumbnailFileName = picture
68 .getRelativeThumbnailFileName(desiredDimension);
70 return localPrefix + Constants.THUMBNAILS_DIRECTORY_NAME + "/"