public static ParsedResult parseMasked(ModelNode value) throws OperationFailedException { final String[] split = value.asString().split("/"); if (split.length != 2) { throw new OperationFailedException(MESSAGES.invalidAddressMaskValue(value.asString())); } try { // TODO - replace with non-dns routine InetAddress address = InetAddress.getByName(split[0]); int mask = Integer.parseInt(split[1]); int max = address.getAddress().length * 8; if (mask > max) { throw new OperationFailedException(MESSAGES.invalidAddressMask(split[1], "> " + max)); } else if (mask < 0) { throw new OperationFailedException(MESSAGES.invalidAddressMask(split[1], "< 0")); } return new ParsedResult(address, mask); } catch (final UnknownHostException e) { throw new OperationFailedException(MESSAGES.invalidAddressValue(split[0], e.getLocalizedMessage())); } catch (final NumberFormatException e) { throw new OperationFailedException(MESSAGES.invalidAddressMask(split[1], e.getLocalizedMessage())); } }
public static ParsedResult parseMasked(ModelNode value) throws OperationFailedException { final String[] split = value.asString().split("/"); if (split.length != 2) { throw new OperationFailedException(MESSAGES.invalidAddressMaskValue(value.asString())); } try { // TODO - replace with non-dns routine InetAddress address = InetAddress.getByName(split[0]); int mask = Integer.parseInt(split[1]); int max = address.getAddress().length * 8; if (mask > max) { throw new OperationFailedException(MESSAGES.invalidAddressMask(split[1], "> " + max)); } else if (mask < 0) { throw new OperationFailedException(MESSAGES.invalidAddressMask(split[1], "< 0")); } return new ParsedResult(address, mask); } catch (final UnknownHostException e) { throw new OperationFailedException(MESSAGES.invalidAddressValue(split[0], e.getLocalizedMessage())); } catch (final NumberFormatException e) { throw new OperationFailedException(MESSAGES.invalidAddressMask(split[1], e.getLocalizedMessage())); } }
public static ParsedResult parseMasked(ModelNode value) throws OperationFailedException { final String[] split = value.asString().split("/"); if (split.length != 2) { throw new OperationFailedException(ControllerLogger.ROOT_LOGGER.invalidAddressMaskValue(value.asString())); } try { // TODO - replace with non-dns routine InetAddress address = InetAddress.getByName(split[0]); int mask = Integer.parseInt(split[1]); int max = address.getAddress().length * 8; if (mask > max) { throw new OperationFailedException(ControllerLogger.ROOT_LOGGER.invalidAddressMask(split[1], "> " + max)); } else if (mask < 0) { throw new OperationFailedException(ControllerLogger.ROOT_LOGGER.invalidAddressMask(split[1], "< 0")); } return new ParsedResult(address, mask); } catch (final UnknownHostException e) { throw new OperationFailedException(ControllerLogger.ROOT_LOGGER.invalidAddressValue(split[0], e.getLocalizedMessage())); } catch (final NumberFormatException e) { throw new OperationFailedException(ControllerLogger.ROOT_LOGGER.invalidAddressMask(split[1], e.getLocalizedMessage())); } }
public static ParsedResult parseMasked(ModelNode value) throws OperationFailedException { final String[] split = value.asString().split("/"); if (split.length != 2) { throw new OperationFailedException(ControllerLogger.ROOT_LOGGER.invalidAddressMaskValue(value.asString())); } try { // TODO - replace with non-dns routine InetAddress address = InetAddress.getByName(split[0]); int mask = Integer.parseInt(split[1]); int max = address.getAddress().length * 8; if (mask > max) { throw new OperationFailedException(ControllerLogger.ROOT_LOGGER.invalidAddressMask(split[1], "> " + max)); } else if (mask < 0) { throw new OperationFailedException(ControllerLogger.ROOT_LOGGER.invalidAddressMask(split[1], "< 0")); } return new ParsedResult(address, mask); } catch (final UnknownHostException e) { throw new OperationFailedException(ControllerLogger.ROOT_LOGGER.invalidAddressValue(split[0], e.getLocalizedMessage())); } catch (final NumberFormatException e) { throw new OperationFailedException(ControllerLogger.ROOT_LOGGER.invalidAddressMask(split[1], e.getLocalizedMessage())); } }