Search in sources :

Example 1 with MessageType

use of org.talend.esb.policy.schemavalidate.SchemaValidationPolicy.MessageType in project tesb-rt-se by Talend.

the class SchemaValidationPolicyAbstractInterceptor method handleMessageWithoutAssertionInfo.

protected void handleMessageWithoutAssertionInfo(Message message) throws Fault {
    ValidationType vldType = policy.getValidationType();
    AppliesToType appliesToType = policy.getApplyToType();
    MessageType msgType = policy.getMessageType();
    String customSchemaPath = policy.getCustomSchemaPath();
    if (shouldSchemaValidate(message, msgType, appliesToType)) {
        if (vldType == ValidationType.CustomSchema) {
            // load custom schema from external source
            try {
                loadCustomSchema(message, customSchemaPath, this.getClass());
            } catch (IOException ex) {
                throw new RuntimeException("Can not load custom schema", ex);
            }
        }
        // do schema validation by setting value to
        // "schema-validation-enabled" property
        validateBySettingProperty(message);
    }
}
Also used : AppliesToType(org.talend.esb.policy.schemavalidate.SchemaValidationPolicy.AppliesToType) ValidationType(org.talend.esb.policy.schemavalidate.SchemaValidationPolicy.ValidationType) IOException(java.io.IOException) MessageType(org.talend.esb.policy.schemavalidate.SchemaValidationPolicy.MessageType)

Example 2 with MessageType

use of org.talend.esb.policy.schemavalidate.SchemaValidationPolicy.MessageType in project tesb-rt-se by Talend.

the class SchemaValidationPolicyAbstractInterceptor method handleMessageWithAssertionInfo.

protected void handleMessageWithAssertionInfo(Message message) throws Fault {
    AssertionInfoMap aim = message.get(AssertionInfoMap.class);
    if (null == aim) {
        return;
    }
    Collection<AssertionInfo> ais = aim.get(SchemaValidationPolicyBuilder.SCHEMA_VALIDATION);
    if (null == ais) {
        return;
    }
    for (AssertionInfo ai : ais) {
        if (ai.getAssertion() instanceof SchemaValidationPolicy) {
            SchemaValidationPolicy vPolicy = (SchemaValidationPolicy) ai.getAssertion();
            ValidationType vldType = vPolicy.getValidationType();
            AppliesToType appliesToType = vPolicy.getApplyToType();
            MessageType msgType = vPolicy.getMessageType();
            String customSchemaPath = vPolicy.getCustomSchemaPath();
            if (vldType != ValidationType.WSDLSchema) {
                ai.setAsserted(true);
            }
            if (shouldSchemaValidate(message, msgType, appliesToType)) {
                if (vldType == ValidationType.CustomSchema) {
                    // load custom schema from external source
                    try {
                        loadCustomSchema(message, customSchemaPath, this.getClass());
                    } catch (IOException ex) {
                        throw new RuntimeException("Can not load custom schema", ex);
                    }
                }
                // do schema validation by setting value to
                // "schema-validation-enabled" property
                validateBySettingProperty(message);
            }
            ai.setAsserted(true);
        }
        ai.setAsserted(true);
    }
}
Also used : AssertionInfo(org.apache.cxf.ws.policy.AssertionInfo) SchemaValidationPolicy(org.talend.esb.policy.schemavalidate.SchemaValidationPolicy) AppliesToType(org.talend.esb.policy.schemavalidate.SchemaValidationPolicy.AppliesToType) ValidationType(org.talend.esb.policy.schemavalidate.SchemaValidationPolicy.ValidationType) IOException(java.io.IOException) MessageType(org.talend.esb.policy.schemavalidate.SchemaValidationPolicy.MessageType) AssertionInfoMap(org.apache.cxf.ws.policy.AssertionInfoMap)

Aggregations

IOException (java.io.IOException)2 AppliesToType (org.talend.esb.policy.schemavalidate.SchemaValidationPolicy.AppliesToType)2 MessageType (org.talend.esb.policy.schemavalidate.SchemaValidationPolicy.MessageType)2 ValidationType (org.talend.esb.policy.schemavalidate.SchemaValidationPolicy.ValidationType)2 AssertionInfo (org.apache.cxf.ws.policy.AssertionInfo)1 AssertionInfoMap (org.apache.cxf.ws.policy.AssertionInfoMap)1 SchemaValidationPolicy (org.talend.esb.policy.schemavalidate.SchemaValidationPolicy)1