Search in sources :

Example 1 with IllegalTransitionException

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;
}
Also used : IllegalTransitionException(org.meveo.admin.exception.IllegalTransitionException) BundleKey(org.jboss.seam.international.status.builder.BundleKey) File(java.io.File) IllegalTransitionException(org.meveo.admin.exception.IllegalTransitionException) ELException(org.meveo.elresolver.ELException) NamingException(javax.naming.NamingException) BusinessException(org.meveo.admin.exception.BusinessException) ActionMethod(org.meveo.admin.web.interceptor.ActionMethod)

Aggregations

File (java.io.File)1 NamingException (javax.naming.NamingException)1 BundleKey (org.jboss.seam.international.status.builder.BundleKey)1 BusinessException (org.meveo.admin.exception.BusinessException)1 IllegalTransitionException (org.meveo.admin.exception.IllegalTransitionException)1 ActionMethod (org.meveo.admin.web.interceptor.ActionMethod)1 ELException (org.meveo.elresolver.ELException)1