Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-7547

Problem to generate Java from WADL file when method id defined

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 3.1.14, 3.2.1
    • 3.2.2, 3.1.15
    • JAX-RS
    • All Plataforms

    • Novice

    Description

      The following code base

      @Path("/baz")
      public class Baz {
      
      	@GET
      	@Path("/foo/{id}")
      	@Produces("text/plain")
      	public String get(@PathParam int id);
      
      }
      

      generates a similar wadl as follow as result of Java2Wadl process:

      <application xmlns="http://wadl.dev.java.net/2009/02" xmlns:xs="http://www.w3.org/2001/XMLSchema">
          <resources base="/baz" id="Baz">
              <resource path="/foo/{id}" id="get">
                  <param name="id" style="template" type="xs:int"/>
                  <method name="GET" id="get">
                      <response>
                          <representation mediaType="text/plain">
                              <param name="result" style="plain" type="xs:string"/>
                          </representation>
                      </response>
                  </method>
              </resource>
          </resources>
      </application>
      

      When we run after the Wadl2Java process against previous wadl as input, the process takes to the following java definition class as output:

      @Path("/baz")
      public class Baz {
      
      	@GET
      	@Path("/foo/{id}")
      	@Produces("text/plain")
      	public String getId(@PathParam int id);
      
      }
      

      According to tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/SourceGenerator.java a wadl method element generates the path as complement to the java method name when it does not have an id atribute or when it is the even value of name atribute.

      When id is not defined this behavior is right, but when both of atributes are defined in order to get the even class used to generate the wadl file as result of Wadl2Java process this is not.

      The solution to enable creating the even code is check if the id is present or not at wadl file as follow:

      	// Line 796 instead of this
              if (methodNameLowerCase.equals(genMethodName)) {
      	// this code
              if (methodNameLowerCase.equals(genMethodName) && methodNameLowerCase == id) {
      

      The above code check if methodNameLowerCase is the even reference of id, only in this case, the normal behavior is applied.

      Attachments

        Activity

          People

            sergey_beryozkin Sergey Beryozkin
            evaristowb Evaristo Wychoski Benfatti
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: