From dc39315ed323e0ace1a1e3b5d90e2207d2a54667 Mon Sep 17 00:00:00 2001 From: Bosn Ma Date: Thu, 29 May 2014 10:42:38 +0800 Subject: [PATCH] dev --- DEPLOY.md | 24 ++--- WebContent/stat/js/util/mock.plugin.js | 2 +- .../rap/mock/service/impl/MockMgrImpl.java | 8 +- .../rap/project/dao/impl/ProjectDaoImpl.java | 99 ++++++++----------- 4 files changed, 53 insertions(+), 80 deletions(-) diff --git a/DEPLOY.md b/DEPLOY.md index 8f952e5..897cecd 100644 --- a/DEPLOY.md +++ b/DEPLOY.md @@ -1,19 +1,7 @@ -### v0.8.2上线手册 +上线前检查 - -#### 增加心表tb_user_settings - -```bash -/** - * user settings table - */ -CREATE TABLE tb_user_settings -( - user_id int(10) NOT NULL, - `key` varchar(128) NOT NULL, - `value` varchar(128) NOT NULL, - - PRIMARY KEY(user_id, `key`), - FOREIGN KEY(user_id) REFERENCES tb_user(id) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; -``` \ No newline at end of file +0. 备份 +1. 检查RAP插件root +2. 检查数据库配置文件 +3. 检查UT是否全部通过 +4. 检查数据库脚本是否更新 \ No newline at end of file diff --git a/WebContent/stat/js/util/mock.plugin.js b/WebContent/stat/js/util/mock.plugin.js index d0691e7..a50d8ad 100644 --- a/WebContent/stat/js/util/mock.plugin.js +++ b/WebContent/stat/js/util/mock.plugin.js @@ -7,7 +7,7 @@ var ROOT = 'rap.alibaba-inc.com'; // [DEBUG] - ROOT = 'etaoux-bj.taobao.ali.com:8080'; + //ROOT = 'etaoux-bj.taobao.ali.com:8080'; var LOST = "LOST"; var PREFIX = "/mockjs/"; var EMPTY_ARRAY = "EMPTY_ARRAY"; diff --git a/src/com/taobao/rigel/rap/mock/service/impl/MockMgrImpl.java b/src/com/taobao/rigel/rap/mock/service/impl/MockMgrImpl.java index df3a9fc..203a6bb 100644 --- a/src/com/taobao/rigel/rap/mock/service/impl/MockMgrImpl.java +++ b/src/com/taobao/rigel/rap/mock/service/impl/MockMgrImpl.java @@ -404,11 +404,11 @@ private void buildMockTemplate(StringBuilder json, Parameter para, int index) { if (para.getParameterList() == null || para.getParameterList().size() == 0) { - json.append(para.getMockJSIdentifier() + ":" + json.append(processMockValueWithParams(para.getMockJSIdentifier()) + ":" + StringUtils.chineseToUnicode(mockjsValue(para, index))); } else { // object and array - json.append(para.getMockJSIdentifier() + ":"); + json.append(processMockValueWithParams(para.getMockJSIdentifier()) + ":"); String left = "{", right = "}"; if (isArrayObject) { @@ -627,7 +627,7 @@ private String mockjsValue(Parameter para, int index) { escape = false; } - mockValue = processMockValueWithParams(para, mockValue); + mockValue = processMockValueWithParams(mockValue); if (mockValue != null && !mockValue.isEmpty()) { if (mockValue.startsWith("[") && mockValue.endsWith("]")) { @@ -650,7 +650,7 @@ private String mockjsValue(Parameter para, int index) { return returnValue; } - private String processMockValueWithParams(Parameter para, String mockValue) { + private String processMockValueWithParams(String mockValue) { Pattern p = Pattern.compile(Patterns.MOCK_TEMPLATE_PATTERN); if (mockValue == null) diff --git a/src/com/taobao/rigel/rap/project/dao/impl/ProjectDaoImpl.java b/src/com/taobao/rigel/rap/project/dao/impl/ProjectDaoImpl.java index 0b5e1b5..2585f5a 100644 --- a/src/com/taobao/rigel/rap/project/dao/impl/ProjectDaoImpl.java +++ b/src/com/taobao/rigel/rap/project/dao/impl/ProjectDaoImpl.java @@ -124,9 +124,9 @@ public String updateProject(int id, String projectData, Session session = getSession(); // StringBuilder log = new StringBuilder(); Gson gson = new Gson(); - + Project projectClient = gson.fromJson(projectData, Project.class); - + ObjectItem[] deletedObjectList = gson.fromJson(deletedObjectListData, ObjectItem[].class); @@ -294,8 +294,6 @@ public long getProjectListNum(User user) { List list = query.list(); return list.get(0); } - - @Override public List getMatchedActionList(int projectId, String pattern) { @@ -303,7 +301,8 @@ public List getMatchedActionList(int projectId, String pattern) { List result = new ArrayList(); for (Action action : list) { String url = action.getRequestUrl(); - if (url != null && !url.isEmpty() && url.charAt(0) != '/') { + if (url != null && !url.isEmpty() && url.charAt(0) != '/' + && !url.startsWith("reg:")) { url = "/" + url; } if (url.startsWith("reg:")) { // regular pattern @@ -312,70 +311,56 @@ public List getMatchedActionList(int projectId, String pattern) { } } else if (url.contains(":")) { String urlParamRemoved = StringUtils.removeParamsInUrl(url); - String realUrlParamRemoved = StringUtils.removeRealParamsInUrl(pattern); + String realUrlParamRemoved = StringUtils + .removeRealParamsInUrl(pattern); if (urlParamRemoved.contains(realUrlParamRemoved)) { result.add(action); } - } else { // normal pattern + } else { // normal pattern if (url.contains(pattern)) { result.add(action); } } } - - + return result; - - - + // process /:id/ cases -// boolean urlParalized = false; -// String patternOrignial = pattern; -// if (pattern.contains(":")) { -// urlParalized = true; -// pattern = pattern.substring(0, pattern.indexOf(":")); -// } + // boolean urlParalized = false; + // String patternOrignial = pattern; + // if (pattern.contains(":")) { + // urlParalized = true; + // pattern = pattern.substring(0, pattern.indexOf(":")); + // } /** - StringBuilder sb = new StringBuilder(); - sb.append("SELECT a.id FROM tb_action a ") - .append("JOIN tb_action_and_page ap ON ap.action_id = a.id ") - .append("JOIN tb_page p ON p.id = ap.page_id ") - .append("JOIN tb_module m ON m.id = p.module_id ") - .append("WHERE LOCATE(:pattern, a.request_url) != 0 AND m.project_id = :projectId "); - - String sql = sb.toString(); - Query query = getSession().createSQLQuery(sql); - query.setString("pattern", pattern); - query.setInteger("projectId", projectId); - List list = query.list(); - List actionList = new ArrayList(); - for (int id : list) { - actionList.add(getAction(id)); - } - */ + * StringBuilder sb = new StringBuilder(); + * sb.append("SELECT a.id FROM tb_action a ") + * .append("JOIN tb_action_and_page ap ON ap.action_id = a.id ") + * .append("JOIN tb_page p ON p.id = ap.page_id ") + * .append("JOIN tb_module m ON m.id = p.module_id ") .append( + * "WHERE LOCATE(:pattern, a.request_url) != 0 AND m.project_id = :projectId " + * ); + * + * String sql = sb.toString(); Query query = + * getSession().createSQLQuery(sql); query.setString("pattern", + * pattern); query.setInteger("projectId", projectId); List + * list = query.list(); List actionList = new + * ArrayList(); for (int id : list) { + * actionList.add(getAction(id)); } + */ // URL parameters filter /** - if (urlParalized) { - List filteredActionList = new ArrayList(); - for (Action a : actionList) { - String u = a.getRequestUrl(); - if (u.contains("?")) { - u = u.substring(0, u.indexOf("?")); - } - u = StringUtils.removeParamsInUrl(u); - patternOrignial = StringUtils - .removeParamsInUrl(patternOrignial); - if (u != null && patternOrignial != null - && u.equals(patternOrignial)) { - filteredActionList.add(a); - } - } - actionList = filteredActionList; - } - */ -// return actionList; + * if (urlParalized) { List filteredActionList = new + * ArrayList(); for (Action a : actionList) { String u = + * a.getRequestUrl(); if (u.contains("?")) { u = u.substring(0, + * u.indexOf("?")); } u = StringUtils.removeParamsInUrl(u); + * patternOrignial = StringUtils .removeParamsInUrl(patternOrignial); if + * (u != null && patternOrignial != null && u.equals(patternOrignial)) { + * filteredActionList.add(a); } } actionList = filteredActionList; } + */ + // return actionList; } @SuppressWarnings("unchecked") @@ -447,7 +432,7 @@ public List search(String key) { query.setString("key", "%" + key + "%"); return query.list(); } - + @SuppressWarnings({ "rawtypes" }) private List getActionListOfProject(int projectId) { List list = new ArrayList(); @@ -461,11 +446,11 @@ private List getActionListOfProject(int projectId) { sql.append("WHERE p.id = :projectId "); Query query = getSession().createSQLQuery(sql.toString()); query.setInteger("projectId", projectId); - + List result = query.list(); List ids = new ArrayList(); for (Object r : result) { - ids.add((Integer)r); + ids.add((Integer) r); } for (Integer id : ids) { list.add(this.getAction(id));