use of it.cnr.cool.mail.model.EmailMessage in project cool-jconon by consiglionazionaledellericerche.
the class PrintService method schedeNonAnonime.
public void schedeNonAnonime(PrintParameterModel item) {
final Session adminSession = cmisService.createAdminSession();
final String idCall = Optional.ofNullable(item.getIds()).map(List::stream).map(Stream::findFirst).orElseThrow(() -> new ClientMessageException("ID CALL NOT FOUND")).orElseThrow(() -> new ClientMessageException("ID CALL NOT FOUND"));
final String callCodice = adminSession.getObject(idCall).getPropertyValue(JCONONPropertyIds.CALL_CODICE.value());
String messageBody = schedeNonAnonime(adminSession, idCall, item.getContextURL());
EmailMessage message = new EmailMessage();
message.setBody("<b>Il processo di controllo delle schede anonime relative al bando " + callCodice + " è terminato.</b><br>" + messageBody);
message.setHtmlBody(true);
message.setSubject(i18nService.getLabel("subject-info", Locale.ITALIAN) + "Controllo delle schede anonime - " + callCodice);
message.setRecipients(Arrays.asList(item.getIndirizzoEmail()));
mailService.send(message);
}
use of it.cnr.cool.mail.model.EmailMessage in project cool-jconon by consiglionazionaledellericerche.
the class CallService method convocazioniAsync.
@Async("threadPoolTaskExecutor")
public Long convocazioniAsync(Session session, MultipartHttpServletRequest mRequest, BindingSession bindingSession, String contextURL, Locale locale, String userId) throws IOException {
final Long aLong = convocazioni(session, mRequest, bindingSession, contextURL, locale, userId);
CMISUser user = userService.loadUserForConfirm(userId);
EmailMessage message = new EmailMessage();
message.setBody(i18NService.getLabel("message.convocazioni.async.email.body", locale, aLong));
message.setHtmlBody(true);
message.setSubject(i18NService.getLabel("subject-info", locale));
message.setRecipients(Arrays.asList(user.getEmail()));
mailService.send(message);
return aLong;
}
use of it.cnr.cool.mail.model.EmailMessage in project cool-jconon by consiglionazionaledellericerche.
the class CallService method comunicazioniAsync.
@Async("threadPoolTaskExecutor")
public Long comunicazioniAsync(Session session, MultipartHttpServletRequest mRequest, BindingSession bindingSession, String contextURL, Locale locale, String userId) throws IOException {
final Long aLong = comunicazioni(session, mRequest, bindingSession, contextURL, locale, userId);
CMISUser user = userService.loadUserForConfirm(userId);
EmailMessage message = new EmailMessage();
message.setBody(i18NService.getLabel("message.comunicazioni.async.email.body", locale, aLong));
message.setHtmlBody(true);
message.setSubject(i18NService.getLabel("subject-info", locale));
message.setRecipients(Arrays.asList(user.getEmail()));
mailService.send(message);
return aLong;
}
use of it.cnr.cool.mail.model.EmailMessage in project cool-jconon by consiglionazionaledellericerche.
the class PrintService method printApplication.
public void printApplication(String nodeRef, final String contextURL, final Locale locale, final boolean email) {
try {
LOGGER.info("Start print application width id: " + nodeRef);
Session cmisSession = cmisService.createAdminSession();
Folder application = (Folder) cmisSession.getObject(nodeRef);
Boolean confirmed = isConfirmed(application);
Folder call = (Folder) cmisSession.getObject(application.getParentId());
application.refresh();
CMISUser applicationUser;
try {
applicationUser = userService.loadUserForConfirm(application.getPropertyValue(JCONONPropertyIds.APPLICATION_USER.value()));
} catch (CoolUserFactoryException e) {
throw new ClientMessageException("User not found of application " + nodeRef, e);
}
String nameRicevutaReportModel = getNameRicevutaReportModel(cmisSession, application, locale);
byte[] stampaByte = getRicevutaReportModel(cmisSession, application, contextURL, nameRicevutaReportModel, false);
InputStream is = new ByteArrayInputStream(stampaByte);
archiviaRicevutaReportModel(cmisSession, application, is, nameRicevutaReportModel, confirmed);
/**
* Spedisco la mail con la stampa allegata
*/
if (email) {
Map<String, Object> mailModel = new HashMap<String, Object>();
List<String> emailList = new ArrayList<String>();
emailList.add(applicationUser.getEmail());
mailModel.put("contextURL", contextURL);
mailModel.put("folder", application);
mailModel.put("call", call);
mailModel.put("message", context.getBean("messageMethod", locale));
mailModel.put("email_comunicazione", applicationUser.getEmail());
EmailMessage message = new EmailMessage();
message.setRecipients(emailList);
message.setCcRecipients(getCcRecipientsForPrint(confirmed));
message.setBccRecipients(getBccRecipientsForPrint(confirmed));
String body;
if (confirmed) {
body = Util.processTemplate(mailModel, "/pages/application/application.registration.html.ftl");
message.setSubject(i18nService.getLabel("subject-info", locale) + i18nService.getLabel("subject-confirm-domanda", locale, call.getProperty(JCONONPropertyIds.CALL_CODICE.value()).getValueAsString()));
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(JCONONPropertyIds.APPLICATION_DUMMY.value(), "{\"stampa_archiviata\" : true}");
application.updateProperties(properties);
} else {
body = Util.processTemplate(mailModel, "/pages/application/application.print.html.ftl");
message.setSubject(i18nService.getLabel("subject-info", locale) + i18nService.getLabel("subject-print-domanda", locale, call.getProperty(JCONONPropertyIds.CALL_CODICE.value()).getValueAsString()));
}
message.setBody(body);
message.setAttachments(Arrays.asList(new AttachmentBean(nameRicevutaReportModel, stampaByte)));
mailService.send(message);
}
if (LOGGER.isInfoEnabled())
LOGGER.info("End print application width id: " + nodeRef);
} catch (Exception t) {
LOGGER.error("Error while print application width id:" + nodeRef, t);
}
}
use of it.cnr.cool.mail.model.EmailMessage in project cool-jconon by consiglionazionaledellericerche.
the class PrintService method extractionApplication.
public void extractionApplication(PrintParameterModel item) {
String objectId = extractionApplication(cmisService.createAdminSession(), item.getIds(), item.getType(), item.getQueryType(), item.getContextURL(), item.getUserId());
EmailMessage message = new EmailMessage();
message.setBody("<b>Il processo di estrazione è terminato.</b><br>È possibile scaricare il file dal seguente <a href=\"" + item.getContextURL() + "/rest/content?deleteAfterDownload=true&nodeRef=" + objectId + "\">link</a>");
message.setHtmlBody(true);
message.setSubject(i18nService.getLabel("subject-info", Locale.ITALIAN) + "Estrazione");
message.setRecipients(Arrays.asList(item.getIndirizzoEmail()));
mailService.send(message);
}
Aggregations