This commit is contained in:
Nunzio Andrea Galante 2017-09-01 15:24:42 +00:00
parent 87dbf00750
commit 1d285e5972
1 changed files with 17 additions and 9 deletions

View File

@ -19,8 +19,11 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.sql.Timestamp;
import java.util.*;
import javax.ws.rs.core.NewCookie;
/**
* Created by ggiammat on 5/9/17.
*/
@ -378,17 +381,19 @@ public class SVNUpdater {
svnRepository.getFile(file, SVNRepository.INVALID_REVISION, null, byteArrayOutputStream);
String lines[] = byteArrayOutputStream.toString().split("\\r?\\n");
// check if the algorithm is already in the list (match the class
// name)
List<String> newContent = new LinkedList<>(Arrays.asList(lines));
// check if the algorithm is already in the list (match the class name) and delete the content
for (String l : lines) {
if (l.contains(algorithm.getClazz())) {
System.out.println("Not updating algorithm list beacuse already present");
return;
newContent.remove(l);
//System.out.println("Not updating algorithm list beacuse already present");
//return;
}
}
// the algorithm is not in the list. Add it
List<String> newContent = new LinkedList<>(Arrays.asList(lines));
// the algorithm is not in the list or must be overwritten cause some modification. Add it
newContent.add(this.generateAlgorithmEntry(algorithm, targetVRE, category,algorithm_type, env));
// Collections.sort(newContent);
@ -425,6 +430,8 @@ public class SVNUpdater {
}
public String generateAlgorithmEntry(Algorithm algorithm, String targetVRE, String category, String algorithm_type,String env) {
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
StringBuffer sb = new StringBuffer("| ");
sb.append(algorithm.getName() + " | ");
sb.append(algorithm.getFullname() + " | ");
@ -433,7 +440,8 @@ public class SVNUpdater {
sb.append("<notextile>./addAlgorithm.sh " + algorithm.getName() + " " + algorithm.getCategory() + " "
+ algorithm.getClazz() + " " + targetVRE + " " + algorithm_type + " N "
+ algorithm.getPackageURL() + " \"" + algorithm.getDescription() + "\" </notextile> | ");
sb.append("none |");
sb.append("none | ");
sb.append(timestamp + " | ");
return sb.toString();
}
@ -638,10 +646,10 @@ public class SVNUpdater {
SVNUpdater c = new SVNUpdater(sc);
//File a = new File("/home/ngalante/Desktop/testCiro");
File b = new File ("/home/ngalante/Desktop/testB");
//File b = new File ("/home/ngalante/Desktop/testB");
//c.updateAlgorithmFiles(a);
c.updateAlgorithmFiles(b);
//c.updateAlgorithmFiles(b);