Source:
<code>public void handleAction(ActionParameters params) throws ActionException { params.requireLoggedInUser(); int datasourceId = params.getRequiredParamInt(StatisticsHelper.PARAM_DATASOURCE_ID); StatisticalDatasourcePlugin datasource = StatisticalDatasourcePluginManager.getInstance().getPlugin(datasourceId); if(datasource == null) { throw new ActionParamsException("Invalid datasource:" + datasourceId); } if(!datasource.canModify(params.getUser())) { throw new ActionDeniedException("User doesn't have permission to modify datasource:" + datasourceId); } <START> String id = params.getRequiredParam(ActionConstants.PARAM_ID); <END> StatisticalIndicator indicator = datasource.getIndicator(params.getUser(), id); if(indicator == null) { throw new ActionParamsException("Requested invalid indicator:" + id); } JSONObject selectors = params.getHttpParamAsJSON(StatisticsHelper.PARAM_SELECTORS); StatisticalIndicatorDataModel model = StatisticsHelper.getIndicatorDataModel(selectors); int regionsetId = params.getRequiredParamInt(StatisticsHelper.PARAM_REGIONSET); DatasourceLayer layer = datasource.getSource().getLayers().stream() .filter(x -> x.getMaplayerId() == regionsetId) .findFirst() .orElseThrow(() -> new ActionParamsException("Invalid regionset: " + regionsetId)); if(indicator.getLayer(layer.getMaplayerId()) == null) { indicator.addLayer(layer); } try { indicator.setDataModel(model); Map<String, IndicatorValue> data = parseIndicatorData(params.getHttpParam(PARAM_DATA)); if (data != null) { datasource.saveIndicatorData(indicator, regionsetId, data, params.getUser()); } } catch (Exception ex) { throw new ActionException("Couldn't save data", ex); } if (datasource.canCache()) { StatisticsHelper.flushDataFromCache(datasourceId, id, regionsetId, selectors); } JSONObject jobj = new JSONObject(); JSONHelper.putValue(jobj, "id", id); ResponseHelper.writeResponse(params,jobj); }</code><technical_language>parameters required if checked for presence correctness right beginning of function instead. waste processing power requests bound fail</technical_language>

Target:
public void handleAction(ActionParameters params) throws ActionException { params.requireLoggedInUser(); final int datasourceId = params.getRequiredParamInt(StatisticsHelper.PARAM_DATASOURCE_ID); final String indicatorId = params.getRequiredParam(ActionConstants.PARAM_ID); final int regionsetId = params.getRequiredParamInt(StatisticsHelper.PARAM_REGIONSET); final String dataJSON = params.getRequiredParam(PARAM_DATA); StatisticalDatasourcePlugin datasource = StatisticalDatasourcePluginManager.getInstance().getPlugin(datasourceId); if(datasource == null) { throw new ActionParamsException("Invalid datasource:" + datasourceId); } if(!datasource.canModify(params.getUser())) { throw new ActionDeniedException("User doesn't have permission to modify datasource:" + datasourceId); } StatisticalIndicator indicator = datasource.getIndicator(params.getUser(), indicatorId); if(indicator == null) { throw new ActionParamsException("Requested invalid indicator:" + indicatorId); } JSONObject selectors = params.getHttpParamAsJSON(StatisticsHelper.PARAM_SELECTORS); StatisticalIndicatorDataModel model = StatisticsHelper.getIndicatorDataModel(selectors); indicator.setDataModel(model); DatasourceLayer layer = datasource.getSource().getLayers().stream() .filter(x -> x.getMaplayerId() == regionsetId) .findFirst() .orElseThrow(() -> new ActionParamsException("Invalid regionset: " + regionsetId)); if(indicator.getLayer(layer.getMaplayerId()) == null) { indicator.addLayer(layer); } Map<String, IndicatorValue> data = parseIndicatorData(dataJSON); try { datasource.saveIndicatorData(indicator, regionsetId, data, params.getUser()); } catch (Exception ex) { throw new ActionException("Couldn't save data", ex); } if (datasource.canCache()) { StatisticsHelper.flushDataFromCache(datasourceId, indicatorId, regionsetId, selectors); } JSONObject jobj = new JSONObject(); JSONHelper.putValue(jobj, "id", indicatorId); ResponseHelper.writeResponse(params,jobj); }