package org.wyona.yarep.core.impl.fs;
import org.wyona.yarep.core.Path;
import org.wyona.yarep.core.UID;
import org.apache.log4j.Category;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
/**
*@deprecated
*/
public class FileSystemRepositoryWriter extends Writer {
private static Category log = Category.getInstance(FileSystemRepositoryWriter.class);
FileWriter writer;
/**
*
*/
public FileSystemRepositoryWriter(UID uid, Path path, File contentDir) {
try {
File file = new File(contentDir.getAbsolutePath() + File.separator + uid.toString());
//File file = new File(contentDir.getAbsolutePath() + path.toString());
log.debug(file.toString());
File parent = new File(file.getParent());
if (!parent.exists()) {
log.warn("Directory will be created: " + parent);
parent.mkdirs();
}
writer = new FileWriter(file);
} catch (Exception e) {
log.error(e);
}
}
/**
*
*/
public void flush() throws IOException {
writer.flush();
}
/**
*
*/
public void write(char cbuf[], int off, int len) throws IOException {
writer.write(cbuf, off, len);
}
/**
*
*/
public void write(String str) throws IOException {
log.debug(str);
writer.write(str);
}
/**
*
*/
public void close() throws IOException {
log.debug("CLOSE");
writer.close();
}
}