+ private static final int METADATA_LOAD_TRY_COUNT = 10;
+ private final String globalPrefix;
+ private final String jspPath;
+
+ public WebIndexer(final String globalPrefix, final String jspPath) {
+ this.globalPrefix = globalPrefix;
+ 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) {
+
+ 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
+ IOException, ClassNotFoundException {
+
+ if (requestPath == null)
+ requestPath = "";
+
+ if (requestPath.equals("/"))
+ requestPath = "";
+
+ final MixedLayout layout = new MixedLayout();
+ final IndexingContext context = new IndexingContext(globalPrefix,
+ requestPath);
+ layout.init("Photos", context.getLocalPathComponents(), this, context);
+
+ final DirectoryMetadata directory = getMetadataForPath(requestPath);
+
+ compileHtml(layout, directory);
+
+ return layout.getHtml(false, false, directory);
+ }
+
+ private DirectoryMetadata getMetadataForPath(final String requestPath)
+ throws ClassNotFoundException, IOException {
+
+ final String urlString = globalPrefix +
+ Utils.urlEncode(requestPath) +
+ "/.thumbnails/metadata_6.dat";