calLongTime.set(Calendar.YEAR, 1900);
//prepare link
link = TextTools.purgeLink(link);
DataManager dm = DataManagerFactory.getInstance();
PersistenceManager pm = dm.newPersistenceManager();
//find if blog already exists in database
Blog blog = dm.getBlogFromLink(pm , link);
if (blog == null) {
//blog does not exist : load content to parse it
String content = DocumentLoader.loadPage(link);
String rss = null;
//test if given link is already RSS or Atom FEED
if (FeedManager.isFeed(content)){
rss = link;
}else {
//extract RSS link from page content
rss = TextTools.extractRssFromPage(content);
}
//test if rss information hase been found
if (rss != null){
//check again if blog exists with given link
blog = dm.getBlogFromLink(pm , rss);
//actually create new blog in database
if (blog == null){
blog = new Blog();
blog.setLatestEntry(calLongTime.getTime());
blog.setNextUpdate(now);