updates for packages changes
This commit is contained in:
parent
45df4708d7
commit
60703efdd4
|
@ -13960,7 +13960,7 @@ public class VersionConvertor_30_50 {
|
|||
private static org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.MedicationDispense.MedicationDispenseStatus> convertMedicationDispenseStatus(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.MedicationDispense.MedicationDispenseStatus> src) throws FHIRException {
|
||||
if (src == null)
|
||||
return null;
|
||||
org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.MedicationDispense.MedicationDispenseStatus> tgt = new org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.MedicationDispense.MedicationDispenseStatus>();
|
||||
org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.MedicationDispense.MedicationDispenseStatus> tgt = new org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.MedicationDispense.MedicationDispenseStatus>(new org.hl7.fhir.r5.model.MedicationDispense.MedicationDispenseStatusEnumFactory());
|
||||
copyElement(src, tgt);
|
||||
switch (src.getValue()) {
|
||||
case PREPARATION: tgt.setValue(org.hl7.fhir.r5.model.MedicationDispense.MedicationDispenseStatus.PREPARATION); break;
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
<configuration scan="true" scanPeriod="30 seconds">
|
||||
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
||||
<level>INFO</level>
|
||||
</filter>
|
||||
<encoder>
|
||||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} [%file:%line] %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="info">
|
||||
<appender-ref ref="STDOUT" />
|
||||
</root>
|
||||
|
||||
</configuration>
|
|
@ -835,35 +835,45 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
}
|
||||
int ndl = findEndOfElement(differential, ndc);
|
||||
// the first element is setting up the slicing
|
||||
if (diffMatches.get(0).getSlicing().hasRules())
|
||||
if (diffMatches.get(0).getSlicing().getRules() != SlicingRules.CLOSED)
|
||||
throw new FHIRException("Error at path "+cpath+" in "+url+": Type slicing with slicing.rules != closed");
|
||||
if (diffMatches.get(0).getSlicing().hasOrdered())
|
||||
if (diffMatches.get(0).getSlicing().getOrdered())
|
||||
if (diffMatches.get(0).getSlicing().hasRules()) {
|
||||
// this rule revoked at DevDays Amsterdam 2019 - discussion between Grahame Lloyd Alexander Ardon
|
||||
// if (diffMatches.get(0).getSlicing().getRules() != SlicingRules.CLOSED) {
|
||||
// throw new FHIRException("Error at path "+cpath+" in "+url+": Type slicing with slicing.rules != closed");
|
||||
// }
|
||||
}
|
||||
if (diffMatches.get(0).getSlicing().hasOrdered()) {
|
||||
if (diffMatches.get(0).getSlicing().getOrdered()) {
|
||||
throw new FHIRException("Error at path "+cpath+" in "+url+": Type slicing with slicing.ordered = true");
|
||||
}
|
||||
}
|
||||
if (diffMatches.get(0).getSlicing().hasDiscriminator()) {
|
||||
if (diffMatches.get(0).getSlicing().getDiscriminator().size() != 1)
|
||||
if (diffMatches.get(0).getSlicing().getDiscriminator().size() != 1) {
|
||||
throw new FHIRException("Error at path "+cpath+" in "+url+": Type slicing with slicing.discriminator.count() > 1");
|
||||
if (!"$this".equals(diffMatches.get(0).getSlicing().getDiscriminatorFirstRep().getPath()))
|
||||
}
|
||||
if (!"$this".equals(diffMatches.get(0).getSlicing().getDiscriminatorFirstRep().getPath())) {
|
||||
throw new FHIRException("Error at path "+cpath+" in "+url+": Type slicing with slicing.discriminator.path != '$this'");
|
||||
if (diffMatches.get(0).getSlicing().getDiscriminatorFirstRep().getType() != DiscriminatorType.TYPE)
|
||||
}
|
||||
if (diffMatches.get(0).getSlicing().getDiscriminatorFirstRep().getType() != DiscriminatorType.TYPE) {
|
||||
throw new FHIRException("Error at path "+cpath+" in "+url+": Type slicing with slicing.discriminator.type != 'type'");
|
||||
}
|
||||
}
|
||||
// check the slice names too while we're at it...
|
||||
for (TypeSlice ts : typeList)
|
||||
for (TypeSlice ts : typeList) {
|
||||
if (ts.type != null) {
|
||||
String tn = rootName(cpath)+Utilities.capitalize(ts.type);
|
||||
if (!ts.defn.hasSliceName())
|
||||
if (!ts.defn.hasSliceName()) {
|
||||
ts.defn.setSliceName(tn);
|
||||
else if (!ts.defn.getSliceName().equals(tn))
|
||||
} else if (!ts.defn.getSliceName().equals(tn)) {
|
||||
throw new FHIRException("Error at path "+(!Utilities.noString(contextPathSrc) ? contextPathSrc : cpath)+": Slice name must be '"+tn+"' but is '"+ts.defn.getSliceName()+"'");
|
||||
if (!ts.defn.hasType())
|
||||
} if (!ts.defn.hasType()) {
|
||||
ts.defn.addType().setCode(ts.type);
|
||||
else if (ts.defn.getType().size() > 1)
|
||||
} else if (ts.defn.getType().size() > 1) {
|
||||
throw new FHIRException("Error at path "+(!Utilities.noString(contextPathSrc) ? contextPathSrc : cpath)+": Slice for type '"+tn+"' has more than one type '"+ts.defn.typeSummary()+"'");
|
||||
else if (!ts.defn.getType().get(0).getCode().equals(ts.type))
|
||||
throw new FHIRException("Error at path "+(!Utilities.noString(contextPathSrc) ? contextPathSrc : cpath)+": Slice for type '"+tn+"' has wrong type '"+ts.defn.typeSummary()+"'");
|
||||
} else if (!ts.defn.getType().get(0).getCode().equals(ts.type)) {
|
||||
throw new FHIRException("Error at path "+(!Utilities.noString(contextPathSrc) ? contextPathSrc : cpath)+": Slice for type '"+tn+"' has wrong type '"+ts.defn.typeSummary()+"'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ok passed the checks.
|
||||
// copy the root diff, and then process any children it has
|
||||
|
|
|
@ -289,6 +289,7 @@ public class SimpleWorkerContext extends BaseWorkerContext implements IWorkerCon
|
|||
for (String s : pi.listResources(types)) {
|
||||
loadDefinitionItem(s, pi.load("package", s), loader);
|
||||
}
|
||||
// todogg
|
||||
version = pi.version();
|
||||
}
|
||||
|
||||
|
@ -469,6 +470,9 @@ public class SimpleWorkerContext extends BaseWorkerContext implements IWorkerCon
|
|||
generateSnapshot(sd);
|
||||
} catch (Exception e) {
|
||||
System.out.println("Unable to generate snapshot for "+sd.getUrl()+" because "+e.getMessage());
|
||||
if (true) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
result.add(sd);
|
||||
set.add(sd);
|
||||
|
@ -586,6 +590,7 @@ public class SimpleWorkerContext extends BaseWorkerContext implements IWorkerCon
|
|||
ProfileUtilities pu = new ProfileUtilities(this, msgs, this);
|
||||
pu.setThrowException(false);
|
||||
pu.sortDifferential(sd, p, p.getUrl(), errors);
|
||||
pu.setDebug(false);
|
||||
for (String err : errors)
|
||||
msgs.add(new ValidationMessage(Source.ProfileValidator, IssueType.EXCEPTION, p.getUserString("path"), "Error sorting Differential: "+err, ValidationMessage.IssueSeverity.ERROR));
|
||||
pu.generateSnapshot(sd, p, p.getUrl(), Utilities.extractBaseUrl(sd.getUserString("path")), p.getName());
|
||||
|
|
|
@ -48,6 +48,7 @@ import org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream;
|
|||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.utilities.CommaSeparatedStringBuilder;
|
||||
import org.hl7.fhir.utilities.IniFile;
|
||||
import org.hl7.fhir.utilities.TextFile;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
|
@ -250,10 +251,18 @@ public class NpmPackage {
|
|||
if (f.exists() && f.isDirectory())
|
||||
for (String s : f.list())
|
||||
res.add(s);
|
||||
f = new File(Utilities.path(path, "package", folder));
|
||||
if (f.exists() && f.isDirectory())
|
||||
for (String s : f.list())
|
||||
res.add(s);
|
||||
} else {
|
||||
for (String s : content.keySet()) {
|
||||
if (s.startsWith(folder+"/") && !s.substring(folder.length()+2).contains("/"))
|
||||
if (s.startsWith(folder+"/") && !s.substring(folder.length()+2).contains("/")) {
|
||||
res.add(s.substring(folder.length()+1));
|
||||
}
|
||||
if (s.startsWith("package/"+folder+"/")) {
|
||||
res.add(s.substring(folder.length()+9));
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
|
@ -325,10 +334,15 @@ public class NpmPackage {
|
|||
* @throws IOException
|
||||
*/
|
||||
public InputStream load(String folder, String file) throws IOException {
|
||||
if (content.containsKey(folder+"/"+file))
|
||||
if (content.containsKey(folder+"/"+file)) {
|
||||
return new ByteArrayInputStream(content.get(folder+"/"+file));
|
||||
else {
|
||||
} else if (content.containsKey("package/"+folder+"/"+file)) {
|
||||
return new ByteArrayInputStream(content.get(folder+"/"+file));
|
||||
} else {
|
||||
File f = new File(Utilities.path(path, folder, file));
|
||||
if (f.exists())
|
||||
return new FileInputStream(f);
|
||||
f = new File(Utilities.path(path, "package", folder, file));
|
||||
if (f.exists())
|
||||
return new FileInputStream(f);
|
||||
throw new IOException("Unable to find the file "+folder+"/"+file+" in the package "+name());
|
||||
|
@ -534,14 +548,26 @@ public class NpmPackage {
|
|||
bufferedOutputStream = new BufferedOutputStream(OutputStream);
|
||||
gzipOutputStream = new GzipCompressorOutputStream(bufferedOutputStream);
|
||||
tar = new TarArchiveOutputStream(gzipOutputStream);
|
||||
|
||||
NpmPackageIndexBuilder indexer = new NpmPackageIndexBuilder();
|
||||
indexer.start();
|
||||
|
||||
Map<String, NpmPackageIndexBuilder> indexers = new HashMap<>();
|
||||
|
||||
for (String s : content.keySet()) {
|
||||
byte[] b = content.get(s);
|
||||
if (s.startsWith("package/")) {
|
||||
indexer.seeFile(tail(s), b);
|
||||
if (s.startsWith("package/")) {
|
||||
String n = s.substring(8);
|
||||
String dir = null;
|
||||
if (n.contains("/")) {
|
||||
dir = n.substring(0, n.lastIndexOf("/"));
|
||||
n = n.substring(n.lastIndexOf("/")+1);
|
||||
}
|
||||
if (!indexers.containsKey(dir)) {
|
||||
NpmPackageIndexBuilder indexer = new NpmPackageIndexBuilder();
|
||||
indexer.start();
|
||||
indexers.put(dir, indexer);
|
||||
}
|
||||
indexers.get(dir).seeFile(n, b);
|
||||
} else {
|
||||
throw new IOException("The package has an illegal file path "+s);
|
||||
}
|
||||
if (!s.endsWith(".index.json") && !s.equals("package/package.json")) {
|
||||
TarArchiveEntry entry = new TarArchiveEntry(s);
|
||||
|
@ -558,12 +584,14 @@ public class NpmPackage {
|
|||
tar.write(cnt);
|
||||
tar.closeArchiveEntry();
|
||||
|
||||
cnt = indexer.build().getBytes(Charset.forName("UTF-8"));
|
||||
entry = new TarArchiveEntry("package/.index.json");
|
||||
entry.setSize(cnt.length);
|
||||
tar.putArchiveEntry(entry);
|
||||
tar.write(cnt);
|
||||
tar.closeArchiveEntry();
|
||||
for (String s : indexers.keySet()) {
|
||||
cnt = indexers.get(s).build().getBytes(Charset.forName("UTF-8"));
|
||||
entry = s == null ? new TarArchiveEntry("package/.index.json") : new TarArchiveEntry("package/"+s+"/.index.json");
|
||||
entry.setSize(cnt.length);
|
||||
tar.putArchiveEntry(entry);
|
||||
tar.write(cnt);
|
||||
tar.closeArchiveEntry();
|
||||
}
|
||||
|
||||
tar.finish();
|
||||
tar.close();
|
||||
|
@ -640,6 +668,27 @@ public class NpmPackage {
|
|||
return ver.matches("^[0-9]+\\.[0-9]+\\.[0-9]+$");
|
||||
}
|
||||
|
||||
public String fhirVersionList() {
|
||||
if (npm.has("fhirVersions")) {
|
||||
CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder();
|
||||
for (JsonElement n : npm.getAsJsonArray("fhirVersions")) {
|
||||
b.append(n.getAsString());
|
||||
}
|
||||
return b.toString();
|
||||
} else
|
||||
return "";
|
||||
}
|
||||
|
||||
public String dependencySummary() {
|
||||
if (npm.has("dependencies")) {
|
||||
CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder();
|
||||
for (Entry<String, JsonElement> e : npm.getAsJsonObject("dependencies").entrySet()) {
|
||||
b.append(e.getKey()+"#"+e.getValue().getAsString());
|
||||
}
|
||||
return b.toString();
|
||||
} else
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -188,7 +188,9 @@ public class PackageCacheManager {
|
|||
int c = 0;
|
||||
File[] packages = new File(Utilities.path(dir, "package")).listFiles();
|
||||
for (File f : packages) {
|
||||
indexer.seeFile(f.getName(), TextFile.fileToBytes(f));
|
||||
if (!f.isDirectory()) {
|
||||
indexer.seeFile(f.getName(), TextFile.fileToBytes(f));
|
||||
}
|
||||
i++;
|
||||
if (progress && i % 50 == 0) {
|
||||
c++;
|
||||
|
@ -289,6 +291,7 @@ public class PackageCacheManager {
|
|||
|
||||
public boolean initUrlMaps(IniFile ini, boolean save) {
|
||||
save = checkIniHasMapping("hl7.fhir.core", "http://hl7.org/fhir", ini) || save;
|
||||
save = checkIniHasMapping("hl7.fhir.pubpack", "http://fhir.org/packages/hl7.fhir.pubpack", ini) || save;
|
||||
|
||||
save = checkIniHasMapping("hl7.fhir.r2.core", "http://hl7.org/fhir/DSTU2/hl7.fhir.r2.core.tgz", ini) || save;
|
||||
save = checkIniHasMapping("hl7.fhir.r2.examples", "http://hl7.org/fhir/DSTU2/hl7.fhir.r2.examples.tgz", ini) || save;
|
||||
|
@ -644,7 +647,13 @@ public class PackageCacheManager {
|
|||
try {
|
||||
json = fetchJson(pu);
|
||||
} catch (Exception e) {
|
||||
throw new FHIRException("Error fetching package list for "+id+" from "+pu+": "+e.getMessage(), e);
|
||||
String pv = Utilities.pathURL(url, v, "package.tgz");
|
||||
try {
|
||||
InputStream stream = fetchFromUrlSpecific(pv, true);
|
||||
return addPackageToCache(id, v, stream, pv);
|
||||
} catch (Exception e1) {
|
||||
throw new FHIRException("Error fetching package directly ("+pv+"), or fetching package list for "+id+" from "+pu+": "+e1.getMessage(), e1);
|
||||
}
|
||||
}
|
||||
if (!id.equals(JSONUtil.str(json, "package-id")))
|
||||
throw new FHIRException("Package ids do not match in "+pu+": "+id+" vs "+JSONUtil.str(json, "package-id"));
|
||||
|
|
|
@ -7,11 +7,16 @@ import java.io.FileOutputStream;
|
|||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.hl7.fhir.utilities.CSVWriter;
|
||||
import org.hl7.fhir.utilities.TextFile;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
public class PackageScanner {
|
||||
public static void main(String[] args) throws FileNotFoundException, IOException {
|
||||
new PackageScanner().scan(new File("C:\\web\\hl7.org\\fhir"), "c:\\temp\\package-scan.csv", "http://hl7.org/fhir");
|
||||
|
@ -19,8 +24,8 @@ public class PackageScanner {
|
|||
|
||||
private void scan(File folder, String dest, String url) throws IOException {
|
||||
CSVWriter csv = new CSVWriter(new FileOutputStream(dest));
|
||||
csv.line("path", "error", "name", "version", "fhir-version", "canonical", "homepage",
|
||||
"url", "type", "#types", "#urls");
|
||||
csv.line("path", "error", "name", "version", "fhir-version", "fhir-version-explicit", "canonical", "homepage",
|
||||
"url", "type", "#types", "#urls", "dependencies");
|
||||
scanFolders(folder, csv, folder.getAbsolutePath(), url);
|
||||
csv.close();
|
||||
System.out.println("done");
|
||||
|
@ -40,9 +45,9 @@ public class PackageScanner {
|
|||
private void processPackage(File file, CSVWriter csv, String root, String url) {
|
||||
try {
|
||||
NpmPackage npm = NpmPackage.fromPackage(new FileInputStream(file));
|
||||
// fix(npm, file.getAbsolutePath(), root, url);
|
||||
csv.line(file.getAbsolutePath(), "", npm.name(), npm.version(), npm.fhirVersion(), npm.canonical(), npm.homepage(),
|
||||
npm.url(), npm.type(), Integer.toString(npm.getTypes().size()), Integer.toString(npm.getUrls().size()));
|
||||
fix(npm, file, root, url);
|
||||
csv.line(file.getAbsolutePath(), "", npm.name(), npm.version(), npm.fhirVersion(), npm.fhirVersionList(), npm.canonical(), npm.homepage(),
|
||||
npm.url(), npm.type(), Integer.toString(npm.getTypes().size()), Integer.toString(npm.getUrls().size()), npm.dependencySummary());
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
csv.line(file.getAbsolutePath(), e.getMessage() == null ? "NPE" : e.getMessage());
|
||||
|
@ -54,25 +59,74 @@ public class PackageScanner {
|
|||
|
||||
}
|
||||
|
||||
private void fix(NpmPackage npm, String filename, String root, String url) throws FileNotFoundException, IOException {
|
||||
String u = Utilities.pathURL(url, Utilities.getDirectoryForFile(filename).substring(root.length()).replace("\\", "/"));
|
||||
if (Utilities.getDirectoryForFile(filename).equals("C:\\web\\hl7.org\\fhir")) {
|
||||
private void fix(NpmPackage npm, File file, String root, String url) throws FileNotFoundException, IOException {
|
||||
String u = Utilities.pathURL(url, Utilities.getDirectoryForFile(file.getAbsolutePath()).substring(root.length()).replace("\\", "/"));
|
||||
if (Utilities.getDirectoryForFile(file.getAbsolutePath()).equals("C:\\web\\hl7.org\\fhir")) {
|
||||
u = "http://hl7.org/fhir/R4";
|
||||
}
|
||||
boolean save = false;
|
||||
if (npm.url() == null || !npm.url().equals(u)) {
|
||||
npm.getNpm().remove("url");
|
||||
npm.getNpm().addProperty("url", u);
|
||||
save = true;
|
||||
}
|
||||
if (!npm.canonical().startsWith("http://hl7.org")) {
|
||||
npm.getNpm().remove("canonical");
|
||||
npm.getNpm().addProperty("canonical", "http://hl7.org/fhir/smart-app-launch");
|
||||
save = true;
|
||||
List<String> names = new ArrayList<>();
|
||||
names.addAll(npm.getContent().keySet());
|
||||
for (String s : names) {
|
||||
if (!s.startsWith("package/")) {
|
||||
save = true;
|
||||
String n = "package/"+s;
|
||||
npm.getContent().put(n, npm.getContent().get(s));
|
||||
npm.getContent().remove(s);
|
||||
}
|
||||
}
|
||||
|
||||
if (!npm.getNpm().has("fhirVersions")) {
|
||||
JsonArray fv = new JsonArray();
|
||||
fv.add(npm.fhirVersion());
|
||||
npm.getNpm().add("fhirVersions", fv);
|
||||
save = true;
|
||||
}
|
||||
if (npm.getNpm().has("dependencies")) {
|
||||
JsonObject dep = npm.getNpm().getAsJsonObject("dependencies");
|
||||
for (Entry<String, JsonElement> e : dep.entrySet()) {
|
||||
if ("current".equals(e.getValue().getAsString())) {
|
||||
save = true;
|
||||
if ("hl7.fhir.us.core.r4".equals(e.getKey())) {
|
||||
dep.remove("hl7.fhir.us.core.r4");
|
||||
dep.addProperty("hl7.fhir.us.core", "3.0.1");
|
||||
} else if ("hl7.fhir.us.davinci-pas".equals(e.getKey())) {
|
||||
dep.remove("hl7.fhir.us.davinci-pas");
|
||||
dep.addProperty("hl7.fhir.us.davinci-pas", "0.1.0");
|
||||
} else if ("hl7.fhir.uv.sdc".equals(e.getKey())) {
|
||||
dep.remove("hl7.fhir.uv.sdc");
|
||||
if ("0.1.0".equals(npm.version()))
|
||||
dep.addProperty("hl7.fhir.uv.sdc", "2.5.0");
|
||||
else
|
||||
dep.addProperty("hl7.fhir.uv.sdc", "2.7.0");
|
||||
} else if ("hl7.fhir.us.core".equals(e.getKey())) {
|
||||
dep.remove("hl7.fhir.us.core");
|
||||
dep.addProperty("hl7.fhir.us.core", "3.0.1");
|
||||
} else if ("hl7.fhir.us.ccda.r4".equals(e.getKey())) {
|
||||
dep.remove("hl7.fhir.us.ccda.r4");
|
||||
dep.addProperty("hl7.fhir.us.ccda", "1.0.0");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// if (npm.url() == null || !npm.url().equals(u)) {
|
||||
// npm.getNpm().remove("url");
|
||||
// npm.getNpm().addProperty("url", u);
|
||||
// save = true;
|
||||
// }
|
||||
// if (!npm.canonical().startsWith("http://hl7.org")) {
|
||||
// npm.getNpm().remove("canonical");
|
||||
// npm.getNpm().addProperty("canonical", "http://hl7.org/fhir/smart-app-launch");
|
||||
// save = true;
|
||||
// }
|
||||
//
|
||||
if (save) {
|
||||
npm.save(new FileOutputStream(filename));
|
||||
File bck = new File(Utilities.changeFileExt(file.getAbsolutePath(), ".bcknpm"));
|
||||
if (bck.exists()) {
|
||||
bck.delete();
|
||||
}
|
||||
file.renameTo(bck);
|
||||
npm.save(new FileOutputStream(file));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -794,16 +794,7 @@ public class ValidationEngine implements IValidatorResourceFetcher {
|
|||
for (Entry<String, byte[]> t : source.entrySet()) {
|
||||
String fn = t.getKey();
|
||||
if (!exemptFile(fn)) {
|
||||
if (debug)
|
||||
System.out.print("* load file: "+fn);
|
||||
Resource r = null;
|
||||
try {
|
||||
r = loadResourceByVersion(version, t.getValue(), fn);
|
||||
if (debug)
|
||||
System.out.println(" .. success");
|
||||
} catch (Exception e) {
|
||||
System.out.println(" - ignored due to error: "+e.getMessage());
|
||||
}
|
||||
Resource r = loadFileWithErrorChecking(version, t, fn);
|
||||
if (r != null) {
|
||||
context.cacheResource(r);
|
||||
if (r instanceof ImplementationGuide) {
|
||||
|
@ -821,6 +812,25 @@ public class ValidationEngine implements IValidatorResourceFetcher {
|
|||
grabNatives(source, canonical);
|
||||
}
|
||||
|
||||
public Resource loadFileWithErrorChecking(String version, Entry<String, byte[]> t, String fn) {
|
||||
if (debug)
|
||||
System.out.print("* load file: "+fn);
|
||||
Resource r = null;
|
||||
try {
|
||||
r = loadResourceByVersion(version, t.getValue(), fn);
|
||||
if (debug)
|
||||
System.out.println(" .. success");
|
||||
} catch (Exception e) {
|
||||
if (!debug) {
|
||||
System.out.print("* load file: "+fn);
|
||||
}
|
||||
System.out.println(" - ignored due to error: "+(e.getMessage() == null ? " (null - NPE)" : e.getMessage()));
|
||||
if (debug)
|
||||
e.printStackTrace();
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
public Resource loadResourceByVersion(String version, byte[] content, String fn) throws IOException, Exception {
|
||||
Resource r;
|
||||
if (version.startsWith("3.0")) {
|
||||
|
|
Loading…
Reference in New Issue