Skip to content

Commit

Permalink
dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Bosn committed May 29, 2014
1 parent 41af1bc commit dc39315
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 80 deletions.
24 changes: 6 additions & 18 deletions DEPLOY.md
Original file line number Diff line number Diff line change
@@ -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;
```
0. 备份
1. 检查RAP插件root
2. 检查数据库配置文件
3. 检查UT是否全部通过
4. 检查数据库脚本是否更新
2 changes: 1 addition & 1 deletion WebContent/stat/js/util/mock.plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
8 changes: 4 additions & 4 deletions src/com/taobao/rigel/rap/mock/service/impl/MockMgrImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<object>
json.append(para.getMockJSIdentifier() + ":");
json.append(processMockValueWithParams(para.getMockJSIdentifier()) + ":");
String left = "{", right = "}";

if (isArrayObject) {
Expand Down Expand Up @@ -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("]")) {
Expand All @@ -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)
Expand Down
99 changes: 42 additions & 57 deletions src/com/taobao/rigel/rap/project/dao/impl/ProjectDaoImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -294,16 +294,15 @@ public long getProjectListNum(User user) {
List<Long> list = query.list();
return list.get(0);
}



@Override
public List<Action> getMatchedActionList(int projectId, String pattern) {
List<Action> list = getActionListOfProject(projectId);
List<Action> result = new ArrayList<Action>();
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
Expand All @@ -312,70 +311,56 @@ public List<Action> 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<Integer> list = query.list();
List<Action> actionList = new ArrayList<Action>();
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<Integer>
* list = query.list(); List<Action> actionList = new
* ArrayList<Action>(); for (int id : list) {
* actionList.add(getAction(id)); }
*/

// URL parameters filter
/**
if (urlParalized) {
List<Action> filteredActionList = new ArrayList<Action>();
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<Action> filteredActionList = new
* ArrayList<Action>(); 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")
Expand Down Expand Up @@ -447,7 +432,7 @@ public List<Project> search(String key) {
query.setString("key", "%" + key + "%");
return query.list();
}

@SuppressWarnings({ "rawtypes" })
private List<Action> getActionListOfProject(int projectId) {
List<Action> list = new ArrayList<Action>();
Expand All @@ -461,11 +446,11 @@ private List<Action> getActionListOfProject(int projectId) {
sql.append("WHERE p.id = :projectId ");
Query query = getSession().createSQLQuery(sql.toString());
query.setInteger("projectId", projectId);

List result = query.list();
List<Integer> ids = new ArrayList<Integer>();
for (Object r : result) {
ids.add((Integer)r);
ids.add((Integer) r);
}
for (Integer id : ids) {
list.add(this.getAction(id));
Expand Down

0 comments on commit dc39315

Please sign in to comment.