CORS support in servlet

2016-03-09 Thread Patrick Valsecchi
Hi,

I'm trying to have CORS working with with the REST DSL (I'm actually using
XML) in a servlet context (to run under tomcat).

I've put enableCORS="true" at the  level and in all my  and 
elements. That seems to work fine as long as I only do GET and PUT queries.
The problem is that web clients have to do OPTIONS queries when some
criteria are not met. And OPTIONS queries are not returning the required
headers (Access-Control-Allow-Origin and Access-Control-Allow-Methods
mainly). I just have a weird Allow header.

After trying to add an  section in my  section to handle
that manually, I've quickly figured out that they where never called. Then
I've looked at the code and seen that CamelServlet.service is directly
handling the OPTIONS query and is never forwarding them to the consumer. So
it seems it's impossible to properly handling CORS queries with my setup.

Am I doing something wrong? Is there another solution?

Thanks for your help.


Re: Set Header using xpath

2016-03-09 Thread krish_p
Hi Claus,

My XML has a namespace without a prefix.

Is that causing the issue then?







--
View this message in context: 
http://camel.465427.n5.nabble.com/Set-Header-using-xpath-tp5778202p5778761.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Unexpected shutdow of the Camel context

2016-03-09 Thread ursouca
Dears,

I think I found the culprit.
I did not mentioned that in the same application,we are using also
Spring-Batch runtime (through JSR API). The Spring context of the
Spring-Batch is inheriting of a common shared context to allow the usage of
some bean in the jobs definition. But since we are using Camel (part of
share context), when a job is starts it seems to try  to start again Camel
(not really a problem) but when it stops it seems ti unload its own context
and raise an 'ContextClosedEvent' event that is processed by the
CamelContext class and shutdown Camel. From this moment Camel is available
during the run of Jobs!

If somebody has this kind of configuration and it does have this kind of
issue. I am interested in their configuration. Not directly an Camel issue.
But in there is a way that Came can to filter some event base on their
source it could help.

The event looks like :
/2016-03-09 10:42:16,210|.kernel.Default (self-tuning)'|
   
||| INFO
[org.springframework.batch.core.jsr.configuration.xml.JsrXmlApplicationContext:960]
Closing
org.springframework.batch.core.jsr.configuration.xml.JsrXmlApplicationContext@413a14cc:
startup date [Wed Mar 09 10:42:15 CET 2016]; parent: ApplicationContext
'baseContext' 
2016-03-09 10:42:16,210|.kernel.Default (self-tuning)'| 
  
|||DEBUG [org.apache.camel.spring.SpringCamelContext:130]
onApplicationEvent:
*org.springframework.context.event.ContextClosedEvent[source=org.springframework.batch.core.jsr.configuration.xml.JsrXmlApplicationContext@413a14cc:
startup date [Wed Mar 09 10:42:15 CET 2016]; parent: ApplicationContext
'baseContext'] *
2016-03-09 10:42:16,211|.kernel.Default (self-tuning)'| 
  
||| INFO [org.apache.camel.spring.SpringCamelContext:3023]
Apache Camel 2.16.2 (CamelContext: sep-eval-camel-service) is shutting down
/

Tx,
Cataldo



--
View this message in context: 
http://camel.465427.n5.nabble.com/Unexpected-shutdow-of-the-Camel-context-tp5778699p5778770.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Camel XMLRPC dateTime.iso8601 format.

2016-03-09 Thread Gregoire Autric
hi, Nunzio

