mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
added a little doc
This commit is contained in:
@@ -19,6 +19,10 @@ import com.commafeed.backend.model.Feed;
|
|||||||
import com.commafeed.backend.model.FeedSubscription;
|
import com.commafeed.backend.model.FeedSubscription;
|
||||||
import com.commafeed.backend.services.ApplicationSettingsService;
|
import com.commafeed.backend.services.ApplicationSettingsService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains utility methods for cleaning the database
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class DatabaseCleaner {
|
public class DatabaseCleaner {
|
||||||
|
|
||||||
private static Logger log = LoggerFactory.getLogger(DatabaseCleaner.class);
|
private static Logger log = LoggerFactory.getLogger(DatabaseCleaner.class);
|
||||||
|
|||||||
@@ -20,6 +20,10 @@ import liquibase.structure.DatabaseObject;
|
|||||||
|
|
||||||
import com.commafeed.backend.services.ApplicationPropertiesService;
|
import com.commafeed.backend.services.ApplicationPropertiesService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Executes needed liquibase database schema upgrades
|
||||||
|
*
|
||||||
|
*/
|
||||||
@Stateless
|
@Stateless
|
||||||
@TransactionManagement(TransactionManagementType.BEAN)
|
@TransactionManagement(TransactionManagementType.BEAN)
|
||||||
public class DatabaseUpdater {
|
public class DatabaseUpdater {
|
||||||
|
|||||||
@@ -5,6 +5,11 @@ import java.util.Collections;
|
|||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List wrapper that sorts its elements in the order provided by given comparator and ensure a maximum capacity.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class FixedSizeSortedSet<E> {
|
public class FixedSizeSortedSet<E> {
|
||||||
|
|
||||||
private List<E> inner;
|
private List<E> inner;
|
||||||
|
|||||||
@@ -41,6 +41,10 @@ import org.apache.http.util.EntityUtils;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smart HTTP getter
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class HttpGetter {
|
public class HttpGetter {
|
||||||
|
|
||||||
private static Logger log = LoggerFactory.getLogger(HttpGetter.class);
|
private static Logger log = LoggerFactory.getLogger(HttpGetter.class);
|
||||||
|
|||||||
@@ -13,6 +13,10 @@ import org.slf4j.LoggerFactory;
|
|||||||
|
|
||||||
import com.commafeed.backend.services.ApplicationSettingsService;
|
import com.commafeed.backend.services.ApplicationSettingsService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains all scheduled tasks
|
||||||
|
*
|
||||||
|
*/
|
||||||
@Stateless
|
@Stateless
|
||||||
public class ScheduledTasks {
|
public class ScheduledTasks {
|
||||||
protected final static Logger log = LoggerFactory.getLogger(ScheduledTasks.class);
|
protected final static Logger log = LoggerFactory.getLogger(ScheduledTasks.class);
|
||||||
@@ -26,7 +30,9 @@ public class ScheduledTasks {
|
|||||||
@PersistenceContext
|
@PersistenceContext
|
||||||
EntityManager em;
|
EntityManager em;
|
||||||
|
|
||||||
// every day at midnight
|
/**
|
||||||
|
* clean old read statuses, runs every day at midnight
|
||||||
|
*/
|
||||||
@Schedule(hour = "0", persistent = false)
|
@Schedule(hour = "0", persistent = false)
|
||||||
private void cleanupOldStatuses() {
|
private void cleanupOldStatuses() {
|
||||||
Date threshold = applicationSettingsService.get().getUnreadThreshold();
|
Date threshold = applicationSettingsService.get().getUnreadThreshold();
|
||||||
|
|||||||
@@ -25,6 +25,10 @@ import com.commafeed.backend.services.ApplicationSettingsService;
|
|||||||
import com.commafeed.backend.services.UserService;
|
import com.commafeed.backend.services.UserService;
|
||||||
import com.google.api.client.util.Maps;
|
import com.google.api.client.util.Maps;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starting point of the application
|
||||||
|
*
|
||||||
|
*/
|
||||||
@Startup
|
@Startup
|
||||||
@Singleton
|
@Singleton
|
||||||
@ConcurrencyManagement(ConcurrencyManagementType.BEAN)
|
@ConcurrencyManagement(ConcurrencyManagementType.BEAN)
|
||||||
@@ -56,14 +60,19 @@ public class StartupBean {
|
|||||||
private void init() {
|
private void init() {
|
||||||
|
|
||||||
startupTime = System.currentTimeMillis();
|
startupTime = System.currentTimeMillis();
|
||||||
|
|
||||||
|
// update database schema
|
||||||
databaseUpdater.update();
|
databaseUpdater.update();
|
||||||
|
|
||||||
if (applicationSettingsDAO.getCount() == 0) {
|
if (applicationSettingsDAO.getCount() == 0) {
|
||||||
|
// import initial data
|
||||||
initialData();
|
initialData();
|
||||||
}
|
}
|
||||||
applicationSettingsService.applyLogLevel();
|
applicationSettingsService.applyLogLevel();
|
||||||
|
|
||||||
initSupportedLanguages();
|
initSupportedLanguages();
|
||||||
|
|
||||||
|
// start fetching feeds
|
||||||
taskGiver.start();
|
taskGiver.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,6 +92,9 @@ public class StartupBean {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* create default users
|
||||||
|
*/
|
||||||
private void initialData() {
|
private void initialData() {
|
||||||
log.info("Populating database with default values");
|
log.info("Populating database with default values");
|
||||||
|
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ public class FaviconFetcher {
|
|||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isValidIconResponse(byte[] content, String contentType) {
|
private boolean isValidIconResponse(byte[] content, String contentType) {
|
||||||
if (content == null) {
|
if (content == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,11 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wraps a {@link ThreadPoolExecutor} instance. Blocks when queue is full instead of rejecting the task. Allow priority queueing by using
|
||||||
|
* {@link Task} instead of {@link Runnable}
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class FeedRefreshExecutor {
|
public class FeedRefreshExecutor {
|
||||||
|
|
||||||
private static Logger log = LoggerFactory.getLogger(FeedRefreshExecutor.class);
|
private static Logger log = LoggerFactory.getLogger(FeedRefreshExecutor.class);
|
||||||
|
|||||||
@@ -25,6 +25,11 @@ import com.google.api.client.util.Maps;
|
|||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Queues;
|
import com.google.common.collect.Queues;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Infinite loop fetching feeds from the database and queuing them to the {@link FeedRefreshWorker} pool. Also handles feed database updates
|
||||||
|
* at the end of the cycle through {@link #giveBack(Feed)}.
|
||||||
|
*
|
||||||
|
*/
|
||||||
@ApplicationScoped
|
@ApplicationScoped
|
||||||
public class FeedRefreshTaskGiver {
|
public class FeedRefreshTaskGiver {
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,10 @@ import com.commafeed.backend.model.FeedEntry;
|
|||||||
import com.commafeed.backend.services.ApplicationSettingsService;
|
import com.commafeed.backend.services.ApplicationSettingsService;
|
||||||
import com.sun.syndication.io.FeedException;
|
import com.sun.syndication.io.FeedException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calls {@link FeedFetcher} and handles its outcome
|
||||||
|
*
|
||||||
|
*/
|
||||||
@ApplicationScoped
|
@ApplicationScoped
|
||||||
public class FeedRefreshWorker {
|
public class FeedRefreshWorker {
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,10 @@ import com.steadystate.css.parser.CSSOMParser;
|
|||||||
|
|
||||||
import edu.uci.ics.crawler4j.url.URLCanonicalizer;
|
import edu.uci.ics.crawler4j.url.URLCanonicalizer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility methods related to feed handling
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class FeedUtils {
|
public class FeedUtils {
|
||||||
|
|
||||||
protected static Logger log = LoggerFactory.getLogger(FeedUtils.class);
|
protected static Logger log = LoggerFactory.getLogger(FeedUtils.class);
|
||||||
|
|||||||
@@ -8,6 +8,10 @@ import javax.persistence.Id;
|
|||||||
import javax.persistence.MappedSuperclass;
|
import javax.persistence.MappedSuperclass;
|
||||||
import javax.persistence.TableGenerator;
|
import javax.persistence.TableGenerator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Abstract model for all entities, defining id and table generator
|
||||||
|
*
|
||||||
|
*/
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
@MappedSuperclass
|
@MappedSuperclass
|
||||||
public abstract class AbstractModel implements Serializable {
|
public abstract class AbstractModel implements Serializable {
|
||||||
|
|||||||
@@ -22,8 +22,13 @@ import com.commafeed.backend.feeds.FeedRefreshTaskGiver;
|
|||||||
import com.commafeed.backend.feeds.FeedUtils;
|
import com.commafeed.backend.feeds.FeedUtils;
|
||||||
import com.commafeed.backend.model.Feed;
|
import com.commafeed.backend.model.Feed;
|
||||||
import com.commafeed.backend.services.ApplicationSettingsService;
|
import com.commafeed.backend.services.ApplicationSettingsService;
|
||||||
|
import com.commafeed.frontend.rest.resources.PubSubHubbubCallbackREST;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends push subscription requests. Callback is handled by {@link PubSubHubbubCallbackREST}
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class SubscriptionHandler {
|
public class SubscriptionHandler {
|
||||||
|
|
||||||
private static Logger log = LoggerFactory.getLogger(SubscriptionHandler.class);
|
private static Logger log = LoggerFactory.getLogger(SubscriptionHandler.class);
|
||||||
|
|||||||
@@ -4,6 +4,10 @@ import org.jdom.Element;
|
|||||||
|
|
||||||
import com.sun.syndication.feed.opml.Opml;
|
import com.sun.syndication.feed.opml.Opml;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add missing title to the generated OPML
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class OPML11Generator extends com.sun.syndication.io.impl.OPML10Generator {
|
public class OPML11Generator extends com.sun.syndication.io.impl.OPML10Generator {
|
||||||
|
|
||||||
public OPML11Generator() {
|
public OPML11Generator() {
|
||||||
|
|||||||
@@ -5,6 +5,10 @@ import org.jdom.Element;
|
|||||||
|
|
||||||
import com.sun.syndication.io.impl.OPML10Parser;
|
import com.sun.syndication.io.impl.OPML10Parser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Support for OPML 1.1 parsing
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class OPML11Parser extends OPML10Parser {
|
public class OPML11Parser extends OPML10Parser {
|
||||||
|
|
||||||
public OPML11Parser() {
|
public OPML11Parser() {
|
||||||
|
|||||||
@@ -6,6 +6,10 @@ import com.sun.syndication.feed.synd.SyndContentImpl;
|
|||||||
import com.sun.syndication.feed.synd.SyndEntry;
|
import com.sun.syndication.feed.synd.SyndEntry;
|
||||||
import com.sun.syndication.feed.synd.impl.ConverterForRSS090;
|
import com.sun.syndication.feed.synd.impl.ConverterForRSS090;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Support description tag for RSS09
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class RSS090DescriptionConverter extends ConverterForRSS090 {
|
public class RSS090DescriptionConverter extends ConverterForRSS090 {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -6,6 +6,10 @@ import com.sun.syndication.feed.rss.Description;
|
|||||||
import com.sun.syndication.feed.rss.Item;
|
import com.sun.syndication.feed.rss.Item;
|
||||||
import com.sun.syndication.io.impl.RSS090Parser;
|
import com.sun.syndication.io.impl.RSS090Parser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Support description tag for RSS09
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class RSS090DescriptionParser extends RSS090Parser {
|
public class RSS090DescriptionParser extends RSS090Parser {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -18,6 +18,10 @@ import org.slf4j.LoggerFactory;
|
|||||||
import com.commafeed.backend.model.ApplicationSettings;
|
import com.commafeed.backend.model.ApplicationSettings;
|
||||||
import com.commafeed.backend.model.User;
|
import com.commafeed.backend.model.User;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mailing service
|
||||||
|
*
|
||||||
|
*/
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class MailService implements Serializable {
|
public class MailService implements Serializable {
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
|
|
||||||
import com.commafeed.backend.dao.UserDAO;
|
import com.commafeed.backend.dao.UserDAO;
|
||||||
|
|
||||||
// http://www.javacodegeeks.com/2012/05/secure-password-storage-donts-dos-and.html
|
// taken from http://www.javacodegeeks.com/2012/05/secure-password-storage-donts-dos-and.html
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class PasswordEncryptionService implements Serializable {
|
public class PasswordEncryptionService implements Serializable {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user