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

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

Introduction

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

Prototype

public static boolean isEmpty(final CharSequence cs) 

Source Link

Document

Checks if a CharSequence is empty ("") or null.

 StringUtils.isEmpty(null)      = true StringUtils.isEmpty("")        = true StringUtils.isEmpty(" ")       = false StringUtils.isEmpty("bob")     = false StringUtils.isEmpty("  bob  ") = false 

NOTE: This method changed in Lang version 2.0.

Usage

From source file:com.controller.email.GetEmailDetailServlet.java

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
 * methods.//  w ww. j av  a  2s .co m
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    try {
        String mandrillEmailId = request.getParameter("mandrill_email_id");
        if (StringUtils.isEmpty(mandrillEmailId)) {
            Map<String, String> responseMap = new HashMap<>();
            responseMap.put("error", "mandrill_email_id is required request parameter");
            response.getWriter().write(new Gson().toJson(responseMap));
            response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
            return;
        }
        response.getWriter().write(new Gson().toJson(MandrillApiHandler.getEmailDetails(mandrillEmailId)));
        response.getWriter().flush();
        response.setStatus(HttpServletResponse.SC_OK);
        return;
    } catch (URISyntaxException ex) {
        Logger.getLogger(GetEmailDetailServlet.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:de.jaxenter.eesummit.caroline.backend.batches.customerimport.CustomerImportItemProcessor.java

@Override
protected Customer doProcessItem(CustomerCsv customerCsv) {
    if (StringUtils.isEmpty(customerCsv.getFirstName()) || StringUtils.isEmpty(customerCsv.getLastName())) {
        logger.warn("Skipping import of user " + customerCsv.toString());
        return null;
    }//from ww w  .  ja va 2  s .c  o  m

    Customer customer = new Customer();
    customer.setFirstName(customerCsv.getFirstName());
    customer.setLastName(customerCsv.getLastName());

    calculateLoginCredentials(customer);

    return customer;
}

From source file:com.jaeksoft.searchlib.renderer.plugin.AuthPluginHttpHeader.java

@Override
public User getUser(Renderer renderer, HttpServletRequest request) throws IOException {

    String remoteUser = request.getRemoteUser();
    if (remoteUser == null)
        remoteUser = request.getHeader("X-OSS-REMOTE-USER");
    if (StringUtils.isEmpty(remoteUser))
        throw new AuthException("No user");
    String[] groups = null;//from  www .j  a v a  2  s  .c om
    String remoteGroups = request.getHeader("X-OSS-REMOTE-GROUPS");
    if (remoteGroups != null)
        groups = StringUtils.split(remoteGroups, ',');
    User user = new User(remoteUser, remoteUser, null, groups);
    Logging.info(
            "USER authenticated: " + user.userId + " Groups count: " + (groups == null ? 0 : groups.length));
    return user;
}

From source file:de.micromata.genome.util.types.Converter.java

/**
 * Encode url param.//  w w  w  .j av  a  2 s .c  om
 *
 * @param value the value
 * @return the string
 */
public static String encodeUrlParam(String value) {
    if (StringUtils.isEmpty(value) == true) {
        return "";
    }

    try {
        return URLEncoder.encode(value, StandardCharsets.UTF_8.name());
    } catch (UnsupportedEncodingException ex) {
        throw new RuntimeException(ex);
    }
}

From source file:gov.nih.nci.cadsr.cdecurate.dto.AdministeredComponentBean.java

public String getPublicIdVersion() {
    if (StringUtils.isEmpty(getPublicId()) && StringUtils.isEmpty(getVersion())) {
        return "";
    }//  w  ww. jav  a  2 s  .  co m
    publicIdVersion = getPublicId() + "v" + getVersion();
    return publicIdVersion;
}

From source file:gov.nih.nci.caintegrator.common.EmailUtil.java

/**
 * Sends mail based upon input parameters.
 *
 * @param mailRecipients List of strings that are the recipient email addresses
 * @param from the from of the email//from  w w w  . j  av  a  2s  .c  o  m
 * @param mailSubject the subject of the email
 * @param mailBody the body of the email
 * @throws MessagingException thrown if there is a problem sending the message
 */
public static void sendMail(List<String> mailRecipients, String from, String mailSubject, String mailBody)
        throws MessagingException {
    MimeMessage message = constructMessage(mailRecipients, from, mailSubject);

    if (StringUtils.isEmpty(mailBody)) {
        LOG.info("No email body specified");
    }
    message.setText(mailBody);

    LOG.debug("sending email");
    Transport.send(message);
    LOG.debug("email successfully sent");
}

From source file:com.ieasy.basic.util.CookieSupport.java

/**
 * ?cookies/*from www  . j  a v a  2  s . c om*/
 * 
 * @param request
 * @param cookieName
 * @return
 */
public static final Cookie[] readCookies(HttpServletRequest request, String cookieName) {
    Cookie[] cookies = request.getCookies();
    if (cookies == null || cookies.length == 0)
        return null;
    if (StringUtils.isEmpty(cookieName))
        return cookies;
    for (int i = 0; i < cookies.length; i++) {
        if (cookies[i].getName().equals(cookieName))
            return new Cookie[] { cookies[i] };
    }
    return null;
}

From source file:io.cloudslang.lang.runtime.env.ExecutionPath.java

private String getCurrentPath(int position) {
    String parents = getParentPath();
    return StringUtils.isEmpty(parents) ? position + "" : parents + PATH_SEPARATOR + position;
}

From source file:com.netflix.spinnaker.halyard.config.validate.v1.persistentStorage.S3Validator.java

@Override
public void validate(ConfigProblemSetBuilder ps, S3PersistentStore n) {
    if (!StringUtils.isEmpty(n.getEndpoint())) {
        return;//from  ww  w .ja va  2 s. c  o  m
    }

    try {
        AWSCredentialsProvider credentialsProvider = AwsAccountValidator
                .getAwsCredentialsProvider(n.getAccessKeyId(), n.getSecretAccessKey());
        S3Config s3Config = new S3Config();
        S3Properties s3Properties = new S3Properties();
        s3Properties.setBucket(n.getBucket());
        s3Properties.setRootFolder(n.getRootFolder());
        s3Properties.setRegion(n.getRegion());
        AmazonS3 s3Client = s3Config.awsS3Client(credentialsProvider, s3Properties);
        new S3Config().s3StorageService(s3Client, s3Properties);
    } catch (Exception e) {
        ps.addProblem(Problem.Severity.ERROR,
                "Failed to ensure the required bucket \"" + n.getBucket() + "\" exists: " + e.getMessage());
    }
}

From source file:de.micromata.genome.gwiki.controls.GWikiCreateOrShowPage.java

public Object onInit() {
    if (StringUtils.isEmpty(pageId) == true) {
        throw new AuthorizationFailedException("pageId is missing");
    }//from w w  w  .  j av a 2 s .com
    if (wikiContext.getWikiWeb().findElementInfo(pageId) != null) {
        return pageId;
    }
    if (wikiContext.getWikiWeb().getAuthorization().isAllowTo(wikiContext,
            GWikiAuthorizationRights.GWIKI_CREATEPAGES.name()) == false) {
        return "admin/PageNotFound";
    }
    if (StringUtils.isNotBlank(metaTemplatePageId) == true) {

        GWikiMetaTemplate metaTemplate = wikiContext.getWikiWeb().findMetaTemplate(metaTemplatePageId);
        if (wikiContext.getWikiWeb().getAuthorization().isAllowTo(wikiContext,
                metaTemplate.getRequiredEditRight()) == false) {
            return "admin/PageNotFound";
        }
    }
    StringBuilder sb = new StringBuilder();
    sb.append("/edit/EditPage").append("?newPage=true&pageId=").append(Converter.encodeUrlParam(pageId));
    if (StringUtils.isNotBlank(title) == true) {
        sb.append("&title=").append(Converter.encodeUrlParam(title));
    }
    if (StringUtils.isNotBlank(metaTemplatePageId) == true) {
        sb.append("&metaTemplatePageId=").append(Converter.encodeUrlParam(metaTemplatePageId));
    }
    if (StringUtils.isNotBlank(parentPageId) == true) {
        sb.append("&parentPageId=").append(Converter.encodeUrlParam(parentPageId));
    }
    return sb.toString();
}