How to expand non-entity reference in xml file with Ant - java

I have an XML file with the following content:
<root-tag>
<entry name="name1" value="/usr/bin" />
<entry name="full_path" value="${name2}" />
<entry name="name2" value="${name1}/dpkg" />
</root-tag>
I want to read this file in Ant and put the attribute value of value in the <entry> node whose name value is "full_path" into a property with Ant.
I can easily do this, e.g. using <xmltask> with its <copy> element:
<copy path="root-tag/entry[#name='full_path']/#value" property="outputProperty" />
However, what I get is ${name2}, which is meaningless to me. I need ${name2} to be resolved into the ${name1}/dpkg and then the ${name1} part is resolved into /usr/bin, as a result, /usr/bin/dpkg.
And I must look for "full_path" because the other two names can't be predicted.
Since this is not entity reference, <xmltask> can't automatically expand it.
How should I achieve my goal in Ant build file?

You can use anttask propertycopy for the same.
Refer link - http://ant-contrib.sourceforge.net/tasks/tasks/propertycopy.html

Related

Aspect name in Alfresco showing up as undefined in 'Manage Aspect'

I was working with Alfresco-entreprise 4.1.1.3 and i moved to alfresco-community 5.0.2.
In this migration i copied all the config files of my custom aspects to the same locations as it was in
Alfresco-entreprise 4.1.1.3
I have set them to visible in share UI and I can see them in the share UI.
The problem is that when I right click on a site or folder and choose 'Manage Aspect', i see that the aspect name is listed as
undefined (gifapidocument:MyAspect)
I am not sure why it is showing up as undefined. When I click on manage rules -> add aspect , I see that the name is showing up correctly.
When i try to add a document to Alfresco from my application it works but the document is added without any properties and empty Aspects.
the paths of my configs are :
share-config-custom.xml : ./tomcat/shared/classes/alfresco/web-extension
In <alfresco-config><config><aspects><visible>, i added :
<aspect name="gifapidocument:*MyAspect*" />
In <alfresco-config><config><forms><form>, i added :
<field-visibility>
<show id="gifapidocument:typeDocumentXXXX" />
</field-visibility>
<field-visibility>
<show id="gifapidocument:idXXXXXXXX" />
</field-visibility>
another path of my configs :
myAppDocument-model.xml : ./tomcat/shared/classes/alfresco/extension/myApp/model
In <model><aspects>, i added :
<aspect name="gifapidocument:*MyAspect*">
<properties>
<property name="gifapidocument:typeDocumentXXXX">
<type>d:text</type>
<mandatory>false</mandatory>
</property>
<property name="gifapidocument:idXXXXXXXX">
<type>d:text</type>
<mandatory>false</mandatory>
</property>
</properties>
</aspect>
and finaly :
myApp.properties : ./tomcat/shared/classes/alfresco/extension/myApp/messages
i added :
aspect.gifapidocument_*myAspect*=GIF-API-MYAPP-*myAspect*
u can check yours aspects with:
yourhost/api/-default-/public/alfresco/versions/1/nodes/{{uiid}
it is shown in this properties"aspectNames": []
in my case when i click to manage aspect i cant see any thing in share but the aspect is added correctly.
Could the asterisks be in the name of aspect?

Izpack toggel Checkbox on Install Location

I have a checkbox for Windows Service installation in a UserInput Panel and i would want to make this dependent with the installation path.
If the installation path is local drive, then the "install windows service" checkbox should appear.
But if the installation path is a Network Shared location or a mounted Drive , the checkbox shouldnt appear.
For this i tried using Dynamic variable along with a Condition
Here is the snippet from install.xml
<conditions>
<condition type="variable" id="install.path.condition">
<name>$INSTALL_PATH</name>
<value>//</value>
</condition>
</conditions>
<dynamicvariables>
<variable name="windowsservice" value="false" condition="install.path.condition" />
<variable name="windowsservice" value="true" condition="!install.path.condition" />
</dynamicvariables>
The target field in install_userinputspec.xml
<field align="left" type="check" variable="windowsservice" conditionid="install.path.condition" revalidate="true">
<os family="windows"/>
<spec txt="Install as Windows Service" id="windowsServiceCheckbox" true="on" false="off"
set="false" />
</field>
I tried my luck getting this work, but it wont. Please help
Change $INSTALL_PATH to INSTALL_PATH
<name>INSTALL_PATH</name>
If you're not sure about the exact value that will be entered for the INSTALL_PATH then instead of using a condition of type="variable" use type="contains"with a nested <variable> tag, such as:
<condition type="contains" id="...">
<variable>INSTALL_PATH</variable>
<value>a substring to match in the value of INSTALL_PATH</string>
</condition>
IzPack doc contains cond.
Use revalidate="yes" as an attribute of the <spec> tag and not the <field> tag itself.
First, try to make your <condition> work. Once you've tested that, the check field can be linked to the condition directly for enabling/disabling and as such, you do not need to use <dynamicvariables> in this case, unless you need it for something other than checkbox-enable-disable-based-by-INSTALL_PATH.

Include tag in jaxb

I have an xml file of following structure:
<root>
<paramsToInclude>
<params id="id1">
<param11>val1</param11>
<param12>val2</param12>
<param13>val3</param13>
<param14>val4</param14>
</params>
<params id="id3">
<param31>val1</param31>
<param32>val2</param32>
</params>
</paramsToInclude>
<process>
<subprocess1>
<include params="id1"/>
<query>
SELECT *
FROM
table;
</query>
</subprocess2>
<subprocess1>
<rule>rule1</rule>
<rule>rule2</rule>
</subprocess2>
<subprocess3>
<processParam>val1</processParam>
<include params="id2"/>
<include params="id3"/>
</subprocess3>
</process>
I'm using jaxb to parse this xml into the java classes. Is there a way to substitute includes in the process by it's values from the begin of file? I mean, I wan't file to be parsed as if it look's like
<root>
<paramsToInclude>
<params id="id1">
<param11>val1</param11>
<param12>val2</param12>
<param13>val3</param13>
<param14>val4</param14>
</params>
<params id="id3">
<param31>val1</param31>
<param32>val2</param32>
</params>
</paramsToInclude>
<process>
<subprocess1>
<param11>val1</param11>
<param12>val2</param12>
<param13>val3</param13>
<param14>val4</param14>
<query>
SELECT *
FROM
table;
</query>
</subprocess2>
<subprocess1>
<rule>rule1</rule>
<rule>rule2</rule>
</subprocess2>
<subprocess3>
<processParam>val1</processParam>
<param11>val1</param11>
<param12>val2</param12>
<param13>val3</param13>
<param14>val4</param14>
<param31>val1</param31>
<param32>val2</param32>
</subprocess3>
</process>
is it possible t do this? I've found link http://thetechietutorials.blogspot.com/2011/08/jaxb-tutorial-part-2-jaxb-with-xinclude.html how to this include from another file, but comment says that it's impossible to do this for the same file (I understand that I can put this includes in another xml, but I don't think it's a best way). Also I don't want to use hashMap because in this way included params will be stored in hashMap and processParam (from subprocess3) will be class variable.
Is there a way to do this somehow?

Using CSVParser to parse a tab-delimited file

I need to parse a file which is tab delimited. I'm attempting to use CSVBeans version 0.7 to do this. In an XML configuration file, I have to pass a separator value to indicate how fields are delimited, as follows:
parser className="org.csvbeans.parsers.CSVParser"/>
</strategy>
<property name="separator" value="\t" />
<property name="noStartTag" value="true" />
<converters>
As shown above, I have tried value="\t" />, but it's not working. I have also tried '\\t' and '\t' but to no avail. What value should I use for a tab character?
folks it would be highly appreciated if you guys please let me know the solution specific to csv beans 0.7.1 jar .
In XML a tab character is represented as . So, your file should be like:
<parser className="org.csvbeans.parsers.CSVParser"/>
</strategy>
<property name="separator" value=" " />
<property name="noStartTag" value="true" />
<converters>

Why would Spring be trying to use the properties variable reference string instead of the value?

Here's the problem in a nutshell:
<bean id="handlerFactory" class="com.westfieldgrp.audit.jdklogging.cpm.CPMHandlerFactory">
<property name="schemaName" value="${env.audit.databaseSchema}" />
<property name="bufferSize" value="${env.audit.bufferSize}" />
<property name="threaded" value="${env.audit.threadedAuditHandler}" />
<property name="dataSourceSelector" ref="dataSourceSelector" />
</bean>
bufferSize on the CPMHandlerFactory is an int. Spring is failing because it is trying to set the value to '${env.audit.bufferSize}' instead of the actual value from the properties file.
Now, when I change the name of the properties file or env.audit.bufferSize in the file, Spring complains that it can't find the property 'env.audit.bufferSize'. This says to me that it CAN find the property, but instead of setting the value to '20', it's trying to set it to '${env.audit.bufferSize}'. Can anyone explain why Spring might be doing this and what I can do about it?
Contents of the properties file below:
env.audit.databaseSchema=TDB2DATA
env.audit.dataSourceName=java:comp/env/AuditDataSourceAlias
env.audit.bufferSize=20
env.audit.threadedAuditHandler=true
Thanks,
Peter
EDIT:
Found the problem thanks to Jamestastic below. Here's what it was:
We have a "master" context file that looks like so:
<import resource="environmentBeans.xml" />
<import resource="serviceBeans.xml" />
<import resource="auditBeans.xml" />
The 'environmentBeans.xml' has the PropertyPlaceholderConfigurer in it. The problem was, I added some code that referenced the 'auditBeans.xml' context, which of course doesn't have the configurer. I switched it to reference the 'master' context and it works great.
The key was understanding why the values wouldn't get substituted out: because there was no property configurer.
So, Thanks!
Did you remember to add <context:property-placeholder /> or a PropertyPlaceholderConfigurer bean definition to your Spring context?

Categories

Resources