Link rootLink0View = rootFolderView.getLink("link0.link");
assertNotNull(rootLink0View);
assertEquals(rootFolderView, rootLink0View.getParent());
assertEquals("link0.link", rootLink0View.getName());
assertEquals("/link0.link", extractFileSystemPathFromId(rootLink0View.getId()));
DynamicPage docPageView = rootFolderView.getDynamicPage("docpage.dpsml");
assertNotNull(docPageView);
assertEquals(rootFolderView, docPageView.getParent());
assertEquals("docpage.dpsml", docPageView.getName());
assertEquals("/docpage.dpsml", extractFileSystemPathFromId(docPageView.getId()));
Folder rootFolder0View = rootFolderView.getFolder("folder0");
assertNotNull(rootFolder0View);
assertEquals(rootFolderView, rootFolder0View.getParent());
assertEquals(1, rootFolder0View.getPages().size());
assertNull(rootFolder0View.getLinks());
assertEquals("folder0", rootFolder0View.getName());
assertEquals("/folder0", extractFileSystemPathFromId(rootFolder0View.getId()));
Page folder0Page0View = rootFolder0View.getPage("page0.psml");
assertNotNull(folder0Page0View);
assertEquals(rootFolder0View, folder0Page0View.getParent());
assertEquals("page0.psml", folder0Page0View.getName());
assertEquals("/folder0/page0.psml", extractFileSystemPathFromId(folder0Page0View.getId()));
// test SiteView access by path
Folder rootFolderViewByPath = (Folder)baseView.getNodeView("/", null, null, true, false, false);
assertNotNull(rootFolderViewByPath);
assertEquals(rootFolderView, rootFolderViewByPath);
Folder rootFolder0ViewByPath = (Folder)baseView.getNodeView("/folder0/", null, null, true, false, false);
assertNotNull(rootFolder0ViewByPath);
assertEquals(rootFolder0View, rootFolder0ViewByPath);
Page folder0Page0ViewByPath = (Page)baseView.getNodeView("/folder0/page0.psml", null, null, true, false, false);
assertNotNull(folder0Page0ViewByPath);
assertEquals(folder0Page0View, folder0Page0ViewByPath);
folder0Page0ViewByPath = (Page)baseView.getNodeView("page0.psml", rootFolder0View, null, true, false, false);
assertNotNull(folder0Page0ViewByPath);
assertEquals(folder0Page0View, folder0Page0ViewByPath);
try
{
baseView.getNodeView("/folderX/page0.psml", null, null, true, false, false);
fail("/folderX/page0.psml should not be found");
}
catch (NodeNotFoundException nnfe)
{
}
try
{
baseView.getNodeView("/folder0/pageX.psml", null, null, true, false, false);
fail("/folder0/pageX.psml should not be found");
}
catch (NodeNotFoundException nnfe)
{
}
List rootPageViewsByPath = baseView.getNodeViews("/page?.psml", null, null, true, false, false);
assertNotNull(rootPageViewsByPath);
assertEquals(3,rootPageViewsByPath.size());
assertTrue(rootPageViewsByPath.contains(rootPage0View));
List rootFolderViewsByPath = baseView.getNodeViews("/*/", null, null, true, false, false);
assertNotNull(rootFolderViewsByPath);
assertEquals(6,rootFolderViewsByPath.size());
assertTrue(rootFolderViewsByPath.contains(rootFolder0View));
List folderPageViewsByPath = baseView.getNodeViews("*/p*[0-9].psml", rootFolderView, null, true, false, false);
assertNotNull(folderPageViewsByPath);
assertEquals(2,folderPageViewsByPath.size());
assertTrue(folderPageViewsByPath.contains(folder0Page0View));
// test aggregating SiteView
SearchPathsSiteView aggregateView = new SearchPathsSiteView(pageManager, "/_user/user,/_role/role0,/_group/group,/", false);
assertEquals("/_user/user,/_role/role0,/_group/group,/", aggregateView.getSearchPathsString());
rootFolderView = aggregateView.getRootFolderView();
assertNotNull(rootFolderView);
assertEquals("/", rootFolderView.getName());
assertEquals("user root", rootFolderView.getTitle());
assertEquals("/_user/user", extractFileSystemPathFromId(rootFolderView.getId()));
assertEquals(6, rootFolderView.getFolders().size());
assertEquals(4, rootFolderView.getPages().size());
assertEquals(2, rootFolderView.getLinks().size());
assertEquals(2, rootFolderView.getDynamicPages().size());
rootPage0View = rootFolderView.getPage("page0.psml");
assertNotNull(rootPage0View);
assertEquals(rootFolderView, rootPage0View.getParent());
assertEquals("page0.psml", rootPage0View.getName());
assertEquals("/page0.psml", extractFileSystemPathFromId(rootPage0View.getId()));
List rootPage0ViewMenus = rootPage0View.getMenuDefinitions();
assertNotNull(rootPage0ViewMenus);
assertEquals(7 + aggregateView.getStandardMenuNames().size(), rootPage0ViewMenus.size());
Iterator menusIter = rootPage0ViewMenus.iterator();
MenuDefinition rootPage0ViewTemplateTestMenu = (MenuDefinition)menusIter.next();
assertEquals("template-test", rootPage0ViewTemplateTestMenu.getName());
assertEquals("/page2.psml", rootPage0ViewTemplateTestMenu.getOptions());
MenuDefinition rootPage0ViewTopMenu = (MenuDefinition)menusIter.next();
assertEquals("top", rootPage0ViewTopMenu.getName());
assertEquals("/", rootPage0ViewTopMenu.getOptions());
assertEquals(2, rootPage0ViewTopMenu.getDepth());
assertEquals("dhtml-pull-down", rootPage0ViewTopMenu.getSkin());
MenuDefinition rootPage0ViewBreadCrumbMenu = (MenuDefinition)menusIter.next();
assertEquals("bread-crumbs", rootPage0ViewBreadCrumbMenu.getName());
assertEquals("./", rootPage0ViewBreadCrumbMenu.getOptions());
assertEquals(true, rootPage0ViewBreadCrumbMenu.isPaths());
MenuDefinition rootPage0ViewCurrentPageTestMenu = (MenuDefinition)menusIter.next();
assertEquals("current-page-test", rootPage0ViewCurrentPageTestMenu.getName());
MenuDefinition rootPage0ViewCurrentPathTestMenu = (MenuDefinition)menusIter.next();
assertEquals("current-path-test", rootPage0ViewCurrentPathTestMenu.getName());
MenuDefinition rootPage0SiteNavigationsMenu = (MenuDefinition)menusIter.next();
assertEquals("site-navigations", rootPage0SiteNavigationsMenu.getName());
assertTrue(rootPage0SiteNavigationsMenu.isRegexp());
assertEquals("/*/,/*.psml", rootPage0SiteNavigationsMenu.getOptions());
assertEquals(-1, rootPage0SiteNavigationsMenu.getDepth());
MenuDefinition rootPage0RootedNavigationsMenu = (MenuDefinition)menusIter.next();
assertEquals("rooted-navigations", rootPage0RootedNavigationsMenu.getName());
for (int i = 0; (i < aggregateView.getStandardMenuNames().size()); i++)
{
assertTrue(aggregateView.getStandardMenuNames().contains(((MenuDefinition)menusIter.next()).getName()));
}
Page rootPage2View = rootFolderView.getPage("page2.psml");
assertNotNull(rootPage2View);
assertEquals(rootFolderView, rootPage2View.getParent());
assertEquals("page2.psml", rootPage2View.getName());
assertEquals("/_user/user/page2.psml", extractFileSystemPathFromId(rootPage2View.getId()));
List rootPage2ViewMenus = rootPage2View.getMenuDefinitions();
assertNotNull(rootPage2ViewMenus);
assertEquals(7 + aggregateView.getStandardMenuNames().size(), rootPage2ViewMenus.size());
menusIter = rootPage2ViewMenus.iterator();
MenuDefinition rootPage2ViewTopMenu = (MenuDefinition)menusIter.next();
assertEquals("top", rootPage2ViewTopMenu.getName());
assertEquals("/", rootPage2ViewTopMenu.getOptions());
assertEquals(1, rootPage2ViewTopMenu.getDepth());
MenuDefinition rootPage2ViewBreadCrumbMenu = (MenuDefinition)menusIter.next();
assertEquals("bread-crumbs", rootPage2ViewBreadCrumbMenu.getName());
MenuDefinition rootPage2ViewTemplateTestMenu = (MenuDefinition)menusIter.next();
assertEquals("template-test", rootPage2ViewTemplateTestMenu.getName());
assertEquals("/page0.psml", rootPage2ViewTemplateTestMenu.getOptions());
MenuDefinition rootPage2ViewCurrentPageTestMenu = (MenuDefinition)menusIter.next();
assertEquals("current-page-test", rootPage0ViewCurrentPageTestMenu.getName());
MenuDefinition rootPage2ViewCurrentPathTestMenu = (MenuDefinition)menusIter.next();
assertEquals("current-path-test", rootPage0ViewCurrentPathTestMenu.getName());
MenuDefinition rootPage2SiteNavigationsMenu = (MenuDefinition)menusIter.next();
assertEquals("site-navigations", rootPage2SiteNavigationsMenu.getName());
MenuDefinition rootPage2RootedNavigationsMenu = (MenuDefinition)menusIter.next();
assertEquals("rooted-navigations", rootPage2RootedNavigationsMenu.getName());
for (int i = 0; (i < aggregateView.getStandardMenuNames().size()); i++)
{
assertTrue(aggregateView.getStandardMenuNames().contains(((MenuDefinition)menusIter.next()).getName()));
}
rootLink0View = rootFolderView.getLink("link0.link");
assertNotNull(rootLink0View);
assertEquals(rootFolderView, rootLink0View.getParent());
assertEquals("link0.link", rootLink0View.getName());
assertEquals("/_group/group/link0.link", extractFileSystemPathFromId(rootLink0View.getId()));
rootFolder0View = rootFolderView.getFolder("folder0");
assertNotNull(rootFolder0View);
assertEquals(rootFolderView, rootFolder0View.getParent());
assertEquals(1, rootFolder0View.getPages().size());
assertNull(rootFolder0View.getLinks());
assertNull(rootFolder0View.getFolders());
assertEquals("folder0", rootFolder0View.getName());
assertEquals("folder0", rootFolder0View.getTitle());
assertEquals("/folder0", extractFileSystemPathFromId(rootFolder0View.getId()));
folder0Page0View = rootFolder0View.getPage("page0.psml");
assertNotNull(folder0Page0View);
assertEquals(rootFolder0View, folder0Page0View.getParent());
assertEquals("page0.psml", folder0Page0View.getName());
assertEquals("/folder0/page0.psml", extractFileSystemPathFromId(folder0Page0View.getId()));
Folder rootFolder1View = rootFolderView.getFolder("folder1");
assertNotNull(rootFolder1View);
assertEquals(rootFolderView, rootFolder1View.getParent());
assertEquals(2, rootFolder1View.getPages().size());
assertNull(rootFolder1View.getLinks());
assertNotNull(rootFolder1View.getFolders());
assertEquals(1, rootFolder1View.getFolders().size());
assertEquals("folder1", rootFolder1View.getName());
assertEquals("group folder1", rootFolder1View.getTitle());
assertEquals("/_user/user/folder1", extractFileSystemPathFromId(rootFolder1View.getId()));
assertEquals("/_user/user", aggregateView.getUserFolderPath());
assertEquals("/", aggregateView.getBaseFolderPath());
// test degenerate aggregating SiteView
aggregateView = new SearchPathsSiteView(pageManager, "/__subsite-root", false);
assertEquals("/__subsite-root", aggregateView.getSearchPathsString());
rootFolderView = aggregateView.getRootFolderView();
assertNotNull(rootFolderView);
assertEquals("/", rootFolderView.getName());
assertEquals("subsite root", rootFolderView.getTitle());
assertEquals("/__subsite-root", extractFileSystemPathFromId(rootFolderView.getId()));
assertNull(rootFolderView.getFolders());
assertEquals(1, rootFolderView.getPages().size());
assertEquals(1, rootFolderView.getLinks().size());
// test SiteView construction using profile locators
JetspeedProfileLocator locator = new JetspeedProfileLocator();
locator.init(null, "/");
SearchPathsSiteView profileView = new SearchPathsSiteView(pageManager, locator, false);
assertEquals("/", profileView.getSearchPathsString());
locator = new JetspeedProfileLocator();
locator.init(null, "/");
locator.add("user", true, false, "user");
locator.add("page", false, false, "default-page");
profileView = new SearchPathsSiteView(pageManager, locator, false);
assertEquals("/_user/user,/", profileView.getSearchPathsString());
locator = new JetspeedProfileLocator();
locator.init(null, "/");
locator.add("page", false, false, "default-page");
locator.add("user", true, false, "user");
locator.add("mediatype", true, false, "html");
locator.add("language", true, false, "en");
locator.add("country", true, false, "US");
profileView = new SearchPathsSiteView(pageManager, locator, false);
assertEquals("/_user/user/_mediatype/html,/_user/user,/", profileView.getSearchPathsString());
locator = new JetspeedProfileLocator();
locator.init(null, "/");
locator.add("page", false, false, "default-page");
locator.add("role", true, false, "role0");
locator.add("role", true, false, "role1");
profileView = new SearchPathsSiteView(pageManager, locator, false);
assertEquals("/_role/role0,/_role/role1,/", profileView.getSearchPathsString());
locator = new JetspeedProfileLocator();
locator.init(null, "/");
locator.add("user", true, false, "user");
locator.add("navigation", false, true, "/");
locator.add("role", true, false, "role0");
locator.add("navigation", false, true, "/");
locator.add("group", true, false, "group");
locator.add("page", false, false, "default-page");
profileView = new SearchPathsSiteView(pageManager, locator, false);
assertEquals("/_user/user,/_role/role0,/_group/group,/", profileView.getSearchPathsString());
locator = new JetspeedProfileLocator();
locator.init(null, "/");
locator.add("hostname", true, false, "dash");
locator.add("user", true, false, "joe");
locator.add("page", false, false, "home");
profileView = new SearchPathsSiteView(pageManager, locator, false);
assertEquals("/_hostname/dash/_user/joe,/_hostname/dash,/", profileView.getSearchPathsString());
locator = new JetspeedProfileLocator();
locator.init(null, "/");
locator.add("navigation", false, true, "subsite-root");
profileView = new SearchPathsSiteView(pageManager, locator, false);
assertEquals("/__subsite-root", profileView.getSearchPathsString());
Map locators = new HashMap();
locator = new JetspeedProfileLocator();
locator.init(null, "/");
locator.add("role", true, false, "role0");
locator.add("role", true, false, "role1");
locators.put(ProfileLocator.PAGE_LOCATOR, locator);
locator = new JetspeedProfileLocator();
locator.init(null, "/");
locator.add("user", true, false, "user");
locator.add("navigation", false, true, "/");
locator.add("group", true, false, "group");
locators.put("alternate-locator-name", locator);
profileView = new SearchPathsSiteView(pageManager, locators, false);
assertEquals("/_role/role0,/_role/role1,/_user/user,/_group/group,/", profileView.getSearchPathsString());
rootFolderView = profileView.getRootFolderView();
assertNotNull(rootFolderView);
assertEquals("/", rootFolderView.getName());
assertEquals("user root", rootFolderView.getTitle());
assertEquals("/_role/role0", extractFileSystemPathFromId(rootFolderView.getId()));
assertEquals(ProfileLocator.PAGE_LOCATOR, extractLocatorNameFromView(rootFolderView));
rootPage2View = rootFolderView.getPage("page2.psml");
assertNotNull(rootPage2View);
assertEquals("page2.psml", rootPage2View.getName());
assertEquals("/_role/role0/page2.psml", extractFileSystemPathFromId(rootPage2View.getId()));
assertEquals(ProfileLocator.PAGE_LOCATOR, extractLocatorNameFromView(rootPage2View));
rootFolder1View = rootFolderView.getFolder("folder1");
assertNotNull(rootFolder1View);
assertEquals("folder1", rootFolder1View.getName());
assertEquals("group folder1", rootFolder1View.getTitle());
assertEquals("/_user/user/folder1", extractFileSystemPathFromId(rootFolder1View.getId()));
assertEquals("alternate-locator-name", extractLocatorNameFromView(rootFolder1View));
Page folder1Page1View = rootFolder1View.getPage("page1.psml");
assertNotNull(folder1Page1View);
assertEquals("page1.psml", folder1Page1View.getName());
assertEquals("/_group/group/folder1/page1.psml", extractFileSystemPathFromId(folder1Page1View.getId()));
assertEquals("alternate-locator-name", extractLocatorNameFromView(folder1Page1View));
assertEquals("/_user/user", profileView.getUserFolderPath());
assertEquals("/", profileView.getBaseFolderPath());
// test physical SiteView
PhysicalSiteView basePhysicalView = new PhysicalSiteView(pageManager, "user");
rootFolderView = basePhysicalView.getRootFolderView();
assertNotNull(rootFolderView);
assertEquals("/", rootFolderView.getName());
assertEquals("root", rootFolderView.getTitle());
assertEquals("/", extractFileSystemPathFromId(rootFolderView.getId()));
assertEquals(11, rootFolderView.getFolders().size());
foldersIter = rootFolderView.getFolders().iterator();
assertEquals("__subsite-root", ((Folder)foldersIter.next()).getName());
assertEquals("_group", ((Folder)foldersIter.next()).getName());
assertEquals("_hostname", ((Folder)foldersIter.next()).getName());
assertEquals("_role", ((Folder)foldersIter.next()).getName());
assertEquals("_user", ((Folder)foldersIter.next()).getName());
assertEquals("contentfolder", ((Folder)foldersIter.next()).getName());
assertEquals("folder0", ((Folder)foldersIter.next()).getName());
assertEquals("folder1", ((Folder)foldersIter.next()).getName());
assertEquals("folder2", ((Folder)foldersIter.next()).getName());
assertEquals("folder3", ((Folder)foldersIter.next()).getName());
assertEquals("folder4", ((Folder)foldersIter.next()).getName());
assertEquals(4, rootFolderView.getPages().size());
pagesIter = rootFolderView.getPages().iterator();
assertEquals("page2.psml", ((Page)pagesIter.next()).getName());
assertEquals("page1.psml", ((Page)pagesIter.next()).getName());
assertEquals("page0.psml", ((Page)pagesIter.next()).getName());
assertEquals("hidden.psml", ((Page)pagesIter.next()).getName());
assertEquals(2, rootFolderView.getLinks().size());
linksIter = rootFolderView.getLinks().iterator();
assertEquals("link1.link", ((Link)linksIter.next()).getName());
assertEquals("link0.link", ((Link)linksIter.next()).getName());
assertEquals(2, rootFolderView.getDynamicPages().size());
dynamicPagesIter = rootFolderView.getDynamicPages().iterator();
assertEquals("contentpage.dpsml", ((DynamicPage)dynamicPagesIter.next()).getName());
assertEquals("docpage.dpsml", ((DynamicPage)dynamicPagesIter.next()).getName());
rootPage0View = rootFolderView.getPage("page0.psml");
assertNotNull(rootPage0View);
assertEquals(rootFolderView, rootPage0View.getParent());
assertEquals("page0.psml", rootPage0View.getName());
assertEquals("/page0.psml", extractFileSystemPathFromId(rootPage0View.getId()));
rootHiddenView = rootFolderView.getPage("hidden.psml");
assertNotNull(rootHiddenView);
assertEquals("hidden.psml", rootHiddenView.getName());
assertTrue(rootHiddenView.isHidden());
rootLink0View = rootFolderView.getLink("link0.link");
assertNotNull(rootLink0View);
assertEquals(rootFolderView, rootLink0View.getParent());
assertEquals("link0.link", rootLink0View.getName());
assertEquals("/link0.link", extractFileSystemPathFromId(rootLink0View.getId()));
docPageView = rootFolderView.getDynamicPage("docpage.dpsml");
assertNotNull(docPageView);
assertEquals(rootFolderView, docPageView.getParent());
assertEquals("docpage.dpsml", docPageView.getName());
assertEquals("/docpage.dpsml", extractFileSystemPathFromId(docPageView.getId()));
rootFolder0View = rootFolderView.getFolder("folder0");
assertNotNull(rootFolder0View);
assertEquals(rootFolderView, rootFolder0View.getParent());
assertEquals(1, rootFolder0View.getPages().size());
assertEquals(0, rootFolder0View.getLinks().size());