Search in sources :

Example 6 with RobustFileWriter

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);
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) BufferedWriter(java.io.BufferedWriter) TimeLog(net.sourceforge.processdash.log.time.TimeLog) TimeLogEntry(net.sourceforge.processdash.log.time.TimeLogEntry) CompletionStatus(net.sourceforge.processdash.tool.export.mgr.CompletionStatus) Iterator(java.util.Iterator) EVTaskList(net.sourceforge.processdash.ev.EVTaskList) RobustFileWriter(net.sourceforge.processdash.util.RobustFileWriter) PrintWriter(java.io.PrintWriter) HashSet(java.util.HashSet)

Example 7 with RobustFileWriter

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;
    }
}
Also used : RobustFileWriter(net.sourceforge.processdash.util.RobustFileWriter) File(java.io.File) IOException(java.io.IOException) BufferedWriter(java.io.BufferedWriter)

Example 8 with RobustFileWriter

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;
}
Also used : RobustFileWriter(net.sourceforge.processdash.util.RobustFileWriter) File(java.io.File) IOException(java.io.IOException) BufferedWriter(java.io.BufferedWriter)

Example 9 with RobustFileWriter

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");
}
Also used : InputStreamReader(java.io.InputStreamReader) TamperDeterrent(net.sourceforge.processdash.security.TamperDeterrent) RobustFileWriter(net.sourceforge.processdash.util.RobustFileWriter) File(java.io.File) BufferedWriter(java.io.BufferedWriter) RobustFileWriter(net.sourceforge.processdash.util.RobustFileWriter) Writer(java.io.Writer) BufferedWriter(java.io.BufferedWriter)

Example 10 with RobustFileWriter

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");
}
Also used : ChangeHistory(teamdash.wbs.ChangeHistory) RobustFileWriter(net.sourceforge.processdash.util.RobustFileWriter) IOException(java.io.IOException) File(java.io.File) BufferedWriter(java.io.BufferedWriter)

Aggregations

RobustFileWriter (net.sourceforge.processdash.util.RobustFileWriter)22 BufferedWriter (java.io.BufferedWriter)17 File (java.io.File)11 IOException (java.io.IOException)11 Writer (java.io.Writer)6 InputStreamReader (java.io.InputStreamReader)2 Iterator (java.util.Iterator)2 BufferedReader (java.io.BufferedReader)1 FileInputStream (java.io.FileInputStream)1 PrintWriter (java.io.PrintWriter)1 Reader (java.io.Reader)1 MalformedURLException (java.net.MalformedURLException)1 PrivilegedAction (java.security.PrivilegedAction)1 Date (java.util.Date)1 Enumeration (java.util.Enumeration)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 DefaultTableColumnModel (javax.swing.table.DefaultTableColumnModel)1