Set<String> ignored, boolean folderNameIsLabelcode, boolean lookupLabelcodeInNfo) {
for (Folder f : list) {
if (f.findLabelcode() == null) { // no label code for this folder yet => assign
CatalogNumberHibernateImpl lc = null;
// walk bottom up and try to find label code
Folder cur = f;
if (folderNameIsLabelcode) {
while(cur.getParent().getName() != null) { // walk until root
lc = LabelcodeMatcher.findLabelcode(cur.getName());
if (lc == null) {
lc = LabelcodeMatcher.findLabelcode2(cur.getName());
}
if (lc != null) {
break;
}
cur = (Folder) cur.getParent();
}
} else {
while(cur.getParent().getName() != null // walk until root
&& (lc = LabelcodeMatcher.findLabelcode(cur.getName())) == null) {
cur = (Folder) cur.getParent();
}
}
if (lc != null) { // got label code from folder => confirm
if(!addLabelCode(interaction, labelCodes, ignored, cur, lc)) {
// not confirmed => try get from nfo if indicated