[DEBUG] update new xml API

This commit is contained in:
Edouard DUPIN 2022-08-28 19:47:48 +02:00
parent 38dd3dda35
commit ba0ef7a106
6 changed files with 30 additions and 23 deletions

View File

@ -10,7 +10,7 @@ import java.util.Map;
import java.util.Map.Entry;
import org.atriasoft.aknot.exception.AknotException;
import org.atriasoft.exml.Exml;
import org.atriasoft.exml.XmlMapper;
import org.atriasoft.exml.exception.ExmlBuilderException;
import org.atriasoft.exml.exception.ExmlException;
import org.atriasoft.exml.exception.ExmlParserErrorMulti;
@ -284,11 +284,9 @@ public class Manifest {
Log.debug("PArse main XML config " + rootDirectory);
ManifestFile parsedElements = null;
try {
parsedElements = Exml.parseOne(this.manifestXml, ManifestFile.class, "manifest");
} catch (final ExmlException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (final AknotException e1) {
final XmlMapper mapper = new XmlMapper();
parsedElements = mapper.read(ManifestFile.class, this.manifestXml);
} catch (final ExmlException | AknotException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
@ -299,11 +297,9 @@ public class Manifest {
Log.debug("PArse <<SUB>> XML config " + maniPath);
ManifestFile tmpManifest = null;
try {
tmpManifest = Exml.parseOne(maniPath, ManifestFile.class, "manifest");
} catch (final ExmlException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (final AknotException e) {
final XmlMapper mapper = new XmlMapper();
tmpManifest = mapper.read(ManifestFile.class, maniPath);
} catch (final ExmlException | AknotException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

View File

@ -26,7 +26,7 @@ import org.atriasoft.ejson.Ejson;
import org.atriasoft.ejson.model.JsonArray;
import org.atriasoft.ejson.model.JsonObject;
import org.atriasoft.ejson.model.JsonString;
import org.atriasoft.exml.Exml;
import org.atriasoft.exml.XmlMapper;
import org.atriasoft.exml.exception.ExmlException;
import org.atriasoft.island.Config;
import org.atriasoft.island.Env;
@ -158,7 +158,8 @@ public class DependencySync {
Log.verbose("dataAsString: " + dataAsString);
MavenMetadata metaData = null;
try {
metaData = Exml.parseOne(dataAsString, MavenMetadata.class, "metadata");
final XmlMapper mapper = new XmlMapper();
metaData = mapper.parse(dataAsString, MavenMetadata.class);
} catch (ExmlException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@ -178,7 +179,8 @@ public class DependencySync {
readRemoteFileAndStore(remotePakageFileName + "/" + base, localPackageFileName.resolve(base), base);
PomMaven mavenPom = null;
try {
mavenPom = Exml.parseOne(localPackageFileName.resolve(base), PomMaven.class, "project");
final XmlMapper mapper = new XmlMapper();
mavenPom = mapper.read(PomMaven.class, localPackageFileName.resolve(base));
} catch (ExmlException e) {
// TODO Auto-generated catch block
e.printStackTrace();

View File

@ -9,13 +9,14 @@ import java.util.ListIterator;
import org.atriasoft.aknot.annotation.AknotList;
import org.atriasoft.aknot.annotation.AknotName;
import org.atriasoft.aknot.exception.AknotException;
import org.atriasoft.exml.Exml;
import org.atriasoft.exml.XmlMapper;
import org.atriasoft.exml.exception.ExmlBuilderException;
import org.atriasoft.exml.exception.ExmlException;
import org.atriasoft.island.Env;
import org.atriasoft.island.internal.Log;
import org.atriasoft.island.model.Volatile;
@AknotName("config-island")
public class ConfigManifest {
public static ConfigManifest load() {
@ -23,20 +24,24 @@ public class ConfigManifest {
}
public static ConfigManifest load(final Path path) {
ConfigManifest[] root = null;
ConfigManifest root = null;
try {
root = Exml.parse(path, ConfigManifest.class, "config-island");
XmlMapper mapper = new XmlMapper();
root = mapper.read(ConfigManifest.class, path);
} catch (final ExmlException e) {
Log.error("Can not parse the file.1. " + path);
e.printStackTrace();
} catch (final AknotException e) {
Log.error("Can not parse the file.2. " + path);
e.printStackTrace();
}
if (root.length != 1) {
} catch (IOException e) {
Log.error("Can not parse the file.3. " + path);
e.printStackTrace();
}
return root[0];
if (root == null) {
Log.error("Can not parse the file.4. " + path);
}
return root;
}
private String repo = "";
@ -182,8 +187,9 @@ public class ConfigManifest {
public void store(final Path path) throws ExmlBuilderException {
try {
Exml.store(path, this, "config-island");
} catch (final ExmlException | IOException ex) {
XmlMapper mapper = new XmlMapper();
mapper.store(this, path);
} catch (final ExmlException | IOException | AknotException ex) {
Log.warning("detect throw: " + ex.getMessage());
ex.printStackTrace();
}

View File

@ -10,6 +10,7 @@ import org.atriasoft.aknot.annotation.AknotManaged;
import org.atriasoft.aknot.annotation.AknotName;
@AknotIgnoreUnknown
@AknotName("manifest")
public class ManifestFile {
private Path fileRealPath = null;
private List<ProjectConfig> projects = new ArrayList<>();

View File

@ -1,11 +1,12 @@
package org.atriasoft.island.model.maven;
import org.atriasoft.aknot.annotation.AknotDefaultAttribute;
import org.atriasoft.aknot.annotation.AknotIgnoreUnknown;
import org.atriasoft.aknot.annotation.AknotName;
import org.atriasoft.aknot.annotation.AknotDefaultAttribute;
@AknotDefaultAttribute(false)
@AknotIgnoreUnknown
@AknotName("metadata")
public record MavenMetadata(
@AknotName("groupId") String groupId,
@AknotName("artifactId") String artifactId,

View File

@ -10,6 +10,7 @@ import org.atriasoft.aknot.annotation.AknotOptional;
@AknotDefaultNullValue
@AknotIgnoreUnknown
@AknotName("project")
public record PomMaven(
@AknotName("modelVersion") String modelVersion,
@AknotName("groupId") String groupId,