public RepositoryContentMetadata getCurrentContentMetadata() throws IOException
{
synchronized (this)
{
RepositoryContentMetadata md = new RepositoryContentMetadata(profileKey);
List<RepositoryRootMetadata> roots = new ArrayList<RepositoryRootMetadata>();
RepositoryContentMetadata official = getOfficialContentMetadata();
for (Map.Entry<String, VirtualFile> entry : vfCache.entrySet())
{
RepositoryRootMetadata rmd = new RepositoryRootMetadata();
rmd.setName(entry.getKey());
RepositoryRootMetadata existingRmd = official == null ? null : official.getRepositoryRootMetadata(entry.getKey());
VirtualFile root = entry.getValue();
if (isDirectory(root))
{
for(VirtualFile child: root.getChildren())
{
createItemMetadataFromScan(rmd, existingRmd, child, root);
}
}
else
{
// The root is itself an item. Treat it as a "child" of
// itself with no relative path
createItemMetadataFromScan(rmd, existingRmd, root, root);
}
roots.add(rmd);
}
md.setRepositories(roots);
// Retain any existing "removed item" metadata -- but only if
// it wasn't re-added!!
RepositoryContentMetadata existing = getOfficialContentMetadata();
if (existing != null)
{
for (RepositoryRootMetadata existingRoot : existing.getRepositories())
{
RepositoryRootMetadata rmd = md.getRepositoryRootMetadata(existingRoot.getName());
if (rmd != null)
{
Collection<RepositoryItemMetadata> rimds = rmd.getContent();