Example usage for org.apache.commons.lang3 StringUtils lowerCase

List of usage examples for org.apache.commons.lang3 StringUtils lowerCase

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils lowerCase.

Prototype

public static String lowerCase(final String str) 

Source Link

Document

Converts a String to lower case as per String#toLowerCase() .

A null input String returns null .

 StringUtils.lowerCase(null)  = null StringUtils.lowerCase("")    = "" StringUtils.lowerCase("aBc") = "abc" 

Note: As described in the documentation for String#toLowerCase() , the result of this method is affected by the current locale.

Usage

From source file:org.wso2.carbon.identity.recovery.password.SecurityQuestionPasswordRecoveryManager.java

/**
 * Validate requested questions with answered questions
 *
 * @param requestedQuestions       list of questions asked, setIDs
 * @param userChallengeAnswers     list of questions answered
 * @param userUniqueID             unique ID of user
 * @param challengeQuestionManager ChallengeQuestionManager instance
 * @return List of asked questions/*from w w w  . ja va2 s.  c  o m*/
 * @throws IdentityRecoveryException
 */
private List<ChallengeQuestion> getValidatedQuestions(String[] requestedQuestions,
        List<UserChallengeAnswer> userChallengeAnswers, String userUniqueID,
        ChallengeQuestionManager challengeQuestionManager) throws IdentityRecoveryException {

    List<String> userChallengeIds = new ArrayList<>();
    List<ChallengeQuestion> questions = new ArrayList<>();

    userChallengeIds.addAll(userChallengeAnswers.stream()
            .map(answer -> answer.getQuestion().getQuestionSetId().toLowerCase()).collect(Collectors.toList()));

    for (int i = 0; i < requestedQuestions.length; i++) {
        //check whether answered question is available in asked question
        if (!userChallengeIds.contains(StringUtils.lowerCase(requestedQuestions[i]))) {
            throw Utils.handleClientException(
                    IdentityRecoveryConstants.ErrorMessages.ERROR_CODE_NEED_TO_ANSWER_TO_REQUESTED_QUESTIONS,
                    null);
        } else {
            //if answered question is in asked questions
            String q = challengeQuestionManager.getUserChallengeQuestion(userUniqueID, requestedQuestions[i])
                    .getQuestion();
            ChallengeQuestion question = new ChallengeQuestion(requestedQuestions[i], q);
            questions.add(question);
        }
    }
    //list of asked questions
    return questions;
}

From source file:org.xlrnet.metadict.core.query.QueryRequestBuilder.java

/**
 * Set the query string for this request. This is usually the string that will be forwarded to the search backend.
 *
 * @param queryString//w w  w. ja va2  s  .c  o  m
 *         The query string for this request.
 * @return the current builder
 */
public QueryRequestBuilder setQueryString(@NotNull String queryString) {
    checkNotNull(queryString);

    this.queryString = StringUtils.lowerCase(queryString);
    return this;
}

From source file:org.xwiki.edit.internal.XDOMEditorConfiguration.java

@Override
public String getDefaultEditor() {
    String propertyName = "editor";
    String defaultEditor = this.userConfig.getProperty(propertyName, String.class);
    if (StringUtils.isEmpty(defaultEditor)) {
        defaultEditor = this.documentsConfig.getProperty(propertyName, String.class);
        if (StringUtils.isEmpty(defaultEditor)) {
            defaultEditor = this.xwikiConfig.getProperty("xwiki.editor", TextXDOMEditor.ROLE_HINT);
        }/*w w  w.  j  av  a2  s  . c o  m*/
    }
    // We need to keep the value case insensitive for backwards compatibility.
    return StringUtils.lowerCase(defaultEditor);
}

From source file:org.xwiki.platform.search.index.internal.SolrjDocumentData.java

/**
 * @param attachment reference to the attachment.
 * @return the ContentText/*from   ww  w  .ja va2s.c  om*/
 */
