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

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

Introduction

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

Prototype

public static boolean isNotBlank(String str) 

Source Link

Document

Checks if a String is not empty (""), not null and not whitespace only.

Usage

From source file:com.stoxx.portlet.accountdetails.datatransformer.AccountDetailsTransformer.java

public static List<AccessDetails> convertToAccessDetails(List<UserProfileDetails> licensedUsers,
        String keyAccntEmail) {/*w ww.  j a  va2  s  .  c  om*/
    List<AccessDetails> accessDetailsList = new ArrayList<AccessDetails>();
    int serialNumber = 1;
    for (UserProfileDetails userProfileDetails : licensedUsers) {
        AccessDetails accessDetails = new AccessDetails();
        accessDetails.setSerialNumber(serialNumber + StringPool.BLANK);
        if (StringUtils.isNotBlank(userProfileDetails.getMachineId())) {
            if (userProfileDetails.getMachineId().equals("0")) {
                accessDetails.setMember(userProfileDetails.getEmailAddress());
                accessDetails.setType(STOXXConstants.EMAIL);
            } else {
                if (userProfileDetails.getMachineId().equals("1")) {
                    accessDetails.setMember(userProfileDetails.getEmailAddress());
                    accessDetails.setType(STOXXConstants.MACHINEID);
                }
            }
        } else {
            accessDetails.setMember(userProfileDetails.getEmailAddress());
            accessDetails.setType(STOXXConstants.EMAIL);
        }
        if (!(keyAccntEmail.equalsIgnoreCase(userProfileDetails.getEmailAddress()))) {
            accessDetails.setFlag("0");
        } else {
            accessDetails.setFlag("1");
        }
        accessDetailsList.add(accessDetails);
        serialNumber++;
    }
    return accessDetailsList;
}

From source file:controllers.user.CommentApp.java

@Transactional
public static Result saveComment() throws Exception {
    JsonNode json = getJson();/*from   ww w.j av  a2 s .  c o m*/
    User user = User.getFromSession(session());
    Long toCommentId = json.findPath("toCommentId").asLong();
    int commentLevel = json.findPath("level").asInt(5);
    String content = json.findPath("content").asText();
    String type = json.findPath("type").asText();
    if (StringUtils.isNotBlank(content))
        content = common.SensitiveWordsFilter.doFilter(content);
    if (type.equals("expert")) {
        User toCommentUser = User.findById(toCommentId);
        ExpertComment comment = new ExpertComment(null, user, toCommentUser, content, new java.util.Date(),
                null, commentLevel);
        comment.addExpertComment();
    } else if (type.equals("service")) {
        Service service = Service.queryServiceById(toCommentId);
        ServiceComment comment = new ServiceComment(null, user, service.owner, service, content,
                new java.util.Date(), null, commentLevel);
        comment.addServiceComment();
    }
    return ok(play.libs.Json.toJson(new ResultVO("200", "??")));
}

From source file:com.platform.learn.service.impl.AdminServiceImpl.java

@Override
public User doLogin(String userName, String password) throws Exception {
    User user = null;/*from ww  w  .j  a  v a  2s.  co m*/
    if (StringUtils.isNotBlank(userName) && StringUtils.isNotBlank(password)) {
        user = userDao.doLogin(userName, password);

    }
    return user;
}

From source file:com.zb.app.web.webuser.ZuobianWebUserBuilder.java

/**
 * webUser/*from   w w w.  j  av  a2  s. c om*/
 * 
 * @param cookieManager
 * @return
 */
public static ZuobianWebUser create(CookieManager cookieManager) {
    ZuobianWebUser webUser = new ZuobianWebUser();

    String userName = cookieManager.get(CookieKeyEnum.member_nickname);
    Long mId = NumberUtils.toLong(cookieManager.get(CookieKeyEnum.member_id));
    Long cId = NumberUtils.toLong(cookieManager.get(CookieKeyEnum.member_company_id));
    Integer type = NumberUtils.toInt(cookieManager.get(CookieKeyEnum.member_type));
    Date lastLogin = new Date(NumberUtils.toLong(cookieManager.get(CookieKeyEnum.last_login_time)));

    webUser.setUserName(userName);
    webUser.setmId(mId);
    webUser.setcId(cId);
    webUser.setType(CompanyTypeEnum.getEnum(type));
    webUser.setLastLogin(lastLogin);

    boolean hasLogin = StringUtils.isNotBlank(userName) && mId != null && mId != 0l && cId != null && cId != 0l
            && type != null && type != 0;
    webUser.setHasLogin(hasLogin);

    String cookieId = CookieIdBuilder.getCookieId(cookieManager);
    if (cookieId == null) {
        webUser.setFirstAccess(true);
        cookieId = CookieIdBuilder.createCookieId(cookieManager);
    } else {
        webUser.setFirstAccess(false);
    }
    webUser.setCookieId(cookieId);

    ZuobianWebUser.setCurrentUser(webUser);
    return ZuobianWebUser.getCurrentUser();
}

From source file:edu.usu.sdl.openstorefront.web.rest.model.ComponentMediaView.java

