initial commit

This commit is contained in:
Athou
2013-03-20 20:33:42 +01:00
commit 7b3c53fcb9
82 changed files with 3346 additions and 0 deletions

View File

@@ -0,0 +1,74 @@
package com.commafeed.backend;
import javax.annotation.PostConstruct;
import javax.ejb.Singleton;
import javax.ejb.Startup;
import javax.inject.Inject;
import com.commafeed.backend.dao.FeedCategoryService;
import com.commafeed.backend.dao.FeedService;
import com.commafeed.backend.dao.FeedSubscriptionService;
import com.commafeed.backend.dao.UserService;
import com.commafeed.backend.security.PasswordEncryptionService;
import com.commafeed.model.Feed;
import com.commafeed.model.FeedCategory;
import com.commafeed.model.FeedSubscription;
import com.commafeed.model.User;
@Startup
@Singleton
public class StartupBean {
@Inject
FeedService feedService;
@Inject
FeedCategoryService feedCategoryService;
@Inject
FeedSubscriptionService feedSubscriptionService;
@Inject
UserService userService;
@Inject
PasswordEncryptionService encryptionService;
@PostConstruct
private void init() {
if (userService.getCount() == 0) {
User user = new User();
byte[] salt = encryptionService.generateSalt();
user.setName("admin");
user.setSalt(salt);
user.setPassword(encryptionService.getEncryptedPassword("admin",
salt));
userService.save(user);
Feed feed = new Feed("http://feed.dilbert.com/dilbert/daily_strip");
feedService.save(feed);
FeedCategory newsCategory = new FeedCategory();
newsCategory.setName("News");
newsCategory.setUser(user);
feedCategoryService.save(newsCategory);
FeedCategory comicsCategory = new FeedCategory();
comicsCategory.setName("Comics");
comicsCategory.setUser(user);
comicsCategory.setParent(newsCategory);
feedCategoryService.save(comicsCategory);
FeedSubscription sub = new FeedSubscription();
sub.setCategory(comicsCategory);
sub.setFeed(feed);
sub.setTitle("Dilbert - Strips");
sub.setUser(user);
feedSubscriptionService.save(sub);
}
}
}