private String getContentAsText(AttachmentReference attachment) {
    String contentText = null;

    try {
        Tika tika = new Tika();

        Metadata metadata = new Metadata();
        metadata.set(Metadata.RESOURCE_NAME_KEY, attachment.getName());

        InputStream in = documentAccessBridge.getAttachmentContent(attachment);

        contentText = StringUtils.lowerCase(tika.parseToString(in, metadata));
    } catch (Throwable ex) {
        logger.error("Exception while retrieving attachment content for document " + attachment.getName());
    }

    return contentText;
}

From source file:org.xwiki.search.solr.internal.metadata.AttachmentSolrMetadataExtractor.java

/**
 * Tries to extract text indexable content from a generic attachment.
 * /*from w  w w .j a va 2 s.c  om*/
 * @param attachment reference to the attachment.
 * @return the text representation of the attachment's content.
 * @throws SolrIndexException if problems occur.
 */
protected String getContentAsText(AttachmentReference attachment) throws SolrIndexException {
    try {
        Tika tika = new Tika();

        Metadata metadata = new Metadata();
        metadata.set(Metadata.RESOURCE_NAME_KEY, attachment.getName());

        InputStream in = documentAccessBridge.getAttachmentContent(attachment);

        String result = StringUtils.lowerCase(tika.parseToString(in, metadata));

        return result;
    } catch (Exception e) {
        throw new SolrIndexException(String.format("Failed to retrieve attachment content for '%s'",
                serializer.serialize(attachment)), e);
    }
}

From source file:org.zanata.action.LanguageJoinAction.java

public String getMyLocalisedRoles() {
    if (authenticatedAccount == null) {
        return "";
    }/*from  ww  w  . java2 s . co m*/
    HLocaleMember localeMember = getLocaleMember();
    if (localeMember == null) {
        return "";
    }
    if (localeMember.isCoordinator()) {
        return msgs.format("jsf.language.myRoles", StringUtils.lowerCase(msgs.get("jsf.Coordinator")));
    }
    List<String> roles = Lists.newArrayList();
    if (localeMember.isTranslator()) {
        roles.add(StringUtils.lowerCase(msgs.get("jsf.Translator")));
    }
    if (localeMember.isReviewer()) {
        roles.add(StringUtils.lowerCase(msgs.get("jsf.Reviewer")));
    }
    return msgs.format("jsf.language.myRoles", Joiner.on(" and ").join(roles));
}

From source file:org.zanata.service.impl.RequestServiceImpl.java

private String getRequestRoles(LanguageRequest languageRequest) {
    StringBuilder sb = new StringBuilder();
    if (languageRequest.isCoordinator()) {
        sb.append(StringUtils.lowerCase(msgs.get("jsf.Coordinator")));
    }//  w  ww. j a  va 2s  . com
    if (languageRequest.isReviewer()) {
        sb.append(StringUtils.lowerCase(msgs.get("jsf.Reviewer")));
    }
    if (languageRequest.isTranslator()) {
        sb.append(StringUtils.lowerCase(msgs.get("jsf.Translator")));
    }
    return sb.toString();
}

From source file:pe.gob.mef.gescon.web.ui.ContenidoMB.java

