Examples of JexlContext


Examples of org.apache.commons.jexl2.JexlContext

                    if (role.getResourceNames().contains(task.getResource().getName())
                            && StringUtils.isNotBlank(task.getResource().getRmapping().getAccountLink())) {

                        LOG.debug("Evaluating accountLink for {}", role);

                        final JexlContext jexlContext = new MapContext();
                        JexlUtil.addFieldsToContext(role, jexlContext);
                        JexlUtil.addAttrsToContext(role.getAttributes(), jexlContext);
                        JexlUtil.addDerAttrsToContext(role.getDerivedAttributes(), role.getAttributes(), jexlContext);
                        final String roleAccountLink =
                                JexlUtil.evaluate(task.getResource().getRmapping().getAccountLink(), jexlContext);
View Full Code Here

Examples of org.apache.commons.jexl2.JexlContext

     *
     * @return the newly created context
     */
    private JexlContext createContext()
    {
        JexlContext ctx = new MapContext();
        initializeContext(ctx);
        return ctx;
    }
View Full Code Here

Examples of org.apache.commons.jexl2.JexlContext

        final ConfigurableApplicationContext context = ApplicationContextProvider.getApplicationContext();
        final JexlUtil jexlUtil = context.getBean(JexlUtil.class);

        // Prepare context using user attributes
        final JexlContext jexlContext = jexlUtil.addAttrsToContext(attributes, null);

        final AbstractAttributable owner = getOwner();
        if (owner instanceof SyncopeUser) {
            jexlContext.set("username", ((SyncopeUser) owner).getUsername() != null
                    ? ((SyncopeUser) owner).getUsername()
                    : "");
            jexlContext.set("creationDate", ((SyncopeUser) owner).getCreationDate() != null
                    ? ((SyncopeUser) owner).getDateFormatter().format(((SyncopeUser) owner).getCreationDate())
                    : "");
            jexlContext.set("lastLoginDate", ((SyncopeUser) owner).getLastLoginDate() != null
                    ? ((SyncopeUser) owner).getDateFormatter().format(((SyncopeUser) owner).getLastLoginDate())
                    : "");
            jexlContext.set("failedLogins", ((SyncopeUser) owner).getFailedLogins() != null
                    ? ((SyncopeUser) owner).getFailedLogins()
                    : "");
            jexlContext.set("changePwdDate", ((SyncopeUser) owner).getChangePwdDate() != null
                    ? ((SyncopeUser) owner).getDateFormatter().format(((SyncopeUser) owner).getChangePwdDate())
                    : "");
        }

        // Evaluate expression using the context prepared before
View Full Code Here

Examples of org.apache.commons.jexl2.JexlContext

        return result;
    }

    public String evaluate(final String expression, final AbstractAttributable attributable) {

        final JexlContext jexlContext = new MapContext();

        if (attributable instanceof SyncopeUser) {
            SyncopeUser user = (SyncopeUser) attributable;

            jexlContext.set("username", user.getUsername() != null
                    ? user.getUsername()
                    : StringUtils.EMPTY);
            jexlContext.set("creationDate", user.getCreationDate() != null
                    ? user.getDateFormatter().format(user.getCreationDate())
                    : StringUtils.EMPTY);
            jexlContext.set("lastLoginDate", user.getLastLoginDate() != null
                    ? user.getDateFormatter().format(user.getLastLoginDate())
                    : StringUtils.EMPTY);
            jexlContext.set("failedLogins", user.getFailedLogins() != null
                    ? user.getFailedLogins()
                    : StringUtils.EMPTY);
            jexlContext.set("changePwdDate", user.getChangePwdDate() != null
                    ? user.getDateFormatter().format(user.getChangePwdDate())
                    : StringUtils.EMPTY);
        }

        addAttrsToContext(attributable.getAttributes(), jexlContext);
View Full Code Here

Examples of org.apache.commons.jexl2.JexlContext

    }

    public JexlContext addAttrsToContext(final Collection<? extends AbstractAttr> attributes,
            final JexlContext jexlContext) {

        JexlContext context = jexlContext == null
                ? new MapContext()
                : jexlContext;

        for (AbstractAttr attribute : attributes) {
            List<String> attributeValues = attribute.getValuesAsStrings();
            String expressionValue = attributeValues.isEmpty()
                    ? StringUtils.EMPTY
                    : attributeValues.get(0);

            LOG.debug("Add attribute {} with value {}",
                    new Object[] { attribute.getSchema().getName(), expressionValue });

            context.set(attribute.getSchema().getName(), expressionValue);
        }

        return context;
    }
View Full Code Here

