diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 79af6a0..2d4135e 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,10 +4,11 @@
-
-
-
-
+
+
+
+
+
@@ -51,10 +52,16 @@
+
+
{
@@ -97,48 +104,56 @@
- {
- "keyToString": {
- "Gradle.Build forms.executor": "Run",
- "Gradle.TestForm.executor": "Run",
- "Gradle.TestForm.testFunctions.executor": "Debug",
- "Gradle.TestForm.testRetrieveForm.executor": "Run",
- "RequestMappingsPanelOrder0": "0",
- "RequestMappingsPanelOrder1": "1",
- "RequestMappingsPanelWidth0": "75",
- "RequestMappingsPanelWidth1": "75",
- "RunOnceActivity.OpenProjectViewOnStart": "true",
- "RunOnceActivity.ShowReadmeOnStart": "true",
- "SHARE_PROJECT_CONFIGURATION_FILES": "true",
- "Spring Boot.Main.executor": "Run",
- "Tomcat Server.Tomcat 10.1.17.executor": "Run",
- "git-widget-placeholder": "master",
- "ignore.virus.scanning.warn.message": "true",
- "kotlin-language-version-configured": "true",
- "last_opened_file_path": "P:/Code/Plugins/forms",
- "node.js.detected.package.eslint": "true",
- "node.js.detected.package.tslint": "true",
- "node.js.selected.package.eslint": "(autodetect)",
- "node.js.selected.package.tslint": "(autodetect)",
- "nodejs_package_manager_path": "npm",
- "project.structure.last.edited": "Project",
- "project.structure.proportion": "0.0",
- "project.structure.side.proportion": "0.0",
- "run.code.analysis.last.selected.profile": "pProject Default",
- "settings.editor.selected.configurable": "preferences.lookFeel",
- "vue.rearranger.settings.migration": "true"
+
+}]]>
+
+
+
+
@@ -369,6 +384,7 @@
+
@@ -578,7 +594,63 @@
1723059265558
-
+
+
+ 1723242929470
+
+
+
+ 1723242929470
+
+
+
+ 1723242942749
+
+
+
+ 1723242942749
+
+
+
+ 1723242960642
+
+
+
+ 1723242960642
+
+
+
+ 1723243853994
+
+
+
+ 1723243853994
+
+
+
+ 1723247556185
+
+
+
+ 1723247556185
+
+
+
+ 1723249700073
+
+
+
+ 1723249700073
+
+
+
+ 1723249968746
+
+
+
+ 1723249968746
+
+
@@ -596,14 +668,6 @@
-
-
-
-
-
-
-
-
@@ -621,6 +685,14 @@
-
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/com/alttd/forms/controlers/form_active/BooleanResponse.java b/src/main/java/com/alttd/forms/controlers/form_active/BooleanResponse.java
new file mode 100644
index 0000000..9a94d4b
--- /dev/null
+++ b/src/main/java/com/alttd/forms/controlers/form_active/BooleanResponse.java
@@ -0,0 +1,4 @@
+package com.alttd.forms.controlers.form_active;
+
+public record BooleanResponse(boolean isActive) {
+}
diff --git a/src/main/java/com/alttd/forms/controlers/form_active/FormActiveController.java b/src/main/java/com/alttd/forms/controlers/form_active/FormActiveController.java
index 8919e96..6a3500f 100644
--- a/src/main/java/com/alttd/forms/controlers/form_active/FormActiveController.java
+++ b/src/main/java/com/alttd/forms/controlers/form_active/FormActiveController.java
@@ -1,7 +1,8 @@
package com.alttd.forms.controlers.form_active;
import com.alttd.forms.form.FormSettingsQuery;
-import jakarta.servlet.http.HttpServletRequest;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
import jakarta.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -21,7 +22,7 @@ public class FormActiveController {
private static final Logger logger = LoggerFactory.getLogger(FormActiveController.class);
@PostMapping("/formActive")
- public CompletableFuture> formActiveRequest(@Valid @RequestBody FormActiveData formData, HttpServletRequest request) {
+ public CompletableFuture> formActiveRequest(@Valid @RequestBody FormActiveData formData) {
logger.debug("formActive");
logger.trace(formData.toString());
@@ -29,12 +30,17 @@ public class FormActiveController {
return formSettingsQuery
.isActive(formData.formName)
.thenApply(result -> {
- if (result.isEmpty()) {
- return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Failed to check if the form is active");
- } else if (result.get()) {
- return ResponseEntity.ok("yes");
- } else {
- return ResponseEntity.ok("no");
+ try {
+ if (result.isEmpty()) {
+ return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Failed to check if the form is active");
+ } else if (result.get()) {
+ return ResponseEntity.ok(new ObjectMapper().writeValueAsString(new BooleanResponse(true)));
+ } else {
+ return ResponseEntity.ok(new ObjectMapper().writeValueAsString(new BooleanResponse(false)));
+ }
+ } catch (JsonProcessingException e) {
+ logger.error("Failed to parse BooleanResponse", e);
+ return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Failed to respond");
}
});
}
diff --git a/src/main/java/com/alttd/forms/controlers/form_active/FormActiveData.java b/src/main/java/com/alttd/forms/controlers/form_active/FormActiveData.java
index 52af249..e5d0733 100644
--- a/src/main/java/com/alttd/forms/controlers/form_active/FormActiveData.java
+++ b/src/main/java/com/alttd/forms/controlers/form_active/FormActiveData.java
@@ -6,6 +6,8 @@ import org.hibernate.validator.constraints.Length;
public class FormActiveData {
+ public FormActiveData() {}
+
public FormActiveData(String formName) {
this.formName = formName;
}
@@ -13,6 +15,6 @@ public class FormActiveData {
@NotEmpty(message = "You have to provide a form name")
@Length(min = 1, max = 64, message = "Usernames have to be between 3 and 16 characters")
@Pattern(regexp = "[a-zA-Z]{1,64}", message = "This is an invalid form name")
- public final String formName;
+ public String formName;
}
\ No newline at end of file
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index 5b2c197..596ab70 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -1,4 +1,4 @@
-logging.level.com.alttd.forms=warn
+logging.level.com.alttd.forms=WARN
server.port=8002
spring.jackson.date-format=yyyy-MM-dd
spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS=false
\ No newline at end of file