/** * Describes given {@link Rule} as: * <p> * <code>ID: Phase - Provider [tags ...]".</code> */ public static String prettyPrintRule(Rule rule) { StringBuilder result = new StringBuilder(); if (rule instanceof Context) { final Context context = (Context) rule; RuleProvider provider = (RuleProvider) context.get(RuleMetadataType.RULE_PROVIDER); if (provider != null && provider.getMetadata() != null) { result.append(provider.getMetadata().getPhase().getSimpleName()).append(" - "); result.append(provider.getMetadata().getID()).append(" - "); } if (rule.getId() != null) result.append(rule.getId()); } return result.toString(); }
@Override public boolean evaluate(final Rewrite event, final EvaluationContext context) { context.put(ParameterStore.class, store); if (wrapped != null && condition != null) return wrapped.evaluate(event, context) && condition.evaluate(event, context); else if (wrapped != null) return wrapped.evaluate(event, context); else if (condition != null) return condition.evaluate(event, context); return true; }
@Override public void perform(final Rewrite event, final EvaluationContext context) { if (wrapped != null) wrapped.perform(event, context); if (operation != null) operation.perform(event, context); }
if (windupStopRequested) String msg = Util.WINDUP_BRAND_NAME_ACRONYM+" was requested to stop before beforeRuleEvaluation() of " + rule.getId() + ", skipping further rules."; log.fine(msg); event.setWindupStopException(new WindupStopException(msg)); if (rule.evaluate(event, subContext)) if (windupStopRequested) String msg = Util.WINDUP_BRAND_NAME_ACRONYM+" was requested to stop before beforeRuleOperationsPerformed() of " + rule.getId() + ", skipping further rules."; log.warning(msg); event.setWindupStopException(new WindupStopException(msg)); break; rule.perform(event, subContext); final String msg = Util.WINDUP_BRAND_NAME_ACRONYM+" was requested to stop during execution of " + rule.getId() + ", skipping further rules."; log.fine(msg); event.setWindupStopException(new WindupStopException(msg, ex)); throw new WindupException(exMsg, ex); else exceptions.put(rule.getId(), ex);
if (windupStopRequested) String msg = Util.WINDUP_BRAND_NAME_ACRONYM+" was requested to stop before beforeRuleEvaluation() of " + rule.getId() + ", skipping further rules."; log.fine(msg); event.setWindupStopException(new WindupStopException(msg)); if (rule.evaluate(event, subContext)) if (windupStopRequested) String msg = Util.WINDUP_BRAND_NAME_ACRONYM+" was requested to stop before beforeRuleOperationsPerformed() of " + rule.getId() + ", skipping further rules."; log.warning(msg); event.setWindupStopException(new WindupStopException(msg)); break; rule.perform(event, subContext); final String msg = Util.WINDUP_BRAND_NAME_ACRONYM+" was requested to stop during execution of " + rule.getId() + ", skipping further rules."; log.fine(msg); event.setWindupStopException(new WindupStopException(msg, ex)); throw new WindupException(exMsg, ex); else exceptions.put(rule.getId(), ex);
/** * Describes given {@link Rule} as: * <p> * <code>ID: Phase - Provider [tags ...]".</code> */ public static String prettyPrintRule(Rule rule) { StringBuilder result = new StringBuilder(); if (rule instanceof Context) { final Context context = (Context) rule; RuleProvider provider = (RuleProvider) context.get(RuleMetadataType.RULE_PROVIDER); if (provider != null && provider.getMetadata() != null) { result.append(provider.getMetadata().getPhase().getSimpleName()).append(" - "); result.append(provider.getMetadata().getID()).append(" - "); } if (rule.getId() != null) result.append(rule.getId()); } return result.toString(); }
@Override public boolean evaluate(final Rewrite event, final EvaluationContext context) { context.put(ParameterStore.class, store); if (wrapped != null && condition != null) return wrapped.evaluate(event, context) && condition.evaluate(event, context); else if (wrapped != null) return wrapped.evaluate(event, context); else if (condition != null) return condition.evaluate(event, context); return true; }
@Override public void perform(final Rewrite event, final EvaluationContext context) { if (wrapped != null) wrapped.perform(event, context); if (operation != null) operation.perform(event, context); }
private RuleBuilder(Rule rule) { store = new DefaultParameterStore(); withId(rule.getId()); if (rule instanceof Weighted) withPriority(((Weighted) rule).priority()); wrapped = rule; }
private RuleBuilder(Rule rule) { store = new DefaultParameterStore(); withId(rule.getId()); if (rule instanceof Weighted) withPriority(((Weighted) rule).priority()); wrapped = rule; }
public void perform(GraphRewrite event, EvaluationContext context, FileLocationModel payload) { // for all file location models that match the regular expression in the where clause, add // the IP Location Model to the graph if (InetAddressValidator.getInstance().isValid(payload.getSourceSnippit())) { // if the file is a property file, make sure the line isn't commented out. if (ignoreLine(event.getGraphContext(), payload)) { return; } if (payload.getFile() instanceof SourceFileModel) ((SourceFileModel) payload.getFile()).setGenerateSourceReport(true); HardcodedIPLocationModel location = GraphService.addTypeToModel(event.getGraphContext(), payload, HardcodedIPLocationModel.class); location.setRuleID(((Rule) context.get(Rule.class)).getId()); location.setTitle("Hard-coded IP address"); StringBuilder hintBody = new StringBuilder("**Hard-coded IP: "); hintBody.append(payload.getSourceSnippit()); hintBody.append("**"); hintBody.append(System.lineSeparator()+System.lineSeparator()); hintBody.append("When migrating environments, hard-coded IP addresses may need to be modified or eliminated."); location.setHint(hintBody.toString()); //location.setIssueCategory(IssueCategoryRegistry.loadFromGraph(event.getGraphContext(), IssueCategoryRegistry.MANDATORY)); location.setIssueCategory(IssueCategoryRegistry.loadFromGraph(event.getGraphContext(), IssueCategoryRegistry.CLOUD_MANDATORY)); location.setEffort(1); } } })
public void perform(GraphRewrite event, EvaluationContext context, FileLocationModel payload) { // for all file location models that match the regular expression in the where clause, add // the IP Location Model to the graph if (InetAddressValidator.getInstance().isValid(payload.getSourceSnippit())) { // if the file is a property file, make sure the line isn't commented out. if (ignoreLine(event.getGraphContext(), payload)) { return; } if (payload.getFile() instanceof SourceFileModel) ((SourceFileModel) payload.getFile()).setGenerateSourceReport(true); HardcodedIPLocationModel location = GraphService.addTypeToModel(event.getGraphContext(), payload, HardcodedIPLocationModel.class); location.setRuleID(((Rule) context.get(Rule.class)).getId()); location.setTitle("Hard-coded IP address"); StringBuilder hintBody = new StringBuilder("**Hard-coded IP: "); hintBody.append(payload.getSourceSnippit()); hintBody.append("**"); hintBody.append(System.lineSeparator()+System.lineSeparator()); hintBody.append("When migrating environments, hard-coded IP addresses may need to be modified or eliminated."); location.setHint(hintBody.toString()); //location.setIssueCategory(IssueCategoryRegistry.loadFromGraph(event.getGraphContext(), IssueCategoryRegistry.MANDATORY)); location.setIssueCategory(IssueCategoryRegistry.loadFromGraph(event.getGraphContext(), IssueCategoryRegistry.CLOUD_MANDATORY)); location.setEffort(1); } } })
List<Rule> rules = cfg.getRules(); for (Rule rule : rules) overrideRules.put(new RuleKey(provider.getMetadata().getID(), rule.getId()), rule); Rule overrideRule = overrideRules.get(new RuleKey(provider.getMetadata().getID(), rule.getId())); if (overrideRule != null) LOG.info("Replacing rule " + rule.getId() + " with a user override!"); ruleIterator.set(overrideRule); if (rule instanceof RuleBuilder && StringUtils.isBlank(rule.getId()))