String subDirName = subDirProp.getStringValue();
if (subDirName == null || subDirName.trim().length() < 1)
throw new Exception("updateManualTransfer: the mandatory property '" + ReplicationConstants.INITIAL_DATA_ID + "' was empty");
String initialFilesLocation = this.info.get("replication.initialFilesLocation", "${user.home}/tmp");
XmlScriptParser xmlScriptParser = new XmlScriptParser();
xmlScriptParser.init(new Global(), null, null);
DbWriter dbWriter = (DbWriter)this.info.getObject("org.xmlBlaster.contrib.dbwriter.DbWriter");
if (dbWriter == null)
throw new Exception("The DbWriter is not set in the info");
File dirWhereToStore = ReplManagerPlugin.checkExistance(initialFilesLocation);
File subDir = new File(dirWhereToStore, subDirName);
if (!subDir.exists()) {
String txt = "directory '" + subDir.getAbsolutePath() + "' does not exist";
log.severe(txt);
throw new Exception(txt);
}
if (!subDir.isDirectory()) {
String txt = "file '" + subDir.getAbsolutePath() + "' is not a directory";
log.severe(txt);
throw new Exception(txt);
}
String[] files = subDir.list();
log.info("retreiving '" + files.length + "' manual transferred data files from directory '" + subDir.getAbsolutePath() + "'");
// alphabetical order guarantees correct sequence.
TreeSet set = new TreeSet();
for (int i=0; i < files.length; i++)
set.add(files[i]);
files = (String[])set.toArray(new String[set.size()]);
for (int i=0; i < files.length; i++) {
File file = new File(subDir, files[i]);
if (!file.exists())
throw new Exception("The entry nr. '" + i + "': file '" + file.getAbsolutePath() + "' does not exist");
if (!file.isFile())
throw new Exception("The entry nr. '" + i + "': file '" + file.getAbsolutePath() + "' is not a file");
FileInputStream fis = new FileInputStream(file);
MsgInfo[] msgInfos = xmlScriptParser.parse(fis);
log.info("Processing entry " + i + " of " + files.length + ": '" + file.getAbsoluteFile() + "' which has " + msgInfos.length + "' msg");
for (int j=0; j < msgInfos.length; j++) {
MsgUnitRaw[] messages = msgInfos[j].getMessageArr();
for (int k=0; k < messages.length; k++) {
MsgUnit msgUnit = new MsgUnit(new Global(), messages[k].getKey(), messages[k].getContent(), messages[k].getQos());