Browse Source

json-works

home
esoe 2 years ago
parent
commit
46133ad4c3
  1. 7
      options.json
  2. 45
      out/unzip/molokoin/molokoin-client/css/style.css
  3. 23
      out/unzip/molokoin/molokoin-client/index.html
  4. 1
      out/unzip/molokoin/molokoin-client/js/main.js
  5. 0
      out/zip/molokoin-client-master.zip
  6. 5
      pom.xml
  7. 42
      src/main/java/ru/molokoin/sourceListener/Options.java
  8. 78
      src/main/java/ru/molokoin/sourceListener/SourceListener.java
  9. BIN
      target/classes/ru/molokoin/sourceListener/Options.class
  10. BIN
      target/classes/ru/molokoin/sourceListener/SourceListener.class

7
options.json

@ -0,0 +1,7 @@ @@ -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"
}

45
out/unzip/molokoin/molokoin-client/css/style.css

@ -0,0 +1,45 @@ @@ -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;
}

23
out/unzip/molokoin/molokoin-client/index.html

@ -0,0 +1,23 @@ @@ -0,0 +1,23 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>molokoin.ru</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
<div class="header">
molokoin.ru/ добавить картинку и кнопку авторизации
</div>
<div class="controls">
<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.egspt.ru">moodle</a></li>
<li><a href="http://isp12.adminvps.ru">adminvps</a></li>
</div>
<script src="js/main.js"></script>
</body>
</html>

1
out/unzip/molokoin/molokoin-client/js/main.js

@ -0,0 +1 @@ @@ -0,0 +1 @@
console.log("qu")

0
molokoin-client-master.zip → out/zip/molokoin-client-master.zip

5
pom.xml

@ -23,6 +23,11 @@ @@ -23,6 +23,11 @@
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.14.0</version>
</dependency>
</dependencies>
</project>

42
src/main/java/ru/molokoin/sourceListener/Options.java

@ -0,0 +1,42 @@ @@ -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;
}
}

78
src/main/java/ru/molokoin/sourceListener/SourceListener.java

@ -14,28 +14,53 @@ import java.util.Enumeration; @@ -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<? extends ZipEntry> 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 { @@ -47,7 +72,6 @@ public class SourceListener {
}
}
}
}
/**
* скачиваем архив проекта из системы контроля версий,
@ -56,12 +80,12 @@ 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<Path> 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 { @@ -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();

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

Binary file not shown.

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

Binary file not shown.
Loading…
Cancel
Save