private static void parseGet(String[] arr, ConfigUpdater o) throws ParseException { if (arr.length > 1) { switch (arr[1]) { case "LIST_CLIENT": { if (arr.length == 2) { o.sendList(ProxyFilter.getClientsLists()); } else { o.sendList(ProxyFilter.getClientList(arr[2])); } } break; case "LIST_ADDRESS": { if (arr.length == 2) { o.sendList(ProxyFilter.getAddressesLists()); } else { o.sendList(ProxyFilter.getAddressList(arr[2])); } } break; default: { throw new ParseException("Wrong get params", 2); } } } else { throw new ParseException("Wrong get section", 1); } }
private static void parseCreate(String[] arr, int lineNumber) throws ParseException { if (arr.length > 1) { switch (arr[1]) { case "LIST_CLIENT": { if (arr.length > 2) { ProxyFilter.createClientList(arr[2]); } else { throw new ParseException("Name for client list is not specified at " + lineNumber, 2); } } break; case "LIST_ADDRESS": { if (arr.length > 2) { ProxyFilter.createAddressList(arr[2]); } else { throw new ParseException( "Name for address list is not specified at " + lineNumber, 2); } } break; default: { throw new ParseException("Wrong create params at " + lineNumber, 2); } } } else { throw new ParseException("Wrong create section at " + lineNumber, 1); } }
private static void parseDefault(String[] arr, int lineNumber) throws ParseException { if (arr.length > 1) { ProxyFilter.setDefault(arr[1].equals("1")); } else { throw new ParseException("Wrong default section at " + lineNumber, 1); } }
private static void parseSave(ConfigUpdater o) throws IOException { if (_path != null) { File file = new File(_path); if (!file.isDirectory() && file.canWrite()) { FileWriter fr = new FileWriter(file); ProxyFilter.saveConfig(fr); o.sendSave("Saved current config to " + _path + " successfully"); fr.close(); } else { throw new IOException("Bad config file specified"); } } else { throw new IOException("File path not specified"); } }
private static void parseRemove(String[] arr, ConfigUpdater o) throws ParseException { if (arr.length > 1) { switch (arr[1]) { case "CLIENT": { if (arr.length > 2) { if (arr.length > 3) { switch (arr[3]) { case "LIST_CLIENT": { if (arr.length > 4) { o.sendRemoval(ProxyFilter.removeClientFromClientList(arr[4], arr[2])); } else { throw new ParseException("Name for client list is not specified", 6); } } break; case "LIST_ADDRESS": { if (arr.length > 4) { o.sendRemoval(ProxyFilter.removeClientFromAddressList(arr[4], arr[2])); } else { throw new ParseException("Name for address list is not specified", 6); } } break; default: { throw new ParseException("Wrong list type", 5); } } } else { throw new ParseException("List type is not specified", 4); } } else { throw new ParseException("Name for client is not specified", 3); } } break; case "ADDRESS": { if (arr.length > 2) { if (arr.length > 3) { switch (arr[3]) { case "LIST_ADDRESS": { if (arr.length > 4) { o.sendRemoval(ProxyFilter.removeAddressFromAddressList(arr[4], arr[2])); } else { throw new ParseException("Name for address list is not specified", 6); } } break; default: { throw new ParseException("Wrong list type", 5); } } } else { throw new ParseException("List type is not specified", 4); } } else { throw new ParseException("Address is not specified", 3); } } break; case "LIST_CLIENT": { if (arr.length > 2) { o.sendRemoval(ProxyFilter.removeClientList(arr[2])); } else { throw new ParseException("Name for client list is not specified", 3); } } break; case "LIST_ADDRESS": { if (arr.length > 2) { o.sendRemoval(ProxyFilter.removeAddressList(arr[2])); } else { throw new ParseException("Name for address list is not specified", 3); } } break; default: { throw new ParseException("Wrong remove params", 2); } } } else { throw new ParseException("Wrong remove section", 1); } }
private static void parseAdd(String[] arr, int lineNumber) throws ParseException { if (arr.length > 1) { switch (arr[1]) { case "CLIENT": { if (arr.length > 2) { if (arr.length > 3) { switch (arr[3]) { case "LIST_CLIENT": { if (arr.length > 4) { ProxyFilter.addClientToClientList(arr[4], arr[2]); } else { throw new ParseException( "Client list name not specified at " + lineNumber, 5); } } break; case "LIST_ADDRESS": { if (arr.length > 4) { if (arr.length > 5) { ProxyFilter.addClientToAddressList(arr[4], arr[2], arr[5].equals("1")); } else { throw new ParseException( "Permision type not specified at " + lineNumber, 6); } } else { throw new ParseException( "Address list name not specified at " + lineNumber, 5); } } break; default: { throw new ParseException("Wrong list type specified at " + lineNumber, 4); } } } else { throw new ParseException("List type not specified at " + lineNumber, 3); } } else { throw new ParseException("Client ip not specified at " + lineNumber, 2); } } break; case "LIST_CLIENT": { if (arr.length > 2) { if (arr.length > 3) { switch (arr[3]) { case "LIST_ADDRESS": { if (arr.length > 4) { if (arr.length > 5) { ProxyFilter.addClientListToAddressList( arr[4], arr[2], arr[5].equals("1")); } else { throw new ParseException( "Permision type not specified at " + lineNumber, 6); } } else { throw new ParseException( "Address list name not specified at " + lineNumber, 5); } } break; default: { throw new ParseException("Wrong list type specified at " + lineNumber, 4); } } } else { throw new ParseException("List type not specified at " + lineNumber, 3); } } else { throw new ParseException("Client list name not specified at " + lineNumber, 2); } } break; case "ADDRESS": { if (arr.length > 2) { if (arr.length > 3) { switch (arr[3]) { case "LIST_ADDRESS": { if (arr.length > 4) { ProxyFilter.addAddressToAddressList(arr[4], arr[2]); } else { throw new ParseException( "Address list name not specified at " + lineNumber, 5); } } break; default: { throw new ParseException("Wrong list type specified at " + lineNumber, 4); } } } else { throw new ParseException("List type not specified at " + lineNumber, 3); } } else { throw new ParseException("Website name not specified at " + lineNumber, 2); } } break; default: { throw new ParseException("Wrong add params at " + lineNumber, 2); } } } else { throw new ParseException("Wrong add section at " + lineNumber, 1); } }