Replacing URLs in bookmarks 

Run a command to replace URLs in bookmarks to correct broken links.


Before you begin


.

To edit configuration files, use the wsadmin client. See Starting the wsadmin client for details.


About this task


There may be times when you want to update the URLs for a collections of bookmarks. For example, when a web site changes its host name permanently, you will want to update all of the associated bookmarks with the new host name. For example, if http://site1.mycompany.com is changed to be http://site2.mycompany.com, run this replace URL command to update all bookmarks on http://site1.mycomapny.com.

The new URL may already be bookmarked by some users who also bookmarked the original URL. In those cases, you can not simply update the bookmark to the new URL as the Bookmarks application does not allow a user to have two or more valid bookmarks to the same URL. The IDs of those duplicated bookmarks will be saved to a file that you specify. You can either leave those duplicated bookmarks in the application or run LinkService.deleteLinkByURLBatch('<file>') to delete them from the application.

When you run this command you can replace URLs in the following ways:


Procedure

  1. See the topic Running Bookmarks administrative commands for information on using administrative commands.

  2. Use the following form for the UrlService command:

      UrlService.<command_name>(<parameters>)

  3. Run the following command to replace an existing URL with a new URL you specify:

      UrlService.replaceURLWithURL('original_URL_str', 'replace_URL_str', 'log_file')

      Parameters:

      original_URL_str

        A plain text string that specifies the URL to be replaced

      replace_URL_str

        A plain text string that specifies the replacement URL

      log_file

        A local file path that is used to log any messages that result from running the command. The file will be created if it is not exist; otherwise, new log data is appended to the data in the existing file.

      The exact match command finds the bookmarks with the specified URL and updates them to the specified replacement URL. The command runs immediately.

      Example:

      wsadmin>UrlService.replaceURLs('www.mysite.com', 'www.mycompany.com',  'c:\\log.txt') 

      This command searches for the URL www.mysite.com and replaces each instance with www.mycompany.com. Log messages are printed to c:\log.txt.

  4. To find URLs to replace and write them to a file, enter this command:

      UrlService.findURLsToReplace('<base>', '<URL_pattern>', '<replace_str>', '<output_file>', '<log_file>')

      Parameters:

      base

        Aplain text string that is used to limit the number of URLs to be scanned. Only those URLs containing <base> string are scanned.

      URL_pattern

        AJava-style regular expression that is used to match URLs

      replace_str

        Plain text string that is used to replace the found pattern in the matched URL

      output_file

        Local file path that is used to store the matched URLs and their replacement URLs. The file will be created if it does not exist and will be appended if it already exists.

      log_file

        Local file path that is used to log any messages that result from running the command. The file will be created if it does not exist; otherwise, new log data is appended to the data in the existing file.

      This command scans the Bookmarks database to URLs with associated bookmarks that match the given <URL_pattern> and then calculates the replacement URLs based on the <replace_str>. The command does not update the matched URLs in the Bookmarks. Scan results are saved in <output_file> so you can check the matched URLs and their replacement URLs to verify that the pairs are what you want. If not, you can manually edit the file to add, remove, or update the URL pairs. The command runs as a backend task in the system

      Example:

      wsadmin>UrlService.findURLsToReplace('mycompany', 'w3\\.mycompany\\.com', 'www.mycompany.com', 'c:\\output.txt', 'c:\\log.txt') 

      This command scans all URLs containing the string 'mycompany' and matches them against the regular expression pattern "w3\\.mycompany\\.com". The "w3.mycompany.com" in the matching URLs will be replaced by "www.mycompany.com". The matched URLs and the replacement URLs are printed into c:\output.txt file. Log messages are printed to c:\log.txt.

  5. To replace the URLs based on the contents of a file, enter this command:

      UrlService.replaceURLs('<input_file>', '<log_file>')

      Parameters:

        input_file

        A an input file which contains the original URLs and the replacement URLs.


      log_file
      A local file path that is used to log any messages that result from running the command. The file will be created if it does not exist; otherwise, new log data is appended to the data in the existing file.
      Specify an input file which contains the original URLs and the replacement URLs. You can use the output file of the findURLsToReplace command as the input here. URLs are updated unless a bookmark for the replacement URL already exists. Those are skipped to avoid creating duplicate bookmarks. Log messages are printed to c:\log.txt.

      Example:

      wsadmin>UrlService.replaceURLs('c:\\output.txt', 'c:\\log.txt')

      This command loads the URL pairs in the file c:\output.txt and updates all the bookmarks on the specified original URLs to the replacement URLs. Log messages are printed to c:\log.txt.


Parent topic

Manage links


November 23, 2011 6:49:43 AM
   

 

Nov 23, 2011 6:49:43 AM 2 Nov 22, 2011 9:10:04 AM 1

});