Thanks a lot Sergey..

On Mon, Apr 21, 2014 at 10:13 PM, Sergey Beryozkin <[email protected]>wrote:

> 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 <[email protected]
>> >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 <[email protected]
>>>>
>>>>> 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..
>>>>>>>
>>>>>>>                   <xs:element name="property" minOccurs="1"
>>>>>>> maxOccurs="1">
>>>>>>>                        <xs:complexType>
>>>>>>>                            <xs:sequence>
>>>>>>>                                <xs:element name="property"
>>>>>>> minOccurs="0"
>>>>>>> maxOccurs="unbounded">
>>>>>>>                                    <xs:complexType>
>>>>>>>                                        <xs:sequence>
>>>>>>>                                            <xs:element name="name"
>>>>>>> minOccurs="1" maxOccurs="1" nillable="false"/>
>>>>>>>                                            <xs:element name="value"
>>>>>>> minOccurs="1" maxOccurs="1" nillable="false"/>
>>>>>>>                                        </xs:sequence>
>>>>>>>                                    </xs:complexType>
>>>>>>>                                </xs:element>
>>>>>>>                            </xs:sequence>
>>>>>>>                        </xs:complexType>
>>>>>>>                    </xs:element>
>>>>>>>
>>>>>>>
>>>>>>> Am i doing the correct thing, May be im missing a trivial thing.  Is
>>>>>>> it
>>>>>>> possible at all.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>> <xs:element name="property" minOccurs="1" maxOccurs="unbounded">
>>>>>>       <xs:complexType>
>>>>>>           <xs:sequence>
>>>>>>              <xs:element name="name" nillable="false"/>
>>>>>>              <xs:element name="value" nillable="false"/>
>>>>>>           </xs:sequence>
>>>>>>      </xs:complexType>
>>>>>> </xs:element>
>>>>>>
>>>>>> 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
>>>
>>>
>>
>>
>>
>


-- 
Pradeep Fernando.
http://pradeepfernando.blogspot.com/

Reply via email to