1 |
|
---|
2 | package de.ugoe.cs.quest.plugin.jfc.commands;
|
---|
3 |
|
---|
4 | import java.io.File;
|
---|
5 | import java.util.List;
|
---|
6 | import java.util.logging.Level;
|
---|
7 |
|
---|
8 | import de.ugoe.cs.quest.plugin.jfc.JFCTraceCorrector;
|
---|
9 | import de.ugoe.cs.util.console.Command;
|
---|
10 | import de.ugoe.cs.util.console.Console;
|
---|
11 |
|
---|
12 | /**
|
---|
13 | * <p>
|
---|
14 | * Command that tries to correct all files in a folder as if they were log files generated by the
|
---|
15 | * older version of the JFCMonitor which sometimes do not include correct event sources. The result
|
---|
16 | * is another specified directory, which contains the corrected files.
|
---|
17 | * </p>
|
---|
18 | *
|
---|
19 | * @author Patrick Harms
|
---|
20 | * @version 1.0
|
---|
21 | */
|
---|
22 | public class CMDcorrectDirOldJFC implements Command {
|
---|
23 |
|
---|
24 | /*
|
---|
25 | * (non-Javadoc)
|
---|
26 | *
|
---|
27 | * @see de.ugoe.cs.util.console.Command#run(java.util.List)
|
---|
28 | */
|
---|
29 | @Override
|
---|
30 | public void run(List<Object> parameters) {
|
---|
31 | String path;
|
---|
32 | String resultPath;
|
---|
33 |
|
---|
34 | try {
|
---|
35 | path = (String) parameters.get(0);
|
---|
36 | resultPath = (String) parameters.get(1);
|
---|
37 | }
|
---|
38 | catch (Exception e) {
|
---|
39 | throw new IllegalArgumentException();
|
---|
40 | }
|
---|
41 |
|
---|
42 | File folder = new File(path);
|
---|
43 | if (!folder.isDirectory()) {
|
---|
44 | Console.printerrln(path + " is not a directory");
|
---|
45 | return;
|
---|
46 | }
|
---|
47 |
|
---|
48 | File destfolder = new File(resultPath);
|
---|
49 | if (!destfolder.isDirectory()) {
|
---|
50 | Console.printerrln(resultPath + " is not a directory");
|
---|
51 | return;
|
---|
52 | }
|
---|
53 |
|
---|
54 | JFCTraceCorrector corrector = new JFCTraceCorrector();
|
---|
55 |
|
---|
56 | String absolutPath = folder.getAbsolutePath();
|
---|
57 | String absolutDestPath = destfolder.getAbsolutePath();
|
---|
58 | for (String filename : folder.list()) {
|
---|
59 | String source = absolutPath + "/" + filename;
|
---|
60 | String dest = absolutDestPath + "/" + filename;
|
---|
61 | Console.traceln(Level.INFO, "Processing file: " + source);
|
---|
62 |
|
---|
63 | corrector.correctFile(source, dest);
|
---|
64 | }
|
---|
65 | }
|
---|
66 |
|
---|
67 | /*
|
---|
68 | * (non-Javadoc)
|
---|
69 | *
|
---|
70 | * @see de.ugoe.cs.util.console.Command#help()
|
---|
71 | */
|
---|
72 | @Override
|
---|
73 | public String help() {
|
---|
74 | return "correctDirOldJFC <sourcedirectory> <destinationdirectory>";
|
---|
75 | }
|
---|
76 |
|
---|
77 | }
|
---|