which camel component has been involved ? (
http://camel.apache.org/xmlrpc.html ?)
Could you copy/paste your error too ?

by advance, thx

Best Regards, Bien à vous,  どうぞお元気で,

Greg AUTRIC
- JBoss Middleware Consultant -

On Tue, Mar 8, 2016 at 5:34 PM, Palmentieri Nunzio <
nunzio.palmenti...@eng.it> wrote:

> Hi,
> I'm trying to use XMLRPC over apache Camel.
>
> I succeeded in getting response from xmlrpc server, but I got an error
> When trying to receive a date field in the following format:
>
> 
>   startDate
>   
> 20160301T12:00:00+
>   
> 
>
> Any suggestion?
>
> Thanks a lot
>
>
> Nunzio Palmentieri
>
> Engineering Ingegneria Informatica S.p.A.
> Via Emanuele Gianturco, 15 - 80142 Napoli
> Tel.+39 0816103388
> Mob. +39 3351214806
> www.eng.it
>
> This electronic message contains information from Engineering Ingegneria
> Informatica S.p.A., which may be privileged and confidential. The
> information is intended to be use of the individual(s) or entity named
> above. If you are not the intended recipient, be aware that any disclosure,
> copying, distribution or use of the contents of this information is
> prohibited.
>
>
>


Re: bean parameter binding

2016-03-09 Thread Gregoire Autric
Hi Minh,

it is be an improvement that Camel could implements
Coud you please rise a JIRA for it ?

Camel team will check it too.

https://issues.apache.org/jira/browse/CAMEL


thx for this topic

Best Regards, Bien à vous,  どうぞお元気で,

Greg AUTRIC
- JBoss Middleware Consultant -


On Tue, Mar 8, 2016 at 11:21 PM, Minh Tran  wrote:

> Hello
>
> I’m using camel 2.16.2 and I’m finding the bean parameter binding doesn’t
> seem to work very well on overloaded methods. See below for an example
>
> public class ClassA {
> public int foo() {
> return 0;
> }
>
> public int foo(String param1) {
> return 1;
> }
>
> public int foo(String param1, String param2) {
> return 2;
> }
>
> public int foo(String param1, ClassB param2) {
> return 3;
> }
>
> public int foo(boolean param1, String param2) {
> return 4;
> }
> }
>
> public class ClassB {
>
> }
>
> Here are the routes
>
> from("direct:noParam").bean(ClassA.class, "foo()").to("mock:end");
> from("direct:1Param").bean(ClassA.class, "foo(${body})").to("mock:end");
> from("direct:2Param").bean(ClassA.class, "foo(${body},
> ${header.key})").to("mock:end”);
>
> And here are the tests
>
> @EndpointInject(uri = "mock:end")
> private MockEndpoint end;
>
> @Produce
> private ProducerTemplate producerTemplate;
>
> @Test
> // passes
> public void testNoParam() throws InterruptedException {
> end.expectedBodiesReceived(0);
> producerTemplate.sendBodyAndHeader("direct:noParam",
> "body", "key", "value");
> end.assertIsSatisfied();
> }
>
> @Test
> // passes
> public void test1Param() throws InterruptedException {
> end.expectedBodiesReceived(1);
> producerTemplate.sendBodyAndHeader("direct:1Param",
> "body", "key", "value");
> end.assertIsSatisfied();
> }
>
> @Test
> // throws ambiguous method call exception
> public void test2Param_string() throws InterruptedException {
> end.expectedBodiesReceived(2);
> producerTemplate.sendBodyAndHeader("direct:2Param",
> "body", "key", "value");
> end.assertIsSatisfied();
> }
>
> @Test
> // throws ambiguous method call exception
> public void test2Param_classB() throws InterruptedException {
> end.expectedBodiesReceived(3);
> producerTemplate.sendBodyAndHeader("direct:2Param",
> "body", "key", new ClassB());
> end.assertIsSatisfied();
> }
>
> @Test
> // passes
> public void test2Param_boolBody() throws InterruptedException {
> end.expectedBodiesReceived(4);
> producerTemplate.sendBodyAndHeader("direct:2Param", true,
> "key", "value");
> end.assertIsSatisfied();
> }
>
>
> I don’t understand why test2Param_string and test2Param_classB throw
> ambiguous call exceptions. Here’s a sample stack trace.
>
> org.apache.camel.component.bean.AmbiguousMethodCallException: Ambiguous
> method invocations possible: [public int
> au.com.winning.navmidware.routes.navws.ClassA.foo(java.lang.String,java.lang.String),
> public int
> au.com.winning.navmidware.routes.navws.ClassA.foo(java.lang.String,au.com.winning.navmidware.routes.navws.ClassB)].
> Exchange[ID-minhmac-local-53614-1457474273519-0-2][Message: body]
> at
> org.apache.camel.component.bean.BeanInfo.chooseBestPossibleMethodInfo(BeanInfo.java:835)
> ~[camel-core-2.16.2.jar:2.16.2]
> at
> org.apache.camel.component.bean.BeanInfo.chooseMethodWithMatchingBody(BeanInfo.java:764)
> ~[camel-core-2.16.2.jar:2.16.2]
> at
> org.apache.camel.component.bean.BeanInfo.chooseMethod(BeanInfo.java:621)
> ~[camel-core-2.16.2.jar:2.16.2]
> at
> org.apache.camel.component.bean.BeanInfo.createInvocation(BeanInfo.java:254)
> ~[camel-core-2.16.2.jar:2.16.2]
> at
> org.apache.camel.component.bean.BeanInfo.createInvocation(BeanInfo.java:183)
> ~[camel-core-2.16.2.jar:2.16.2]
>
>
> From looking at the code in BeanInfo, I *think* it just tries to match the
> type on the body and if it sees multiple possible methods then it throws
> the exception. I believe it should go further and try to match the type on
> the other parameters as well?
>
> To get around this issue temporarily, I’ve had to write an adapter class
> that wraps around ClassA but it’s not an ideal solution.


R: Camel XMLRPC dateTime.iso8601 format.

2016-03-09 Thread Palmentieri Nunzio
Hi Gregoire,
the Camel component is apache-camel-2.16.2

The error is got when reading the following response from server:
_


 
  
   

 
  startDate
  
   20160301T12:00:00+
  
 
 
  responseCode
  
   0
  
 

   
  
 

_

Following the stacktrace

Stacktrace
---
java.lang.NullPointerException
at java.util.Calendar$Builder.setTimeZone(Calendar.java:1313)
at 
sun.util.locale.provider.CalendarProviderImpl.getInstance(CalendarProviderImpl.java:86)
at java.util.Calendar.createCalendar(Calendar.java:1666)
at java.util.Calendar.getInstance(Calendar.java:1627)
at 
org.apache.xmlrpc.util.XmlRpcDateTimeFormat.parseObject(XmlRpcDateTimeFormat.java:138)
at 
org.apache.xmlrpc.util.XmlRpcDateTimeDateFormat.parseObject(XmlRpcDateTimeDateFormat.java:47)
at java.text.Format.parseObject(Format.java:243)
at org.apache.xmlrpc.parser.DateParser.setResult(DateParser.java:45)
at 
org.apache.xmlrpc.parser.AtomicParser.endElement(AtomicParser.java:59)
at 
org.apache.xmlrpc.parser.RecursiveTypeParserImpl.endElement(RecursiveTypeParserImpl.java:103)
at org.apache.xmlrpc.parser.MapParser.endElement(MapParser.java:193)
at 
org.apache.xmlrpc.parser.RecursiveTypeParserImpl.endElement(RecursiveTypeParserImpl.java:103)
at 
org.apache.xmlrpc.parser.XmlRpcResponseParser.endElement(XmlRpcResponseParser.java:208)
at 
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:609)
at 
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1783)
at 
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2970)
at 
com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606)
at 
com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:118)
at 
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
at 
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848)
at 
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777)
at 
com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
at 
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
at 
com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:643)
at 
org.apache.xmlrpc.client.XmlRpcStreamTransport.readResponse(XmlRpcStreamTransport.java:186)
at 
org.apache.xmlrpc.client.XmlRpcStreamTransport.sendRequest(XmlRpcStreamTransport.java:156)
at 
org.apache.xmlrpc.client.XmlRpcHttpTransport.sendRequest(XmlRpcHttpTransport.java:143)
at 
org.apache.xmlrpc.client.XmlRpcSunHttpTransport.sendRequest(XmlRpcSunHttpTransport.java:69)
at 
org.apache.xmlrpc.client.XmlRpcClientWorker$1.run(XmlRpcClientWorker.java:80)
at java.lang.Thread.run(Thread.java:745)


