esoe 2 years ago
parent
commit
cae741771a
  1. 1
      options-home.json
  2. 2
      out/repos
  3. 0
      out/var/www/html/css/style.css
  4. 4
      out/var/www/html/index.html
  5. 0
      out/var/www/html/js/main.js
  6. BIN
      out/zip/molokoin-client-master.zip
  7. 52
      src/main/java/ru/molokoin/sourceListener/GitListener.java
  8. 57
      src/main/java/ru/molokoin/sourceListener/fs/ApacheService.java
  9. 8
      src/main/java/ru/molokoin/sourceListener/opt/Options.java
  10. BIN
      target/classes/ru/molokoin/sourceListener/GitListener.class
  11. BIN
      target/classes/ru/molokoin/sourceListener/fs/ApacheService.class
  12. BIN
      target/classes/ru/molokoin/sourceListener/opt/Options.class

1
options-home.json

@ -5,5 +5,6 @@
"downloadPath" : "C:\\Users\\Strannik\\Documents\\esoe\\code\\sourceListener\\out\\zip", "downloadPath" : "C:\\Users\\Strannik\\Documents\\esoe\\code\\sourceListener\\out\\zip",
"zipPath" : "C:\\Users\\Strannik\\Documents\\esoe\\code\\sourceListener\\out\\zip\\molokoin-client-master.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", "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" "destinationPath" : "C:\\Users\\Strannik\\Documents\\esoe\\code\\sourceListener\\out\\var\\www\\html"
} }

2
out/repos

@ -1 +1 @@
Subproject commit ab1d9fe840340945098569399bb6ec50d5daccc0 Subproject commit cd6a2c2e64ec4093db8a428c3e26c5aa09df1b79

0
out/war/www/html/css/style.css → out/var/www/html/css/style.css

4
out/war/www/html/index.html → out/var/www/html/index.html

@ -9,11 +9,13 @@
</head> </head>
<body> <body>
<div class="header"> <div class="header">
molokoin.ru molokoin.ru/ try 13
</div> </div>
<div class="controls01"> <div class="controls01">
<li><a href="http://molokoin.ru:3000/esoe">gitea</a></li> <li><a href="http://molokoin.ru:3000/esoe">gitea</a></li>
<li><a href="http://www.molokoin.ru:8080">apache</a></li> <li><a href="http://www.molokoin.ru:8080">apache</a></li>
<li><a href="http://www.molokoin.ru">projects</a></li>
<li><a href="http://www.molokoin.ru">muse</a></li>
</div> </div>
<script src="js/main.js"></script> <script src="js/main.js"></script>
</body> </body>

0
out/war/www/html/js/main.js → out/var/www/html/js/main.js

BIN
out/zip/molokoin-client-master.zip

Binary file not shown.

52
src/main/java/ru/molokoin/sourceListener/GitListener.java

@ -4,12 +4,14 @@ import java.io.BufferedInputStream;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; 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.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.StandardCopyOption; import java.nio.file.StandardCopyOption;
import java.util.Comparator;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.concurrent.DelayQueue; import java.util.Objects;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipFile; import java.util.zip.ZipFile;
@ -75,7 +77,7 @@ public class GitListener {
try { try {
NetService.download(opt.getZipLink(), opt.getDownloadPath()); NetService.download(opt.getZipLink(), opt.getDownloadPath());
extract(); extract();
move(); move(opt.getSourcePath(), opt.getDestinationPath());
} catch (IOException e) { } catch (IOException e) {
System.out.println("Ошибка move(): " + e.getMessage()); System.out.println("Ошибка move(): " + e.getMessage());
} }
@ -135,19 +137,41 @@ public class GitListener {
} }
/** /**
* * перемещаем файлы из директории source в target
*/ */
public void move() throws IOException { public void move(String sourceString, String targetString) {
Path source = Path.of("/home/esoe/Documents/repos-listen/molokoin/unzip/molokoin-client"); Path source = Path.of(sourceString);
Path target = Path.of(opt.getDestinationPath()); Path target = Path.of(targetString);
//освобождение target
System.out.println("освобождение target ...");
FileUtils.delete(target.toFile());
//перемещение контента
System.out.println("Перемещение контента ... "); System.out.println("Перемещение контента ... ");
Files.move(source, target, StandardCopyOption.ATOMIC_MOVE); System.out.println("sourceString: " + sourceString);
System.out.println("Перемещение контента завершено. "); System.out.println("targetString: " + targetString);
try {
//просмотр содержимого папки target
try (DirectoryStream<Path> 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 { public static void main(String[] args) throws InvalidRemoteException, TransportException, GitAPIException, IOException {

57
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<Path> 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<Path> 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));
}
}
}

8
src/main/java/ru/molokoin/sourceListener/opt/Options.java

@ -7,6 +7,7 @@ public class Options {
private String downloadPath; private String downloadPath;
private String zipPath; private String zipPath;
private String unzipPath; private String unzipPath;
private String sourcePath;
private String destinationPath; private String destinationPath;
public Options(){} public Options(){}
@ -46,6 +47,12 @@ public class Options {
public String getZipPath() { public String getZipPath() {
return zipPath; return zipPath;
} }
public void setSourcePath(String sourcePath) {
this.sourcePath = sourcePath;
}
public String getSourcePath() {
return sourcePath;
}
public void setDestinationPath(String destinationPath) { public void setDestinationPath(String destinationPath) {
this.destinationPath = destinationPath; this.destinationPath = destinationPath;
} }
@ -60,6 +67,7 @@ public class Options {
s = s + "downloadPath : " + getDownloadPath() + "\n"; s = s + "downloadPath : " + getDownloadPath() + "\n";
s = s + "zipPath : " + getZipPath() + "\n"; s = s + "zipPath : " + getZipPath() + "\n";
s = s + "unzipPath : " + getUnzipPath() + "\n"; s = s + "unzipPath : " + getUnzipPath() + "\n";
s = s + "sourcePath : " + getSourcePath() + "\n";
s = s + "destinationPath : " + getDestinationPath() + "\n"; s = s + "destinationPath : " + getDestinationPath() + "\n";
return s; return s;
} }

BIN
target/classes/ru/molokoin/sourceListener/GitListener.class

Binary file not shown.

BIN
target/classes/ru/molokoin/sourceListener/fs/ApacheService.class

Binary file not shown.

BIN
target/classes/ru/molokoin/sourceListener/opt/Options.class

Binary file not shown.
Loading…
Cancel
Save