[927] | 1 | // Copyright 2012 Georg-August-Universität Göttingen, Germany
|
---|
| 2 | //
|
---|
| 3 | // Licensed under the Apache License, Version 2.0 (the "License");
|
---|
| 4 | // you may not use this file except in compliance with the License.
|
---|
| 5 | // You may obtain a copy of the License at
|
---|
| 6 | //
|
---|
| 7 | // http://www.apache.org/licenses/LICENSE-2.0
|
---|
| 8 | //
|
---|
| 9 | // Unless required by applicable law or agreed to in writing, software
|
---|
| 10 | // distributed under the License is distributed on an "AS IS" BASIS,
|
---|
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
| 12 | // See the License for the specific language governing permissions and
|
---|
| 13 | // limitations under the License.
|
---|
[787] | 14 |
|
---|
[922] | 15 | package de.ugoe.cs.autoquest.plugin.jfc.commands;
|
---|
[787] | 16 |
|
---|
| 17 | import java.io.File;
|
---|
| 18 | import java.util.List;
|
---|
| 19 | import java.util.logging.Level;
|
---|
| 20 |
|
---|
[922] | 21 | import de.ugoe.cs.autoquest.plugin.jfc.JFCTraceCorrector;
|
---|
[787] | 22 | import de.ugoe.cs.util.console.Command;
|
---|
| 23 | import de.ugoe.cs.util.console.Console;
|
---|
| 24 |
|
---|
| 25 | /**
|
---|
| 26 | * <p>
|
---|
| 27 | * Command that tries to correct all files in a folder as if they were log files generated by the
|
---|
| 28 | * older version of the JFCMonitor which sometimes do not include correct event sources. The result
|
---|
| 29 | * is another specified directory, which contains the corrected files.
|
---|
| 30 | * </p>
|
---|
| 31 | *
|
---|
| 32 | * @author Patrick Harms
|
---|
| 33 | * @version 1.0
|
---|
| 34 | */
|
---|
| 35 | public class CMDcorrectDirOldJFC implements Command {
|
---|
| 36 |
|
---|
| 37 | /*
|
---|
| 38 | * (non-Javadoc)
|
---|
| 39 | *
|
---|
| 40 | * @see de.ugoe.cs.util.console.Command#run(java.util.List)
|
---|
| 41 | */
|
---|
| 42 | @Override
|
---|
| 43 | public void run(List<Object> parameters) {
|
---|
| 44 | String path;
|
---|
| 45 | String resultPath;
|
---|
| 46 |
|
---|
| 47 | try {
|
---|
| 48 | path = (String) parameters.get(0);
|
---|
| 49 | resultPath = (String) parameters.get(1);
|
---|
| 50 | }
|
---|
| 51 | catch (Exception e) {
|
---|
| 52 | throw new IllegalArgumentException();
|
---|
| 53 | }
|
---|
| 54 |
|
---|
| 55 | File folder = new File(path);
|
---|
| 56 | if (!folder.isDirectory()) {
|
---|
| 57 | Console.printerrln(path + " is not a directory");
|
---|
| 58 | return;
|
---|
| 59 | }
|
---|
| 60 |
|
---|
| 61 | File destfolder = new File(resultPath);
|
---|
| 62 | if (!destfolder.isDirectory()) {
|
---|
| 63 | Console.printerrln(resultPath + " is not a directory");
|
---|
| 64 | return;
|
---|
| 65 | }
|
---|
| 66 |
|
---|
| 67 | JFCTraceCorrector corrector = new JFCTraceCorrector();
|
---|
| 68 |
|
---|
| 69 | String absolutPath = folder.getAbsolutePath();
|
---|
| 70 | String absolutDestPath = destfolder.getAbsolutePath();
|
---|
| 71 | for (String filename : folder.list()) {
|
---|
| 72 | String source = absolutPath + "/" + filename;
|
---|
| 73 | String dest = absolutDestPath + "/" + filename;
|
---|
| 74 | Console.traceln(Level.INFO, "Processing file: " + source);
|
---|
| 75 |
|
---|
| 76 | corrector.correctFile(source, dest);
|
---|
| 77 | }
|
---|
| 78 | }
|
---|
| 79 |
|
---|
| 80 | /*
|
---|
| 81 | * (non-Javadoc)
|
---|
| 82 | *
|
---|
| 83 | * @see de.ugoe.cs.util.console.Command#help()
|
---|
| 84 | */
|
---|
| 85 | @Override
|
---|
| 86 | public String help() {
|
---|
| 87 | return "correctDirOldJFC <sourcedirectory> <destinationdirectory>";
|
---|
| 88 | }
|
---|
| 89 |
|
---|
| 90 | }
|
---|