Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  
  package hudson.plugins.starteam;
  
 
 import java.io.File;
 import java.util.List;
 
 import org.dom4j.Node;
ChangeLogParser implementation for the StarTeam SCM.

Author(s):
Eric D. Broyles
Version:
1.0
 
 public class StarTeamChangeLogParser extends ChangeLogParser {
  
 
   @Override
   public ChangeLogSet<? extends Entryparse(AbstractBuild build,
       File changelogFilethrows IOExceptionSAXException {
     return parse0(buildnew FileInputStream(changelogFile),
         changelogFile.getAbsolutePath());
   }

  
Parses the change log stream and returns a Perforce change log set.

Parameters:
aBuild the build for the change log
aChangeLogStream input stream containing the change log
Returns:
the change log set
 
   public static StarTeamChangeLogSet parse(AbstractBuild aBuild,
       InputStream aChangeLogStreamthrows IOExceptionSAXException {
     return parse0(aBuildaChangeLogStreamnull);
   }
 
   private static final ThreadLocal<SimpleDateFormatTIME_FORMATTER =
       new ThreadLocal<SimpleDateFormat>() {
         @Override
         protected SimpleDateFormat initialValue() {
           return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         };
       };
 
   @SuppressWarnings("unchecked")
   private static StarTeamChangeLogSet parse0(AbstractBuild aBuild,
       InputStream aChangeLogStreamString filePaththrows IOException,
       SAXException {
 
     ArrayList<StarTeamChangeLogEntrychangeLogEntries =
         new ArrayList<StarTeamChangeLogEntry>();
 
     SAXReader reader = new SAXReader();
     Document changeDoc = null;
     StarTeamChangeLogSet changeLogSet =
         new StarTeamChangeLogSet(aBuildchangeLogEntries);
 
     try {
       changeDoc = reader.read(aChangeLogStream);
 
       Node historyNode = changeDoc.selectSingleNode("/changelog");
       if (historyNode == null) {
         return changeLogSet;
       }
 
       List<Nodeentries = historyNode.selectNodes("entry");
       if (entries == null) {
         return changeLogSet;
       }
 
       for (Node node : entries) {
         StarTeamChangeLogEntry change = new StarTeamChangeLogEntry();
 
         if (node.selectSingleNode("fileName") != null) {
           change
               .setFileName(node.selectSingleNode("fileName").getStringValue());
         }
         if (node.selectSingleNode("revisionNumber") != null) {
           change.setRevisionNumber(Integer.parseInt((node
               .selectSingleNode("revisionNumber").getStringValue())));
         }
        if (node.selectSingleNode("date") != null) {
          change.setDate(.get().parse(
              node.selectSingleNode("date").getStringValue()));
        }
        if (node.selectSingleNode("message") != null) {
          change.setMsg(node.selectSingleNode("message").getStringValue());
        }
        if (node.selectSingleNode("user") != null) {
          change.setUsername(node.selectSingleNode("user").getStringValue());
        }
        if (node.selectSingleNode("changeType") != null) {
          change.setChangeType(node.selectSingleNode("changeType")
              .getStringValue());
        }
        change.setParent(changeLogSet); // Assign Parent
        changeLogEntries.add(change);
      }
    } catch (Exception e) {
      throw new IOException("Failed to parse changelog file"
          + (filePath != null ? filePath : "") + ": " + e.getMessage(), e);
    }
    return changeLogSet;
  }
New to GrepCode? Check out our FAQ X