mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
* initial java9+ support * restore session management, updated for jetty 9.4 * Session actually implements EntityManager * reusable method for setting the timeout
153 lines
3.0 KiB
Java
153 lines
3.0 KiB
Java
package com.commafeed;
|
|
|
|
import java.util.Date;
|
|
import java.util.ResourceBundle;
|
|
|
|
import javax.validation.Valid;
|
|
import javax.validation.constraints.Min;
|
|
import javax.validation.constraints.NotNull;
|
|
|
|
import org.apache.commons.lang3.time.DateUtils;
|
|
import org.hibernate.validator.constraints.NotBlank;
|
|
|
|
import com.commafeed.backend.cache.RedisPoolFactory;
|
|
import com.commafeed.frontend.session.SessionHandlerFactory;
|
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
|
|
import io.dropwizard.Configuration;
|
|
import io.dropwizard.db.DataSourceFactory;
|
|
import lombok.Getter;
|
|
|
|
@Getter
|
|
public class CommaFeedConfiguration extends Configuration {
|
|
|
|
public static enum CacheType {
|
|
NOOP, REDIS
|
|
}
|
|
|
|
private ResourceBundle bundle;
|
|
|
|
public CommaFeedConfiguration() {
|
|
bundle = ResourceBundle.getBundle("application");
|
|
}
|
|
|
|
@Valid
|
|
@NotNull
|
|
@JsonProperty("database")
|
|
private DataSourceFactory dataSourceFactory = new DataSourceFactory();
|
|
|
|
@Valid
|
|
@NotNull
|
|
@JsonProperty("redis")
|
|
private RedisPoolFactory redisPoolFactory = new RedisPoolFactory();
|
|
|
|
@Valid
|
|
@NotNull
|
|
@JsonProperty("session")
|
|
private SessionHandlerFactory SessionHandlerFactory = new SessionHandlerFactory();
|
|
|
|
@Valid
|
|
@NotNull
|
|
@JsonProperty("app")
|
|
private ApplicationSettings applicationSettings;
|
|
|
|
public String getVersion() {
|
|
return bundle.getString("version");
|
|
}
|
|
|
|
public String getGitCommit() {
|
|
return bundle.getString("git.commit");
|
|
}
|
|
|
|
@Getter
|
|
public static class ApplicationSettings {
|
|
@NotNull
|
|
@NotBlank
|
|
@Valid
|
|
private String publicUrl;
|
|
|
|
@NotNull
|
|
@Valid
|
|
private Boolean allowRegistrations;
|
|
|
|
@NotNull
|
|
@Valid
|
|
private Boolean createDemoAccount;
|
|
|
|
private String googleAnalyticsTrackingCode;
|
|
|
|
private String googleAuthKey;
|
|
|
|
@NotNull
|
|
@Min(1)
|
|
@Valid
|
|
private Integer backgroundThreads;
|
|
|
|
@NotNull
|
|
@Min(1)
|
|
@Valid
|
|
private Integer databaseUpdateThreads;
|
|
|
|
private String smtpHost;
|
|
private int smtpPort;
|
|
private boolean smtpTls;
|
|
private String smtpUserName;
|
|
private String smtpPassword;
|
|
private String smtpFromAddress;
|
|
|
|
private boolean graphiteEnabled;
|
|
private String graphitePrefix;
|
|
private String graphiteHost;
|
|
private int graphitePort;
|
|
private int graphiteInterval;
|
|
|
|
@NotNull
|
|
@Valid
|
|
private Boolean heavyLoad;
|
|
|
|
@NotNull
|
|
@Valid
|
|
private Boolean pubsubhubbub;
|
|
|
|
@NotNull
|
|
@Valid
|
|
private Boolean imageProxyEnabled;
|
|
|
|
@NotNull
|
|
@Min(0)
|
|
@Valid
|
|
private Integer queryTimeout;
|
|
|
|
@NotNull
|
|
@Min(0)
|
|
@Valid
|
|
private Integer keepStatusDays;
|
|
|
|
@NotNull
|
|
@Min(0)
|
|
@Valid
|
|
private Integer maxFeedCapacity;
|
|
|
|
@NotNull
|
|
@Min(0)
|
|
@Valid
|
|
private Integer refreshIntervalMinutes;
|
|
|
|
@NotNull
|
|
@Valid
|
|
private CacheType cache;
|
|
|
|
@Valid
|
|
private String announcement;
|
|
|
|
private String userAgent;
|
|
|
|
public Date getUnreadThreshold() {
|
|
int keepStatusDays = getKeepStatusDays();
|
|
return keepStatusDays > 0 ? DateUtils.addDays(new Date(), -1 * keepStatusDays) : null;
|
|
}
|
|
|
|
}
|
|
|
|
}
|