Approach 1: CRN Script
Anthony Colebourne wrote an export script that was used at Manchester. Just drop this file into uPortal along with the other crn scripts and execute in the usual way. The exported files can then be imported with the help of the import scripts included with this project.
Approach 2: SQL Queries
Data can be nested. See attached file that shows data in bookmark_store table for admin (and sample users):
admin
- folder
- respondr bookmark
- up8080 bookmark
If you are running Oracle, it would be easy because of Oracle's hierarchial queries to handle arbitrary nesting depth ( http://docs.oracle.com/cd/B19306_01/server.102/b14200/queries003.htm). Otherwise, if the data is flat (no folders) or a single folder it would be fairly easy; e.g. something like
# Get bookmarks owned by user not under any folder
select b.url, b.name, b.note, b.modified, b2.owner
from bookmark_store b, bookmark_store b2
where b.entry_type='BOOKMARK' and b.parent_folder_id=b2.entry_id and b2.entry_type='BOOKMARK_SET';
# Get bookmarks owned by user under single folder
select b.url, b.name, b.note, b.modified,
(select b1.owner from bookmark_store b1
where b1.entry_id = b2.parent_folder_id and b1.entry_type='BOOKMARK_SET') AS OWNER
from bookmark_store b, bookmark_store b2
where b.entry_type='BOOKMARK' and b.parent_folder_id=b2.entry_id and b2.entry_type='FOLDER';