Skip to content

Commit

Permalink
客户端访问服务端请求知识包内容时不再尝试获取登录用户信息
Browse files Browse the repository at this point in the history
  • Loading branch information
jacky6024 committed Dec 4, 2017
1 parent 90c6c79 commit 85c5abb
Show file tree
Hide file tree
Showing 84 changed files with 194 additions and 185 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public KnowledgePackage buildKnowledgePackage(String packageInfo,boolean withPer
for(ResourceItem item:list){
resourceBase.addResource(item.getPath(),item.getVersion(),withPermission);
}
KnowledgeBase knowledgeBase=knowledgeBuilder.buildKnowledgeBase(resourceBase);
KnowledgeBase knowledgeBase=knowledgeBuilder.buildKnowledgeBase(resourceBase,withPermission);
KnowledgePackage knowledgePackage=knowledgeBase.getKnowledgePackage();
return knowledgePackage;
}catch(Exception ex){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class RepositoryResourceProvider implements ResourceProvider {

@Override
public Resource provide(String path, String version) {
return null;
return provide(path,version,true);
}
@Override
public Resource provide(String path,String version,boolean withPermiossion) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ public void loadXml(HttpServletRequest req, HttpServletResponse resp) throws Ser
Element element=parseXml(inputStream);
for(Deserializer<?> des:deserializers){
if(des.support(element)){
result.add(des.deserialize(element));
result.add(des.deserialize(element,true));
if(des instanceof ActionLibraryDeserializer){
isaction=true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void loadFlowDefinition(HttpServletRequest req, HttpServletResponse resp)
inputStream=repositoryService.readFile(file,version);
}
Element root=parseXml(inputStream);
FlowDefinition fd = flowDeserializer.deserialize(root);
FlowDefinition fd = flowDeserializer.deserialize(root,true);
inputStream.close();
writeObjectToJson(resp, new FlowDefinitionWrapper(fd));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public void loadXml(HttpServletRequest req, HttpServletResponse resp) throws Ser
Element element=parseXml(inputStream);
for(Deserializer<?> des:deserializers){
if(des.support(element)){
result.add(des.deserialize(element));
result.add(des.deserialize(element,true));
if(des instanceof ActionLibraryDeserializer){
isaction=true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ public class KnowledgeBuilder extends AbstractBuilder{
private DSLRuleSetBuilder dslRuleSetBuilder;
public static final String BEAN_ID="urule.knowledgeBuilder";
public KnowledgeBase buildKnowledgeBase(ResourceBase resourceBase) throws IOException{
return buildKnowledgeBase(resourceBase,true);
}
public KnowledgeBase buildKnowledgeBase(ResourceBase resourceBase,boolean withPermission) throws IOException{
KnowledgePackageService knowledgePackageService=(KnowledgePackageService)applicationContext.getBean(KnowledgePackageService.BEAN_ID);
List<Rule> rules=new ArrayList<Rule>();
Map<String,Library> libMap=new HashMap<String,Library>();
Expand All @@ -77,7 +80,7 @@ public KnowledgeBase buildKnowledgeBase(ResourceBase resourceBase) throws IOExce
if(!builder.support(root)){
continue;
}
Object object=builder.build(root);
Object object=builder.build(root,withPermission);
ResourceType type=builder.getType();
if(type.equals(ResourceType.RuleSet)){
RuleSet ruleSet=(RuleSet)object;
Expand Down Expand Up @@ -125,7 +128,7 @@ public KnowledgeBase buildKnowledgeBase(ResourceBase resourceBase) throws IOExce
break;
}
}
ResourceLibrary resourceLibrary=resourceLibraryBuilder.buildResourceLibrary(libMap.values());
ResourceLibrary resourceLibrary=resourceLibraryBuilder.buildResourceLibrary(libMap.values(),withPermission);
buildLoopRules(rules, resourceLibrary);
Rete rete=reteBuilder.buildRete(rules, resourceLibrary);
return new KnowledgeBase(rete,flowMap,retriveNoLhsRules(rules));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@
*/
public class ResourceLibraryBuilder extends AbstractBuilder{
private BuiltInActionLibraryBuilder builtInActionLibraryBuilder;
@SuppressWarnings("unchecked")
public ResourceLibrary buildResourceLibrary(Collection<Library> libraries){
return buildResourceLibrary(libraries,true);
}
@SuppressWarnings("unchecked")
public ResourceLibrary buildResourceLibrary(Collection<Library> libraries,boolean withPermission){
if(libraries==null){
libraries=Collections.EMPTY_LIST;
}
Expand All @@ -52,7 +55,7 @@ public ResourceLibrary buildResourceLibrary(Collection<Library> libraries){
List<VariableCategory> parameterVariableCategories=new ArrayList<VariableCategory>();
ResourceBase resourceBase=newResourceBase();
for(Library lib:libraries){
resourceBase.addResource(lib.getPath(),lib.getVersion());
resourceBase.addResource(lib.getPath(),lib.getVersion(),withPermission);
}
for(Resource resource:resourceBase.getResources()){
String content=resource.getContent();
Expand All @@ -61,7 +64,7 @@ public ResourceLibrary buildResourceLibrary(Collection<Library> libraries){
if(!builder.support(root)){
continue;
}
Object object=builder.build(root);
Object object=builder.build(root,withPermission);
ResourceType type=builder.getType();
if(type.equals(ResourceType.ActionLibrary)){
ActionLibrary al=(ActionLibrary)object;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,16 @@
public class RulesRebuilder {
private ResourceLibraryBuilder resourceLibraryBuilder;
public void rebuildRules(List<Library> libraries, List<Rule> rules) {
rebuildRules(libraries,rules,true);
}
public void rebuildRules(List<Library> libraries, List<Rule> rules,boolean withPermission) {
if(libraries==null){
return;
}
if(rules==null){
return;
}
ResourceLibrary resLibraries=resourceLibraryBuilder.buildResourceLibrary(libraries);
ResourceLibrary resLibraries=resourceLibraryBuilder.buildResourceLibrary(libraries,withPermission);
for(Rule rule:rules){
Map<String,String> namedMap=new HashMap<String,String>();
if(rule.getLhs()!=null){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
*/
public class ActionLibraryResourceBuilder implements ResourceBuilder<ActionLibrary> {
private ActionLibraryDeserializer actionLibraryDeserializer;
public ActionLibrary build(Element root) {
return actionLibraryDeserializer.deserialize(root);
public ActionLibrary build(Element root,boolean withPermission) {
return actionLibraryDeserializer.deserialize(root,withPermission);
}

public void setActionLibraryDeserializer(ActionLibraryDeserializer actionLibraryDeserializer) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
*/
public class ConstantLibraryResourceBuilder implements ResourceBuilder<ConstantLibrary> {
private ConstantLibraryDeserializer constantLibraryDeserializer;
public ConstantLibrary build(Element root) {
return constantLibraryDeserializer.deserialize(root);
public ConstantLibrary build(Element root,boolean withPermission) {
return constantLibraryDeserializer.deserialize(root,withPermission);
}
public boolean support(Element root) {
return constantLibraryDeserializer.support(root);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
*/
public class DecisionTableResourceBuilder implements ResourceBuilder<DecisionTable> {
private DecisionTableDeserializer decisionTableDeserializer;
public DecisionTable build(Element root) {
return decisionTableDeserializer.deserialize(root);
public DecisionTable build(Element root,boolean withPermission) {
return decisionTableDeserializer.deserialize(root,withPermission);
}
public ResourceType getType() {
return ResourceType.DecisionTable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
public class DecisionTreeResourceBuilder implements ResourceBuilder<DecisionTree> {
private DecisionTreeDeserializer decisionTreeDeserializer;
@Override
public DecisionTree build(Element root) {
return decisionTreeDeserializer.deserialize(root);
public DecisionTree build(Element root,boolean withPermission) {
return decisionTreeDeserializer.deserialize(root,withPermission);
}
@Override
public ResourceType getType() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
*/
public class FlowResourceBuilder implements ResourceBuilder<FlowDefinition> {
private FlowDeserializer flowDeserializer;
public FlowDefinition build(Element root) {
return flowDeserializer.deserialize(root);
public FlowDefinition build(Element root,boolean withPermission) {
return flowDeserializer.deserialize(root,withPermission);
}
public ResourceType getType() {
return ResourceType.Flow;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
public class ParameterLibraryResourceBuilder implements ResourceBuilder<VariableCategory> {
private ParameterLibraryDeserializer parameterLibraryDeserializer;
@Override
public VariableCategory build(Element root) {
public VariableCategory build(Element root,boolean withPermission) {
VariableCategory category=new VariableCategory();
category.setName(VariableCategory.PARAM_CATEGORY);
category.setClazz(HashMap.class.getName());
category.setType(CategoryType.Clazz);
category.setVariables(parameterLibraryDeserializer.deserialize(root));
category.setVariables(parameterLibraryDeserializer.deserialize(root,withPermission));
return category;
}
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* @since 2014年12月22日
*/
public interface ResourceBuilder<T>{
T build(Element root);
T build(Element root,boolean withPermission);
boolean support(Element root);
ResourceType getType();
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
*/
public class RuleSetResourceBuilder implements ResourceBuilder<RuleSet> {
private RuleSetDeserializer ruleSetDeserializer;
public RuleSet build(Element root) {
return ruleSetDeserializer.deserialize(root);
public RuleSet build(Element root,boolean withPermission) {
return ruleSetDeserializer.deserialize(root,withPermission);
}
public boolean support(Element root) {
return ruleSetDeserializer.support(root);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ public class ScorecardResourceBuilder implements ResourceBuilder<ScoreRule> {
private ScorecardDeserializer scorecardDeserializer;
private RulesRebuilder rulesRebuilder;
@Override
public ScoreRule build(Element root) {
ScorecardDefinition scorecard = scorecardDeserializer.deserialize(root);
public ScoreRule build(Element root,boolean withPermission) {
ScorecardDefinition scorecard = scorecardDeserializer.deserialize(root,withPermission);
ScoreRule scoreRule=new ScoreRule();
scoreRule.setName(scorecard.getName());
scoreRule.setEffectiveDate(scorecard.getEffectiveDate());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
*/
public class ScriptDecisionTableResourceBuilder implements ResourceBuilder<ScriptDecisionTable> {
private ScriptDecisionTableDeserializer scriptDecisionTableDeserializer;
public ScriptDecisionTable build(Element root) {
return scriptDecisionTableDeserializer.deserialize(root);
public ScriptDecisionTable build(Element root,boolean withPermission) {
return scriptDecisionTableDeserializer.deserialize(root,withPermission);
}
public ResourceType getType() {
return ResourceType.ScriptDecisionTable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
*/
public class VariableLibraryResourceBuilder implements ResourceBuilder<VariableLibrary> {
private VariableLibraryDeserializer variableLibraryDeserializer;
public VariableLibrary build(Element root) {
public VariableLibrary build(Element root,boolean withPermission) {
VariableLibrary lib=new VariableLibrary();
lib.setVariableCategories(variableLibraryDeserializer.deserialize(root));
lib.setVariableCategories(variableLibraryDeserializer.deserialize(root,withPermission));
return lib;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* @since 2015年2月28日
*/
public abstract class AbstractParser<T> implements Parser<T> {
protected List<Parameter> parseParameters(Element element,ValueParser valueParser) {
protected List<Parameter> parseParameters(Element element,ValueParser valueParser,boolean withPermission) {
List<Parameter> parameters=new ArrayList<Parameter>();
for(Object obj:element.elements()){
if(obj==null || !(obj instanceof Element)){
Expand All @@ -46,7 +46,7 @@ protected List<Parameter> parseParameters(Element element,ValueParser valueParse
}
Element e=(Element)o;
if(valueParser.support(e.getName())){
Value value=valueParser.parse(e);
Value value=valueParser.parse(e,withPermission);
parameter.setValue(value);
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public abstract class AbstractRuleParser<T> implements Parser<T> {
protected LhsParser lhsParser;
protected RhsParser rhsParser;
private OtherParser otherParser;
public void parseRule(Rule rule,Element element) {
public void parseRule(Rule rule,Element element,boolean withPermission) {
rule.setName(element.attributeValue("name"));
String salience=element.attributeValue("salience");
if(StringUtils.isNotEmpty(salience)){
Expand Down Expand Up @@ -81,11 +81,11 @@ public void parseRule(Rule rule,Element element) {
}
Element ele=(Element)obj;
if(lhsParser.support(ele.getName())){
rule.setLhs(lhsParser.parse(ele));
rule.setLhs(lhsParser.parse(ele,withPermission));
}else if(rhsParser.support(ele.getName())){
rule.setRhs(rhsParser.parse(ele));
rule.setRhs(rhsParser.parse(ele,withPermission));
}else if(otherParser.support(ele.getName())){
rule.setOther(otherParser.parse(ele));
rule.setOther(otherParser.parse(ele,withPermission));
}else if(ele.getName().equals("remark")){
rule.setRemark(ele.getText());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* @since 2014年12月23日
*/
public class ActionLibraryParser implements Parser<ActionLibrary> {
public ActionLibrary parse(Element element) {
public ActionLibrary parse(Element element,boolean withPermission) {
ActionLibrary lib=new ActionLibrary();
for(Object obj:element.elements()){
if(obj==null){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
*/
public class CommonFunctionActionParser extends ActionParser {
@Override
public Action parse(Element element) {
public Action parse(Element element,boolean withPermission) {
ExecuteCommonFunctionAction action=new ExecuteCommonFunctionAction();
action.setLabel(element.attributeValue("function-label"));
action.setName(element.attributeValue("function-name"));
Expand All @@ -51,7 +51,7 @@ public Action parse(Element element) {
if(!e.getName().equals("value")){
continue;
}
p.setObjectParameter(valueParser.parse(e));
p.setObjectParameter(valueParser.parse(e,withPermission));
}
action.setParameter(p);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
public class ComplexArithmeticParser implements Parser<ComplexArithmetic> {
private ValueParser valueParser;
private ParenParser parenParser;
public ComplexArithmetic parse(Element element) {
public ComplexArithmetic parse(Element element,boolean withPermission) {
ComplexArithmetic arithmetic=new ComplexArithmetic();
ArithmeticType arithmeticType=ArithmeticType.valueOf(element.attributeValue("type"));
arithmetic.setType(arithmeticType);
Expand All @@ -37,9 +37,9 @@ public ComplexArithmetic parse(Element element) {
}
Element ele=(Element)obj;
if(valueParser.support(ele.getName())){
arithmetic.setValue(valueParser.parse(ele));
arithmetic.setValue(valueParser.parse(ele,withPermission));
}else if(parenParser.support(ele.getName())){
arithmetic.setValue(parenParser.parse(ele));
arithmetic.setValue(parenParser.parse(ele,withPermission));
}
}
return arithmetic;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@
* @since 2014年12月23日
*/
public class ConsolePrintActionParser extends ActionParser {
public Action parse(Element element) {
public Action parse(Element element,boolean withPermission) {
ConsolePrintAction action=new ConsolePrintAction();
for(Object obj:element.elements()){
if(obj==null || !(obj instanceof Element)){
continue;
}
Element ele=(Element)obj;
if(valueParser.support(ele.getName())){
action.setValue(valueParser.parse(ele));
action.setValue(valueParser.parse(ele,withPermission));
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
*/
public class ConstantLibraryParser implements Parser<ConstantLibrary> {
public static final String BEAN_ID="urule.constantLibraryParser";
public ConstantLibrary parse(Element element) {
public ConstantLibrary parse(Element element,boolean withPermission) {
List<ConstantCategory> categories=new ArrayList<ConstantCategory>();
for(Object obj:element.elements()){
if(obj==null || !(obj instanceof Element)){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
public class CriteriaParser extends CriterionParser {
private ValueParser valueParser;
private LeftParser leftParser;
public Criterion parse(Element element) {
public Criterion parse(Element element,boolean withPermission) {
Criteria criteria=new Criteria();
Op op=Op.valueOf(element.attributeValue("op"));
criteria.setOp(op);
Expand All @@ -39,9 +39,9 @@ public Criterion parse(Element element) {
Element ele=(Element)obj;
String name=ele.getName();
if(name.equals("value")){
criteria.setValue(valueParser.parse(ele));
criteria.setValue(valueParser.parse(ele,withPermission));
}else if(name.equals("left")){
criteria.setLeft(leftParser.parse(ele));
criteria.setLeft(leftParser.parse(ele,withPermission));
}
}
return criteria;
Expand Down
Loading

0 comments on commit 85c5abb

Please sign in to comment.