Return-Path: X-Original-To: apmail-cxf-commits-archive@www.apache.org Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 08CD810B21 for ; Thu, 27 Nov 2014 07:26:28 +0000 (UTC) Received: (qmail 3404 invoked by uid 500); 27 Nov 2014 07:26:28 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 3345 invoked by uid 500); 27 Nov 2014 07:26:27 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 3336 invoked by uid 99); 27 Nov 2014 07:26:27 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 27 Nov 2014 07:26:27 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 68C0F948A43; Thu, 27 Nov 2014 07:26:27 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jpell@apache.org To: commits@cxf.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: cxf git commit: forgot the new class Date: Thu, 27 Nov 2014 07:26:26 +0000 (UTC) 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 Authored: Thu Nov 27 18:25:55 2014 +1100 Committer: Jason Pell 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 { + 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); + } + } +}