@PostConstruct
public void init() {
    try {//from w  ww. j  a  v a 2 s .co  m
        ContenidoService service = (ContenidoService) ServiceFinder.findBean("ContenidoService");
        this.setListaContenido(service.getContenidos());
        this.setTipoDocumentos(StringUtils.EMPTY);
        this.setTipoVideos(StringUtils.EMPTY);
        this.setTipoAudios(StringUtils.EMPTY);
        this.setTipoImagenes(StringUtils.EMPTY);
        this.setTipoArchivos(StringUtils.EMPTY);
        this.setTipoLinks(StringUtils.EMPTY);
        this.setTipoOtros(StringUtils.EMPTY);
        this.setListaArchivos(new ArrayList<ArchivoConocimiento>());
        this.setListaSourceVinculos(new ArrayList<Consulta>());
        this.setListaTargetVinculos(new ArrayList<Consulta>());
        this.setPickList(
                new DualListModel<Consulta>(this.getListaSourceVinculos(), this.getListaTargetVinculos()));
        ListaSessionMB listaSessionMB = (ListaSessionMB) JSFUtils.getSessionAttribute("listaSessionMB");
        listaSessionMB = listaSessionMB != null ? listaSessionMB : new ListaSessionMB();
        for (SelectItem s : listaSessionMB.getListaTipoDocumentosActivos()) {
            this.setTipoDocumentos(this.getTipoDocumentos()
                    .concat(StringUtils.capitalize(StringUtils.lowerCase(s.getLabel())).concat(", ")));
        }
        for (SelectItem s : listaSessionMB.getListaTipoVideosActivos()) {
            this.setTipoVideos(this.getTipoVideos()
                    .concat(StringUtils.capitalize(StringUtils.lowerCase(s.getLabel())).concat(", ")));
        }
        for (SelectItem s : listaSessionMB.getListaTipoAudiosActivos()) {
            this.setTipoAudios(this.getTipoAudios()
                    .concat(StringUtils.capitalize(StringUtils.lowerCase(s.getLabel())).concat(", ")));
        }
        for (SelectItem s : listaSessionMB.getListaTipoImagenesActivas()) {
            this.setTipoImagenes(this.getTipoImagenes()
                    .concat(StringUtils.capitalize(StringUtils.lowerCase(s.getLabel())).concat(", ")));
        }
        for (SelectItem s : listaSessionMB.getListaTipoArchivosTextoActivos()) {
            this.setTipoArchivos(this.getTipoArchivos()
                    .concat(StringUtils.capitalize(StringUtils.lowerCase(s.getLabel())).concat(", ")));
        }
        for (SelectItem s : listaSessionMB.getListaTipoLinksActivos()) {
            this.setTipoLinks(this.getTipoLinks()
                    .concat(StringUtils.capitalize(StringUtils.lowerCase(s.getLabel())).concat(", ")));
        }
        for (SelectItem s : listaSessionMB.getListaTipoOtrosArchivosActivos()) {
            this.setTipoOtros(this.getTipoOtros()
                    .concat(StringUtils.capitalize(StringUtils.lowerCase(s.getLabel())).concat(", ")));
        }
        this.setTipoDocumentos(
                this.getTipoDocumentos().substring(0, this.getTipoDocumentos().lastIndexOf(",")));
        this.setTipoVideos(this.getTipoVideos().substring(0, this.getTipoVideos().lastIndexOf(",")));
        this.setTipoAudios(this.getTipoAudios().substring(0, this.getTipoAudios().lastIndexOf(",")));
        this.setTipoImagenes(this.getTipoImagenes().substring(0, this.getTipoImagenes().lastIndexOf(",")));
        this.setTipoArchivos(this.getTipoArchivos().substring(0, this.getTipoArchivos().lastIndexOf(",")));
        this.setTipoLinks(this.getTipoLinks().substring(0, this.getTipoLinks().lastIndexOf(",")));
        this.setTipoOtros(this.getTipoOtros().substring(0, this.getTipoOtros().lastIndexOf(",")));
    } catch (Exception e) {
        e.getMessage();
        e.printStackTrace();
    }
}

From source file:pe.gob.mef.gescon.web.ui.UserMB.java

