use of org.activityinfo.server.command.handler.sync.UpdateBuilder in project activityinfo by bedatadriven.
the class GetSyncRegionUpdatesHandler method execute.
@Override
public CommandResult execute(GetSyncRegionUpdates cmd, User user) throws CommandException {
Log.info("Fetching updates for " + cmd.getRegionId() + ", localVersion = " + cmd.getLocalVersion());
UpdateBuilder builder;
if (cmd.getRegionId().equals("schema")) {
builder = injector.getInstance(SchemaUpdateBuilder.class);
} else if (cmd.getRegionId().startsWith("admin/")) {
builder = injector.getInstance(AdminUpdateBuilder.class);
} else if (cmd.getRegionId().startsWith("location/")) {
builder = injector.getInstance(LocationUpdateBuilder.class);
} else if (cmd.getRegionId().startsWith("site/")) {
builder = injector.getInstance(SiteUpdateBuilder.class);
} else if (cmd.getRegionId().equals("site-tables")) {
builder = injector.getInstance(SiteTableUpdateBuilder.class);
} else {
throw new CommandException("Unknown sync region: " + cmd.getRegionId());
}
try {
return builder.build(user, cmd);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
Aggregations