View Javadoc

1   package org.paneris.bibliomania;
2   
3   import java.io.File;
4   
5   import org.melati.Melati;
6   import org.melati.poem.AccessToken;
7   import org.melati.poem.PoemTask;
8   import org.melati.poem.UnexpectedExceptionPoemException;
9   import org.webmacro.servlet.WebContext;
10  
11  public class RegenerateNavigation extends BibliomaniaServlet {
12  
13    /**
14     * 
15     */
16    private static final long serialVersionUID = 1L;
17  
18    private static void doRegen(BibliomaniaDatabase db) throws Exception {
19      db.interpolateTemplateToFile(Bib.bibliomaniaTemplate("bookToURL"),
20          new File(db.getCachedContentRootDir(),
21                   "bookToURL.html"),
22          null);
23      db.interpolateTemplateToFile(Bib.bibliomaniaTemplate("createSymLinks.pl"),
24          new File(db.getCachedContentRootDir(),
25                   "createSymLinks.pl"),
26          null);
27      db.interpolateTemplateToFile(Bib.bibliomaniaTemplate("google"),
28                             new File(db.getCachedContentRootDir(),
29                                      "google.html"),
30                             null);
31      db.interpolateTemplateToFile(Bib.bibliomaniaTemplate("totalContents"),
32                             new File(db.getCachedContentRootDir(),
33                                      "contents.html"),
34                             null);
35      db.interpolateTemplateToFile(Bib.bibliomaniaTemplate("totalnav"),
36                             new File(db.getCachedContentRootDir(),
37                                      "totalnav.html"),
38                             null);
39      db.interpolateTemplateToFile(Bib.bibliomaniaTemplate("Faq"),
40                             new File(db.getCachedContentRootDir(),
41                                      "Faq.html"),
42                             null);
43    }
44  
45    protected String bibliomaniaHandle(Melati melati, WebContext context)
46        throws Exception {
47      doRegen((BibliomaniaDatabase)melati.getDatabase());
48      return bibliomaniaTemplate("admin/RegenerateNavigation");
49    }
50  
51    public static void main(final String[] args) {
52      final BibliomaniaDatabase db = new BibliomaniaDatabase();
53      db.connect("bibliomania","org.melati.poem.dbms.Postgresql",
54                  "jdbc:postgresql:bibliomania", "postgres", "*",8);
55  
56      db.inSession(
57          AccessToken.root,       // FIXME
58          new PoemTask() {
59            public void run() {
60              try {
61                doRegen(db);
62              }
63              catch (Exception e) {
64                throw new UnexpectedExceptionPoemException(e);
65              }
66            }
67          });
68    }
69  }