From 2b36761fa561434fc222ef2195a3e19c0ca99202 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Sun, 19 Sep 2021 16:11:58 +0200 Subject: [PATCH] [DEV] update basic code --- .classpath | 10 ++++++++++ src/module-info.java | 2 ++ src/org/atriasoft/island/Manifest.java | 17 +++++++++++++++-- .../island/actions/IslandActionInit.java | 10 ++++++++++ .../atriasoft/island/model/ConfigManifest.java | 11 ++++++++++- 5 files changed, 47 insertions(+), 3 deletions(-) diff --git a/.classpath b/.classpath index d5132fe..9504d44 100644 --- a/.classpath +++ b/.classpath @@ -45,10 +45,20 @@ + + + + + + + + + + diff --git a/src/module-info.java b/src/module-info.java index 43e3d22..1580512 100644 --- a/src/module-info.java +++ b/src/module-info.java @@ -14,4 +14,6 @@ open module org.atriasoft.island { requires org.atriasoft.exml; requires org.atriasoft.etk; requires org.eclipse.jgit; + requires org.eclipse.jgit.ssh.apache; + } diff --git a/src/org/atriasoft/island/Manifest.java b/src/org/atriasoft/island/Manifest.java index e4a60ea..860c84f 100644 --- a/src/org/atriasoft/island/Manifest.java +++ b/src/org/atriasoft/island/Manifest.java @@ -11,6 +11,7 @@ import java.util.Map.Entry; import org.atriasoft.exml.Exml; import org.atriasoft.exml.exception.ExmlBuilderException; +import org.atriasoft.exml.exception.ExmlException; import org.atriasoft.exml.exception.ExmlParserErrorMulti; import org.atriasoft.island.internal.Log; import org.atriasoft.island.model.Link; @@ -88,12 +89,24 @@ public class Manifest { this.rootManifest = rootDirectory.getFileName().toString(); rootDirectory = rootDirectory.getParent(); - ManifestFile parsedElements = Exml.parseOne(this.manifestXml, ManifestFile.class, "manifest"); + ManifestFile parsedElements = null; + try { + parsedElements = Exml.parseOne(this.manifestXml, ManifestFile.class, "manifest"); + } catch (ExmlException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } parsedElements.setFileRealPath(this.manifestXml); this.manifests.put(this.rootManifest, parsedElements); for (String includeElem : parsedElements.getIncludes()) { Path maniPath = rootDirectory.resolve(includeElem); - ManifestFile tmpManifest = Exml.parseOne(maniPath, ManifestFile.class, "manifest"); + ManifestFile tmpManifest = null; + try { + tmpManifest = Exml.parseOne(maniPath, ManifestFile.class, "manifest"); + } catch (ExmlException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } tmpManifest.setFileRealPath(maniPath); this.manifests.put(includeElem, tmpManifest); } diff --git a/src/org/atriasoft/island/actions/IslandActionInit.java b/src/org/atriasoft/island/actions/IslandActionInit.java index b78bd46..9ccd54e 100644 --- a/src/org/atriasoft/island/actions/IslandActionInit.java +++ b/src/org/atriasoft/island/actions/IslandActionInit.java @@ -17,6 +17,10 @@ import org.atriasoft.island.model.ConfigManifest; import org.atriasoft.island.model.ProjectConfig; import org.eclipse.jgit.api.Git; +import org.eclipse.jgit.transport.SshSessionFactory; +import org.eclipse.jgit.transport.sshd.DefaultProxyDataFactory; +import org.eclipse.jgit.transport.sshd.JGitKeyCache; +import org.eclipse.jgit.transport.sshd.SshdSessionFactory; public class IslandActionInit extends ActionInterface { @@ -80,6 +84,12 @@ public class IslandActionInit extends ActionInterface { Tools.createDirectory(Env.get_island_path_manifest()); Log.info("Clone the manifest"); + // init session on apache ssh: + SshdSessionFactory factory = new SshdSessionFactory(new JGitKeyCache(), new DefaultProxyDataFactory()); + Log.error("iiii " + factory.getSshDirectory()); + Runtime.getRuntime().addShutdownHook(new Thread(factory::close)); + SshSessionFactory.setInstance(factory); + Git git = Git.cloneRepository() .setURI( address_manifest ) .setDirectory( Env.get_island_path_manifest().toFile() ) diff --git a/src/org/atriasoft/island/model/ConfigManifest.java b/src/org/atriasoft/island/model/ConfigManifest.java index 1e8a0be..8e76603 100644 --- a/src/org/atriasoft/island/model/ConfigManifest.java +++ b/src/org/atriasoft/island/model/ConfigManifest.java @@ -9,6 +9,7 @@ import org.atriasoft.exml.Exml; import org.atriasoft.exml.annotation.XmlList; import org.atriasoft.exml.annotation.XmlName; import org.atriasoft.exml.exception.ExmlBuilderException; +import org.atriasoft.exml.exception.ExmlException; import org.atriasoft.island.Env; import org.atriasoft.island.internal.Log; public class ConfigManifest { @@ -92,6 +93,9 @@ public class ConfigManifest { } catch (ExmlBuilderException e) { Log.error("Can not parse the file.1. " + path); e.printStackTrace(); + } catch (ExmlException e) { + Log.error("Can not parse the file.1. " + path); + e.printStackTrace(); } if (root.length != 1) { Log.error("Can not parse the file.2. " + path); @@ -108,7 +112,12 @@ public class ConfigManifest { } public void store(final Path path) throws ExmlBuilderException { StringBuilder builder = new StringBuilder(); - Exml.generate(this, "config-island", builder); + try { + Exml.generate(this, "config-island", builder); + } catch (ExmlException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } Log.warning("data generated: " + builder.toString()); }