fix errors caused by using the same list for versioned and unversioned entries

This commit is contained in:
sebg-mio42 2024-12-06 16:55:46 +01:00
parent 236ed52735
commit 5c1fac1a05
1 changed files with 26 additions and 11 deletions

View File

@ -1049,25 +1049,40 @@ public class BaseValidator implements IValidationContextResourceLoader, IMessagi
if (resource != null) { if (resource != null) {
String et = resource.getType(); String et = resource.getType();
String eid = resource.getNamedChildValue(ID, false); String eid = resource.getNamedChildValue(ID, false);
String rl = null;
if (eid != null) { if (eid != null) {
String rl = et+"/"+eid; rl = et+"/"+eid;
list = relMap.get(rl); list = relMap.get(rl);
if (list == null) { if (list == null) {
list = new ArrayList<Element>(); list = new ArrayList<Element>();
relMap.put(rl, list); relMap.put(rl, list);
boolean versionIdPresent = resource.hasChild(META, false)
&& resource.getNamedChild(META, false).hasChild(VERSION_ID, false)
&& resource.getNamedChild(META, false).getNamedChild(VERSION_ID, false).hasValue();
if (versionIdPresent){
String versionId = resource.getNamedChild(META).getNamedChild(VERSION_ID).getValue();
String fullUrlVersioned = fu + "/_history/" + versionId;
String relativePathVersioned = rl + "/_history/" + versionId;
relMap.put(relativePathVersioned, list);
map.put(fullUrlVersioned, list);
}
} }
list.add(entry); list.add(entry);
} }
boolean versionIdPresent = resource.hasChild(META, false)
&& resource.getNamedChild(META, false).hasChild(VERSION_ID, false)
&& resource.getNamedChild(META, false).getNamedChild(VERSION_ID, false).hasValue();
if (versionIdPresent){
String versionId = resource.getNamedChild(META).getNamedChild(VERSION_ID).getValue();
String fullUrlVersioned = fu + "/_history/" + versionId;
List<Element> listMapVersioned = null;
listMapVersioned = map.get(fullUrlVersioned);
if (listMapVersioned == null) {
listMapVersioned = new ArrayList<Element>();
map.put(fullUrlVersioned, listMapVersioned);
}
listMapVersioned.add(entry);
if (rl != null) {
String relativePathVersioned = rl + "/_history/" + versionId;
List<Element> listRelMapVersioned = null;
listRelMapVersioned = relMap.get(relativePathVersioned);
if (listRelMapVersioned == null) {
listRelMapVersioned = new ArrayList<Element>();
relMap.put(relativePathVersioned, listRelMapVersioned);
}
listRelMapVersioned.add(entry);
}
}
} }
} }
} }