[DEV] update basic code

This commit is contained in:
Edouard DUPIN 2021-09-19 16:11:58 +02:00
parent 9be04fb7d7
commit 2b36761fa5
5 changed files with 47 additions and 3 deletions

View File

@ -45,10 +45,20 @@
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/org.eclipse.jgit.ssh.apache-5.12.0.202106070339-r.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5">
<attributes>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/sshd-core-2.7.0.jar"/>
<classpathentry kind="lib" path="lib/sshd-sftp-2.7.0.jar"/>
<classpathentry kind="lib" path="lib/eddsa-0.3.0.jar"/>
<classpathentry kind="lib" path="lib/sshd-common-2.7.0.jar"/>
<classpathentry kind="lib" path="lib/sshd-osgi-2.7.0.jar"/>
<classpathentry kind="output" path="out/eclipse/classes"/>
</classpath>

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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() )

View File

@ -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());
}