use of org.meveo.admin.exception.BusinessException in project meveo by meveo-org.
the class CustomEntityInstanceObserver method onRemoved.
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public void onRemoved(@Observes(during = TransactionPhase.AFTER_SUCCESS) @Removed CustomEntityInstance cei) throws BusinessException {
log.debug("CEI onRemoved observer={}", cei);
BusinessService businessService = businessServiceFinder.find(cei);
MeveoModule module = businessService.findModuleOf(cei);
try {
if (module != null) {
businessService.removeFilesFromModule(cei, module);
}
} catch (BusinessException e) {
throw new BusinessException("CEI: " + cei.getCode() + " cannot be removed");
}
}
use of org.meveo.admin.exception.BusinessException in project meveo by meveo-org.
the class FilterService method persistCustomFieldTemplates.
private void persistCustomFieldTemplates(Filter filter) throws BusinessException {
try {
List<CustomFieldTemplate> customFieldTemplates = new ArrayList<>();
extractCustomFields(filter, filter.getFilterCondition(), customFieldTemplates);
customFieldTemplateService.createMissingTemplates(filter, customFieldTemplates, true, true);
} catch (CustomFieldException e) {
throw new BusinessException(e);
}
}
use of org.meveo.admin.exception.BusinessException in project meveo by meveo-org.
the class BaseBean method hfHandleFileUpload.
public void hfHandleFileUpload(FileUploadEvent event) throws BusinessException {
uploadedFile = event.getFile();
try {
ImageUploadEventHandler<T> uploadHandler = new ImageUploadEventHandler<T>(currentUser.getProviderCode());
String filename = uploadHandler.handleImageUpload(entity, uploadedFile);
if (filename != null) {
((IImageUpload) entity).setImagePath(filename);
messages.info(new BundleKey("messages", "message.upload.succesful"));
}
} catch (Exception e) {
messages.error(new BundleKey("messages", "message.upload.fail"), e.getMessage());
}
}
use of org.meveo.admin.exception.BusinessException in project meveo by meveo-org.
the class BaseBean method addToModule.
protected void addToModule(T entity, MeveoModule module) throws BusinessException {
BusinessEntity businessEntity = (BusinessEntity) entity;
MeveoModuleItem item = new MeveoModuleItem(businessEntity);
if (!module.getModuleItems().contains(item)) {
try {
meveoModuleService.addModuleItem(item, module);
} catch (BusinessException e2) {
throw new BusinessException("Entity cannot be add or remove from the module", e2);
}
try {
if (!org.meveo.commons.utils.StringUtils.isBlank(module.getModuleSource())) {
module.setModuleSource(JacksonUtil.toString(updateModuleItemDto(module)));
}
meveoModuleService.update(module);
messages.info(businessEntity.getCode() + " added to module " + module.getCode());
} catch (Exception e) {
messages.error(businessEntity.getCode() + " not added to module " + module.getCode(), e);
}
} else {
messages.error(new BundleKey("messages", "meveoModule.error.moduleItemExisted"), businessEntity.getCode(), module.getCode());
return;
}
}
use of org.meveo.admin.exception.BusinessException in project meveo by meveo-org.
the class BaseCrudBean method exportCSV.
public StreamedContent exportCSV() throws IOException, BusinessException, MeveoApiException {
if (baseCrudApi == null) {
throw new BusinessException(getClass().getSimpleName() + " is not using a base crud api");
}
PaginationConfiguration configuration = new PaginationConfiguration(getFilters());
File exportCSV = baseCrudApi.exportCSV(configuration);
DefaultStreamedContent defaultStreamedContent = new DefaultStreamedContent();
defaultStreamedContent.setContentEncoding("UTF-8");
defaultStreamedContent.setContentType("application/csv");
defaultStreamedContent.setStream(new FileInputStream(exportCSV));
defaultStreamedContent.setName(exportCSV.getName());
return defaultStreamedContent;
}
Aggregations