From 3938a678ec83a3e5a9c069e75dd28a555b12d4b1 Mon Sep 17 00:00:00 2001 From: chenson42 Date: Mon, 22 Jun 2015 17:39:05 +0000 Subject: [PATCH] 0002327: Add an install method to the REST api that takes a properties file and installs it in the engines directory and starts the node --- .../symmetric/web/rest/RestService.java | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/symmetric-server/src/main/java/org/jumpmind/symmetric/web/rest/RestService.java b/symmetric-server/src/main/java/org/jumpmind/symmetric/web/rest/RestService.java index 3fd297eaab..0235d89c6d 100644 --- a/symmetric-server/src/main/java/org/jumpmind/symmetric/web/rest/RestService.java +++ b/symmetric-server/src/main/java/org/jumpmind/symmetric/web/rest/RestService.java @@ -34,6 +34,7 @@ import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Properties; import java.util.Set; import javax.servlet.ServletContext; @@ -300,7 +301,7 @@ public final NodeList getChildrenByEngine(@PathVariable("engine") String engineN /** * Takes a snapshot for this engine and streams it to the client. The result * of this call is a stream that should be written to a zip file. The zip - * contains configuration and operational information about the installation + * contains configuration and operational information about the sureation * and can be used to diagnose state of the node */ @ApiOperation(value = "Take a diagnostic snapshot for the single engine") @@ -362,6 +363,28 @@ public final void getSnapshot(@PathVariable("engine") String engineName, IOUtils.closeQuietly(bis); } } + + /** + * Installs and starts a new node + * + * @param file + * A file stream that contains the node's properties. + */ + @ApiOperation(value = "Load a configuration file to the single engine") + @RequestMapping(value = "engine/install", method = RequestMethod.POST) + @ResponseStatus(HttpStatus.NO_CONTENT) + @ResponseBody + public final void postInstall(@RequestParam MultipartFile file) { + try { + Properties properties = new Properties(); + properties.load(file.getInputStream()); + getSymmetricEngineHolder().install(properties); + } catch (RuntimeException ex) { + throw ex; + } catch (Exception ex) { + throw new RuntimeException(ex); + } + } /** * Loads a configuration profile for the single engine on the node.