Search in sources :

Example 6 with SchemaValidationType

use of org.apache.cxf.annotations.SchemaValidation.SchemaValidationType in project tomee by apache.

the class ServiceUtils method isSchemaValidationEnabled.

/**
 * A short cut method to be able to test for if Schema Validation should be enabled
 * for IN or OUT without having to check BOTH and IN or OUT.
 *
 * @param message
 * @param type
 */
public static boolean isSchemaValidationEnabled(SchemaValidationType type, Message message) {
    SchemaValidationType validationType = getSchemaValidationType(message);
    boolean isRequestor = MessageUtils.isRequestor(message);
    if (SchemaValidationType.REQUEST.equals(validationType)) {
        if (isRequestor) {
            validationType = SchemaValidationType.OUT;
        } else {
            validationType = SchemaValidationType.IN;
        }
    } else if (SchemaValidationType.RESPONSE.equals(validationType)) {
        if (isRequestor) {
            validationType = SchemaValidationType.IN;
        } else {
            validationType = SchemaValidationType.OUT;
        }
    }
    return validationType.equals(type) || ((SchemaValidationType.IN.equals(type) || SchemaValidationType.OUT.equals(type)) && SchemaValidationType.BOTH.equals(validationType));
}
Also used : SchemaValidationType(org.apache.cxf.annotations.SchemaValidation.SchemaValidationType)

Example 7 with SchemaValidationType

use of org.apache.cxf.annotations.SchemaValidation.SchemaValidationType in project cxf by apache.

the class ServiceUtilsTest method testGetSchemaValidationType.

@Test
public void testGetSchemaValidationType() {
    for (SchemaValidationType type : SchemaValidationType.values()) {
        setupSchemaValidationValue(type.name(), false);
        assertEquals(type, ServiceUtils.getSchemaValidationType(msg));
        setupSchemaValidationValue(type.name().toLowerCase(), false);
        assertEquals(type, ServiceUtils.getSchemaValidationType(msg));
        setupSchemaValidationValue(StringUtils.capitalize(type.name()), false);
        assertEquals(type, ServiceUtils.getSchemaValidationType(msg));
    }
}
Also used : SchemaValidationType(org.apache.cxf.annotations.SchemaValidation.SchemaValidationType) Test(org.junit.Test)

Example 8 with SchemaValidationType

use of org.apache.cxf.annotations.SchemaValidation.SchemaValidationType in project cxf by apache.

the class JavaFirstSchemaValidationTest method createNoSchemaValidationFeature.

private static SchemaValidationFeature createNoSchemaValidationFeature() {
    Map<String, SchemaValidationType> operationMap = new HashMap<>();
    operationMap.put("*", SchemaValidationType.NONE);
    DefaultSchemaValidationTypeProvider provider = new DefaultSchemaValidationTypeProvider(operationMap);
    return new SchemaValidationFeature(provider);
}
Also used : HashMap(java.util.HashMap) SchemaValidationType(org.apache.cxf.annotations.SchemaValidation.SchemaValidationType) SchemaValidationFeature(org.apache.cxf.feature.validation.SchemaValidationFeature) DefaultSchemaValidationTypeProvider(org.apache.cxf.feature.validation.DefaultSchemaValidationTypeProvider)

Example 9 with SchemaValidationType

use of org.apache.cxf.annotations.SchemaValidation.SchemaValidationType in project cxf by apache.

the class JavaFirstSchemaValidationTest method createSchemaValidationFeature.

private static SchemaValidationFeature createSchemaValidationFeature() {
    Map<String, SchemaValidationType> operationMap = new HashMap<>();
    operationMap.put("saveInheritEndpoint", SchemaValidationType.BOTH);
    operationMap.put("saveNoValidation", SchemaValidationType.NONE);
    operationMap.put("saveValidateIn", SchemaValidationType.IN);
    operationMap.put("saveValidateOut", SchemaValidationType.OUT);
    DefaultSchemaValidationTypeProvider provider = new DefaultSchemaValidationTypeProvider(operationMap);
    return new SchemaValidationFeature(provider);
}
Also used : HashMap(java.util.HashMap) SchemaValidationType(org.apache.cxf.annotations.SchemaValidation.SchemaValidationType) SchemaValidationFeature(org.apache.cxf.feature.validation.SchemaValidationFeature) DefaultSchemaValidationTypeProvider(org.apache.cxf.feature.validation.DefaultSchemaValidationTypeProvider)

Aggregations

SchemaValidationType (org.apache.cxf.annotations.SchemaValidation.SchemaValidationType)9 HashMap (java.util.HashMap)2 Endpoint (org.apache.cxf.endpoint.Endpoint)2 DefaultSchemaValidationTypeProvider (org.apache.cxf.feature.validation.DefaultSchemaValidationTypeProvider)2 SchemaValidationFeature (org.apache.cxf.feature.validation.SchemaValidationFeature)2 Exchange (org.apache.cxf.message.Exchange)2 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)2 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)2 OperationInfo (org.apache.cxf.service.model.OperationInfo)2 Test (org.junit.Test)1