Search in sources :

Example 31 with NodeSecurity

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;
}
Also used : RegistrationInfo(org.jumpmind.symmetric.web.rest.model.RegistrationInfo) NodeSecurity(org.jumpmind.symmetric.model.NodeSecurity) IRegistrationService(org.jumpmind.symmetric.service.IRegistrationService) ISymmetricEngine(org.jumpmind.symmetric.ISymmetricEngine) IOException(java.io.IOException) Date(java.util.Date) INodeService(org.jumpmind.symmetric.service.INodeService) Heartbeat(org.jumpmind.symmetric.web.rest.model.Heartbeat) IoException(org.jumpmind.exception.IoException) 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

NodeSecurity (org.jumpmind.symmetric.model.NodeSecurity)31 Node (org.jumpmind.symmetric.model.Node)13 INodeService (org.jumpmind.symmetric.service.INodeService)12 Date (java.util.Date)7 ProcessInfo (org.jumpmind.symmetric.model.ProcessInfo)7 ProcessInfoKey (org.jumpmind.symmetric.model.ProcessInfoKey)7 IOException (java.io.IOException)5 ArrayList (java.util.ArrayList)4 IoException (org.jumpmind.exception.IoException)4 SymmetricException (org.jumpmind.symmetric.SymmetricException)4 IncomingBatch (org.jumpmind.symmetric.model.IncomingBatch)4 NodeHost (org.jumpmind.symmetric.model.NodeHost)4 MalformedURLException (java.net.MalformedURLException)3 HashMap (java.util.HashMap)3 List (java.util.List)3 UniqueKeyException (org.jumpmind.db.sql.UniqueKeyException)3 ChannelMap (org.jumpmind.symmetric.model.ChannelMap)2 NetworkedNode (org.jumpmind.symmetric.model.NetworkedNode)2 NodeGroupLink (org.jumpmind.symmetric.model.NodeGroupLink)2 OutgoingBatch (org.jumpmind.symmetric.model.OutgoingBatch)2