Multipart data in AbstractPhaseInterceptor

2017-12-06 Thread narayanasgs
Hi,

I am creating a RESTful file upload using CXF. The method is crated as below
and I am able to test it from Fiddler and via a HTML form with
enctype='multipart/form-data'. 

I need to access one of these multipart data in the interceptor that
implements AbstractPhaseInterceptor with Phase.PRE_INVOKE. 

I tried using Apache Commons File upload 1.2.2 to read multipart data but
got this error: org.apache.commons.fileupload.FileUploadException: Stream
closed. 

Please help me with details of how to access any of these multipart
attributes like code, desc etc in interceptor.  


Web service method:
@POST
@Path("addAttachment")
@Consumes({MediaType.MULTIPART_FORM_DATA})
public int addAttachment(@Multipart(value = "id", type = "text/plain")
Integer ID,
@Multipart(value = "code", type = "text/plain") Integer 
code,
@Multipart(value = "desc", type = "text/plain") String 
desc,
MultipartBody multipartBody) throws WebServiceFault {
}

Thanks in advance. 



--
Sent from: http://cxf.547215.n5.nabble.com/cxf-user-f547216.html


Re: CXF 3.2.1 swagger generation are wrong for json

2017-12-06 Thread nino martinez wael
Yes I think so.. Although I have no proof it works on non osgi systems..

On Wed, 6 Dec 2017, 12:35 Sergey Beryozkin,  wrote:

> Hi Nino
>
> So it is a pure OSGI issue now, right ?
> Lets ask Christian as well, Christian, can you advise how to overcome
> this annotations issue ?
>
> Cheers, Sergey
> On 06/12/17 11:30, nino martinez wael wrote:
> > No change after getting the javax.xml.bind.annotation.. I can see I can
> > change how some of the interpretations are done when adding jackson
> > specific json annotations.. But it's still not correct. :(
> >
> > On Wed, Dec 6, 2017 at 7:07 AM, nino martinez wael
> > mailto:nino.martinez.w...@gmail.com>>
> wrote:
> >
> > Okay after adding swagger annotations as an export from my bundle.
> > The swagger json are now including whatever I describe in the
> > annotations. However the maven bundle plugin keeps removing my
> > export for javax.xml.bind.annotation and so I cannot test if this
> > also have an impact on swagger ignoring my javax.xml.bind.annotation
> > configurations, however it does seem logical.. Digging further.
> >
> >
> > regards Nino
> >
> > On Tue, Dec 5, 2017 at 8:07 AM, nino martinez wael
> > mailto:nino.martinez.w...@gmail.com>>
> > wrote:
> >
> > I've started testing that idea, and it seems to have an impact..
> > I will return once I know more!!
> >
> > Thanks!
> >
> > On Mon, Dec 4, 2017 at 5:08 PM, Sergey Beryozkin
> > mailto:sberyoz...@gmail.com>> wrote:
> >
> > CXF Swagger feature itself is not importing Swagger
> > annotations because it does not work with them, I'm not
> > sure, may be you need to have your application bundle
> > exporting the annotations to make the visible...
> >
> > Sergey
> > On 04/12/17 15:06, nino martinez wael wrote:
> >
> > No, no namespaces
> >
> > And I am still pussled on why it does not do it the
> > "right" way.. Currently I am experimenting putting in
> > io.swagger.annotations BUT they seem to have no effect
> > on the generated swagger describtion when placed in our
> > backend models, they are in another bundle, im wondering
> > if the swagger feature somehow are not able to read the
> > annotations across the bundles, that would very much
> > explain why its not working..?
> >
> > On Mon, Dec 4, 2017 at 11:46 AM, Sergey Beryozkin
> > mailto:sberyoz...@gmail.com>
> >  > >> wrote:
> >
> >  Nice,
> >  Just out of curiosity, what does Swagger set the
> > XML Object's
> >  namespace to ? Is it initialized ?
> >
> >  Sergey
> >
> >  On 04/12/17 06:03, nino martinez wael wrote:
> >
> >  Okay so I've looked into this a bit. And turned
> > the problem
> >  upside down. Instead of trying to make the cxf
> > swagger feature
> >  use jackson, just taking a look at the outcome
> > and play around
> >  trying to change it.. Again if there is any way
> > to see what the
> >  swagger feature plugin are using runtime to
> > process file with,
> >  it would very helpfull..
> >
> >  It seems that the swagger feature are partially
> > ignoring my
> >  annotations, so picking up @xmlrootelement but
> > partially
> >  ignoring the list annotations..
> >
> >  @XmlAccessorType(XmlAccessType.FIELD)
> >  @XmlRootElement(name = "contacts")
> >  public class MinimalContactWrapper {
> >
> >@XmlElementWrapper(name = "wrap")
> >@XmlElement(name = "minimalcontact")
> >private List contactList;
> >
> >public List
> > getMinimalContacts() {
> >return contactList;
> >}
> >
> >public void
> > setMinimalContacts(List
> >  minimalContacts) {
> >this.contactList = minimalContacts;
> >}
> >
> >  }
> >
> >
> >  to
> >
> >  @XmlAccessorType(XmlAccessType.FIELD)
> >  @XmlRootElement