public void save(ActionEvent event) {
    try {//  w w  w .  j  a v  a 2 s . co  m
        if (StringUtils.isBlank(this.getDni())) {
            FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, "ERROR.",
                    "Ingrese el DNI del usuario a registrar.");
            FacesContext.getCurrentInstance().addMessage(null, message);
            return;
        }
        if (StringUtils.isBlank(this.getNombres())) {
            FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, "ERROR.",
                    "Ingrese el nombre del usuario a registrar.");
            FacesContext.getCurrentInstance().addMessage(null, message);
            return;
        }
        if (StringUtils.isBlank(this.getApellidos())) {
            FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, "ERROR.",
                    "Ingrese el apellido del usuario a registrar.");
            FacesContext.getCurrentInstance().addMessage(null, message);
            return;
        }
        if (this.getFechaNacimiento() == null) {
            FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, "ERROR.",
                    "Ingrese la fecha de nacimiento del usuario a registrar.");
            FacesContext.getCurrentInstance().addMessage(null, message);
            return;
        }
        if (StringUtils.isBlank(this.getCorreo())) {
            FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, "ERROR.",
                    "Ingrese el correo electrnico del usuario a registrar.");
            FacesContext.getCurrentInstance().addMessage(null, message);
            return;
        }
        if (StringUtils.isBlank(this.getDepartamento())) {
            FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, "ERROR.",
                    "Seleccione el departamento del lugar de residencia.");
            FacesContext.getCurrentInstance().addMessage(null, message);
            return;
        }
        if (StringUtils.isBlank(this.getProvincia())) {
            FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, "ERROR.",
                    "Seleccione la provincia del lugar de residencia.");
            FacesContext.getCurrentInstance().addMessage(null, message);
            return;
        }
        if (StringUtils.isBlank(this.getDistrito())) {
            FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, "ERROR.",
                    "Seleccione el distrito del lugar de residencia.");
            FacesContext.getCurrentInstance().addMessage(null, message);
            return;
        }
        UserService service = (UserService) ServiceFinder.findBean("UserService");
        User user = service.getUserByDNI(this.getDni());
        if (user != null) {
            FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, "ERROR.",
                    "El DNI ingresado ya se encuentra registrado.");
            FacesContext.getCurrentInstance().addMessage(null, message);
            return;
        }
        user = service.getUserByLogin(this.getLogin());
        if (user != null) {
            FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, "ERROR.",
                    "El nombre de usuario ingresado ya se encuentra registrado.");
            FacesContext.getCurrentInstance().addMessage(null, message);
            return;
        }
        ResourceBundle bundle = ResourceBundle.getBundle(Parameters.getMessages());
        String usuarioexterno = bundle.getString("usuarioexterno");

        user = new User();
        user.setNusuarioid(service.getNextPK());
        user.setVnombres(StringUtils.capitalize(this.getNombres()));
        user.setVapellidos(StringUtils.capitalize(this.getApellidos()));
        user.setVlogin(StringUtils.lowerCase(this.getLogin()));
        user.setDfechanacimiento(this.getFechaNacimiento());
        user.setVsexo(this.getSexo());
        user.setVdni(this.getDni());
        user.setVcorreo(this.getCorreo());
        user.setVdpto(this.getDepartamento());
        user.setVprov(this.getProvincia());
        user.setVdist(this.getDistrito());
        user.setVprofesion(this.getProfesion());
        user.setVentidad(this.getEntidad());
        user.setVpliego(this.getPliego());
        user.setVcargo(this.getCargo());
        user.setVarea(this.getArea());
        user.setVsector(this.getSector());
        user.setVgobierno(this.getGobierno());
        user.setNestado(BigDecimal.ONE);
        user.setNactivo(BigDecimal.ONE);
        user.setNperfilid(BigDecimal.valueOf(Long.parseLong(usuarioexterno)));
        user.setNuserinterno(BigDecimal.ZERO);
        user.setDfechacreacion(new Date());
        user.setVusuariocreacion(this.getLogin());
        service.saveOrUpdate(user);

        ParametroService parametroService = (ParametroService) ServiceFinder.findBean("ParametroService");
        Parametro passDefault = parametroService
                .getParametroById(BigDecimal.valueOf(Long.parseLong(Constante.CLAVE_DEFAULT)));

        TpassId tpassid = new TpassId();
        PassService passservice = (PassService) ServiceFinder.findBean("PassService");
        tpassid.setNpassid(passservice.getNextPK());
        tpassid.setNusuarioid(user.getNusuarioid());
        Pass pass = new Pass();
        pass.setId(tpassid);
        pass.setVclave(passDefault.getVvalor());
        pass.setDfechacreacion(new Date());
        pass.setVusuariocreacion(this.getLogin());
        passservice.saveOrUpdate(pass);

        if (this.getCroppedImage() != null) {
            String pathImage = this.path + File.separator + user.getNusuarioid() + File.separator;
            this.saveFile(pathImage, this.photoFileName, croppedImage.getBytes());
        }

        TuserPerfilId tuserPerfilId = new TuserPerfilId();
        tuserPerfilId.setNusuarioid(user.getNusuarioid());
        tuserPerfilId.setNperfilid(BigDecimal.valueOf(Long.parseLong(usuarioexterno)));
        TuserPerfil tuserPerfil = new TuserPerfil();
        tuserPerfil.setId(tuserPerfilId);
        tuserPerfil.setNperfilid(tuserPerfilId.getNperfilid());
        tuserPerfil.setNusuarioid(tuserPerfilId.getNusuarioid());
        tuserPerfil.setDfechacreacion(new Date());
        tuserPerfil.setVusuariocreacion(this.getLogin());
        service.asignProfileToUser(tuserPerfil);

        try {
            MailUtils.sendMail(user.getVcorreo(), "GESCON MEF - Usuario Creado",
                    getSaveBodyMail(user.getVlogin(), pass.getVclave()));
            FacesContext.getCurrentInstance().getExternalContext().redirect("/gescon/index.xhtml");
        } catch (Exception e) {
            FacesContext.getCurrentInstance().getExternalContext().redirect("/gescon/index.xhtml");
        }
    } catch (Exception e) {
        log.error(e.getMessage());
        e.printStackTrace();
    }
}

