Example usage for org.apache.commons.lang StringUtils defaultIfBlank

List of usage examples for org.apache.commons.lang StringUtils defaultIfBlank

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils defaultIfBlank.

Prototype

public static String defaultIfBlank(String str, String defaultStr) 

Source Link

Document

Returns either the passed in String, or if the String is whitespace, empty ("") or null, the value of defaultStr.

Usage

From source file:org.sonarsource.sonarlint.core.container.analysis.issue.ignore.pattern.AbstractPatternInitializer.java

@VisibleForTesting
protected final void initPatterns() {
    // Patterns Multicriteria
    multicriteriaPatterns = new ArrayList<>();
    String patternConf = StringUtils.defaultIfBlank(settings.getString(getMulticriteriaConfigurationKey()), "");
    for (String id : StringUtils.split(patternConf, ',')) {
        String propPrefix = getMulticriteriaConfigurationKey() + "." + id + ".";
        String resourceKeyPattern = settings.getString(propPrefix + "resourceKey");
        String ruleKeyPattern = settings.getString(propPrefix + "ruleKey");
        IssuePattern pattern = new IssuePattern(firstNonNull(resourceKeyPattern, "*"),
                firstNonNull(ruleKeyPattern, "*"));
        multicriteriaPatterns.add(pattern);
    }/*ww w. j a  va 2 s .  c o m*/
}

From source file:org.springframework.data.keyvalue.riak.mapreduce.RiakLinkPhase.java

public String toUrlFormat() {
    String bucket = StringUtils.defaultIfBlank(getBucket(), "_");
    String tag = StringUtils.defaultIfBlank(getTag(), "_");
    String keep = super.getKeep() == null ? "_" : BooleanUtils.toIntegerObject(super.getKeep()).toString();

    return bucket + "," + tag + "," + keep;
}

From source file:org.unitedinternet.cosmo.acegisecurity.userdetails.CosmoUserDetailsService.java

public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException {
    carldav.entity.User user = userRepository.findByEmailIgnoreCase(username);
    if (user == null) {
        throw new UsernameNotFoundException("user " + username + " not found");
    }//from  w w w.  j  ava2s .  c o  m

    final boolean accountNonLocked = !user.isLocked();
    final List<GrantedAuthority> authorities = AuthorityUtils
            .createAuthorityList(StringUtils.defaultIfBlank(user.getRole(), "ROLE_USER"));

    return new User(user.getEmail(), user.getPassword(), true, true, true, accountNonLocked, authorities);
}

From source file:org.xenei.jdbc4sparql.J4SUrl.java

/**
 * Parse an argument out of the URL string section.
 *
 * Should be of the form x=y[:|&]//from  w w w  . ja va2s.  com
 *
 * @param urlStr
 * @param startPos
 */
private void parseJ4SArgs(final String urlStr, final int startPos) {

    int pos = startPos;
    // (arg)=(val)(:|&)
    final Pattern pattern = Pattern.compile("(([a-zA-Z]+)(\\=([^:\\&]+))?([:|\\&])).+");
    Matcher matcher = pattern.matcher(urlStr.substring(startPos));

    while (matcher.matches()) {
        final String arg = matcher.group(2);
        boolean found = false;
        for (final String validArg : J4SUrl.ARGS) {
            found |= validArg.equalsIgnoreCase(arg);
        }
        if (!found) {
            throw new IllegalArgumentException(
                    "Not a valid J4S JDBC URL -- '" + arg + "' is not a recognized argument");
        }
        properties.put(arg, StringUtils.defaultIfBlank(matcher.group(4), ""));
        pos += matcher.group(1).length();
        if (":".equals(matcher.group(5))) {
            matcher = pattern.matcher("");
        } else {
            matcher = pattern.matcher(urlStr.substring(pos));
        }
    }

    // check for valid type value and make sure it is upper case.
    // valid type is a Jena Lang.
    if (properties.containsKey(J4SPropertyNames.TYPE_PROPERTY)) {
        final String type = properties.getProperty(J4SPropertyNames.TYPE_PROPERTY);
        if (type.equalsIgnoreCase(J4SUrl.TYPE_SPARQL)) {
            properties.setProperty(J4SPropertyNames.TYPE_PROPERTY, J4SUrl.TYPE_SPARQL);
        } else {
            final Lang l = RDFLanguages.nameToLang(type);
            if (l != null) {
                properties.setProperty(J4SPropertyNames.TYPE_PROPERTY, l.getName());
            } else {
                throw new IllegalArgumentException(
                        "Not a valid J4S JDBC URL -- '" + type + "' is not a recognized type value");
            }
        }
    }
    if (properties.containsKey(J4SPropertyNames.PARSER_PROPERTY)) {
        // verify we can load the parser
        parser = SparqlParser.Util.getParser(properties.getProperty(J4SPropertyNames.PARSER_PROPERTY));
    }
    if (properties.containsKey(J4SPropertyNames.BUILDER_PROPERTY)) {
        // verify we can load the builder
        builder = SchemaBuilder.Util.getBuilder(properties.getProperty(J4SPropertyNames.BUILDER_PROPERTY));
    }
    parseJ4SEndpoint(urlStr, pos);
}

From source file:ucv1ap101.ejb.business.process.logic.impl.InvitacionBusinessProcessLogicImpl.java

/**
 * SYNCHRONOUS INSTANCE PROCESS enviar./*  w  ww .jav a2 s  .c  om*/
 *
 * @param message
 * @param instance
 * @throws java.lang.Exception
 */
