diff --git a/options.json b/options.json new file mode 100644 index 0000000..290cefa --- /dev/null +++ b/options.json @@ -0,0 +1,7 @@ +{ + "linkVC" : "http://molokoin.ru:3000/esoe/molokoin-client/archive/master.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", + "unzipPath" : "C:\\Users\\Strannik\\Documents\\esoe\\code\\sourceListener\\out\\unzip\\molokoin" + +} \ No newline at end of file diff --git a/out/unzip/molokoin/molokoin-client/css/style.css b/out/unzip/molokoin/molokoin-client/css/style.css new file mode 100644 index 0000000..50893ee --- /dev/null +++ b/out/unzip/molokoin/molokoin-client/css/style.css @@ -0,0 +1,45 @@ +body { + font-family: Arial; + padding: 20px; + background: #f1f1f1; +} +div { + background-color: rgb(181, 122, 236); + padding: 5px; + margin: 5px; +} +.header{ + display: block; + padding: 30px; + font-size: 40px; + text-align: center; + background: rgb(181, 122, 236); + /*position: relative; top: 20px;*/ +} +.controls{ + /*position: relative; left: 20px;*/ + list-style: none; /* Отключение отображения маркеров. */ + width: 25%; /* Ширина меню. */ + float: left; + /*padding-left: 20px;*/ +} +.controls li { + margin: 5px; /* Отступ между блоками по высоте, необходимый для того чтобы пункты меню не сливались */ + font-family: Verdana, Arial, Helvetica, sans-serif; /* Тип шрифта пунктов меню */ + font-size: 14px; /* Размер текста меню */ +} +.controls li a{ + display: block; /* Изменение отображения на блочное для того, чтобы иметь возможность задать внутренние отступы. */ + padding: 4px 15px; /* Отступы внутри блоков. */ + background: #0db5b5; /* Цвет блоков меню. */ + color: #3f3f3f; /* Цвет текста в блоках меню. */ + text-decoration: none; /* Устранение подчёркивания ссылок. */ + position: relative; /* Это необходимо при использовании Internet Explorer 6 для того, чтобы ссылка по всей своей площади была «кликабельной». */ +} +.controls li a:hover { + background: #92d3d3; /* Цвет фона при наведении курсора мыши */ + color: #6b6b6b; /* Цвет текста при наведении курсора мыши */ +} +.mainframe{ + background-color: aliceblue; +} \ No newline at end of file diff --git a/out/unzip/molokoin/molokoin-client/index.html b/out/unzip/molokoin/molokoin-client/index.html new file mode 100644 index 0000000..744949d --- /dev/null +++ b/out/unzip/molokoin/molokoin-client/index.html @@ -0,0 +1,23 @@ + + + + + + + molokoin.ru + + + +
+ molokoin.ru/ добавить картинку и кнопку авторизации +
+
+
  • gitea
  • +
  • apache
  • +
  • moodle
  • +
  • adminvps
  • + +
    + + + \ No newline at end of file diff --git a/out/unzip/molokoin/molokoin-client/js/main.js b/out/unzip/molokoin/molokoin-client/js/main.js new file mode 100644 index 0000000..1a90dbd --- /dev/null +++ b/out/unzip/molokoin/molokoin-client/js/main.js @@ -0,0 +1 @@ +console.log("qu") \ No newline at end of file diff --git a/molokoin-client-master.zip b/out/zip/molokoin-client-master.zip similarity index 100% rename from molokoin-client-master.zip rename to out/zip/molokoin-client-master.zip diff --git a/pom.xml b/pom.xml index a406b19..e1cbee1 100644 --- a/pom.xml +++ b/pom.xml @@ -23,6 +23,11 @@ 4.12 test + + com.fasterxml.jackson.core + jackson-databind + 2.14.0 + \ No newline at end of file diff --git a/src/main/java/ru/molokoin/sourceListener/Options.java b/src/main/java/ru/molokoin/sourceListener/Options.java new file mode 100644 index 0000000..08b5b1c --- /dev/null +++ b/src/main/java/ru/molokoin/sourceListener/Options.java @@ -0,0 +1,42 @@ +package ru.molokoin.sourceListener; + +public class Options { + private String linkVC; + private String downloadPath; + private String zipPath; + private String unzipPath; + + public Options(){} + public void setLinkVC(String linkVC) { + this.linkVC = linkVC; + } + public String getLinkVC() { + return linkVC; + } + public void setDownloadPath(String downloadPath) { + this.downloadPath = downloadPath; + } + public String getDownloadPath() { + return downloadPath; + } + public void setUnzipPath(String unzipPath) { + this.unzipPath = unzipPath; + } + public String getUnzipPath() { + return unzipPath; + } + public void setZipPath(String zipPath) { + this.zipPath = zipPath; + } + public String getZipPath() { + return zipPath; + } + @Override + public String toString() { + String s = "linkVC : " + getLinkVC() + "\n"; + s = s + "downloadPath : " + getDownloadPath() + "\n"; + s = s + "zipPath : " + getZipPath() + "\n"; + s = s + "unzipPath : " + getUnzipPath() + "\n"; + return s; + } +} diff --git a/src/main/java/ru/molokoin/sourceListener/SourceListener.java b/src/main/java/ru/molokoin/sourceListener/SourceListener.java index af97918..b816dfa 100644 --- a/src/main/java/ru/molokoin/sourceListener/SourceListener.java +++ b/src/main/java/ru/molokoin/sourceListener/SourceListener.java @@ -14,28 +14,53 @@ import java.util.Enumeration; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; +import com.fasterxml.jackson.core.exc.StreamReadException; +import com.fasterxml.jackson.databind.DatabindException; +import com.fasterxml.jackson.databind.ObjectMapper; public class SourceListener { - private URI link = URI.create("http://molokoin.ru:3000/esoe/molokoin-client/archive/master.zip"); - private Path downloadPath = Path.of(System.getProperty("user.dir")); - + public Options opt; + public SourceListener(){ + try { + opt = readOptions(); + } catch (StreamReadException e) { + System.out.println(e.getMessage()); + e.printStackTrace(); + } catch (DatabindException e) { + System.out.println(e.getMessage()); + e.printStackTrace(); + } catch (IOException e) { + System.out.println(e.getMessage()); + e.printStackTrace(); + } + } + /** + * + * @return + * @throws StreamReadException + * @throws DatabindException + * @throws IOException + */ + public Options readOptions() throws StreamReadException, DatabindException, IOException{ + Options opt; + ObjectMapper mapper = new ObjectMapper(); + opt = mapper.readValue(new File("options.json"), Options.class); + return opt; + } + public Options getOpt() { + return opt; + } /** * извлечение данных архива */ public void extract()throws IOException{ - String fileZip = "C:\\Users\\devuser\\Documents\\code\\sourceListener\\molokoin-client-master.zip"; - File destDir = new File("src/main/resources/unzip"); - - try (ZipFile file = new ZipFile(fileZip)) - { + //считываем настройки извлечения + try (ZipFile file = new ZipFile(opt.getZipPath())){ Enumeration zipEntries = file.entries(); while (zipEntries.hasMoreElements()){ ZipEntry zipEntry = zipEntries.nextElement(); - File newFile = new File(destDir, zipEntry.getName()); - - //create sub directories + File newFile = new File(opt.getUnzipPath(), zipEntry.getName()); newFile.getParentFile().mkdirs(); - if (!zipEntry.isDirectory()){ try (FileOutputStream outputStream = new FileOutputStream(newFile)){ BufferedInputStream inputStream = new BufferedInputStream(file.getInputStream(zipEntry)); @@ -47,7 +72,6 @@ public class SourceListener { } } } - } /** * скачиваем архив проекта из системы контроля версий, @@ -56,12 +80,12 @@ public class SourceListener { public void download(){ HttpClient client = HttpClient.newHttpClient(); HttpRequest request = HttpRequest.newBuilder() - .uri(getLink()) + .uri(URI.create(opt.getLinkVC())) .build(); try { HttpResponse response = client.send(request, HttpResponse.BodyHandlers - .ofFileDownload(getDownloadPath(), StandardOpenOption.CREATE, StandardOpenOption.WRITE)); + .ofFileDownload(Path.of(opt.getDownloadPath()), StandardOpenOption.CREATE, StandardOpenOption.WRITE)); System.out.println(response.statusCode()); System.out.println(response.headers()); @@ -71,30 +95,6 @@ public class SourceListener { System.out.println(e.getMessage()); } } - /** - * @param link the link to set - */ - public void setLink(URI link) { - this.link = link; - } - /** - * @return the link - */ - public URI getLink() { - return link; - } - /** - * @param downloadPath the downloadPath to set - */ - public void setDownloadPath(Path downloadPath) { - this.downloadPath = downloadPath; - } - /** - * @return the downloadPath - */ - public Path getDownloadPath() { - return downloadPath; - } public static void main(String[] args) { SourceListener ear = new SourceListener(); diff --git a/target/classes/ru/molokoin/sourceListener/Options.class b/target/classes/ru/molokoin/sourceListener/Options.class new file mode 100644 index 0000000..f400803 Binary files /dev/null and b/target/classes/ru/molokoin/sourceListener/Options.class differ diff --git a/target/classes/ru/molokoin/sourceListener/SourceListener.class b/target/classes/ru/molokoin/sourceListener/SourceListener.class index 4630a79..f73638d 100644 Binary files a/target/classes/ru/molokoin/sourceListener/SourceListener.class and b/target/classes/ru/molokoin/sourceListener/SourceListener.class differ