Skip to content
Snippets Groups Projects
Commit ea96b0fb authored by david_williams's avatar david_williams
Browse files

webtools update project clean up

parent 274d0bd8
No related branches found
No related tags found
No related merge requests found
.deployables
bin
package org.eclipse.wtp.releng.webupdatesite;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
public class GenerateMirrorTags {
private static final String QUOTE = "\"";
private static final String ARCHIVE_PATH = "<archive path=";
private static final String SLASH = "/";
private static final String PLUGINS = "plugins";
private static final String FEATURES = "features";
private static final String IGNORE = "/home/data/httpd/download.eclipse.org/";
private static final boolean DEBUG = false;
private static final String urlCONST = " url=\"http://www.eclipse.org/downloads/download.php?r=1&amp;file=/";
private static final String ENDTAG = "/>";
public static void main(String[] args) {
try {
new GenerateMirrorTags().generate();
}
catch (FileNotFoundException e) {
e.printStackTrace();
}
catch (IOException e) {
e.printStackTrace();
}
}
private String currentDirectory;
private String currentType;
private int totalTags;
private void generate() throws IOException {
// read input and create tags
readInput();
System.out.println();
System.out.print("Total Tags: " + totalTags);
}
private void readInput() throws IOException {
String filename = "allUpdates.txt";
File inFile = new File(filename);
FileReader reader = new FileReader(inFile);
BufferedReader buffer = new BufferedReader(reader);
String line = null;
while (buffer.ready()) {
line = buffer.readLine();
parseLine(line);
}
}
private void parseLine(String line) {
if (line == null)
return;
if (line.length() == 0)
return;
if (line.startsWith(SLASH)) {
currentDirectory = getDirectory(line);
currentType = getType(line);
if (DEBUG) {
System.out.println("Directory: " + currentDirectory + " Type: " + currentType);
}
}
else {
if (notInSkipList(line)) {
createTag(currentDirectory, currentType, line);
}
}
}
private boolean notInSkipList(String directory) {
boolean result = false;
if (directory != null && directory.length() > 0) {
if (contains(directory, ".tests.") || contains(directory, "validation.test") || contains(directory, "validation.sample")) {
result = false;
}
else {
result = true;
}
}
return result;
}
private boolean contains(String directory, String string) {
return (-1 < directory.indexOf(string));
}
private void createTag(String directory, String type, String line) {
String tagStart = ARCHIVE_PATH + QUOTE + type + SLASH + line + QUOTE;
String urlAttrib = urlCONST + directory + SLASH + type + SLASH + line + QUOTE + ENDTAG;
System.out.println();
System.out.println("\t" + tagStart);
System.out.println("\t\t" + urlAttrib);
System.out.println();
totalTags++;
}
private String getType(String line) {
String type = null;
if (line.endsWith(PLUGINS + SLASH))
type = PLUGINS;
else if (line.endsWith(FEATURES + SLASH))
type = FEATURES;
return type;
}
private String getDirectory(String line) {
String projectDirectory = null;
int start = 0;
if (line.startsWith(IGNORE)) {
start = IGNORE.length();
}
int end = line.lastIndexOf(SLASH + FEATURES + SLASH);
if (end == -1) {
end = line.lastIndexOf(SLASH + PLUGINS + SLASH);
}
projectDirectory = line.substring(start, end);
return projectDirectory;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment