/** * 功能描述:generate curl for API * * @return * @author <a href="mailto:[email protected]">李伟光 </a> created on: 2016-1-11 */ public String generateCURL() { long curUserId = getCurUserId(); if (curUserId <= 0) { setIsOk(false); setErrMsg(LOGIN_WARN_MSG); return JSON_ERROR; } boolean isOk = false; // System.out.println("ActionId():" + this.actionId); validationMgr.saveCURL(this.actionId, validationMgr.generateCURL(this.actionId)); isOk = true; if (isOk) { setJson("{\"isOk\":true}"); } return SUCCESS; }
/** * 功能描述:保存修改好的cURL内容 * * @return * @author <a href="mailto:[email protected]">李伟光 </a> created on: 2016-1-11 */ public String getCURL() { long curUserId = getCurUserId(); if (curUserId <= 0) { setIsOk(false); setErrMsg(LOGIN_WARN_MSG); return JSON_ERROR; } boolean isOk = false; // 先生成最新的CURL validationMgr.saveCURL(this.actionId, validationMgr.generateCURL(this.actionId)); String cURL = validationMgr.getCURLByActionId(actionId); isOk = true; if (isOk) { setJson("{\"isOk\":true,\"cURL\":\"" + string2Json(cURL) + "\"}"); } return SUCCESS; }
/** * 功能描述:校验改动过的jsonschema * * @return * @author <a href="mailto:[email protected]">李伟光 </a> created on: 2015-9-2 * @throws IOException * @throws ProcessingException */ public String validateJsonSchema() throws ProcessingException, IOException { boolean isOk = false; // System.out.println("newJsonSchema:" + newJsonSchema); String result = validationMgr.validateJsonSchema(newJsonSchema); if ("".equals(result)) { result = "JsonSchema内容格式没有错误,可放心保存."; } isOk = true; // System.out.println("result:" + result.replaceAll("\"", "'")); if (isOk) { setJson("{\"isOk\":true,\"result\":\"" + result.replaceAll("\"", "'") + "\"}"); } return SUCCESS; }
/** * 功能描述:保存用户提交的PB协议的文本内容(用户导入pb的时候) * * @return * @author <a href="mailto:[email protected]">李伟光 </a> created on: 2015-10-20 */ public String savePB() { long curUserId = getCurUserId(); if (curUserId <= 0) { setIsOk(false); setErrMsg(LOGIN_WARN_MSG); return JSON_ERROR; } boolean isOk = false; validationMgr.savePB(actionId, pbtxt, reflag); isOk = true; if (isOk) { setJson("{\"isOk\":true}"); } return SUCCESS; }
/** * 功能描述:获取jsonschema内容 * * @return * @author <a href="mailto:[email protected]">李伟光 </a> created on: 2015-9-1 */ public String getJsonSchema() { // System.out.println("getJsonSchema()this.actionId:" + actionId); long curUserId = getCurUserId(); if (curUserId <= 0) { setIsOk(false); setErrMsg(LOGIN_WARN_MSG); return JSON_ERROR; } boolean isOk = false; String jsonSchema = validationMgr.getJsonSchemaByActionId(actionId); isOk = true; if (isOk) { setJson("{\"isOk\":true,\"jsonSchema\":" + jsonSchema + "}"); } return SUCCESS; }
/** * 功能描述:保存修改好的jsonschema内容 * * @return * @author <a href="mailto:[email protected]">李伟光 </a> created on: 2015-9-1 */ public String saveJsonSchema() { long curUserId = getCurUserId(); if (curUserId <= 0) { setIsOk(false); setErrMsg(LOGIN_WARN_MSG); return JSON_ERROR; } boolean isOk = false; // System.out.println("actionId:" + actionId); // System.out.println("newJsonSchema:" + newJsonSchema); validationMgr.saveJsonSchema(actionId, newJsonSchema); isOk = true; if (isOk) { setJson("{\"isOk\":true}"); } return SUCCESS; }
// 查看PB协议的内容 public String getPB() { boolean isOk = false; Map<String, String> result = validationMgr.getPB(actionId); String pbrequest = result.get("pbrequest"); String pbresponse = result.get("pbresponse"); if (pbrequest == null) pbrequest = ""; if (pbresponse == null) pbresponse = ""; isOk = true; // System.out.println("result:" + result.replaceAll("\"", "'")); // System.out.println("result:" + result); if (isOk) { setJson( "{\"isOk\":true,\"pbrequest\":\"" + pbrequest.replaceAll("\\n", "\\\\n") + "\"," + "\"pbresponse\":\"" + pbresponse.replaceAll("\\n", "\\\\n") + "\"}"); } return SUCCESS; }