Mandalika's scratchpad [ Work blog @Oracle | Stock Market Notes | My Music Compositions ]

Old Posts: 09.04  10.04  11.04  12.04  01.05  02.05  03.05  04.05  05.05  06.05  07.05  08.05  09.05  10.05  11.05  12.05  01.06  02.06  03.06  04.06  05.06  06.06  07.06  08.06  09.06  10.06  11.06  12.06  01.07  02.07  03.07  04.07  05.07  06.07  08.07  09.07  10.07  11.07  12.07  01.08  02.08  03.08  04.08  05.08  06.08  07.08  08.08  09.08  10.08  11.08  12.08  01.09  02.09  03.09  04.09  05.09  06.09  07.09  08.09  09.09  10.09  11.09  12.09  01.10  02.10  03.10  04.10  05.10  06.10  07.10  08.10  09.10  10.10  11.10  12.10  01.11  02.11  03.11  04.11  05.11  07.11  08.11  09.11  10.11  11.11  12.11  01.12  02.12  03.12  04.12  05.12  06.12  07.12  08.12  09.12  10.12  11.12  12.12  01.13  02.13  03.13  04.13  05.13  06.13  07.13  08.13  09.13  10.13  11.13  12.13  01.14  02.14  03.14  04.14  05.14  06.14  07.14  09.14  10.14  11.14  12.14  01.15  02.15  03.15  04.15  06.15  09.15  12.15  01.16  03.16  04.16  05.16  06.16  07.16  08.16  09.16  12.16  01.17  02.17  03.17  04.17 

Monday, November 09, 2009
Java Code to Convert TWiki URLs to HTML Links

Few days ago I was looking for some code or tool with the ability to convert TWiki URLs to equivalent HTML URLs. (For the uninitiated, TWiki supports wide variety of URL formats in addition to the standard HTML format.). I spent almost 3 hours searching the web and trying out different code, Java classes etc., But at the end, none of the things that I found elsewhere seems to have the ability to convert almost all the TWiki URL formats that I'm trying to convert [to HTML]. So, I gave up looking for some readymade code and quickly wrote some Java code to resolve the issue that I'm trying to solve.

Now that I have the code, thought publishing it in my blog would help other people who are looking for something similar to this. So here it is. Download the source code from the following location.

The code assumes that the TWiki system is deployed on (a fake web site), and is capable of handling the following TWiki URL formats:

<a href="">twiki</a>

Sample inputs and outputs:

% java TwikiToHTML

TWiki URL: NotSoPl@inY0uKnow
HTTP equivalent:

TWiki URL: ItIsJustplain
HTTP equivalent: <a href="" target="_new">ItIsJustplain</a>

TWiki URL: GiriK@lyanaChakravarth!
HTTP equivalent:

TWiki URL: &ersand
HTTP equivalent:

TWiki URL: Harisha
HTTP equivalent:

TWiki URL: Janaki Lakshmi
HTTP equivalent:

TWiki URL: JanakiLakshmi
HTTP equivalent:

TWiki URL: [[OmalleyDataProject]]
HTTP equivalent: <a href="" target="_new">OmalleyDataProject</a>

TWiki URL: [[Giri][Mandalika]]
HTTP equivalent: <a href="" target="_new">Mandalika</a>

TWiki URL: [[Giri][Mandalika]], [[Kalyana][Chakravarthy]]
HTTP equivalent: <a href="" target="_new">Mandalika</a><BR><a href="" target="_new">Chakravarthy</a>

TWiki URL: [[Giri][Mandalika]], [[Kalyana][Chakravarthy]], [[IsveSeeameOrgadKimchiIGTvLabProcedures][docs]]
HTTP equivalent: <a href="" target="_new">Mandalika</a><BR><a href="" target="_new">Chakravarthy</a><BR><a href="" target="_new">docs</a>

TWiki URL: [[Giri][Mandalika]], [[Kalyana][Chakravarthy]], [[IsveSeeameOrgadKimchiIGTvLabProcedures][docs]], [[OmalleyDataProject][Omalley]]
HTTP equivalent: <a href="" target="_new">Mandalika</a><BR><a href="" target="_new">Chakravarthy</a><BR><a href="" target="_new">docs</a><BR><a href="" target="_new">Omalley</a>

TWiki URL:
HTTP equivalent: <a href="" target="_new">ana.html</a>

TWiki URL:,
HTTP equivalent: <a href="" target="_new">ana.html</a><BR><a href="" target="_new"></a>

TWiki URL: [[][MeraJanuaryScoping]]
HTTP equivalent: <a href="" target="_new">MeraJanuaryScoping</a>

TWiki URL: [[][execution details]] <BR> [[][OracleRAConLDom]]
HTTP equivalent: <a href="" target="_new">execution details</a><BR><a href="" target="_new">OracleRAConLDom</a>

TWiki URL: [[][scoping document]] , [[][MeraJanuaryScoping]] <BR> [[][techeval]] , [[][techeval]]
HTTP equivalent: <a href="" target="_new">scoping document</a><BR><a href="" target="_new">MeraJanuaryScoping</a><BR><a href="" target="_new">techeval</a><BR><a href="" target="_new">techeval</a>

