use of org.meveo.admin.exception.IllegalTransitionException in project meveo by meveo-org.
the class CustomEntityInstanceBean method saveOrUpdate.
@Override
@ActionMethod
public String saveOrUpdate(boolean killConversation) throws BusinessException, ELException {
if (StringUtils.isBlank(entity.getCetCode())) {
messages.error(new BundleKey("messages", "customEntityInstance.noCetCodeSet"));
return null;
}
String result = getListViewName();
boolean isNew = StringUtils.isBlank(uuid) || "null".equals(uuid);
try {
customFieldDataEntryBean.saveCustomFieldsToEntity(entity, isNew);
String message = entity.isTransient() ? "save.successful" : "update.successful";
try {
crossStorageService.createOrUpdate(repository, entity);
} catch (IllegalTransitionException e) {
messages.error(new BundleKey("messages", "customEntityInstance.update.illegalTransition"), e.getField(), e.getFrom(), e.getTo());
return null;
}
if (killConversation) {
endConversation();
}
messages.info(new BundleKey("messages", message));
// Delete old binaries
for (String fileToDelete : customFieldDataEntryBean.getFilesToDeleteOnExit()) {
File file = new File(fileToDelete);
if (file.exists()) {
file.delete();
}
}
} catch (Exception e) {
messages.error(new BundleKey("messages", "customEntityInstance.save.ko"));
log.error("Cannot create or update CEI", e);
return null;
}
return result;
}
Aggregations