Search in sources :

Example 1 with User

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());
        }
    }
}
Also used : User(it.cnr.ict.domain.User) CMISUser(it.cnr.cool.security.service.impl.alfresco.CMISUser) CMISUser(it.cnr.cool.security.service.impl.alfresco.CMISUser) FeignException(feign.FeignException)

Example 2 with User

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));
    }
}
Also used : CMISService(it.cnr.cool.cmis.service.CMISService) User(it.cnr.ict.domain.User) LoggerFactory(org.slf4j.LoggerFactory) CmisObjectNotFoundException(org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException) Autowired(org.springframework.beans.factory.annotation.Autowired) SimpleDateFormat(java.text.SimpleDateFormat) OilService(it.cnr.ict.service.OilService) Value(org.springframework.beans.factory.annotation.Value) JSONObject(org.json.JSONObject) Calendar(java.util.Calendar) Service(org.springframework.stereotype.Service) State(it.cnr.ict.domain.State) UrlBuilder(org.apache.chemistry.opencmis.commons.impl.UrlBuilder) DateFormat(java.text.DateFormat) FeignException(feign.FeignException) CmisBindingsHelper(org.apache.chemistry.opencmis.client.bindings.impl.CmisBindingsHelper) Response(org.apache.chemistry.opencmis.client.bindings.spi.http.Response) Logger(org.slf4j.Logger) IOException(java.io.IOException) StringUtil(it.cnr.cool.util.StringUtil) CMISUser(it.cnr.cool.security.service.impl.alfresco.CMISUser) HttpStatus(org.springframework.http.HttpStatus) Category(it.cnr.ict.domain.Category) HelpDeskNotConfiguredException(it.cnr.si.cool.jconon.exception.HelpDeskNotConfiguredException) FormData(feign.form.FormData) MultipartFile(org.springframework.web.multipart.MultipartFile) Optional(java.util.Optional) ExternalProblem(it.cnr.ict.domain.ExternalProblem) MailException(org.springframework.mail.MailException) UserService(it.cnr.cool.security.service.UserService) Collections(java.util.Collections) HelpdeskBean(it.cnr.si.cool.jconon.model.HelpdeskBean) I18nService(it.cnr.cool.service.I18nService) FormData(feign.form.FormData) ExternalProblem(it.cnr.ict.domain.ExternalProblem) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) SimpleDateFormat(java.text.SimpleDateFormat)

Aggregations

FeignException (feign.FeignException)2 CMISUser (it.cnr.cool.security.service.impl.alfresco.CMISUser)2 User (it.cnr.ict.domain.User)2 FormData (feign.form.FormData)1 CMISService (it.cnr.cool.cmis.service.CMISService)1 UserService (it.cnr.cool.security.service.UserService)1 I18nService (it.cnr.cool.service.I18nService)1 StringUtil (it.cnr.cool.util.StringUtil)1 Category (it.cnr.ict.domain.Category)1 ExternalProblem (it.cnr.ict.domain.ExternalProblem)1 State (it.cnr.ict.domain.State)1 OilService (it.cnr.ict.service.OilService)1 HelpDeskNotConfiguredException (it.cnr.si.cool.jconon.exception.HelpDeskNotConfiguredException)1 HelpdeskBean (it.cnr.si.cool.jconon.model.HelpdeskBean)1 IOException (java.io.IOException)1 DateFormat (java.text.DateFormat)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Calendar (java.util.Calendar)1 Collections (java.util.Collections)1 Optional (java.util.Optional)1