use of net.sourceforge.processdash.util.RobustFileWriter in project processdash by dtuma.
the class TextMetricsFileExporter method run.
public void run() {
try {
outWriter = new RobustFileWriter(dest, "UTF-8");
PrintWriter out = new PrintWriter(new BufferedWriter(outWriter));
// Find and print any applicable task lists.
Iterator i = ctx.getData().getKeys();
Set taskListNames = new HashSet();
String name;
int pos;
while (i.hasNext()) {
name = (String) i.next();
pos = name.indexOf(TASK_ORD_PREF);
if (pos != -1 && Filter.matchesFilter(filter, name))
taskListNames.add(name.substring(pos + TASK_ORD_PREF.length()));
}
i = taskListNames.iterator();
String owner = ProcessDashboard.getOwnerName(ctx.getData());
while (i.hasNext()) {
name = (String) i.next();
EVTaskList tl = EVTaskList.openExisting(name, ctx.getData(), ctx.getHierarchy(), ctx.getCache(), false);
if (tl == null)
continue;
tl.recalc();
String xml = tl.getAsXML(false);
name = exportedScheduleDataName(owner, name);
out.write(name + ",");
out.write(StringData.escapeString(xml));
out.println();
}
ctx.getData().dumpRepository(out, filter, DataRepository.DUMP_STYLE_TEXT);
TimeLog tl = ctx.getTimeLog();
Iterator keys = tl.filter(null, null, null);
while (keys.hasNext()) {
TimeLogEntry tle = (TimeLogEntry) keys.next();
if (Filter.matchesFilter(filter, tle.getPath()))
out.println(toAbbrevString(tle));
}
out.println(DefectXmlConstantsv1.DEFECT_START_TOKEN);
DefectExporterXMLv1 exp = new DefectExporterXMLv1();
exp.dumpDefects(ctx.getHierarchy(), filter, out);
out.close();
outWriter = null;
completionStatus = new CompletionStatus(CompletionStatus.SUCCESS, dest, null);
} catch (Exception ioe) {
completionStatus = new CompletionStatus(CompletionStatus.ERROR, dest, ioe);
System.out.println("IOException: " + ioe);
tryCancel();
}
ctx.getData().gc(filter);
}
use of net.sourceforge.processdash.util.RobustFileWriter in project processdash by dtuma.
the class TeamProject method saveXML.
/** Save an XML file. Return false on error. */
private boolean saveXML(Element xml, File dir, String filename) {
try {
File file = new File(dir, filename);
BufferedWriter out = new BufferedWriter(new RobustFileWriter(file, "utf-8"));
out.write(XMLUtils.getAsText(xml));
out.flush();
out.close();
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
use of net.sourceforge.processdash.util.RobustFileWriter in project processdash by dtuma.
the class TeamProject method saveTeamList.
/** Save the list of team members */
private boolean saveTeamList(File directory) {
try {
// For now, we save the data to two different files:
// "team.xml" and "team2.xml". "team.xml" will be read - and
// possibly overwritten incorrectly - by older versions of the
// TeamTools code. "team2.xml" will be preferred by newer
// versions, and shouldn't get clobbered.
File f = new File(directory, TEAM_LIST_FILENAME2);
RobustFileWriter out = new RobustFileWriter(f, "UTF-8");
BufferedWriter buf = new BufferedWriter(out);
teamList.getAsXML(buf);
buf.flush();
out.close();
f = new File(directory, TEAM_LIST_FILENAME);
out = new RobustFileWriter(f, "UTF-8");
buf = new BufferedWriter(out);
teamList.getAsXML(buf);
buf.flush();
out.close();
} catch (Exception e) {
e.printStackTrace();
return false;
}
return true;
}
use of net.sourceforge.processdash.util.RobustFileWriter in project processdash by dtuma.
the class FilterSignedFiles method filter.
@Override
public Reader filter(RedactFilterData data, String filename, Reader contents) throws IOException {
// see if this is a signed file. If not, return with no changes
TamperDeterrent.FileType t;
if (filename.startsWith("externalresources/") && filename.endsWith("/settings.xml"))
t = TamperDeterrent.FileType.WBS;
else if (SIGNED_FILES.contains(filename))
t = TamperDeterrent.FileType.XML;
else
return contents;
// save the data to a temporary file
File tempFile = TempFileFactory.get().createTempFile("redact", ".tmp");
Writer w = new BufferedWriter(new RobustFileWriter(tempFile, "UTF-8"));
int b;
while ((b = contents.read()) != -1) w.write(b);
w.close();
// sign the data, then read the signed content
TamperDeterrent.getInstance().addThumbprint(tempFile, tempFile, t);
return new InputStreamReader(new TempInputStream(tempFile), "UTF-8");
}
use of net.sourceforge.processdash.util.RobustFileWriter in project processdash by dtuma.
the class WorkflowMappingAltererProjectDir method saveWorkflows.
@Override
public void saveWorkflows(WorkflowWBSModel workflows) throws IOException, LockFailureException {
// save the workflows
RobustFileWriter out = new RobustFileWriter(workflowFile(), "UTF-8");
BufferedWriter buf = new BufferedWriter(out);
workflows.getAsXML(buf);
buf.flush();
out.close();
// add an entry to the change history file
File changeHistoryFile = new File(dir.getDirectory(), TeamProject.CHANGE_HISTORY_FILE);
ChangeHistory changeHistory = new ChangeHistory(changeHistoryFile);
changeHistory.addEntry(userName);
changeHistory.write(changeHistoryFile);
// flush data to the server
if (dir.flushData() == false)
throw new IOException("Unable to save data");
// save a data backup with the new contents
dir.doBackup("saved_mappings");
}
Aggregations