How to pass report parameter to data source url - birt

under my property binding I have this:
<expression name="value" type="javascript">"http://localhost:8080/myapp/report/fetch?param1 = "+params["param1"];</expression>
but when I run my app I am getting this error:
java.io.FileNotFoundException: http://localhost:8080/myapp/report/fetch%3Fparam1%20=%20value1
as you can see the ? mark in the url is encoded into %3 , any way to handle this?

Remove the spaces in your URL infront of and after the =. They are not getting removed and are not allowed at this place in the URL. The encoding of ? to %3F is fine as you can see from the HTML URL encoding table:
Change:
<expression name="value" type="javascript">"http://localhost:8080/myapp/report/fetch?param1 = "+params["param1"];</expression>
to:
<expression name="value" type="javascript">"http://localhost:8080/myapp/report/fetch?param1="+params["param1"];</expression>

Related

Chef deployment with "$" dollar sign in string truncates encrypted password

I have a chef deployment that runs like this:
encryptedvalues = chef_vault_item(node.chef_environment, 'my_app_name')
do_windows_service "Installing Windows Service" do
action :install
#...
app_config_changes ({
"configuration/secureAppSettings/add[#key='XSWebserviceUser']/#value" => "#{encryptedvalues['XSWebserviceUser']}",
"configuration/secureAppSettings/add[#key='XSWebservicePassword']/#value" => "#{encryptedvalues['XSWebservicePassword']}"
})
end
I have determined that the values are correct, they are inserted into the correct position, and everything is fine, until the encrypted password value has "$" in it. I cannot change the password, and tried to escape it by wrapping it in an interpolated string: "#{pass}", but unfortunately it didn't work. Any ideas on how I can get the deploy to succeed?
Originally in the app config it looks like
<secureAppSettings>
<add key="XSWebserviceUser" value="XXX" />
<add key="XSWebservicePassword" value="XXX" />
</secureAppSettings>
and after deployment with a password="xyz#$%xyz"
<secureAppSettings>
<add key="XSWebserviceUser" value="User" />
<add key="XSWebservicePassword" value="xyz#" />
</secureAppSettings>
Update: Checking the logs I see this in the server
4. 2020-01-08T23:36:36.3315043Z STDERR: Cannot convert value "System.String" to type "System.Boolean". Boolean parameters accept only Boolean values and numbers, such as $True, $False, 1 or 0.
Looks like it may actually be an issue with windows powershell?

Comment .XML file content using ruby code

Can anyone tell me how I can comment the following line in my .XML file using Ruby?
I hope this can be done by using "nokogiri".
<message group="1" sub_group="1" type="none" destination="mydata" remark="mylist" userOnly="true "/>
output should be:
<!-- <message group="1" sub_group="1" type="none" destination="mydata" remark="mylist" userOnly="true "/> -->
You can search your document with the search method, add a comment with Comment.new and then remove the original line with the remove method.
Nokogiri::XML::Comment.new(doc, node.to_s)
Class: Nokogiri::XML::Comment
Edit:
I implemented an example, but used replace instead of remove:
require 'nokogiri'
f = File.open('./config.xml')
x = Nokogiri::XML(f);
x.search('message').each do |el|
puts(el.to_s)
c = Nokogiri::XML::Comment.new(x, el.to_s);
el.replace(c);
end
File.write('./config.xml', x.to_xml);

How can I return a Unicode escaped string to an HTTP client via an http-inbound-gateway?

