I want to read a file which is in datapower through api gateway v10 - api-gateway

I'm using url-open() function but I'm getting an empty response.

Something like this should work. You don't need to do urlopen if you are running the code from the same appliance.
<!-- Load config file -->
<xsl:variable name="configFile" select="document('local:///myfolder/servers.xml')" />
<!-- Look in the XML file to find your server -->
<xsl:variable name="myURL">
<xsl:copy-of select="$configFile/config/Servers/Server[#name='prod']/url" />
</xsl:variable>
<?xml version="1.0" encoding="utf-8"?>
<config>
<Servers>
<Server name="prod">
<url>www.google.com</url>
</Server>
<Server name="dev">
<url>www.yahoo.com</url>
</Server>
</Servers>
</config>

Related

Why is my Magento2 di.xml not having any effect?

I've overridden \Magento\Checkout\Block\Cart\Item\Renderer and when I add this to the end of config in /app/etc/di.xml the override works.
<preference for="Magento\Checkout\Block\Cart\Item\Renderer" type="Tls\Module\Block\Cart\Item\Renderer" />
However, when I try to use /app/code/Tls/Module/etc/di.xml there is no effect. This is the contents of my di.xml (though I've tried many things)
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">
<preference for="Magento\Checkout\Block\Cart\Item\Renderer" type="Tls\Module\Block\Cart\Item\Renderer" />
</config>
Magento 2.2.4

How to make clickhouse take new users.xml file?

Do I have to restart clickhouse to make it read any update to users.xml?
Is there a way to juse "reload" clickhouse?
These files are reloaded in runtime, no need to restart the server.
As you can notice config folder has several files, like
config-preprocessed.xml
config.xml
users-preprocessed.xml
users.xml
.*-preprocessed.xml are for parsed config so you will see when it is loaded and parsed.
I wouldn't recommend to modify files '/etc/clickhouse-server/config.xml' or 'etc/clickhouse-server/user.xml' because it will be rewritten after upgrading ClickHouse and you will lose custom settings.
The subfolder '/etc/clickhouse-server/config.d/' and '/etc/clickhouse-server/users.d/' serve to store overrides for 'config.xml' and 'user.xml' relatively.
Example overrides for 'config.xml':
config.d/config.xml
<?xml version="1.0"?>
<yandex>
<listen_host replace="replace">::</listen_host>
<dictionaries_config replace="replace">dictionaries/*.xml</dictionaries_config>
<openSSL>
<client>
<verificationMode replace="replace">none</verificationMode>
</client>
</openSSL>
</yandex>
config.d/cluster.xml
<?xml version="1.0"?>
<yandex>
<remote_servers>
<your_cluster>
<!-- topology definition -->
</your_cluster>
</remote_servers>
<zookeeper>
<!-- .. -->
</zookeeper>
</yandex>
config.d/kafka.xml
<?xml version="1.0"?>
<yandex>
<!-- The default configuration for Kafka Engine Table (https://clickhouse.yandex/docs/en/operations/table_engines/kafka/#configuration). -->
<kafka>
<bootstrap_servers>11.22.33.44:6667,11.22.33.55:6667,11.22.33.66:6667</bootstrap_servers>
<auto_offset_reset>latest</auto_offset_reset>
</kafka>
<!-- The Topics configurations. -->
<kafka_topic_name>
<group_id>clickhouse-group_id</group_id>
</kafka_topic_name>
</yandex>
Example overrides for 'users.xml':
users.d/user.xml
<?xml version="1.0"?>
<yandex>
<users>
<default>
<password replace="replace">hello_clickhouse</password>
</default>
<readonly>
<password replace="replace">hello</password>
</readonly>
</users>
</yandex>
Another example of config overrides.
See for details ClickHouse Configuration files.

How to read a parameter passed by maven on my stylesheet XSL?

I'm running this command:
mvn org.codehaus.mojo:xml-maven-plugin:transform "-DAPP=testingapp"
And inside my XSL I'm transforming a graphml to a HTML and I want to display this app name on the top of my HTML.
How do I read this attribute that I'm passing on the command line on my xsl?
Thank you!
Yes. It is possible.
In your pom.xml
<configuration>
<transformationSets>
<transformationSet>
<parameters>
<parameter>
<name>APP</name>
<value>${APP}</value>
</parameter>
</parameters>
</transformationSet>
</transformationSets>
</configuration>
In your xsl file
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes" />
<xsl:param name="APP" />
<xsl:value-of select="$APP"/>
</xsl:stylesheet>
You will need to declare in pom.xml and repeat in your xsl file. This is the trick.
Note: This also work for xslt-2.0

Access specific appsettings key in Url Rewrite rules

I am trying to access AppSettings Key in the Url Rewrite rules and I am not sure how to access them. Can anyone help me out?
<appSettings>
<add key="APIUrl" value="https://www.x.com/api/{R:1}" />
</appSettings>
<system.webServer>
<rewrite>
<rules>
<rule name="ProxyApi" stopProcessing="true">
<match url="^api/?(.*)" />
<serverVariables>
<set name="HTTP_X_ORIGINAL_ACCEPT_ENCODING" value="{HTTP_ACCEPT_ENCODING}" />
<set name="HTTP_X_ORIGINAL_HOST" value="{HTTP_HOST}" />
</serverVariables>
<action type="Rewrite" url="{APIUrl}" />
</rule>
</rules>
</rewrite>
</system.webServer>
Trying to access the APIUrl key in the UrlRewrite Rule
I think that appsettings are unavailable elsewhere in your config files.
I've found two ways to address this issue using msbuild:
Use xmlupdate task from MSBuild Community Tasks Project to update config files. My work was using this already so it was the path that I took. Would look Like:
<XmlUpdate
XPath="//rule[#name='ProxyApi']/action/#url"
XmlFileName="{Your Config File Location}"
Value="https://www.x.com/api/{R:1}" />
Use XslTransformation Task to update your config files. This solution is built in but requires more knowledge of XSL. The Xsl would looke something like:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes"/>
<!-- identity transform -->
<xsl:template match="#*|node()">
<xsl:copy>
<xsl:apply-templates select="#*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="//rule[#name='ProxyApi']/action/#url">
<xsl:attribute name="url">
<xsl:value-of select="'https://www.x.com/api/{R:1}'"/>
</xsl:attribute>
</xsl:template>
</xsl:stylesheet>

WebSphere Liberty Profile: Context Root Not Found

I can't seem to get this working locally, even though the same WAR works on a remote server. When I go to visit my application locally, I get the "Context Root Not Found" error. The Liberty profile version is 8.5.5.5.
Here are the relevant files:
server.xml
<?xml version="1.0" encoding="UTF-8"?>
<server description="tlc server">
<!-- Enable features -->
<featureManager>
<feature>jsp-2.2</feature>
<feature>ssl-1.0</feature>
<feature>localConnector-1.0</feature>
<feature>restConnector-1.0</feature>
<feature>json-1.0</feature>
<feature>jaxrs-1.1</feature>
<feature>servlet-3.0</feature>
<feature>jpa-2.0</feature>
<feature>beanValidation-1.0</feature>
<feature>jndi-1.0</feature>
<feature>jdbc-4.0</feature>
<feature>monitor-1.0</feature>
</featureManager>
<httpEndpoint id="defaultHttpEndpoint" host="*" httpPort="9080" httpsPort="9443" virtualHost="default_host" />
<jdbcDriver id="DerbyJDBCDriver">
<library name="DerbyLib">
<fileset dir="C:\tools\servers\wlp\lib" includes="derbyclient-10.6.1.0.jar" />
</library>
</jdbcDriver>
<dataSource jndiName="jdbc/TLCDataSource" id="derbyDataSource" jdbcDriverRef="DerbyJDBCDriver">
<properties.derby.client databaseName="TLC" password="APP" user="APP" />
</dataSource>
<applicationMonitor updateTrigger="mbean" />
<application id="TLC_war" context-root="/TLC" location="C:\Users\nd26434\gitrepos\tlc\target\TLC-1.0.0-SNAPSHOT.war" name="TLC_war" type="war">
<classloader delegation="parentLast">
<privateLibrary>
<fileset dir="C:\tools\servers\wlp\lib" includes="aspectjweaver-1.8.0.jar" />
</privateLibrary>
</classloader>
</application>
</server>
message.log
[3/18/15 20:19:54:789 EDT] 0000001b com.ibm.ws.app.manager.AppMessageHelper A CWWKZ0022W: Application TLC_war has not started in 30.018 seconds.
[3/18/15 20:20:03:174 EDT] 0000001f com.ibm.ws.webcontainer.osgi.webapp.WebGroup I SRVE0169I: Loading Web Module: TLC-1.0.0-SNAPSHOT.
[3/18/15 20:20:03:175 EDT] 0000001f com.ibm.ws.webcontainer I SRVE0250I: Web Module TLC-1.0.0-SNAPSHOT has been bound to tlc_host.
ibm-web-bnd.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-bnd xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://websphere.ibm.com/xml/ns/javaee"
xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-web-bnd_1_0.xsd"
version="1.0">
<virtual-host name="tlc_host"/>
<resource-ref name="jdbc/TLCDataSource"
binding-name="jdbc/TLCDataSource" />
</web-bnd>
ibm-web-ext.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-ext
xmlns="http://websphere.ibm.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-web-ext_1_0.xsd"
version="1.0">
<reload-interval value="3"/>
<context-root uri="TLC" />
<enable-directory-browsing value="false"/>
<enable-file-serving value="true"/>
<enable-reloading value="true"/>
<enable-serving-servlets-by-class-name value="false" />
</web-ext>
Remove <virtual-host name="tlc_host"/> from your ibm-web-ext.xml file. As you dont have tlc_host, but default_host.
Context Root Not found is caused due to issue in one of the config files.
In my case, web.xml had an unclosed comment due to which the war was not built correctly.
This resulted in EAR file not updating.
Solution:
Compare you web.xml with previous versions to see what changed.
Add war to the server instead of the ear file to see the error. (If Running on Liberty Server)

Resources