Files
Athou_commafeed/src/main/java/com/commafeed/CommaFeedConfiguration.java

123 lines
2.2 KiB
Java
Raw Normal View History

package com.commafeed;
import io.dropwizard.Configuration;
import io.dropwizard.db.DataSourceFactory;
import java.util.Date;
import javax.validation.Valid;
2014-08-16 12:40:39 +02:00
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import lombok.Getter;
import org.apache.commons.lang.time.DateUtils;
2014-08-16 12:40:39 +02:00
import org.hibernate.validator.constraints.NotBlank;
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
}
@Valid
@NotNull
@JsonProperty("database")
private DataSourceFactory database = new DataSourceFactory();
@Valid
@NotNull
@JsonProperty("app")
private ApplicationSettings applicationSettings;
@Getter
public static class ApplicationSettings {
@JsonProperty
2014-08-16 12:40:39 +02:00
@NotNull
@NotBlank
private String contextPath;
@JsonProperty
2014-08-16 12:40:39 +02:00
@NotNull
@NotBlank
private String publicUrl;
@JsonProperty
2014-08-16 12:40:39 +02:00
@NotNull
private boolean allowRegistrations;
@JsonProperty
private String googleAnalyticsTrackingCode;
@JsonProperty
2014-08-16 12:40:39 +02:00
@NotNull
@Min(1)
private int backgroundThreads;
@JsonProperty
2014-08-16 12:40:39 +02:00
@NotNull
@Min(1)
private int databaseUpdateThreads;
@JsonProperty
private String smtpHost;
@JsonProperty
private int smtpPort;
@JsonProperty
private boolean smtpTls;
@JsonProperty
private String smtpUserName;
@JsonProperty
private String smtpPassword;
@JsonProperty
2014-08-16 12:40:39 +02:00
@NotNull
private boolean heavyLoad;
@JsonProperty
2014-08-16 12:40:39 +02:00
@NotNull
private boolean pubsubhubbub;
@JsonProperty
2014-08-16 12:40:39 +02:00
@NotNull
private boolean imageProxyEnabled;
@JsonProperty
2014-08-16 12:40:39 +02:00
@NotNull
@Min(0)
private int queryTimeout;
@JsonProperty
2014-08-16 12:40:39 +02:00
@NotNull
@Min(0)
private int keepStatusDays;
@JsonProperty
2014-08-16 12:40:39 +02:00
@NotNull
@Min(0)
private int refreshIntervalMinutes;
2014-08-09 13:26:03 +02:00
@JsonProperty
2014-08-16 12:40:39 +02:00
@NotNull
2014-08-09 13:26:03 +02:00
private CacheType cache;
@JsonProperty
2014-08-16 12:40:39 +02:00
@NotNull
private String announcement;
public Date getUnreadThreshold() {
int keepStatusDays = getKeepStatusDays();
return keepStatusDays > 0 ? DateUtils.addDays(new Date(), -1 * keepStatusDays) : null;
}
}
}