Thanks in advance

By

Nunzio Palmentieri

Engineering Ingegneria Informatica S.p.A.
Via Emanuele Gianturco, 15 - 80142 Napoli
Tel.+39 0816103388
Mob. +39 3351214806
www.eng.it

This electronic message contains information from Engineering Ingegneria 
Informatica S.p.A., which may be privileged and confidential. The information 
is intended to be use of the individual(s) or entity named above. If you are 
not the intended recipient, be aware that any disclosure, copying, distribution 
or use of the contents of this information is prohibited.
 
-Messaggio originale-
Da: Gregoire Autric [mailto:gaut...@redhat.com] 
Inviato: mercoledì 9 marzo 2016 11:44
A: users@camel.apache.org
Oggetto: Re: Camel XMLRPC dateTime.iso8601 format.

hi, Nunzio

which camel component has been involved ? (
http://camel.apache.org/xmlrpc.html ?)
Could you copy/paste your error too ?

by advance, thx

Best Regards, Bien à vous,  どうぞお元�荬�,

Greg AUTRIC
- JBoss Middleware Consultant -

On Tue, Mar 8, 2016 at 5:34 PM, Palmentieri Nunzio <
nunzio.palmenti...@eng.it> wrote:

> Hi,
> I'm trying to use XMLRPC over apache Camel.
>
> I succeeded in getting response from xmlrpc server, but I got an error
> When trying to receive a date field in the following format:
>
> 
>   startDate
>   
> 20160301T12:0

Limit swagger API

2016-03-09 Thread fabrizio.spataro
Hello,

To hide part of my API documentation, It could be nice to have a swagger
switch off mode.

I am thinking the following code:


off

   
   
   



Best regards



--
View this message in context: 
http://camel.465427.n5.nabble.com/Limit-swagger-API-tp5778791.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Limit swagger API

2016-03-09 Thread Claus Ibsen
Whats the use-case for this?



On Wed, Mar 9, 2016 at 3:46 PM, fabrizio.spataro
 wrote:
> Hello,
>
> To hide part of my API documentation, It could be nice to have a swagger
> switch off mode.
>
> I am thinking the following code:
>
> 
> off
> 
>
>
>
> 
> 
>
> Best regards
>
>
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/Limit-swagger-API-tp5778791.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2


Re: Camel XMLRPC dateTime.iso8601 format.

2016-03-09 Thread Claus Ibsen
You get a NPE in Java itself. Wonder maybe you can upgrade Java? Or
try to google / search for that stacktrace error to see what you can
find.

It seems like a timezone missing / not known or something. It can also
be related to what the locale is setup on that OS you use to run the
app.



On Wed, Mar 9, 2016 at 2:31 PM, Palmentieri Nunzio
 wrote:
> Hi Gregoire,
> the Camel component is apache-camel-2.16.2
>
> The error is got when reading the following response from server:
> _
> 
> 
>  
>   
>
> 
>  
>   startDate
>   
>20160301T12:00:00+
>   
>  
>  
>   responseCode
>   
>0
>   
>  
> 
>
>   
>  
> 
> _
>
> Following the stacktrace
>
> Stacktrace
> ---
> java.lang.NullPointerException
> at java.util.Calendar$Builder.setTimeZone(Calendar.java:1313)
> at 
> sun.util.locale.provider.CalendarProviderImpl.getInstance(CalendarProviderImpl.java:86)
> at java.util.Calendar.createCalendar(Calendar.java:1666)
> at java.util.Calendar.getInstance(Calendar.java:1627)
> at 
> org.apache.xmlrpc.util.XmlRpcDateTimeFormat.parseObject(XmlRpcDateTimeFormat.java:138)
> at 
> org.apache.xmlrpc.util.XmlRpcDateTimeDateFormat.parseObject(XmlRpcDateTimeDateFormat.java:47)
> at java.text.Format.parseObject(Format.java:243)
> at org.apache.xmlrpc.parser.DateParser.setResult(DateParser.java:45)
> at 
> org.apache.xmlrpc.parser.AtomicParser.endElement(AtomicParser.java:59)
> at 
> org.apache.xmlrpc.parser.RecursiveTypeParserImpl.endElement(RecursiveTypeParserImpl.java:103)
> at org.apache.xmlrpc.parser.MapParser.endElement(MapParser.java:193)
> at 
> org.apache.xmlrpc.parser.RecursiveTypeParserImpl.endElement(RecursiveTypeParserImpl.java:103)
> at 
> org.apache.xmlrpc.parser.XmlRpcResponseParser.endElement(XmlRpcResponseParser.java:208)
> at 
> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:609)
> at 
> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1783)
> at 
> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2970)
> at 
> com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606)
> at 
> com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:118)
> at 
> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
> at 
> com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848)
> at 
> com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777)
> at 
> com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
> at 
> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
> at 
> com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:643)
> at 
> org.apache.xmlrpc.client.XmlRpcStreamTransport.readResponse(XmlRpcStreamTransport.java:186)
> at 
> org.apache.xmlrpc.client.XmlRpcStreamTransport.sendRequest(XmlRpcStreamTransport.java:156)
> at 
> org.apache.xmlrpc.client.XmlRpcHttpTransport.sendRequest(XmlRpcHttpTransport.java:143)
> at 
> org.apache.xmlrpc.client.XmlRpcSunHttpTransport.sendRequest(XmlRpcSunHttpTransport.java:69)
> at 
> org.apache.xmlrpc.client.XmlRpcClientWorker$1.run(XmlRpcClientWorker.java:80)
> at java.lang.Thread.run(Thread.java:745)
> 
>
> Thanks in advance
>
> By
>
> Nunzio Palmentieri
>
> Engineering Ingegneria Informatica S.p.A.
> Via Emanuele Gianturco, 15 - 80142 Napoli
> Tel.+39 0816103388
> Mob. +39 3351214806
> www.eng.it
>
> This electronic message contains information from Engineering Ingegneria 
> Informatica S.p.A., which may be privileged and confidential. The information 
> is intended to be use of the individual(s) or entity named above. If you are 
> not the intended recipient, be aware that any disclosure, copying, 
> distribution or use of the contents of this information is prohibited.
>
> -Messaggio originale-
> Da: Gregoire Autric [mailto:gaut...@redhat.com]
> Inviato: mercoledì 9 marzo 2016 11:44
> A: users@camel.apache.org
> Oggetto: Re: Camel XMLRPC dateTime.iso8601 format.
>
> hi, Nunzio
>
> which camel component has been involved 

