diff --git a/options-home.json b/options-home.json
index 8a0d98f..8a9ddc5 100644
--- a/options-home.json
+++ b/options-home.json
@@ -5,5 +5,6 @@
"downloadPath" : "C:\\Users\\Strannik\\Documents\\esoe\\code\\sourceListener\\out\\zip",
"zipPath" : "C:\\Users\\Strannik\\Documents\\esoe\\code\\sourceListener\\out\\zip\\molokoin-client-master.zip",
"unzipPath" : "C:\\Users\\Strannik\\Documents\\esoe\\code\\sourceListener\\out\\unzip\\molokoin",
+ "sourcePath" : "C:\\Users\\Strannik\\Documents\\esoe\\code\\sourceListener\\out\\unzip\\molokoin\\molokoin-client",
"destinationPath" : "C:\\Users\\Strannik\\Documents\\esoe\\code\\sourceListener\\out\\var\\www\\html"
}
\ No newline at end of file
diff --git a/out/repos b/out/repos
index ab1d9fe..cd6a2c2 160000
--- a/out/repos
+++ b/out/repos
@@ -1 +1 @@
-Subproject commit ab1d9fe840340945098569399bb6ec50d5daccc0
+Subproject commit cd6a2c2e64ec4093db8a428c3e26c5aa09df1b79
diff --git a/out/war/www/html/css/style.css b/out/var/www/html/css/style.css
similarity index 100%
rename from out/war/www/html/css/style.css
rename to out/var/www/html/css/style.css
diff --git a/out/war/www/html/index.html b/out/var/www/html/index.html
similarity index 76%
rename from out/war/www/html/index.html
rename to out/var/www/html/index.html
index e59d56b..17faf28 100644
--- a/out/war/www/html/index.html
+++ b/out/var/www/html/index.html
@@ -9,11 +9,13 @@
diff --git a/out/war/www/html/js/main.js b/out/var/www/html/js/main.js
similarity index 100%
rename from out/war/www/html/js/main.js
rename to out/var/www/html/js/main.js
diff --git a/out/zip/molokoin-client-master.zip b/out/zip/molokoin-client-master.zip
index adefef5..7ef9d9f 100644
Binary files a/out/zip/molokoin-client-master.zip and b/out/zip/molokoin-client-master.zip differ
diff --git a/src/main/java/ru/molokoin/sourceListener/GitListener.java b/src/main/java/ru/molokoin/sourceListener/GitListener.java
index 12be418..c0707d7 100644
--- a/src/main/java/ru/molokoin/sourceListener/GitListener.java
+++ b/src/main/java/ru/molokoin/sourceListener/GitListener.java
@@ -4,12 +4,14 @@ import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
-import java.nio.file.CopyOption;
+import java.nio.file.DirectoryNotEmptyException;
+import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
+import java.util.Comparator;
import java.util.Enumeration;
-import java.util.concurrent.DelayQueue;
+import java.util.Objects;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
@@ -75,7 +77,7 @@ public class GitListener {
try {
NetService.download(opt.getZipLink(), opt.getDownloadPath());
extract();
- move();
+ move(opt.getSourcePath(), opt.getDestinationPath());
} catch (IOException e) {
System.out.println("Ошибка move(): " + e.getMessage());
}
@@ -135,19 +137,41 @@ public class GitListener {
}
/**
- *
+ * перемещаем файлы из директории source в target
*/
- public void move() throws IOException {
- Path source = Path.of("/home/esoe/Documents/repos-listen/molokoin/unzip/molokoin-client");
- Path target = Path.of(opt.getDestinationPath());
- //освобождение target
- System.out.println("освобождение target ...");
- FileUtils.delete(target.toFile());
- //перемещение контента
+ public void move(String sourceString, String targetString) {
+ Path source = Path.of(sourceString);
+ Path target = Path.of(targetString);
System.out.println("Перемещение контента ... ");
- Files.move(source, target, StandardCopyOption.ATOMIC_MOVE);
- System.out.println("Перемещение контента завершено. ");
-
+ System.out.println("sourceString: " + sourceString);
+ System.out.println("targetString: " + targetString);
+ try {
+ //просмотр содержимого папки target
+ try (DirectoryStream files = Files.newDirectoryStream(target)) {
+ for (Path path : files){
+ System.out.println("Очистка пути: " + path);//вывод содержимого в консоль
+ //очистка папки
+ if(Files.isDirectory(path)){
+ deleteDirectory(path);
+ }else{
+ Files.delete(path);
+ }
+ }
+ }
+ Files.move(source, target, StandardCopyOption.REPLACE_EXISTING);
+ System.out.println("Метод move() успешно выполнен!!!!");
+ } catch (IOException e) {
+ System.err.println("Ошибка в методе move():" + e.getMessage());
+ System.err.println("out >>>>>>>>>>>" + e.getLocalizedMessage());
+ e.printStackTrace();
+ }
+ }
+
+ public static void deleteDirectory(Path directory) throws IOException {
+ Files.walk(directory)
+ .sorted(Comparator.reverseOrder())
+ .map(Path::toFile)
+ .forEach(File::delete);
}
public static void main(String[] args) throws InvalidRemoteException, TransportException, GitAPIException, IOException {
diff --git a/src/main/java/ru/molokoin/sourceListener/fs/ApacheService.java b/src/main/java/ru/molokoin/sourceListener/fs/ApacheService.java
new file mode 100644
index 0000000..1681226
--- /dev/null
+++ b/src/main/java/ru/molokoin/sourceListener/fs/ApacheService.java
@@ -0,0 +1,57 @@
+package ru.molokoin.sourceListener.fs;
+
+import java.io.IOException;
+import java.nio.file.DirectoryIteratorException;
+import java.nio.file.DirectoryStream;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.LinkOption;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+/**
+ * Класс предоставляет инструменты адаптации контента, для размещения на запущеный сервер apache2
+ */
+public class ApacheService {
+ public static void main(String[] args) throws IOException {
+ //перечисление корневых каталогов файловой системы
+ Iterable dirs = FileSystems.getDefault().getRootDirectories();
+ for (Path name: dirs) {
+ System.err.println(name);
+ }
+
+ /**
+ * перечисление содержимого каталога
+ * .. не проходит по внутренним каталогам
+ */
+ Path dir = Paths.get("C:\\Users\\Strannik\\Documents\\esoe\\code\\sourceListener\\out\\zip\\molokoin-client-master.zip");
+ System.out.println("Перечисляем содержимое каталога: " + dir.toString());
+
+ try (DirectoryStream stream = Files.newDirectoryStream(dir)) {
+ for (Path file: stream) {
+ System.out.println(file.getFileName());
+ }
+ } catch (IOException | DirectoryIteratorException x) {
+ // IOException не может броситься во время итерации.
+ // В этом куске кода оно может броситься только
+ // методом newDirectoryStream.
+ System.err.println(x);
+ }
+ System.out.println("--------------------------------");
+ /**
+ * проверка доступа к файлу
+ */
+ System.out.println("проверка доступа к файлу: " + dir);
+ System.out.println("Files.isReadable(dir) : " + Files.isReadable(dir));
+ if (Files.isReadable(dir)){
+ System.out.println("Files.getOwner : " + Files.getOwner(dir, LinkOption.NOFOLLOW_LINKS));
+ System.out.println("Files.getFileStore(dir) : " + Files.getFileStore(dir));
+ System.out.println("Files.size(dir) : " + Files.size(dir));
+ System.out.println("Files.isSymbolicLink(dir) : " + Files.isSymbolicLink(dir));
+ System.out.println("Files.probeContentType(dir) : " + Files.probeContentType(dir));
+
+ }
+
+ }
+
+}
diff --git a/src/main/java/ru/molokoin/sourceListener/opt/Options.java b/src/main/java/ru/molokoin/sourceListener/opt/Options.java
index cf48226..b70f843 100644
--- a/src/main/java/ru/molokoin/sourceListener/opt/Options.java
+++ b/src/main/java/ru/molokoin/sourceListener/opt/Options.java
@@ -7,6 +7,7 @@ public class Options {
private String downloadPath;
private String zipPath;
private String unzipPath;
+ private String sourcePath;
private String destinationPath;
public Options(){}
@@ -46,6 +47,12 @@ public class Options {
public String getZipPath() {
return zipPath;
}
+ public void setSourcePath(String sourcePath) {
+ this.sourcePath = sourcePath;
+ }
+ public String getSourcePath() {
+ return sourcePath;
+ }
public void setDestinationPath(String destinationPath) {
this.destinationPath = destinationPath;
}
@@ -60,6 +67,7 @@ public class Options {
s = s + "downloadPath : " + getDownloadPath() + "\n";
s = s + "zipPath : " + getZipPath() + "\n";
s = s + "unzipPath : " + getUnzipPath() + "\n";
+ s = s + "sourcePath : " + getSourcePath() + "\n";
s = s + "destinationPath : " + getDestinationPath() + "\n";
return s;
}
diff --git a/target/classes/ru/molokoin/sourceListener/GitListener.class b/target/classes/ru/molokoin/sourceListener/GitListener.class
index b673c51..36ac6e2 100644
Binary files a/target/classes/ru/molokoin/sourceListener/GitListener.class and b/target/classes/ru/molokoin/sourceListener/GitListener.class differ
diff --git a/target/classes/ru/molokoin/sourceListener/fs/ApacheService.class b/target/classes/ru/molokoin/sourceListener/fs/ApacheService.class
new file mode 100644
index 0000000..34a82f8
Binary files /dev/null and b/target/classes/ru/molokoin/sourceListener/fs/ApacheService.class differ
diff --git a/target/classes/ru/molokoin/sourceListener/opt/Options.class b/target/classes/ru/molokoin/sourceListener/opt/Options.class
index 5b292d6..e2d4035 100644
Binary files a/target/classes/ru/molokoin/sourceListener/opt/Options.class and b/target/classes/ru/molokoin/sourceListener/opt/Options.class differ