31 DumpResource.listDumpFilesDeleteForMax();
33 File tmpDir1 =
new File(DumpResource.tmpDirPath.substring(0, DumpResource.tmpDirPath.length() - 1));
34 if (!tmpDir1.exists()) {
35 if (tmpDir1.mkdir()) {
37 System.out.println(
"Failed to create directory!");
40 File tmpDir2 =
new File(DumpResource.tmpDirPath2.substring(0, DumpResource.tmpDirPath2.length() - 1));
41 if (!tmpDir2.exists()) {
42 if (tmpDir2.mkdir()) {
44 System.out.println(
"Failed to create directory!");
48 URL link =
new URL(DumpResource.downloadLink);
49 InputStream in =
new BufferedInputStream(link.openStream());
50 ByteArrayOutputStream out =
new ByteArrayOutputStream();
51 byte[] buf =
new byte[1024];
53 while (-1 != (n = in.read(buf))) {
58 byte[] response2 = out.toByteArray();
59 long currentTime = System.currentTimeMillis();
60 String fileName = DumpResource.tmpDirPath + String.valueOf(currentTime) +
".ttl";
61 FileOutputStream fos =
new FileOutputStream(fileName);
65 Path sourcePath = Paths.get(fileName);
66 Path destinationpath = Paths.get(fileName.replace(String.valueOf(currentTime),
"labelingsystem-latest").replace(DumpResource.tmpDirString, DumpResource.tmpDirString2));
67 Files.copy(sourcePath, destinationpath);
69 File fileDelete =
new File(fileName.replace(String.valueOf(currentTime),
"labelingsystem-latest"));
70 Files.deleteIfExists(fileDelete.toPath());
72 PrintWriter writer =
new PrintWriter(DumpResource.tmpDirPath +
"readme.txt",
"UTF-8");
73 writer.println(
"Labeling System Readme");
75 PrintWriter writer2 =
new PrintWriter(DumpResource.tmpDirPath2 +
"readme.txt",
"UTF-8");
76 writer2.println(
"Labeling System Readme");
79 DumpResource.dumbNo++;
80 String compressedFile = DumpResource.fileDir +
"LS-" + String.valueOf(currentTime) +
"-" + DumpResource.getNumberOfStatements() +
"-" + DumpResource.dumbNo +
".tar.gz";
81 TarGZ.compressWithoutFolder(DumpResource.tmpDirPath, compressedFile, DumpResource.tmpDirString);
82 String compressedFile2 = DumpResource.fileDir +
"labelingsystem-latest.tar.gz";
83 TarGZ.compressWithoutFolder(DumpResource.tmpDirPath2, compressedFile2, DumpResource.tmpDirString2);
85 FileUtils.deleteDirectory(
new File(DumpResource.tmpDirPath));
86 FileUtils.deleteDirectory(
new File(DumpResource.tmpDirPath2));
88 DumpResource.lastDump = DumpResource.filePath +
"LS-" + String.valueOf(currentTime) +
"-" + DumpResource.getNumberOfStatements() +
"-" + DumpResource.dumbNo +
".tar.gz";
90 SimpleDateFormat sdf =
new SimpleDateFormat(
"MMM dd yyyy HH:mm:ss");
91 Date resultdate =
new Date(currentTime);
92 System.out.println(
"downloaded at: " + sdf.format(resultdate) +
" | " + compressedFile);
93 DumpResource.lastDumpTime = sdf.format(resultdate);
94 Thread.currentThread().sleep(DumpResource.sleepTimeInMills);
95 if (DumpResource.dumping) {
99 System.out.println(e.toString());
100 throw new IllegalStateException(e.toString());