Repository: cxf Updated Branches: refs/heads/cxf6118 0341657b5 -> 90c9e4cf0
forgot the new class Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/90c9e4cf Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/90c9e4cf Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/90c9e4cf Branch: refs/heads/cxf6118 Commit: 90c9e4cf080de7d5d3341dd4057456f767bdc5d2 Parents: 0341657 Author: Jason Pell <[email protected]> Authored: Thu Nov 27 18:25:55 2014 +1100 Committer: Jason Pell <[email protected]> Committed: Thu Nov 27 18:25:55 2014 +1100 ---------------------------------------------------------------------- .../AbstractDatabindingInterceptor.java | 68 ++++++++++++++++++++ 1 file changed, 68 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/90c9e4cf/api/src/main/java/org/apache/cxf/interceptor/AbstractDatabindingInterceptor.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/org/apache/cxf/interceptor/AbstractDatabindingInterceptor.java b/api/src/main/java/org/apache/cxf/interceptor/AbstractDatabindingInterceptor.java new file mode 100644 index 0000000..2db27ea --- /dev/null +++ b/api/src/main/java/org/apache/cxf/interceptor/AbstractDatabindingInterceptor.java @@ -0,0 +1,68 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.cxf.interceptor; + +import org.apache.cxf.annotations.SchemaValidation.SchemaValidationType; +import org.apache.cxf.helpers.ServiceUtils; +import org.apache.cxf.message.Message; +import org.apache.cxf.phase.AbstractPhaseInterceptor; +import org.apache.cxf.service.model.EndpointInfo; +import org.apache.cxf.service.model.OperationInfo; + +public abstract class AbstractDatabindingInterceptor extends AbstractPhaseInterceptor<Message> { + public AbstractDatabindingInterceptor(String phase) { + super(phase); + } + + public AbstractDatabindingInterceptor(String id, String phase) { + super(id, phase); + } + + protected boolean isRequestor(Message message) { + return Boolean.TRUE.equals(message.containsKey(Message.REQUESTOR_ROLE)); + } + + protected void setOperationSchemaValidation(EndpointInfo ep, OperationInfo opInfo, Message message) { + SchemaValidationType validationType = null; + + // look for a message override property before going any further + // note this is not a a getContextProperty call, as we need to know + // if it was just a simple Endpoint Properties entry, rather than stuff loaded from + // the EndpointInfo Properties. + Object obj = message.get(Message.SCHEMA_VALIDATION_ENABLED); + if (obj != null) { + // this method will transform the legacy enabled as well + validationType = ServiceUtils.getSchemaValidationType(obj); + } + + if (validationType == null && opInfo != null) { + validationType = ServiceUtils.getSchemaValidationType(opInfo); + + // else fall back to endpoint level schema validation + if (validationType == null && ep != null) { + validationType = ServiceUtils.getSchemaValidationType(ep); + } + } + + if (validationType != null) { + message.put(Message.SCHEMA_VALIDATION_ENABLED, validationType); + } + } +}