I have a simple http-inbound-gateway that calls a service-activator and returns the result to the HTTP client.
The service-activator returns a String containing Unicode escape sequences, like this:
Fran\u00e7ais
This is passed to the http-inbound-gateway to be returned to the client as a response payload.
When I call the inbound gateway's URL, however, there seems to be some conversion going on; the escape sequences are rendered into their binary format which my browser cannot render:
Fran�ais
I would like the escape sequences to be passed through the inbound-http-gateway and returned to the browser.
What I should be doing to achieve that result?
Here is the relevant SI config:
<http:inbound-gateway
id="inboundGateway"
request-channel="inboundClientRequestChannel"
request-payload-type="java.lang.String"
reply-channel="inboundClientResponseChannel"
reply-timeout="30000"
supported-methods="GET"
message-converters="stringJsonMessageConverter"
path="/test">
<http:request-mapping produces="application/json"/>
</http:inbound-gateway>
<int:service-activator
input-channel="inboundClientRequestChannel"
output-channel="inboundClientResponseChannel"
ref="clientRequestHandler"/>
<bean id="stringJsonMessageConverter" class="org.springframework.http.converter.StringHttpMessageConverter">
<property name="writeAcceptCharset" value="false"/>
<property name="supportedMediaTypes">
<list>
<value>application/json</value>
</list>
</property>
</bean>
The problem here was that the stringJsonMessageConverter, an instance of org.springframework.http.converter.StringHttpMessageConverter, by default converts Strings to the ISO-8859-1 encoding.
See the Javadoc here. Note the defaultCharset constructor parameter.
Initializing stringJsonMessageConverter to use the UTF-8 encoding solved the problem.

WSO2 Filter Proxy Boolean Expression evaluator issue

in my proxy i'm using a filter mediator. My target is to activate a sequence if some conditions on some properties are verified:
codice = 0
idElementoCross is different from null or empty string or if it exists
tipoElementoCross is different from null or empty string or if it exists
i wrote this condition:
<sequence>
<property name="codice" expression="//codice"></property>
<property name="idElementoCross" expression="//idElementoCross"></property>
<property name="tipoElementoCross" expression="//tipoElementoCross"></property>
<filter xpath="boolean(fn:get-property('codice')=0 and fn:get-property('tipoRisposta')='worker' and fn:get-property('tipoElementoCross')!='null' and fn:get-property('idElementoCross')!='null' and fn:get-property('tipoElementoCross')!='' and fn:get-property('idElementoCross')!='' and fn:get-property('tipoElementoCross') and fn:get-property('idElementoCross'))">
<then> ...
but in my log i see that esb enter the sequence even if idElementoCross and tipoElementoCross are empty.
Im using WSO2 ESB 4.8.1.
What am i missing?
This is because when there is no value, //tipoElementoCross return the node and not the text value :
send <tipoElementoCross></tipoElementoCross>
//tipoElementoCross = <tipoElementoCross></tipoElementoCross>
//tipoElementoCross/text() =

Trouble Parsing XML using Ruby XML Parser

I am having trouble parsing some returned XML using this command: XML::Parser.string(xml_string).parse
Here is the XML I am trying to parse:
<div style=\"border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;\">
<h4>A PHP Error was encountered</h4>
<p>Severity: Notice</p>
<p>Message: Undefined index: HTTP_USER_AGENT</p>
<p>Filename: test</p>
<p>Line Number: test</p>
</div><?xml version=\"1.0\" encoding=\"UTF-8\"?>
<response>
<review>
<reviewer><![CDATA[test]]></reviewer>
<ip><![CDATA[test]]></ip>
rating><![CDATA[test]]></rating>
<content><![CDATA[test.]]></content>
<date><![CDATA[test]]></date>
</review>
</response>
I get this error:
Fatal error: XML declaration allowed only at the start of the document at :10.Fatal error: Extra content at the end of the document at :11.
LibXML::XML::Error: Fatal error: Extra content at the end of the document
What is going on here?
Your string is not a valid XML document; it appears to be two documents concatenated together. (The first one is a "<div>" the second one is a "<response>".)
Try separating them into two strings and parsing each of them separately.
When you are fetching xml_string, I believe you need to set the user agent. You are not providing a user agent so the server serving the XML is choking.
Use this code to add a user agent to your request:
resp = http.post(path, query, {'User-Agent' => "Ruby"})

Resources