1402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/*******************************************************************************
2402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Copyright (c) 2005, 2006 IBM Corporation and others.
3402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * All rights reserved. This program and the accompanying materials
4402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * are made available under the terms of the Eclipse Public License v1.0
5402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * which accompanies this distribution, and is available at
6402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * http://www.eclipse.org/legal/epl-v10.html
7402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *
8402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Contributors:
9402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *     IBM Corporation - initial API and implementation
10402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *******************************************************************************/
11402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpackage org.eclipse.releng.generators.rss;
12402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
13402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll//TODO: bug - can't run CreateFeed and AddEntry together when debug=2 - file locking problem?
14402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
15402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport java.io.File;
16402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport java.io.FileNotFoundException;
17402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport java.io.FileOutputStream;
18402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport java.io.IOException;
19402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport java.io.OutputStreamWriter;
20402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport java.util.Date;
21402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
22402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport javax.xml.parsers.DocumentBuilder;
23402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport javax.xml.parsers.DocumentBuilderFactory;
24402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport javax.xml.parsers.ParserConfigurationException;
25402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport javax.xml.transform.OutputKeys;
26402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport javax.xml.transform.Transformer;
27402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport javax.xml.transform.TransformerException;
28402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport javax.xml.transform.TransformerFactory;
29402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport javax.xml.transform.dom.DOMSource;
30402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport javax.xml.transform.stream.StreamResult;
31402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
32402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.apache.tools.ant.BuildException;
33402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.apache.tools.ant.Task;
34402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.apache.tools.ant.util.DateUtils;
35402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
36402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.eclipse.releng.util.rss.Messages;
37402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.eclipse.releng.util.rss.RSSFeedUtil;
38402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
39402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.w3c.dom.Document;
40402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.w3c.dom.Element;
41402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.w3c.dom.Node;
42402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.xml.sax.SAXException;
43402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
44402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/**
45402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Parameters:
46402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *   debug      - more output to console - eg., 0|1|2
47402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *
48402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *   file       - path to the XML file that will be created - eg., /path/to/file.to.create.xml
49402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *   project    - project's name, used to label the feed - eg., Eclipse, EMF, UML2
50402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *   branch     - build's branch, eg., 2.2.0
51402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *   buildID    - build's ID, eg., S200605051234
52402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *   feedURL    - URL of the feed where it will be published - eg., http://servername/path/to/feed.xml
53402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *      note that feedURL is not required if the feed already exists, only if a new feed file must be created
54402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *   buildURL   - URL of the build being added to the feed - eg., http://servername/path/to/project/branch/buildID/
55402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *
56402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *   buildAlias - build's alias, eg., 2.2.0RC2
57402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *
58402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *   dependencyURLs   - upstream dependencies, eg., UML2 depends on emf and eclipse, so specify TWO URLs in properties file or ant task
59402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *
60402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *   releaseNotesURL  - URL of the build's release notes page - eg., http://www.eclipse.org/project/news/release-notes.php
61402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *   updateManagerURL - URL of the build's Update Manager site - eg., http://servername/path/to/project/updates/
62402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *   downloadsURL     - URL of the build's downloads - eg., http://servername/path/to/project/downloads/
63402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *
64402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *   jarSigningStatus - code to define jar signing status - eg., one of:
65402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *      NONE (or '')  - no status available or not participating
66402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *      UNSIGNED      - no jar signage available or done yet
67402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *      SIGNREADY     - jars promoted to eclipse.org, ready for signing
68402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *      BUILDREADY    - signed on eclipse.org, ready to be collected and bundled as zips and copied to UM site
69402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *      SIGNED        - signed & bundled on download page and on UM site
70402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *
71402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *   callistoStatus   - code to define Callisto status, eg., one of:
72402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *      NONE (or '')         - not part of Callisto or unknown status
73402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *      BUILDCOMPLETE        - Have you finished your RC1 bits?
74402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *      2006-05-02T20:50:00Z - When do you expect to finish them?
75402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *      TPTP                 - If you're waiting for another project, which one(s)? (TPTP is just an example)
76402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *      UMSITEREADY          - Have you placed those bits in your update site?
77402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *      CALLISTOSITEREADY    - Have you updated the features.xml file in the Callisto CVS directory?
78402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *      COMPLETE             - Are you ready for RC1 to be declared?
79402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *
80402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *   buildType - code to define type of build, eg., one of:
81402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *      N      - Nightly
82402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *      I      - Integration
83402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *      M      - Maintenance
84402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *      S      - Stable (Milestone or Release Candidate)
85402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *      R      - Release
86402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *      MC     - Maintenance-Callisto
87402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *      SC     - Stable-Callisto
88402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *      RC     - Release-Callisto
89402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *
90402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *   Releases           - comma or space-separated list of releases in quints of os,ws,arch,type/name,filename,...
91402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *                      - eg., win32,win,x86,SDK,eclipse-SDK-3.2RC5-win32.zip,linux,gtk,x86_64,SDK,eclipse-SDK-3.2RC5-linux-gtk.tar.gz
92402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *                      - (for examples and definitions of ws, os + arch, see below)
93402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *
94402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *   JUnitTestURL       - URL of the build's JUnit test results - eg., http://servername/path/to/project/branch/buildID/testResults.php
95402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *   performanceTestURL - URL of the build's performance tests - eg., http://servername/path/to/project/branch/buildID/performance/performance.php
96402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *   APITestURL         - URL of the build's API test results - eg., http://servername/path/to/project/branch/buildID/testResults.php
97402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *
98402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *   JUnitTestResults       - comma or space-separated list of test results in quads of os,ws,arch,status,os,ws,status,arch,... - eg., win32,win,x86,PASS,linux,gtk,x86,PASS
99402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *   performanceTestResults - comma or space-separated list of test results in quads of os,ws,arch,status,os,ws,status,arch,... - eg., win32,win,x86_64,PASS,linux,gtk,x86_64,PASS
100402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *   APITestResults         - comma or space-separated list of test results in quads of os,ws,arch,status,os,ws,status,arch,... - eg., win32,win,ppc,PASS,linux,gtk,ppc,PASS
101402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *      ws     - window system - eg., ALL, win32, win64, linux, macos...
102402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *      os     - operating system - eg., ALL, win, gtk, motif, carbon, ...
103402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *      arch   - architecture, eg., ALL, x86, x86_64, ppc, ...
104402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *      status - status code for test results - eg., one of: PASS, PENDING, FAIL, UNKNOWN, SKIPPED
105402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *
106402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @author nickb
107402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *
108402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */
109402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpublic class RSSFeedAddEntryTask extends Task {
110402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
111402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  private int debug = 0;
112402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
113402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  private static final String now = getTimestamp();
114402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
115402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  //$ANALYSIS-IGNORE codereview.java.rules.portability.RulePortabilityLineSeparators
116402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  private static final String NL="\n"; //$NON-NLS-1$
117402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  private static final String NS = ""; //$NON-NLS-1$
118402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  private static final String SEP = "----"; //$NON-NLS-1$
119402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  private static final String SP = " "; //$NON-NLS-1$
120402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
121402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  private static final String splitter = "[,\t " + NL + "]+"; //$NON-NLS-1$ //$NON-NLS-2$
122402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
123402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  //required fields
124402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  private File file;
125402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  private String project;
126402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  private String branch;
127402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  private String buildID;
128402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  private String feedURL;
129402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  private String buildURL;
130402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
131402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  //optional
132402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  private String buildAlias;
133402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
134402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  //optional
135402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  private String[] dependencyURLs = new String[] {};
136402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
137402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  //optional
138402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  private String releaseNotesURL;
139402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  private String updateManagerURL;
140402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  private String downloadsURL;
141402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  private String jarSigningStatus;
142402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  private String callistoStatus;
143402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  private String buildType;
144402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
145402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  //optional
146402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  private String[] releases = new String[] {};
147402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
148402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  //optional
149402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  private String JUnitTestURL;
150402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  private String performanceTestURL;
151402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  private String APITestURL;
152402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  private String[] JUnitTestResults;
153402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  private String[] performanceTestResults;
154402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  private String[] APITestResults;
155402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
156402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  //optional
157402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  public void setDebug(int debug) { this.debug = debug; }
158402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
159402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  //required fields
160402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  public void setFile(String file) {
161402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    if (isNullString(file))
162402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    { System.err.println(Messages.getString("RSSFeedCommon.FileError")); }  //$NON-NLS-1$
163402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    else
164402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    { this.file = new File(file); }
165402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  }
166402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  public void setProject(String project) {
167402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    if (isNullString(project))
168402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    { System.err.println(Messages.getString("RSSFeedCommon.ProjectError")); }  //$NON-NLS-1$
169402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    else
170402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    { this.project = project; }
171402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  }
172402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  public void setBranch(String branch) {
173402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    if (isNullString(branch))
174402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    { System.err.println(Messages.getString("RSSFeedAddEntryTask.BranchError")); }  //$NON-NLS-1$
175402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    else
176402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    { this.branch = branch; }
177402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  }
178402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  public void setBuildID(String buildID) {
179402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    if (isNullString(buildID))
180402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    { System.err.println(Messages.getString("RSSFeedAddEntryTask.BuildIDError")); }  //$NON-NLS-1$
181402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    else
182402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    { this.buildID = buildID; }
183402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  }
184402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  public void setFeedURL(String feedURL) {
185402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    if (isNullString(feedURL))
186402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    { System.err.println(Messages.getString("RSSFeedCommon.FeedURLError")); }  //$NON-NLS-1$
187402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    else
188402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    { this.feedURL = feedURL; }
189402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  }
190402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  public void setBuildURL(String buildURL) {
191402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    if (isNullString(buildURL))
192402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    { System.err.println(Messages.getString("RSSFeedAddEntryTask.BuildURLError")); }  //$NON-NLS-1$
193402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    else
194402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    { this.buildURL = buildURL; }
195402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  }
196402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
197402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  //optional: alias is usually something like "3.2.0M6"
198402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  public void setBuildAlias(String buildAlias) { this.buildAlias = buildAlias; }
199402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
200402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  //optional: upstream dependencies, eg., UML2 depends on emf and eclipse, so specify TWO URLs in properties file or ant task
201402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  public void setDependencyURLs(String dependencyURLs) { if (!isNullString(dependencyURLs)) { this.dependencyURLs = dependencyURLs.split(splitter); } }
202402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
203402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  //optional: define releases available in this build for a series of operating systems, windowing systems, and type
204402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  public void setReleases(String releases) { if (!isNullString(releases)) { this.releases = releases.split(splitter); } }
205402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
206402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  //optional: informational links to release notes, downloads, update manager
207402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  public void setReleaseNotesURL(String releaseNotesURL) { this.releaseNotesURL = releaseNotesURL; }
208402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  public void setUpdateManagerURL(String updateManagerURL) { this.updateManagerURL = updateManagerURL; }
209402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  public void setDownloadsURL(String downloadsURL) { this.downloadsURL = downloadsURL; }
210402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  public void setJarSigningStatus(String jarSigningStatus) { this.jarSigningStatus = jarSigningStatus; }
211402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  public void setCallistoStatus(String callistoStatus) { this.callistoStatus = callistoStatus; }
212402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  public void setBuildType(String buildType) {
213402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    if (!isNullString(buildType))
214402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    {
215402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      this.buildType = buildType;
216402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    }
217402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    else
218402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    {
219402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      this.buildType = buildID.replaceAll("[^NIMSR]", NS); //$NON-NLS-1$
220402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      if (this.buildType.length()>1)
221402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      {
222402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll        this.buildType=this.buildType.substring(0, 1);
223402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      }
224402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    }
225402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
226402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  }
227402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
228402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  //optional: test URLs and results
229402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  public void setJUnitTestURL(String JUnitTestURL) { this.JUnitTestURL = JUnitTestURL; }
230402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  public void setPerformanceTestURL(String performanceTestURL) { this.performanceTestURL = performanceTestURL; }
231402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  public void setAPITestURL(String APITestURL) { this.APITestURL = APITestURL; }
232402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  public void setJUnitTestResults(String JUnitTestResults) { if (!isNullString(JUnitTestResults)) { this.JUnitTestResults = JUnitTestResults.split(splitter); } }
233402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  public void setPerformanceTestResults(String performanceTestResults) { if (!isNullString(performanceTestResults)) { this.performanceTestResults = performanceTestResults.split(splitter); } }
234402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  public void setAPITestResults(String APITestResults) { if (!isNullString(APITestResults)) { this.APITestResults = APITestResults.split(splitter); } }
235402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
236402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  // The method executing the task
237402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  public void execute() throws BuildException {
238402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    if (debug>0) {
239402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      System.out.println(Messages.getString("RSSFeedAddEntryTask.AddingEntryTo") + project + SP + Messages.getString("RSSFeedCommon.RSSFeedFile") + SP + file.toString() + ", " + Messages.getString("RSSFeedCommon.ToBePublishedAt") + feedURL); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
240402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    }
241402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    updateFeedXML(file); // load previous
242402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  }
243402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
244402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  //$ANALYSIS-IGNORE codereview.java.rules.exceptions.RuleExceptionsSpecificExceptions
245402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  private void updateFeedXML(File file){
246402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    if (!file.exists()) {
247402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      System.out.println(Messages.getString("RSSFeedCommon.RSSFeedFile") + SP + file.toString() + SP + Messages.getString("RSSFeedAddEntryTask.DoesNotExist")); //$NON-NLS-1$ //$NON-NLS-2$
248402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      RSSFeedCreateFeedTask creator=new RSSFeedCreateFeedTask();
249402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      creator.setFile(file.toString());
250402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      creator.setFeedURL(feedURL);
251402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      creator.setProject(project);
252402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      creator.setDebug(debug);
253402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      creator.execute();
254402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    }
255402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    DocumentBuilderFactory documentBuilderFactory=DocumentBuilderFactory.newInstance();
256402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    documentBuilderFactory.setNamespaceAware(true);
257402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    DocumentBuilder documentBuilder=null;
258402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    try {
259402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      documentBuilder=documentBuilderFactory.newDocumentBuilder();
260402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    }
261402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    catch (ParserConfigurationException e) {
262402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      e.printStackTrace();
263402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    }
264402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    Document document=null;
265402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    try {
266402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      document=documentBuilder.parse(file);
267402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    }
268402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    catch (SAXException e) {
269402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      e.printStackTrace();
270402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    }
271402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    catch (IOException e) {
272402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      e.printStackTrace();
273402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    }
274402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
275402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    Transformer transformer = null;
276402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    try {
277402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      transformer = createTransformer("UTF-8"); //$NON-NLS-1$
278402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    } catch (TransformerException e) {
279402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      e.printStackTrace();
280402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    }
281402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
282402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    Element element=document.getDocumentElement();
283402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    for (Node child=element.getFirstChild(); child != null; child=child.getNextSibling()) {
284402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      if ("updated".equals(child.getLocalName())) { //$NON-NLS-1$
285402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll        if (debug > 0) {
286402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll          System.out.println(Messages.getString("RSSFeedCommon.Set") + " <" + child.getLocalName()+ ">"+ now+ "</"+ child.getLocalName()+ ">"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
287402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll        }
288402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll        ((Element)child).setTextContent(now);
289402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      }
290402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      else if ("id".equals(child.getLocalName())) { //$NON-NLS-1$
291402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll        Node newNode=createEntry(document);
292402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll        if (debug > 0) {
293402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll          System.out.println(Messages.getString("RSSFeedAddEntryTask.AttachNew") + " <entry/>"); //$NON-NLS-1$ //$NON-NLS-2$
294402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll        }
295402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll        try {
296402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll          if (debug > 0) {
297402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll            System.out.println(SEP); //$NON-NLS-1$
298402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll            transformer.transform(new DOMSource(newNode),new StreamResult(System.out));
299402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll            System.out.println(SEP); //$NON-NLS-1$
300402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll          }
301402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll        }
302402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll        catch (TransformerException e) {
303402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll          e.printStackTrace();
304402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll        }
305402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll        Node refNode=child.getNextSibling();
306402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll        element.insertBefore(document.createTextNode(NL + "  "),refNode); //$NON-NLS-1$
307402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll        element.insertBefore(newNode,refNode);
308402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll        break;
309402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      }
310402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    }
311402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    try {
312402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      transformer.transform(new DOMSource(document),new StreamResult(new OutputStreamWriter(new FileOutputStream(file))));
313402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      if (debug > 1) {
314402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll        System.out.println(SEP); //$NON-NLS-1$
315402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll        transformer.transform(new DOMSource(document),new StreamResult(System.out));
316402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll        System.out.println(SEP); //$NON-NLS-1$
317402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      }
318402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    }
319402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    catch (FileNotFoundException e) {
320402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      e.printStackTrace();
321402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    }
322402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    catch (TransformerException e) {
323402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      e.printStackTrace();
324402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    }
325402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  }
326402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
327402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
328402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  private Element createEntry(Document document) {
329402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
330402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll//  <entry>
331402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    Element entry =  document.createElement("entry"); //$NON-NLS-1$
332402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
333402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    String[] txt = { NL + "  ", NL + "    ", NL + "      ", NL + "        ", NL + "          " , NL + "            " }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
334402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    Element elem = null;
335402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
336402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    String projectVersionString = project + SP + (!isNullString(buildAlias)?  //$NON-NLS-1$
337402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      (buildAlias.startsWith(branch) ?
338402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll        buildAlias + " (" + buildID + ")" :                   // 2.2.0RC2 (S200605051234) //$NON-NLS-1$ //$NON-NLS-2$
339402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll          buildAlias + " (" + branch + "." + buildID + ")") : // Foobar (2.2.0.S200605051234)  //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
340402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll            branch + SP + buildID);                                // 2.2.0.S200605051234 //$NON-NLS-1$
341402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
342402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    doVarSubs();
343402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
344402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll//  <title>[announce] " + project + SP + branch + SP + buildID + " is available</title>
345402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    elem = document.createElement("title"); //$NON-NLS-1$
346402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    elem.setTextContent(Messages.getString("RSSFeedAddEntryTask.AnnouncePrefix") + projectVersionString + SP + Messages.getString("RSSFeedAddEntryTask.IsAvailable")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
347402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    attachNode(document, entry, elem, txt[1]);
348402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
349402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll//  <link href=\"" + buildURL + "\"/>
350402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    elem = document.createElement("link"); //$NON-NLS-1$
351402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    elem.setAttribute("href", !isNullString(buildURL) ? buildURL : projectVersionString); //$NON-NLS-1$
352402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    attachNode(document, entry, elem, txt[1]);
353402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
354402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll//  <id>" + buildURL + "</id>
355402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    elem = document.createElement("id"); //$NON-NLS-1$
356402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    elem.setTextContent(!isNullString(buildURL) ? buildURL : projectVersionString);
357402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    attachNode(document, entry, elem, txt[1]);
358402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
359402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll//  <updated>" + getTimestamp() + "</updated>
360402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    elem = document.createElement("updated"); //$NON-NLS-1$
361402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    elem.setTextContent(now);
362402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    attachNode(document, entry, elem, txt[1]);
363402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
364402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll//  <summary>
365402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    Element summary = document.createElement("summary"); //$NON-NLS-1$
366402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    attachNode(document, entry, summary, txt[1]);
367402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
368402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll//  <build callisto="" jars="" type="" href="" xmlns="http://www.eclipse.org/2006/BuildFeed">
369402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    Element build = document.createElement("build"); //$NON-NLS-1$
370402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    build.setAttribute("jars", jarSigningStatus); //$NON-NLS-1$
371402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    build.setAttribute("callisto", callistoStatus); //$NON-NLS-1$
372402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    build.setAttribute("type", buildType); //$NON-NLS-1$
373402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    build.setAttribute("xmlns", "http://www.eclipse.org/2006/BuildFeed"); //$NON-NLS-1$ //$NON-NLS-2$
374402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    if (!isNullString(buildURL)) {
375402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      build.setAttribute("href",buildURL); //$NON-NLS-1$
376402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    }
377402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    attachNode(document, summary, build, txt[2]);
378402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
379402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll//  <update>" + usiteURL + "</update>
380402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    if (!isNullString(updateManagerURL)) {
381402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      elem = document.createElement("update"); //$NON-NLS-1$
382402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      elem.setTextContent(updateManagerURL);
383402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      attachNode(document, build, elem, txt[3]);
384402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    }
385402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
386402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll//  <downloads>" + dropsURL + "</downloads>
387402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    if (!isNullString(downloadsURL)) {
388402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      elem = document.createElement("downloads"); //$NON-NLS-1$
389402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      elem.setTextContent(downloadsURL);
390402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      attachNode(document, build, elem, txt[3]);
391402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    }
392402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
393402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll//  <releasenotes>" + releaseNotesURL + "</releasenotes>
394402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    if (!isNullString(releaseNotesURL)) {
395402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      elem = document.createElement("releasenotes"); //$NON-NLS-1$
396402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      elem.setTextContent(releaseNotesURL);
397402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      attachNode(document, build, elem, txt[3]);
398402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    }
399402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
400402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll//  <releases>
401402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll//    <release os="" ws="" type=""> + filename + </release>
402402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    if (releases!=null && releases.length>0) {
403402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      if (releases.length % 5 != 0) {
404402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll        System.err.println(Messages.getString("RSSFeedAddEntryTask.WrongNumberOfVariables") + SP + Messages.getString("RSSFeedAddEntryTask.MustBeMultipleOf5") + SP + Messages.getString("RSSFeedAddEntryTask.InProperty") + SP + "releases"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
405402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      }
406402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      Element releasesElem = document.createElement("releases"); //$NON-NLS-1$
407402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      for (int i = 0; i < releases.length; i+=5)
408402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      {
409402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll        Element release = document.createElement("release"); //$NON-NLS-1$
410402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll        release.setAttribute("os", releases[i]); //$NON-NLS-1$
411402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll        release.setAttribute("ws", releases[i+1]); //$NON-NLS-1$
412402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll        release.setAttribute("arch", releases[i+2]); //$NON-NLS-1$
413402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll        release.setAttribute("type", releases[i+3]); //$NON-NLS-1$
414402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll        release.setTextContent(varSub(releases[i+4]));
415402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll        attachNode(document, releasesElem, release, txt[4]);
416402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      }
417402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      attachNode(document, build, releasesElem, txt[3]);
418402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    }
419402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
420402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll//  <tests>
421402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    Element tests = document.createElement("tests"); //$NON-NLS-1$
422402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
423402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll//    <test type=\"junit\" href=\"" + JUnitTestURL + "\"/>
424402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    if (!isNullString(JUnitTestURL)) {
425402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      Element test = document.createElement("test"); //$NON-NLS-1$
426402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      test.setAttribute("type", "junit"); //$NON-NLS-1$ //$NON-NLS-2$
427402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      test.setAttribute("href", JUnitTestURL); //$NON-NLS-1$
428402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      if (JUnitTestResults!=null && JUnitTestResults.length>0) {
429402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll        if (JUnitTestResults.length % 4 != 0) {
430402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll          System.err.println(Messages.getString("RSSFeedAddEntryTask.WrongNumberOfVariables") + SP + Messages.getString("RSSFeedAddEntryTask.MustBeMultipleOf4") + SP + Messages.getString("RSSFeedAddEntryTask.InProperty") + SP + "JUnitTestResults"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
431402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll        }
432402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll        for (int i = 0; i < JUnitTestResults.length; i+=4)
433402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll        {
434402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll          Element result = document.createElement("result"); //$NON-NLS-1$
435402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll          result.setAttribute("os", JUnitTestResults[i]); //$NON-NLS-1$
436402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll          result.setAttribute("ws", JUnitTestResults[i+1]); //$NON-NLS-1$
437402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll          result.setAttribute("arch", JUnitTestResults[i+2]); //$NON-NLS-1$
438402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll          result.setTextContent(JUnitTestResults[i+3]);
439402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll          attachNode(document, test, result, txt[5]);
440402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll        }
441402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll        // extra space to close containing tag
442402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll        elem.appendChild(document.createTextNode(txt[4]));
443402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      }
444402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      attachNode(document, tests, test, txt[4]);
445402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    }
446402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
447402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll//    <test type=\"performance\" href=\"" + performanceTestURL + "\"/>
448402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    if (!isNullString(performanceTestURL)) {
449402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      Element test = document.createElement("test"); //$NON-NLS-1$
450402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      test.setAttribute("type", "performance"); //$NON-NLS-1$ //$NON-NLS-2$
451402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      test.setAttribute("href", performanceTestURL); //$NON-NLS-1$
452402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      if (performanceTestResults!=null && performanceTestResults.length>0) {
453402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll        if (performanceTestResults.length % 4 != 0) {
454402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll          System.err.println(Messages.getString("RSSFeedAddEntryTask.WrongNumberOfVariables") + SP + Messages.getString("RSSFeedAddEntryTask.MustBeMultipleOf4") + SP + Messages.getString("RSSFeedAddEntryTask.InProperty") + SP + "performanceTestResults"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
455402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll        }
456402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll        for (int i = 0; i < performanceTestResults.length; i+=4)
457402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll        {
458402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll          Element result = document.createElement("result"); //$NON-NLS-1$
459402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll          result.setAttribute("os", performanceTestResults[i]); //$NON-NLS-1$
460402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll          result.setAttribute("ws", performanceTestResults[i+1]); //$NON-NLS-1$
461402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll          result.setAttribute("arch", performanceTestResults[i+2]); //$NON-NLS-1$
462402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll          result.setTextContent(performanceTestResults[i+3]);
463402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll          attachNode(document, test, result, txt[5]);
464402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll        }
465402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll        // extra space to close containing tag
466402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll        test.appendChild(document.createTextNode(txt[4]));
467402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      }
468402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      attachNode(document, tests, test, txt[4]);
469402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    }
470402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
471402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll//    <test type=\"performance\" href=\"" + performanceTestURL + "\"/>
472402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    if (!isNullString(APITestURL)) {
473402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      Element test = document.createElement("test"); //$NON-NLS-1$
474402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      test.setAttribute("type", "api"); //$NON-NLS-1$ //$NON-NLS-2$
475402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      test.setAttribute("href", APITestURL); //$NON-NLS-1$
476402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      if (APITestResults!=null && APITestResults.length>0) {
477402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll        if (APITestResults.length % 4 != 0) {
478402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll          System.err.println(Messages.getString("RSSFeedAddEntryTask.WrongNumberOfVariables") + SP + Messages.getString("RSSFeedAddEntryTask.MustBeMultipleOf4") + SP + Messages.getString("RSSFeedAddEntryTask.InProperty") + SP + "APITestResults"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
479402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll        }
480402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll        for (int i = 0; i < APITestResults.length; i+=4)
481402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll        {
482402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll          Element result = document.createElement("result"); //$NON-NLS-1$
483402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll          result.setAttribute("os", APITestResults[i]); //$NON-NLS-1$
484402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll          result.setAttribute("ws", APITestResults[i+1]); //$NON-NLS-1$
485402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll          result.setAttribute("arch", APITestResults[i+2]); //$NON-NLS-1$
486402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll          result.setTextContent(APITestResults[i+3]);
487402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll          attachNode(document, tests, result, txt[5]);
488402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll        }
489402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll        // extra space to close containing tag
490402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll        test.appendChild(document.createTextNode(txt[4]));
491402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      }
492402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      attachNode(document, tests, test, txt[4]);
493402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    }
494402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
495402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    attachNode(document, build, tests, txt[3]);
496402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
497402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    if (dependencyURLs!=null && dependencyURLs.length>0) {
498402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  //  <dependencies>
499402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  //    <dependency>" + dependencyURL + "</dependency>
500402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      Element dependencies = document.createElement("dependencies"); //$NON-NLS-1$
501402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      for (int i = 0; i < dependencyURLs.length; i++)
502402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      {
503402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll        elem = document.createElement("dependency"); //$NON-NLS-1$
504402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll        elem.setTextContent(dependencyURLs[i]);
505402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll        attachNode(document, dependencies, elem, txt[4]);
506402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      }
507402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      attachNode(document, build, dependencies, txt[3]);
508402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    }
509402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
510402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    return entry;
511402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  }
512402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
513402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  //$ANALYSIS-IGNORE codereview.java.rules.exceptions.RuleExceptionsSpecificExceptions
514402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  private void attachNode(Document document,Element entry,Element elem,String txt){
515402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    entry.appendChild(document.createTextNode(txt));
516402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    entry.appendChild(elem);
517402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  }
518402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
519402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  private static String getTimestamp() { // eg., 2006-04-10T20:40:08Z
520402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    return DateUtils.format(new Date(), DateUtils.ISO8601_DATETIME_PATTERN) + "Z";  //$NON-NLS-1$
521402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  }
522402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
523402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  private void doVarSubs()
524402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  {
525402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    feedURL = varSub(feedURL);
526402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    buildURL = varSub(buildURL);
527402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
528402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    releaseNotesURL = varSub(releaseNotesURL);
529402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    updateManagerURL = varSub(updateManagerURL);
530402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    downloadsURL = varSub(downloadsURL);
531402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
532402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    JUnitTestURL = varSub(JUnitTestURL);
533402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    performanceTestURL = varSub(performanceTestURL);
534402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    APITestURL = varSub(APITestURL);
535402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  }
536402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
537402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  public static Transformer createTransformer(String encoding) throws TransformerException
538402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  {
539402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    TransformerFactory transformerFactory = TransformerFactory.newInstance();
540402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
541402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    try
542402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    {
543402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      transformerFactory.setAttribute("indent-number", new Integer(2)); //$NON-NLS-1$
544402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    }
545402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    catch (IllegalArgumentException exception)
546402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    {
547402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    }
548402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
549402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    Transformer transformer = transformerFactory.newTransformer();
550402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
551402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
552402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
553402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
554402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    // Unless a width is set, there will be only line breaks but no indentation.
555402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    // The IBM JDK and the Sun JDK don't agree on the property name,
556402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    // so we set them both.
557402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    //
558402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    transformer.setOutputProperty("{http://xml.apache.org/xalan}indent-amount", "2"); //$NON-NLS-1$ //$NON-NLS-2$
559402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); //$NON-NLS-1$ //$NON-NLS-2$
560402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    if (encoding != null)
561402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    {
562402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      transformer.setOutputProperty(OutputKeys.ENCODING, encoding);
563402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    }
564402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    return transformer;
565402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  }
566402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
567402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  /*
568402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll   * variable substitution in URLs - eg., replace %%branch%% and %%buildID%% in buildURL
569402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll   */
570402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  private String varSub(String urlstring)
571402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  {
572402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    if (!isNullString(urlstring) && urlstring.indexOf("%%")>=0) //$NON-NLS-1$
573402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    {
574402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll      return urlstring.replaceAll(Messages.getString("RSSFeedAddEntryTask.BranchKeyword"), branch).replaceAll(Messages.getString("RSSFeedAddEntryTask.BuildIDKeyword"), buildID).replaceAll(Messages.getString("RSSFeedAddEntryTask.BuildAliasKeyword"), buildAlias); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
575402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    }
576402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    return urlstring;
577402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  }
578402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
579402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  private static boolean isNullString(String str)
580402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  {
581402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    return RSSFeedUtil.isNullString(str);
582402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  }
583402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
584402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll}