code for a DirFileSystemProvider:
if a pagename has dots in it, the file will be saved in subdirs
slighly modified from FilesystemProvider
only the diffs are given.
WolfgangIrler --- ....
if a pagename has dots in it, the file will be saved in subdirs
slighly modified from FilesystemProvider
only the diffs are given.
WolfgangIrler --- ....
public class DirFileSystemProvider implements WikiPageProvider { ..... /** * Wolfgang Irler changed this method to cope with dots in pageName * Finds a Wiki page from the page repository. */ protected File findPage( String page ) { String pageDir = null; String thePage = page; int lastDot = thePage.lastIndexOf("."); if ( 0 < lastDot && lastDot < thePage.length() ) { // dot must not be on borders pageDir = thePage.substring(0, lastDot+1).replace('.', '/'); thePage = thePage.substring( lastDot+1 ); return new File( m_pageDirectory + "/" + pageDir, mangleName(thePage)+FILE_EXT ); } else return new File( m_pageDirectory, mangleName(page)+FILE_EXT ); // original return } ///////////Wolfgang added the following /** * @Author: Wolfgang Irler (01/2003) * checks the dir for a page with dots. * SIDE EFFECT: if dir inexistant, creates it * returns true if a new one has been created */ private boolean pageHasDotsAndExists( String page ) { String pageDir = null; String thePage = page; int lastDot = thePage.lastIndexOf("."); if ( 0 < lastDot && lastDot < thePage.length() ) { // dot not on borders pageDir = thePage.substring(0, lastDot+1).replace('.', '/'); thePage = thePage.substring( lastDot+1 ); File dir = new File( m_pageDirectory + "/" + pageDir ); log.info( "++++++++DirFileSystemProvider: new dir = " + dir ); if ( !dir.exists() ) dir.mkdirs(); // THIS IS THE SIDE EFFECT!! return dir.exists(); } return false; } ///////////Wolfgang added the preceeding ..... public void putPageText( WikiPage page, String text ) { ///////////Wolfgang added the following if ( pageHasDotsAndExists( page.getName() ) ){ log.info(" dir for " +page+ " created"); } ///////////Wolfgang added the preceeding File file = findPage( page.getName() ); try { PrintWriter out = new PrintWriter(new OutputStreamWriter( new FileOutputStream( file ), m_encoding )); out.print( text ); out.close(); } catch( IOException e ) { log.error( "Saving failed" ); } } ....
Add new attachment
Only authorized users are allowed to upload new attachments.
«
This particular version was published on 24-Jan-2003 13:40 by 195.191.18.172.