@Override
public ReturnWithExceptions<Void, ModelObserver> dipPermissionsUpdated(DIP dip) {
ReturnWithExceptions<Void, ModelObserver> ret = new ReturnWithExceptions<>(this);
SolrUtils.update(index, IndexedDIP.class, dip.getId(),
SolrUtils.getPermissionsAsPreCalculatedFields(dip.getPermissions()), (ModelObserver) this).addTo(ret);
if (ret.isEmpty()) {
try (CloseableIterable<OptionalWithCause<DIPFile>> allFiles = model.listDIPFilesUnder(dip.getId(), true)) {
for (OptionalWithCause<DIPFile> dipFile : allFiles) {
if (dipFile.isPresent()) {
SolrUtils.update(index, DIPFile.class, IdUtils.getDIPFileId(dipFile.get()),
SolrUtils.getPermissionsAsPreCalculatedFields(dip.getPermissions()), (ModelObserver) this).addTo(ret);
} else {
LOGGER.error("Cannot do a partial update on DIP file", dipFile.getCause());
ret.add(dipFile.getCause());
}
}
} catch (AuthorizationDeniedException | IOException | NotFoundException | GenericException
| RequestNotValidException e) {
LOGGER.error("Cannot do a partial update", e);
ret.add(e);
}
}
return ret;
}