/** {@inheritDoc} */ @Override protected void submit(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException, Descriptor.FormException { super.submit(req, rsp); synchronized (this) { JSONObject json = req.getSubmittedForm(); /* Set<String> oldSourceIds = new HashSet<String>(); for (SCMSource source : getSCMSources()) { oldSourceIds.add(source.getId()); } */ sources.replaceBy(req.bindJSONToList(BranchSource.class, json.opt("sources"))); for (SCMSource scmSource : getSCMSources()) { scmSource.setOwner(this); } setProjectFactory( req.bindJSON(BranchProjectFactory.class, json.getJSONObject("projectFactory"))); save(); /* TODO currently ComputedFolder.save always reschedules indexing; could define API to be more discerning Set<String> newSourceIds = new HashSet<String>(); for (SCMSource source : getSCMSources()) { newSourceIds.add(source.getId()); } reindex = !newSourceIds.equals(oldSourceIds); */ } }
public void startResponseReqBody() { ParameterParser parameter = getParameterParser(); String command = parameter.getParameter("command"); if (command != null) { doCommand(command, parameter); return; } JSONObject json = (JSONObject) parameter.getJsonObject(); if (json != null) { command = json.optString("command"); Object paramObj = json.opt("param"); doObjCommand(command, paramObj); return; } completeResponse("404"); }
public String getCodeByCategoryJson( MobileServerConfig mobileServerConfig, Document doc, String urlPara) { String json = ""; String paraJson = urlPara; JSONObject jsonObject = JSONObject.fromObject(paraJson); String category = ""; if (jsonObject.containsKey("category")) { category = jsonObject.opt("category").toString(); } JSONObject jsonObjectResult = new JSONObject(); try { if (category != null && !category.equals("")) { List<Code> list = getCodeCacheListByCategory(category); if (list != null && list.size() > 0) { JSONArray jsonArray = new JSONArray(); for (Code code : list) { JSONObject jsonObjectData = new JSONObject(); jsonObjectData.put("codeName", code.getCodeName()); jsonObjectData.put("description", code.getDescription()); jsonArray.add(jsonObjectData); } jsonObjectResult.put("result", "1"); jsonObjectResult.put("data", jsonArray); } } else { jsonObjectResult.put("result", "0"); jsonObjectResult.put("message", "缺少必要参数"); } } catch (Exception e) { // TODO: handle exception jsonObjectResult.put("result", "0"); jsonObjectResult.put("message", e.getMessage()); } json = jsonObjectResult.toString(); return json; }