public void setXPathMapping(String xpath, String type, JSONObject target, int index) { JSONArray mappings = target.getJSONArray("mappings"); JSONObject mapping = null; target.remove("warning"); if (index > -1) { mapping = mappings.getJSONObject(index); mapping.put("type", "xpath"); mapping.put("value", xpath); } else { mapping = new JSONObject(); mapping.put("type", "xpath"); mapping.put("value", xpath); mappings.add(mapping); } if (mapping != null) { if (target.has("type") && type != null && type.length() > 0) { if (target.getString("type").equalsIgnoreCase("dateUnion")) { if (!type.equalsIgnoreCase("date") && !type.equalsIgnoreCase("dateTime") && !type.equalsIgnoreCase("dateUnion")) { target.element("warning", type); } } else if (!target.getString("type").equalsIgnoreCase(type) || (mappings.size() > 1 && !type.equalsIgnoreCase("string"))) { target.element("warning", type); } } } // mappings.clear(); }
public void removeMappings(JSONObject target, int index) { JSONArray mappings = target.getJSONArray("mappings"); target.remove("warning"); if (index > -1) { mappings.remove(index); } }
public JSONObject removeCondition(String target) { JSONObject targetElement = this.elementCache.get(target); targetElement.remove("condition"); saveMappings(); return targetElement; }
public JSONObject setFixed(JSONObject object, boolean fixed) { if (fixed) { if (!object.has("fixed")) { object = object.element("fixed", ""); } } else { if (object.has("fixed")) { object.remove("fixed"); } } return object; }
@Override public void handle(HttpExchange arg0) throws IOException { try { JSONObject json = (JSONObject) JSONSerializer.toJSON(IOUtils.toString(arg0.getRequestBody())); String contents = json.getString("names"); byte[] fileContents = contents.getBytes("UTF-8"); ByteArrayOutputStream byteArray = new ByteArrayOutputStream(); GZIPOutputStream gzipStr = new GZIPOutputStream(byteArray); gzipStr.write(fileContents); gzipStr.close(); ByteArrayOutputStream byteArray2 = new ByteArrayOutputStream(); Base64OutputStream base64 = new Base64OutputStream(byteArray2); base64.write(byteArray.toByteArray()); base64.close(); String value = new String(byteArray2.toByteArray()); json.remove("names"); json.put("upload", value); HttpClient client = new HttpClient(); PostMethod post = new PostMethod( "http://" + properties.getProperty("org.iplantc.tnrs.servicesHost") + "/tnrs-svc/upload"); post.setRequestEntity(new StringRequestEntity(json.toString(), "text/plain", "UTF-8")); client.executeMethod(post); HandlerHelper.writeResponseRequest(arg0, 200, "", "text/plain"); } catch (Exception ex) { log.error(ExceptionUtils.getFullStackTrace(ex)); ex.printStackTrace(); throw new IOException(ex); } }
public JSONObject clearXPathFunction(String id, int index) { JSONObject target = this.elementCache.get(id); JSONArray mappings = target.getJSONArray("mappings"); JSONObject mapping = null; if (index > -1) { mapping = mappings.getJSONObject(index); mapping.remove("func"); } saveMappings(); return target; }
@RequestMapping() public void select(HttpServletRequest request, HttpServletResponse response) { try { response.setContentType("text/html;charset=UTF-8"); request.setCharacterEncoding("UTF-8"); super.initializePagingSortingFiltering(request); // Map<String, Object> params = new HashMap<String, Object>(); params.put("pagination.pageSize", getPageSize()); params.put("pagination.currentPage", getPageNo()); // JSONObject json = VLivesCaller.HTTP.USER_FEEDBACK_READ.invoke(null, params); // JSONArray ja = new JSONArray(); for (Object obj : json.getJSONArray("list").toArray()) { JSONObject jsObj = (JSONObject) obj; JSONObject jt = (JSONObject) jsObj.get("user"); String str = jsObj.getString("user"); if (jt == null || "null".equals(str)) { jsObj.remove("user"); JSONObject jn = new JSONObject(); jn.put("name", "匿名"); jn.put("mobile", ""); jsObj.put("user", jn); ja.add(jsObj); } else { str = jt.getString("name"); if (str == null || "null".equals(str)) { jt.put("name", "匿名"); } ja.add(jsObj); } } // if ("true".equals(json.getString("success"))) { String result = makeSuccessArrayString( json.getJSONObject("pagination").getString("count"), ja.toString()); response.getWriter().write(result); } else { responseMessage(response, json.getString("msg"), false); } } catch (RuntimeException e) { e.printStackTrace(); responseMessage(response, "系统错误<br />请检查配置后重试", false); } catch (Exception e) { e.printStackTrace(); responseMessage(response, "查询反馈信息列表失败", false); } }
private void removeConditionClauseKey(JSONObject condition, String path, String key) { if (path.length() == 0) { condition.remove(key); } else { if (condition.has("clauses")) { JSONArray clauses = condition.getJSONArray("clauses"); if (path.contains(".")) { String[] parts = path.split("\\.", 2); int index = Integer.parseInt(parts[0]); removeConditionClauseKey(clauses.getJSONObject(index), parts[1], key); } else { int index = Integer.parseInt(path); removeConditionClauseKey(clauses.getJSONObject(index), "", key); } } } }
protected void deleteSchema( HttpServletRequest request, HttpServletResponse response, HttpSession session) throws IOException, ServletException { String schema_id = (String) request.getParameter("schema_id"); VendorDBConnector vendorDBConnector = new VendorDBConnector(); JSONObject schemaDeleteInfo = vendorDBConnector.deleteSchema(schema_id); String message = schemaDeleteInfo.getString("message"); schemaDeleteInfo.remove("message"); this.forwardToPage( "/vendor/succDeleteSchema.jsp?message=" + message + "&operationsToDelete=" + schemaDeleteInfo, request, response); }
/** 缓存session 和登录用户信息绑定一起 */ public static void addUserToSession(JSONObject json) { synchronized ("") { MemcachedCli cli = MemcachedCli.getInstance(); Object memCachedJsonData = cli.get(CACHED_KEY_SESSION_ID + json.getString("sessionId")); JSONObject jsonData = JSONObject.fromObject(memCachedJsonData == null ? "{}" : memCachedJsonData); int size = jsonData.size(); if (size == 0) { jsonData.accumulate("site", json.getString("site")); } else { // 判断当前登录站点 if (jsonData.getString("site").indexOf(json.getString("site")) == -1) { String site = jsonData.getString("site") + "," + json.getString("site"); jsonData.remove("site"); jsonData.accumulate("site", site); } } jsonData.put("name", json.getString("name")); jsonData.put("passwd", json.getString("passwd")); jsonData.put("sessionId", json.getString("sessionId")); jsonData.put("lastTime", json.getString("lastTime")); cli.set( CACHED_KEY_SESSION_ID + json.getString("sessionId"), jsonData.toString(), new java.util.Date(System.currentTimeMillis() + 60 * 1000 * 120)); // ------------------------------------------------------------ Map<String, String> map = new HashMap<String, String>(); map.put("sessionId", json.getString("sessionId")); map.put("siteSessionId", json.getString("siteSessionId")); map.put("site", json.getString("site")); cli.set( CACHED_KEY_SESSION_SITE + json.getString("siteSessionId"), JSONObject.fromObject(map).toString(), new java.util.Date(System.currentTimeMillis() + 60 * 1000 * 120)); // ------------------------------------------------------------ } }