Methods Summary |
---|
private java.lang.String | badStatusFileMessage(java.io.File file)
String msg = StringHelper.get("backup-res.Props.backup.file", file);
msg += "\n";
msg += StringHelper.get("backup-res.CorruptBackupFile.NoStatusFile");
return msg;
|
void | delete()
if(!statusFile.delete())
{
// TBD warning message
statusFile.deleteOnExit();
}
|
java.lang.String | getDomainName()
if(props == null)
return null;
return props.getProperty(Constants.PROPS_DOMAIN_NAME);
|
long | getInternalTimestamp(java.io.File f)open the zip file, parse the status file and return the timestamp
of when it was created.
props = null;
setPropsFromFile(f);
try
{
String s = props.getProperty(Constants.PROPS_TIMESTAMP_MSEC);
return Long.parseLong(s);
}
catch(Exception e)
{
LoggerHelper.warning(badStatusFileMessage(f));
return 0;
}
|
private java.lang.String | propsToString(boolean terse)
final String pre = "backup-res.Props.";
StringBuffer sb = new StringBuffer();
if(terse)
{
sb.append(props.getProperty(Constants.PROPS_BACKUP_FILE));
}
else
{
sb.append(StringHelper.get(pre + Constants.PROPS_DESCRIPTION, props.getProperty(Constants.PROPS_DESCRIPTION)));
sb.append("\n");
sb.append(StringHelper.get(pre + Constants.PROPS_BACKUP_FILE, props.getProperty(Constants.PROPS_BACKUP_FILE)));
sb.append("\n");
sb.append(StringHelper.get(pre + Constants.PROPS_TIMESTAMP_HUMAN, props.getProperty(Constants.PROPS_TIMESTAMP_HUMAN)));
sb.append("\n");
sb.append(StringHelper.get(pre + Constants.PROPS_DOMAINS_DIR, props.getProperty(Constants.PROPS_DOMAINS_DIR)));
sb.append("\n");
sb.append(StringHelper.get(pre + Constants.PROPS_DOMAIN_DIR, props.getProperty(Constants.PROPS_DOMAIN_DIR)));
sb.append("\n");
sb.append(StringHelper.get(pre + Constants.PROPS_DOMAIN_NAME, props.getProperty(Constants.PROPS_DOMAIN_NAME)));
sb.append("\n");
sb.append(StringHelper.get(pre + Constants.PROPS_USER_NAME, props.getProperty(Constants.PROPS_USER_NAME)));
}
return sb.toString();
|
java.lang.String | read(java.io.File file)
return read(file, true);
|
java.lang.String | read(java.io.File file, boolean terse)
props = null;
setPropsFromFile(file);
if(props == null)
{
return badStatusFileMessage(file);
}
return propsToString(terse);
|
private void | readPropertiesFile(java.io.File propsFile)
try
{
BufferedInputStream in = new BufferedInputStream(new FileInputStream(propsFile));
props = new Properties();
props.load(in);
in.close();
}
catch(IOException ioe)
{
props = null;
}
|
private void | setProps()
props.setProperty(Constants.PROPS_USER_NAME, System.getProperty(Constants.PROPS_USER_NAME));
props.setProperty(Constants.PROPS_TIMESTAMP_MSEC, "" + request.timestamp);
props.setProperty(Constants.PROPS_DOMAINS_DIR, FileUtils.safeGetCanonicalPath(request.domainsDir));
props.setProperty(Constants.PROPS_DOMAIN_DIR, FileUtils.safeGetCanonicalPath(request.domainDir));
props.setProperty(Constants.PROPS_BACKUP_FILE, FileUtils.safeGetCanonicalPath(request.backupFile));
props.setProperty(Constants.PROPS_DOMAIN_NAME, request.domainName);
props.setProperty(Constants.PROPS_DESCRIPTION, request.description);
props.setProperty(Constants.PROPS_TIMESTAMP_HUMAN, new Date(request.timestamp).toString());
|
private void | setPropsFromFile(java.io.File file)
props = null;
ZipInputStream zis = null;
if(file.getName().toLowerCase().endsWith(".properties"))
{
readPropertiesFile(file);
// props is now set...
return;
}
try
{
zis = new ZipInputStream(new FileInputStream(file));
ZipEntry ze;
while( (ze = zis.getNextEntry()) != null )
{
if(ze.getName().equals(Constants.PROPS_FILENAME))
{
props = new Properties();
props.load(zis);
break;
}
}
// props may be null
}
catch(Exception e)
{
// overkill...
props = null;
}
finally
{
if(zis != null)
{
try
{
zis.close();
}
catch(Exception e)
{
}
}
}
|
java.lang.String | write(BackupRequest req)
props = new Properties();
request = req;
statusFile = new File(request.domainDir, Constants.PROPS_FILENAME);
try
{
setProps();
FileOutputStream out = new FileOutputStream(statusFile);
props.store(out, Constants.PROPS_HEADER);
return propsToString(false);
}
catch(Exception e)
{
return StringHelper.get("backup-res.CantWriteStatus", statusFile);
}
|