Additional Blogs by Members
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member
0 Kudos
This weblog is meant as a follow up to the original weblog by Prakash Singh of Universal Systems Technologies, Inc. The core code described in this weblog was written by Prakash, who has given me permission to write this weblog on his behalf. This is also a tool I use at work as it has saved me significant manual work when transporting (or migrating) KM content between development, test/QA and production environments.

A bit of background to begin. I recently posted a question in the forums concerning whether there was an automated way to recursively navigate within a folder in KM and replace text strings in target URLs of external links. I got a very useful reply by Prakash Singh, a growingly popular SDN member. He'd advised me to use the code I will describe later, and further to that went the extra mile to contact me by phone and assist me to actually build the project and compile the resulting PAR using SAP Netweaver Dev Studio. 'Pretty cool, eh? This is the type of collaborative effort SDN members have made that make SDN such an effective resource to the SAP customer base.

Now, to the code. Firstly, please refer to the weblog Prakash wrote earlier concerning building an HTMLB tree using recursive logic, as follows:

Build Your Own KM Navigation iView Using HTMLB Tree

Taking some of the learning in Prakash's weblog, you can now apply the same logic to modifying target URLs of external links. Building a new project, make sure to add the libraries that are part of the SAP NetWeaver Dev Studio installation in the path:

{SAP NetWeaver Dev Studio Installation Folder}JDTeclipsepluginscom.sap.km.rfwizardlib

And, libraries in the path you can locate from the Ep6 portal server:

{Ep6 Portal Server path}appssap.comirjservlet_jspirj
ootWEB-INFportalportalappscom.sap.portal.htmlblib


Then, in your code, ensure you've the following import lines before you proceed:



Next, you will want to declare three String variables: strPath, strSearch and strReplace. These will need to be assigned through your interface, or as properties within your 'portalapp.xml' file which your retrieve through a profile object, or however you wish. Those will then be used by the two methods that will perform the actual search and replace.

Now, include the following two methods within your application:



Now, you've an application that can perform a recursive search and replace in KM. That is, it will modify any external links within a given path (such as '/documents') and search and replace strings you specify within the target URL property of the external links that are found. I've a little tool in the works that combines this code into a proper Portal application (with a GUI, that is). I'll try and get that uploaded after the SDN Meets Labs event next week. Thanks to Prakash Singh for the great code and guidance. I hope you find this helpful. I've already been notified that someone has enquired about applying this logic towards modifying metadata in KM documents. The code would be very close to what is included here, with exception to referencing the KM objects not as links but as resources with specific properties.

4 Comments