Source:
private void doHandleConfigureMucRequest( String target, HttpServletRequest request, HttpServletResponse response) throws IOException { if (!POST_HTTP_METHOD.equals(request.getMethod())) { response.setStatus(HttpServletResponse.SC_METHOD_NOT_ALLOWED); return; } if (!RESTUtil.isJSONContentType(request.getContentType())) { response.setStatus(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE); return; } JSONObject requestJSONObject; try { Object o = new JSONParser().parse(request.getReader()); if (o instanceof JSONObject) { requestJSONObject = (JSONObject) o; } else { requestJSONObject = null; } } catch (Exception e) { requestJSONObject = null; } if (requestJSONObject == null) { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); return; } if (!JigasiBundleActivator.getConfigurationService() .getBoolean( CallControlMucActivator.BREWERY_ENABLED_PROP, false)) { response.setStatus(HttpServletResponse.SC_SERVICE_UNAVAILABLE); return; } if ("add".equals(target)) { if (requestJSONObject == null || !(requestJSONObject.get("id") instanceof String)) { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); return; } String id = (String) requestJSONObject.get("id"); try { CallControlMucActivator.addCallControlMucAccount( id, requestJSONObject.entrySet()); } catch(OperationFailedException e) { logger.error("Failed to add account:" + id, e); response.setStatus( HttpServletResponse.SC_INTERNAL_SERVER_ERROR); return; } response.setStatus(HttpServletResponse.SC_OK); } else if ("remove".equals(target)) { if (requestJSONObject == null || !(requestJSONObject.get("id") instanceof String)) { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); return; } CallControlMucActivator.removeCallControlMucAccount( (String) requestJSONObject.get("id")); response.setStatus(HttpServletResponse.SC_OK); } else { response.setStatus(HttpServletResponse.SC_NOT_FOUND); return; } }

Target:
private void doHandleConfigureMucRequest( String target, HttpServletRequest request, HttpServletResponse response) throws IOException { if (!POST_HTTP_METHOD.equals(request.getMethod())) { response.setStatus(HttpServletResponse.SC_METHOD_NOT_ALLOWED); return; } if (!RESTUtil.isJSONContentType(request.getContentType())) { response.setStatus(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE); return; } JSONObject requestJSONObject; try { Object o = new JSONParser().parse(request.getReader()); if (o instanceof JSONObject) { requestJSONObject = (JSONObject) o; } else { requestJSONObject = null; } } catch (Exception e) { requestJSONObject = null; } if (requestJSONObject == null || !(requestJSONObject.get("id") instanceof String)) { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); return; } String id = (String) requestJSONObject.get("id"); if (!JigasiBundleActivator.getConfigurationService() .getBoolean( CallControlMucActivator.BREWERY_ENABLED_PROP, false)) { response.setStatus(HttpServletResponse.SC_SERVICE_UNAVAILABLE); return; } if ("add".equals(target)) { try { CallControlMucActivator.addCallControlMucAccount( id, requestJSONObject); } catch(OperationFailedException e) { logger.error("Failed to add account:" + id, e); response.setStatus( HttpServletResponse.SC_INTERNAL_SERVER_ERROR); return; } response.setStatus(HttpServletResponse.SC_OK); } else if ("remove".equals(target)) { if (CallControlMucActivator.removeCallControlMucAccount(id)) { response.setStatus(HttpServletResponse.SC_OK); } else { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); } } else { response.setStatus(HttpServletResponse.SC_NOT_FOUND); return; } }