public static ComponentMediaView toView(ComponentMedia media) {
    ComponentMediaView mediaView = new ComponentMediaView();

    if (StringUtils.isNotBlank(media.getFileName())) {
        mediaView.setLink("Media.action?LoadMedia&mediaId=" + media.getComponentMediaId());
    } else {/*from   w  ww .  j  a v  a  2  s  .c o  m*/
        mediaView.setLink(media.getLink());
    }
    mediaView.setComponentMediaId(media.getComponentMediaId());
    mediaView.setActiveStatus(media.getActiveStatus());
    mediaView.setFileName(media.getFileName());
    mediaView.setOriginalFileName(media.getOriginalName());
    mediaView.setOriginalLink(media.getLink());
    mediaView.setMediaTypeCode(media.getMediaTypeCode());
    mediaView.setContentType(TranslateUtil.translate(MediaType.class, media.getMediaTypeCode()));
    mediaView.setMimeType(media.getMimeType());
    mediaView.setCaption(media.getCaption());
    mediaView.setUpdateDts(media.getUpdateDts());
    return mediaView;
}

From source file:alluxio.util.LogUtils.java

/**
 * Gets a logger's level with specify name, if the level argument is not null, it will set to
 * specify level first.// w ww. j a  v  a  2  s  .  c om
 * @param logName logger's name
 * @param level logger's level
 * @return an entity object about the log info
 * @throws IOException if an I/O error occurs
 */
public static LogInfo setLogLevel(String logName, String level) throws IOException {
    LogInfo result = new LogInfo();
    if (StringUtils.isNotBlank(logName)) {
        result.setLogName(logName);
        Log log = LogFactory.getLog(logName);
        Logger logger = LoggerFactory.getLogger(logName);
        if (log instanceof Log4JLogger) {
            process(((Log4JLogger) log).getLogger(), level, result);
        } else if (log instanceof Jdk14Logger) {
            process(((Jdk14Logger) log).getLogger(), level, result);
        } else if (logger instanceof Log4jLoggerAdapter) {
            try {
                Field field = Log4jLoggerAdapter.class.getDeclaredField("logger");
                field.setAccessible(true);
                org.apache.log4j.Logger log4jLogger = (org.apache.log4j.Logger) field.get(logger);
                process(log4jLogger, level, result);
            } catch (NoSuchFieldException | IllegalAccessException e) {
                result.setMessage(e.getMessage());
            }
        } else {
            result.setMessage("Sorry, " + log.getClass() + " not supported.");
        }
    } else {
        result.setMessage("Please specify a correct logName.");
    }
    return result;
}

From source file:apm.common.utils.HttpTookit.java

/**
 * HTTP GET?HTML//w w w .j  a  va  2s.com
 * 
 * @param url
 *            URL?
 * @param queryString
 *            ?,?null
 * @param charset
 *            
 * @param pretty
 *            ?
 * @return ?HTML
 */
public static String doGet(String url, String queryString, String charset, boolean pretty) {
    StringBuffer response = new StringBuffer();
    HttpClient client = new HttpClient();
    HttpMethod method = new GetMethod(url);
    try {
        if (StringUtils.isNotBlank(queryString))
            // get??http?????%?
            method.setQueryString(URIUtil.encodeQuery(queryString));
        client.executeMethod(method);
        if (method.getStatusCode() == HttpStatus.SC_OK) {
            BufferedReader reader = new BufferedReader(
                    new InputStreamReader(method.getResponseBodyAsStream(), charset));
            String line;
            while ((line = reader.readLine()) != null) {
                if (pretty) {
                    response.append(line).append(System.getProperty("line.separator"));
                } else {
                    response.append(line);
                }
            }
            reader.close();
        }
    } catch (URIException e) {
        log.error("HTTP Get?" + queryString + "???", e);
    } catch (IOException e) {
        log.error("HTTP Get" + url + "??", e);
    } finally {
        method.releaseConnection();
    }
    return response.toString();
}

From source file:com.github.pfmiles.minvelocity.biztest.JavaSourceFile.java

private static URI genMemFileUri(String fileName, String pkg) {
    String pkgPath = "";
    if (StringUtils.isNotBlank(pkg))
        pkgPath = pkg.replaceAll("\\.", "/") + "/";
    return URI.create("mem:///src/" + pkgPath + fileName);
}

From source file:com.mobileman.projecth.web.util.NumUtils.java

public static Integer convert2int(String str) {
    try {/*from w ww .jav a 2 s . c  om*/
        if (StringUtils.isNotBlank(str)) {
            return Integer.parseInt(str);
        }
    } catch (Exception ex) {
    }
    return null;
}

From source file:com.enonic.cms.business.core.content.mail.AssignedContentMailTemplate.java

@Override
public String getBody() {
    StringBuffer body = new StringBuffer();

    if (StringUtils.isNotBlank(assignmentDescription)) {
        body.append(assignmentDescription);
    }/*from w w  w.  jav a  2 s.  c  om*/

    if (assigner != null) {
        addNewLine(body);
        body.append(" - ");
        body.append(createUserName(assigner));
    }

    addNewLine(body);
    addNewLine(body);

    body.append(createAssignmentMailInfoElement());

    return body.toString();
}