use of org.jumpmind.symmetric.ISymmetricEngine in project symmetric-ds by JumpMind.
the class TestSetupUtil method prepareRoot.
protected static ISymmetricEngine prepareRoot(String sql) {
removeEmbededdedDatabases();
EnvironmentSpecificProperties properties = new EnvironmentSpecificProperties(new URL[] { getResource(DbTestUtils.DB_TEST_PROPERTIES), getResource("/symmetric-test.properties") }, "test.root", new String[] { "root" });
if (StringUtils.isNotBlank(sql)) {
properties.setProperty(ParameterConstants.AUTO_CONFIGURE_REG_SVR_SQL_SCRIPT, sql);
}
ISymmetricEngine engine = new ClientSymmetricEngine(properties);
engine.getStagingManager().clean(0);
dropAndCreateDatabaseTables(properties.getProperty("test.root"), engine);
return engine;
}
use of org.jumpmind.symmetric.ISymmetricEngine in project symmetric-ds by JumpMind.
the class RestService method getSymmetricEngine.
protected ISymmetricEngine getSymmetricEngine() {
ISymmetricEngine engine = null;
SymmetricEngineHolder holder = getSymmetricEngineHolder();
if (holder.getEngines().size() > 0) {
engine = holder.getEngines().values().iterator().next();
}
if (engine == null) {
throw new NotAllowedException();
} else if (!engine.getParameterService().is(ParameterConstants.REST_API_ENABLED)) {
throw new NotAllowedException("The REST API was not enabled for %s", engine.getEngineName());
} else {
return engine;
}
}
use of org.jumpmind.symmetric.ISymmetricEngine in project symmetric-ds by JumpMind.
the class RestService method getSymmetricEngine.
protected ISymmetricEngine getSymmetricEngine(String engineName) {
SymmetricEngineHolder holder = getSymmetricEngineHolder();
ISymmetricEngine engine = null;
if (StringUtils.isNotBlank(engineName)) {
engine = holder.getEngines().get(engineName);
}
if (engine == null) {
throw new NotFoundException();
} else if (!engine.getParameterService().is(ParameterConstants.REST_API_ENABLED)) {
throw new NotAllowedException("The REST API was not enabled for %s", engine.getEngineName());
} else {
MDC.put("engineName", engine.getEngineName());
return engine;
}
}
use of org.jumpmind.symmetric.ISymmetricEngine in project symmetric-ds by JumpMind.
the class RestService method getEngineList.
/**
* Provides a list of {@link Engine} that are configured on the node.
*
* @return {@link EngineList} - Engines configured on the node <br>
*
* <pre>
* Example xml reponse is as follows:<br><br>
* {@code
* <enginelist>
* <engines>
* <name>RootSugarDB-root</name>
* </engines>
* </enginelist>
* }
* <br>
* Example json response is as follows:<br><br>
* {"engines":[{"name":"RootSugarDB-root"}]}
* </pre>
*/
@ApiOperation(value = "Obtain a list of configured Engines")
@RequestMapping(value = "/enginelist", method = RequestMethod.GET)
@ResponseStatus(HttpStatus.OK)
@ResponseBody
public final EngineList getEngineList() {
EngineList list = new EngineList();
Collection<ServerSymmetricEngine> engines = getSymmetricEngineHolder().getEngines().values();
for (ISymmetricEngine engine : engines) {
if (engine.getParameterService().is(ParameterConstants.REST_API_ENABLED)) {
list.addEngine(new Engine(engine.getEngineName()));
}
}
return list;
}
use of org.jumpmind.symmetric.ISymmetricEngine in project symmetric-ds by JumpMind.
the class RestService method putAcknowledgeBatch.
@ApiOperation(value = "Acknowledge a set of batches for the specified engine")
@RequestMapping(value = "/engine/{engine}/acknowledgebatch", method = RequestMethod.PUT)
@ResponseStatus(HttpStatus.OK)
@ResponseBody
public final BatchAckResults putAcknowledgeBatch(@PathVariable("engine") String engineName, @ApiParam(value = "This the password for the nodeId being passed in. The password is stored in the node_security table.") @RequestParam(value = WebConstants.SECURITY_TOKEN) String securityToken, @RequestBody BatchResults batchResults) {
BatchAckResults finalResult = new BatchAckResults();
ISymmetricEngine engine = getSymmetricEngine(engineName);
List<BatchAckResult> results = null;
if (batchResults.getBatchResults().size() > 0) {
if (securityVerified(batchResults.getNodeId(), engine, securityToken)) {
IAcknowledgeService ackService = engine.getAcknowledgeService();
List<BatchAck> batchAcks = convertBatchResultsToAck(batchResults);
results = ackService.ack(batchAcks);
} else {
throw new NotAllowedException();
}
}
finalResult.setBatchAckResults(results);
return finalResult;
}
Aggregations