private @Nullable VPNConnection toConnection( @SuppressWarnings("UnusedParameters") @Nonnull ProviderContext ctx, @Nullable Node node) throws CloudException, InternalException { if (node == null) { return null; } NodeList attributes = node.getChildNodes(); VPNConnection connection = new VPNConnection(); connection.setCurrentState(VPNConnectionState.PENDING); for (int i = 0; i < attributes.getLength(); i++) { Node attr = attributes.item(i); String nodeName = attr.getNodeName(); if (nodeName.equalsIgnoreCase("vpnConnectionId") && attr.hasChildNodes()) { connection.setProviderVpnConnectionId(attr.getFirstChild().getNodeValue().trim()); } else if (nodeName.equalsIgnoreCase("customerGatewayId") && attr.hasChildNodes()) { connection.setProviderGatewayId(attr.getFirstChild().getNodeValue().trim()); } else if (nodeName.equalsIgnoreCase("vpnGatewayId") && attr.hasChildNodes()) { connection.setProviderVpnId(attr.getFirstChild().getNodeValue().trim()); } else if (nodeName.equalsIgnoreCase("customerGatewayConfiguration") && attr.hasChildNodes()) { connection.setConfigurationXml(attr.getFirstChild().getNodeValue().trim()); } else if (nodeName.equalsIgnoreCase("state") && attr.hasChildNodes()) { String state = attr.getFirstChild().getNodeValue().trim(); if (state.equalsIgnoreCase("available")) { connection.setCurrentState(VPNConnectionState.AVAILABLE); } else if (state.equalsIgnoreCase("deleting")) { connection.setCurrentState(VPNConnectionState.DELETING); } else if (state.equalsIgnoreCase("deleted")) { connection.setCurrentState(VPNConnectionState.DELETED); } else if (state.equalsIgnoreCase("pending")) { connection.setCurrentState(VPNConnectionState.PENDING); } else { logger.warn("DEBUG: Unknown VPN connection state: " + state); } } else if (nodeName.equalsIgnoreCase("type") && attr.hasChildNodes()) { String t = attr.getFirstChild().getNodeValue().trim(); if (t.equalsIgnoreCase("ipsec.1")) { connection.setProtocol(VPNProtocol.IPSEC1); } else if (t.equalsIgnoreCase("openvpn")) { connection.setProtocol(VPNProtocol.OPEN_VPN); } else { logger.warn("DEBUG: Unknown VPN connection type: " + t); connection.setProtocol(VPNProtocol.IPSEC1); } } } if (connection.getProviderVpnConnectionId() == null) { return null; } return connection; }