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  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  public class AuthorWebSite  extends AuthorWebSiteBase implements AdminSpecialised {
40  
41   
42  
43  
44  
45  
46  
47  
48  
49  
50  
51    public AuthorWebSite() { }
52  
53    
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