String uuid = (String) iter.next();
String id = dm.getMetadataId(uuid);
//--- check access
final MetadataRepository metadataRepository = context.getBean(MetadataRepository.class);
Metadata info = metadataRepository.findOne(id);
if (info == null) {
notFound.add(Integer.valueOf(id));
} else if (!accessMan.isOwner(context, id)) {
notOwner.add(Integer.valueOf(id));
} else {
//--- remove old operations
info.getCategories().clear();
//--- set new ones
@SuppressWarnings("unchecked")
List<Element> list = params.getChildren();
final MetadataCategoryRepository categoryRepository = context.getBean(MetadataCategoryRepository.class);
for (Element el : list) {
String name = el.getName();
if (name.startsWith("_")) {
final MetadataCategory category = categoryRepository.findOne(Integer.valueOf(name.substring(1)));
if (category != null) {
info.getCategories().add(category);
} else {
context.warning("Unable to find category with name: "+name.substring(1));
}
}
}
metadataRepository.save(info);
metadata.add(Integer.valueOf(id));
}
}
}