TWiki URL: [[Main.RomanIvanovLDomsCheatSheet][Execution tracking page]]
HTTP equivalent: <a href="" target="_new">Execution tracking page</a>

TWiki URL: [[MDE.IsveBravoJeffTaylorProgressApamaSolarisx64Pott][Link]]
HTTP equivalent: <a href="" target="_new">Link</a>

TWiki URL: [[Main.JNetX#April_22nd_2008_Whats_new_at_Sun][report]]
HTTP equivalent: <a href="" target="_new">report</a>

TWiki URL: [[Main.RomanIvanovLDomsCheatSheet][Execution tracking page]], [[MDE.IsveBravoJeffTaylorProgressApamaSolarisx64Pott][Link]] <BR> [[Main.JNetX#April_22nd_2008_Whats_new_at_Sun][report]]
HTTP equivalent: <a href="" target="_new">Execution tracking page</a><BR><a href="" target="_new">Link</a><BR><a href="" target="_new">report</a>

TWiki URL: [[][World-Online]]
HTTP equivalent: <a href="" target="_new">World-Online</a>

TWiki URL: [[ISVeProjects.IsveIndividualSummaryCarylTakvorian][Caryl Takvorian]] Tom Duell
HTTP equivalent: <a href="" target="_new">Caryl Takvorian</a>

TWiki URL: [[][Andrew Walton]]
HTTP equivalent: <a href="" target="_new">Andrew Walton</a>

TWiki URL: [[][Project Folder]]
HTTP equivalent: <a href="" target="_new">Project Folder</a>

TWiki URL: [[][Cust. Report]], [[][ISVE Report]]
HTTP equivalent: <a href="" target="_new">Cust. Report</a><BR><a href="" target="_new">ISVE Report</a>

TWiki URL: MDE.IsveAlphaBogdanVasiliuSynopsysVCSPerformanceOptimization
HTTP equivalent: <a href="" target="_new">IsveAlphaBogdanVasiliuSynopsysVCSPerformanceOptimization</a>

TWiki URL: [[Main.RomanIvanovLDomsCheatSheet]]
HTTP equivalent: <a href="" target="_new">RomanIvanovLDomsCheatSheet</a>

TWiki URL: MDE.PostgreSQLAutoTune <BR> [[Main.RomanIvanovLDomsCheatSheet]] , MDE.IsveAlphaBogdanVasiliuSynopsysVCSPerformanceOptimization
HTTP equivalent: <a href="" target="_new">RomanIvanovLDomsCheatSheet</a><BR><a href="" target="_new">PostgreSQLAutoTune</a><BR><a href="" target="_new">IsveAlphaBogdanVasiliuSynopsysVCSPerformanceOptimization</a>

TWiki URL: [[][Mohammed Yousuf]], Thiagarajan Chandrasekaran
HTTP equivalent: <a href="" target="_new">Mohammed Yousuf</a>

TWiki URL: MDE.IsveDabuboirProsDamienCookeMyStaffMyStaffPostgreSQLAdoption [[http://twiki.etclabs/pub/MDE/IsveDabuboirProsDamienCookeMyStaffMyStaffPostgreSQLAdoption/MyStaff.html][Project Status]]
HTTP equivalent: <a href="http://twiki.etclabs/pub/MDE/IsveDabuboirProsDamienCookeMyStaffMyStaffPostgreSQLAdoption/MyStaff.html" target="_new">Project Status</a><BR><a href="" target="_new">IsveDabuboirProsDamienCookeMyStaffMyStaffPostgreSQLAdoption</a>

TWiki URL: [[]], <a href="">xyz</a>, , <a href="">giri</a> , [[][harisha]], <a href="">etclabs</a>
HTTP equivalent: <a href="">xyz</a><BR><a href="">giri</a><BR><a href="">etclabs</a><BR><a href="" target="_new"><BR><a href="" target="_new">harisha</a><BR><a href="" target="_new"></a>

TWiki URL: New link YousufCertificationofOracleRAConSolaris10u6Containers , old link
HTTP equivalent: <a href="" target="_new">rac</a>

TWiki URL: attached email.
HTTP equivalent:

TWiki URL: [[ Caucho]] [[ 20070812164315]]
HTTP equivalent: <a href="" target="_new">Caucho</a><BR><a href="" target="_new">20070812164315</a>

TWiki URL:
HTTP equivalent: <a href="" target="_new">download.epd?context=40E2D9D5E00E ... BAEB80527B36EC026E03386D659E4DE48</a>

This code is poorly documented, not perfect and most importantly may not even meet the minimum Java coding standards. However it does the intended job with minor modifications. Feel free to use, modify, reproduce or redistribute - but please do not come back complaining. I have no intention of fixing or improving this code.

Comments: Post a Comment

Links to this post:

Create a Link

<< Home


This page is powered by Blogger. Isn't yours?