Re: Limit swagger API

2016-03-09 Thread Matt Sicker
Unreleased APIs, internal APIs, backwards compatibility APIs, maybe a
couple other use cases.

On 9 March 2016 at 08:58, Claus Ibsen  wrote:

> Whats the use-case for this?
>
>
>
> On Wed, Mar 9, 2016 at 3:46 PM, fabrizio.spataro
>  wrote:
> > Hello,
> >
> > To hide part of my API documentation, It could be nice to have a swagger
> > switch off mode.
> >
> > I am thinking the following code:
> >
> > 
> > off
> > 
> >
> >
> >
> > 
> > 
> >
> > Best regards
> >
> >
> >
> > --
> > View this message in context:
> http://camel.465427.n5.nabble.com/Limit-swagger-API-tp5778791.html
> > Sent from the Camel - Users mailing list archive at Nabble.com.
>
>
>
> --
> Claus Ibsen
> -
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2
>



-- 
Matt Sicker 


CXF cross cutting concerns

2016-03-09 Thread Ranx
I have a client who wants to use deployable microservice bundles with
REST/SOAP APIs.  Not a problem of course as it works very well.

The issue is that I'm getting a lot of boilerplate replication across the
project which is only getting to get bigger and more difficult to manage
with time.

This includes everything from basic host/port settings to security. 
Obviously setting that up in every bundles is error prone (especially with
XML) and the a real headache for maintenance.  Part of the problem is that
from what I've read sharing cfg files across bundles is not recommended. 
Perhaps with an update strategy reload that isn't such a big deal.  But it
would be nice to have something like:

com.foo.basic.rest.cfg
com.foo.basic.soap.cfg

and use that in each of my bundles to load basic configuration information. 
Each bundle would still have its own cfg file that will be used for very
special and custom items.

