Search in sources :

Example 26 with ISymmetricEngine

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;
}
Also used : EnvironmentSpecificProperties(org.jumpmind.properties.EnvironmentSpecificProperties) ClientSymmetricEngine(org.jumpmind.symmetric.ClientSymmetricEngine) ISymmetricEngine(org.jumpmind.symmetric.ISymmetricEngine)

Example 27 with ISymmetricEngine

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;
    }
}
Also used : ISymmetricEngine(org.jumpmind.symmetric.ISymmetricEngine) SymmetricEngineHolder(org.jumpmind.symmetric.web.SymmetricEngineHolder)

Example 28 with ISymmetricEngine

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;
    }
}
Also used : ISymmetricEngine(org.jumpmind.symmetric.ISymmetricEngine) SymmetricEngineHolder(org.jumpmind.symmetric.web.SymmetricEngineHolder)

Example 29 with ISymmetricEngine

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;
}
Also used : EngineList(org.jumpmind.symmetric.web.rest.model.EngineList) ISymmetricEngine(org.jumpmind.symmetric.ISymmetricEngine) ISymmetricEngine(org.jumpmind.symmetric.ISymmetricEngine) Engine(org.jumpmind.symmetric.web.rest.model.Engine) ServerSymmetricEngine(org.jumpmind.symmetric.web.ServerSymmetricEngine) ServerSymmetricEngine(org.jumpmind.symmetric.web.ServerSymmetricEngine) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) ApiOperation(com.wordnik.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 30 with ISymmetricEngine

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;
}
Also used : BatchAck(org.jumpmind.symmetric.model.BatchAck) BatchAckResults(org.jumpmind.symmetric.web.rest.model.BatchAckResults) BatchAckResult(org.jumpmind.symmetric.model.BatchAckResult) ISymmetricEngine(org.jumpmind.symmetric.ISymmetricEngine) IAcknowledgeService(org.jumpmind.symmetric.service.IAcknowledgeService) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) ApiOperation(com.wordnik.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

ISymmetricEngine (org.jumpmind.symmetric.ISymmetricEngine)35 IOException (java.io.IOException)12 INodeService (org.jumpmind.symmetric.service.INodeService)8 ApiOperation (com.wordnik.swagger.annotations.ApiOperation)7 InputStream (java.io.InputStream)7 IDatabasePlatform (org.jumpmind.db.platform.IDatabasePlatform)7 Node (org.jumpmind.symmetric.model.Node)7 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)7 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)7 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)7 OutputStream (java.io.OutputStream)6 PipedInputStream (java.io.PipedInputStream)6 PipedOutputStream (java.io.PipedOutputStream)6 NotImplementedException (org.apache.commons.lang.NotImplementedException)6 DatabaseInfo (org.jumpmind.db.platform.DatabaseInfo)6 IExtensionService (org.jumpmind.symmetric.service.IExtensionService)6 File (java.io.File)5 ISqlTransaction (org.jumpmind.db.sql.ISqlTransaction)5 ProcessInfo (org.jumpmind.symmetric.model.ProcessInfo)5 IParameterService (org.jumpmind.symmetric.service.IParameterService)5