List of usage examples for java.lang IllegalArgumentException toString
public String toString()
From source file:com.forrestguice.suntimeswidget.LocationConfigView.java
/** * @param context a context used to access shared prefs * @param bundle a Bundle containing saved state *//*from w w w .j a v a 2 s . c o m*/ protected void loadSettings(Context context, Bundle bundle) { //Log.d("DEBUG", "LocationConfigView loadSettings (bundle)"); // restore LocationMode spinner String modeString = bundle.getString(KEY_LOCATION_MODE); if (modeString != null) { WidgetSettings.LocationMode locationMode; try { locationMode = WidgetSettings.LocationMode.valueOf(modeString); } catch (IllegalArgumentException e) { locationMode = WidgetSettings.PREF_DEF_LOCATION_MODE; } spinner_locationMode.setSelection(locationMode.ordinal()); } else { spinner_locationMode.setSelection(WidgetSettings.PREF_DEF_LOCATION_MODE.ordinal()); } // restore location text fields String label = bundle.getString(KEY_LOCATION_LABEL); String longitude = bundle.getString(KEY_LOCATION_LONGITUDE); String latitude = bundle.getString(KEY_LOCATION_LATITUDE); WidgetSettings.Location location; if (longitude != null && latitude != null) { location = new WidgetSettings.Location(label, latitude, longitude); } else { Log.w("LocationConfigView", "Bundle contained null lat or lon; falling back to saved prefs."); location = WidgetSettings.loadLocationPref(context, appWidgetId); } updateViews(location); // restore dialog (sub)state String viewModeString = bundle.getString(KEY_DIALOGMODE); if (viewModeString != null) { LocationViewMode viewMode; try { viewMode = LocationViewMode.valueOf(viewModeString); } catch (IllegalArgumentException e) { Log.w("DEBUG", "Bundle contained bad viewModeString! " + e.toString()); viewMode = LocationViewMode.MODE_CUSTOM_SELECT; } setMode(viewMode); } getFixHelper.loadSettings(bundle); }
From source file:org.apache.accumulo.proxy.ProxyServer.java
@Override public void closeScanner(String scanner) throws UnknownScanner, TException { UUID uuid = null;// ww w. j a v a2 s. co m try { uuid = UUID.fromString(scanner); } catch (IllegalArgumentException e) { throw new UnknownScanner(e.getMessage()); } try { if (scannerCache.asMap().remove(uuid) == null) { throw new UnknownScanner("Scanner never existed or no longer exists"); } } catch (UnknownScanner e) { throw e; } catch (Exception e) { throw new TException(e.toString()); } }
From source file:org.globus.gsi.gssapi.GlobusGSSContextImpl.java
private ByteBuffer sslDataUnwrap(ByteBuffer inBBuff, ByteBuffer outBBuff) throws GSSException { try {/*from w ww. ja v a2 s. c om*/ int iter = 0; if (sslEngine.getHandshakeStatus() != SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING) { throw new Exception("SSLEngine handshaking needed! " + "HandshakeStatus: " + sslEngine.getHandshakeStatus().toString()); } do { logger.debug("PROCESSING DATA (UNWRAP) " + ++iter + ": " + inBBuff.remaining()); SSLEngineResult result = sslEngine.unwrap(inBBuff, outBBuff); if (result.getHandshakeStatus() == SSLEngineResult.HandshakeStatus.NEED_TASK) { runDelegatedTasks(sslEngine); continue; } if (result.getStatus() == SSLEngineResult.Status.BUFFER_OVERFLOW) { // increase it to the size needed. int appSize = sslEngine.getSession().getApplicationBufferSize(); ByteBuffer b = ByteBuffer.allocate(appSize + outBBuff.position()); outBBuff.flip(); b.put(outBBuff); outBBuff = b; continue; } else if (result.getStatus() == SSLEngineResult.Status.BUFFER_UNDERFLOW) { // More data needed from peer break; } else if (result.getStatus() == SSLEngineResult.Status.CLOSED) { throw new ClosedGSSException(); } if (result.getStatus() != SSLEngineResult.Status.OK) { throw new GlobusGSSException(GSSException.FAILURE, GlobusGSSException.TOKEN_FAIL, result.getStatus().toString()); } } while (inBBuff.hasRemaining()); return outBBuff; } catch (IllegalArgumentException e) { throw new GlobusGSSException(GSSException.DEFECTIVE_TOKEN, e); } catch (SSLException e) { if (e.toString().endsWith("bad record MAC")) throw new GlobusGSSException(GSSException.BAD_MIC, e); else if (e.toString().endsWith("ciphertext sanity check failed")) throw new GlobusGSSException(GSSException.DEFECTIVE_TOKEN, e); else throw new GlobusGSSException(GSSException.FAILURE, e); } catch (GSSException e) { throw e; } catch (Exception e) { throw new GlobusGSSException(GSSException.FAILURE, e); } }
From source file:com.akretion.kettle.steps.terminatooor.ScriptValuesAddedFunctions.java
public static String num2str(ScriptEngine actualContext, Bindings actualObject, Object[] ArgList, Object FunctionContext) { String sRC = ""; switch (ArgList.length) { case 0://from www. j a v a 2 s. co m throw new RuntimeException("The function call num2str requires at least 1 argument."); case 1: try { if (isNull(ArgList[0])) return null; else if (isUndefined(ArgList[0])) return (String) undefinedValue; double sArg1 = (Double) ArgList[0]; if (Double.isNaN(sArg1)) throw new RuntimeException("The first Argument must be a Number."); DecimalFormat formatter = new DecimalFormat(); sRC = formatter.format(sArg1); } catch (IllegalArgumentException e) { throw new RuntimeException("Could not apply the given format on the number : " + e.getMessage()); } break; case 2: try { if (isNull(ArgList, new int[] { 0, 1 })) return null; else if (isUndefined(ArgList, new int[] { 0, 1 })) return (String) undefinedValue; double sArg1 = (Double) ArgList[0]; if (Double.isNaN(sArg1)) throw new RuntimeException("The first Argument must be a Number."); String sArg2 = (String) ArgList[1]; DecimalFormat formatter = new DecimalFormat(sArg2); sRC = formatter.format(sArg1); } catch (IllegalArgumentException e) { throw new RuntimeException("Could not apply the given format on the number : " + e.getMessage()); } break; case 3: try { if (isNull(ArgList, new int[] { 0, 1, 2 })) return null; else if (isUndefined(ArgList, new int[] { 0, 1, 2 })) return (String) undefinedValue; double sArg1 = (Double) ArgList[0]; if (Double.isNaN(sArg1)) throw new RuntimeException("The first Argument must be a Number."); String sArg2 = (String) ArgList[1]; String sArg3 = (String) ArgList[2]; if (sArg3.length() == 2) { DecimalFormatSymbols dfs = new DecimalFormatSymbols(new Locale(sArg3.toLowerCase())); DecimalFormat formatter = new DecimalFormat(sArg2, dfs); sRC = formatter.format(sArg1); } } catch (Exception e) { throw new RuntimeException(e.toString()); } break; default: throw new RuntimeException("The function call num2str requires 1, 2, or 3 arguments."); } return sRC; }
From source file:com.panet.imeta.trans.steps.scriptvalues_mod.ScriptValuesAddedFunctions.java
public static String num2str(Context actualContext, Scriptable actualObject, Object[] ArgList, Function FunctionContext) { String sRC = ""; switch (ArgList.length) { case 0://from w w w . j a v a 2 s. c o m throw Context.reportRuntimeError("The function call num2str requires at least 1 argument."); case 1: try { if (isNull(ArgList[0])) return null; else if (isUndefined(ArgList[0])) return (String) Context.getUndefinedValue(); double sArg1 = Context.toNumber(ArgList[0]); if (Double.isNaN(sArg1)) throw Context.reportRuntimeError("The first Argument must be a Number."); DecimalFormat formatter = new DecimalFormat(); sRC = formatter.format(sArg1); } catch (IllegalArgumentException e) { throw Context .reportRuntimeError("Could not apply the given format on the number : " + e.getMessage()); } break; case 2: try { if (isNull(ArgList, new int[] { 0, 1 })) return null; else if (isUndefined(ArgList, new int[] { 0, 1 })) return (String) Context.getUndefinedValue(); double sArg1 = Context.toNumber(ArgList[0]); if (Double.isNaN(sArg1)) throw Context.reportRuntimeError("The first Argument must be a Number."); String sArg2 = Context.toString(ArgList[1]); DecimalFormat formatter = new DecimalFormat(sArg2); sRC = formatter.format(sArg1); } catch (IllegalArgumentException e) { throw Context .reportRuntimeError("Could not apply the given format on the number : " + e.getMessage()); } break; case 3: try { if (isNull(ArgList, new int[] { 0, 1, 2 })) return null; else if (isUndefined(ArgList, new int[] { 0, 1, 2 })) return (String) Context.getUndefinedValue(); double sArg1 = Context.toNumber(ArgList[0]); if (Double.isNaN(sArg1)) throw Context.reportRuntimeError("The first Argument must be a Number."); String sArg2 = Context.toString(ArgList[1]); String sArg3 = Context.toString(ArgList[2]); if (sArg3.length() == 2) { DecimalFormatSymbols dfs = new DecimalFormatSymbols(new Locale(sArg3.toLowerCase())); DecimalFormat formatter = new DecimalFormat(sArg2, dfs); sRC = formatter.format(sArg1); } } catch (Exception e) { throw Context.reportRuntimeError(e.toString()); } break; default: throw Context.reportRuntimeError("The function call num2str requires 1, 2, or 3 arguments."); } return sRC; }
From source file:com.comphenix.protocol.PacketLogging.java
@Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { PacketType type = null;//from w w w.j ava2 s .c o m try { if (args.length > 2) { Protocol protocol; try { protocol = Protocol.valueOf(args[0].toUpperCase()); } catch (IllegalArgumentException ex) { sender.sendMessage(ChatColor.RED + "Unknown protocol " + args[0]); return true; } Sender pSender; try { pSender = Sender.valueOf(args[1].toUpperCase()); } catch (IllegalArgumentException ex) { sender.sendMessage(ChatColor.RED + "Unknown sender: " + args[1]); return true; } try { try { // Try IDs first int id = Integer.parseInt(args[2]); type = PacketType.findCurrent(protocol, pSender, id); } catch (NumberFormatException ex) { // Check packet names String name = args[2]; outer: for (PacketType packet : PacketType.values()) { if (packet.getProtocol() == protocol && packet.getSender() == pSender) { if (packet.name().equalsIgnoreCase(name)) { type = packet; break outer; } for (String className : packet.getClassNames()) { if (className.equalsIgnoreCase(name)) { type = packet; break outer; } } } } } } catch (IllegalArgumentException ex) { // RIP type = null; } if (type == null) { sender.sendMessage(ChatColor.RED + "Unknown packet: " + args[2]); return true; } if (args.length > 3) { if (args[3].equalsIgnoreCase("console")) { this.location = LogLocation.CONSOLE; } else { this.location = LogLocation.FILE; } } if (pSender == Sender.CLIENT) { if (receivingTypes.contains(type)) { receivingTypes.remove(type); } else { receivingTypes.add(type); } } else { if (sendingTypes.contains(type)) { sendingTypes.remove(type); } else { sendingTypes.add(type); } } startLogging(); sender.sendMessage(ChatColor.GREEN + "Now logging " + type.getPacketClass().getSimpleName()); return true; } sender.sendMessage( ChatColor.RED + "Invalid syntax: /packetlog <protocol> <sender> <packet> [location]"); return true; } catch (Throwable ex) { sender.sendMessage(ChatColor.RED + "Failed to parse command: " + ex.toString()); return true; } }
From source file:org.pentaho.di.trans.steps.script.ScriptAddedFunctions.java
public static String num2str(ScriptEngine actualContext, Bindings actualObject, Object[] ArgList, Object FunctionContext) { String sRC = ""; switch (ArgList.length) { case 0:/*from ww w. ja va2s . co m*/ throw new RuntimeException("The function call num2str requires at least 1 argument."); case 1: try { if (isNull(ArgList[0])) { return null; } else if (isUndefined(ArgList[0])) { return (String) undefinedValue; } double sArg1 = (Double) ArgList[0]; if (Double.isNaN(sArg1)) { throw new RuntimeException("The first Argument must be a Number."); } DecimalFormat formatter = new DecimalFormat(); sRC = formatter.format(sArg1); } catch (IllegalArgumentException e) { throw new RuntimeException("Could not apply the given format on the number : " + e.getMessage()); } break; case 2: try { if (isNull(ArgList, new int[] { 0, 1 })) { return null; } else if (isUndefined(ArgList, new int[] { 0, 1 })) { return (String) undefinedValue; } double sArg1 = (Double) ArgList[0]; if (Double.isNaN(sArg1)) { throw new RuntimeException("The first Argument must be a Number."); } String sArg2 = (String) ArgList[1]; DecimalFormat formatter = new DecimalFormat(sArg2); sRC = formatter.format(sArg1); } catch (IllegalArgumentException e) { throw new RuntimeException("Could not apply the given format on the number : " + e.getMessage()); } break; case 3: try { if (isNull(ArgList, new int[] { 0, 1, 2 })) { return null; } else if (isUndefined(ArgList, new int[] { 0, 1, 2 })) { return (String) undefinedValue; } double sArg1 = (Double) ArgList[0]; if (Double.isNaN(sArg1)) { throw new RuntimeException("The first Argument must be a Number."); } String sArg2 = (String) ArgList[1]; String sArg3 = (String) ArgList[2]; if (sArg3.length() == 2) { DecimalFormatSymbols dfs = new DecimalFormatSymbols(EnvUtil.createLocale(sArg3.toLowerCase())); DecimalFormat formatter = new DecimalFormat(sArg2, dfs); sRC = formatter.format(sArg1); } } catch (Exception e) { throw new RuntimeException(e.toString()); } break; default: throw new RuntimeException("The function call num2str requires 1, 2, or 3 arguments."); } return sRC; }
From source file:org.pentaho.di.trans.steps.scriptvalues_mod.ScriptValuesAddedFunctions.java
public static String num2str(Context actualContext, Scriptable actualObject, Object[] ArgList, Function FunctionContext) { String sRC = ""; switch (ArgList.length) { case 0://from w w w .j a v a 2 s .co m throw Context.reportRuntimeError("The function call num2str requires at least 1 argument."); case 1: try { if (isNull(ArgList[0])) { return null; } else if (isUndefined(ArgList[0])) { return (String) Context.getUndefinedValue(); } double sArg1 = Context.toNumber(ArgList[0]); if (Double.isNaN(sArg1)) { throw Context.reportRuntimeError("The first Argument must be a Number."); } DecimalFormat formatter = new DecimalFormat(); sRC = formatter.format(sArg1); } catch (IllegalArgumentException e) { throw Context .reportRuntimeError("Could not apply the given format on the number : " + e.getMessage()); } break; case 2: try { if (isNull(ArgList, new int[] { 0, 1 })) { return null; } else if (isUndefined(ArgList, new int[] { 0, 1 })) { return (String) Context.getUndefinedValue(); } double sArg1 = Context.toNumber(ArgList[0]); if (Double.isNaN(sArg1)) { throw Context.reportRuntimeError("The first Argument must be a Number."); } String sArg2 = Context.toString(ArgList[1]); DecimalFormat formatter = new DecimalFormat(sArg2); sRC = formatter.format(sArg1); } catch (IllegalArgumentException e) { throw Context .reportRuntimeError("Could not apply the given format on the number : " + e.getMessage()); } break; case 3: try { if (isNull(ArgList, new int[] { 0, 1, 2 })) { return null; } else if (isUndefined(ArgList, new int[] { 0, 1, 2 })) { return (String) Context.getUndefinedValue(); } double sArg1 = Context.toNumber(ArgList[0]); if (Double.isNaN(sArg1)) { throw Context.reportRuntimeError("The first Argument must be a Number."); } String sArg2 = Context.toString(ArgList[1]); String sArg3 = Context.toString(ArgList[2]); if (sArg3.length() == 2) { DecimalFormatSymbols dfs = new DecimalFormatSymbols(EnvUtil.createLocale(sArg3.toLowerCase())); DecimalFormat formatter = new DecimalFormat(sArg2, dfs); sRC = formatter.format(sArg1); } } catch (Exception e) { throw Context.reportRuntimeError(e.toString()); } break; default: throw Context.reportRuntimeError("The function call num2str requires 1, 2, or 3 arguments."); } return sRC; }
From source file:net.vivekiyer.GAL.Configure.java
@Override public void taskComplete(boolean taskStatus, int statusCode, int requestStatus, String errorString) { if ((progressdialog != null) && progressdialog.isShowing()) { try {//from w ww . j av a 2 s . c o m progressdialog.dismiss(); } catch (java.lang.IllegalArgumentException e) { } } // Looks like there was an error in the settings if (!taskStatus) { if (Debug.Enabled) { // Send the error message via email Debug.sendDebugEmail(this); } else { try { // Handle all errors we're capable of, // inform user of others switch (statusCode) { case 200: // Successful, but obviously something went wrong switch (requestStatus) { case Parser.STATUS_TOO_MANY_DEVICES: ChoiceDialogFragment .newInstance(getString(R.string.too_many_device_partnerships_title), getString(R.string.too_many_device_partnerships_detail)) .show(getSupportFragmentManager(), "tooManyDevices"); //$NON-NLS-1$ break; default: break; } break; case 401: // UNAUTHORIZED ChoiceDialogFragment .newInstance(getString(R.string.authentication_failed_title), getString(R.string.authentication_failed_detail)) .show(getSupportFragmentManager(), "unauthorized"); //$NON-NLS-1$ break; case 403: // FORBIDDEN, typically means that the DeviceID is not accepted and needs to be set in Exchange String title = getString(R.string.forbidden_by_server_title); String details = getString(R.string.forbidden_by_server_detail, activeSyncManager.getDeviceId()); ChoiceDialogFragment .newInstance(title, details, getString(android.R.string.ok), getString(android.R.string.copy), android.R.id.button2, android.R.id.copy) .setListener(this).show(getSupportFragmentManager(), "forbidden"); //$NON-NLS-1$ break; case ConnectionChecker.SSL_PEER_UNVERIFIED: ChoiceDialogFragment .newInstance(getString(R.string.authentication_failed_title), getString(R.string.unable_to_find_matching_certificate, "\n", //$NON-NLS-1$ getString(R.string.acceptAllSllText))).show(getSupportFragmentManager(), "SslUnverified"); //$NON-NLS-1$ break; case ConnectionChecker.UNKNOWN_HOST: ChoiceDialogFragment .newInstance(getString(R.string.invalid_server_title), getString(R.string.invalid_server_detail)) .show(getSupportFragmentManager(), "UnknownHost"); //$NON-NLS-1$ break; case ConnectionChecker.TIMEOUT: ChoiceDialogFragment .newInstance(getString(R.string.timeout_title), String.format(getString(R.string.timeout_detail), getString(R.string.useSecureSslText))) .show(getSupportFragmentManager(), "Timeout"); //$NON-NLS-1$ break; default: ChoiceDialogFragment .newInstance(getString(R.string.connection_failed_title), getString(R.string.connection_failed_detail, statusCode)) .show(getSupportFragmentManager(), "connError"); //$NON-NLS-1$ break; } } catch (java.lang.IllegalStateException e) { Debug.Log("Server configuration window was dismissed before Connection check was finished:\n" //$NON-NLS-1$ + e.toString()); } } } // All went well. Store the settings and return to the main page else { SharedPreferences.Editor editor = mPreferences.edit(); editor.putString(KEY_SERVER_PREFERENCE, getTextFromId(R.id.txtServerName).trim()); editor.putString(KEY_DOMAIN_PREFERENCE, domain); editor.putString(KEY_USERNAME_PREFERENCE, username); editor.putString(KEY_PASSWORD_PREFERENCE, getTextFromId(R.id.txtPassword)); editor.putBoolean(KEY_USE_SSL, getValueFromCheckbox(R.id.chkUseSSL)); editor.putBoolean(KEY_ACCEPT_ALL_CERTS, getValueFromCheckbox(R.id.chkAcceptAllSSLCert)); editor.putString(KEY_ACTIVESYNCVERSION_PREFERENCE, activeSyncManager.getActiveSyncVersion()); editor.putString(KEY_DEVICE_ID_STRING, activeSyncManager.getDeviceId()); editor.putString(KEY_POLICY_KEY_PREFERENCE, activeSyncManager.getPolicyKey()); editor.putBoolean(Configure.KEY_SUCCESSFULLY_CONNECTED, true); // Commit the edits! editor.commit(); // Close the activity finish(); } }
From source file:at.alladin.rmbt.controlServer.SettingsResource.java
/** * //from w ww.j ava 2s . co m * @param entity * @return */ @Post("json") public String request(final String entity) { long startTime = System.currentTimeMillis(); addAllowOrigin(); JSONObject request = null; final ErrorList errorList = new ErrorList(); final JSONObject answer = new JSONObject(); String answerString; final String clientIpRaw = getIP(); System.out.println(MessageFormat.format(labels.getString("NEW_SETTINGS_REQUEST"), clientIpRaw)); if (entity != null && !entity.isEmpty()) // try parse the string to a JSON object try { request = new JSONObject(entity); String lang = request.optString("language"); // Load Language Files for Client final List<String> langs = Arrays .asList(settings.getString("RMBT_SUPPORTED_LANGUAGES").split(",\\s*")); if (langs.contains(lang)) { errorList.setLanguage(lang); labels = ResourceManager.getSysMsgBundle(new Locale(lang)); } else lang = settings.getString("RMBT_DEFAULT_LANGUAGE"); // System.out.println(request.toString(4)); if (conn != null) { final Client client = new Client(conn); int typeId = 0; if (request.optString("type").length() > 0) { typeId = client.getTypeId(request.getString("type")); if (client.hasError()) errorList.addError(client.getError()); } final List<String> clientNames = Arrays .asList(settings.getString("RMBT_CLIENT_NAME").split(",\\s*")); final JSONArray settingsList = new JSONArray(); final JSONObject jsonItem = new JSONObject(); if (clientNames.contains(request.optString("name")) && typeId > 0) { // String clientName = request.getString("name"); // String clientVersionCode = // request.getString("version_name"); // String clientVersionName = // request.optString("version_code", ""); UUID uuid = null; long clientUid = 0; final String uuidString = request.optString("uuid", ""); try { if (!Strings.isNullOrEmpty(uuidString)) uuid = UUID.fromString(uuidString); } catch (IllegalArgumentException e) // not a valid uuid { } if (uuid != null && errorList.getLength() == 0) { clientUid = client.getClientByUuid(uuid); if (client.hasError()) errorList.addError(client.getError()); } boolean tcAccepted = request.optInt("terms_and_conditions_accepted_version", 0) > 0; // accept any version for now if (!tcAccepted) // allow old non-version parameter tcAccepted = request.optBoolean("terms_and_conditions_accepted", false); { if (tcAccepted && (uuid == null || clientUid == 0)) { final Timestamp tstamp = java.sql.Timestamp .valueOf(new Timestamp(System.currentTimeMillis()).toString()); final Calendar timeWithZone = Helperfunctions .getTimeWithTimeZone(Helperfunctions.getTimezoneId()); client.setTimeZone(timeWithZone); client.setTime(tstamp); client.setClient_type_id(typeId); client.setTcAccepted(tcAccepted); uuid = client.storeClient(); if (client.hasError()) errorList.addError(client.getError()); else jsonItem.put("uuid", uuid.toString()); } if (client.getUid() > 0) { /* map server */ final Series<Parameter> ctxParams = getContext().getParameters(); final String host = ctxParams.getFirstValue("RMBT_MAP_HOST"); final String sslStr = ctxParams.getFirstValue("RMBT_MAP_SSL"); final String portStr = ctxParams.getFirstValue("RMBT_MAP_PORT"); if (host != null && sslStr != null && portStr != null) { JSONObject mapServer = new JSONObject(); mapServer.put("host", host); mapServer.put("port", Integer.parseInt(portStr)); mapServer.put("ssl", Boolean.parseBoolean(sslStr)); jsonItem.put("map_server", mapServer); } // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // HISTORY / FILTER final JSONObject subItem = new JSONObject(); final JSONArray netList = new JSONArray(); try { // deviceList: subItem.put("devices", getSyncGroupDeviceList(errorList, client)); // network_type: final PreparedStatement st = conn.prepareStatement("SELECT DISTINCT group_name" + " FROM test t" + " JOIN network_type nt ON t.network_type=nt.uid" + " WHERE t.deleted = false AND t.status = 'FINISHED' " + " AND (t.client_id IN (SELECT ? UNION SELECT uid FROM client WHERE sync_group_id = ? ))" + " AND group_name IS NOT NULL ORDER BY group_name;"); st.setLong(1, client.getUid()); st.setInt(2, client.getSync_group_id()); final ResultSet rs = st.executeQuery(); if (rs != null) while (rs.next()) // netList.put(Helperfunctions.getNetworkTypeName(rs.getInt("network_type"))); netList.put(rs.getString("group_name")); else errorList.addError("ERROR_DB_GET_SETTING_HISTORY_NETWORKS_SQL"); rs.close(); st.close(); subItem.put("networks", netList); } catch (final SQLException e) { e.printStackTrace(); errorList.addError("ERROR_DB_GET_SETTING_HISTORY_SQL"); // errorList.addError("ERROR_DB_GET_CLIENT_SQL"); } if (errorList.getLength() == 0) jsonItem.put("history", subItem); } else errorList.addError("ERROR_CLIENT_UUID"); } //also put there: basis-urls for all services final JSONObject jsonItemURLs = new JSONObject(); jsonItemURLs.put("open_data_prefix", getSetting("url_open_data_prefix", lang)); jsonItemURLs.put("statistics", getSetting("url_statistics", lang)); jsonItemURLs.put("control_ipv4_only", getSetting("control_ipv4_only", lang)); jsonItemURLs.put("control_ipv6_only", getSetting("control_ipv6_only", lang)); jsonItemURLs.put("url_ipv4_check", getSetting("url_ipv4_check", lang)); jsonItemURLs.put("url_ipv6_check", getSetting("url_ipv6_check", lang)); jsonItem.put("urls", jsonItemURLs); final JSONObject jsonControlServerVersion = new JSONObject(); jsonControlServerVersion.put("control_server_version", RevisionHelper.getVerboseRevision()); jsonItem.put("versions", jsonControlServerVersion); try { final Locale locale = new Locale(lang); final QoSTestTypeDescDao testTypeDao = new QoSTestTypeDescDao(conn, locale); final JSONArray testTypeDescArray = new JSONArray(); for (QoSTestTypeDesc desc : testTypeDao.getAll()) { JSONObject json = new JSONObject(); json.put("test_type", desc.getTestType().name()); json.put("name", desc.getName()); testTypeDescArray.put(json); } jsonItem.put("qostesttype_desc", testTypeDescArray); } catch (SQLException e) { errorList.addError("ERROR_DB_CONNECTION"); } settingsList.put(jsonItem); answer.put("settings", settingsList); //debug: print settings response (JSON) //System.out.println(settingsList); } else errorList.addError("ERROR_CLIENT_VERSION"); } else errorList.addError("ERROR_DB_CONNECTION"); } catch (final JSONException e) { errorList.addError("ERROR_REQUEST_JSON"); System.out.println("Error parsing JSDON Data " + e.toString()); } else errorList.addErrorString("Expected request is missing."); try { answer.putOpt("error", errorList.getList()); } catch (final JSONException e) { System.out.println("Error saving ErrorList: " + e.toString()); } answerString = answer.toString(); // try // { // System.out.println(answer.toString(4)); // } // catch (final JSONException e) // { // e.printStackTrace(); // } answerString = answer.toString(); long elapsedTime = System.currentTimeMillis() - startTime; System.out.println(MessageFormat.format(labels.getString("NEW_SETTINGS_REQUEST_SUCCESS"), clientIpRaw, Long.toString(elapsedTime))); return answerString; }