assertEquals("hidden.psml", ((Page)pagesIter.next()).getName());
assertEquals(2, rootFolderProxy.getLinks().size());
Iterator linksIter = rootFolderProxy.getLinks().iterator();
assertEquals("link1.link", ((Link)linksIter.next()).getName());
assertEquals("link0.link", ((Link)linksIter.next()).getName());
Page rootPage0Proxy = rootFolderProxy.getPage("page0.psml");
assertNotNull(rootPage0Proxy);
assertEquals(rootFolderProxy, rootPage0Proxy.getParent());
assertEquals("page0.psml", rootPage0Proxy.getName());
assertEquals("/page0.psml", extractFileSystemPathFromId(rootPage0Proxy.getId()));
Page rootHiddenProxy = rootFolderProxy.getPage("hidden.psml");
assertNotNull(rootHiddenProxy);
assertEquals("hidden.psml", rootHiddenProxy.getName());
assertTrue(rootHiddenProxy.isHidden());
Link rootLink0Proxy = rootFolderProxy.getLink("link0.link");
assertNotNull(rootLink0Proxy);
assertEquals(rootFolderProxy, rootLink0Proxy.getParent());
assertEquals("link0.link", rootLink0Proxy.getName());
assertEquals("/link0.link", extractFileSystemPathFromId(rootLink0Proxy.getId()));
Folder rootFolder0Proxy = rootFolderProxy.getFolder("folder0");
assertNotNull(rootFolder0Proxy);
assertEquals(rootFolderProxy, rootFolder0Proxy.getParent());
assertEquals(1, rootFolder0Proxy.getPages().size());
assertEquals(null, rootFolder0Proxy.getLinks());
assertEquals("folder0", rootFolder0Proxy.getName());
assertEquals("/folder0", extractFileSystemPathFromId(rootFolder0Proxy.getId()));
Page folder0Page0Proxy = rootFolder0Proxy.getPage("page0.psml");
assertNotNull(folder0Page0Proxy);
assertEquals(rootFolder0Proxy, folder0Page0Proxy.getParent());
assertEquals("page0.psml", folder0Page0Proxy.getName());
assertEquals("/folder0/page0.psml", extractFileSystemPathFromId(folder0Page0Proxy.getId()));
// test SiteView access by path
Folder rootFolderProxyByPath = (Folder)baseView.getNodeProxy("/", null, false, false);
assertNotNull(rootFolderProxyByPath);
assertEquals(rootFolderProxy, rootFolderProxyByPath);
Folder rootFolder0ProxyByPath = (Folder)baseView.getNodeProxy("/folder0/", null, false, false);
assertNotNull(rootFolder0ProxyByPath);
assertEquals(rootFolder0Proxy, rootFolder0ProxyByPath);
Page folder0Page0ProxyByPath = (Page)baseView.getNodeProxy("/folder0/page0.psml", null, false, false);
assertNotNull(folder0Page0ProxyByPath);
assertEquals(folder0Page0Proxy, folder0Page0ProxyByPath);
folder0Page0ProxyByPath = (Page)baseView.getNodeProxy("page0.psml", rootFolder0Proxy, false, false);
assertNotNull(folder0Page0ProxyByPath);
assertEquals(folder0Page0Proxy, folder0Page0ProxyByPath);
List rootPageProxiesByPath = baseView.getNodeProxies("/page?.psml", null, false, false);
assertNotNull(rootPageProxiesByPath);
assertEquals(3,rootPageProxiesByPath.size());
assertTrue(rootPageProxiesByPath.contains(rootPage0Proxy));
List rootFolderProxiesByPath = baseView.getNodeProxies("/*/", null, false, false);
assertNotNull(rootFolderProxiesByPath);
assertEquals(4,rootFolderProxiesByPath.size());
assertTrue(rootFolderProxiesByPath.contains(rootFolder0Proxy));
List folderPageProxiesByPath = baseView.getNodeProxies("*/p*[0-9].psml", rootFolderProxy, false, false);
assertNotNull(folderPageProxiesByPath);
assertEquals(2,folderPageProxiesByPath.size());
assertTrue(folderPageProxiesByPath.contains(folder0Page0Proxy));
// test aggregating SiteView
SiteView aggregateView = new SiteView(pageManager, "/_user/user,/_role/role0,/_group/group,/");
assertEquals("/_user/user,/_role/role0,/_group/group,/", aggregateView.getSearchPathsString());
rootFolderProxy = aggregateView.getRootFolderProxy();
assertNotNull(rootFolderProxy);
assertEquals("/", rootFolderProxy.getName());
assertEquals("user root", rootFolderProxy.getTitle());
assertEquals("/_user/user", extractFileSystemPathFromId(rootFolderProxy.getId()));
assertEquals(4, rootFolderProxy.getFolders().size());
assertEquals(4, rootFolderProxy.getPages().size());
assertEquals(2, rootFolderProxy.getLinks().size());
rootPage0Proxy = rootFolderProxy.getPage("page0.psml");
assertNotNull(rootPage0Proxy);
assertEquals(rootFolderProxy, rootPage0Proxy.getParent());
assertEquals("page0.psml", rootPage0Proxy.getName());
assertEquals("/page0.psml", extractFileSystemPathFromId(rootPage0Proxy.getId()));
List rootPage0ProxyMenus = rootPage0Proxy.getMenuDefinitions();
assertNotNull(rootPage0ProxyMenus);
assertEquals(2 + aggregateView.getStandardMenuNames().size(), rootPage0ProxyMenus.size());
Iterator menusIter = rootPage0ProxyMenus.iterator();
MenuDefinition rootPage0ProxyTopMenu = (MenuDefinition)menusIter.next();
assertEquals("top", rootPage0ProxyTopMenu.getName());
assertEquals("/", rootPage0ProxyTopMenu.getOptions());
assertEquals(2, rootPage0ProxyTopMenu.getDepth());
assertEquals("dhtml-pull-down", rootPage0ProxyTopMenu.getSkin());
MenuDefinition rootPage0ProxyBreadCrumbMenu = (MenuDefinition)menusIter.next();
assertEquals("bread-crumbs", rootPage0ProxyBreadCrumbMenu.getName());
assertEquals("./", rootPage0ProxyBreadCrumbMenu.getOptions());
assertEquals(true, rootPage0ProxyBreadCrumbMenu.isPaths());
for (int i = 0; (i < aggregateView.getStandardMenuNames().size()); i++)
{
assertTrue(aggregateView.getStandardMenuNames().contains(((MenuDefinition)menusIter.next()).getName()));
}
Page rootPage2Proxy = rootFolderProxy.getPage("page2.psml");
assertNotNull(rootPage2Proxy);
assertEquals(rootFolderProxy, rootPage2Proxy.getParent());
assertEquals("page2.psml", rootPage2Proxy.getName());
assertEquals("/_user/user/page2.psml", extractFileSystemPathFromId(rootPage2Proxy.getId()));
List rootPage2ProxyMenus = rootPage2Proxy.getMenuDefinitions();
assertNotNull(rootPage2ProxyMenus);
assertEquals(2 + aggregateView.getStandardMenuNames().size(), rootPage2ProxyMenus.size());
menusIter = rootPage2ProxyMenus.iterator();
MenuDefinition rootPage2ProxyTopMenu = (MenuDefinition)menusIter.next();
assertEquals("top", rootPage2ProxyTopMenu.getName());
assertEquals("/", rootPage2ProxyTopMenu.getOptions());
assertEquals(1, rootPage2ProxyTopMenu.getDepth());
MenuDefinition rootPage2ProxyBreadCrumbMenu = (MenuDefinition)menusIter.next();
assertEquals("bread-crumbs", rootPage2ProxyBreadCrumbMenu.getName());
for (int i = 0; (i < aggregateView.getStandardMenuNames().size()); i++)
{
assertTrue(aggregateView.getStandardMenuNames().contains(((MenuDefinition)menusIter.next()).getName()));
}
rootLink0Proxy = rootFolderProxy.getLink("link0.link");
assertNotNull(rootLink0Proxy);
assertEquals(rootFolderProxy, rootLink0Proxy.getParent());
assertEquals("link0.link", rootLink0Proxy.getName());
assertEquals("/_group/group/link0.link", extractFileSystemPathFromId(rootLink0Proxy.getId()));
rootFolder0Proxy = rootFolderProxy.getFolder("folder0");
assertNotNull(rootFolder0Proxy);
assertEquals(rootFolderProxy, rootFolder0Proxy.getParent());
assertEquals(1, rootFolder0Proxy.getPages().size());
assertEquals(null, rootFolder0Proxy.getLinks());
assertEquals(null, rootFolder0Proxy.getFolders());
assertEquals("folder0", rootFolder0Proxy.getName());
assertEquals("folder0", rootFolder0Proxy.getTitle());
assertEquals("/folder0", extractFileSystemPathFromId(rootFolder0Proxy.getId()));
folder0Page0Proxy = rootFolder0Proxy.getPage("page0.psml");
assertNotNull(folder0Page0Proxy);
assertEquals(rootFolder0Proxy, folder0Page0Proxy.getParent());
assertEquals("page0.psml", folder0Page0Proxy.getName());
assertEquals("/folder0/page0.psml", extractFileSystemPathFromId(folder0Page0Proxy.getId()));
Folder rootFolder1Proxy = rootFolderProxy.getFolder("folder1");
assertNotNull(rootFolder1Proxy);
assertEquals(rootFolderProxy, rootFolder1Proxy.getParent());
assertEquals(2, rootFolder1Proxy.getPages().size());
assertEquals(null, rootFolder1Proxy.getLinks());
assertEquals(null, rootFolder1Proxy.getFolders());
assertEquals("folder1", rootFolder1Proxy.getName());
assertEquals("group folder1", rootFolder1Proxy.getTitle());
assertEquals("/_user/user/folder1", extractFileSystemPathFromId(rootFolder1Proxy.getId()));
// test degenerate aggregating SiteView
aggregateView = new SiteView(pageManager, "/__subsite-root");
assertEquals("/__subsite-root", aggregateView.getSearchPathsString());
rootFolderProxy = aggregateView.getRootFolderProxy();
assertNotNull(rootFolderProxy);
assertEquals("/", rootFolderProxy.getName());
assertEquals("subsite root", rootFolderProxy.getTitle());
assertEquals("/__subsite-root", extractFileSystemPathFromId(rootFolderProxy.getId()));
assertEquals(null, rootFolderProxy.getFolders());
assertEquals(1, rootFolderProxy.getPages().size());
assertEquals(1, rootFolderProxy.getLinks().size());
// test SiteView construction using profile locators
JetspeedProfileLocator locator = new JetspeedProfileLocator();
locator.init(null, "/");
SiteView profileView = new SiteView(pageManager, locator);
assertEquals("/", profileView.getSearchPathsString());
locator = new JetspeedProfileLocator();
locator.init(null, "/");
locator.add("user", true, false, "user");
locator.add("page", false, false, "default-page");
profileView = new SiteView(pageManager, locator);
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 SiteView(pageManager, locator);
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 SiteView(pageManager, locator);
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 SiteView(pageManager, locator);
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 SiteView(pageManager, locator);
assertEquals("/_hostname/dash/_user/joe,/_hostname/dash,/", profileView.getSearchPathsString());
locator = new JetspeedProfileLocator();
locator.init(null, "/");
locator.add("navigation", false, true, "subsite-root");
profileView = new SiteView(pageManager, locator);
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 SiteView(pageManager, locators);
assertEquals("/_role/role0,/_role/role1,/_user/user,/_group/group,/", profileView.getSearchPathsString());
rootFolderProxy = profileView.getRootFolderProxy();
assertNotNull(rootFolderProxy);
assertEquals("/", rootFolderProxy.getName());
assertEquals("user root", rootFolderProxy.getTitle());
assertEquals("/_role/role0", extractFileSystemPathFromId(rootFolderProxy.getId()));
assertEquals(ProfileLocator.PAGE_LOCATOR, extractLocatorNameFromProxy(rootFolderProxy));
rootPage2Proxy = rootFolderProxy.getPage("page2.psml");
assertNotNull(rootPage2Proxy);
assertEquals("page2.psml", rootPage2Proxy.getName());
assertEquals("/_role/role0/page2.psml", extractFileSystemPathFromId(rootPage2Proxy.getId()));
assertEquals(ProfileLocator.PAGE_LOCATOR, extractLocatorNameFromProxy(rootPage2Proxy));
rootFolder1Proxy = rootFolderProxy.getFolder("folder1");
assertNotNull(rootFolder1Proxy);
assertEquals("folder1", rootFolder1Proxy.getName());
assertEquals("group folder1", rootFolder1Proxy.getTitle());
assertEquals("/_user/user/folder1", extractFileSystemPathFromId(rootFolder1Proxy.getId()));
assertEquals("alternate-locator-name", extractLocatorNameFromProxy(rootFolder1Proxy));
Page folder1Page1Proxy = rootFolder1Proxy.getPage("page1.psml");
assertNotNull(folder1Page1Proxy);
assertEquals("page1.psml", folder1Page1Proxy.getName());
assertEquals("/_group/group/folder1/page1.psml", extractFileSystemPathFromId(folder1Page1Proxy.getId()));
assertEquals("alternate-locator-name", extractLocatorNameFromProxy(folder1Page1Proxy));
}