hstaudacher / osgi-jax-rs-connector

An OSGi - JAX-RS 2.0 Connector, software repository available on the link below
http://hstaudacher.github.io/osgi-jax-rs-connector
Other
190 stars 98 forks source link

No Support for @FormDataParam annotation #38

Closed anujbhatia closed 10 years ago

anujbhatia commented 10 years ago

There is no support for Multi-Part requests using the @FormDataParam annotation.

This does not work:

Interface:

@Path("/jobs")
public interface JobsManager {

    @POST
    @Path("/new")
    @Consumes(MediaType.MULTIPART_FORM_DATA)
    public abstract Response create(@FormDataParam("inputFile")
              String projectDescription);
}

Publisher:

 publisher.publishConsumers( baseUrl, 
                                new Class<?>[] { JobsManager.class }, 
                                new Object[] {  });

Caller:

String projDesc = "...";
JobsManager jobsMgr = bundleContext.getService( ... );
jobsMgr.create(projDesc);

This works:

Interface:

@Path("/jobs")
public interface JobsManager {

    @POST
    @Path("/new")
    @Consumes(MediaType.MULTIPART_FORM_DATA)
    public abstract Response create(FormDataMultiPart 
                     projectDescription);
}

Publisher:

 publisher.publishConsumers( baseUrl, 
                                new Class<?>[] { JobsManager.class }, 
                                new Object[] { new MultiPartFeature() });

Caller:

String projDesc = "...";
JobsManager jobsMgr = bundleContext.getService( ... );
FormDataMultiPart formData = new FormDataMultiPart();
formData.field("inputFile", projDesc, MediaType.TEXT_PLAIN_TYPE);
jobsMgr.create(formData);
hstaudacher commented 10 years ago

Alright, you are talking about the cunsomer, right? It seems that the @FormDataParam is not read in the RequestConfigurer, see https://github.com/hstaudacher/osgi-jax-rs-connector/blob/master/bundles/com.eclipsesource.jaxrs.consumer/src/com/eclipsesource/jaxrs/consumer/internal/RequestConfigurer.java

The next weeks I will not find time to fix it, so you need to wait for the next release (maybe in march) or fix it yourself and open a pull request ;)

hstaudacher commented 10 years ago

Fixed with the merge of Pull Request #39