Checking if the properties file exists - apache

I need to check if the properties file exists. If it not exists build.xml must use itself property.
<property file="AntHW.properties"/>
<property name="src" location="src"/>
<property name="build" location="build"/>
<property name="dist" location="dist"/>
<property name="docdir" location="javadoc"/>

You don't need to check if it exists. Properties in ant are immutable, once set the values cannot be changed. So you want to import the properties file above your snippet, if the properties exist in that properties file the values are set and will not be overwritten by the snippet.

Maybe you can try
<available property="properties.available" file="path/to/properties/file" />
Now properties.available will tell you whether or on the properties file exists.

Related

WSO2 esb access node from xml in property

i stored an XML document in a property:
<property expression="$body//*" name="InDoc"
scope="default" type="OM"/>
in a later step of the proxy a want to access the XML doucment.
This
<log level="custom">
<property name="InDoc" expression="get-property('InDoc')"/>
</log>
gives the whole XML document. But I would like to access only some parts of the XML e.g. only one value in a later step of the proxy. I already tried
<log level="custom">
<property name="InDoc" expression="get-property('InDoc')//AAA"/>
</log>
or this
<log level="custom">
<property name="InDoc" expression="$ctx:InDoc//AAA"/>
</log>
But both do not work. Is there another way?
Thanks in advance.
Roland
I think both way should work fine. The expression support XPath 1.0. You can run any XPath after the "get-property" in expression.
But you need check,
make sure you use the right XPath.
So you can log/copy the get-property('InDoc'), and then you can use any XPath tool to validate your XPath.
Namespace of the XPath in expression,
if your xml payload have namespace, make sure your XPath namespace is right, and declare right NS in property.
Through property mediator, you are not going to store XML file, you just retrieving content from it. As you have to retrieve part of it, you can give it through property mediator.
<property expression="$body//*" name="InDoc" scope="default" type="OM"/>
Through expression you should define it.
expression="$body//*"
You can change this and get required parts of xml. If you need few parts, you can add several properties for each and retrieve value from it.

Jackrabbit index boost configuration

I'm trying to understand the use of 'boosting' properties in the indexing configuration for CQ5. I thought I understood from http://wiki.apache.org/jackrabbit/IndexingConfiguration that setting a boost determined how far up the list an item would be returned as a search result. So I tried adding the following boost lines to my default CQ5 indexing configuration:
<index-rule nodeType="nt:base">
<property boost="5.0">jcr:title</property>
<property boost="5.0">history:title</property>
<property boost="3.0">history:description</property>
<property boost="3.0">history:caption</property>
<property boost="2.0">text</property>
<property nodeScopeIndex="false">analyticsProvider</property>
<property nodeScopeIndex="false">analyticsSnippet</property>
<property nodeScopeIndex="false">hideInNav</property>
<property nodeScopeIndex="false">offTime</property>
<property nodeScopeIndex="false">onTime</property>
:
:
<property isRegexp="true">.*:.*</property>
</index-rule>
The intent was that, in a full text search, text found in jcr:title or history:title properties would be the most relevant followed by history:description, history:caption and, finally, text.
I deleted the index information from the repository and from the workspace, then restarted CQ and let it rebuild all of the indexes.
Now when I do a full text search, I'm only getting results if the search text is in the nodename itself - nothing from description, caption, etc.
Obviously I've done something wrong but I'm not sure what. Any help would be greatly appreciated.

wix - fill edit-control with value from registry

