View Javadoc

1   package org.paneris.bibliomania;
2   
3   import java.io.IOException;
4   import java.net.HttpURLConnection;
5   import java.net.MalformedURLException;
6   import java.net.URL;
7   
8   import org.melati.Melati;
9   import org.melati.admin.AdminSpecialised;
10  import org.melati.template.MarkupLanguage;
11  import org.paneris.bibliomania.generated.AuthorWebSiteBase;
12  
13  /**
14   * Melati POEM generated, programmer modifiable stub 
15   * for a <code>Persistent</code> <code>AuthorWebSite</code> object.
16   * 
17   * <p> 
18   * Description: 
19   *   A web site devoted to an author. 
20   * </p>
21   * 
22   * <table> 
23   * <tr><th colspan='3'>
24   * Field summary for SQL table <code>AuthorWebSite</code>
25   * </th></tr>
26   * <tr><th>Name</th><th>Type</th><th>Description</th></tr>
27   * <tr><td> id </td><td> Integer </td><td> &nbsp; </td></tr> 
28   * <tr><td> author </td><td> Author </td><td> The author to whom the site is 
29   * dedicated </td></tr> 
30   * <tr><td> url </td><td> String </td><td> The full URL for the site's front 
31   * page </td></tr> 
32   * <tr><td> displayname </td><td> String </td><td> The site's name </td></tr> 
33   * <tr><td> displayorder </td><td> Integer </td><td> &nbsp; </td></tr> 
34   * <tr><td> description </td><td> String </td><td> &nbsp; </td></tr> 
35   * </table> 
36   * 
37   * @see org.melati.poem.prepro.TableDef#generatePersistentJava 
38   */
39  public class AuthorWebSite  extends AuthorWebSiteBase implements AdminSpecialised {
40  
41   /**
42    * Constructor 
43    * for a <code>Persistent</code> <code>AuthorWebSite</code> object.
44    * <p>
45    * Description: 
46    *   A web site devoted to an author. 
47    * </p>
48    * 
49    * @see org.melati.poem.prepro.TableDef#generatePersistentJava 
50    */
51    public AuthorWebSite() { }
52  
53    // programmer's domain-specific code here
54    
55  
56    public boolean isStillLive() { 
57      System.err.println(getUrl());
58      HttpURLConnection  it = null;
59      try {
60        it = (HttpURLConnection) new URL(getUrl()).openConnection();
61      } catch (MalformedURLException e) {
62        System.err.println("Malformed:" +getUrl());
63        return false;
64      } catch (IOException e) {
65        System.err.println("Not findable: " + getUrl());
66        return false;
67      }
68      try {
69        int responseCode = it.getResponseCode();
70        if (responseCode > 399) { 
71          System.err.println("Page not found: " + responseCode);
72          return false;
73        }
74        System.err.println("AuthorWebSite.isStillLive response code:" + responseCode);
75      } catch (IOException e) {
76        System.err.println("Domain not found: " + getUrl());
77        return false;
78      }
79      
80      return true;
81    }
82  
83    public String adminHandle(Melati melati, MarkupLanguage markupLanguage)
84        throws Exception {
85      return null;
86    }
87  
88    public BibliomaniaDatabase getBibliomaniaDatabase () {
89      return (BibliomaniaDatabase)getDatabase();
90    }
91    public String adminSpecialFacilities(Melati melati,
92        MarkupLanguage markupLanguage) throws Exception {
93      return getBibliomaniaDatabase().getWMTemplet("AuthorWebSite-specials");  }
94  
95  }
96