ServiceSelector resourceTypeSelector = null;
try {
selector = (ServiceSelector) getManager().lookup(SiteManager.ROLE + "Selector");
siteManager = (SiteManager) selector.select(pub.getSiteManagerHint());
SiteStructure structure = siteManager.getSiteStructure(factory, pub,
Publication.AUTHORING_AREA);
docManager = (DocumentManager) getManager().lookup(DocumentManager.ROLE);
resourceTypeSelector = (ServiceSelector) getManager().lookup(
ResourceType.ROLE + "Selector");
ResourceType type = (ResourceType) resourceTypeSelector.select("entry");
String contentSourceUri = "context://sitemap.xmap";
Document doc = docManager.add(factory, type, contentSourceUri, pub,
Publication.AUTHORING_AREA, "en", "xml");
structure.add(PATH, doc);
assertTrue(structure.contains(PATH));
Document linkDoc = structure.getNode(PATH).getLink("en").getDocument();
assertSame(linkDoc, doc);
if (!(structure instanceof DocumentStore)) {
Link link = doc.getLink();
checkSetLabel(link);
}
SiteNode[] nodes = structure.getNodes();
assertTrue(nodes.length > 0);
for (int i = 0; i < nodes.length; i++) {
assertTrue(structure.contains(nodes[i].getPath()));
SiteNode node = structure.getNode(nodes[i].getPath());
assertNotNull(node);
assertEquals(nodes[i], node);
checkLinks(siteManager, node);
}
doc.getLink().delete();
assertFalse(structure.containsByUuid(doc.getUUID(), doc.getLanguage()));
assertFalse(structure.contains(PATH));
assertFalse(structure.contains(PARENT_PATH));
} finally {
if (selector != null) {
if (siteManager != null) {
selector.release(siteManager);