Installer is writting SQL Server's name to registry during installing my service.
And I created a dialog window with edit control where user will type the servername . Now I want to fill this control with value from registry in ChangeMode. And if this registry key is empty to fill with some default name.
How is possible to resolve it?
I tried to put RegistrySearch node into Control node. But it seems to me it's not working..
Any help is appreciated
P.S. Looked some information here: link1. And tried code like:
<Property Id="SERVCONNSTR" Value=".\SQLEXPRESS">
</Property>
<Property Id="CONNSEARCH">
<RegistrySearch Id="servconstr" Root="HKLM"
Key="Software\$(var.Manufacturer)\SERVICE" Name="SQL Server" Type="raw"></RegistrySearch>
</Property>
<SetProperty Id="SERVCONNSTR" Value="CONNSEARCH"
After="AppSearch"><![CDATA[CONNSEARCH AND (!FEATURE1=3 OR !FEATURE2=3 OR !FEATURE3=3)]]></SetProperty>
But I'm still getting .\SQLEXPRESS in edit-control during modifying.
What i'm doing wrong?
Put RegistrySearch into a Property, and tie that property to the Control.
<Property Id="SERVCONNSTR" Value=".\SQLEXPRESS">
</Property>
<Property Id="CONNSEARCH">
<RegistrySearch Id="servconstr" Root="HKLM"
Key="Software\$(var.Manufacturer)\SERVICE" Name="SQL Server" Type="raw"></RegistrySearch>
</Property>
<SetProperty Id="SERVCONNSTR" Value="[CONNSEARCH]"
After="AppSearch">CONNSEARCH</SetProperty>
I don't know why you are using two properties, If you set your property CONNSEARCH with the registrySearch, it'll check the registry and assign it the value found there, if one is present. This happens in the AppSearch phase well before most UI's take place, where your edit box would be. So you shouldn't need to use SetProperty either.
Did you want to fill the registry key with a default value, or your property with a default value?
For the property just fill the Value attribute of the property element that is using a registry search. It'll default to that if nothing is found in registry, as I said above.
It would look like this;
<
<Property Id="CONNSEARCH" Value="DefaultValue">
<RegistrySearch Id="servconstr" Root="HKLM"
Key="Software\$(var.Manufacturer)\SERVICE" Name="SQL Server" Type="raw"></RegistrySearch>
</Property>
After Appsearch your property would be set, and if your control is tied to that property it'll be filled with that value. This will also set your default property value to "DefaultValue" If nothing is in the registry.
To create a default value for the key in the registry, I guess just put a registryKey/RegistryValue element in a component that will always be installed in this scenario, and set that key to your default value if you don't set it anywhere else.
Best

Change nhibernate config with nant xmlpoke

How can I change the connection string from nhibernate.config file using nant
the problem is that all examples are about changing attribute value, but nhibernate has inner text
eq:
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="connection.connection_string">Data Source.\server;Database=UnitTestDb;UID=user;pwd=pass;</property>
<property name="dialect">NHibernate.Dialect.MsSql2008Dialect</property>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
<property name="show_sql">true</property>
<property name="connection.release_mode">auto</property>
<property name="adonet.batch_size">500</property>
....
I need to change property connection.connection_string
<xmlpoke file="${nhibernate.file}"
xpath="/hibernate-configuration/session-factory/add[#key='connection.connection_string']/#value"
value="${connection.string}">
</xmlpoke>
this does not work in this case.
Thanks
The sample xpath you're using refers to elements named add with attributes called key. In your case you are looking for property elements with attributes called name.
Next, since you want to change the inner text and not the #value attribute on the property element you should remove the trailing attribute reference.
And finally, since the NHibernate xml has a specific namespace you will have to inform xmlpoke to use the correct namespace.
So the task should look like this:
<xmlpoke file="${nhibernate.file}"
xpath="/nhc:hibernate-configuration/nhc:session-factory/nhc:property[#name='connection.connection_string']"
value="${connection.string}">
<namespaces>
<namespace prefix="nhc" uri="urn:nhibernate-configuration-2.2" />
</namespaces>
</xmlpoke>
Note: I've not tested this out, but general xml/xpath rules are in work here so I hope it works. Also, it could be that there is a way to indicate to xmlpoke that the specified namespace should be the default and thus eliminate the need to namespace prefix all the various parts in the xpath.
Good luck!

nhibernate datasource sqlite relative filepath

I have the following nhibernate cfg file:
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="connection.driver_class">NHibernate.Driver.SQLite20Driver</property>
<property name="connection.connection_string">Data Source=dbFile.db;Version=3</property>
<property name="dialect">NHibernate.Dialect.SQLiteDialect</property>
However this creates and references dbFile.db in the bin/Debug folder. I was wondering if there is any way to refernce another folder i.e. something like .../app/database/dbFile.db?
Thanks in advance
You can set the connection string property from c# code. You have to do this before you call the Configure() method.
var configuration = new Configuration();
config.SetProperty(NHibernate.Cfg.Environment.ConnectionString, myCustomDbPath);
configuration.Configure();
Hope that helps.
Maybe you can use DataDirectory-Property to start from the Exe-Path:
Data Source=|DataDirectory|../app/database/dbFile.db;Version=3
or
Data Source=jdbc:sqlite:../app/database/path.db;Version=3
Edit: After some googling i found out that this probably won't work. if not i would go with striders solution setting the property at runtime.