ADB Code uncompilable and with incorrect validations
----------------------------------------------------

                 Key: AXIS2-4975
                 URL: https://issues.apache.org/jira/browse/AXIS2-4975
             Project: Axis2
          Issue Type: Bug
          Components: adb
    Affects Versions: 1.5.4
         Environment: Win XP, jdk1.6.0_23, Axis2 1.5.4
            Reporter: Sami Nieminen


When generating ADB code with wsdl2java from using the helper mode (option -Eh) 
the generated code is in some cases uncompilable. Further the generated code is 
logically wrong. 

The problem with the compiling occurs if either minInclusive or minExclusive 
and maxInclusive or maxExclusive restrictions are used
Example

        <simpleType name="MaxNoOfHits">
                <restriction base="int">
                        <minInclusive value="10"></minInclusive>
                        <maxInclusive value="50"></maxInclusive>
                </restriction>
        </simpleType>

is producing following code:

public void setMaxNoOfHits(int param) throws Exception{

                                    if ( 10 <=  param  >= 50 ) {

                                        this.localMaxNoOfHits=param;

                                    }

                                    else {

                                        throw new ADBException();

                                    }

                               }

The line "if ( 10 <=  param  >= 50 ) {" won't compile due to a syntax error - 
the correct way to compile succesfully would be "if ( 10 <=  param  && param >= 
50 ) {"

The same line contains the logical bug - the value of the variable should be 
between 10 and 50 inclusive - but the validation of the max limit is expecting 
a value 
equal or over the value from the schema. Correct would be ( 10 <=  param  && 
param <= 50 ) {


Similar length validation exists for string variables where code like if "(  (0 
< param.length())  &&  (param.length() => 20)  ) {" is produced for a string 
restricted to have
length between 0 exclusive and 20 inclusive.

A way of fixing the compilation issue and the validation problem:

<xsl:when test="(@maxExFacet) or (@minExFacet) or (@maxInFacet) or 
(@minInFacet)">
                                    if (<xsl:if test="(@minExFacet)"> 
<xsl:value-of select="$minExFacet"/> &lt; </xsl:if> <xsl:if 
test="(@minInFacet)"> <xsl:value-of select="$minInFacet"/> &lt;= </xsl:if> 
                                        param <xsl:if test="((@minInFacet) or 
(@minExFacet)) and ((@minInFacet) or (@maxIntFacet))"> &amp;&amp; param 
</xsl:if>
                                        <xsl:if test="(@maxExFacet)"> &lt; 
<xsl:value-of select="$maxExFacet"/> </xsl:if> <xsl:if test="(@maxInFacet)"> 
&lt;= <xsl:value-of select="$maxInFacet"/> </xsl:if> ) {
                                        this.<xsl:value-of 
select="$varName"/>=param;
                                    }
                                    else {


--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to