@Override
public void enviar(InvitacionEnviarMessage message, Invitacion instance) throws Exception {
    if (message == null) {
        throw new IllegalArgumentException(InvitacionEnviarMessage.class.getSimpleName());
    }
    if (instance == null) {
        throw new IllegalArgumentException(Invitacion.class.getSimpleName());
    }
    boolean rejected = !processor.enviarAllowed(message, instance);
    if (rejected) {
        throw new ExcepcionAplicacion(TLC.getBitacora().getLogString());
    }
    //      logician.enviar(message, instance);
    instance.setEstado(estadoInvitacionFacade.find(EstadoInvitacionEnumeration.ENVIADA.intValue()));
    instance.setFechaHoraEstado(TimeUtils.currentTimestamp());
    /**/
    String correo = instance.getInvitado().getCorreoElectronico();
    if (StringUtils.isNotBlank(correo)) {
        String asunto = instance.getReunion().getAsunto();
        String nombre = instance.getInvitado().getNombre();
        String agenda = instance.getReunion().getAgenda();
        Sala sala = instance.getReunion().getSala();
        String lugar = sala == null ? "An no confirmado" : sala.getNombre();
        String fecha = TimeUtils.defaultDateString(instance.getReunion().getFechaInicioPautada());
        String desde = TimeUtils.defaultTimeString(instance.getReunion().getHoraInicioPautada());
        String hasta = TimeUtils.defaultTimeString(instance.getReunion().getHoraFinPautada());
        String mensaje = "Estimado/a " + nombre + ", ";
        mensaje += "\n\nLe invitamos cordialmente a un evento sobre: " + asunto;
        if (agenda != null) {
            mensaje += "\n\nLa agenda del evento es la siguiente:\n\n" + agenda + "\n";
        }
        mensaje += "\n\nLugar: " + lugar;
        mensaje += "\n\nFecha: " + fecha;
        mensaje += "\n\nDesde: " + desde;
        mensaje += "\n\nHasta: " + hasta;
        mensaje += "\n\nHaga clic en este link para aceptar  la invitacin: http://localhost:8080/ucv1ap101-war?cr=3&id="
                + instance.getId();
        mensaje += "\n\nHaga clic en este link para rechazar la invitacin: http://localhost:8080/ucv1ap101-war?cr=4&id="
                + instance.getId();
        enviarCorreo(correo, asunto, StringUtils.defaultIfBlank(mensaje, asunto));
    }
}

From source file:ucv1ap101.ejb.business.process.logic.impl.ReunionBusinessProcessLogicImpl.java

/**
 * SYNCHRONOUS INSTANCE PROCESS convocar.
 *
 * @param message/*w  w  w .  java2s.c  o  m*/
 * @param instance
 * @throws java.lang.Exception
 */
@Override
public void convocar(ReunionConvocarMessage message, Reunion instance) throws Exception {
    if (message == null) {
        throw new IllegalArgumentException(ReunionConvocarMessage.class.getSimpleName());
    }
    if (instance == null) {
        throw new IllegalArgumentException(Reunion.class.getSimpleName());
    }
    boolean rejected = !processor.convocarAllowed(message, instance);
    if (rejected) {
        throw new ExcepcionAplicacion(TLC.getBitacora().getLogString());
    }
    //      logician.convocar(message, instance);
    instance.setEstado(estadoReunionFacade.find(EstadoReunionEnumeration.CONVOCADA.intValue()));
    instance.setFechaHoraEstadoReunion(TimeUtils.currentTimestamp());
    /**/
    String asunto = instance.getAsunto();
    String agenda = instance.getAgenda();
    enviarCorreos(instance, asunto, StringUtils.defaultIfBlank(agenda, asunto));
}

From source file:ucv1ap101.ejb.custom.scheduler.CustomSchedulerBean.java

private void enviarCorreoEncuesta(Reunion reunion) {
    String correo = reunion.getOrganizador().getCorreoElectronico();
    logger.debug(reunion + "/" + correo);
    if (StringUtils.isNotBlank(correo)) {
        String asunto = reunion.getAsunto();
        String nombre = reunion.getOrganizador().getNombreUsuario();
        String mensaje = "Estimado/a " + nombre + ", ";
        mensaje += "\n\nLe invitamos cordialmente a llenar la encuesta de satisfaccion.";
        mensaje += "\n\nHaga clic en este link para ir a la aplicacin: http://localhost:8080/ucv1ap101-war?id="
                + reunion.getId();/*  w w w.j a v  a  2  s. com*/
        enviarCorreo(correo, asunto, StringUtils.defaultIfBlank(mensaje, asunto));
    }
}

From source file:vn.vnpttech.ssdc.nms.mediation.stbacs.utils.XmppUtils.java

public static String getMD5Password(String password, String salt) {
    try {//from  w  w w . ja v a  2  s.c  o m
        String input = StringUtils.defaultIfBlank(salt, RandomStringUtils.random(10)).concat(password);
        MessageDigest md = MessageDigest.getInstance("MD5");

        md.update(input.getBytes());
        byte byteData[] = md.digest();

        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < byteData.length; i++) {
            sb.append(Integer.toString((byteData[i] & 0xff) + 0x100, 16).substring(1));
        }

        return sb.toString();
    } catch (NoSuchAlgorithmException ex) {
        throw new RuntimeException(ex);
    }
}

From source file:vng.paygate.domain.log.impl.LogService.java

@Override
public void generateDataMessage(String... params) {
    for (String param : params) {
        this.data.append(StringUtils.defaultIfBlank(param, "")).append(Constants.TAB);
    }/*from  ww w  .j  a  va 2 s.  c  o  m*/
}