Things like PasswordCallback and keystores are exactly the same.  In the
past I've always used a gateway bundle to centralize that.  I may still end
up using something like that in this project but as "microservices" become
more and more the holy grail (until it isn't anymore) this is going to be an
on-going concern.

I'm using Karaf so can also imagine using OSGi registry for creating CXF
interceptors that I might inject into the setup of each of my projects. 

This problem is manifesting on the endpoints in both directions.  For
example, one of the systems I'm integrating with is JDEdwards SOAP services
which require PasswordCallbacks and http conduit settings.  But there are a
large number of these services with WSDLs for many aspects of inventory,
supply, invoices, etc.






--
View this message in context: 
http://camel.465427.n5.nabble.com/CXF-cross-cutting-concerns-tp5778798.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Limit swagger API

2016-03-09 Thread Claus Ibsen
Yeah that sounds like good use-cases.

Welcome to log a JIRA

On Wed, Mar 9, 2016 at 4:07 PM, Matt Sicker  wrote:
> Unreleased APIs, internal APIs, backwards compatibility APIs, maybe a
> couple other use cases.
>
> On 9 March 2016 at 08:58, Claus Ibsen  wrote:
>
>> Whats the use-case for this?
>>
>>
>>
>> On Wed, Mar 9, 2016 at 3:46 PM, fabrizio.spataro
>>  wrote:
>> > Hello,
>> >
>> > To hide part of my API documentation, It could be nice to have a swagger
>> > switch off mode.
>> >
>> > I am thinking the following code:
>> >
>> > 
>> > off
>> > 
>> >
>> >
>> >
>> > 
>> > 
>> >
>> > Best regards
>> >
>> >
>> >
>> > --
>> > View this message in context:
>> http://camel.465427.n5.nabble.com/Limit-swagger-API-tp5778791.html
>> > Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
>>
>> --
>> Claus Ibsen
>> -
>> http://davsclaus.com @davsclaus
>> Camel in Action 2: https://www.manning.com/ibsen2
>>
>
>
>
> --
> Matt Sicker 



-- 
Claus Ibsen
-
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2


Re: Cross cutting concern for microservices

2016-03-09 Thread Ranx
I'm going to bump this as I'm getting farther in the project now and this
sort of replication is getting to be more critical.



--
View this message in context: 
http://camel.465427.n5.nabble.com/Cross-cutting-concern-for-microservices-tp5776981p5778800.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Camel dozer component unable to map custom function on field with null value

2016-03-09 Thread Narsi Nallamilli
I am working on a camel project and user camel dozer for transformation(json
to json). However if source json's field is null it is not getting mapped to
targer json's field. So I though to map the field with custom function to
check if the field is null, if so return "null" value to map.


 phone 
*phone*


caseNull function,
public Object caseNull(Object object){
return null==object?"null":object;
}

I have found the issue in 
https://github.com/apache/camel/blob/master/components/camel-dozer/src/main/java/org/apache/camel/component/dozer/CustomMapper.java

In Object mapCustom(Object source) it is calling getClass() on the field
value and in this case being null, throwing Failed to load custom function.

try {
Class customClass = resolver.resolveClass(className);
customObj = customClass.newInstance();

// If a specific mapping operation has been supplied use that
if (operation != null && prmTypesAndValues != null) {
method = selectMethod(customClass, operation, source,
prmTypesAndValues);
} else if (operation != null) {
method = customClass.getMethod(operation,
source.getClass());
} else {
method = selectMethod(customClass, source);
}
} catch (Exception e) {
throw new RuntimeException("Failed to load custom function", e);
}

Please help with solution.



--
View this message in context: 
http://camel.465427.n5.nabble.com/Camel-dozer-component-unable-to-map-custom-function-on-field-with-null-value-tp5778801.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Camel dozer component unable to map custom function on field with null value

2016-03-09 Thread Brad Johnson
I can't speak directly to JSON to JSON mapping as I use Dozer for mapping
Java/XML/JSON with POJOs but I've run into a similar problem and the
solution may be somewhat similar.  Where I've run into it is if there
aren't getters/setter pairs on generated objects Dozer will sometimes
access a null object and then the game is done.  To get around that it has
a setting to tell it to use field access for that and it will then create
the correct object type for that field and set it.

I don't know if that works in JSON to JSON.

On Wed, Mar 9, 2016 at 9:51 AM, Narsi Nallamilli  wrote:

> I am working on a camel project and user camel dozer for
> transformation(json
> to json). However if source json's field is null it is not getting mapped
> to
> targer json's field. So I though to map the field with custom function to
> check if the field is null, if so return "null" value to map.
>
> 
> custom-converter-param="com.integration.transformation.GetVendorsTransformationUtil,caseNull">
>  phone
> *phone*
> 
>
> caseNull function,
> public Object caseNull(Object object){
> return null==object?"null":object;
> }
>
> I have found the issue in
>
> https://github.com/apache/camel/blob/master/components/camel-dozer/src/main/java/org/apache/camel/component/dozer/CustomMapper.java
>
> In Object mapCustom(Object source) it is calling getClass() on the field
> value and in this case being null, throwing Failed to load custom function.
>
> try {
> Class customClass = resolver.resolveClass(className);
> customObj = customClass.newInstance();
>
> // If a specific mapping operation has been supplied use that
> if (operation != null && prmTypesAndValues != null) {
> method = selectMethod(customClass, operation, source,
> prmTypesAndValues);
> } else if (operation != null) {
> method = customClass.getMethod(operation,
> source.getClass());
> } else {
> method = selectMethod(customClass, source);
> }
> } catch (Exception e) {
> throw new RuntimeException("Failed to load custom function",
> e);
> }
>
> Please help with solution.
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Camel-dozer-component-unable-to-map-custom-function-on-field-with-null-value-tp5778801.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>


Re: Limit swagger API

2016-03-09 Thread fabrizio.spataro




--
View this message in context: 
http://camel.465427.n5.nabble.com/Limit-swagger-API-tp5778791p5778804.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: camel-swagger-java not parse property

2016-03-09 Thread fabrizio.spataro
+1



--
View this message in context: 
http://camel.465427.n5.nabble.com/camel-swagger-java-not-parse-property-tp5778734p5778805.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Camel reference property files with and without OSGI

2016-03-09 Thread souciance
Hi,

I understand that if you deploy our Camel project to an OSGI environment
like Karaf you can simply write:



http://camel.apache.org/schema/blueprint";
id="INT001_SelfServiceMachine" useMDCLogging="true">


And this works when the project is deployed to Karaf and the property file
is located there.

But how can you configure it when Karaf is not available?

I used this bean before:


But is there a single way to refer to property files regardless of when you
are in Karaf or when you are in your e.g. Eclipse and your property file is
in your /src/resources folder and the bean above works? For instance, when
you use Jenkins and and want to run tests and build the bundle, you may not
have Karaf available.

Thanks for any input on this.

Best
Souciance






--
View this message in context: 
http://camel.465427.n5.nabble.com/Camel-reference-property-files-with-and-without-OSGI-tp5778806.html
Sent from the Camel - Users mailing list archive at Nabble.com.


file trigger processing lots of files

2016-03-09 Thread jamesburn
Hello

I want to have the processing of a batch of 1000s of files triggered by the
arrival of a header file.

We're working with Spring/Blueprint DSL - I'm no Java expert.

I spent the morning playing with PollEnrich, but now see that this will only
pickup the first file in the batch.  

Digging deeper, I think that RoutePolicy would work, to start and stop a
route which would collect/process the batch of 1000's but can only find
examples of Quartz2 and throttler triggering another route. 

Is this the best way? Are there any more pertinent examples?

Thanks

James



--
View this message in context: 
http://camel.465427.n5.nabble.com/file-trigger-processing-lots-of-files-tp5778807.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: CAMEL 2.16.2 and Swagger

2016-03-09 Thread Gerald Mixa
Hi Claus,

I updated the swagger library to 1.5.7 which seems to be the latest version in 
camel 2.16.2.
Unfortunately this did not change things. The camel example still shows up that 
selection box even with this updated dependency.

Greetings 

Gerald 

Von meinem iPhone gesendet

> Am 08.03.2016 um 07:17 schrieb Claus Ibsen :
> 
> Can you upgrade the swagger-java library as there is a bug in it
> afaik. There is a newer 1.5.7 release.
> 
>> On Fri, Mar 4, 2016 at 5:40 PM, Gerald Mixa  wrote:
>> Hi,
>> 
>> i have just tried out the camel swagger plugin example which is shipped
>> with 2.16.
>> So far it seems to work. But when i go to the use case which is offered
>> by http://localhost/#!/user/get_user_id
>> to retrieve specific info for a user who is ghiven by its id swagger just
>> offers a selection box to insert some id.
>> Unfortunately the selection box is empty and contains no values. This
>> behavior is present on google chrome and firefox. I did not manage to
>> figure out how to change this behaviour. I would like to be able to enter a
>> random Value for the USER id so i count request an arbitrary user info.
>> Doese someone else have the same issues ?
>> 
>> Greetings
>> 
>> Gerald
> 
> 
> 
> -- 
> Claus Ibsen
> -
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2


Re: Camel reference property files with and without OSGI

2016-03-09 Thread Ranx
What version are you using?  You shouldn't have to replicate the definition
into Camel context like that anymore.



http://localhost"; />





You can use the default properties for your testing and override them in
your .cfg file for deployment.

someAddress=http://anotheraddress.com
someValue=false

In CamelBlueprintTestSupport you can also override the properties.  You can
also assign a cfg file in there but I haven't found that to work very well.

I commonly keep my blueprint-properties.xml separate from my other camel
blueprint xml. That's for a couple of reasons.  If I want to use a different
properties set in my camel blueprint tests I then point it to the
blueprint-properties in the src/test/resources directory instead of the one
in the src/main/resources.

Remember that at deployment Karaf will load all the blueprint files it finds
in the OSGi-INF folder so there isn't anything special about putting these
files in separate places.  During testing however you do need to explicitly
set the files to use (naturally enough). To do that you simply specify them
to CBTS in a comma delimited String.



--
View this message in context: 
http://camel.465427.n5.nabble.com/Camel-reference-property-files-with-and-without-OSGI-tp5778806p5778809.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Camel reference property files with and without OSGI

2016-03-09 Thread souciance
Hi,

I am using 2.16.1 and Karaf 4.0.2.

I am not sure if I understand you correctly. Do you mean that I need
to define default properties for every single property in the
blueprint during development and testing, and then when the bundle is
deployed, these values are overridden by the cfg file as that is
loaded by Karaf?

Could you explain what you mean by "specificy them to CBTS in a comma
delimited string"?

Best
Souciance

On Wed, Mar 9, 2016 at 5:59 PM, Ranx [via Camel]
 wrote:
> What version are you using?  You shouldn't have to replicate the definition
> into Camel context like that anymore.
>
> 
> 
>  value="http://localhost"; />
>
> 
> 
> 
>
> You can use the default properties for your testing and override them in
> your .cfg file for deployment.
>
> someAddress=http://anotheraddress.com
> someValue=false
>
> In CamelBlueprintTestSupport you can also override the properties.  You can
> also assign a cfg file in there but I haven't found that to work very well.
>
> I commonly keep my blueprint-properties.xml separate from my other camel
> blueprint xml. That's for a couple of reasons.  If I want to use a different
> properties set in my camel blueprint tests I then point it to the
> blueprint-properties in the src/test/resources directory instead of the one
> in the src/main/resources.
>
> Remember that at deployment Karaf will load all the blueprint files it finds
> in the OSGi-INF folder so there isn't anything special about putting these
> files in separate places.  During testing however you do need to explicitly
> set the files to use (naturally enough). To do that you simply specify them
> to CBTS in a comma delimited String.
>
> 
> If you reply to this email, your message will be added to the discussion
> below:
> http://camel.465427.n5.nabble.com/Camel-reference-property-files-with-and-without-OSGI-tp5778806p5778809.html
> To start a new topic under Camel - Users, email
> ml-node+s465427n465428...@n5.nabble.com
> To unsubscribe from Camel reference property files with and without OSGI,
> click here.
> NAML




--
View this message in context: 
http://camel.465427.n5.nabble.com/Camel-reference-property-files-with-and-without-OSGI-tp5778806p5778810.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: camel-swagger-java not parse property

2016-03-09 Thread Claus Ibsen
Hi

Yeah we should output the resolved values. I logged a ticket
https://issues.apache.org/jira/browse/CAMEL-9687

On Tue, Mar 8, 2016 at 11:35 AM, fabrizio.spataro
 wrote:
> Hello.
>
> There is a bug into swagger JSON file.
>
> I am using follow rest DSL (xml) with camel-2.16.3-SNAPSHOT
>
> 
>...
> 
>
> Output Swagger JSON:
>
> {
>   "swagger" : "2.0",
>   "info" : {
> "version" : "1.0.0",
> "title" : "MY API"
>   },
>   "host" : "0.0.0.0:8080",
>   "tags" : [ {
> "name" : "{{rest.root.path}}"
>   } ],
>   "schemes" : [ "http" ],
>   "paths" : {
> "{{rest.root.path}}/users" : {
>   "get" : {
> "tags" : [ "{{rest.root.path}}" ],
> "produces" : [ "application/json" ],
> ...
> 
> .
>
>
>
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/camel-swagger-java-not-parse-property-tp5778734.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2


Re: file trigger processing lots of files

2016-03-09 Thread Quinn Stevenson
I think you could accomplish this with two routes.

The first route would auto-start, and would watch for the trigger file.  When 
the trigger file arrives, the route would start a second route using the 
control-bus EIP (http://camel.apache.org/controlbus.html 
).

The second route would not auto-start, and would process the files.  Once it’s 
finished, it could disable itself using the control-bus EIP.

> On Mar 9, 2016, at 9:40 AM, jamesburn  wrote:
> 
> Hello
> 
> I want to have the processing of a batch of 1000s of files triggered by the
> arrival of a header file.
> 
> We're working with Spring/Blueprint DSL - I'm no Java expert.
> 
> I spent the morning playing with PollEnrich, but now see that this will only
> pickup the first file in the batch.  
> 
> Digging deeper, I think that RoutePolicy would work, to start and stop a
> route which would collect/process the batch of 1000's but can only find
> examples of Quartz2 and throttler triggering another route. 
> 
> Is this the best way? Are there any more pertinent examples?
> 
> Thanks
> 
> James
> 
> 
> 
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/file-trigger-processing-lots-of-files-tp5778807.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



Unable to Install the Camel Websocket Component

2016-03-09 Thread Rizon
I'm trying to install the camel-websocket v2.16.2 into Karaf 4.0.4 and it
just hangs.  Anyone else experiencing this issue?  Any workarounds?



--
View this message in context: 
http://camel.465427.n5.nabble.com/Unable-to-Install-the-Camel-Websocket-Component-tp5778818.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: bean parameter binding

2016-03-09 Thread Minh Tran
Thanks for the quick response, I’ve created jira

https://issues.apache.org/jira/browse/CAMEL-9690 


> On 9 Mar 2016, at 9:49 PM, Gregoire Autric  wrote:
> 
> Hi Minh,
> 
> it is be an improvement that Camel could implements
> Coud you please rise a JIRA for it ?
> 
> Camel team will check it too.
> 
> https://issues.apache.org/jira/browse/CAMEL
> 
> 
> thx for this topic
> 
> Best Regards, Bien à vous,  どうぞお元気で,
> 
> Greg AUTRIC
> - JBoss Middleware Consultant -
> 
> 
> On Tue, Mar 8, 2016 at 11:21 PM, Minh Tran  wrote:
> 
>> Hello
>> 
>> I’m using camel 2.16.2 and I’m finding the bean parameter binding doesn’t
>> seem to work very well on overloaded methods. See below for an example
>> 
>> public class ClassA {
>>public int foo() {
>>return 0;
>>}
>> 
>>public int foo(String param1) {
>>return 1;
>>}
>> 
>>public int foo(String param1, String param2) {
>>return 2;
>>}
>> 
>>public int foo(String param1, ClassB param2) {
>>return 3;
>>}
>> 
>>public int foo(boolean param1, String param2) {
>>return 4;
>>}
>> }
>> 
>> public class ClassB {
>> 
>> }
>> 
>> Here are the routes
>> 
>> from("direct:noParam").bean(ClassA.class, "foo()").to("mock:end");
>> from("direct:1Param").bean(ClassA.class, "foo(${body})").to("mock:end");
>> from("direct:2Param").bean(ClassA.class, "foo(${body},
>> ${header.key})").to("mock:end”);
>> 
>> And here are the tests
>> 
>>@EndpointInject(uri = "mock:end")
>>private MockEndpoint end;
>> 
>>@Produce
>>private ProducerTemplate producerTemplate;
>> 
>>@Test
>>// passes
>>public void testNoParam() throws InterruptedException {
>>end.expectedBodiesReceived(0);
>>producerTemplate.sendBodyAndHeader("direct:noParam",
>> "body", "key", "value");
>>end.assertIsSatisfied();
>>}
>> 
>>@Test
>>// passes
>>public void test1Param() throws InterruptedException {
>>end.expectedBodiesReceived(1);
>>producerTemplate.sendBodyAndHeader("direct:1Param",
>> "body", "key", "value");
>>end.assertIsSatisfied();
>>}
>> 
>>@Test
>>// throws ambiguous method call exception
>>public void test2Param_string() throws InterruptedException {
>>end.expectedBodiesReceived(2);
>>producerTemplate.sendBodyAndHeader("direct:2Param",
>> "body", "key", "value");
>>end.assertIsSatisfied();
>>}
>> 
>>@Test
>>// throws ambiguous method call exception
>>public void test2Param_classB() throws InterruptedException {
>>end.expectedBodiesReceived(3);
>>producerTemplate.sendBodyAndHeader("direct:2Param",
>> "body", "key", new ClassB());
>>end.assertIsSatisfied();
>>}
>> 
>>@Test
>>// passes
>>public void test2Param_boolBody() throws InterruptedException {
>>end.expectedBodiesReceived(4);
>>producerTemplate.sendBodyAndHeader("direct:2Param", true,
>> "key", "value");
>>end.assertIsSatisfied();
>>}
>> 
>> 
>> I don’t understand why test2Param_string and test2Param_classB throw
>> ambiguous call exceptions. Here’s a sample stack trace.
>> 
>> org.apache.camel.component.bean.AmbiguousMethodCallException: Ambiguous
>> method invocations possible: [public int
>> au.com.winning.navmidware.routes.navws.ClassA.foo(java.lang.String,java.lang.String),
>> public int
>> au.com.winning.navmidware.routes.navws.ClassA.foo(java.lang.String,au.com.winning.navmidware.routes.navws.ClassB)].
>> Exchange[ID-minhmac-local-53614-1457474273519-0-2][Message: body]
>>at
>> org.apache.camel.component.bean.BeanInfo.chooseBestPossibleMethodInfo(BeanInfo.java:835)
>> ~[camel-core-2.16.2.jar:2.16.2]
>>at
>> org.apache.camel.component.bean.BeanInfo.chooseMethodWithMatchingBody(BeanInfo.java:764)
>> ~[camel-core-2.16.2.jar:2.16.2]
>>at
>> org.apache.camel.component.bean.BeanInfo.chooseMethod(BeanInfo.java:621)
>> ~[camel-core-2.16.2.jar:2.16.2]
>>at
>> org.apache.camel.component.bean.BeanInfo.createInvocation(BeanInfo.java:254)
>> ~[camel-core-2.16.2.jar:2.16.2]
>>at
>> org.apache.camel.component.bean.BeanInfo.createInvocation(BeanInfo.java:183)
>> ~[camel-core-2.16.2.jar:2.16.2]
>> 
>> 
>> From looking at the code in BeanInfo, I *think* it just tries to match the
>> type on the body and if it sees multiple possible methods then it throws
>> the exception. I believe it should go further and try to match the type on
>> the other parameters as well?
>> 
>> To get around this issue temporarily, I’ve had to write an adapter class
>> that wraps aro

Camel Rest DSL issue with fuse fabric

2016-03-09 Thread GaganT
Hi,

I am doing a poc to expose rest ful services using camel rest dsl and
deploying them in a container on a fuse fabric profile. The example is based
out of camel-example-servlet-rest-blueprint project. my bluprint file is: 
blueprint.xml
  

Example is simple and I am able to access rest services if I install the
bundle in standalone fuse. However, if I install the same bundle in a fuse
fabric container, it does not work and I always get http 404 error. I am
struggling with this for few days now. Has anyone managed to use rest-dsl
with fuse fabric? I would appreciate any help in this regard.

Thanks!
Gagan



--
View this message in context: 
http://camel.465427.n5.nabble.com/Camel-Rest-DSL-issue-with-fuse-fabric-tp5778820.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Bug in RestSwaggerReader.appendModels() - need confirmation

2016-03-09 Thread tomb50
Hi,

I have encountered an issue relating to the Swagger component of Camel, I
believe it is related to the RestModelConvertor that is used when creating
the Swagger model from the Rest API model from Camel.

When a model that is directly referenced (e.g. an out-type) is added to the
Swagger.definitions map by that method, it is decorated with the extension
of "x-className". Any models that are subsequently referenced from the
original model are also added to the definitions map, undecorated.

Definitions needs to be decorated as such in order to be returned later as
ReferenceProperties in RestSwaggerReader.modelTypeAsRef(), otherwise they
are returned as StringProperties.

The issue seems to that there is nothing preventing a decorated element in
the Swagger.definitions map from being overwritten by an undecorated version
of the same class, if the REST API Verbs in Camel is ordered in a certain
way.

E.g.

API 1 returns Model A, which references Model B.
API 2 returns Model B.

Case 1 (no issue):

API 1 is loaded first.
Model A is added to Swagger.definition map decorated with "x-className",
Model B is added to the definition map undecorated.
API 2 is then loaded.
Model B is then decorated with "x-classname" and replaces the previous Model
B element in the definition map.

All good

Case 2 (the issue):

Consider that API 2 is loaded before API one, then after both API's are
loaded the definitions map contains a Decorated Model A but an undecorated
Model B.

Then when the RestSwaggerReader tries to set the schema on the response
element of API2 (towards the end of doParseVerbs()), it fails to find Model
B as a reference Property and adds it as a StringProperty, so the Model does
not show in Swagger UI and broke our validation tests.

We have many existing APIs and Models, all working perfectly, and I came
across this specific scenario today. I would appreciate If someone was able
to verify if this indeed is a defect or I am mistaken in my understanding.

If this is a bug, would a suitable fix to be to check the definition map for
an existing Model and NOT replace it, if it is decorated with the
"x-className" extension? Happy to get involved with a Pull request if
required.

Thanks
Tom

For ease: below is the code in question

-
RestSwaggerReader.class

  private void appendModels(Class clazz, Swagger swagger) {
RestModelConverters converters = new RestModelConverters();
final Map models = converters.readClass(clazz);
for (Map.Entry entry : models.entrySet()) {
swagger.model(entry.getKey(), entry.getValue());
}
}


---
RestModelConverters.class

public Map readClass(Class clazz) {
String name = clazz.getName();
Map resolved = super.read(clazz);
if (resolved != null) {
for (Model model : resolved.values()) {
// enrich with the class name of the model
model.getVendorExtensions().put("x-className", new
StringProperty(name));
}

// read any extra using read-all
Map extra = super.readAll(clazz);
if (extra != null) {
for (Map.Entry entry : extra.entrySet()) {
if (!resolved.containsKey(entry.getKey())) {
resolved.put(entry.getKey(), entry.getValue());
}
}
}
}
return resolved;
}







--
View this message in context: 
http://camel.465427.n5.nabble.com/Bug-in-RestSwaggerReader-appendModels-need-confirmation-tp5778821.html
Sent from the Camel - Users mailing list archive at Nabble.com.