*/
public String list() throws BackupException {
StringBuffer sb = new StringBuffer();
String headings[] = { BACKUP, USER, DATE, FILENAME };
List<Integer> badPropsList = null;
ColumnFormatter cf = null;
boolean itemInRow = false;
TreeSet<Status>statusSet = new TreeSet<Status>(new FileNameComparator());
// If a backup config was not provided then look for all zips
// including those in the backup config directories.
// If a backup config was provided then only look for zips in
// that backup config directory.
findZips(request.backupConfig == null);
badPropsList = new ArrayList<Integer>();
// it is GUARANTEED that the length > 0
for(int i = 0; i < zips.length; i++) {
Status status = new Status();
if (!status.loadProps(zips[i]))
badPropsList.add(new Integer(i));
else {
//XXX: if (request.terse) How indicate no headers?
statusSet.add(status);
itemInRow = true;
}
}
if (itemInRow) {
for (Status status : statusSet) {
if (request.verbose) {
File f = null;
try {
f = new File(status.getBackupPath());
} catch (NullPointerException e) {
}
if (f != null) {
sb.append(status.read(f, request.terse));
sb.append("\n\n");
}
} else {
String filename = status.getFileName();
if (cf == null) {
cf = new ColumnFormatter(headings);
}
if (filename == null)
filename = strings.get("backup-list.unavailable");
cf.addRow(new Object[] {
status.getBackupConfigName(),
status.getUserName(),
status.getTimeStamp(),
filename
});
}
}
}
if (cf != null)
sb.append(cf.toString());
// If no items in the row and we are not in terse mode indicate
// there was nothing to list.
if (!itemInRow && !request.terse)
sb.append("\n" + strings.get("backup-list.nothing"));