Logging
This commit is contained in:
@@ -6,6 +6,11 @@
|
|||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>log4j</groupId>
|
||||||
|
<artifactId>log4j</artifactId>
|
||||||
|
<version>1.2.16</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-io</groupId>
|
<groupId>commons-io</groupId>
|
||||||
<artifactId>commons-io</artifactId>
|
<artifactId>commons-io</artifactId>
|
||||||
|
|||||||
@@ -5,19 +5,28 @@ import java.io.File;
|
|||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.log4j.BasicConfigurator;
|
||||||
|
import org.apache.log4j.ConsoleAppender;
|
||||||
|
import org.apache.log4j.Layout;
|
||||||
|
import org.apache.log4j.Level;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import org.apache.log4j.PatternLayout;
|
||||||
|
|
||||||
import com.univocity.parsers.csv.CsvParser;
|
import com.univocity.parsers.csv.CsvParser;
|
||||||
import com.univocity.parsers.csv.CsvParserSettings;
|
import com.univocity.parsers.csv.CsvParserSettings;
|
||||||
|
|
||||||
public class ToolboxFileExporter {
|
public class ToolboxFileExporter {
|
||||||
|
|
||||||
|
private static Logger log = Logger.getLogger(ToolboxFileExporter.class);
|
||||||
|
|
||||||
|
|
||||||
private List<String[]> rows;
|
private List<String[]> rows;
|
||||||
private String baseDir = "I:\\Toolbox\\Assets";
|
private String baseDir = "I:\\Toolbox\\Assets";
|
||||||
|
|
||||||
// Formatdatei generiert mit
|
// Formatdatei generiert mit
|
||||||
// bcp "SELECT OriginalImage FROM AssetImages WHERE AssetID=586" queryout Image.jpg -S MOVNCG -d Bayertoolbox_prod -T -x
|
// bcp "SELECT OriginalImage FROM AssetImages WHERE AssetID=586" queryout Image.jpg -S MOVNCG -d Bayertoolbox_prod -T
|
||||||
// Geben Sie den Dateispeichertyp des Felds OriginalImage ein [varbinary(max)]: x
|
// Geben Sie den Dateispeichertyp des Felds OriginalImage ein [varbinary(max)]: x
|
||||||
// Geben Sie die Präfixlänge des OriginalImage-Felds ein [8]:
|
// Geben Sie die Präfixlänge des OriginalImage-Felds ein [8]: 0
|
||||||
// Geben Sie das Feldabschlusszeichen ein [none]:
|
// Geben Sie das Feldabschlusszeichen ein [none]:
|
||||||
|
|
||||||
// Abruf:
|
// Abruf:
|
||||||
@@ -39,18 +48,20 @@ public class ToolboxFileExporter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void getImage(String assetId, String originalFilenname) throws Exception {
|
private void getImage(String assetId, String originalFilenname) throws Exception {
|
||||||
System.out.println("AssetID: " + assetId + " OriginalFilename: '" + originalFilenname + "'");
|
if (new File(baseDir + File.separator + assetId).exists()) {
|
||||||
|
log.error("File for asset " + assetId + " already present, skipping");
|
||||||
|
}
|
||||||
// TODO Check if file already exists (bcp just overwrites existing files)
|
else {
|
||||||
|
log.info("Download for asset " + assetId + ", OriginalFilename: '" + originalFilenname + "'");
|
||||||
Process process = Runtime.getRuntime().exec(command1 + assetId + command2 + assetId + command3, null, workingDir);
|
Process process = Runtime.getRuntime().exec(command1 + assetId + command2 + assetId + command3, null, workingDir);
|
||||||
process.waitFor();
|
process.waitFor();
|
||||||
|
if (0 < process.exitValue()) {
|
||||||
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||||
|
|
||||||
String s;
|
String s;
|
||||||
while ((s = reader.readLine()) != null) {
|
while ((s = reader.readLine()) != null) {
|
||||||
System.out.println(s);
|
log.error(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,6 +79,10 @@ public class ToolboxFileExporter {
|
|||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
Layout layout = new PatternLayout("%p %m%n"); // "%d{ISO8601} - %p %m%n"
|
||||||
|
BasicConfigurator.configure(new ConsoleAppender(layout));
|
||||||
|
log.setLevel(Level.DEBUG);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
new ToolboxFileExporter();
|
new ToolboxFileExporter();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user