protected void exportPage(WikiEngine engine, Attachment att) throws IOException, ProviderException { exportPageHeader(att.getName(), att.getWiki(), att.getAuthor(), att.getLastModified(), true); m_out.println(" <sv:property sv:name='" + att.getFileName() + "' sv:type='" + BINARY + "'>"); m_out.print("<sv:value>"); InputStream binary = engine.getAttachmentManager().getAttachmentStream(att); Base64.InputStream base64 = new Base64.InputStream(binary, Base64.ENCODE); FileUtil.copyContents(new InputStreamReader(base64), m_out); binary.close(); m_out.println("</sv:value>"); m_out.println("</sv:property>"); exportPageFooter(); }
protected void exportPage(WikiEngine engine, WikiPage p) throws IOException, ProviderException { String name = p.getName(); String title = name; boolean isAttachment = p instanceof Attachment; title = generateTitle(name, title, isAttachment); exportPageHeader(p.getName(), p.getWiki(), p.getAuthor(), p.getLastModified(), isAttachment); Map<String, Object> attrMap = p.getAttributes(); exportAttributes(attrMap); // // ACLs // Acl acl = p.getAcl(); exportAcl(acl); // // Export page content // exportProperty("wiki:content", engine.getPureText(p), STRING); // // Finally, list attachment. According to JCR rules, these must be last. // /* Collection<Attachment> atts = m_engine.getAttachmentManager().listAttachments( p ); for( Attachment a : atts ) { exportPage( a ); } */ exportPageFooter(); }
protected void export(String dir) throws IOException { System.out.println( "Exporting a FileSystemProvider/RCSFileProvider/VersioningFileProvider compatible repository."); System.out.println( "This version does not export attributes, ACLs or attachments. Please use --properties for that."); File df = new File(dir); File[] pages = df.listFiles( new FilenameFilter() { public boolean accept(File dir, String name) { return name.endsWith(FileSystemProvider.FILE_EXT); } }); exportDocumentHeader(); for (File f : pages) { String pageName = f.getName(); pageName = pageName.replace(".txt", ""); exportPageHeader(pageName, "Main", "TBD", new Date(f.lastModified()), false); // File content FileInputStream in = new FileInputStream(f); exportProperty("wiki:content", FileUtil.readContents(in, "UTF-8"), STRING); in.close(); exportPageFooter(); } exportDocumentFooter(); System.out.println("...done"); }