From source file:pe.gob.mef.gescon.web.ui.UserMB.java

public void saveadm(ActionEvent event) {

    try {//from   w  ww .j a  v a  2 s  .  com
        if (StringUtils.isBlank(this.getTrabajaMef())) {
            FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, "ERROR.",
                    "Indique si el usuario a registra labora en el MEF.");
            FacesContext.getCurrentInstance().addMessage(null, message);
            return;
        }
        if (StringUtils.isBlank(this.getDni())) {
            FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, "ERROR.",
                    "Ingrese el DNI del usuario a registrar.");
            FacesContext.getCurrentInstance().addMessage(null, message);
            return;
        }
        if (StringUtils.isBlank(this.getNombres())) {
            FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, "ERROR.",
                    "Ingrese el nombre del usuario a registrar.");
            FacesContext.getCurrentInstance().addMessage(null, message);
            return;
        }
        if (StringUtils.isBlank(this.getApellidos())) {
            FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, "ERROR.",
                    "Ingrese el apellido del usuario a registrar.");
            FacesContext.getCurrentInstance().addMessage(null, message);
            return;
        }
        if (StringUtils.isBlank(this.getPerfil()) && this.getTrabajaMef().equals(BigDecimal.ONE.toString())) {
            FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, "ERROR.",
                    "Seleccione el perfil del usuario a registrar.");
            FacesContext.getCurrentInstance().addMessage(null, message);
            return;
        }
        if (this.getFechaNacimiento() == null) {
            FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, "ERROR.",
                    "Ingrese la fecha de nacimiento del usuario a registrar.");
            FacesContext.getCurrentInstance().addMessage(null, message);
            return;
        }
        if (StringUtils.isBlank(this.getCorreo())) {
            FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, "ERROR.",
                    "Ingrese el correo electrnico del usuario a registrar.");
            FacesContext.getCurrentInstance().addMessage(null, message);
            return;
        }
        if (StringUtils.isBlank(this.getDepartamento())) {
            FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, "ERROR.",
                    "Seleccione el departamento del lugar de residencia.");
            FacesContext.getCurrentInstance().addMessage(null, message);
            return;
        }
        if (StringUtils.isBlank(this.getProvincia())) {
            FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, "ERROR.",
                    "Seleccione la provincia del lugar de residencia.");
            FacesContext.getCurrentInstance().addMessage(null, message);
            return;
        }
        if (StringUtils.isBlank(this.getDistrito())) {
            FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, "ERROR.",
                    "Seleccione el distrito del lugar de residencia.");
            FacesContext.getCurrentInstance().addMessage(null, message);
            return;
        }
        UserService userService = (UserService) ServiceFinder.findBean("UserService");
        User user = userService.getUserByDNI(this.getDni());
        if (user != null) {
            FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, "ERROR.",
                    "El DNI ingresado ya se encuentra registrado.");
            FacesContext.getCurrentInstance().addMessage(null, message);
            return;
        }
        user = userService.getUserByLogin(this.getLogin());
        if (user != null) {
            FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, "ERROR.",
                    "El nombre de usuario ingresado ya se encuentra registrado.");
            FacesContext.getCurrentInstance().addMessage(null, message);
            return;
        }
        ResourceBundle bundle = ResourceBundle.getBundle(Parameters.getMessages());
        String usuarioexterno = bundle.getString("usuarioexterno");

        LoginMB loginMB = (LoginMB) JSFUtils.getSessionAttribute("loginMB");
        User usuario = loginMB.getUser();
        user = new User();
        user.setNusuarioid(userService.getNextPK());
        user.setVnombres(StringUtils.capitalize(this.getNombres()));
        user.setVapellidos(StringUtils.capitalize(this.getApellidos()));
        user.setVlogin(StringUtils.lowerCase(this.getLogin()));
        user.setDfechanacimiento(this.getFechaNacimiento());
        user.setVsexo(this.getSexo());
        user.setVdni(this.getDni());
        user.setVcorreo(this.getCorreo());
        user.setVdpto(this.getDepartamento());
        user.setVprov(this.getProvincia());
        user.setVdist(this.getDistrito());
        user.setVprofesion(this.getProfesion());
        user.setVentidad(this.getEntidad());
        user.setVpliego(this.getPliego());
        user.setVcargo(this.getCargo());
        user.setVarea(this.getArea());
        user.setVsector(this.getSector());
        user.setVgobierno(this.getGobierno());
        user.setNestado(BigDecimal.ONE);
        user.setNactivo(BigDecimal.ONE);
        user.setNuserinterno(BigDecimal.valueOf(Long.parseLong(this.getTrabajaMef())));
        if (this.getTrabajaMef().equals(BigDecimal.ONE.toString())) {
            user.setNperfilid(BigDecimal.valueOf(Long.parseLong(this.getPerfil())));
        } else {
            user.setNperfilid(BigDecimal.valueOf(Long.parseLong(usuarioexterno)));
        }
        user.setDfechacreacion(new Date());
        user.setVusuariocreacion(usuario.getVlogin());
        userService.saveOrUpdate(user);

        ParametroService parametroService = (ParametroService) ServiceFinder.findBean("ParametroService");
        Parametro passDefault = parametroService
                .getParametroById(BigDecimal.valueOf(Long.parseLong(Constante.CLAVE_DEFAULT)));

        TpassId tpassid = new TpassId();
        PassService passservice = (PassService) ServiceFinder.findBean("PassService");
        tpassid.setNpassid(passservice.getNextPK());
        tpassid.setNusuarioid(user.getNusuarioid());
        Pass pass = new Pass();
        pass.setId(tpassid);
        pass.setVclave(passDefault.getVvalor());
        pass.setDfechacreacion(new Date());
        pass.setVusuariocreacion(usuario.getVlogin());
        passservice.saveOrUpdate(pass);

        if (this.getCroppedImage() != null) {
            String pathImage = this.path + File.separator + user.getNusuarioid() + File.separator;
            this.saveFile(pathImage, this.photoFileName, croppedImage.getBytes());
        }

        TuserPerfilId tuserPerfilId = new TuserPerfilId();
        tuserPerfilId.setNusuarioid(user.getNusuarioid());
        tuserPerfilId.setNperfilid(BigDecimal.valueOf(Long.parseLong(this.getPerfil())));
        TuserPerfil tuserPerfil = new TuserPerfil();
        tuserPerfil.setId(tuserPerfilId);
        tuserPerfil.setNperfilid(tuserPerfilId.getNperfilid());
        tuserPerfil.setNusuarioid(tuserPerfilId.getNusuarioid());
        tuserPerfil.setDfechacreacion(new Date());
        tuserPerfil.setVusuariocreacion(this.getLogin());
        userService.asignProfileToUser(tuserPerfil);

        this.setListaUser(userService.getUsers());
        try {
            MailUtils.sendMail(user.getVcorreo(), "GESCON MEF - Usuario Creado",
                    getSaveBodyMail(user.getVlogin(), pass.getVclave()));
            FacesContext.getCurrentInstance().getExternalContext()
                    .redirect("/gescon/pages/usuarioexterno/lista.xhtml");
        } catch (Exception e) {
            FacesContext.getCurrentInstance().getExternalContext()
                    .redirect("/gescon/pages/usuarioexterno/lista.xhtml");
        }

    } catch (Exception e) {
        e.getMessage();
        e.printStackTrace();
    }
}