creadur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject svn commit: r1462932 - in /creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles: FileSystem.java Main.java
Date Sun, 31 Mar 2013 11:31:45 GMT
Author: rdonkin
Date: Sun Mar 31 11:31:44 2013
New Revision: 1462932

URL: http://svn.apache.org/r1462932
Log:
Move toward more specific interface

Modified:
    creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/FileSystem.java
    creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/Main.java

Modified: creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/FileSystem.java
URL: http://svn.apache.org/viewvc/creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/FileSystem.java?rev=1462932&r1=1462931&r2=1462932&view=diff
==============================================================================
--- creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/FileSystem.java (original)
+++ creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/FileSystem.java Sun
Mar 31 11:31:44 2013
@@ -32,41 +32,14 @@ public class FileSystem {
         this.filters = new Filters();
     }
 
-    public FileFilter filesOnly() {
-        return this.filters.filesOnly();
+    public List<File> legalDocumentsUndeclaredIn(final File contents) {
+        return collect(contents,
+                this.filters.legalDocumentsUndeclaredIn(contents));
     }
 
-    public FileFilter licensesOnly() {
-        return this.filters.licensesOnly();
-    }
-
-    public FileFilter noticesOnly() {
-        return this.filters.noticesOnly();
-    }
-
-    public FileFilter legalOnly() {
-        return this.filters.legalOnly();
-    }
-
-    public FileFilter licensesDeclaredIn(final File contents) {
-        return this.filters.licensesDeclaredIn(contents);
-
-    }
-
-    public FileFilter noticesDeclaredIn(final File contents) {
-        return this.filters.noticesDeclaredIn(contents);
-    }
-
-    public FileFilter legalDocumentsUndeclaredIn(final File contents) {
-        return this.filters.legalDocumentsUndeclaredIn(contents);
-    }
-
-    public FileFilter archivesInPath(final String repositoryPathNameFilter) {
-        return this.filters.archivesInPath(repositoryPathNameFilter);
-    }
-
-    public FileFilter legalDocumentsDeclaredIn(final File contents) {
-        return this.filters.legalDocumentsDeclaredIn(contents);
+    public List<File> legalDocumentsDeclaredIn(final File contents) {
+        return collect(contents,
+                this.filters.legalDocumentsDeclaredIn(contents));
     }
 
     public List<File> collect(final File dir, final String regex) {
@@ -115,4 +88,29 @@ public class FileSystem {
         final boolean isDirectory = file.isDirectory();
         assert isDirectory : "Not a directory: " + file;
     }
+
+    public List<File> documentsFrom(final File repository) {
+        return collect(repository, this.filters.filesOnly());
+    }
+
+    public List<File> licensesFrom(final File directory) {
+        return collect(directory, this.filters.licensesOnly());
+    }
+
+    public List<File> noticesOnly(final File directory) {
+        return collect(directory, this.filters.noticesOnly());
+    }
+
+    public List<File> licensesDeclaredIn(final File contents) {
+        return collect(contents, this.filters.licensesDeclaredIn(contents));
+    }
+
+    public List<File> noticesDeclaredIn(final File contents) {
+        return collect(contents, this.filters.noticesDeclaredIn(contents));
+    }
+
+    public List<File> archivesInPath(final File file,
+            final String fileRepositoryPathNameFilter) {
+        return collect(file, this.filters.archivesInPath(fileRepositoryPathNameFilter));
+    }
 }

Modified: creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/Main.java
URL: http://svn.apache.org/viewvc/creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/Main.java?rev=1462932&r1=1462931&r2=1462932&view=diff
==============================================================================
--- creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/Main.java (original)
+++ creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/Main.java Sun Mar 31
11:31:44 2013
@@ -121,9 +121,7 @@ public class Main {
 
         prepare();
 
-        final List<File> jars =
-                this.fileSystem.collect(this.repository,
-                        this.fileSystem.filesOnly());
+        final List<File> jars = this.fileSystem.documentsFrom(this.repository);
 
         final List<Archive> archives = new ArrayList<Archive>();
         for (final File file : jars) {
@@ -156,8 +154,7 @@ public class Main {
 
         for (final Archive archive : archives) {
             final List<File> files =
-                    this.fileSystem.collect(contents(archive.getFile()),
-                            this.fileSystem.licensesOnly());
+                    this.fileSystem.licensesFrom(contents(archive.getFile()));
             for (final File file : files) {
                 final License license = new License(this.ioSystem.slurp(file));
 
@@ -205,9 +202,7 @@ public class Main {
                 new HashSet<License>(archive.getLicenses());
 
         final File contents = contents(archive.getFile());
-        final List<File> files =
-                this.fileSystem.collect(contents,
-                        this.fileSystem.licensesDeclaredIn(contents));
+        final List<File> files = this.fileSystem.licensesDeclaredIn(contents);
 
         for (final File file : files) {
 
@@ -244,8 +239,7 @@ public class Main {
 
             final File contents = contents(archive.getFile());
             final List<File> files =
-                    this.fileSystem.collect(contents,
-                            this.fileSystem.noticesDeclaredIn(contents));
+                    this.fileSystem.noticesDeclaredIn(contents);
 
             for (final File file : files) {
 
@@ -280,10 +274,9 @@ public class Main {
         final Map<Notice, Notice> notices = new HashMap<Notice, Notice>();
 
         for (final Archive archive : archives) {
-            final List<File> files =
-                    this.fileSystem.collect(contents(archive.getFile()),
-                            this.fileSystem.noticesOnly());
-            for (final File file : files) {
+            final List<File> noticeDocuments =
+                    this.fileSystem.noticesOnly(contents(archive.getFile()));
+            for (final File file : noticeDocuments) {
                 final Notice notice = new Notice(this.ioSystem.slurp(file));
 
                 Notice existing = notices.get(notice);
@@ -303,24 +296,6 @@ public class Main {
                 .write(new File(this.local, "notices.html"));
     }
 
-    private List<URI> allNoticeFiles() {
-        final List<File> legal =
-                this.fileSystem.collect(this.content,
-                        this.fileSystem.legalOnly());
-        for (final File file : legal) {
-            log.info("Legal " + file);
-        }
-
-        final URI uri = this.local.toURI();
-        final List<URI> uris = new ArrayList<URI>();
-        for (final File file : legal) {
-            final URI full = file.toURI();
-            final URI relativize = uri.relativize(full);
-            uris.add(relativize);
-        }
-        return uris;
-    }
-
     private void prepare() throws URISyntaxException, IOException {
         final Set<File> files = new HashSet<File>();
 
@@ -339,9 +314,8 @@ public class Main {
             final File file =
                     new File(this.configuration.getStagingRepositoryURI());
             final List<File> collect =
-                    this.fileSystem.collect(file, this.fileSystem
-                            .archivesInPath(this.configuration
-                                    .getFileRepositoryPathNameFilter()));
+                    this.fileSystem.archivesInPath(file, this.configuration
+                            .getFileRepositoryPathNameFilter());
 
             for (final File f : collect) {
                 files.add(copyToMirror(f));
@@ -631,9 +605,8 @@ public class Main {
         private Map<URI, URI> mapOther() {
             final File jarContents = contents(this.file);
             final List<File> legal =
-                    Main.this.fileSystem.collect(jarContents,
-                            Main.this.fileSystem
-                                    .legalDocumentsUndeclaredIn(jarContents));
+                    Main.this.fileSystem
+                            .legalDocumentsUndeclaredIn(jarContents);
 
             final Map<URI, URI> map = new LinkedHashMap<URI, URI>();
             for (final File file : legal) {
@@ -649,9 +622,7 @@ public class Main {
         private Map<URI, URI> map() {
             final File jarContents = contents(this.file);
             final List<File> legal =
-                    Main.this.fileSystem.collect(jarContents,
-                            Main.this.fileSystem
-                                    .legalDocumentsDeclaredIn(jarContents));
+                    Main.this.fileSystem.legalDocumentsDeclaredIn(jarContents);
 
             final Map<URI, URI> map = new LinkedHashMap<URI, URI>();
             for (final File file : legal) {



Mime
View raw message