| <?xml version="1.0" encoding="ISO-8859-1"?> |
| |
| <xsp:page language="java" |
| xmlns:xsp="http://apache.org/xsp" |
| xmlns:xsp-request="http://apache.org/xsp/request/2.0"> |
| |
| <xsp:structure> |
| <xsp:include>org.apache.avalon.framework.context.ContextException</xsp:include> |
| <xsp:include>org.apache.avalon.framework.component.ComponentException</xsp:include> |
| <xsp:include>org.apache.cocoon.ProcessingException</xsp:include> |
| <xsp:include>java.net.URL</xsp:include> |
| <xsp:include>java.net.MalformedURLException</xsp:include> |
| <xsp:include>org.apache.cocoon.components.language.markup.xsp.XSPUtil</xsp:include> |
| <xsp:include>org.apache.avalon.framework.context.ContextException</xsp:include> |
| <xsp:include>org.apache.cocoon.components.search.*</xsp:include> |
| <xsp:include>org.apache.lucene.store.Directory</xsp:include> |
| <xsp:include>org.apache.lucene.analysis.Analyzer</xsp:include> |
| <xsp:include>java.util.*</xsp:include> |
| </xsp:structure> |
| |
| <xsp:logic> |
| String base = "docs/xdocs" ; |
| String baseContext = "context://" + base; |
| |
| File []allFiles(File base) { |
| List allFiles = new ArrayList(); |
| |
| try { |
| if (base == null) { |
| base = theBaseDir(); |
| } |
| File []allTheFiles = base.listFiles(); |
| |
| for (int i = 0; i < allTheFiles.length; i++ ) { |
| File f = allTheFiles[i]; |
| if (f.isDirectory()) { |
| File[] allFilesOfDirectory = allFiles( f ); |
| allFiles.addAll( Arrays.asList( allFilesOfDirectory ) ); |
| } else if (f.isFile()) { |
| if (f.canRead() && f.getName().endsWith( ".xml" )) { |
| allFiles.add( f ); |
| } |
| } |
| } |
| } catch (Exception e) { |
| e.printStackTrace(); |
| } |
| return (File[])allFiles.toArray(new File[0]); |
| } |
| |
| File theBaseDir() { |
| File f = null; |
| try { |
| org.apache.excalibur.source.Source source = resolver.resolveURI( baseContext ); |
| String s = source.getURI(); |
| f = new File( new URL(s).getFile() ); |
| } catch (Exception e) { |
| e.printStackTrace(); |
| } |
| return f; |
| } |
| |
| String strippedFileName( File f ) { |
| String sf = f.toString(); |
| int index = sf.indexOf("xdocs"); |
| if (index >= 0) { |
| sf = sf.substring( index + 5 + 1); |
| } |
| sf = sf.replace( '\\', '/' ); |
| return sf; |
| } |
| |
| </xsp:logic> |
| |
| <files> |
| <path><xsp:expr>theBaseDir()</xsp:expr></path> |
| <xsp:logic> |
| File []allFiles = allFiles(null); |
| for (int i = 0; allFiles != null && i < allFiles.length; i++) { |
| File f = allFiles[i]; |
| if (f.isFile()) { |
| <xsp:content> |
| <file> |
| <path><xsp:expr>strippedFileName(f)</xsp:expr></path> |
| <absolutePath><xsp:expr>f.getAbsolutePath()</xsp:expr></absolutePath> |
| </file> |
| </xsp:content> |
| } |
| } |
| </xsp:logic> |
| </files> |
| </xsp:page> |