2014-08-08 16:49:02 +02:00
|
|
|
package com.commafeed;
|
|
|
|
|
|
|
|
|
|
import io.dropwizard.Configuration;
|
|
|
|
|
import io.dropwizard.db.DataSourceFactory;
|
|
|
|
|
|
|
|
|
|
import java.util.Date;
|
2014-08-16 17:27:27 +02:00
|
|
|
import java.util.ResourceBundle;
|
2014-08-08 16:49:02 +02:00
|
|
|
|
|
|
|
|
import javax.validation.Valid;
|
2014-08-16 12:40:39 +02:00
|
|
|
import javax.validation.constraints.Min;
|
2014-08-08 16:49:02 +02:00
|
|
|
import javax.validation.constraints.NotNull;
|
|
|
|
|
|
|
|
|
|
import lombok.Getter;
|
|
|
|
|
|
2014-10-28 16:36:09 +01:00
|
|
|
import org.apache.commons.lang3.time.DateUtils;
|
2014-08-16 12:40:39 +02:00
|
|
|
import org.hibernate.validator.constraints.NotBlank;
|
2014-08-08 16:49:02 +02:00
|
|
|
|
2014-09-22 09:51:55 +02:00
|
|
|
import com.commafeed.backend.cache.RedisPoolFactory;
|
2014-10-22 10:35:50 +02:00
|
|
|
import com.commafeed.frontend.session.SessionManagerFactory;
|
2014-08-08 16:49:02 +02:00
|
|
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
|
|
|
|
|
|
|
|
@Getter
|
|
|
|
|
public class CommaFeedConfiguration extends Configuration {
|
|
|
|
|
|
2014-08-09 13:26:03 +02:00
|
|
|
public static enum CacheType {
|
|
|
|
|
NOOP, REDIS
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-16 17:27:27 +02:00
|
|
|
private ResourceBundle bundle;
|
|
|
|
|
|
|
|
|
|
public CommaFeedConfiguration() {
|
|
|
|
|
bundle = ResourceBundle.getBundle("application");
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-08 16:49:02 +02:00
|
|
|
@Valid
|
|
|
|
|
@NotNull
|
|
|
|
|
@JsonProperty("database")
|
2014-11-21 16:50:20 +01:00
|
|
|
private DataSourceFactory dataSourceFactory = new DataSourceFactory();
|
2014-09-22 09:51:55 +02:00
|
|
|
|
|
|
|
|
@Valid
|
|
|
|
|
@NotNull
|
|
|
|
|
@JsonProperty("redis")
|
|
|
|
|
private RedisPoolFactory redisPoolFactory = new RedisPoolFactory();
|
|
|
|
|
|
2014-08-18 13:09:54 +02:00
|
|
|
@Valid
|
|
|
|
|
@NotNull
|
|
|
|
|
@JsonProperty("session")
|
|
|
|
|
private SessionManagerFactory sessionManagerFactory = new SessionManagerFactory();
|
2014-08-08 16:49:02 +02:00
|
|
|
|
|
|
|
|
@Valid
|
|
|
|
|
@NotNull
|
|
|
|
|
@JsonProperty("app")
|
|
|
|
|
private ApplicationSettings applicationSettings;
|
|
|
|
|
|
2014-08-16 17:27:27 +02:00
|
|
|
public String getVersion() {
|
|
|
|
|
return bundle.getString("version");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getGitCommit() {
|
|
|
|
|
return bundle.getString("git.commit");
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-08 16:49:02 +02:00
|
|
|
@Getter
|
|
|
|
|
public static class ApplicationSettings {
|
2014-08-16 12:40:39 +02:00
|
|
|
@NotNull
|
|
|
|
|
@NotBlank
|
2014-08-08 16:49:02 +02:00
|
|
|
private String publicUrl;
|
|
|
|
|
|
2014-08-16 12:40:39 +02:00
|
|
|
@NotNull
|
2014-08-08 16:49:02 +02:00
|
|
|
private boolean allowRegistrations;
|
|
|
|
|
|
2014-11-23 13:27:34 +01:00
|
|
|
private boolean createDemoAccount;
|
|
|
|
|
|
2014-08-08 16:49:02 +02:00
|
|
|
private String googleAnalyticsTrackingCode;
|
|
|
|
|
|
2014-08-16 12:40:39 +02:00
|
|
|
@NotNull
|
|
|
|
|
@Min(1)
|
2014-08-08 16:49:02 +02:00
|
|
|
private int backgroundThreads;
|
|
|
|
|
|
2014-08-16 12:40:39 +02:00
|
|
|
@NotNull
|
|
|
|
|
@Min(1)
|
2014-08-08 16:49:02 +02:00
|
|
|
private int databaseUpdateThreads;
|
|
|
|
|
|
|
|
|
|
private String smtpHost;
|
|
|
|
|
|
|
|
|
|
private int smtpPort;
|
|
|
|
|
|
|
|
|
|
private boolean smtpTls;
|
|
|
|
|
|
|
|
|
|
private String smtpUserName;
|
|
|
|
|
|
|
|
|
|
private String smtpPassword;
|
|
|
|
|
|
2014-11-07 09:38:55 +01:00
|
|
|
private String smtpFromAddress;
|
|
|
|
|
|
2014-08-16 12:40:39 +02:00
|
|
|
@NotNull
|
2014-08-08 16:49:02 +02:00
|
|
|
private boolean heavyLoad;
|
|
|
|
|
|
2014-08-16 12:40:39 +02:00
|
|
|
@NotNull
|
2014-08-08 16:49:02 +02:00
|
|
|
private boolean pubsubhubbub;
|
|
|
|
|
|
2014-08-16 12:40:39 +02:00
|
|
|
@NotNull
|
2014-08-08 16:49:02 +02:00
|
|
|
private boolean imageProxyEnabled;
|
|
|
|
|
|
2014-08-16 12:40:39 +02:00
|
|
|
@NotNull
|
|
|
|
|
@Min(0)
|
2014-08-08 16:49:02 +02:00
|
|
|
private int queryTimeout;
|
|
|
|
|
|
2014-08-16 12:40:39 +02:00
|
|
|
@NotNull
|
|
|
|
|
@Min(0)
|
2014-08-08 16:49:02 +02:00
|
|
|
private int keepStatusDays;
|
|
|
|
|
|
2014-08-16 12:40:39 +02:00
|
|
|
@NotNull
|
|
|
|
|
@Min(0)
|
2014-08-08 16:49:02 +02:00
|
|
|
private int refreshIntervalMinutes;
|
|
|
|
|
|
2014-08-16 12:40:39 +02:00
|
|
|
@NotNull
|
2014-08-09 13:26:03 +02:00
|
|
|
private CacheType cache;
|
|
|
|
|
|
2014-08-16 12:40:39 +02:00
|
|
|
@NotNull
|
2014-08-08 16:49:02 +02:00
|
|
|
private String announcement;
|
|
|
|
|
|
|
|
|
|
public Date getUnreadThreshold() {
|
|
|
|
|
int keepStatusDays = getKeepStatusDays();
|
|
|
|
|
return keepStatusDays > 0 ? DateUtils.addDays(new Date(), -1 * keepStatusDays) : null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|