public SerializableResource(Resource resource, List<SerializableResource> ancestors) { this.ancestors = ( ancestors == null ? Arrays.<SerializableResource>asList() : ancestors ) ; this.name = resource.getName(); this.uri = resource.getURI(); }
public static File asFile(Resource resource, String parentPath, String ext) { String childPath = ( resource.hasBreadcrumbs() ? StringUtils.join(resource.getBreadcrumbs(), "/") : "" ) + "/" + resource.getName() + ext; return new File(parentPath, childPath); }
public TreeResource(Resource resource) { this.name = resource.getName(); this.parentName = resource.getParentName(); this.uri = resource.getURI(); }
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; }
protected String entity(Resource resource, Type type) { Page page = new Page(); page.title = resource.getName(); page.text = resource.getContent(); Entity entity = new Entity(); entity.wiki_page = page; switch (type) { case JSON: Gson gson = new Gson(); return gson.toJson(entity); case XML: default: return resource.getContent(); } }
protected String entity(Resource resource, Type type) { Page page = new Page(); page.syntax = ( resource.hasSyntax() ? resource.getSyntax() : "xwiki/2.0"); page.title = resource.getName(); page.content = resource.getContent(); page.parent = resource.getParentName(); switch (type) { case JSON: Gson gson = new Gson(); String json = gson.toJson(page); return json; case XML: page.xmlns = "http://www.xwiki.org"; XStream xstream = new XStream(); xstream.alias("page", Page.class); xstream.useAttributeFor(Page.class, "xmlns"); xstream.aliasField("xmlns", Page.class, "xmlns"); xstream.ignoreUnknownElements(); String xml = xstream.toXML(page); return xml; default: return resource.getContent(); } }