I am trying to use janino conditional statements in logback configuration and it is working fine with "if" and "else". But I want to ask if there is it possible to write "else if" in it?
My case -
<if condition='p("log.environment").equals("prod")'>
<then>
<include file="${LOG_CONFIG_DIR}/logback-prod.xml" />
</then>
</if>
<if condition='p("log.environment").equals("uat")'>
<then>
<include file="${LOG_CONFIG_DIR}/logback-uat.xml" />
</then>
</if>
<if condition='p("log.environment").equals("dev")'>
<then>
<include file="${LOG_CONFIG_DIR}/logback-dev.xml" />
</then>
</if>
You can use if-then-else in multi-level
<if condition='p("log.environment").equals("prod")'>
<then>
<include file="${LOG_CONFIG_DIR}/logback-prod.xml" />
</then>
<if condition='p("log.environment").equals("uat")'>
<then>
<include file="${LOG_CONFIG_DIR}/logback-uat.xml" />
</then>
<else>
<include file="${LOG_CONFIG_DIR}/logback-dev.xml" />
</else>
</if>
</if>
Try to do like this.
<if condition=''>
<then>..</then>
<else>
<if condition=''>
<then>..</then>
<else>..</else>
</if>
</else>
</if>
Related
How do you display the response returned by calling a webservice endpoint on a sequence?
Below is the sequence that I use. I would like to display the return value from the dataservice called "CDServiceEndpoint" on the wso2carbon.log. Is that possible? If not, how can I get the data displayed.
<sequence xmlns="http://ws.apache.org/ns/synapse" name="ConcurGetADPExtractFlow" onError="GeneralErrorHandler">
<property xmlns:ns="http://org.apache.synapse/xsd" xmlns:ns3="http://org.apache.synapse/xsd" name="current-context-details" expression="concat(get-property('current-context-details'), ', ConcurGetADPExtractFlow')" />
<property name="scenario" value="ConcurGetADPExtractFlow" />
<log level="custom">
<property name="DEBUGGING" value="ConcurGetADPExtractFlow" />
<property name="start-date" value="2015-02-23" />
<property xmlns:ns="http://org.apache.synapse/xsd" xmlns:ns3="http://org.apache.synapse/xsd" name="End Date" expression="get-property('current-date')" />
</log>
<xslt key="Concur_Get_ADP_Extract_Transformation">
<property name="start-date" value="2015-03-02" />
<property xmlns:ns="http://org.apache.synapse/xsd" xmlns:ns3="http://org.apache.synapse/xsd" name="end-date" expression="get-property('current-date')" />
</xslt>
<property name="post-data-service-sequence" value="ConcurTransformADPExtractFlow" />
<property name="OUT_ONLY" value="false" />
<send receive="DataServiceInvocationErrorFlow">
<endpoint key="ConcurDataServiceEndpoint" />
</send>
<description>Sends a request to the data service for the ADP extract data.</description>
</sequence>
Below is how my DataServiceInvocationErrorFlow looks like.
<sequence xmlns="http://ws.apache.org/ns/synapse" name="DataServiceInvocationErrorFlow">
<filter xmlns:ns="http://org.apache.synapse/xsd" xmlns:m="http://ws.wso2.org/dataservice" xmlns:ns3="http://org.apache.synapse/xsd" xpath="//m:DataServiceFault">
<then>
<log level="custom">
<property name="status" value="data-service-fault" />
</log>
<property name="error_message" expression="//m:DataServiceFault" />
<sequence key="GeneralErrorHandler" />
<drop />
</then>
<else>
<filter source="string-length(get-property('ERROR_MESSAGE'))" regex="0.0">
<then>
<filter xpath="//soapenv:Fault">
<then>
<log level="custom">
<property name="status" value="ERROR" />
</log>
<property name="error_message" expression="//soapenv:Fault" />
<sequence key="GeneralErrorHandler" />
<drop />
</then>
<else>
<log level="custom">
<property name="status" value="success response from DSS" />
</log>
<filter source="string-length(normalize-space(get-property('post-data-service-sequence')))" regex="0.0">
<then />
<else>
<property name="temp-post-data-service-sequence" expression="get-property('post-data-service-sequence')" />
<property name="post-data-service-sequence" value="" />
<sequence key="{get-property('temp-post-data-service-sequence')}" />
</else>
</filter>
</else>
</filter>
</then>
<else>
<property name="error_message" expression="get-property('ERROR_MESSAGE')" />
<sequence key="GeneralErrorHandler" />
<drop />
</else>
</filter>
</else>
</filter>
</sequence>
If by CDServiceEndpoint you meant ConcurDataServiceEndpoint, then you are already handling the response from that endpoint in your DataServiceInvocationErrorFlow sequence that you defined on the Send mediator, which by the way is confusingly named, since your receive sequence will run no matter if you get an error response or a good one. All you need to do is log it inside DataServiceInvocationErrorFlow using Log mediator.
Had you not defined a receive sequence on your Send mediator, the response would have gotten to your outSequence, where you can log it with Log mediator too.
Tiles configuration
<definition name="defaultLayout" template="/{1}/{2}/common/{4}/layouts/layout.jsp">
<put-attribute name="header" value="header.jsp" />
<put-attribute name="body" value="" />
<put-attribute name="footer" value="/{1}/{2}/common/s/footer.jsp" />
</definition>
<!-- Default Layout Defination over -->
<definition name="*/*/*/*/*/index" extends="defaultLayout">
<put-attribute name="body" value="/{1}/{2}/common/s/index.jsp" />
Problem is my defaultLayout definition was not replace with define wildcart in child definition.
When I was hit URL from my browser like http://localhost:8080/etisalat/wap/common/b/index.wfv then
Error is
HTTP Status 404 - /{1}/{2}/common/{4}/layouts/layout.jsp
type Status report
message /{1}/{2}/common/{4}/layouts/layout.jsp
description The requested resource (/{1}/{2}/common/{4}/layouts/layout.jsp) is not available.
Apache Tomcat/6.0.32
The wildcard placeholders are not passed on to the inherited definition.
You would need to
<definition name="defaultLayout.*.*.*" template="/{1}/{2}/common/{3}/layouts/layout.jsp">
<put-attribute name="header" value="header.jsp" />
<put-attribute name="body" value="" />
<put-attribute name="footer" value="/{1}/{2}/common/s/footer.jsp" />
</definition>
<definition name="*/*/*/*/*/index" extends="defaultLayout.{1}.{2}.{4}">
<put-attribute name="body" value="/{1}/{2}/common/s/index.jsp" />
...
From proxy service or sequence or rest API WSO2 developer studio 3.6.0 is removing $ from XPATH variables like $ctx, $trp, $body etc after build. Please advice me how to fix this issue or work around for this.
example sequence
<sequence xmlns="http://ws.apache.org/ns/synapse" name="XMFSequence">
<property xmlns:ns="http://org.apache.synapse/xsd" xmlns:np1="http://ws.apache.org/commons/ns/payload" xmlns:np="http://schemas.xmlsoap.org/soap/envelope/" xmlns:np2="http://services.www.up.com/xmf/2.0" name="serviceName" expression="//np:Envelope/np:Header/np2:request-header/np2:service-name" scope="default" type="STRING"/>
<property xmlns:ns="http://org.apache.synapse/xsd" xmlns:fn="http://www.w3.org/2005/xpath-functions" name="localEntryName" expression="fn:replace($ctx:serviceName,'/','-')" scope="default" type="STRING"/>
<property xmlns:ns="http://org.apache.synapse/xsd" name="contractEnforcedVal" expression="get-property(get-property('localEntryName'))" scope="default" type="STRING"/>
<filter xmlns:ns="http://org.apache.synapse/xsd" xpath="fn:contains(get-property('contractEnforcedVal'),$trp:XMFRequestor)">
<then>
<filter xpath="fn:contains(get-property('contractEnforcedVal'),'isSecured=true')">
<then>
<class name="com.uprr.app.poc.esb.mediator.RequestHandler">
<property name="secValServiceURL" value="http://localhost:9080/SecurityService/secure-util"/>
</class>
<filter xpath="fn:contains(get-property('isAuthorized'),'true')">
<then>
<send>
<endpoint key-expression="get-property('serviceName')"/>
</send>
</then>
<else>
<drop/>
</else>
</filter>
</then>
<else>
<send>
<endpoint key-expression="get-property('serviceName')"/>
</send>
</else>
</filter>
</then>
<else>
<drop/>
</else>
</filter>
Please check the maven-car-plugin's version in the CAPP's pom file. It should be 2.0.8 as shown below
<groupId>org.wso2.maven</groupId>
<artifactId>maven-car-plugin</artifactId>
<version>2.0.8</version>
Also make sure the ESB project's pom file contains the version 2.0.8 as the sequence plugin version
<groupId>org.wso2.maven</groupId>
<artifactId>wso2-esb-sequence-plugin</artifactId>
<version>2.0.8</version>
I want the where, user clicks on the # and the IVR control goes back to main menu.
But when user clicks on # it say fatal error occurred.
I am newbie in IVR Domain please help me out.
<?xml version='1.0' encoding='iso-8859-1' ?>
<vxml application='http://intx.dev.spokn.com/airtelintx/global.vxml' version='2.0'>
<log expr='[vxml_root_page] This log is after property element' />
<property name='termchar' value=' '></property>
<property name='inputmodes' value='dtmf'></property>
<log expr='[vxml_root_page] This log is after property element' />
<form id='main_menu'>
<var expr='0' name='errorcount' />
<var expr='3' name='maxerrors' />
<field name='ivr_input'>
<grammar mode='dtmf' root='main_choices' type='application/srgs+xml' version='1.0' xml:lang='en-US' xmlns='http://www.w3.org/2001/06/grammar'>
<rule id='main_choices'>
<one-of>
<item>
1
</item>
<item>
2
</item>
<item>
3
</item>
<item>
#
</item>
</one-of>
</rule>
</grammar>
<prompt>
Choose which country you would like to go.
For USA, press 1.
For UK, press 2.
For Canada, press 3.
Press # to return to the main menu.
</prompt>
<nomatch>
<if cond='errorcount == maxerrors'>
<goto next='#exit' />
<else />
<assign expr='errorcount + 1' name='errorcount' />
Oops that was an invalid input
<reprompt />
</if>
</nomatch>
<noinput>
<if cond='errorcount == maxerrors'>
<goto next='#exit' />
<else />
<assign expr='errorcount + 1' name='errorcount' />
No input detected. Please try again.
<reprompt />
</if>
</noinput>
<filled>
<if cond='ivr_input == 1'>
<log expr="'[vxml_reply] ivr_input choice 1, record'" />
<log expr="'[vxml_reply] ivr_input choice 1, record'" />
<log expr="'[vxml_reply] The calling Number callerid'">
<value expr='callerid'></value>
</log>
<submit expr="application.apphost + application.appuri + '/ivr/confirm_country.vxml'" namelist='ivr_input callerid' />
</if>
<if cond='ivr_input == 2'>
<log expr="'[vxml_reply] ivr_input choice 2, record'" />
<log expr="'[vxml_reply] ivr_input choice 2, record'" />
<log expr="'[vxml_reply] The calling Number callerid'">
<value expr='callerid'></value>
</log>
<submit expr="application.apphost + application.appuri + '/ivr/confirm_country.vxml'" namelist='ivr_input callerid' />
</if>
<if cond='ivr_input == 3'>
<log expr="'[vxml_reply] ivr_input choice 3, record'" />
<log expr="'[vxml_reply] ivr_input choice 3, record'" />
<log expr="'[vxml_reply] The calling Number callerid'">
<value expr='callerid'></value>
</log>
<submit expr="application.apphost + application.appuri + '/ivr/confirm_country.vxml'" namelist='ivr_input callerid' />
</if>
<if cond='ivr_input == #'>
<log expr="'[vxml_reply] ivr_input choice #, record'" />
<log expr="'[vxml_reply] ivr_input choice #, record'" />
<log expr="'[vxml_reply] The calling Number callerid'">
<value expr='callerid'></value>
</log>
<submit expr="application.apphost + application.appuri + '/ivr/main_menu.vxml'" namelist='ivr_input callerid' />
</if>
</filled>
</field>
</form>
<error>
<log>
APP ERROR!!!
<value expr='_event' />
</log>
A fatal error occurred. Please contact a customer service representative.
<disconnect />
</error>
<catch event=''>
<log>
UNHANDLED EVENT!!!
<value expr='_event' />
</log>
Sorry, there was a problem processing your request. Please try again later.
<disconnect />
</catch>
</vxml>
I guess this should do the work i.e. assigning termchar value " ", the user can enter # as input.
<property name='termchar' value=' '></property>
I get flowing Error :=
swi:SBjsi|501|SBjsi:ECMAScript engine exception|errmsg=SyntaxError: illegal character|line=1|linetxt=ivr_input == #|tokentxt=#\n
On most platforms the "#" key is a termination character. This can be changed by setting the property "termchar" in you application. If you want to see if the user pressed a "termchar" you can use the shadow variable "termchar" to see what they pressed. For more details on this property and shadow variable you can reference the VoiceXML Specification.
The if condition inside tag should be
<if cond='ivr_input == '#''>
And it works fine. yeah!!!
As we see the Tiles docs said
https://tiles.apache.org/framework/tutorial/advanced/wildcard.html
We can define a wildcard to accept arbitrary name. But if the name includes "/", for example "c4/login". Tiles will throw an exception
org.apache.tiles.definition.NoSuchDefinitionException: c4/login
at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:625)
at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:321)
My definition is below:
<definition name="*" template="/WEB-INF/tiles/basicLayout.jsp">
<put-attribute name="header" value="/WEB-INF/tiles/header.jsp" />
<put-attribute name="content" value="/WEB-INF/pages/{1}.jsp" />
<put-attribute name="footer" value="/WEB-INF/tiles/footer.jsp" />
</definition>
If I change definition to the example below, a name with slash inside is accepted.
<definition name="c4/login" template="/WEB-INF/tiles/basicLayout.jsp">
<put-attribute name="header" value="/WEB-INF/tiles/header.jsp" />
<put-attribute name="content" value="/WEB-INF/pages/c4/login.jsp" />
<put-attribute name="footer" value="/WEB-INF/tiles/footer.jsp" />
</definition>
Please advise. Thanks a lot.
I think I found a more general workaround: use ** as the wildcard:
<definition name="**" template="/WEB-INF/tiles/basicLayout.jsp">
<put-attribute name="header" value="/WEB-INF/tiles/header.jsp" />
<put-attribute name="content" value="/WEB-INF/pages/{1}.jsp" />
<put-attribute name="footer" value="/WEB-INF/tiles/footer.jsp" />
</definition>
I got a workaround solution, use the revised definition below
<definition name="*/*" template="/WEB-INF/tiles/basicLayout.jsp">
<put-attribute name="header" value="/WEB-INF/tiles/header.jsp" />
<put-attribute name="content" value="/WEB-INF/pages/{1}/{2}.jsp" />
<put-attribute name="footer" value="/WEB-INF/tiles/footer.jsp" />
</definition>
Hope this is useful for you.