Unverified Commit 7f1c68fd authored by Féry Mathieu (Mathius)'s avatar Féry Mathieu (Mathius)
Browse files

feat(datastore): Add endpoint for reset on dev

This option is available only if datastore emulated are attached
parent 7fa0789c
Pipeline #34319 passed with stages
in 6 minutes and 11 seconds
......@@ -10,7 +10,8 @@ import org.springframework.context.annotation.PropertySources;
* Class represent main app of Server
*/
@SpringBootApplication
@PropertySources(value = { @PropertySource("classpath:springdoc.properties") })
@PropertySources(value = { @PropertySource("classpath:springdoc.properties"),
@PropertySource("classpath:datastore.properties") })
public class App extends SpringBootServletInitializer {
public static void main(String[] args) {
......
package fr.univnantes.webandcloud.api.controllers;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import fr.univnantes.webandcloud.api.services.ServiceUsingDatastore;
@ConditionalOnProperty("datastore.emulated")
@RestController()
@RequestMapping("/datastore")
public class DatastoreController extends ServiceUsingDatastore {
@RequestMapping(value = "/reset", method = RequestMethod.GET)
public void reset() {
datastoreService.reset();
}
}
......@@ -71,6 +71,15 @@ public class DatastoreService implements SmartLifecycle {
return null;
}
public void reset() {
if (testing)
try {
localDatastore.reset();
} catch (IOException e) {
throw new RuntimeException("Error on reset of emulted datastore", e);
}
}
public Datastore getDatastore() {
if (datastore == null) {
logger.info("Init Datastore");
......
Markdown is supported
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