forked from Archives/Athou_commafeed
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.services.ApplicationSettingsService;
|
||||
|
||||
/**
|
||||
* Contains utility methods for cleaning the database
|
||||
*
|
||||
*/
|
||||
public class DatabaseCleaner {
|
||||
|
||||
private static Logger log = LoggerFactory.getLogger(DatabaseCleaner.class);
|
||||
|
||||
@@ -20,6 +20,10 @@ import liquibase.structure.DatabaseObject;
|
||||
|
||||
import com.commafeed.backend.services.ApplicationPropertiesService;
|
||||
|
||||
/**
|
||||
* Executes needed liquibase database schema upgrades
|
||||
*
|
||||
*/
|
||||
@Stateless
|
||||
@TransactionManagement(TransactionManagementType.BEAN)
|
||||
public class DatabaseUpdater {
|
||||
|
||||
@@ -5,6 +5,11 @@ import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
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> {
|
||||
|
||||
private List<E> inner;
|
||||
|
||||
@@ -41,6 +41,10 @@ import org.apache.http.util.EntityUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Smart HTTP getter
|
||||
*
|
||||
*/
|
||||
public class HttpGetter {
|
||||
|
||||
private static Logger log = LoggerFactory.getLogger(HttpGetter.class);
|
||||
|
||||
@@ -13,6 +13,10 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.commafeed.backend.services.ApplicationSettingsService;
|
||||
|
||||
/**
|
||||
* Contains all scheduled tasks
|
||||
*
|
||||
*/
|
||||
@Stateless
|
||||
public class ScheduledTasks {
|
||||
protected final static Logger log = LoggerFactory.getLogger(ScheduledTasks.class);
|
||||
@@ -26,7 +30,9 @@ public class ScheduledTasks {
|
||||
@PersistenceContext
|
||||
EntityManager em;
|
||||
|
||||
// every day at midnight
|
||||
/**
|
||||
* clean old read statuses, runs every day at midnight
|
||||
*/
|
||||
@Schedule(hour = "0", persistent = false)
|
||||
private void cleanupOldStatuses() {
|
||||
Date threshold = applicationSettingsService.get().getUnreadThreshold();
|
||||
|
||||
@@ -25,6 +25,10 @@ import com.commafeed.backend.services.ApplicationSettingsService;
|
||||
import com.commafeed.backend.services.UserService;
|
||||
import com.google.api.client.util.Maps;
|
||||
|
||||
/**
|
||||
* Starting point of the application
|
||||
*
|
||||
*/
|
||||
@Startup
|
||||
@Singleton
|
||||
@ConcurrencyManagement(ConcurrencyManagementType.BEAN)
|
||||
@@ -56,14 +60,19 @@ public class StartupBean {
|
||||
private void init() {
|
||||
|
||||
startupTime = System.currentTimeMillis();
|
||||
|
||||
// update database schema
|
||||
databaseUpdater.update();
|
||||
|
||||
if (applicationSettingsDAO.getCount() == 0) {
|
||||
// import initial data
|
||||
initialData();
|
||||
}
|
||||
applicationSettingsService.applyLogLevel();
|
||||
|
||||
initSupportedLanguages();
|
||||
|
||||
// start fetching feeds
|
||||
taskGiver.start();
|
||||
}
|
||||
|
||||
@@ -83,6 +92,9 @@ public class StartupBean {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* create default users
|
||||
*/
|
||||
private void initialData() {
|
||||
log.info("Populating database with default values");
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ public class FaviconFetcher {
|
||||
return bytes;
|
||||
}
|
||||
|
||||
boolean isValidIconResponse(byte[] content, String contentType) {
|
||||
private boolean isValidIconResponse(byte[] content, String contentType) {
|
||||
if (content == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,11 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
import org.slf4j.Logger;
|
||||
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 {
|
||||
|
||||
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.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
|
||||
public class FeedRefreshTaskGiver {
|
||||
|
||||
|
||||
@@ -22,6 +22,10 @@ import com.commafeed.backend.model.FeedEntry;
|
||||
import com.commafeed.backend.services.ApplicationSettingsService;
|
||||
import com.sun.syndication.io.FeedException;
|
||||
|
||||
/**
|
||||
* Calls {@link FeedFetcher} and handles its outcome
|
||||
*
|
||||
*/
|
||||
@ApplicationScoped
|
||||
public class FeedRefreshWorker {
|
||||
|
||||
|
||||
@@ -36,6 +36,10 @@ import com.steadystate.css.parser.CSSOMParser;
|
||||
|
||||
import edu.uci.ics.crawler4j.url.URLCanonicalizer;
|
||||
|
||||
/**
|
||||
* Utility methods related to feed handling
|
||||
*
|
||||
*/
|
||||
public class FeedUtils {
|
||||
|
||||
protected static Logger log = LoggerFactory.getLogger(FeedUtils.class);
|
||||
|
||||
@@ -8,6 +8,10 @@ import javax.persistence.Id;
|
||||
import javax.persistence.MappedSuperclass;
|
||||
import javax.persistence.TableGenerator;
|
||||
|
||||
/**
|
||||
* Abstract model for all entities, defining id and table generator
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
@MappedSuperclass
|
||||
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.model.Feed;
|
||||
import com.commafeed.backend.services.ApplicationSettingsService;
|
||||
import com.commafeed.frontend.rest.resources.PubSubHubbubCallbackREST;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
/**
|
||||
* Sends push subscription requests. Callback is handled by {@link PubSubHubbubCallbackREST}
|
||||
*
|
||||
*/
|
||||
public class SubscriptionHandler {
|
||||
|
||||
private static Logger log = LoggerFactory.getLogger(SubscriptionHandler.class);
|
||||
|
||||
@@ -4,6 +4,10 @@ import org.jdom.Element;
|
||||
|
||||
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 OPML11Generator() {
|
||||
|
||||
@@ -5,6 +5,10 @@ import org.jdom.Element;
|
||||
|
||||
import com.sun.syndication.io.impl.OPML10Parser;
|
||||
|
||||
/**
|
||||
* Support for OPML 1.1 parsing
|
||||
*
|
||||
*/
|
||||
public class OPML11Parser extends OPML10Parser {
|
||||
|
||||
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.impl.ConverterForRSS090;
|
||||
|
||||
/**
|
||||
* Support description tag for RSS09
|
||||
*
|
||||
*/
|
||||
public class RSS090DescriptionConverter extends ConverterForRSS090 {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -6,6 +6,10 @@ import com.sun.syndication.feed.rss.Description;
|
||||
import com.sun.syndication.feed.rss.Item;
|
||||
import com.sun.syndication.io.impl.RSS090Parser;
|
||||
|
||||
/**
|
||||
* Support description tag for RSS09
|
||||
*
|
||||
*/
|
||||
public class RSS090DescriptionParser extends RSS090Parser {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,6 +18,10 @@ import org.slf4j.LoggerFactory;
|
||||
import com.commafeed.backend.model.ApplicationSettings;
|
||||
import com.commafeed.backend.model.User;
|
||||
|
||||
/**
|
||||
* Mailing service
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class MailService implements Serializable {
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
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")
|
||||
public class PasswordEncryptionService implements Serializable {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user