Return-Path: X-Original-To: apmail-wicket-users-archive@minotaur.apache.org Delivered-To: apmail-wicket-users-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 029521951D for ; Thu, 28 Apr 2016 08:31:38 +0000 (UTC) Received: (qmail 86895 invoked by uid 500); 28 Apr 2016 08:31:37 -0000 Delivered-To: apmail-wicket-users-archive@wicket.apache.org Received: (qmail 86841 invoked by uid 500); 28 Apr 2016 08:31:37 -0000 Mailing-List: contact users-help@wicket.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@wicket.apache.org Delivered-To: mailing list users@wicket.apache.org Received: (qmail 86829 invoked by uid 99); 28 Apr 2016 08:31:37 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 28 Apr 2016 08:31:37 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id B45BBC01D6 for ; Thu, 28 Apr 2016 08:31:36 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.179 X-Spam-Level: * X-Spam-Status: No, score=1.179 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd1-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id 84EisM3pjj69 for ; Thu, 28 Apr 2016 08:31:35 +0000 (UTC) Received: from mail-ob0-f180.google.com (mail-ob0-f180.google.com [209.85.214.180]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id C22B85F23E for ; Thu, 28 Apr 2016 08:31:34 +0000 (UTC) Received: by mail-ob0-f180.google.com with SMTP id x1so15452147obt.0 for ; Thu, 28 Apr 2016 01:31:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to; bh=s97mnBrM65RWJiRWw+9uVk0UUV16g8fXQUb5qDy+w7M=; b=GDoGwVYYsM0L3jH/p6VkFE5L+xNDffaewOnf3UmaiHkbisuiNdFCL7SIDfNoUDyv/o 4cSCuyVaPj9AbZuoupoVOdP5pWwHBJDV45DP4KvwrbJfn6eT5sKXCEw7Uq9IXjJvMJlJ 8+69REgfw0upgUG0DUVbOgee43fWvvFHwxca/ZytTmGcDvSAZ4/JWBcr9oG9qlIX6DG5 xCqgW3/doOyH4Ymu0pwsKfc4hmkckt8UirhM37UKnc5DY5Near09eEujZpic0u9jVuho IZ6IARJO6SAN+w6Pxn6l3+MVqBcpJt6iNsfn9VPlNT4kY7X/vuZDx7WI21SLej3Z7yaC qPRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to; bh=s97mnBrM65RWJiRWw+9uVk0UUV16g8fXQUb5qDy+w7M=; b=ge/JCWKPDcQZCMmqYpPI3ydxpO1GD3FOSSmZ8WgbS9+YHeF1LY1qoQv7aoOV6uKpHu gcU5Bzgo80NK+n5KLpBFrxHnLTNecPrpWb2YfMo4EYW7EwwzCAzugUVIXfXWrvJ+q3u1 +xRjNoAPLp+wnJnF2h52tWV/WJ37ulivQpLkRn5Ybo296si7BBIR0tDDrcgp7Ei9W4H/ jz0Ux7ccgNzNw3n9C2nV3OpI8gqV8HFp5XAlQlwQZakOLWvlpxjWX18PwYUbM3HKW4GK 43lL862UFFE04EqCd0q5upw/rPRMUds0CtmE5V8qrm3zmOC4ZVN0rBvfI1XHJZMQz3++ oF6A== X-Gm-Message-State: AOPr4FXnxpUT6UEUr60H2j9X8lyT1DdFOji16txjqTnJjnwKty8aTrZYRWQ+QyuWbjiuxXW5WLp3hAWBIxUEsQ== MIME-Version: 1.0 X-Received: by 10.60.1.33 with SMTP id 1mr6063408oej.42.1461832288192; Thu, 28 Apr 2016 01:31:28 -0700 (PDT) Received: by 10.202.175.18 with HTTP; Thu, 28 Apr 2016 01:31:28 -0700 (PDT) In-Reply-To: References: Date: Thu, 28 Apr 2016 10:31:28 +0200 Message-ID: Subject: Re: [wicketstuff-restannotations] AbstractRestResource.toObject makes it impossible for mapped methods to know a parameter conversion went wrong. From: Fabio Fioretti To: users@wicket.apache.org Content-Type: multipart/alternative; boundary=e89a8fb1f9da4250500531875aee --e89a8fb1f9da4250500531875aee Content-Type: text/plain; charset=UTF-8 Hi Martin, Thanks, I agree - findOffices() shouldn't be executed at all. In fact, handleMethodExecution() returns before invoking application code in all other cases (step 1 for unauthorized access, step 3 for validation errors). Any chance to have it fixed relatively soon? (maybe Andrea can answer this) Kind regards, Fabio On Thu, Apr 28, 2016 at 6:44 AM, Martin Grigorov wrote: > Hi, > > > On Wed, Apr 27, 2016 at 12:07 PM, Fabio Fioretti < > windom.macrosorch@gmail.com> wrote: > > > Hi all, > > > > Please consider the following simple implementation of > AbstractRestResource > > (6.22.0): > > > > @ResourcePath("/rest/api") > > public class MyRestResource extends > > AbstractRestResource > > { > > > > public MyRestResource () > > { > > super(new JsonWebSerialDeserial(new GsonObjectSerialDeserial())); > > } > > > > @MethodMapping(value = "/offices") > > public List findOffices( > > @RequestParam(value = "region", required = false) Integer regionId) > > { > > return findOfficesByRegion(regionId); > > } > > } > > > > My question relates to the findOffices method and its filtering regionId > > parameter when the value is not a valid integer. For example, consider > the > > request 'GET /rest/api/offices?region=AA'. > > > > At the second step of AbstractRestResource.handleMethodExecution, > > extractMethodParameters is invoked, which in turn triggers the conversion > > of all parameters through the static method toObject. > > > > When the conversion goes wrong and ConversionException is thrown, > toObject > > catches it, sets the response status to 400 and returns null! > > > > Now, when my findOffices is finally executed, I get a null regionId but I > > don't know whether it was not valid or the parameter was not present at > > all. Checking the response status downstream is also particularly hard > > because I have no getStatus (Tomcat 6 here, ouch!). > > > > To my mind, findOffices should return null instead of the unfiltered list > > of offices if the conversion went wrong, even because the response > > status is 400 (as set by toObject). However, how can I know it? > > > > Any suggestions? > > > > IMO this is a bug in the library. > #findOffices() should not be executed at all. > A response with status code 400 should be returned immediately after the > unsuccessful convention without giving a chance to the application code to > be executed. > > > > > Many thanks, > > Fabio > > > --e89a8fb1f9da4250500531875aee--