
hudson.plugins.starteam.StarTeamChangeLogBuilder Maven / Gradle / Ivy
package hudson.plugins.starteam;
import hudson.Util;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.nio.charset.Charset;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Collection;
import java.util.GregorianCalendar;
import com.starbase.starteam.File;
/**
* Builds changelog.xml for {@link StarTeamSCM}.
*
* Remove use of deprecated classes.
*
* @author Eric D. Broyles
* @author Steve Favez
*/
public final class StarTeamChangeLogBuilder {
/**
* Stores the history objects to the output stream as xml.
*
* Current version supports a format like the following:
*
*
* <?xml version='1.0' encoding='UTF-8'?>
* <changelog>
* <entry>
* <revisionNumber>73</revisionNumber>
* <date>2008-06-23 09:46:27</date>
* <message>Checkin message</message>
* <user>Author Name</user>
* </entry>
* </changelog>
*
*
*
*
*
* @param aOutputStream
* the stream to write to
* @param aChanges
* the history objects to store
* @param aConnection
* the connection to the StarTeam Server (required to determine
* the name of the user who made changes)
* @throws IOException
*
*/
public static boolean writeChangeLog(OutputStream aOutputStream,
Collection aChanges, StarTeamConnection aConnection)
throws IOException {
GregorianCalendar cal = (GregorianCalendar) Calendar.getInstance();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd' 'HH:mm:ss");
dateFormat.setCalendar(cal);
dateFormat.setLenient(false);
OutputStreamWriter writer = new OutputStreamWriter(aOutputStream,
Charset.forName("UTF-8"));
PrintWriter printwriter = new PrintWriter( writer ) ;
printwriter.println("");
printwriter.println("");
for (File change : aChanges) {
printwriter.println("\t");
printwriter.println("\t\t" + change.getName() + " ");
printwriter.println("\t\t" + change.getContentVersion()
+ " ");
java.util.Date aDate = change.getModifiedTime().createDate();
printwriter.println("\t\t"
+ Util.xmlEscape(dateFormat.format(aDate)) + " ");
printwriter.println("\t\t"
+ Util.xmlEscape(change.getComment()) + " ");
printwriter.println("\t\t"
+ aConnection.getUsername(change.getModifiedBy())
+ " ");
printwriter.println("\t ");
}
printwriter.println(" ");
printwriter.close();
return true;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy