esoe 2 years ago
parent
commit
a51ea7d8db
  1. 47
      src/main/java/ru/molokoin/sourceListener/SourceListener.java

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

@ -15,19 +15,18 @@ import java.util.zip.ZipEntry;
import java.util.zip.ZipFile; import java.util.zip.ZipFile;
import org.eclipse.jgit.api.Git; import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.GitCommand; import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.events.RepositoryListener; import org.eclipse.jgit.api.errors.InvalidRemoteException;
import org.eclipse.jgit.api.errors.TransportException;
import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
import com.fasterxml.jackson.core.exc.StreamReadException; import com.fasterxml.jackson.core.exc.StreamReadException;
import com.fasterxml.jackson.databind.DatabindException; import com.fasterxml.jackson.databind.DatabindException;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.deser.impl.ExternalTypeHandler.Builder;
public class SourceListener { public class SourceListener {
public Options opt; public Options opt;
public String optionsPath = "options-office.json"; public String optionsPath = "options-home.json";
public SourceListener(){ public SourceListener(){
try { try {
opt = readOptions(); opt = readOptions();
@ -54,22 +53,28 @@ public class SourceListener {
*/ */
public boolean isUpdated(){ public boolean isUpdated(){
try { try {
Repository rep = openJGitCookbookRepository(); Repository repo = RepoCrafter.copy(opt.getGitLink(), new File(opt.getGitLocalPath()));
System.out.println(">>" + rep.getIdentifier()); System.out.println(repo.getConfig());
System.out.println(repo.getIndexFile());
Git git = new Git(repo);
//repo.close();
} catch (InvalidRemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (TransportException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) { } catch (IOException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} catch (GitAPIException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} }
return true; return true;
} }
public static Repository openJGitCookbookRepository() throws IOException {
FileRepositoryBuilder builder = new FileRepositoryBuilder();
return builder
.readEnvironment() // scan environment GIT_* variables
.findGitDir() // scan up the file system tree
.build();
}
/** /**
* Извлечение данных из options.json * Извлечение данных из options.json
* @return * @return
@ -116,7 +121,7 @@ public class SourceListener {
public void download(){ public void download(){
HttpClient client = HttpClient.newHttpClient(); HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder() HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(opt.getLinkVC())) .uri(URI.create(opt.getZipLink()))
.build(); .build();
try { try {
HttpResponse<Path> response = client.send(request, HttpResponse<Path> response = client.send(request,
@ -132,12 +137,12 @@ public class SourceListener {
public static void main(String[] args) { public static void main(String[] args) {
SourceListener ear = new SourceListener(); SourceListener ear = new SourceListener();
ear.download(); // try {
try { // ear.download();
ear.extract(); // ear.extract();
} catch (IOException e) { // } catch (IOException e) {
System.out.println(e.getMessage()); // System.out.println(e.getMessage());
} // }
ear.isUpdated(); ear.isUpdated();
} }
} }

Loading…
Cancel
Save