Search in sources :

Example 1 with PegNoMatchFoundException

use of io.vertigo.commons.peg.PegNoMatchFoundException in project vertigo by KleeGroup.

the class AbstractSecurityRuleTranslator method withRule.

/**
 * Set security pattern.
 * @param securityRule security Pattern (not null, could be empty)
 * @return this builder
 */
public final S withRule(final String securityRule) {
    Assertion.checkNotNull(securityRule);
    // -----
    try {
        final RuleMultiExpression myMultiExpression = DslParserUtil.parseMultiExpression(securityRule);
        myMultiExpressions.add(myMultiExpression);
    } catch (final PegNoMatchFoundException e) {
        final String message = StringUtil.format("Echec de lecture de la securityRule {0}\n{1}", securityRule, e.getFullMessage());
        throw WrappedException.wrap(e, message);
    } catch (final Exception e) {
        final String message = StringUtil.format("Echec de lecture de la securityRule {0}\n{1}", securityRule, e.getMessage());
        throw WrappedException.wrap(e, message);
    }
    return (S) this;
}
Also used : PegNoMatchFoundException(io.vertigo.commons.peg.PegNoMatchFoundException) RuleMultiExpression(io.vertigo.account.authorization.metamodel.rulemodel.RuleMultiExpression) WrappedException(io.vertigo.lang.WrappedException) PegNoMatchFoundException(io.vertigo.commons.peg.PegNoMatchFoundException)

Example 2 with PegNoMatchFoundException

use of io.vertigo.commons.peg.PegNoMatchFoundException in project vertigo by KleeGroup.

the class KspLoader method load.

/**
 * Chargement et analyse du fichier.
 *
 * @param dynamicModelrepository DynamicDefinitionRepository
 */
void load(final DslDefinitionRepository dynamicModelrepository) {
    Assertion.checkNotNull(dynamicModelrepository);
    try {
        final String s = parseFile();
        new DslKspRule(dynamicModelrepository).parse(s, 0);
    } catch (final PegNoMatchFoundException e) {
        final String message = StringUtil.format("Echec de lecture du fichier KSP {0}\n{1}", kspURL.getFile(), e.getFullMessage());
        throw WrappedException.wrap(e, message);
    } catch (final Exception e) {
        final String message = StringUtil.format("Echec de lecture du fichier KSP {0}\n{1}", kspURL.getFile(), e.getMessage());
        throw WrappedException.wrap(e, message);
    }
}
Also used : PegNoMatchFoundException(io.vertigo.commons.peg.PegNoMatchFoundException) DslKspRule(io.vertigo.dynamo.plugins.environment.loaders.kpr.rules.DslKspRule) WrappedException(io.vertigo.lang.WrappedException) IOException(java.io.IOException) PegNoMatchFoundException(io.vertigo.commons.peg.PegNoMatchFoundException)

Example 3 with PegNoMatchFoundException

use of io.vertigo.commons.peg.PegNoMatchFoundException in project vertigo by KleeGroup.

the class DslDefinitionBodyRuleTest method testError.

@Test
public void testError() {
    final List<DslEntity> entities = dslDefinitionRepository.getGrammar().getEntities();
    final DslEntity entity = find(entities, "Domain");
    final String testValue = "{ dataType : String ,  formatter : FMT_DEFAULT,  constraint : [ CK_CODE_POSTAL ] , maxLengh:\"true\"   } ";
    try {
        new DslDefinitionBodyRule(entity).parse(testValue, 0);
        Assert.fail();
    } catch (final PegNoMatchFoundException e) {
        // System.out.println(e.getFullMessage());
        Assert.assertEquals(testValue.indexOf("maxLengh") + "maxLengh".length() - 1, e.getIndex());
    }
}
Also used : PegNoMatchFoundException(io.vertigo.commons.peg.PegNoMatchFoundException) DslEntity(io.vertigo.dynamo.plugins.environment.dsl.entity.DslEntity) DslDefinitionBodyRule(io.vertigo.dynamo.plugins.environment.loaders.kpr.rules.DslDefinitionBodyRule) Test(org.junit.Test)

Aggregations

PegNoMatchFoundException (io.vertigo.commons.peg.PegNoMatchFoundException)3 WrappedException (io.vertigo.lang.WrappedException)2 RuleMultiExpression (io.vertigo.account.authorization.metamodel.rulemodel.RuleMultiExpression)1 DslEntity (io.vertigo.dynamo.plugins.environment.dsl.entity.DslEntity)1 DslDefinitionBodyRule (io.vertigo.dynamo.plugins.environment.loaders.kpr.rules.DslDefinitionBodyRule)1 DslKspRule (io.vertigo.dynamo.plugins.environment.loaders.kpr.rules.DslKspRule)1 IOException (java.io.IOException)1 Test (org.junit.Test)1