View Javadoc

1   package org.paneris.bibliomania;
2   
3   import java.io.File;
4   
5   import org.melati.Melati;
6   import org.melati.poem.util.ArrayUtils;
7   import org.melati.poem.util.StringUtils;
8   import org.webmacro.WebMacroException;
9   import org.webmacro.servlet.WebContext;
10  
11  public class Serve extends BibliomaniaServlet {
12  
13    /**
14     * 
15     */
16    private static final long serialVersionUID = 1L;
17  
18    public class ServeContext extends BibContext {
19      public String subPath;
20    }
21  
22    protected BibContext melatiContext() {
23      return new ServeContext();
24    }
25  
26    protected void decipherExtraPathInfo(String[] parts, BibContext it) {
27      String subPath =
28          StringUtils.concatenated(
29              File.separator,
30              (String[])ArrayUtils.section(parts, 4, parts.length));
31  
32      if (subPath.indexOf("..") != -1)
33        throw new RuntimeException(
34            "Access to " + subPath + " denied because it contains `..'");
35  
36      ((ServeContext)it).subPath = subPath;
37    }
38  
39    protected String bibliomaniaHandle(Melati melati, WebContext context)
40        throws WebMacroException {
41      return bibliomaniaTemplate("read/Special.wm");
42    }
43  }
44  
45  
46  
47