Download Automating Code Build and Deployment for Large
Transcript
* Method to get current release name and filter it to only name
*/
public String getCurrentReleaseName() {
List<String> allNames = getReleaseNames();
String currentReleaseName = “”;
for (int I = 0; I < allNames.size(); i++) {
if (allNames.get(i).contains(“current”)) {
for (char inputChar :
allNames.get(i).replaceAll(“(current)”, “ “).toCharArray()) {
if (inputChar == ‘/’ ||
Character.isDigit(inputChar) || inputChar == ‘(‘
|| inputChar == ‘)’ || inputChar
== ‘?’) {
continue;
}
currentReleaseName += inputChar;
}
return currentReleaseName;
}
}
return null;
}
/**
* Method to get all release names
*/
public List<String> getReleaseNames() {
try {
Document doc = ScraperUtil.getDocument(URL);
NodeList nodeList = doc.getElementsByTagName(“tr”);
List<String> text = new ArrayList<String>();
NodeList tableRow = nodeList.item(0).getChildNodes();
int columnIndex = 0;
for (int I = 7; I < tableRow.getLength(); I += 2) {
Node node = tableRow.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE
&& ((Element)
node).getTagName().equalsIgnoreCase(“th”)) {
// We’ve found a th tag, so check all the
children to see if
// they contain the column text that we’re
searching for
columnIndex++;
String name =
ScraperUtil.extractTextFromChildren(node);
text.add((I – 7) / 2, ScraperUtil.clean(name));
}
}
return text;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
/**
*
*/
public Release getRelease(String releaseEnv, String releaseName) {
try {
Document doc = ScraperUtil.getDocument(URL);
Map<String, Component> compMap =
getComponentsMapFromFirstTable(doc, releaseName, releaseEnv);
scrapeComponents(doc, releaseName, releaseEnv, compMap);
Release release = new Release(releaseName, getComponentList());
return release;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public List<Component> getComponentList() {
List<Component> components = new ArrayList<Component>();
Set<Entry<String, Component>> compSet = compMap.entrySet();
for (Entry<String, Component> entry : compSet) {
components.add(entry.getValue());
49