Cleanup/consolidation/expansion of *Utils classes

* IoUtils.java
    remove class that confusingly-overlaps with commons IOUtils; move remaining methods to ArchiveUtils or archive's FileUtils
* ArchiveUtils.java, FileUtils.java
    receive relocated methods; eliminated deprecated or unused methods
* JSONUtils.java
    new class to collect common JSON actions
* Iteratorable.java
    wrap Iterator as Iterable for foreach usage
* (many)
    update to use alternate utils methods
This commit is contained in:
gojomo
2009-11-19 22:39:53 +00:00
parent 300ce15a06
commit e42e2ed7f6
21 changed files with 314 additions and 601 deletions
@@ -35,7 +35,7 @@ import java.util.logging.Logger;
import org.apache.commons.httpclient.Cookie;
import org.archive.spring.ConfigPath;
import org.archive.util.IoUtils;
import org.archive.util.ArchiveUtils;
import org.springframework.context.Lifecycle;
/**
@@ -154,7 +154,7 @@ public abstract class AbstractCookieStorage
} catch (IOException e) {
LOGGER.log(Level.WARNING,e.getMessage(), e);
} finally {
IoUtils.close(raf);
ArchiveUtils.closeQuietly(raf);
}
}
@@ -41,7 +41,6 @@ import org.archive.modules.CrawlURI;
import org.archive.modules.Processor;
import org.archive.util.ArchiveUtils;
import org.archive.util.FileUtils;
import org.archive.util.IoUtils;
import org.archive.util.OneLineSimpleLogger;
import org.archive.util.SURT;
import org.archive.util.bdbje.EnhancedEnvironment;
@@ -301,10 +300,10 @@ public abstract class PersistProcessor extends Processor {
} else {
BufferedReader persistLogReader = null;
if (sourceFile.isFile()) {
persistLogReader = IoUtils.getBufferedReader(sourceFile);
persistLogReader = ArchiveUtils.getBufferedReader(sourceFile);
} else {
URL sourceUrl = new URL(sourcePath);
persistLogReader = IoUtils.getBufferedReader(sourceUrl);
persistLogReader = ArchiveUtils.getBufferedReader(sourceUrl);
}
count = populatePersistEnvFromLog(persistLogReader, historyMap);
}
@@ -50,7 +50,7 @@ import org.archive.io.ReplayInputStream;
import org.archive.modules.CrawlURI;
import org.archive.modules.Processor;
import org.archive.net.UURI;
import org.archive.util.IoUtils;
import org.archive.util.FileUtils;
/**
Processor module that writes the results of successful fetches to
@@ -399,7 +399,7 @@ public class MirrorWriterProcessor extends Processor {
destFile = new File(baseDir + File.separator + mps);
File parent = destFile.getParentFile();
if (null != parent) {
IoUtils.ensureWriteableDirectory(parent);
FileUtils.ensureWriteableDirectory(parent);
}
} else {
URIToFileReturn r = null; // Return from uriToFile().