My apologies, I don't think I'm exactly following what you need to do. Can you give me a step by step user story on how your custom widget will work?
Also, have you considered using the Digital Asset Manager for this task?
- Drag & Drop Digital Asset Libraries
Please take a look at the following documentation: Documents and files. This will go into detail about how to use the Sitefinity API to create libraries and documents.
I would recommend using Sitefinity Thunder to build a custom widget and then adding your code to create libraries and upload documents. Please note that Sitefinity doesn't have an upload component, so you will need code the upload dialog using C# or VB.Net.
I did a some more research on your question and there's one more step to getting your sub libraries content items. Your sub-libraries are not treated as libraries at all, but are actually organizational folders within your library. For example:
Only Library 1 and Library 2 are considered libraries. SubLibrary 1, SubLibrary 2, etc... are considered folders within each library.
Take a look at the following documentation, especially item #3, for more info on how to get sub folders and sub items.
Here's a quick sample of how you could do it in a foreach loop, though.
foreach(var library in documentLibraries)
var childItemsUnderFolder = librariesManager.GetChildFolders(library);
foreach (var subLibrary in childItemsUnderFolder)
var subLibraryItems = librariesManager.GetAncestorItems(subLibrary);
From there you will probably have to construct your own libraries and library items list to make it all manageable in your view.
Take a look at this forum post about how to get associated taxonomies from a document.