[jbosstools-issues] [JBoss JIRA] (JBIDE-18710) Invalid generated code in JAX-RS Endpoint

Xavier Coulon (JIRA) issues at jboss.org
Mon Nov 24 10:42:40 EST 2014


    [ https://issues.jboss.org/browse/JBIDE-18710?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13022410#comment-13022410 ] 

Xavier Coulon commented on JBIDE-18710:
---------------------------------------

[~mlabuda],

Are you OK with adding a fix for this issue in 4.2.1.Final ? 

Thanks

> Invalid generated code in JAX-RS Endpoint
> -----------------------------------------
>
>                 Key: JBIDE-18710
>                 URL: https://issues.jboss.org/browse/JBIDE-18710
>             Project: Tools (JBoss Tools)
>          Issue Type: Bug
>          Components: webservices
>    Affects Versions: 4.2.0.Final
>            Reporter: Xavier Coulon
>            Assignee: Xavier Coulon
>             Fix For: 4.2.1.Final, 4.3.0.Alpha1
>
>
> The generated code in the 'create' method contains something like this:
> {code}
> return Response.created(
>   UriBuilder.fromResource(Session.class)
>   .path(String.valueOf(session.getId())).build()).build();
> {code}
> but the {{Session.class}} should be {{SessionEndpoint.class}} since it must be the resource class annotated with {{@Path}}
> Also, after discussion with [~maxandersen], here the plan to fix this issue:
> - if the {{create}} method generation is selected and the target entity is selected and contains a 'getId()' method, then generate the following method body:
> {code}
> //TODO: process the given pojo 
> // here we use Pojo#getId(), assuming it provides the end-user with the identifier to retrieve the created Pojo resource
> Response.created(UriBuilder.fromResource(PojoEndpoint.class).path(String.valueOf(pojo.getId())).build())
> 				.build();
> {code}
> - if the {{create}} method generation is selected and the target entity is selected and *does not contain* a 'getId()' method, then generate the following method body:
> {code}
> //TODO: process the given pojo 
> // you may want to do something like this
> // return Response.created(UriBuilder.fromResource(PojoEndpoint.class).path(String.valueOf(pojo.getId())).build();
> // assuming that Pojo#getId() or a similar method would provide the end-user with the identifier to retrieve the created Pojo resource
> Response.created(null).build();
> {code}
> If no target entity is provided, there is no way to generate the method skeletons.
> The goal if this change is to make sure we generate code that compiles (that was not the case if the target entity class did not have a {{getId()}} method) and that returns a sensitive Response object (hence, we don't return {{null}}).



--
This message was sent by Atlassian JIRA
(v6.3.8#6338)


More information about the jbosstools-issues mailing list