<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Information Centre &#187; apache</title>
	<atom:link href="http://my.center-of.info/tag/apache/feed/" rel="self" type="application/rss+xml" />
	<link>http://my.center-of.info</link>
	<description>“Wenn etwas schon da war, wie kann man es dann patentieren?” D.E.Knuth, 2002</description>
	<lastBuildDate>Sat, 22 Oct 2011 11:09:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Commons-IO: DirectoryWalker</title>
		<link>http://my.center-of.info/2009/07/19/commons-io-directorywalker/</link>
		<comments>http://my.center-of.info/2009/07/19/commons-io-directorywalker/#comments</comments>
		<pubDate>Sun, 19 Jul 2009 19:43:27 +0000</pubDate>
		<dc:creator>Haf</dc:creator>
				<category><![CDATA[JEE]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[util]]></category>

		<guid isPermaLink="false">http://my.center-of.info/?p=132</guid>
		<description><![CDATA[Commons-IO bzw. allg. Apache Commons ist eine schöne Ansammlung von nützlichen Bibliotheken und Funktionen. Darunter ist auch Commons-IO zu finden. Daraus will ich heute eine spezielle Lösung vorstellen. Hat man folgendes Problem: Möchte man einen Ordner, inklusive dessen Unterordner, nach bestimmten Dateien suchen und dann diese vielleicht nach Last-Modified sortiert, bietet Commons-IO eine Lösung an. [...]]]></description>
			<content:encoded><![CDATA[<p>Commons-IO bzw. allg. <a href="http://commons.apache.org/" target="_blank" title="Apache Commons">Apache Commons</a> ist eine schöne Ansammlung von nützlichen Bibliotheken und Funktionen.<br />
Darunter ist auch Commons-IO zu finden. Daraus will ich heute eine spezielle Lösung vorstellen.<br />
Hat man folgendes Problem:<br />
Möchte man einen Ordner, inklusive dessen Unterordner, nach bestimmten Dateien suchen und dann diese vielleicht nach Last-Modified sortiert, bietet Commons-IO eine Lösung an.<br />
<span id="more-132"></span></p>
<p>Um den/die Ordner durchzulaufen existiert ein <a href="http://commons.apache.org/io/api-release/org/apache/commons/io/DirectoryWalker.html" target="_blank" title="Commons-IO API: DirectoryWalker">DirectoryWalker</a>.<br />
Um den abstrakten DirectoryWalker nutzen zu können könnte man z.B. eine folgende Implementierung nutzen:</p>
<pre class="brush: java">
public class TestDirectoryWalker extends DirectoryWalker {

	public TestDirectoryWalker(IOFileFilter dirFilter, IOFileFilter fileFilter, int depth) {
		super(dirFilter, fileFilter, depth);
	}

        /**
          * This method sets the start directory and starts the DirectoryWalker.
          */
	public List search(File startDir) throws IOException {

		List results = new ArrayList();
		walk(startDir, results);
		return results;
	}

	protected boolean handleDirectory(File directory, int depth, Collection results) {
		// return true, cause every sub directory is allowed
		return true;
	}

	protected void handleFile(File file, int depth, Collection results) {		

                // we want only the files with the name &quot;abc.txt&quot; in the
                // subdirectories. This files will be inserted in the given
                // result collection. This collection is the same as the
                // created List in search(File)
		String filename = file.getName();
		if(&quot;abc.txt&quot;.equalsIgnoreCase(filename))
			results.add(file);
	}
}
</pre>
<p>Wie man sehen kann, kann man innerhalb weniger Zeilen einen DirectoryWalker schreiben, der alle Unterordner durchgeht und alle Dateien mit dem Titel &#8220;abc.txt&#8221; liefert.<br />
Die Nutzung ist genauso simpel:</p>
<pre class="brush: java">
TestDirectoryWalker idw = new TestDirectoryWalker(DirectoryFileFilter.DIRECTORY, FileFilterUtils.suffixFileFilter(&quot;.txt&quot;), 3);

		String startDir = &quot;D:/Temp/.../blub&quot;;
		List files = null;
		try {
                        // search the directory for the wanted files
			files = idw.search(new File(startDir));
			System.out.println(&quot;Files: #&quot; + files.size());

                        // sort the resulting files using the LastModifiedFileComparator
			System.out.println(&quot;first file: &quot; + files.get(0));
			Collections.sort(files, LastModifiedFileComparator.LASTMODIFIED_COMPARATOR);

			System.out.println(&quot;oldest file: &quot; + files.get(0));
		} catch (IOException e) {
			e.printStackTrace();
		}
</pre>
<p>Der Konstruktor TestDirectoryWalker(<a href="http://commons.apache.org/io/api-release/org/apache/commons/io/filefilter/IOFileFilter.html" target="_blank" title="Apache Commons-IO API: IOFileFilter">IOFileFilter</a>, <a href="http://commons.apache.org/io/api-release/org/apache/commons/io/filefilter/IOFileFilter.html" target="_blank" title="Apache Commons-IO API: IOFileFilter">IOFileFilter</a>, int) erwartet zwei Filter, einen für die Ordner und einen für die Dateien. Die <a href="http://commons.apache.org/io/api-release/org/apache/commons/io/filefilter/IOFileFilter.html" target="_blank" title="Apache Commons-IO API: IOFileFilter">Auswahl</a> ist umfangreich, ansonsten kann man auch seinen eigenen schreiben.</p>
<p>Als letztes ist vielleicht noch die Zeile</p>
<pre class="brush: java">
Collections.sort(files, LastModifiedFileComparator.LASTMODIFIED_COMPARATOR);
</pre>
<p>interessant. <a href="http://commons.apache.org/io/api-release/org/apache/commons/io/comparator/LastModifiedFileComparator.html" target="_blank" title="Apache Commons IO API: LastModifiedFileComparator">LastModifiedFileComparator</a> ist wie der Name schon andeutet, eine Klasse welches <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/util/Comparator.html" target="_blank" title="J2SE API: Comparator">Comparator</a> implementiert bzgl. <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/io/File.html#lastModified()" target="_blank" title="J2SE API: File#lastModified()">File.lastModified()</a>. Die Liste mit den gefundenen Dateien wird aufsteigend sortiert.</p>
<p>Innerhalb weniger Minuten kann man verschiedene Ordner nach speziellen Dateien suchen. Dank <a href="http://commons.apache.org/io/" target="_blank" title="Apache Commons IO">Apache Commons IO</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://my.center-of.info/2009/07/19/commons-io-directorywalker/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>WebDav ganz simpel</title>
		<link>http://my.center-of.info/2008/10/28/webdav-ganz-simpel/</link>
		<comments>http://my.center-of.info/2008/10/28/webdav-ganz-simpel/#comments</comments>
		<pubDate>Tue, 28 Oct 2008 18:47:55 +0000</pubDate>
		<dc:creator>Haf</dc:creator>
				<category><![CDATA[DevEnv]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[webdav]]></category>

		<guid isPermaLink="false">http://blog.had493.schokokeks.org/?p=29</guid>
		<description><![CDATA[Ja, WebDav ist leichter zu installieren als man denkt. Wobei installieren hier zu hoch gegriffen ist. Hat man schon ein Apache installiert muss man nur noch ein paar Konfigurationen durchführen und schon funktioniert es &#8211; simple. In Apache benötigt man die Module (siehe httpd.conf): LoadModule dav_module modules/mod_dav.so LoadModule dav_fs_module modules/mod_dav_fs.so Nun könnte man z.B. in [...]]]></description>
			<content:encoded><![CDATA[<p>Ja, WebDav ist leichter zu installieren als man denkt. Wobei installieren hier zu hoch gegriffen ist. Hat man schon ein Apache installiert muss man nur noch ein paar Konfigurationen durchführen und schon funktioniert es &#8211; simple.</p>
<p><span id="more-29"></span></p>
<p>In Apache benötigt man die Module (siehe httpd.conf):</p>
<pre class="brush: php">
LoadModule dav_module modules/mod_dav.so
LoadModule dav_fs_module modules/mod_dav_fs.so
</pre>
<p>Nun könnte man z.B. in einer <a title="Apache2.2: Location-Direktive" href="http://httpd.apache.org/docs/2.2/mod/core.html#location">&lt;Location&gt;</a> oder <a title="Apache2.2: VirtualHost-Direktive" href="http://httpd.apache.org/docs/2.2/mod/core.html#virtualhost">&lt;VirtualHost&gt;</a> folgendes definieren:</p>
<pre class="brush: php">
# WebDav Modul aktivieren
Dav On

# auth
AuthType Digest
AuthName &quot;WebDav Area&quot;
AuthDigestDomain http://webdav.example/
AuthDigestFile /web/auth/.htdigest
Require group webdavGroup
</pre>
<p>. Simple!</p>
<p>Links:</p>
<p>[1] <a title="WebDav" href="http://www.webdav.org/">WebDav.org</a><br />
[2] <a title="Apache2.2: Modul mod_dav" href="http://httpd.apache.org/docs/2.2/mod/mod_dav.html">Apache Module mod_dav</a></p>
]]></content:encoded>
			<wfw:commentRss>http://my.center-of.info/2008/10/28/webdav-ganz-simpel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

