[jbosstools-issues] [JBoss JIRA] (JBIDE-18823) Invalid generated code in JAX-RS Endpoint
Marián Labuda (JIRA)
issues at jboss.org
Thu Nov 27 04:40:39 EST 2014
[ https://issues.jboss.org/browse/JBIDE-18823?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Marián Labuda updated JBIDE-18823:
----------------------------------
Labels: jax-rs (was: )
> Invalid generated code in JAX-RS Endpoint
> -----------------------------------------
>
> Key: JBIDE-18823
> URL: https://issues.jboss.org/browse/JBIDE-18823
> Project: Tools (JBoss Tools)
> Issue Type: Bug
> Components: webservices
> Affects Versions: 4.2.0.Final
> Reporter: Xavier Coulon
> Assignee: Xavier Coulon
> Labels: jax-rs
> Fix For: 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