import from google reader

This commit is contained in:
Athou
2013-04-05 16:31:42 +02:00
parent ad1e64b101
commit a1ab76d176
16 changed files with 388 additions and 1 deletions

View File

@@ -11,10 +11,12 @@ import javax.inject.Inject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.commafeed.backend.dao.ApplicationSettingsService;
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.model.ApplicationSettings;
import com.commafeed.backend.model.Feed;
import com.commafeed.backend.model.FeedCategory;
import com.commafeed.backend.model.FeedSubscription;
@@ -44,6 +46,9 @@ public class StartupBean {
@Inject
PasswordEncryptionService encryptionService;
@Inject
ApplicationSettingsService applicationSettingsService;
private long startupTime;
@PostConstruct
@@ -52,6 +57,8 @@ public class StartupBean {
if (userService.getCount() == 0) {
log.info("Populating database with default values");
applicationSettingsService.save(new ApplicationSettings());
User user = userService.register(ADMIN_NAME, "admin",
Arrays.asList(Role.ADMIN, Role.USER));
userService.register("test", "test", Arrays.asList(Role.USER));

View File

@@ -0,0 +1,34 @@
package com.commafeed.backend.dao;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import com.commafeed.backend.model.ApplicationSettings;
import com.google.common.collect.Iterables;
import com.uaihebert.factory.EasyCriteriaFactory;
import com.uaihebert.model.EasyCriteria;
@Stateless
public class ApplicationSettingsService {
@PersistenceContext
protected EntityManager em;
public void save(ApplicationSettings settings) {
if (settings.getId() == null) {
em.persist(settings);
} else {
em.merge(settings);
}
}
public ApplicationSettings get() {
EasyCriteria<ApplicationSettings> criteria = EasyCriteriaFactory
.createQueryCriteria(em, ApplicationSettings.class);
List<ApplicationSettings> list = criteria.getResultList();
return Iterables.getFirst(list, null);
}
}

View File

@@ -0,0 +1,48 @@
package com.commafeed.backend.model;
import javax.persistence.Entity;
import javax.persistence.Table;
@Entity
@Table(name = "APPLICATIONSETTINGS")
@SuppressWarnings("serial")
public class ApplicationSettings extends AbstractModel {
private String publicUrl;
private boolean allowRegistrations = false;
private String googleClientId;
private String googleClientSecret;
public String getPublicUrl() {
return publicUrl;
}
public void setPublicUrl(String publicUrl) {
this.publicUrl = publicUrl;
}
public boolean isAllowRegistrations() {
return allowRegistrations;
}
public void setAllowRegistrations(boolean allowRegistrations) {
this.allowRegistrations = allowRegistrations;
}
public String getGoogleClientId() {
return googleClientId;
}
public void setGoogleClientId(String googleClientId) {
this.googleClientId = googleClientId;
}
public String getGoogleClientSecret() {
return googleClientSecret;
}
public void setGoogleClientSecret(String googleClientSecret) {
this.googleClientSecret = googleClientSecret;
}
}

View File

@@ -21,6 +21,10 @@ public class User extends AbstractModel {
@Index(name = "username_index")
private String name;
@Column(length = 256, unique = true)
@Index(name = "useremail_index")
private String email;
@Column(length = 256, nullable = false)
private byte[] password;