List of usage examples for java.lang NumberFormatException getMessage
public String getMessage()
From source file:controllers.api.v1.AdvSearch.java
public static Result search() { ObjectNode result = Json.newObject(); String searchOptStr = request().getQueryString("searchOpts"); JsonNode searchOpt = Json.parse(searchOptStr); int page = 1; int size = 10; String pageStr = request().getQueryString("page"); if (StringUtils.isBlank(pageStr)) { page = 1;// w w w .j av a 2s . c om } else { try { page = Integer.parseInt(pageStr); } catch (NumberFormatException e) { Logger.error("AdvSearch Controller search wrong page parameter. Error message: " + e.getMessage()); page = 1; } } String sizeStr = request().getQueryString("size"); if (StringUtils.isBlank(sizeStr)) { size = 10; } else { try { size = Integer.parseInt(sizeStr); } catch (NumberFormatException e) { Logger.error("AdvSearch Controller search wrong page parameter. Error message: " + e.getMessage()); size = 10; } } result.put("status", "ok"); String searchEngine = Play.application().configuration().getString(SearchDAO.WHEREHOWS_SEARCH_ENGINE__KEY); if (searchOpt != null && searchOpt.has("category")) { String category = searchOpt.get("category").asText(); if (category.equalsIgnoreCase("flow")) { if (StringUtils.isNotBlank(searchEngine) && searchEngine.equalsIgnoreCase("elasticsearch")) { result.set("result", Json.toJson(AdvSearchDAO.elasticSearchFlowJobs(searchOpt, page, size))); } else { result.set("result", Json.toJson(AdvSearchDAO.searchFlows(searchOpt, page, size))); } return ok(result); } else if (category.equalsIgnoreCase("metric")) { if (StringUtils.isNotBlank(searchEngine) && searchEngine.equalsIgnoreCase("elasticsearch")) { result.set("result", Json.toJson(AdvSearchDAO.elasticSearchMetric(searchOpt, page, size))); } else { result.set("result", Json.toJson(AdvSearchDAO.searchMetrics(searchOpt, page, size))); } return ok(result); } } if (StringUtils.isNotBlank(searchEngine) && searchEngine.equalsIgnoreCase("elasticsearch")) { result.set("result", Json.toJson(AdvSearchDAO.elasticSearch(searchOpt, page, size))); } else { result.set("result", Json.toJson(AdvSearchDAO.search(searchOpt, page, size))); } return ok(result); }
From source file:controllers.api.v1.Search.java
public static Result searchByKeyword() { ObjectNode result = Json.newObject(); int page = 1; int size = 10; String keyword = request().getQueryString("keyword"); String category = request().getQueryString("category"); String source = request().getQueryString("source"); String pageStr = request().getQueryString("page"); if (StringUtils.isBlank(pageStr)) { page = 1;/*from ww w .ja v a 2 s .c om*/ } else { try { page = Integer.parseInt(pageStr); } catch (NumberFormatException e) { Logger.error("Dataset Controller searchByKeyword wrong page parameter. Error message: " + e.getMessage()); page = 1; } } String sizeStr = request().getQueryString("size"); if (StringUtils.isBlank(sizeStr)) { size = 10; } else { try { size = Integer.parseInt(sizeStr); } catch (NumberFormatException e) { Logger.error("Dataset Controller searchByKeyword wrong page parameter. Error message: " + e.getMessage()); size = 10; } } result.put("status", "ok"); Boolean isDefault = false; if (StringUtils.isBlank(category)) { category = "datasets"; } if (StringUtils.isBlank(source) || source.equalsIgnoreCase("all") || source.equalsIgnoreCase("default")) { source = null; } String searchEngine = Play.application().configuration().getString(SearchDAO.WHEREHOWS_SEARCH_ENGINE__KEY); if (category.toLowerCase().equalsIgnoreCase("metric")) { if (StringUtils.isNotBlank(searchEngine) && searchEngine.equalsIgnoreCase("elasticsearch")) { result.set("result", SearchDAO.elasticSearchMetricByKeyword(category, keyword, page, size)); } else { result.set("result", SearchDAO.getPagedMetricByKeyword(category, keyword, page, size)); } } else if (category.toLowerCase().equalsIgnoreCase("flows")) { if (StringUtils.isNotBlank(searchEngine) && searchEngine.equalsIgnoreCase("elasticsearch")) { result.set("result", SearchDAO.elasticSearchFlowByKeyword(category, keyword, page, size)); } else { result.set("result", SearchDAO.getPagedFlowByKeyword(category, keyword, page, size)); } } else if (category.toLowerCase().equalsIgnoreCase("jobs")) { if (StringUtils.isNotBlank(searchEngine) && searchEngine.equalsIgnoreCase("elasticsearch")) { result.set("result", SearchDAO.elasticSearchFlowByKeyword(category, keyword, page, size)); } else { result.set("result", SearchDAO.getPagedJobByKeyword(category, keyword, page, size)); } } else if (category.toLowerCase().equalsIgnoreCase("comments")) { if (StringUtils.isNotBlank(searchEngine) && searchEngine.equalsIgnoreCase("elasticsearch")) { result.set("result", SearchDAO.elasticSearchDatasetByKeyword(category, keyword, null, page, size)); } else { result.set("result", SearchDAO.getPagedCommentsByKeyword(category, keyword, page, size)); } } else { if (StringUtils.isNotBlank(searchEngine) && searchEngine.equalsIgnoreCase("elasticsearch")) { result.set("result", SearchDAO.elasticSearchDatasetByKeyword(category, keyword, source, page, size)); } else { result.set("result", SearchDAO.getPagedDatasetByKeyword(category, keyword, source, page, size)); } } return ok(result); }
From source file:controllers.api.v1.Flow.java
public static Result getPagedProjects(String application) { ObjectNode result = Json.newObject(); int page = 1; String pageStr = request().getQueryString("page"); if (StringUtils.isBlank(pageStr)) { page = 1;/*from ww w .j av a 2 s . c o m*/ } else { try { page = Integer.parseInt(pageStr); } catch (NumberFormatException e) { Logger.error( "Flow Controller getPagedDatasets wrong page parameter. Error message: " + e.getMessage()); page = 1; } } int size = 10; String sizeStr = request().getQueryString("size"); if (StringUtils.isBlank(sizeStr)) { size = 10; } else { try { size = Integer.parseInt(sizeStr); } catch (NumberFormatException e) { Logger.error( "Flow Controller getPagedDatasets wrong size parameter. Error message: " + e.getMessage()); size = 10; } } result.put("status", "ok"); result.set("data", FlowsDAO.getPagedProjectsByApplication(application, page, size)); return ok(result); }
From source file:controllers.api.v1.Flow.java
public static Result getPagedFlows(String application, String project) { ObjectNode result = Json.newObject(); int page = 1; String pageStr = request().getQueryString("page"); if (StringUtils.isBlank(pageStr)) { page = 1;//from w ww . j a va 2s . co m } else { try { page = Integer.parseInt(pageStr); } catch (NumberFormatException e) { Logger.error( "Flow Controller getPagedDatasets wrong page parameter. Error message: " + e.getMessage()); page = 1; } } int size = 10; String sizeStr = request().getQueryString("size"); if (StringUtils.isBlank(sizeStr)) { size = 10; } else { try { size = Integer.parseInt(sizeStr); } catch (NumberFormatException e) { Logger.error( "Flow Controller getPagedDatasets wrong size parameter. Error message: " + e.getMessage()); size = 10; } } result.put("status", "ok"); result.set("data", FlowsDAO.getPagedFlowsByProject(application, project, page, size)); return ok(result); }
From source file:controllers.api.v1.Flow.java
public static Result getPagedJobs(String application, Long flowId) { ObjectNode result = Json.newObject(); int page = 1; String pageStr = request().getQueryString("page"); if (StringUtils.isBlank(pageStr)) { page = 1;//from ww w .j a v a 2 s . co m } else { try { page = Integer.parseInt(pageStr); } catch (NumberFormatException e) { Logger.error( "Flow Controller getPagedDatasets wrong page parameter. Error message: " + e.getMessage()); page = 1; } } int size = 10; String sizeStr = request().getQueryString("size"); if (StringUtils.isBlank(sizeStr)) { size = 10; } else { try { size = Integer.parseInt(sizeStr); } catch (NumberFormatException e) { Logger.error( "Flow Controller getPagedDatasets wrong size parameter. Error message: " + e.getMessage()); size = 10; } } result.put("status", "ok"); result.set("data", FlowsDAO.getPagedJobsByFlow(application, flowId, page, size)); return ok(result); }
From source file:controllers.api.v1.Flow.java
public static Result getPagedRootProjects() { ObjectNode result = Json.newObject(); int page = 1; String pageStr = request().getQueryString("page"); if (StringUtils.isBlank(pageStr)) { page = 1;//from w ww .j av a2 s .co m } else { try { page = Integer.parseInt(pageStr); } catch (NumberFormatException e) { Logger.error("Flow Controller getPagedRootProjects wrong page parameter. Error message: " + e.getMessage()); page = 1; } } int size = 10; String sizeStr = request().getQueryString("size"); if (StringUtils.isBlank(sizeStr)) { size = 10; } else { try { size = Integer.parseInt(sizeStr); } catch (NumberFormatException e) { Logger.error("Flow Controller getPagedRootProjects wrong size parameter. Error message: " + e.getMessage()); size = 10; } } result.put("status", "ok"); result.set("data", FlowsDAO.getPagedProjects(page, size)); return ok(result); }
From source file:com.madrobot.di.Converter.java
public static Object convertTo(final JSONObject jsonObject, final String fieldName, final Class<?> clz, final Field field) { Object value = null;/*w w w. j a v a 2 s .c o m*/ if (clzTypeKeyMap.containsKey(clz)) { try { final int code = clzTypeKeyMap.get(clz); switch (code) { case TYPE_STRING: value = jsonObject.optString(fieldName); break; case TYPE_SHORT: value = Short.parseShort(jsonObject.optString(fieldName, "0")); break; case TYPE_INT: value = jsonObject.optInt(fieldName); break; case TYPE_LONG: value = jsonObject.optLong(fieldName); break; case TYPE_CHAR: String chatValue = jsonObject.optString(fieldName); if (chatValue.length() > 0) { value = chatValue.charAt(0); } else { value = '\0'; } break; case TYPE_FLOAT: value = Float.parseFloat(jsonObject.optString(fieldName, "0.0f")); break; case TYPE_DOUBLE: value = jsonObject.optDouble(fieldName); break; case TYPE_BOOLEAN: value = jsonObject.optString(fieldName); if (field.isAnnotationPresent(BooleanFormat.class)) { BooleanFormat formatAnnotation = field.getAnnotation(BooleanFormat.class); String trueFormat = formatAnnotation.trueFormat(); String falseFormat = formatAnnotation.falseFormat(); if (trueFormat.equals(value)) { value = true; } else if (falseFormat.equals(value)) { value = false; } else { Log.e(JSONDeserializer.TAG, "Expecting " + trueFormat + " / " + falseFormat + " but its " + value); } } else { value = Boolean.parseBoolean((String) value); } break; case TYPE_DATE: value = DateFormat.getDateInstance().parse(jsonObject.optString(fieldName)); break; } } catch (NumberFormatException e) { Log.e(JSONDeserializer.TAG, e.getMessage()); } catch (ParseException e) { Log.e(JSONDeserializer.TAG, e.getMessage()); } } return value; }
From source file:controllers.api.v1.Lineage.java
public static Result getDatasetLineageGraphData(int id) { ObjectNode result = Json.newObject(); String username = session("user"); if (id < 1) { result.put("status", "error"); result.put("message", "wrong dataset id"); return ok(result); }//from w ww . ja va2s. c o m models.Dataset dataset = DatasetsDAO.getDatasetByID(id, username); if (dataset == null || StringUtils.isBlank(dataset.urn)) { result.put("status", "error"); result.put("message", "wrong dataset id"); return ok(result); } int upLevel = 1; String upLevelStr = request().getQueryString("upLevel"); if (StringUtils.isBlank(upLevelStr)) { upLevel = 1; } else { try { upLevel = Integer.parseInt(upLevelStr); } catch (NumberFormatException e) { Logger.error( "Lineage Controller getDatasetLineageGraphData wrong upLevel parameter. Error message: " + e.getMessage()); upLevel = 1; } } if (upLevel < 1) upLevel = 1; int downLevel = 1; String downLevelStr = request().getQueryString("downLevel"); if (StringUtils.isBlank(downLevelStr)) { downLevel = 1; } else { try { downLevel = Integer.parseInt(downLevelStr); } catch (NumberFormatException e) { Logger.error( "Lineage Controller getDatasetLineageGraphData wrong downLevel parameter. Error message: " + e.getMessage()); downLevel = 1; } } if (downLevel < 1) downLevel = 1; int lookBackTimeDefault = Integer .valueOf(Play.application().configuration().getString(LINEAGE_LOOK_BACK_TIME_KEY, "30")); int lookBackTime = lookBackTimeDefault; String lookBackTimeStr = request().getQueryString("period"); if (!StringUtils.isBlank(lookBackTimeStr)) { try { lookBackTime = Integer.parseInt(lookBackTimeStr); } catch (NumberFormatException e) { Logger.error("Lineage Controller getDatasetLineageGraphData wrong period parameter. Error message: " + e.getMessage()); lookBackTime = lookBackTimeDefault; } } result.put("status", "ok"); result.set("data", Json.toJson(LineageDAO.getObjectAdjacnet(dataset.urn, upLevel, downLevel, lookBackTime))); System.out .println(Json.toJson(LineageDAO.getObjectAdjacnet(dataset.urn, upLevel, downLevel, lookBackTime))); System.out.println(ok(result)); return ok(result); }
From source file:controllers.api.v1.Metric.java
public static Result getPagedMetrics() { ObjectNode result = Json.newObject(); String username = session("user"); int page = 1; String pageStr = request().getQueryString("page"); if (StringUtils.isBlank(pageStr)) { page = 1;/*from www . jav a2s.c o m*/ } else { try { page = Integer.parseInt(pageStr); } catch (NumberFormatException e) { Logger.warn( "Metric Controller getPagedMetrics wrong page parameter. Error message: " + e.getMessage()); page = 1; } } int size = 10; String sizeStr = request().getQueryString("size"); if (StringUtils.isBlank(sizeStr)) { size = 10; } else { try { size = Integer.parseInt(sizeStr); } catch (NumberFormatException e) { Logger.warn( "Metric Controller getPagedMetrics wrong size parameter. Error message: " + e.getMessage()); size = 10; } } result.put("status", "ok"); result.set("data", MetricsDAO.getPagedMetrics("", "", page, size, username)); return ok(result); }
From source file:com.aurel.track.GeneralSettings.java
/** * Gets the maximal number of items loaded from the database for performance reasons * @return/* w w w . java 2 s .c o m*/ */ public static int getMaxItems() { int maxItems = 10000; if (configMap != null) { String maxItemsStr = configMap.getString(GENERAL_CONFIG.MAX_ITEMS); if (maxItemsStr != null) { try { maxItems = Integer.valueOf(maxItemsStr); } catch (NumberFormatException e) { LOGGER.warn("Getting " + GENERAL_CONFIG.MAX_ITEMS + " as int from " + maxItemsStr + " failed with " + e.getMessage()); } } } return maxItems; }