ProjectMutex.java
1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package com.ui.project;
import org.apache.commons.lang.StringUtils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* 有些项目是互斥的
*/
public class ProjectMutex {
//与其他项目互斥,但是本身并不互斥
private final static List<List<String>> java_mutex_project_to_other=new ArrayList<>();
private final static List<String> java_mutex_project_to_other_rule1= Arrays.asList(new String[]{"yohobuy-activity","yohobuy-product","yohobuy-promotion"});
static {
java_mutex_project_to_other.add(java_mutex_project_to_other_rule1);
}
/**
* 检查是否存在互斥项目
* 差集
* @param sourceProjects
* @return
*/
public static List<Object> checkMutex(String sourceProjects){
boolean mutex=false;
String descr="";
List<String> sourceList=new ArrayList<>();
for(String str:sourceProjects.split(",")){
if(StringUtils.isNotBlank(str)){
sourceList.add(str);
}
}
if(sourceList!=null&&sourceList.size()>0){
//检查互斥
for(List<String> lsTmp:java_mutex_project_to_other){
List<String> checkListList=new ArrayList<>();
checkListList.addAll(sourceList);
checkListList.removeAll(lsTmp);
if(checkListList.size()>0&&checkListList.size()<sourceList.size()){
descr += "项目[";
descr += StringUtils.join(checkListList,",");
descr +="]与[";
descr += StringUtils.join(lsTmp,",");
descr +="]冲突,不允许同时发布";
mutex=true;
break;
}
}
}
List<Object> ls=new ArrayList<>();
ls.add(mutex);
ls.add(descr);
return ls;
}
}