Examples of org.apache.commons.jexl2.JexlContext

    }

    public JexlContext addDerAttrsToContext(final Collection<? extends AbstractDerAttr> derAttributes,
            final Collection<? extends AbstractAttr> attributes, final JexlContext jexlContext) {

        JexlContext context = jexlContext == null
                ? new MapContext()
                : jexlContext;

        for (AbstractDerAttr attribute : derAttributes) {
            String expressionValue = attribute.getValue(attributes);
            if (expressionValue == null) {
                expressionValue = StringUtils.EMPTY;
            }

            LOG.debug("Add derived attribute {} with value {}", new Object[] { attribute.getDerivedSchema().getName(),
                expressionValue });

            context.set(attribute.getDerivedSchema().getName(), expressionValue);
        }

        return context;
    }
View Full Code Here

Examples of org.apache.commons.jexl2.JexlContext

        return context;
    }

    public String evaluate(final String expression, final AbstractAttributableTO attributableTO) {

        final JexlContext context = new MapContext();

        if (attributableTO instanceof UserTO) {
            UserTO user = (UserTO) attributableTO;

            context.set("username", user.getUsername() != null
                    ? user.getUsername()
                    : StringUtils.EMPTY);
            context.set("password", user.getPassword() != null
                    ? user.getPassword()
                    : StringUtils.EMPTY);
        }

        for (AttributeTO attribute : attributableTO.getAttributes()) {
            List<String> attributeValues = attribute.getValues();
            String expressionValue = attributeValues.isEmpty()
                    ? StringUtils.EMPTY
                    : attributeValues.get(0);

            LOG.debug("Add attribute {} with value {}", new Object[] { attribute.getSchema(), expressionValue });

            context.set(attribute.getSchema(), expressionValue);
        }
        for (AttributeTO attribute : attributableTO.getDerivedAttributes()) {
            List<String> attributeValues = attribute.getValues();
            String expressionValue = attributeValues.isEmpty()
                    ? StringUtils.EMPTY
                    : attributeValues.get(0);

            LOG.debug("Add attribute {} with value {}", new Object[] { attribute.getSchema(), expressionValue });

            context.set(attribute.getSchema(), expressionValue);
        }
        for (AttributeTO attribute : attributableTO.getVirtualAttributes()) {
            List<String> attributeValues = attribute.getValues();
            String expressionValue = attributeValues.isEmpty()
                    ? StringUtils.EMPTY
                    : attributeValues.get(0);

            LOG.debug("Add attribute {} with value {}", new Object[] { attribute.getSchema(), expressionValue });

            context.set(attribute.getSchema(), expressionValue);
        }

        // Evaluate expression using the context prepared before
        return evaluate(expression, context);
    }
View Full Code Here

Examples of org.apache.commons.jexl2.JexlContext

    }

    private boolean evaluateMandatoryCondition(final String mandatoryCondition,
            final List<? extends AbstractAttr> attributes) {

        JexlContext jexlContext = new MapContext();
        jexlUtil.addAttrsToContext(attributes, jexlContext);

        return Boolean.parseBoolean(jexlUtil.evaluate(mandatoryCondition, jexlContext));
    }
View Full Code Here

Examples of org.apache.commons.jexl2.JexlContext

        JMeterContext jmctx = JMeterContextService.getContext();
        JMeterVariables vars = jmctx.getVariables();

        try
        {
            JexlContext jc = new MapContext();
            jc.set("log", log); //$NON-NLS-1$
            jc.set("ctx", jmctx); //$NON-NLS-1$
            jc.set("vars", vars); //$NON-NLS-1$
            jc.set("props", JMeterUtils.getJMeterProperties()); //$NON-NLS-1$
            // Previously mis-spelt as theadName
            jc.set("threadName", Thread.currentThread().getName()); //$NON-NLS-1$
            jc.set("sampler", currentSampler); //$NON-NLS-1$ (may be null)
            jc.set("sampleResult", previousResult); //$NON-NLS-1$ (may be null)
            jc.set("OUT", System.out);//$NON-NLS-1$

            // Now evaluate the script, getting the result
            Expression e = jexl.createExpression( exp );
            Object o = e.evaluate(jc);
            if (o != null)
View Full Code Here

Examples of org.apache.commons.jexl2.JexlContext

 
  private boolean matches(Key k) {
    if (log.isDebugEnabled()) {
      log.debug("You've reached the match function!");
    }
    JexlContext ctx = new MapContext();
    // Add the field value from the key to the context
    // String fieldValue = k.getColumnQualifier().toString().split("\0")[0];
    // String fieldValue = getFieldValueFromKey(k);
    keyParser.parse(k);
    String fieldValue = keyParser.getFieldValue();
   
    ctx.set(fNameString, fieldValue);
    Object o = expr.evaluate(ctx);
    if (o instanceof Boolean && (((Boolean) o) == true)) {
      if (log.isDebugEnabled()) {
        log.debug("matches:: fName: " + fName + " , fValue: " + fieldValue + " ,  operator: " + fOperator + " , key: " + k);
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.