cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Evaristo Wychoski Benfatti (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (CXF-7547) Problem to generate Java from WADL file when method id defined
Date Wed, 08 Nov 2017 18:26:00 GMT

    [ https://issues.apache.org/jira/browse/CXF-7547?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16244469#comment-16244469
] 

Evaristo Wychoski Benfatti edited comment on CXF-7547 at 11/8/17 6:25 PM:
--------------------------------------------------------------------------

The id never is empty because of 

{code:java}
    // Line 720
    String id = getMethodId(methodEl, methodNameLowerCase);

    ...

    // Line 845
    private String getMethodId(Element methodEl, String methodNameLowerCase) {
        String id = methodEl.getAttribute("id");
        if (id.length() == 0) {
            id = methodNameLowerCase;
        }
        return id;
    }
{code}

As you can see, the id is the wadl attribute or in case that this is empty it is the methodNameLowerCase
itself.

What it was proposed is to check if id is the same methodNameLowerCase reference returned
by the method calling. If it is the same, this means that there isn't any id attribute in
the wald, otherwise, id won't be the same reference. 

But if you think that it is a quite weird to read, we could do something like:

{code:java}
    // Line 720
    String id = getMethodId(methodEl, methodNameLowerCase);
    boolean wadlIdIsNotPresent = id == methodNameLowerCase;

    ...

    // Line 796
    if (methodNameLowerCase.equals(genMethodName) && wadlIdIsNotPresent) {
{code}

What do you think?



was (Author: evaristowb):
The id never is empty because of 

{code:java}
    // Line 720
    String id = getMethodId(methodEl, methodNameLowerCase);

    ...

    // Line 845
    private String getMethodId(Element methodEl, String methodNameLowerCase) {
        String id = methodEl.getAttribute("id");
        if (id.length() == 0) {
            id = methodNameLowerCase;
        }
        return id;
    }
{code}

As you can see, the id is the wadl attribute or in case that this is empty it is the methodNameLowerCase
itself.

What it was proposed is to check if id is the same methodNameLowerCase reference returned
by the method calling. If it is the same, this means that there isn't any id attribute in
the wald, otherwise, id won't be the same reference. 

But if you think that it is a quite weird to read, we could do something like:

{code:java}
    // Line 720
    String id = getMethodId(methodEl, methodNameLowerCase);
    boolean wadlIdIsNotPresent = id != methodNameLowerCase;

    ...

    // Line 796
    if (methodNameLowerCase.equals(genMethodName) && wadlIdIsNotPresent) {
{code}

What do you think?


> Problem to generate Java from WADL file when method id defined 
> ---------------------------------------------------------------
>
>                 Key: CXF-7547
>                 URL: https://issues.apache.org/jira/browse/CXF-7547
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>    Affects Versions: 3.1.14, 3.2.1
>         Environment: All Plataforms
>            Reporter: Evaristo Wychoski Benfatti
>            Priority: Minor
>              Labels: patch
>
> The following code base
> {code:java}
> @Path("/baz")
> public class Baz {
> 	@GET
> 	@Path("/foo/{id}")
> 	@Produces("text/plain")
> 	public String get(@PathParam int id);
> }
> {code}
> generates a similar wadl as follow as result of {{Java2Wadl}} process:
> {code:xml}
> <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>
> {code}
> When we run after the {{Wadl2Java}} process against previous wadl as input, the process
takes to the following java definition class as output:
> {code:java}
> @Path("/baz")
> public class Baz {
> 	@GET
> 	@Path("/foo/{id}")
> 	@Produces("text/plain")
> 	public String getId(@PathParam int id);
> }
> {code}
> 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:
> {code:java}
> 	// Line 796 instead of this
>         if (methodNameLowerCase.equals(genMethodName)) {
> 	// this code
>         if (methodNameLowerCase.equals(genMethodName) && methodNameLowerCase
== id) {
> {code}
> The above code check if methodNameLowerCase is the even reference of id, only in this
case, the normal behavior is applied.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message