develop #22
|
@ -12,20 +12,25 @@ import javax.persistence.Id
|
|||
import javax.persistence.Table
|
||||
import javax.validation.constraints.NotBlank
|
||||
|
||||
data class Configuration(
|
||||
sealed class ConfigurationBase(
|
||||
@JsonIgnore
|
||||
val type: ConfigurationType,
|
||||
val content: String,
|
||||
val lastUpdated: LocalDateTime
|
||||
) {
|
||||
val key = type.key
|
||||
val requireRestart = type.requireRestart
|
||||
val editable = !type.computed
|
||||
}
|
||||
|
||||
class Configuration(type: ConfigurationType, val content: String, lastUpdated: LocalDateTime) :
|
||||
ConfigurationBase(type, lastUpdated) {
|
||||
fun toEntity() =
|
||||
ConfigurationEntity(key, content, lastUpdated)
|
||||
}
|
||||
|
||||
class SecureConfiguration(type: ConfigurationType, lastUpdated: LocalDateTime) :
|
||||
ConfigurationBase(type, lastUpdated)
|
||||
|
||||
@Entity
|
||||
@Table(name = "configuration")
|
||||
data class ConfigurationEntity(
|
||||
|
@ -92,7 +97,13 @@ enum class ConfigurationType(
|
|||
|
||||
DATABASE_URL("database.url", defaultContent = "mysql://localhost/cre", file = true, requireRestart = true),
|
||||
DATABASE_USER("database.user", defaultContent = "cre", file = true, requireRestart = true),
|
||||
DATABASE_PASSWORD("database.password", defaultContent = "asecurepassword", file = true, requireRestart = true, secure = true),
|
||||
DATABASE_PASSWORD(
|
||||
"database.password",
|
||||
defaultContent = "asecurepassword",
|
||||
file = true,
|
||||
requireRestart = true,
|
||||
secure = true
|
||||
),
|
||||
DATABASE_SUPPORTED_VERSION("database.version.supported", computed = true),
|
||||
|
||||
RECIPE_APPROBATION_EXPIRATION("recipe.approbation.expiration", defaultContent = 4.months),
|
||||
|
@ -128,15 +139,15 @@ class InvalidConfigurationKeyException(val key: String) :
|
|||
)
|
||||
|
||||
class InvalidImageConfigurationException(val type: ConfigurationType) :
|
||||
RestException(
|
||||
"invalid-configuration-image",
|
||||
"Invalid image configuration",
|
||||
HttpStatus.BAD_REQUEST,
|
||||
"The configuration with the key '${type.key}' does not accept images as content",
|
||||
mapOf(
|
||||
"key" to type.key
|
||||
)
|
||||
)
|
||||
RestException(
|
||||
"invalid-configuration-image",
|
||||
"Invalid image configuration",
|
||||
HttpStatus.BAD_REQUEST,
|
||||
"The configuration with the key '${type.key}' does not accept images as content",
|
||||
mapOf(
|
||||
"key" to type.key
|
||||
)
|
||||
)
|
||||
|
||||
class ConfigurationNotSetException(val type: ConfigurationType) :
|
||||
RestException(
|
||||
|
|
Loading…
Reference in New Issue