Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public boolean checkRequireExpression(Requireable candidate, AppContextModel contextModel) {
- try {
- String requireExpression = candidate.getRequire();
- if (StringUtils.isBlank(requireExpression)) {
- return true;
- }
- ObjectMapper j = new ObjectMapper();
- for (Map.Entry<String, Object> e : contextModel.entrySet()) {
- if (!(e.getValue() instanceof Map) && !"util".equals(e.getKey())) {
- javascriptEngine.eval("var " + e.getKey() + " = " + j.writeValueAsString(e.getValue()) + ";");
- }
- }
- return javascriptEngine.eval("(" + requireExpression + ") == true").equals(Boolean.TRUE);
- }
- catch (Exception e) {
- log.error("Failed to evaluate 'require' check for extension " + candidate.getId(), e);
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment