/** * Creates a socket-binding if it doesn't already exists. * * @param port port of the connector, which will be converted to socket-binding * @param name name of the protocol which is used by connector (ajp/http/https) * @return name of the socket-binding so it cant be referenced in connector * @throws NodeGenerationException if createDefaultSocket fails to unmarshall socket-bindings */ private static String createSocketBinding( String port, String name, ServerMigratorResource resource) throws NodeGenerationException { // TODO: Refactor and change the logic MIGR-71 for (SocketBindingBean sb : resource.getSocketTemp()) { if (sb.getSocketPort().equals(port)) { return sb.getSocketName(); } if (sb.getSocketName().equals(name)) { name = "createdSocket"; } } SocketBindingBean socketBinding = new SocketBindingBean(); for (SocketBindingBean sb : resource.getSocketBindings()) { if (sb.getSocketPort().equals(port)) { return sb.getSocketName(); } } for (SocketBindingBean sb : resource.getSocketBindings()) { if (sb.getSocketName().equals(name)) { name = name.concat(resource.getRandomSocket().toString()); } } socketBinding.setSocketName(name); socketBinding.setSocketPort(port); resource.getSocketBindings().add(socketBinding); return name; }