use of org.jumpmind.symmetric.model.NodeSecurity in project symmetric-ds by JumpMind.
the class RestService method postRegisterNode.
@ApiOperation(value = "Register the specified node for the specified engine")
@RequestMapping(value = "/engine/{engine}/registernode", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.OK)
@ResponseBody
public final RegistrationInfo postRegisterNode(@PathVariable("engine") String engineName, @RequestParam(value = "externalId") String externalId, @RequestParam(value = "nodeGroupId") String nodeGroupId, @RequestParam(value = "databaseType") String databaseType, @RequestParam(value = "databaseVersion") String databaseVersion, @RequestParam(value = "hostName") String hostName) {
ISymmetricEngine engine = getSymmetricEngine(engineName);
IRegistrationService registrationService = engine.getRegistrationService();
INodeService nodeService = engine.getNodeService();
RegistrationInfo regInfo = new org.jumpmind.symmetric.web.rest.model.RegistrationInfo();
try {
org.jumpmind.symmetric.model.Node processedNode = registrationService.registerPullOnlyNode(externalId, nodeGroupId, databaseType, databaseVersion);
regInfo.setRegistered(processedNode.isSyncEnabled());
if (regInfo.isRegistered()) {
regInfo.setNodeId(processedNode.getNodeId());
NodeSecurity nodeSecurity = nodeService.findNodeSecurity(processedNode.getNodeId());
regInfo.setNodePassword(nodeSecurity.getNodePassword());
org.jumpmind.symmetric.model.Node modelNode = nodeService.findIdentity();
regInfo.setSyncUrl(modelNode.getSyncUrl());
// do an initial heartbeat
Heartbeat heartbeat = new Heartbeat();
heartbeat.setNodeId(regInfo.getNodeId());
heartbeat.setHostName(hostName);
Date now = new Date();
heartbeat.setCreateTime(now);
heartbeat.setLastRestartTime(now);
heartbeat.setHeartbeatTime(now);
this.heartbeatImpl(engine, heartbeat);
}
// TODO: Catch a RegistrationRedirectException and redirect.
} catch (IOException e) {
throw new IoException(e);
}
return regInfo;
}
Aggregations