protected Map<String, Resource> createIndexFromEntity(String rootURI, String entity) { Collection<Page> pages = parse(entity); Map<String, Resource> index = new HashMap<>(); for (Page page : pages) { String parentName = (page.parent != null ? resolveName(page.parent.title) : null); String uri = format(PAGE_URI, rootURI, page.title); Resource resource = new Resource(uri, resolveName(page.title), parentName); index.put(resource.getName(), resource); } return index; }
protected Map<String, Resource> createIndexFromEntity(String rootURI, String entity) { Collection<Page> pages = parse(entity); Map<String, Resource> index = new HashMap<>(); for (Page page : pages) { String parentName = (page.parent != null ? resolveName(page.parent) : null); String uri = format(PAGE_URI, rootURI, page.name); Resource resource = new Resource(uri, resolveName(page.name), parentName); index.put(resource.getName(), resource); } return index; }
private void indexResources() { try { String uri = configurer.getURI(); Map<String, Resource> index = indexer.indexResources(uri); wikiContext.setTreeRoots(treeRoots(treeResources(index))); } catch (Exception e) { List<TreeResource> roots = new ArrayList<TreeResource>(); roots.add(new TreeResource(new Resource("http://wiki", "Wiki"))); wikiContext.setTreeRoots(roots); // Allow for failures in indexing resources } }
private void addPath(String rootURI, String rootPath, String path, String syntax, Map<String, Resource> index) { File file = new File(path); String name = resolveName(fileNameWithoutExt(file)); String parentName = parentName(file, rootPath); String uri = fullPath(rootURI, name); Resource resource = new Resource(uri, name, parentName); resource.setContent(contentOf(file)); if ( isNotBlank(syntax) ){ resource.setSyntax(syntax); } index.put(name, resource); if (parentName != null) { addPath(rootURI, rootPath, file.getParent(), syntax, index); } }
private void addPage(Map<String, Resource> result, String href, String pattern) { Page page = confluence.loadPage(href, true); Resource resource = new Resource(page.getSelfReference(), page.getTitle()); resource.setContent(page.getBody()); if (pattern == null || (pattern != null && Pattern.matches(pattern, page.getTitle()))) { result.put(page.getTitle(), resource); } if (page.hasChildren()) { for (Page child : page.getChildren()) { addPage(result, child.getSelfReference(), pattern); } } }