Return-Path: X-Original-To: apmail-cxf-users-archive@www.apache.org Delivered-To: apmail-cxf-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 14989119DA for ; Mon, 21 Apr 2014 16:44:05 +0000 (UTC) Received: (qmail 42338 invoked by uid 500); 21 Apr 2014 16:44:03 -0000 Delivered-To: apmail-cxf-users-archive@cxf.apache.org Received: (qmail 42274 invoked by uid 500); 21 Apr 2014 16:44:03 -0000 Mailing-List: contact users-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@cxf.apache.org Delivered-To: mailing list users@cxf.apache.org Received: (qmail 42266 invoked by uid 99); 21 Apr 2014 16:44:02 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 21 Apr 2014 16:44:02 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of sberyozkin@gmail.com designates 74.125.82.182 as permitted sender) Received: from [74.125.82.182] (HELO mail-we0-f182.google.com) (74.125.82.182) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 21 Apr 2014 16:43:57 +0000 Received: by mail-we0-f182.google.com with SMTP id q59so772132wes.13 for ; Mon, 21 Apr 2014 09:43:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=6r1tgFVKDOdtWMFxUcsjW3NaiGLLNmW1Nxk7yp6o6zA=; b=DZT+tHHOk+6iK/F0mjeTtnox/DtJOfBWyhxAiwrpJgORTeQ2eECsKlaWseWxMgOCxy Fc2egqMYi+cA+B5WAkyehKzivI9JulHSxmhdHLex3CFXz1NqjS6+voeSjMpIfnEaJpmz 1nlTh/wCDWMzPda9CNI9SJWmHx7RUaZ98iXZeUqO7coH1AjFSwHi4HWTmHW2OqY6C2S+ 9FiNcvceGe4hwtw+aH152B90CfKvSqbomOkJl7EFWoDER5dFJvUDolxMEhTYWkZuvzlf gW8deUByBi+5dyVQM6VrMBUm8+DmMwZjCo8bMCgWXaiN5Lmn0gsC0aT0tvjwBwjB03iS ljig== X-Received: by 10.194.60.146 with SMTP id h18mr27170448wjr.26.1398098616561; Mon, 21 Apr 2014 09:43:36 -0700 (PDT) Received: from [192.168.2.7] ([89.100.139.33]) by mx.google.com with ESMTPSA id uc3sm17056145wib.10.2014.04.21.09.43.34 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 21 Apr 2014 09:43:35 -0700 (PDT) Message-ID: <53554AA3.1050801@gmail.com> Date: Mon, 21 Apr 2014 17:43:15 +0100 From: Sergey Beryozkin User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 To: users@cxf.apache.org Subject: Re: Content validation of JSON payloads in REST invokation. References: <534FB1D1.1040602@gmail.com> <534FB23B.7050801@gmail.com> <534FF02B.7020407@gmail.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org On 18/04/14 07:36, Pradeep Fernando wrote: > Thanks Sergey, writing a BadRequestException mapper did the trick... > > One last question. I want to map runtime exceptions to my custom json error > format. I did bit of debuggin, WebapplicationExceptionMapper does not get > in such situations... > > Actually i want to map all the exception types(any Throwable) which are not > mapped by any specific mapper using some generic mapper. Is this possible.. > ? Register a custom Throwable mapper and it will catch the exceptions Cheers, Sergey > > > thanks, > --Pradeep > > > On Thu, Apr 17, 2014 at 8:45 PM, Sergey Beryozkin wrote: > >> Custom WebApplicationException mapper will catch it and can check the >> cause, in CXF 2.7.11 you should be able to use JAX-RS 2.0 >> ClientErrorException or more specific BadRequestException mapper too >> >> Sergey >> >> On 17/04/14 16:03, Pradeep Fernando wrote: >> >>> Hi Sergey, >>> >>> Thanks a lot. It solved the issue. Now when i send an wrong input it >>> behaves correctly. spitting something similar to, >>> >>> JAXBException occurred : cvc-datatype-valid.1.2.1: '1pr' is not a valid >>> value for 'integer'.. cvc-datatype-valid.1.2.1: '1pr' is not a valid value >>> for 'integer' >>> >>> >>> However I want to return json formatted error message to my clients. I >>> tried engaging a exceptionMapper handler that handles JAXBException before >>> and after the JSONProvider handler. >>> But it fails to map the exception. >>> >>> During the databinding error scenario, the exception gets handled by >>> org.apache.cxf.jaxrs.provider.AbstractJAXBProvider#handleJaxbException >>> method it seems. >>> >>> your input is much appreciated.. >>> >>> thanks, >>> --Pradeep >>> >>> >>> >>> On Thu, Apr 17, 2014 at 4:21 PM, Sergey Beryozkin >>> wrote: >>> >>> And add xs:string type to name & value too >>>> >>>> Sergey >>>> >>>> On 17/04/14 11:49, Sergey Beryozkin wrote: >>>> >>>> Hi >>>>> On 17/04/14 11:04, Pradeep Fernando wrote: >>>>> >>>>> Hi Devs, >>>>>> >>>>>> I'm using CXF Jax-rs libs. Did some google searching on the $subject >>>>>> and >>>>>> since im using, >>>>>> >>>>>> org.apache.cxf.jaxrs.provider.json.JSONProvider, i made use of >>>>>> >>>>>> org.apache.cxf.jaxrs.utils.schemas.SchemaHandler to validate my input >>>>>> against my schema. >>>>>> >>>>>> I get an input similar, to, >>>>>> >>>>>> { >>>>>> "id": "AWSEC2AsiaPacificPartition1", >>>>>> "provider": "ec2", >>>>>> "property": [ >>>>>> { >>>>>> "name": "region", >>>>>> "value": "ap-southeast-1" >>>>>> } >>>>>> ], >>>>>> "partitionMin": "1", >>>>>> "partitionMax": "3" >>>>>> } >>>>>> >>>>>> I cant figure out how to model property array in xmlSchema without >>>>>> using a >>>>>> wrapping element. And it gives an error at the moment. >>>>>> >>>>>> The schema portion i use to validate the property array.. >>>>>> >>>>>> >>>>> maxOccurs="1"> >>>>>> >>>>>> >>>>>> >>>>> maxOccurs="unbounded"> >>>>>> >>>>>> >>>>>> >>>>> minOccurs="1" maxOccurs="1" nillable="false"/> >>>>>> >>>>> minOccurs="1" maxOccurs="1" nillable="false"/> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> Am i doing the correct thing, May be im missing a trivial thing. Is it >>>>>> possible at all. >>>>>> >>>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> Should probably do it >>>>> >>>>> Note, Bean Validation 1.1 is also supported in 3.0.0-milestone2 >>>>> >>>>> Cheers, Sergey >>>>> >>>>> >>>>> thanks in advance... >>>>>> --Pradeep >>>>>> >>>>>> >>>>>> >>>>> >>>>> >>>> >>>> >>> >>> >> >> -- >> Sergey Beryozkin >> >> Talend Community Coders >> http://coders.talend.com/ >> >> Blog: http://sberyozkin.blogspot.com >> > > >