Permalink
Browse files

0001658: Add sync triggers by table to REST API

  • Loading branch information...
erilong committed Mar 31, 2014
1 parent 2c7e664 commit 687942b54095540bd6de30f8611e1ff4cb4fa1c1
Showing with 33 additions and 0 deletions.
  1. +33 −0 symmetric-server/src/main/java/org/jumpmind/symmetric/web/rest/RestService.java
@@ -41,6 +41,7 @@
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.MDC;
import org.jumpmind.db.model.Table;
import org.jumpmind.db.sql.ISqlTemplate;
import org.jumpmind.db.sql.Row;
import org.jumpmind.exception.IoException;
@@ -433,6 +434,17 @@ public final void postSyncTriggers(
syncTriggersImpl(getSymmetricEngine(), force);
}
@ApiOperation(value = "Sync triggers on the single engine for a table")
@RequestMapping(value = "engine/synctriggers/{table}", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.NO_CONTENT)
@ResponseBody
public final void postSyncTriggersByTable(@PathVariable("table") String tableName,
@RequestParam(required = false, value = "catalog") String catalogName,
@RequestParam(required = false, value = "schema") String schemaName,
@RequestParam(required = false, value = "force") boolean force) {
syncTriggersByTableImpl(getSymmetricEngine(), catalogName, schemaName, tableName, force);
}
/**
* Creates instances of triggers for each entry configured table/trigger for
* the specified engine on the node
@@ -446,6 +458,17 @@ public final void postSyncTriggersByEngine(@PathVariable("engine") String engine
syncTriggersImpl(getSymmetricEngine(engineName), force);
}
@ApiOperation(value = "Sync triggers on the specific engine for a table")
@RequestMapping(value = "engine/{engine}/synctriggers/{table}", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.NO_CONTENT)
@ResponseBody
public final void postSyncTriggersByTable(@PathVariable("engine") String engineName, @PathVariable("table") String tableName,
@RequestParam(required = false, value = "catalog") String catalogName,
@RequestParam(required = false, value = "schema") String schemaName,
@RequestParam(required = false, value = "force") boolean force) {
syncTriggersByTableImpl(getSymmetricEngine(engineName), catalogName, schemaName, tableName, force);
}
/**
* Removes instances of triggers for each entry configured table/trigger for
* the single engine on the node
@@ -1122,6 +1145,16 @@ private void syncTriggersImpl(ISymmetricEngine engine, boolean force) {
triggerRouterService.syncTriggers(buffer, force);
}
private void syncTriggersByTableImpl(ISymmetricEngine engine, String catalogName, String schemaName, String tableName, boolean force) {
ITriggerRouterService triggerRouterService = engine.getTriggerRouterService();
Table table = getSymmetricEngine().getDatabasePlatform().getTableFromCache(catalogName, schemaName, tableName, true);
if (table == null) {
throw new NotFoundException();
}
triggerRouterService.syncTriggers(table, force);
}
private void dropTriggersImpl(ISymmetricEngine engine) {
ITriggerRouterService triggerRouterService = engine.getTriggerRouterService();
triggerRouterService.dropTriggers();

0 comments on commit 687942b

Please sign in to comment.