protected void performFromName(HttpServletRequest request, HttpServletResponse response) throws Exception { String[] names = request.getParameterValues("name"); if( null == names || names.length < 1 ) { throw new Exception("Parameter 'name' not provided"); } if( names.length > 1 ) { throw new Exception("Parameter 'name' provided multiple times"); } if (null != contributions) { JSONObject result = contributions.fromName(names[0], userRepository); sendJsonResponse(response, result); } else { throw new Exception("Contribution record access requests can not be fulfill because of failed initialization - look for earlier exceptions."); } }
protected void performDelete(HttpServletRequest request, HttpServletResponse response) throws Exception { String[] ids = request.getParameterValues("id"); String[] placeIds = request.getParameterValues("placeId"); if( null == ids || ids.length < 1 ) { throw new Exception("Parameter 'id' not provided"); } if( ids.length > 1 ) { throw new Exception("Parameter 'id' provided multiple times"); } if( null == placeIds ) { placeIds = new String[0]; } if( placeIds.length > 1 ) { throw new Exception("Parameter 'place_id' provided multiple times"); } contributions.deleteContribution(ids[0], (placeIds.length > 0 ? placeIds[0] : null)); JSONObject result = new JSONObject(); result.put("id", ids[0]); if( placeIds.length > 0 ) { result.put("place_id", placeIds[0]); } sendJsonResponse(response, result); }