private void processRepresentation(ModelService model, Report report, JobPluginInfo jobPluginInfo, Job job,
List<Representation> representations) {
for (Representation representation : representations) {
Report reportItem = PluginHelper.initPluginReportItem(this, representation.getId(), Representation.class);
PluginHelper.updatePartialJobReport(this, model, reportItem, false, job);
PluginState state = PluginState.SUCCESS;
try {
model.changeRepresentationType(representation.getAipId(), representation.getId(), newType, job.getUsername());
} catch (RequestNotValidException | NotFoundException | GenericException | AuthorizationDeniedException e) {
state = PluginState.FAILURE;
} finally {
jobPluginInfo.incrementObjectsProcessed(state);
reportItem.setPluginState(state);
StringBuilder outcomeText = new StringBuilder().append("The representation '").append(representation.getId())
.append(" of AIP ").append(representation.getAipId()).append("' changed its type from '")
.append(representation.getType()).append("' to '").append(newType).append("'.");
model.createUpdateAIPEvent(representation.getAipId(), representation.getId(), null, null,
PreservationEventType.UPDATE, EVENT_DESCRIPTION, state, outcomeText.toString(), details, job.getUsername(),
true);
report.addReport(reportItem);
PluginHelper.updatePartialJobReport(this, model, reportItem, true, job);
}
}
}