use of it.cnr.ict.domain.User in project cool-jconon by consiglionazionaledellericerche.
the class HelpdeskService method inserisciEsperto.
private void inserisciEsperto(String uid) {
if (!existUser(uid)) {
CMISUser cmisUser = userService.loadUserForConfirm(uid);
User user = new User();
user.setFirstName(cmisUser.getFirstName());
user.setFamilyName(cmisUser.getLastName());
user.setLogin(cmisUser.getId());
user.setEmail(cmisUser.getEmail());
user.setProfile(profilo);
user.setPassword(newUserPassord);
user.setStruttura(struttura);
user.setMailStop(mailStop);
try {
oilService.ifPresent(oil -> oil.addUser(user));
} catch (FeignException _ex) {
LOGGER.warn("Create user on OIL error: {}", _ex.getMessage());
}
}
}
use of it.cnr.ict.domain.User in project cool-jconon by consiglionazionaledellericerche.
the class HelpdeskService method sendMessage.
protected void sendMessage(HelpdeskBean hdBean, MultipartFile allegato, CMISUser user) throws MailException, IOException {
StringBuilder subject = new StringBuilder();
subject.append(hdBean.getCall() + " - " + hdBean.getSubject());
// aggiunge il footer al messaggio
StringBuilder testo = new StringBuilder();
testo.append(hdBean.getMessage());
testo.append("\n\n");
testo.append("Utente: ");
testo.append(hdBean.getFirstName());
testo.append(" ");
testo.append(hdBean.getLastName());
if (Optional.ofNullable(hdBean.getMatricola()).isPresent()) {
testo.append(" Matricola: ");
testo.append(hdBean.getMatricola());
}
testo.append(" Email: ");
testo.append(hdBean.getEmail());
if (Optional.ofNullable(hdBean.getPhoneNumber()).isPresent()) {
testo.append(" Tel: ");
testo.append(hdBean.getPhoneNumber());
}
testo.append(" Data: ");
DateFormat formatter = new SimpleDateFormat("dd.MM.yyyy (HH:mm:ss)");
testo.append(formatter.format(Calendar.getInstance().getTime()));
testo.append(" IP: ");
testo.append(hdBean.getIp());
ExternalProblem externalProblem = new ExternalProblem();
externalProblem.setFirstName(hdBean.getFirstName());
externalProblem.setFamilyName(hdBean.getLastName());
externalProblem.setEmail(hdBean.getEmail());
externalProblem.setConfirmRequested(Optional.ofNullable(user).filter(cmisUser -> cmisUser.isGuest()).map(s -> "y").orElse("n"));
externalProblem.setTitolo(subject.toString());
externalProblem.setDescrizione(testo.toString());
externalProblem.setStato(State.APERTA);
externalProblem.setCategoria(Integer.valueOf(hdBean.getCategory()));
final Optional<Long> idSegnalazione = oilService.map(oil -> oil.newProblem(externalProblem));
if (allegato != null && !allegato.isEmpty() && idSegnalazione.isPresent()) {
FormData formData = new FormData(allegato.getContentType(), allegato.getOriginalFilename(), allegato.getBytes());
oilService.ifPresent(oil -> oil.addAttachments(idSegnalazione.get(), formData));
}
}
Aggregations