Example usage for com.liferay.portal.kernel.util UnicodeFormatter parseString

List of usage examples for com.liferay.portal.kernel.util UnicodeFormatter parseString

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util UnicodeFormatter parseString.

Prototype

public static String parseString(String hexString) 

Source Link

Usage

From source file:com.liferay.document.library.internal.util.DLValidatorImpl.java

License:Open Source License

@Override
public boolean isValidName(String name) {
    if (Validator.isNull(name)) {
        return false;
    }/*from   w w w  . j  av a  2 s . c o m*/

    for (String blacklistChar : PropsValues.DL_CHAR_BLACKLIST) {
        if (name.contains(blacklistChar)) {
            return false;
        }
    }

    for (String blacklistLastChar : PropsValues.DL_CHAR_LAST_BLACKLIST) {
        if (blacklistLastChar.startsWith(UnicodeFormatter.UNICODE_PREFIX)) {
            blacklistLastChar = UnicodeFormatter.parseString(blacklistLastChar);
        }

        if (name.endsWith(blacklistLastChar)) {
            return false;
        }
    }

    String nameWithoutExtension = FileUtil.stripExtension(name);

    for (String blacklistName : PropsValues.DL_NAME_BLACKLIST) {
        if (StringUtil.equalsIgnoreCase(nameWithoutExtension, blacklistName)) {

            return false;
        }
    }

    return true;
}

From source file:com.liferay.document.library.internal.util.DLValidatorImpl.java

License:Open Source License

protected String replaceDLCharLastBlacklist(String title) {
    String previousTitle = null;// w  w  w.  java  2  s  .  c  o  m

    while (!title.equals(previousTitle)) {
        previousTitle = title;

        for (String blacklistLastChar : PropsValues.DL_CHAR_LAST_BLACKLIST) {

            if (blacklistLastChar.startsWith(UnicodeFormatter.UNICODE_PREFIX)) {

                blacklistLastChar = UnicodeFormatter.parseString(blacklistLastChar);
            }

            if (title.endsWith(blacklistLastChar)) {
                title = StringUtil.replaceLast(title, blacklistLastChar, StringPool.BLANK);
            }
        }
    }

    return title;
}