Example usage for com.liferay.portal.kernel.language LanguageUtil isAvailableLocale

List of usage examples for com.liferay.portal.kernel.language LanguageUtil isAvailableLocale

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.language LanguageUtil isAvailableLocale.

Prototype

public static boolean isAvailableLocale(String languageId) 

Source Link

Usage

From source file:com.liferay.dynamic.data.mapping.io.internal.DDMFormValuesJSONDeserializerImpl.java

License:Open Source License

protected boolean isLocalized(JSONObject jsonObject) {
    if (jsonObject == null) {
        return false;
    }// w  w w  . j  av  a  2  s  . com

    Iterator<String> keys = jsonObject.keys();

    while (keys.hasNext()) {
        String key = keys.next();

        if (!LanguageUtil.isAvailableLocale(key)) {
            return false;
        }
    }

    return true;
}

From source file:com.liferay.dynamic.data.mapping.service.impl.DDMStructureLocalServiceImpl.java

License:Open Source License

protected void validate(Map<Locale, String> nameMap, Locale contentDefaultLocale) throws PortalException {

    String name = nameMap.get(contentDefaultLocale);

    if (Validator.isNull(name)) {
        throw new StructureNameException("Name is null for locale " + contentDefaultLocale.getDisplayName());
    }/*from  w ww  . ja v  a2 s . c o m*/

    if (!LanguageUtil.isAvailableLocale(contentDefaultLocale)) {
        Long companyId = CompanyThreadLocal.getCompanyId();

        LocaleException le = new LocaleException(LocaleException.TYPE_CONTENT,
                StringBundler.concat("The locale ", String.valueOf(contentDefaultLocale),
                        " is not available in company ", String.valueOf(companyId)));

        le.setSourceAvailableLocales(Collections.singleton(contentDefaultLocale));
        le.setTargetAvailableLocales(LanguageUtil.getAvailableLocales());

        throw le;
    }
}