Search in sources :

Example 1 with SchemaValidationType

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

the class ServiceUtils method getSchemaValidationTypeFromModel.

private static SchemaValidationType getSchemaValidationTypeFromModel(Message message) {
    Exchange exchange = message.getExchange();
    SchemaValidationType validationType = null;
    if (exchange != null) {
        BindingOperationInfo boi = exchange.getBindingOperationInfo();
        if (boi != null) {
            OperationInfo opInfo = boi.getOperationInfo();
            if (opInfo != null) {
                validationType = getSchemaValidationTypeFromModel(opInfo);
            }
        }
        if (validationType == null) {
            Endpoint endpoint = exchange.getEndpoint();
            if (endpoint != null) {
                EndpointInfo ep = endpoint.getEndpointInfo();
                if (ep != null) {
                    validationType = getSchemaValidationTypeFromModel(ep);
                }
            }
        }
    }
    return validationType;
}
Also used : Exchange(org.apache.cxf.message.Exchange) OperationInfo(org.apache.cxf.service.model.OperationInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) Endpoint(org.apache.cxf.endpoint.Endpoint) SchemaValidationType(org.apache.cxf.annotations.SchemaValidation.SchemaValidationType)

Example 2 with SchemaValidationType

use of org.apache.cxf.annotations.SchemaValidation.SchemaValidationType in project cxf 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 3 with SchemaValidationType

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

the class ServiceUtils method getSchemaValidationTypeFromModel.

private static SchemaValidationType getSchemaValidationTypeFromModel(Message message) {
    Exchange exchange = message.getExchange();
    SchemaValidationType validationType = null;
    if (exchange != null) {
        BindingOperationInfo boi = exchange.getBindingOperationInfo();
        if (boi != null) {
            OperationInfo opInfo = boi.getOperationInfo();
            if (opInfo != null) {
                validationType = getSchemaValidationTypeFromModel(opInfo);
            }
        }
        if (validationType == null) {
            Endpoint endpoint = exchange.getEndpoint();
            if (endpoint != null) {
                EndpointInfo ep = endpoint.getEndpointInfo();
                if (ep != null) {
                    validationType = getSchemaValidationTypeFromModel(ep);
                }
            }
        }
    }
    return validationType;
}
Also used : Exchange(org.apache.cxf.message.Exchange) OperationInfo(org.apache.cxf.service.model.OperationInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) Endpoint(org.apache.cxf.endpoint.Endpoint) SchemaValidationType(org.apache.cxf.annotations.SchemaValidation.SchemaValidationType)

Example 4 with SchemaValidationType

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

the class AbstractOutDatabindingInterceptor method setOperationSchemaValidation.

protected void setOperationSchemaValidation(Message message) {
    SchemaValidationType validationType = ServiceUtils.getSchemaValidationType(message);
    message.put(Message.SCHEMA_VALIDATION_ENABLED, validationType);
}
Also used : SchemaValidationType(org.apache.cxf.annotations.SchemaValidation.SchemaValidationType)

Example 5 with SchemaValidationType

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

the class AbstractInDatabindingInterceptor method setOperationSchemaValidation.

protected void setOperationSchemaValidation(Message message) {
    SchemaValidationType validationType = ServiceUtils.getSchemaValidationType(message);
    message.put(Message.SCHEMA_VALIDATION_ENABLED, validationType);
}
Also used : SchemaValidationType(org.apache.cxf.annotations.SchemaValidation.SchemaValidationType)

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