use of org.jumpmind.symmetric.web.rest.model.NodeList in project symmetric-ds by JumpMind.
the class RestService method childrenImpl.
private NodeList childrenImpl(ISymmetricEngine engine) {
NodeList children = new NodeList();
Node xmlChildNode = null;
INodeService nodeService = engine.getNodeService();
org.jumpmind.symmetric.model.Node modelNode = nodeService.findIdentity();
if (isRegistered(engine)) {
if (isRootNode(engine, modelNode)) {
NetworkedNode networkedNode = nodeService.getRootNetworkedNode();
Set<NetworkedNode> childNetwork = networkedNode.getChildren();
if (childNetwork != null) {
for (NetworkedNode child : childNetwork) {
List<NodeHost> nodeHosts = nodeService.findNodeHosts(child.getNode().getNodeId());
NodeSecurity nodeSecurity = nodeService.findNodeSecurity(child.getNode().getNodeId());
xmlChildNode = new Node();
xmlChildNode.setNodeId(child.getNode().getNodeId());
xmlChildNode.setExternalId(child.getNode().getExternalId());
xmlChildNode.setRegistrationServer(false);
xmlChildNode.setSyncUrl(child.getNode().getSyncUrl());
xmlChildNode.setBatchInErrorCount(child.getNode().getBatchInErrorCount());
xmlChildNode.setBatchToSendCount(child.getNode().getBatchToSendCount());
if (nodeHosts.size() > 0) {
xmlChildNode.setLastHeartbeat(nodeHosts.get(0).getHeartbeatTime());
}
xmlChildNode.setRegistered(nodeSecurity.hasRegistered());
xmlChildNode.setInitialLoaded(nodeSecurity.hasInitialLoaded());
xmlChildNode.setReverseInitialLoaded(nodeSecurity.hasReverseInitialLoaded());
if (child.getNode().getCreatedAtNodeId() == null) {
xmlChildNode.setRegistrationServer(true);
}
children.addNode(xmlChildNode);
}
}
}
} else {
throw new NotFoundException();
}
return children;
}
Aggregations