Re: CXF 3.2.1 swagger generation are wrong for json

2017-12-06 Thread Sergey Beryozkin

Hi Nino

So it is a pure OSGI issue now, right ?
Lets ask Christian as well, Christian, can you advise how to overcome 
this annotations issue ?


Cheers, Sergey
On 06/12/17 11:30, nino martinez wael wrote:
No change after getting the javax.xml.bind.annotation.. I can see I can 
change how some of the interpretations are done when adding jackson 
specific json annotations.. But it's still not correct. :(


On Wed, Dec 6, 2017 at 7:07 AM, nino martinez wael 
mailto:nino.martinez.w...@gmail.com>> wrote:


Okay after adding swagger annotations as an export from my bundle.
The swagger json are now including whatever I describe in the
annotations. However the maven bundle plugin keeps removing my
export for javax.xml.bind.annotation and so I cannot test if this
also have an impact on swagger ignoring my javax.xml.bind.annotation
configurations, however it does seem logical.. Digging further.


regards Nino

On Tue, Dec 5, 2017 at 8:07 AM, nino martinez wael
mailto:nino.martinez.w...@gmail.com>>
wrote:

I've started testing that idea, and it seems to have an impact..
I will return once I know more!!

Thanks!

On Mon, Dec 4, 2017 at 5:08 PM, Sergey Beryozkin
mailto:sberyoz...@gmail.com>> wrote:

CXF Swagger feature itself is not importing Swagger
annotations because it does not work with them, I'm not
sure, may be you need to have your application bundle
exporting the annotations to make the visible...

Sergey
On 04/12/17 15:06, nino martinez wael wrote:

No, no namespaces

And I am still pussled on why it does not do it the
"right" way.. Currently I am experimenting putting in
io.swagger.annotations BUT they seem to have no effect
on the generated swagger describtion when placed in our
backend models, they are in another bundle, im wondering
if the swagger feature somehow are not able to read the
annotations across the bundles, that would very much
explain why its not working..?

On Mon, Dec 4, 2017 at 11:46 AM, Sergey Beryozkin
mailto:sberyoz...@gmail.com>
>> wrote:

     Nice,
     Just out of curiosity, what does Swagger set the
XML Object's
     namespace to ? Is it initialized ?

     Sergey

     On 04/12/17 06:03, nino martinez wael wrote:

         Okay so I've looked into this a bit. And turned
the problem
         upside down. Instead of trying to make the cxf
swagger feature
         use jackson, just taking a look at the outcome
and play around
         trying to change it.. Again if there is any way
to see what the
         swagger feature plugin are using runtime to
process file with,
         it would very helpfull..

         It seems that the swagger feature are partially
ignoring my
         annotations, so picking up @xmlrootelement but
partially
         ignoring the list annotations..

         @XmlAccessorType(XmlAccessType.FIELD)
         @XmlRootElement(name = "contacts")
         public class MinimalContactWrapper {

               @XmlElementWrapper(name = "wrap")
               @XmlElement(name = "minimalcontact")
               private List contactList;

               public List
getMinimalContacts() {
                   return contactList;
               }

               public void
setMinimalContacts(List
         minimalContacts) {
                   this.contactList = minimalContacts;
               }

         }


         to

         @XmlAccessorType(XmlAccessType.FIELD)
         @XmlRootElement(name ="contacts")
         public class MinimalContactWrapper {

               @XmlElementRef(name ="minimalContact")
               @Valid
         @NotNull
         @Size(min =1)
               private
ListminimalContacts=new ArrayList<>();

               public List
getMinimalContacts() {
                   return minimalContacts;
               }