Skip to content
Snippets Groups Projects
Commit eabc7b77 authored by Daniel Gerhardt's avatar Daniel Gerhardt
Browse files

Add feature properties to configuration endpoint

parent 4ba5d63e
Branches
1 merge request!161Config endpoint
Pipeline #31637 passed with warnings with stages
in 1 minute and 30 seconds
......@@ -18,8 +18,11 @@
package de.thm.arsnova.config.properties;
import com.fasterxml.jackson.annotation.JsonView;
import org.springframework.boot.context.properties.ConfigurationProperties;
import de.thm.arsnova.model.serialization.View;
@ConfigurationProperties(FeatureProperties.PREFIX)
public class FeatureProperties {
public static final String PREFIX = "features";
......@@ -28,6 +31,7 @@ public class FeatureProperties {
private boolean enabled;
private int answerOptionLimit;
@JsonView(View.Public.class)
public boolean isEnabled() {
return enabled;
}
......@@ -36,6 +40,7 @@ public class FeatureProperties {
this.enabled = enabled;
}
@JsonView(View.Public.class)
public int getAnswerOptionLimit() {
return answerOptionLimit;
}
......@@ -48,6 +53,7 @@ public class FeatureProperties {
public static class Comments {
private boolean enabled;
@JsonView(View.Public.class)
public boolean isEnabled() {
return enabled;
}
......@@ -61,6 +67,7 @@ public class FeatureProperties {
private boolean enabled;
private int resetInterval;
@JsonView(View.Public.class)
public boolean isEnabled() {
return enabled;
}
......@@ -81,6 +88,7 @@ public class FeatureProperties {
public static class ContentPool {
private boolean enabled;
@JsonView(View.Public.class)
public boolean isEnabled() {
return enabled;
}
......@@ -95,6 +103,7 @@ public class FeatureProperties {
private LiveFeedback liveFeedback;
private ContentPool contentPool;
@JsonView(View.Public.class)
public Contents getContents() {
return contents;
}
......@@ -103,6 +112,7 @@ public class FeatureProperties {
this.contents = contents;
}
@JsonView(View.Public.class)
public Comments getComments() {
return comments;
}
......@@ -111,6 +121,7 @@ public class FeatureProperties {
this.comments = comments;
}
@JsonView(View.Public.class)
public LiveFeedback getLiveFeedback() {
return liveFeedback;
}
......@@ -119,6 +130,7 @@ public class FeatureProperties {
this.liveFeedback = liveFeedback;
}
@JsonView(View.Public.class)
public ContentPool getContentPool() {
return contentPool;
}
......
......@@ -19,13 +19,16 @@
package de.thm.arsnova.controller;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import de.thm.arsnova.config.SecurityConfig;
import de.thm.arsnova.config.properties.AuthenticationProviderProperties;
import de.thm.arsnova.config.properties.FeatureProperties;
import de.thm.arsnova.config.properties.UiProperties;
import de.thm.arsnova.model.AuthenticationProvider;
import de.thm.arsnova.model.Configuration;
......@@ -38,14 +41,19 @@ public class ConfigurationController {
private AuthenticationProviderProperties providerProperties;
private UiProperties uiProperties;
private FeatureProperties featureProperties;
private List<AuthenticationProvider> authenticationProviders;
private Map<String, Object> featureConfig;
public ConfigurationController(
final AuthenticationProviderProperties authenticationProviderProperties,
final UiProperties uiProperties) {
final UiProperties uiProperties,
final FeatureProperties featureProperties) {
this.providerProperties = authenticationProviderProperties;
this.uiProperties = uiProperties;
this.featureProperties = featureProperties;
buildAuthenticationProviderConfig();
buildFeatureConfig();
}
@RequestMapping
......@@ -53,6 +61,7 @@ public class ConfigurationController {
final Configuration configuration = new Configuration();
configuration.setAuthenticationProviders(authenticationProviders);
configuration.setUi(uiProperties.getUi());
configuration.setFeatures(featureConfig);
return configuration;
}
......@@ -79,4 +88,12 @@ public class ConfigurationController {
SecurityConfig.CAS_PROVIDER_ID, providerProperties.getCas()));
}
}
private void buildFeatureConfig() {
this.featureConfig = new HashMap<>();
featureConfig.put("contents", featureProperties.getContents());
featureConfig.put("comments", featureProperties.getComments());
featureConfig.put("liveFeedback", featureProperties.getLiveFeedback());
featureConfig.put("contentPool", featureProperties.getContentPool());
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment