Re: [Dev] javascript.EvaluatorException in replace function

2014-12-16 Thread Vanjikumaran Sivajothy
@elimatha,
You may have to apply the patch that given the jira [1] to solve the problem
[1] https://wso2.org/jira/browse/ESBJAVA-3019


However, @keerthana's workaround will work for your case and good catch
@keerthana

On Wed, Dec 17, 2014 at 11:57 AM, Elilmatha Sivanesan 
wrote:
>
>
> @Vanji ,
> I tried as you suggested.
> * var Str = '{"name": {"is":"john"}}'; *
> * var qReplacedString =
> Str.replace(new RegExp(/\"/g),'\\"');
>  *
> *
>  mc.setProperty('testingJS',qReplacedString);*
> * *
> This script is work on ESB.But when I tried the second script,
> *  var jsonObj = {"name": {"is":"john"}}; *
> * var jsonStr
> = JSON.stringify(jsonObj);*
> * var qReplacedString
> = jsonStr.replace(new RegExp(/\"/g),'\\"');
>*
> *
>  mc.setProperty('testingJS',qReplacedString);*
> *   *
>  I got JSON is not defined error.
>
>
> @Keerthika
> Your suggestion is working.
>
> Thank you both for spending your time on this issue.
>
>
> On Wed, Dec 17, 2014 at 11:49 AM, Keerthika Mahendralingam <
> keerth...@wso2.com> wrote:
>>
>> Hi Elilmatha,
>> When you get the value for query1 from mc.getProperty('uri.var.query1'),
>> you will get json value for it.
>> You can use replace() method to string values. So you need to convert
>> the query json value to string.
>> So you can change the query json value into string as follows:
>>  var str="'"+mc.getProperty('uri.var.query1')+"'";
>> Then you can use replace() method as you wish.
>>
>> On Wed, Dec 17, 2014 at 11:32 AM, Keerthika Mahendralingam <
>> keerth...@wso2.com> wrote:
>>>
>>> Hi Elilmatha,
>>>
>>> try this one.
>>>
>>> 
>>> var str="'"+mc.getProperty('uri.var.query1')+"'";
>>> var qReplacedString = str.replace(new RegExp(/"/g),'\\"');
>>> var qReplacedStr = qReplacedString.replace(new RegExp(/'/g),'"');
>>> mc.setProperty('uri.var.query1',qReplacedStr);
>>>  
>>>
>>> Thank you,
>>>
>>> On Tue, Dec 16, 2014 at 7:03 PM, Vanjikumaran Sivajothy 
>>> wrote:

 Hi,
 I have tried this scenario with wso2 esb 4.8.1 with below[1] proxy that
 simulate your scenario.



 
 http://ws.apache.org/ns/synapse";
name="Scripting"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">

   
   *   var Str = '{"name": {"is":"john"}}'; *
 * var qReplacedString =
 Str.replace(new RegExp(/\"/g),'\\"');
  *
 *
  mc.setProperty('testingJS',qReplacedString);*
 * *
  
 
  
  
   


 


 and i have tried with json object in the JS with the fix given in the
 [2] and it worked

 
 http://ws.apache.org/ns/synapse";
name="Scripting"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">

   
*  var jsonObj = {"name":
 {"is":"john"}}; *
 * var jsonStr
 = JSON.stringify(jsonObj);*
 * var qReplacedString
 = jsonStr.replace(new RegExp(/\"/g),'\\"');
*
 *
  mc.setProperty('testingJS',qReplacedString);*
 * *
  
 
  
  
   


 



 [2]
 https://wso2.org/jira/browse/ESBJAVA-3019


 On Tue, Dec 16, 2014 at 5:07 PM, Elilmatha Sivanesan <
 elilma...@wso2.com> wrote:
>
> Ok , Thank you.
>
> On Tue, Dec 16, 2014 at 5:05 PM, Vanjikumaran Sivajothy <
> va...@wso2.com> wrote:
>>
>> Since there is a bug in the milestone pack, I would recommend you to
>> write a class mediator and perform this task.
>>
>>
>> On Tue, Dec 16, 2014 at 4:25 PM, Elilmatha Sivanesan <
>> elilma...@wso2.com> wrote:
>>>
>>> It is not working with m2,m3
>>>
>>> On Tue, Dec 16, 2014 at 3:26 PM, Elilmatha Sivanesan <
>>> elilma...@wso2.com> wrote:

 Yes now I'm running this with 4.9.0 m3

 On Tue, Dec 16, 2014 at 3:19 PM, Vanjikumaran Sivajothy <
 va...@wso2.com> wrote:
>
> Can you please run this with ESB 4.9.0 m1/m2 ?
>
> On Tue, Dec 16, 2014 at 2:14 PM, Vanjikumaran Sivajothy <
> va...@wso2.com> wrote:
>>
>> Hi elimatha,
>> If this is blocker to you, Have you try to use custom class
>> mediator to perform above job?
>>
>> Best regards,
>> vanji
>>
>> On Tue, Dec 16, 2014 at 2:03 PM, Elilmatha Sivanesan <
>> elilma...@wso2.com> wrote:
>>
>>

Re: [Dev] javascript.EvaluatorException in replace function

2014-12-16 Thread Elilmatha Sivanesan
@Vanji ,
I tried as you suggested.
* var Str = '{"name": {"is":"john"}}'; *
* var qReplacedString =
Str.replace(new RegExp(/\"/g),'\\"');
 *
*
 mc.setProperty('testingJS',qReplacedString);*
* *
This script is work on ESB.But when I tried the second script,
*  var jsonObj = {"name": {"is":"john"}}; *
* var jsonStr
= JSON.stringify(jsonObj);*
* var qReplacedString
= jsonStr.replace(new RegExp(/\"/g),'\\"');
   *
*
 mc.setProperty('testingJS',qReplacedString);*
*   *
 I got JSON is not defined error.


@Keerthika
Your suggestion is working.

Thank you both for spending your time on this issue.


On Wed, Dec 17, 2014 at 11:49 AM, Keerthika Mahendralingam <
keerth...@wso2.com> wrote:
>
> Hi Elilmatha,
> When you get the value for query1 from mc.getProperty('uri.var.query1'),
> you will get json value for it.
> You can use replace() method to string values. So you need to convert the
> query json value to string.
> So you can change the query json value into string as follows:
>  var str="'"+mc.getProperty('uri.var.query1')+"'";
> Then you can use replace() method as you wish.
>
> On Wed, Dec 17, 2014 at 11:32 AM, Keerthika Mahendralingam <
> keerth...@wso2.com> wrote:
>>
>> Hi Elilmatha,
>>
>> try this one.
>>
>> 
>> var str="'"+mc.getProperty('uri.var.query1')+"'";
>> var qReplacedString = str.replace(new RegExp(/"/g),'\\"');
>> var qReplacedStr = qReplacedString.replace(new RegExp(/'/g),'"');
>> mc.setProperty('uri.var.query1',qReplacedStr);
>>  
>>
>> Thank you,
>>
>> On Tue, Dec 16, 2014 at 7:03 PM, Vanjikumaran Sivajothy 
>> wrote:
>>>
>>> Hi,
>>> I have tried this scenario with wso2 esb 4.8.1 with below[1] proxy that
>>> simulate your scenario.
>>>
>>>
>>>
>>> 
>>> http://ws.apache.org/ns/synapse";
>>>name="Scripting"
>>>transports="https,http"
>>>statistics="disable"
>>>trace="disable"
>>>startOnLoad="true">
>>>
>>>   
>>>   *   var Str = '{"name": {"is":"john"}}'; *
>>> * var qReplacedString =
>>> Str.replace(new RegExp(/\"/g),'\\"');
>>>  *
>>> *
>>>  mc.setProperty('testingJS',qReplacedString);*
>>> * *
>>>  
>>> 
>>>  
>>>  
>>>   
>>>
>>>
>>> 
>>>
>>>
>>> and i have tried with json object in the JS with the fix given in the
>>> [2] and it worked
>>>
>>> 
>>> http://ws.apache.org/ns/synapse";
>>>name="Scripting"
>>>transports="https,http"
>>>statistics="disable"
>>>trace="disable"
>>>startOnLoad="true">
>>>
>>>   
>>>*  var jsonObj = {"name": {"is":"john"}}; *
>>> * var jsonStr
>>> = JSON.stringify(jsonObj);*
>>> * var qReplacedString
>>> = jsonStr.replace(new RegExp(/\"/g),'\\"');
>>>*
>>> *
>>>  mc.setProperty('testingJS',qReplacedString);*
>>> * *
>>>  
>>> 
>>>  
>>>  
>>>   
>>>
>>>
>>> 
>>>
>>>
>>>
>>> [2]
>>> https://wso2.org/jira/browse/ESBJAVA-3019
>>>
>>>
>>> On Tue, Dec 16, 2014 at 5:07 PM, Elilmatha Sivanesan >> > wrote:

 Ok , Thank you.

 On Tue, Dec 16, 2014 at 5:05 PM, Vanjikumaran Sivajothy >>> > wrote:
>
> Since there is a bug in the milestone pack, I would recommend you to
> write a class mediator and perform this task.
>
>
> On Tue, Dec 16, 2014 at 4:25 PM, Elilmatha Sivanesan <
> elilma...@wso2.com> wrote:
>>
>> It is not working with m2,m3
>>
>> On Tue, Dec 16, 2014 at 3:26 PM, Elilmatha Sivanesan <
>> elilma...@wso2.com> wrote:
>>>
>>> Yes now I'm running this with 4.9.0 m3
>>>
>>> On Tue, Dec 16, 2014 at 3:19 PM, Vanjikumaran Sivajothy <
>>> va...@wso2.com> wrote:

 Can you please run this with ESB 4.9.0 m1/m2 ?

 On Tue, Dec 16, 2014 at 2:14 PM, Vanjikumaran Sivajothy <
 va...@wso2.com> wrote:
>
> Hi elimatha,
> If this is blocker to you, Have you try to use custom class
> mediator to perform above job?
>
> Best regards,
> vanji
>
> On Tue, Dec 16, 2014 at 2:03 PM, Elilmatha Sivanesan <
> elilma...@wso2.com> wrote:
>
>>
>> Hi all,
>> I need to convert the json string like the following {"name":
>> {"is":"john"}} to {\"name\": {\"is\":\"john\"}}
>>
>> I wrote the javascript as follows which works well on the online
>> java script editor. The script
>> 
>> 
>> 
>> Create Object from JSON String
>> 
>> 
>> var p ='{"name": {"is":"john"}}';
>> var x = p.replace(/\"/g,'\\"');
>> document.write(x);
>> 

Re: [Dev] javascript.EvaluatorException in replace function

2014-12-16 Thread Keerthika Mahendralingam
Hi Elilmatha,
When you get the value for query1 from mc.getProperty('uri.var.query1'),
you will get json value for it.
You can use replace() method to string values. So you need to convert the
query json value to string.
So you can change the query json value into string as follows:
 var str="'"+mc.getProperty('uri.var.query1')+"'";
Then you can use replace() method as you wish.

On Wed, Dec 17, 2014 at 11:32 AM, Keerthika Mahendralingam <
keerth...@wso2.com> wrote:
>
> Hi Elilmatha,
>
> try this one.
>
> 
> var str="'"+mc.getProperty('uri.var.query1')+"'";
> var qReplacedString = str.replace(new RegExp(/"/g),'\\"');
> var qReplacedStr = qReplacedString.replace(new RegExp(/'/g),'"');
> mc.setProperty('uri.var.query1',qReplacedStr);
>  
>
> Thank you,
>
> On Tue, Dec 16, 2014 at 7:03 PM, Vanjikumaran Sivajothy 
> wrote:
>>
>> Hi,
>> I have tried this scenario with wso2 esb 4.8.1 with below[1] proxy that
>> simulate your scenario.
>>
>>
>>
>> 
>> http://ws.apache.org/ns/synapse";
>>name="Scripting"
>>transports="https,http"
>>statistics="disable"
>>trace="disable"
>>startOnLoad="true">
>>
>>   
>>   *   var Str = '{"name": {"is":"john"}}'; *
>> * var qReplacedString =
>> Str.replace(new RegExp(/\"/g),'\\"');
>>  *
>> *
>>  mc.setProperty('testingJS',qReplacedString);*
>> * *
>>  
>> 
>>  
>>  
>>   
>>
>>
>> 
>>
>>
>> and i have tried with json object in the JS with the fix given in the [2]
>> and it worked
>>
>> 
>> http://ws.apache.org/ns/synapse";
>>name="Scripting"
>>transports="https,http"
>>statistics="disable"
>>trace="disable"
>>startOnLoad="true">
>>
>>   
>>*  var jsonObj = {"name": {"is":"john"}}; *
>> * var jsonStr
>> = JSON.stringify(jsonObj);*
>> * var qReplacedString
>> = jsonStr.replace(new RegExp(/\"/g),'\\"');
>>*
>> *
>>  mc.setProperty('testingJS',qReplacedString);*
>> * *
>>  
>> 
>>  
>>  
>>   
>>
>>
>> 
>>
>>
>>
>> [2]
>> https://wso2.org/jira/browse/ESBJAVA-3019
>>
>>
>> On Tue, Dec 16, 2014 at 5:07 PM, Elilmatha Sivanesan 
>> wrote:
>>>
>>> Ok , Thank you.
>>>
>>> On Tue, Dec 16, 2014 at 5:05 PM, Vanjikumaran Sivajothy 
>>> wrote:

 Since there is a bug in the milestone pack, I would recommend you to
 write a class mediator and perform this task.


 On Tue, Dec 16, 2014 at 4:25 PM, Elilmatha Sivanesan <
 elilma...@wso2.com> wrote:
>
> It is not working with m2,m3
>
> On Tue, Dec 16, 2014 at 3:26 PM, Elilmatha Sivanesan <
> elilma...@wso2.com> wrote:
>>
>> Yes now I'm running this with 4.9.0 m3
>>
>> On Tue, Dec 16, 2014 at 3:19 PM, Vanjikumaran Sivajothy <
>> va...@wso2.com> wrote:
>>>
>>> Can you please run this with ESB 4.9.0 m1/m2 ?
>>>
>>> On Tue, Dec 16, 2014 at 2:14 PM, Vanjikumaran Sivajothy <
>>> va...@wso2.com> wrote:

 Hi elimatha,
 If this is blocker to you, Have you try to use custom class
 mediator to perform above job?

 Best regards,
 vanji

 On Tue, Dec 16, 2014 at 2:03 PM, Elilmatha Sivanesan <
 elilma...@wso2.com> wrote:

>
> Hi all,
> I need to convert the json string like the following {"name":
> {"is":"john"}} to {\"name\": {\"is\":\"john\"}}
>
> I wrote the javascript as follows which works well on the online
> java script editor. The script
> 
> 
> 
> Create Object from JSON String
> 
> 
> var p ='{"name": {"is":"john"}}';
> var x = p.replace(/\"/g,'\\"');
> document.write(x);
> 
> 
> 
>
> So I wrote the script in the synapse configuration as below.
>   var q = mc.getProperty('uri.var.query1');
> 
> var qReplacedString = q.replace(/\"/g,'\\"');
> mc.setProperty('uri.var.query1',qReplacedString);
> ]]>
> 
>
> But it gives me the following errors. Is there any issues on using
> /\"/ character ,What would be the problem on this.
>
> ERROR - ScriptMediator The script engine returned an error
> executing the inlined js script function mediate
> [2014-12-16 13:50:45,113]  INFO
> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>  com.sun.phobos.script.util.ExtendedScriptException:
> org.mozilla.javascript.EvaluatorException: The choice of Java
> constructor replace matchi

Re: [Dev] javascript.EvaluatorException in replace function

2014-12-16 Thread Keerthika Mahendralingam
Hi Elilmatha,

try this one.


var str="'"+mc.getProperty('uri.var.query1')+"'";
var qReplacedString = str.replace(new RegExp(/"/g),'\\"');
var qReplacedStr = qReplacedString.replace(new RegExp(/'/g),'"');
mc.setProperty('uri.var.query1',qReplacedStr);
 

Thank you,

On Tue, Dec 16, 2014 at 7:03 PM, Vanjikumaran Sivajothy 
wrote:
>
> Hi,
> I have tried this scenario with wso2 esb 4.8.1 with below[1] proxy that
> simulate your scenario.
>
>
>
> 
> http://ws.apache.org/ns/synapse";
>name="Scripting"
>transports="https,http"
>statistics="disable"
>trace="disable"
>startOnLoad="true">
>
>   
>   *   var Str = '{"name": {"is":"john"}}'; *
> * var qReplacedString =
> Str.replace(new RegExp(/\"/g),'\\"');
>  *
> *
>  mc.setProperty('testingJS',qReplacedString);*
> * *
>  
> 
>  
>  
>   
>
>
> 
>
>
> and i have tried with json object in the JS with the fix given in the [2]
> and it worked
>
> 
> http://ws.apache.org/ns/synapse";
>name="Scripting"
>transports="https,http"
>statistics="disable"
>trace="disable"
>startOnLoad="true">
>
>   
>*  var jsonObj = {"name": {"is":"john"}}; *
> * var jsonStr
> = JSON.stringify(jsonObj);*
> * var qReplacedString
> = jsonStr.replace(new RegExp(/\"/g),'\\"');
>*
> *
>  mc.setProperty('testingJS',qReplacedString);*
> * *
>  
> 
>  
>  
>   
>
>
> 
>
>
>
> [2]
> https://wso2.org/jira/browse/ESBJAVA-3019
>
>
> On Tue, Dec 16, 2014 at 5:07 PM, Elilmatha Sivanesan 
> wrote:
>>
>> Ok , Thank you.
>>
>> On Tue, Dec 16, 2014 at 5:05 PM, Vanjikumaran Sivajothy 
>> wrote:
>>>
>>> Since there is a bug in the milestone pack, I would recommend you to
>>> write a class mediator and perform this task.
>>>
>>>
>>> On Tue, Dec 16, 2014 at 4:25 PM, Elilmatha Sivanesan >> > wrote:

 It is not working with m2,m3

 On Tue, Dec 16, 2014 at 3:26 PM, Elilmatha Sivanesan <
 elilma...@wso2.com> wrote:
>
> Yes now I'm running this with 4.9.0 m3
>
> On Tue, Dec 16, 2014 at 3:19 PM, Vanjikumaran Sivajothy <
> va...@wso2.com> wrote:
>>
>> Can you please run this with ESB 4.9.0 m1/m2 ?
>>
>> On Tue, Dec 16, 2014 at 2:14 PM, Vanjikumaran Sivajothy <
>> va...@wso2.com> wrote:
>>>
>>> Hi elimatha,
>>> If this is blocker to you, Have you try to use custom class mediator
>>> to perform above job?
>>>
>>> Best regards,
>>> vanji
>>>
>>> On Tue, Dec 16, 2014 at 2:03 PM, Elilmatha Sivanesan <
>>> elilma...@wso2.com> wrote:
>>>

 Hi all,
 I need to convert the json string like the following {"name":
 {"is":"john"}} to {\"name\": {\"is\":\"john\"}}

 I wrote the javascript as follows which works well on the online
 java script editor. The script
 
 
 
 Create Object from JSON String
 
 
 var p ='{"name": {"is":"john"}}';
 var x = p.replace(/\"/g,'\\"');
 document.write(x);
 
 
 

 So I wrote the script in the synapse configuration as below.
  
 var qReplacedString = q.replace(/\"/g,'\\"');
 mc.setProperty('uri.var.query1',qReplacedString);
 ]]>
 

 But it gives me the following errors. Is there any issues on using
 /\"/ character ,What would be the problem on this.

 ERROR - ScriptMediator The script engine returned an error
 executing the inlined js script function mediate
 [2014-12-16 13:50:45,113]  INFO
 {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
  com.sun.phobos.script.util.ExtendedScriptException:
 org.mozilla.javascript.EvaluatorException: The choice of Java
 constructor replace matching JavaScript argument types 
 (function,string) is
 ambiguous; candidate constructors are:
 [2014-12-16 13:50:45,113]  INFO
 {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
  class java.lang.String
 replace(java.lang.CharSequence,java.lang.CharSequence)
 [2014-12-16 13:50:45,113]  INFO
 {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
  class java.lang.String replace(char,char) (#4) in 
 >>> Source> at line number 4
 [2014-12-16 13:50:45,113]  INFO
 {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler}

Re: [Dev] javascript.EvaluatorException in replace function

2014-12-16 Thread Vanjikumaran Sivajothy
Hi,
I have tried this scenario with wso2 esb 4.8.1 with below[1] proxy that
simulate your scenario.




http://ws.apache.org/ns/synapse";
   name="Scripting"
   transports="https,http"
   statistics="disable"
   trace="disable"
   startOnLoad="true">
   
  
  *   var Str = '{"name": {"is":"john"}}'; *
* var qReplacedString =
Str.replace(new RegExp(/\"/g),'\\"');
 *
*
 mc.setProperty('testingJS',qReplacedString);*
* *
 

 
 
  
   
   



and i have tried with json object in the JS with the fix given in the [2]
and it worked


http://ws.apache.org/ns/synapse";
   name="Scripting"
   transports="https,http"
   statistics="disable"
   trace="disable"
   startOnLoad="true">
   
  
   *  var jsonObj = {"name": {"is":"john"}}; *
* var jsonStr
= JSON.stringify(jsonObj);*
* var qReplacedString
= jsonStr.replace(new RegExp(/\"/g),'\\"');
   *
*
 mc.setProperty('testingJS',qReplacedString);*
* *
 

 
 
  
   
   




[2]
https://wso2.org/jira/browse/ESBJAVA-3019


On Tue, Dec 16, 2014 at 5:07 PM, Elilmatha Sivanesan 
wrote:
>
> Ok , Thank you.
>
> On Tue, Dec 16, 2014 at 5:05 PM, Vanjikumaran Sivajothy 
> wrote:
>>
>> Since there is a bug in the milestone pack, I would recommend you to
>> write a class mediator and perform this task.
>>
>>
>> On Tue, Dec 16, 2014 at 4:25 PM, Elilmatha Sivanesan 
>> wrote:
>>>
>>> It is not working with m2,m3
>>>
>>> On Tue, Dec 16, 2014 at 3:26 PM, Elilmatha Sivanesan >> > wrote:

 Yes now I'm running this with 4.9.0 m3

 On Tue, Dec 16, 2014 at 3:19 PM, Vanjikumaran Sivajothy >>> > wrote:
>
> Can you please run this with ESB 4.9.0 m1/m2 ?
>
> On Tue, Dec 16, 2014 at 2:14 PM, Vanjikumaran Sivajothy <
> va...@wso2.com> wrote:
>>
>> Hi elimatha,
>> If this is blocker to you, Have you try to use custom class mediator
>> to perform above job?
>>
>> Best regards,
>> vanji
>>
>> On Tue, Dec 16, 2014 at 2:03 PM, Elilmatha Sivanesan <
>> elilma...@wso2.com> wrote:
>>
>>>
>>> Hi all,
>>> I need to convert the json string like the following {"name":
>>> {"is":"john"}} to {\"name\": {\"is\":\"john\"}}
>>>
>>> I wrote the javascript as follows which works well on the online
>>> java script editor. The script
>>> 
>>> 
>>> 
>>> Create Object from JSON String
>>> 
>>> 
>>> var p ='{"name": {"is":"john"}}';
>>> var x = p.replace(/\"/g,'\\"');
>>> document.write(x);
>>> 
>>> 
>>> 
>>>
>>> So I wrote the script in the synapse configuration as below.
>>>  >> var q = mc.getProperty('uri.var.query1');
>>> 
>>> var qReplacedString = q.replace(/\"/g,'\\"');
>>> mc.setProperty('uri.var.query1',qReplacedString);
>>> ]]>
>>> 
>>>
>>> But it gives me the following errors. Is there any issues on using
>>> /\"/ character ,What would be the problem on this.
>>>
>>> ERROR - ScriptMediator The script engine returned an error executing
>>> the inlined js script function mediate
>>> [2014-12-16 13:50:45,113]  INFO
>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>>>  com.sun.phobos.script.util.ExtendedScriptException:
>>> org.mozilla.javascript.EvaluatorException: The choice of Java
>>> constructor replace matching JavaScript argument types 
>>> (function,string) is
>>> ambiguous; candidate constructors are:
>>> [2014-12-16 13:50:45,113]  INFO
>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>>>  class java.lang.String
>>> replace(java.lang.CharSequence,java.lang.CharSequence)
>>> [2014-12-16 13:50:45,113]  INFO
>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>>>  class java.lang.String replace(char,char) (#4) in 
>>> >> Source> at line number 4
>>> [2014-12-16 13:50:45,113]  INFO
>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>>>  at
>>> com.sun.phobos.script.javascript.RhinoCompiledScript.eval(RhinoCompiledScript.java:68)
>>> [2014-12-16 13:50:45,113]  INFO
>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>>>  at javax.script.CompiledScript.eval(CompiledScript.java:92)
>>> [2014-12-16 13:50:45,113]  INFO
>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>>>  at
>>> org.apache.synapse.mediators.bsf.ScriptMediator.mediateForInlineScript(ScriptMediator.java:291)
>>> [2014-12-16 13:50:45,113]  INFO
>>> {org.wso2.carbon.automation.co

Re: [Dev] javascript.EvaluatorException in replace function

2014-12-16 Thread Elilmatha Sivanesan
Ok , Thank you.

On Tue, Dec 16, 2014 at 5:05 PM, Vanjikumaran Sivajothy 
wrote:
>
> Since there is a bug in the milestone pack, I would recommend you to write
> a class mediator and perform this task.
>
>
> On Tue, Dec 16, 2014 at 4:25 PM, Elilmatha Sivanesan 
> wrote:
>>
>> It is not working with m2,m3
>>
>> On Tue, Dec 16, 2014 at 3:26 PM, Elilmatha Sivanesan 
>> wrote:
>>>
>>> Yes now I'm running this with 4.9.0 m3
>>>
>>> On Tue, Dec 16, 2014 at 3:19 PM, Vanjikumaran Sivajothy 
>>> wrote:

 Can you please run this with ESB 4.9.0 m1/m2 ?

 On Tue, Dec 16, 2014 at 2:14 PM, Vanjikumaran Sivajothy >>> > wrote:
>
> Hi elimatha,
> If this is blocker to you, Have you try to use custom class mediator
> to perform above job?
>
> Best regards,
> vanji
>
> On Tue, Dec 16, 2014 at 2:03 PM, Elilmatha Sivanesan <
> elilma...@wso2.com> wrote:
>
>>
>> Hi all,
>> I need to convert the json string like the following {"name":
>> {"is":"john"}} to {\"name\": {\"is\":\"john\"}}
>>
>> I wrote the javascript as follows which works well on the online java
>> script editor. The script
>> 
>> 
>> 
>> Create Object from JSON String
>> 
>> 
>> var p ='{"name": {"is":"john"}}';
>> var x = p.replace(/\"/g,'\\"');
>> document.write(x);
>> 
>> 
>> 
>>
>> So I wrote the script in the synapse configuration as below.
>>  > var q = mc.getProperty('uri.var.query1');
>> 
>> var qReplacedString = q.replace(/\"/g,'\\"');
>> mc.setProperty('uri.var.query1',qReplacedString);
>> ]]>
>> 
>>
>> But it gives me the following errors. Is there any issues on using
>> /\"/ character ,What would be the problem on this.
>>
>> ERROR - ScriptMediator The script engine returned an error executing
>> the inlined js script function mediate
>> [2014-12-16 13:50:45,113]  INFO
>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>>  com.sun.phobos.script.util.ExtendedScriptException:
>> org.mozilla.javascript.EvaluatorException: The choice of Java
>> constructor replace matching JavaScript argument types (function,string) 
>> is
>> ambiguous; candidate constructors are:
>> [2014-12-16 13:50:45,113]  INFO
>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>>  class java.lang.String
>> replace(java.lang.CharSequence,java.lang.CharSequence)
>> [2014-12-16 13:50:45,113]  INFO
>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>>  class java.lang.String replace(char,char) (#4) in 
>> > Source> at line number 4
>> [2014-12-16 13:50:45,113]  INFO
>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>>  at
>> com.sun.phobos.script.javascript.RhinoCompiledScript.eval(RhinoCompiledScript.java:68)
>> [2014-12-16 13:50:45,113]  INFO
>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>>  at javax.script.CompiledScript.eval(CompiledScript.java:92)
>> [2014-12-16 13:50:45,113]  INFO
>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>>  at
>> org.apache.synapse.mediators.bsf.ScriptMediator.mediateForInlineScript(ScriptMediator.java:291)
>> [2014-12-16 13:50:45,113]  INFO
>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>>  at
>> org.apache.synapse.mediators.bsf.ScriptMediator.invokeScript(ScriptMediator.java:235)
>> [2014-12-16 13:50:45,114]  INFO
>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>>  at
>> org.apache.synapse.mediators.bsf.ScriptMediator.mediate(ScriptMediator.java:203)
>> [2014-12-16 13:50:45,114]  INFO
>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>>  at
>> org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:77)
>> [2014-12-16 13:50:45,114]  INFO
>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>>  at
>> org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:47)
>> [2014-12-16 13:50:45,114]  INFO
>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>>  at
>> org.apache.synapse.mediators.template.TemplateMediator.mediate(TemplateMediator.java:77)
>> [2014-12-16 13:50:45,114]  INFO
>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>>  at
>> org.apache.synapse.mediators.template.InvokeMediator.mediate(InvokeMediator.java:129)
>> [2014-12-16 13:50:45,114]  INFO
>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>>  at
>> org.apache.synapse.mediat

Re: [Dev] javascript.EvaluatorException in replace function

2014-12-16 Thread Vanjikumaran Sivajothy
Since there is a bug in the milestone pack, I would recommend you to write
a class mediator and perform this task.


On Tue, Dec 16, 2014 at 4:25 PM, Elilmatha Sivanesan 
wrote:
>
> It is not working with m2,m3
>
> On Tue, Dec 16, 2014 at 3:26 PM, Elilmatha Sivanesan 
> wrote:
>>
>> Yes now I'm running this with 4.9.0 m3
>>
>> On Tue, Dec 16, 2014 at 3:19 PM, Vanjikumaran Sivajothy 
>> wrote:
>>>
>>> Can you please run this with ESB 4.9.0 m1/m2 ?
>>>
>>> On Tue, Dec 16, 2014 at 2:14 PM, Vanjikumaran Sivajothy 
>>> wrote:

 Hi elimatha,
 If this is blocker to you, Have you try to use custom class mediator to
 perform above job?

 Best regards,
 vanji

 On Tue, Dec 16, 2014 at 2:03 PM, Elilmatha Sivanesan <
 elilma...@wso2.com> wrote:

>
> Hi all,
> I need to convert the json string like the following {"name":
> {"is":"john"}} to {\"name\": {\"is\":\"john\"}}
>
> I wrote the javascript as follows which works well on the online java
> script editor. The script
> 
> 
> 
> Create Object from JSON String
> 
> 
> var p ='{"name": {"is":"john"}}';
> var x = p.replace(/\"/g,'\\"');
> document.write(x);
> 
> 
> 
>
> So I wrote the script in the synapse configuration as below.
>   var q = mc.getProperty('uri.var.query1');
> 
> var qReplacedString = q.replace(/\"/g,'\\"');
> mc.setProperty('uri.var.query1',qReplacedString);
> ]]>
> 
>
> But it gives me the following errors. Is there any issues on using
> /\"/ character ,What would be the problem on this.
>
> ERROR - ScriptMediator The script engine returned an error executing
> the inlined js script function mediate
> [2014-12-16 13:50:45,113]  INFO
> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>  com.sun.phobos.script.util.ExtendedScriptException:
> org.mozilla.javascript.EvaluatorException: The choice of Java
> constructor replace matching JavaScript argument types (function,string) 
> is
> ambiguous; candidate constructors are:
> [2014-12-16 13:50:45,113]  INFO
> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>  class java.lang.String
> replace(java.lang.CharSequence,java.lang.CharSequence)
> [2014-12-16 13:50:45,113]  INFO
> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>  class java.lang.String replace(char,char) (#4) in 
>  Source> at line number 4
> [2014-12-16 13:50:45,113]  INFO
> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>  at
> com.sun.phobos.script.javascript.RhinoCompiledScript.eval(RhinoCompiledScript.java:68)
> [2014-12-16 13:50:45,113]  INFO
> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>  at javax.script.CompiledScript.eval(CompiledScript.java:92)
> [2014-12-16 13:50:45,113]  INFO
> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>  at
> org.apache.synapse.mediators.bsf.ScriptMediator.mediateForInlineScript(ScriptMediator.java:291)
> [2014-12-16 13:50:45,113]  INFO
> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>  at
> org.apache.synapse.mediators.bsf.ScriptMediator.invokeScript(ScriptMediator.java:235)
> [2014-12-16 13:50:45,114]  INFO
> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>  at
> org.apache.synapse.mediators.bsf.ScriptMediator.mediate(ScriptMediator.java:203)
> [2014-12-16 13:50:45,114]  INFO
> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>  at
> org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:77)
> [2014-12-16 13:50:45,114]  INFO
> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>  at
> org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:47)
> [2014-12-16 13:50:45,114]  INFO
> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>  at
> org.apache.synapse.mediators.template.TemplateMediator.mediate(TemplateMediator.java:77)
> [2014-12-16 13:50:45,114]  INFO
> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>  at
> org.apache.synapse.mediators.template.InvokeMediator.mediate(InvokeMediator.java:129)
> [2014-12-16 13:50:45,114]  INFO
> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>  at
> org.apache.synapse.mediators.template.InvokeMediator.mediate(InvokeMediator.java:78)
> [2014-12-16 13:50:45,114]  INFO
> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>  at
> org.apache.sy

Re: [Dev] javascript.EvaluatorException in replace function

2014-12-16 Thread Elilmatha Sivanesan
It is not working with m2,m3

On Tue, Dec 16, 2014 at 3:26 PM, Elilmatha Sivanesan 
wrote:
>
> Yes now I'm running this with 4.9.0 m3
>
> On Tue, Dec 16, 2014 at 3:19 PM, Vanjikumaran Sivajothy 
> wrote:
>>
>> Can you please run this with ESB 4.9.0 m1/m2 ?
>>
>> On Tue, Dec 16, 2014 at 2:14 PM, Vanjikumaran Sivajothy 
>> wrote:
>>>
>>> Hi elimatha,
>>> If this is blocker to you, Have you try to use custom class mediator to
>>> perform above job?
>>>
>>> Best regards,
>>> vanji
>>>
>>> On Tue, Dec 16, 2014 at 2:03 PM, Elilmatha Sivanesan >> > wrote:
>>>

 Hi all,
 I need to convert the json string like the following {"name":
 {"is":"john"}} to {\"name\": {\"is\":\"john\"}}

 I wrote the javascript as follows which works well on the online java
 script editor. The script
 
 
 
 Create Object from JSON String
 
 
 var p ='{"name": {"is":"john"}}';
 var x = p.replace(/\"/g,'\\"');
 document.write(x);
 
 
 

 So I wrote the script in the synapse configuration as below.
  
 var qReplacedString = q.replace(/\"/g,'\\"');
 mc.setProperty('uri.var.query1',qReplacedString);
 ]]>
 

 But it gives me the following errors. Is there any issues on using
 /\"/ character ,What would be the problem on this.

 ERROR - ScriptMediator The script engine returned an error executing
 the inlined js script function mediate
 [2014-12-16 13:50:45,113]  INFO
 {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
  com.sun.phobos.script.util.ExtendedScriptException:
 org.mozilla.javascript.EvaluatorException: The choice of Java
 constructor replace matching JavaScript argument types (function,string) is
 ambiguous; candidate constructors are:
 [2014-12-16 13:50:45,113]  INFO
 {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
  class java.lang.String
 replace(java.lang.CharSequence,java.lang.CharSequence)
 [2014-12-16 13:50:45,113]  INFO
 {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
  class java.lang.String replace(char,char) (#4) in >>> Source> at line number 4
 [2014-12-16 13:50:45,113]  INFO
 {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
  at
 com.sun.phobos.script.javascript.RhinoCompiledScript.eval(RhinoCompiledScript.java:68)
 [2014-12-16 13:50:45,113]  INFO
 {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
  at javax.script.CompiledScript.eval(CompiledScript.java:92)
 [2014-12-16 13:50:45,113]  INFO
 {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
  at
 org.apache.synapse.mediators.bsf.ScriptMediator.mediateForInlineScript(ScriptMediator.java:291)
 [2014-12-16 13:50:45,113]  INFO
 {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
  at
 org.apache.synapse.mediators.bsf.ScriptMediator.invokeScript(ScriptMediator.java:235)
 [2014-12-16 13:50:45,114]  INFO
 {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
  at
 org.apache.synapse.mediators.bsf.ScriptMediator.mediate(ScriptMediator.java:203)
 [2014-12-16 13:50:45,114]  INFO
 {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
  at
 org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:77)
 [2014-12-16 13:50:45,114]  INFO
 {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
  at
 org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:47)
 [2014-12-16 13:50:45,114]  INFO
 {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
  at
 org.apache.synapse.mediators.template.TemplateMediator.mediate(TemplateMediator.java:77)
 [2014-12-16 13:50:45,114]  INFO
 {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
  at
 org.apache.synapse.mediators.template.InvokeMediator.mediate(InvokeMediator.java:129)
 [2014-12-16 13:50:45,114]  INFO
 {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
  at
 org.apache.synapse.mediators.template.InvokeMediator.mediate(InvokeMediator.java:78)
 [2014-12-16 13:50:45,114]  INFO
 {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
  at
 org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:77)
 [2014-12-16 13:50:45,114]  INFO
 {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
  at
 org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:255)
 [2014-12-16 13:50:45,115]  INFO
 

Re: [Dev] javascript.EvaluatorException in replace function

2014-12-16 Thread Elilmatha Sivanesan
Yes now I'm running this with 4.9.0 m3

On Tue, Dec 16, 2014 at 3:19 PM, Vanjikumaran Sivajothy 
wrote:
>
> Can you please run this with ESB 4.9.0 m1/m2 ?
>
> On Tue, Dec 16, 2014 at 2:14 PM, Vanjikumaran Sivajothy 
> wrote:
>>
>> Hi elimatha,
>> If this is blocker to you, Have you try to use custom class mediator to
>> perform above job?
>>
>> Best regards,
>> vanji
>>
>> On Tue, Dec 16, 2014 at 2:03 PM, Elilmatha Sivanesan 
>> wrote:
>>
>>>
>>> Hi all,
>>> I need to convert the json string like the following {"name":
>>> {"is":"john"}} to {\"name\": {\"is\":\"john\"}}
>>>
>>> I wrote the javascript as follows which works well on the online java
>>> script editor. The script
>>> 
>>> 
>>> 
>>> Create Object from JSON String
>>> 
>>> 
>>> var p ='{"name": {"is":"john"}}';
>>> var x = p.replace(/\"/g,'\\"');
>>> document.write(x);
>>> 
>>> 
>>> 
>>>
>>> So I wrote the script in the synapse configuration as below.
>>>  >> var q = mc.getProperty('uri.var.query1');
>>> 
>>> var qReplacedString = q.replace(/\"/g,'\\"');
>>> mc.setProperty('uri.var.query1',qReplacedString);
>>> ]]>
>>> 
>>>
>>> But it gives me the following errors. Is there any issues on using /\"/ 
>>> character
>>> ,What would be the problem on this.
>>>
>>> ERROR - ScriptMediator The script engine returned an error executing the
>>> inlined js script function mediate
>>> [2014-12-16 13:50:45,113]  INFO
>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>>>  com.sun.phobos.script.util.ExtendedScriptException:
>>> org.mozilla.javascript.EvaluatorException: The choice of Java
>>> constructor replace matching JavaScript argument types (function,string) is
>>> ambiguous; candidate constructors are:
>>> [2014-12-16 13:50:45,113]  INFO
>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>>>  class java.lang.String
>>> replace(java.lang.CharSequence,java.lang.CharSequence)
>>> [2014-12-16 13:50:45,113]  INFO
>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>>>  class java.lang.String replace(char,char) (#4) in >> Source> at line number 4
>>> [2014-12-16 13:50:45,113]  INFO
>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>>>  at
>>> com.sun.phobos.script.javascript.RhinoCompiledScript.eval(RhinoCompiledScript.java:68)
>>> [2014-12-16 13:50:45,113]  INFO
>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>>>  at javax.script.CompiledScript.eval(CompiledScript.java:92)
>>> [2014-12-16 13:50:45,113]  INFO
>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>>>  at
>>> org.apache.synapse.mediators.bsf.ScriptMediator.mediateForInlineScript(ScriptMediator.java:291)
>>> [2014-12-16 13:50:45,113]  INFO
>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>>>  at
>>> org.apache.synapse.mediators.bsf.ScriptMediator.invokeScript(ScriptMediator.java:235)
>>> [2014-12-16 13:50:45,114]  INFO
>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>>>  at
>>> org.apache.synapse.mediators.bsf.ScriptMediator.mediate(ScriptMediator.java:203)
>>> [2014-12-16 13:50:45,114]  INFO
>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>>>  at
>>> org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:77)
>>> [2014-12-16 13:50:45,114]  INFO
>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>>>  at
>>> org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:47)
>>> [2014-12-16 13:50:45,114]  INFO
>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>>>  at
>>> org.apache.synapse.mediators.template.TemplateMediator.mediate(TemplateMediator.java:77)
>>> [2014-12-16 13:50:45,114]  INFO
>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>>>  at
>>> org.apache.synapse.mediators.template.InvokeMediator.mediate(InvokeMediator.java:129)
>>> [2014-12-16 13:50:45,114]  INFO
>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>>>  at
>>> org.apache.synapse.mediators.template.InvokeMediator.mediate(InvokeMediator.java:78)
>>> [2014-12-16 13:50:45,114]  INFO
>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>>>  at
>>> org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:77)
>>> [2014-12-16 13:50:45,114]  INFO
>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>>>  at
>>> org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:255)
>>> [2014-12-16 13:50:45,115]  INFO
>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>>>  at
>>> org.apache.synapse.core.axis2.Axis2SynapseEnvironment.mediateFromContinuationStateStack(Axis2SynapseEnvironment.java:556)

Re: [Dev] javascript.EvaluatorException in replace function

2014-12-16 Thread Vanjikumaran Sivajothy
Can you please run this with ESB 4.9.0 m1/m2 ?

On Tue, Dec 16, 2014 at 2:14 PM, Vanjikumaran Sivajothy 
wrote:
>
> Hi elimatha,
> If this is blocker to you, Have you try to use custom class mediator to
> perform above job?
>
> Best regards,
> vanji
>
> On Tue, Dec 16, 2014 at 2:03 PM, Elilmatha Sivanesan 
> wrote:
>
>>
>> Hi all,
>> I need to convert the json string like the following {"name":
>> {"is":"john"}} to {\"name\": {\"is\":\"john\"}}
>>
>> I wrote the javascript as follows which works well on the online java
>> script editor. The script
>> 
>> 
>> 
>> Create Object from JSON String
>> 
>> 
>> var p ='{"name": {"is":"john"}}';
>> var x = p.replace(/\"/g,'\\"');
>> document.write(x);
>> 
>> 
>> 
>>
>> So I wrote the script in the synapse configuration as below.
>>  > var q = mc.getProperty('uri.var.query1');
>> 
>> var qReplacedString = q.replace(/\"/g,'\\"');
>> mc.setProperty('uri.var.query1',qReplacedString);
>> ]]>
>> 
>>
>> But it gives me the following errors. Is there any issues on using /\"/ 
>> character
>> ,What would be the problem on this.
>>
>> ERROR - ScriptMediator The script engine returned an error executing the
>> inlined js script function mediate
>> [2014-12-16 13:50:45,113]  INFO
>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>>  com.sun.phobos.script.util.ExtendedScriptException:
>> org.mozilla.javascript.EvaluatorException: The choice of Java
>> constructor replace matching JavaScript argument types (function,string) is
>> ambiguous; candidate constructors are:
>> [2014-12-16 13:50:45,113]  INFO
>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>>  class java.lang.String
>> replace(java.lang.CharSequence,java.lang.CharSequence)
>> [2014-12-16 13:50:45,113]  INFO
>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>>  class java.lang.String replace(char,char) (#4) in > Source> at line number 4
>> [2014-12-16 13:50:45,113]  INFO
>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>>  at
>> com.sun.phobos.script.javascript.RhinoCompiledScript.eval(RhinoCompiledScript.java:68)
>> [2014-12-16 13:50:45,113]  INFO
>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>>  at javax.script.CompiledScript.eval(CompiledScript.java:92)
>> [2014-12-16 13:50:45,113]  INFO
>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>>  at
>> org.apache.synapse.mediators.bsf.ScriptMediator.mediateForInlineScript(ScriptMediator.java:291)
>> [2014-12-16 13:50:45,113]  INFO
>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>>  at
>> org.apache.synapse.mediators.bsf.ScriptMediator.invokeScript(ScriptMediator.java:235)
>> [2014-12-16 13:50:45,114]  INFO
>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>>  at
>> org.apache.synapse.mediators.bsf.ScriptMediator.mediate(ScriptMediator.java:203)
>> [2014-12-16 13:50:45,114]  INFO
>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>>  at
>> org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:77)
>> [2014-12-16 13:50:45,114]  INFO
>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>>  at
>> org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:47)
>> [2014-12-16 13:50:45,114]  INFO
>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>>  at
>> org.apache.synapse.mediators.template.TemplateMediator.mediate(TemplateMediator.java:77)
>> [2014-12-16 13:50:45,114]  INFO
>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>>  at
>> org.apache.synapse.mediators.template.InvokeMediator.mediate(InvokeMediator.java:129)
>> [2014-12-16 13:50:45,114]  INFO
>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>>  at
>> org.apache.synapse.mediators.template.InvokeMediator.mediate(InvokeMediator.java:78)
>> [2014-12-16 13:50:45,114]  INFO
>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>>  at
>> org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:77)
>> [2014-12-16 13:50:45,114]  INFO
>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>>  at
>> org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:255)
>> [2014-12-16 13:50:45,115]  INFO
>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>>  at
>> org.apache.synapse.core.axis2.Axis2SynapseEnvironment.mediateFromContinuationStateStack(Axis2SynapseEnvironment.java:556)
>> [2014-12-16 13:50:45,115]  INFO
>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>>  at
>> org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:198

Re: [Dev] javascript.EvaluatorException in replace function

2014-12-16 Thread Vanjikumaran Sivajothy
Hi elimatha,
If this is blocker to you, Have you try to use custom class mediator to
perform above job?

Best regards,
vanji

On Tue, Dec 16, 2014 at 2:03 PM, Elilmatha Sivanesan 
wrote:
>
>
> Hi all,
> I need to convert the json string like the following {"name":
> {"is":"john"}} to {\"name\": {\"is\":\"john\"}}
>
> I wrote the javascript as follows which works well on the online java
> script editor. The script
> 
> 
> 
> Create Object from JSON String
> 
> 
> var p ='{"name": {"is":"john"}}';
> var x = p.replace(/\"/g,'\\"');
> document.write(x);
> 
> 
> 
>
> So I wrote the script in the synapse configuration as below.
>   var q = mc.getProperty('uri.var.query1');
> 
> var qReplacedString = q.replace(/\"/g,'\\"');
> mc.setProperty('uri.var.query1',qReplacedString);
> ]]>
> 
>
> But it gives me the following errors. Is there any issues on using /\"/ 
> character
> ,What would be the problem on this.
>
> ERROR - ScriptMediator The script engine returned an error executing the
> inlined js script function mediate
> [2014-12-16 13:50:45,113]  INFO
> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>  com.sun.phobos.script.util.ExtendedScriptException:
> org.mozilla.javascript.EvaluatorException: The choice of Java constructor
> replace matching JavaScript argument types (function,string) is ambiguous;
> candidate constructors are:
> [2014-12-16 13:50:45,113]  INFO
> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>  class java.lang.String
> replace(java.lang.CharSequence,java.lang.CharSequence)
> [2014-12-16 13:50:45,113]  INFO
> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>  class java.lang.String replace(char,char) (#4) in  Source> at line number 4
> [2014-12-16 13:50:45,113]  INFO
> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>  at
> com.sun.phobos.script.javascript.RhinoCompiledScript.eval(RhinoCompiledScript.java:68)
> [2014-12-16 13:50:45,113]  INFO
> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>  at javax.script.CompiledScript.eval(CompiledScript.java:92)
> [2014-12-16 13:50:45,113]  INFO
> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>  at
> org.apache.synapse.mediators.bsf.ScriptMediator.mediateForInlineScript(ScriptMediator.java:291)
> [2014-12-16 13:50:45,113]  INFO
> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>  at
> org.apache.synapse.mediators.bsf.ScriptMediator.invokeScript(ScriptMediator.java:235)
> [2014-12-16 13:50:45,114]  INFO
> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>  at
> org.apache.synapse.mediators.bsf.ScriptMediator.mediate(ScriptMediator.java:203)
> [2014-12-16 13:50:45,114]  INFO
> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>  at
> org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:77)
> [2014-12-16 13:50:45,114]  INFO
> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>  at
> org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:47)
> [2014-12-16 13:50:45,114]  INFO
> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>  at
> org.apache.synapse.mediators.template.TemplateMediator.mediate(TemplateMediator.java:77)
> [2014-12-16 13:50:45,114]  INFO
> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>  at
> org.apache.synapse.mediators.template.InvokeMediator.mediate(InvokeMediator.java:129)
> [2014-12-16 13:50:45,114]  INFO
> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>  at
> org.apache.synapse.mediators.template.InvokeMediator.mediate(InvokeMediator.java:78)
> [2014-12-16 13:50:45,114]  INFO
> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>  at
> org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:77)
> [2014-12-16 13:50:45,114]  INFO
> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>  at
> org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:255)
> [2014-12-16 13:50:45,115]  INFO
> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>  at
> org.apache.synapse.core.axis2.Axis2SynapseEnvironment.mediateFromContinuationStateStack(Axis2SynapseEnvironment.java:556)
> [2014-12-16 13:50:45,115]  INFO
> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>  at
> org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:198)
> [2014-12-16 13:50:45,115]  INFO
> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
>  at
> org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:488)
> [2014-12-

[Dev] javascript.EvaluatorException in replace function

2014-12-16 Thread Elilmatha Sivanesan
Hi all,
I need to convert the json string like the following {"name":
{"is":"john"}} to {\"name\": {\"is\":\"john\"}}

I wrote the javascript as follows which works well on the online java
script editor. The script



Create Object from JSON String


var p ='{"name": {"is":"john"}}';
var x = p.replace(/\"/g,'\\"');
document.write(x);




So I wrote the script in the synapse configuration as below.
 
var qReplacedString = q.replace(/\"/g,'\\"');
mc.setProperty('uri.var.query1',qReplacedString);
]]>


But it gives me the following errors. Is there any issues on using
/\"/ character
,What would be the problem on this.

ERROR - ScriptMediator The script engine returned an error executing the
inlined js script function mediate
[2014-12-16 13:50:45,113]  INFO
{org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
 com.sun.phobos.script.util.ExtendedScriptException:
org.mozilla.javascript.EvaluatorException: The choice of Java constructor
replace matching JavaScript argument types (function,string) is ambiguous;
candidate constructors are:
[2014-12-16 13:50:45,113]  INFO
{org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
 class java.lang.String
replace(java.lang.CharSequence,java.lang.CharSequence)
[2014-12-16 13:50:45,113]  INFO
{org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
 class java.lang.String replace(char,char) (#4) in  at line number 4
[2014-12-16 13:50:45,113]  INFO
{org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
 at
com.sun.phobos.script.javascript.RhinoCompiledScript.eval(RhinoCompiledScript.java:68)
[2014-12-16 13:50:45,113]  INFO
{org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
 at javax.script.CompiledScript.eval(CompiledScript.java:92)
[2014-12-16 13:50:45,113]  INFO
{org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
 at
org.apache.synapse.mediators.bsf.ScriptMediator.mediateForInlineScript(ScriptMediator.java:291)
[2014-12-16 13:50:45,113]  INFO
{org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
 at
org.apache.synapse.mediators.bsf.ScriptMediator.invokeScript(ScriptMediator.java:235)
[2014-12-16 13:50:45,114]  INFO
{org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
 at
org.apache.synapse.mediators.bsf.ScriptMediator.mediate(ScriptMediator.java:203)
[2014-12-16 13:50:45,114]  INFO
{org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
 at
org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:77)
[2014-12-16 13:50:45,114]  INFO
{org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
 at
org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:47)
[2014-12-16 13:50:45,114]  INFO
{org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
 at
org.apache.synapse.mediators.template.TemplateMediator.mediate(TemplateMediator.java:77)
[2014-12-16 13:50:45,114]  INFO
{org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
 at
org.apache.synapse.mediators.template.InvokeMediator.mediate(InvokeMediator.java:129)
[2014-12-16 13:50:45,114]  INFO
{org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
 at
org.apache.synapse.mediators.template.InvokeMediator.mediate(InvokeMediator.java:78)
[2014-12-16 13:50:45,114]  INFO
{org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
 at
org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:77)
[2014-12-16 13:50:45,114]  INFO
{org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
 at
org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:255)
[2014-12-16 13:50:45,115]  INFO
{org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
 at
org.apache.synapse.core.axis2.Axis2SynapseEnvironment.mediateFromContinuationStateStack(Axis2SynapseEnvironment.java:556)
[2014-12-16 13:50:45,115]  INFO
{org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
 at
org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:198)
[2014-12-16 13:50:45,115]  INFO
{org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
 at
org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:488)
[2014-12-16 13:50:45,115]  INFO
{org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
 at
org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:170)
[2014-12-16 13:50:45,115]  INFO
{org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} -
 at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
[2014-12-16 13:50:45,115]  INFO
{org.