5 Replies Latest reply on Apr 8, 2016 2:14 PM by PeeZu

    Handler parameter type BOOLEAN not supported

    PeeZu

      Hello,

       

      When I try to define an module handler parameter type in BOOLEAN, the HTTP 500 occur with the error: java.lang.IllegalArgumentException: java.lang.Boolean is not supported

       

      Version: ORDS 3.0.4

       

      It is supported or not ?

        • 1. Re: Handler parameter type BOOLEAN not supported
          Kiran Pawar

          Hi PeeZu,

          PeeZu wrote:

           

          When I try to define an module handler parameter type in BOOLEAN, the HTTP 500 occur with the error: java.lang.IllegalArgumentException: java.lang.Boolean is not supported

          Version: ORDS 3.0.4

          It is supported or not ?

               The ORDS 3.0 documentation says the parameter type of BOOLEAN is supported.

               Refer: https://docs.oracle.com/cd/E56351_01/doc.30/e56293/ords_ref.htm#sthref120 (See the p_param_type description in ORDS.DEFINE_PARAMETER)

           

          Regards,

          Kiran

          • 2. Re: Handler parameter type BOOLEAN not supported
            Kris Rice-Oracle

            Keep in mind using ORDS.DEFINE_PARAMETER is part of ORDS 3.x.  This means using either SQL Developer or the PL/SQL APIs directly and not using the screens inside APEX

            • 3. Re: Handler parameter type BOOLEAN not supported
              PeeZu

              Hi Kris,

               

               

              I use ORDS 3.0.4 and parameter is define by the PL/SQL API, try out the following example:

               

              DECLARE

               

                l_module       VARCHAR2(100);

                l_resource     VARCHAR2(100);

               

              BEGIN

               

                l_module := 'module';

               

                -- delete all REST services and disable REST services for this schema

                ords.drop_rest_for_schema();

               

                -- enable REST for this schema

                ords.enable_schema();

               

                -------------------------------------------------------------------------------------------------

               

                -- define module

                ords.define_module(p_module_name    => l_module,

                                   p_base_path      => '/',

                                   p_items_per_page => 0,

                                   p_status         => 'PUBLISHED',

                                   p_comments       => NULL);

               

                -------------------------------------------------------------------------------------------------

                l_resource := 'boolean/';

               

                -- define resource template   

                ords.define_template(p_module_name => l_module,

                                     p_pattern     => l_resource,

                                     p_priority    => 0,

                                     p_etag_type   => 'NONE',

                                     p_etag_query  => NULL,

                                     p_comments    => NULL);

               

                -- define resource handler

                ords.define_handler(p_module_name    => l_module,

                                    p_pattern        => l_resource,

                                    p_method         => 'GET',

                                    p_source_type    => ords.source_type_plsql,

                                    p_source         => q'[BEGIN

                                                             :boolean := true;

                                                           END;]',

                                    p_items_per_page => 0,

                                    p_mimes_allowed  => NULL,

                                    p_comments       => NULL);

               

              -- define resource handler parameter

                ords.define_parameter(p_module_name        => l_module,

                                      p_pattern            => l_resource,

                                      p_method             => 'GET',

                                      p_name               => 'foo',

                                      p_bind_variable_name => 'boolean',

                                      p_source_type        => 'RESPONSE',

                                      p_param_type         => 'BOOLEAN',

                                      p_access_method      => 'OUT',

                                      p_comments           => NULL);

               

                COMMIT;

               

              END;

              /

               

              My result is always: InternalServerException [statusCode=500, reasons=[An unexpected error with the following message occurred: java.lang.Boolean is not supported]]

               

              What's wrong with my declaration ?

               

              Regards

              • 4. Re: Handler parameter type BOOLEAN not supported
                Kris Rice-Oracle

                I wish all question came with complete test cases !

                 

                There is indeed a bug here.  We'll get it fixed as soon as we can.  In the meantime, you'll have to do a boolean to varchar.  There is a nice/easy helper to do this for you

                 

                Change your source to this:

                     :boo := sys.diutil.bool_to_int(TRUE);

                 

                Then the OUT param to string

                                        p_param_type         => 'STRING',

                 

                -kris

                • 5. Re: Handler parameter type BOOLEAN not supported
                  PeeZu

                  Thanks for the response.

                   

                  Of course casting to string resolve this issue, but JSON response won't be as boolean:

                   

                  Expected: {"foo":true}

                   

                  Got: {"foo":"1"}

                   

                  I'll wait for the fix.

                   

                  Regards.