Java 类com.liferay.portal.kernel.util.LocaleUtil 实例源码

项目:liferay-dummy-factory    文件:JournalUtils.java   
/**
 * Build content field
 *
 * @param groupId Company group ID
 * @param locales locales
 * @param baseArticle content data
 * @return DDMStructure applied content XML strings
 * @throws Exception
 */
public String buildFields(long groupId, String[] locales, String baseArticle) throws Exception {
    DDMStructure ddmStructure = 
        _DDMStructureLocalService.getStructure(
            groupId,
            PortalUtil.getClassNameId(JournalArticle.class), 
            LDFPortletKeys._DDM_STRUCTURE_KEY
        );

    Map<String, Serializable> fieldsMap = Maps.newConcurrentMap();
    fieldsMap.put(DDM_CONTENT, baseArticle);

    Fields fields = _ddmLocalUtil.toFields(
            ddmStructure.getStructureId(), 
            fieldsMap, 
            locales,
            LocaleUtil.getDefault());

    return _journalConverter.getContent(ddmStructure, fields);
}
项目:liferay-dummy-factory    文件:JournalUtils.java   
/**
 * Build content field
 * 
 * @param ddmStructure
 * @param serviceContext
 * @return
 * @throws Exception
 */
public String buildFields(long groupId, DDMStructure ddmStructure, String[] locales) throws Exception {

    Map<String, Serializable> fieldsMap = Maps.newConcurrentMap();
    Set<String> fieldNames = ddmStructure.getFieldNames();

    for(String fieldName : fieldNames ) {
        fieldsMap.put(fieldName, "");
    }

    Fields fields = _ddmLocalUtil.toFields(
            ddmStructure.getStructureId(), 
            fieldsMap, 
            locales,
            LocaleUtil.getDefault());

    return _journalConverter.getContent(ddmStructure, fields);
}
项目:com-liferay-apio-architect    文件:PersonCollectionResource.java   
private User _addUser(
    PersonCreatorForm personCreatorForm, Company company) {

    try {
        return _userLocalService.addUser(
            UserConstants.USER_ID_DEFAULT, company.getCompanyId(), false,
            personCreatorForm.getPassword1(),
            personCreatorForm.getPassword2(),
            personCreatorForm.hasAlternateName(),
            personCreatorForm.getAlternateName(),
            personCreatorForm.getEmail(), 0, StringPool.BLANK,
            LocaleUtil.getDefault(), personCreatorForm.getGivenName(),
            StringPool.BLANK, personCreatorForm.getFamilyName(), 0, 0,
            personCreatorForm.isMale(),
            personCreatorForm.getBirthdayMonth(),
            personCreatorForm.getBirthdayDay(),
            personCreatorForm.getBirthdayYear(),
            personCreatorForm.getJobTitle(), null, null, null, null, false,
            new ServiceContext());
    }
    catch (PortalException pe) {
        throw new ServerErrorException(500, pe);
    }
}
项目:liferay-db-setup-core    文件:SetupPages.java   
private static Layout createPage(final long groupId, final Page currentPage,
                                 final long parentLayoutId, final boolean isPrivate)
        throws SystemException, PortalException {

    Map<Locale, String> titleMap = TitleMapUtil.getTitleMap(currentPage.getTitleTranslation(), groupId,
            currentPage.getName(), " Page with title " + currentPage.getFriendlyURL());

    Locale locale = LocaleUtil.getSiteDefault();

    Map<Locale, String> descriptionMap = new HashMap<>();
    descriptionMap.put(locale, StringPool.BLANK);

    Map<Locale, String> friendlyURLMap = new HashMap<>();
    friendlyURLMap.put(locale, currentPage.getFriendlyURL());

    return LayoutLocalServiceUtil.addLayout(LiferaySetup.getRunAsUserId(), groupId, isPrivate, parentLayoutId, titleMap,titleMap, null,
            null, null, currentPage.getType(), StringPool.BLANK, currentPage.isHidden(), friendlyURLMap, new ServiceContext());
}
项目:org.portletbeans    文件:ImageFieldHandler.java   
@Override
public void write(final DynamicElement element, final Locale locale, final ImageReference value,
        final Map<String, byte[]> images) {
    final String prefix = '_' + element.getName() + '_';
    final String suffix = '_' + LocaleUtil.toLanguageId(locale);
    String qualifiedName = prefix + 0 + suffix;
    for (int i = 1; i < images.size(); i++) {
        if (!images.containsKey(qualifiedName)) {
            break;
        }
        qualifiedName = prefix + i + suffix;
    }
    if (value == null) {
        images.put(qualifiedName, null);
        element.setValue(locale, "");
    } else if (value.isNew() && value.getImageData() != null) {
        images.put(qualifiedName, value.getImageData());
        element.setValue(locale, "data");
    } else {
        images.put(qualifiedName, null);
        element.setValue(locale, value.getUrl());
    }
}
项目:liferaylms-portlet    文件:LmsLocaleUtil.java   
public static Map<Locale, String> getLocalizationMap(
        UploadRequest request, String parameter) {

        Locale[] locales = LanguageUtil.getAvailableLocales();

        Map<Locale, String> map = new HashMap<Locale, String>();

        for (Locale locale : locales) {
            String languageId = LocaleUtil.toLanguageId(locale);

            String localeParameter = parameter.concat(
                StringPool.UNDERLINE).concat(languageId);
            map.put(
                locale,
                ParamUtil.getString(request,localeParameter));
        }

        return map;
}
项目:liferaylms-portlet    文件:StartupAction.java   
public void createDefaultSiteTemplate(long companyId) throws PortalException, SystemException 
{
    boolean exists = false;
    long layoutSetPrototypeId = 0;
    for(LayoutSetPrototype lay:LayoutSetPrototypeLocalServiceUtil.getLayoutSetPrototypes(0, LayoutSetPrototypeLocalServiceUtil.getLayoutSetPrototypesCount())){
        if(lay.getCompanyId() == companyId && "course".equals(lay.getName(LocaleUtil.getDefault()))) {
            exists=true;
            layoutSetPrototypeId = lay.getLayoutSetPrototypeId();
        }
    }

    if(!exists){
        long defaultUserId = UserLocalServiceUtil.getDefaultUserId(companyId);
        Map<Locale, String> nameMap = new HashMap<Locale, String>();
        nameMap.put(LocaleUtil.getDefault(), "course");
        layoutSetPrototype = LayoutSetPrototypeLocalServiceUtil.addLayoutSetPrototype(defaultUserId, companyId, nameMap, "course", true,true,new ServiceContext());
        InputStream larStream=this.getClass().getClassLoader().getResourceAsStream("/course.lar");
        LayoutLocalServiceUtil.importLayouts(defaultUserId,layoutSetPrototype.getGroup().getGroupId() , 
                layoutSetPrototype.getLayoutSet().isPrivateLayout(), getLayoutSetPrototypeParameters(), larStream);
    } else {
        layoutSetPrototype = LayoutSetPrototypeLocalServiceUtil.getLayoutSetPrototype(layoutSetPrototypeId);
    }

}
项目:org.portletbeans    文件:DynamicElements.java   
private void write(final DynamicElementsContainer container, final XMLStreamWriter writer,
        final Map<String, Counter> counters) throws XMLStreamException {
    for (final DynamicElement element : container) {
        writer.writeStartElement("dynamic-element");
        final String name = element.getName();
        writer.writeAttribute("name", name);
        writer.writeAttribute("type", element.getType());
        if (element.getIndexType() != null) {
            writer.writeAttribute("index-type", element.getIndexType());
        }
        Counter counter = counters.get(name);
        if (counter == null) {
            counter = new Counter();
            counters.put(name, counter);
        }
        writer.writeAttribute("index", String.valueOf(counter.increment()));
        write(element, writer, counters);
        for (final Map.Entry<Locale, String> entry : element.getValues().entrySet()) {
            writer.writeStartElement("dynamic-content");
            writer.writeAttribute("language-id", LocaleUtil.toLanguageId(entry.getKey()));
            writer.writeCData(entry.getValue());
            writer.writeEndElement();
        }
        writer.writeEndElement();
    }
}
项目:org.portletbeans    文件:DynamicElements.java   
/**
 * Creates an XML string from this elements.
 *
 * @return the XML content
 */
public String toXML() {
    try {
        final StringWriter buffer = new StringWriter();
        final XMLStreamWriter writer = OUTPUT_FACTORY.createXMLStreamWriter(buffer);
        writer.writeStartDocument();
        writer.writeStartElement("root");
        final Set<Locale> allLocales = new HashSet<>();
        final StringBuilder availableLocales = new StringBuilder();
        if (this.defaultLocale != null) {
            final String defaultLanguageId = LocaleUtil.toLanguageId(this.defaultLocale);
            writer.writeAttribute("default-locale", defaultLanguageId);
            allLocales.add(this.defaultLocale);
            availableLocales.append(defaultLanguageId);
        }
        findAvailableLocales(this, allLocales, availableLocales);
        writer.writeAttribute("available-locales", availableLocales.toString());
        write(this, writer, new HashMap<String, Counter>());
        writer.writeEndElement();
        writer.writeEndDocument();
        return buffer.toString();
    } catch (final XMLStreamException e) {
        throw new IllegalStateException(e);
    }
}
项目:liferay-dummy-factory    文件:JournalContext.java   
/**
 * Constructor
 * 
 * @param actionRequest
 * @throws PortalException
 */
public JournalContext(ActionRequest actionRequest) throws PortalException {
    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    // Fetch data
    numberOfArticles = ParamUtil.getLong(actionRequest, "numberOfArticles", 1);
    baseTitle = ParamUtil.getString(actionRequest, "baseTitle", "");
    baseArticle = ParamUtil.getString(actionRequest, "baseArticle", "");
    folderId = ParamUtil.getLong(actionRequest, "folderId", 0);
    totalParagraphs = ParamUtil.getInteger(actionRequest, "totalParagraphs", 0);
    titleWords = ParamUtil.getInteger(actionRequest, "titleWords", 0);
    randomAmount = ParamUtil.getInteger(actionRequest, "randomAmount", 0);
    createContentsType = ParamUtil.getLong(actionRequest, "createContentsType", 0);
    linkLists = ParamUtil.getString(actionRequest, "linkLists", "");
    ddmStructureId = ParamUtil.getLong(actionRequest, "ddmStructureId", 0);
    ddmTemplateId = ParamUtil.getLong(actionRequest, "ddmTemplateId", 0);

    // Locales
    String[] defLang = { LocaleUtil.getDefault().toString() };
    locales = ParamUtil.getStringValues(actionRequest, "locales", defLang);

    // Sites
    String[] groupsStrIds = ParamUtil.getStringValues(actionRequest, "groupIds",
            new String[] { String.valueOf(themeDisplay.getScopeGroupId()) });
    groupIds = CommonUtil.convertStringToLongArray(groupsStrIds);

    // Fetch default locale
    defaultLocale = LocaleUtil.fromLanguageId(themeDisplay.getUser().getLanguageId());

    descriptionMap = new ConcurrentHashMap<Locale, String>();
    descriptionMap.put(defaultLocale, StringPool.BLANK);
}
项目:index-checker    文件:IndexSearchHelper.java   
public void fillDataObject(Data data, String[] attributes, Document doc) {
    data.set(Field.UID, doc.getUID());

    Locale[] locales = LanguageUtil.getAvailableLocales().toArray(
            new Locale[0]);
    Locale siteLocale = LocaleUtil.getSiteDefault();

    for (String attribute : attributes) {
        String attrDoc = ConfigurationUtil.getIndexAttributeName(
            data.getModel(), attribute);

        List<Map<Locale, String>> listValueMap = null;

        Class<?> typeClass = data.getAttributeClass(attribute);

        if (typeClass.equals(String.class) ||
            typeClass.equals(Object.class)) {

            listValueMap = getLocalizedMap(locales, doc, attrDoc);
        }

        if ((listValueMap != null) && !listValueMap.isEmpty()) {
            String[] xml = new String[listValueMap.size()];

            int pos = 0;

            for (Map<Locale, String> valueMap : listValueMap) {
                xml[pos++] = LocalizationUtil.updateLocalization(
                    valueMap, "", "data",
                    LocaleUtil.toLanguageId(siteLocale));
            }

            data.set(attribute, xml);
        }
        else if (doc.hasField(attrDoc)) {
            data.set(attribute, doc.getField(attrDoc).getValues());
        }
    }
}
项目:liferaylms-portlet    文件:LearningActivityClp.java   
public void setTitle(String title, Locale locale, Locale defaultLocale) {
    String languageId = LocaleUtil.toLanguageId(locale);
    String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale);

    if (Validator.isNotNull(title)) {
        setTitle(LocalizationUtil.updateLocalization(getTitle(), "Title",
                title, languageId, defaultLanguageId));
    }
    else {
        setTitle(LocalizationUtil.removeLocalization(getTitle(), "Title",
                languageId));
    }
}
项目:liferaylms-portlet    文件:LearningActivityClp.java   
public void setDescription(String description, Locale locale,
    Locale defaultLocale) {
    String languageId = LocaleUtil.toLanguageId(locale);
    String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale);

    if (Validator.isNotNull(description)) {
        setDescription(LocalizationUtil.updateLocalization(
                getDescription(), "Description", description, languageId,
                defaultLanguageId));
    }
    else {
        setDescription(LocalizationUtil.removeLocalization(
                getDescription(), "Description", languageId));
    }
}
项目:liferaylms-portlet    文件:CompetenceClp.java   
public void setTitle(String title, Locale locale, Locale defaultLocale) {
    String languageId = LocaleUtil.toLanguageId(locale);
    String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale);

    if (Validator.isNotNull(title)) {
        setTitle(LocalizationUtil.updateLocalization(getTitle(), "Title",
                title, languageId, defaultLanguageId));
    }
    else {
        setTitle(LocalizationUtil.removeLocalization(getTitle(), "Title",
                languageId));
    }
}
项目:liferaylms-portlet    文件:CompetenceClp.java   
public void setDescription(String description, Locale locale,
    Locale defaultLocale) {
    String languageId = LocaleUtil.toLanguageId(locale);
    String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale);

    if (Validator.isNotNull(description)) {
        setDescription(LocalizationUtil.updateLocalization(
                getDescription(), "Description", description, languageId,
                defaultLanguageId));
    }
    else {
        setDescription(LocalizationUtil.removeLocalization(
                getDescription(), "Description", languageId));
    }
}
项目:liferaylms-portlet    文件:CompetenceClp.java   
public void setDiplomaTemplate(String diplomaTemplate, Locale locale,
    Locale defaultLocale) {
    String languageId = LocaleUtil.toLanguageId(locale);
    String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale);

    if (Validator.isNotNull(diplomaTemplate)) {
        setDiplomaTemplate(LocalizationUtil.updateLocalization(
                getDiplomaTemplate(), "DiplomaTemplate", diplomaTemplate,
                languageId, defaultLanguageId));
    }
    else {
        setDiplomaTemplate(LocalizationUtil.removeLocalization(
                getDiplomaTemplate(), "DiplomaTemplate", languageId));
    }
}
项目:liferaylms-portlet    文件:ModuleClp.java   
public void setTitle(String title, Locale locale, Locale defaultLocale) {
    String languageId = LocaleUtil.toLanguageId(locale);
    String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale);

    if (Validator.isNotNull(title)) {
        setTitle(LocalizationUtil.updateLocalization(getTitle(), "Title",
                title, languageId, defaultLanguageId));
    }
    else {
        setTitle(LocalizationUtil.removeLocalization(getTitle(), "Title",
                languageId));
    }
}
项目:liferaylms-portlet    文件:ModuleClp.java   
public void setDescription(String description, Locale locale,
    Locale defaultLocale) {
    String languageId = LocaleUtil.toLanguageId(locale);
    String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale);

    if (Validator.isNotNull(description)) {
        setDescription(LocalizationUtil.updateLocalization(
                getDescription(), "Description", description, languageId,
                defaultLanguageId));
    }
    else {
        setDescription(LocalizationUtil.removeLocalization(
                getDescription(), "Description", languageId));
    }
}
项目:liferaylms-portlet    文件:CourseClp.java   
public void setTitle(String title, Locale locale, Locale defaultLocale) {
    String languageId = LocaleUtil.toLanguageId(locale);
    String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale);

    if (Validator.isNotNull(title)) {
        setTitle(LocalizationUtil.updateLocalization(getTitle(), "Title",
                title, languageId, defaultLanguageId));
    }
    else {
        setTitle(LocalizationUtil.removeLocalization(getTitle(), "Title",
                languageId));
    }
}
项目:liferaylms-portlet    文件:CourseClp.java   
public void setDescription(String description, Locale locale,
    Locale defaultLocale) {
    String languageId = LocaleUtil.toLanguageId(locale);
    String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale);

    if (Validator.isNotNull(description)) {
        setDescription(LocalizationUtil.updateLocalization(
                getDescription(), "Description", description, languageId,
                defaultLanguageId));
    }
    else {
        setDescription(LocalizationUtil.removeLocalization(
                getDescription(), "Description", languageId));
    }
}
项目:liferaylms-portlet    文件:EvaluationAvgCourseEval.java   
@Override
public void setExtraContent(Course course, String actionId, ServiceContext serviceContext)
        throws PortalException, SystemException {
    if((Validator.isNumber(PropsUtil.get("lms.course.default.evaluations")))&&("ADD_COURSE".equals(actionId))) {
        ServiceContext evaluationServiceContext = ServiceContextFactory.getInstance(serviceContext.getRequest());
        long numOfEvaluations = _numOfEvaluations.get();
        Locale locale = LocaleThreadLocal.getThemeDisplayLocale();

        if(locale==null) {
            if(Validator.isNotNull(serviceContext.getLanguageId())){
                locale = LocaleUtil.fromLanguageId(serviceContext.getLanguageId());
            }
            else {
                locale = LocaleUtil.getDefault();
            }
        }
        long[] assetCategoryIds=new long[0];
        evaluationServiceContext.setAssetCategoryIds(assetCategoryIds);
        evaluationServiceContext.setAssetLinkEntryIds(assetCategoryIds);
        String[] emptyArray=new String[0];

        evaluationServiceContext.setAssetTagNames(emptyArray);
        evaluationServiceContext.setGroupPermissions(emptyArray);
        evaluationServiceContext.setGuestPermissions(emptyArray);
        evaluationServiceContext.setDeriveDefaultPermissions(true);


        for(int currentEvaluation=1;currentEvaluation<=numOfEvaluations;currentEvaluation++) {

            Map<Locale,String> evaluationTitle = new HashMap<Locale, String>(1);
            evaluationTitle.put(locale, LanguageUtil.format(locale, "evaluation.number", new Object[]{currentEvaluation}));

            LearningActivityLocalServiceUtil.addLearningActivity(course.getUserId(), course.getGroupCreatedId(), WorkflowConstants.STATUS_APPROVED, 
                    evaluationTitle, evaluationTitle, 8 /* Evaluation */, null, null, 0, 0, 0, 0, null, null, null, 0, 0, evaluationServiceContext);
        }   
    }
}
项目:liferaylms-portlet    文件:ModuleModelImpl.java   
public void setTitle(String title, Locale locale, Locale defaultLocale) {
    String languageId = LocaleUtil.toLanguageId(locale);
    String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale);

    if (Validator.isNotNull(title)) {
        setTitle(LocalizationUtil.updateLocalization(getTitle(), "Title",
                title, languageId, defaultLanguageId));
    }
    else {
        setTitle(LocalizationUtil.removeLocalization(getTitle(), "Title",
                languageId));
    }
}
项目:liferaylms-portlet    文件:ModuleModelImpl.java   
public void setDescription(String description, Locale locale,
    Locale defaultLocale) {
    String languageId = LocaleUtil.toLanguageId(locale);
    String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale);

    if (Validator.isNotNull(description)) {
        setDescription(LocalizationUtil.updateLocalization(
                getDescription(), "Description", description, languageId,
                defaultLanguageId));
    }
    else {
        setDescription(LocalizationUtil.removeLocalization(
                getDescription(), "Description", languageId));
    }
}
项目:liferaylms-portlet    文件:CourseModelImpl.java   
public void setTitle(String title, Locale locale, Locale defaultLocale) {
    String languageId = LocaleUtil.toLanguageId(locale);
    String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale);

    if (Validator.isNotNull(title)) {
        setTitle(LocalizationUtil.updateLocalization(getTitle(), "Title",
                title, languageId, defaultLanguageId));
    }
    else {
        setTitle(LocalizationUtil.removeLocalization(getTitle(), "Title",
                languageId));
    }
}
项目:liferaylms-portlet    文件:CourseModelImpl.java   
public void setDescription(String description, Locale locale,
    Locale defaultLocale) {
    String languageId = LocaleUtil.toLanguageId(locale);
    String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale);

    if (Validator.isNotNull(description)) {
        setDescription(LocalizationUtil.updateLocalization(
                getDescription(), "Description", description, languageId,
                defaultLanguageId));
    }
    else {
        setDescription(LocalizationUtil.removeLocalization(
                getDescription(), "Description", languageId));
    }
}
项目:liferaylms-portlet    文件:CompetenceModelImpl.java   
public void setTitle(String title, Locale locale, Locale defaultLocale) {
    String languageId = LocaleUtil.toLanguageId(locale);
    String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale);

    if (Validator.isNotNull(title)) {
        setTitle(LocalizationUtil.updateLocalization(getTitle(), "Title",
                title, languageId, defaultLanguageId));
    }
    else {
        setTitle(LocalizationUtil.removeLocalization(getTitle(), "Title",
                languageId));
    }
}
项目:liferaylms-portlet    文件:CompetenceModelImpl.java   
public void setDescription(String description, Locale locale,
    Locale defaultLocale) {
    String languageId = LocaleUtil.toLanguageId(locale);
    String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale);

    if (Validator.isNotNull(description)) {
        setDescription(LocalizationUtil.updateLocalization(
                getDescription(), "Description", description, languageId,
                defaultLanguageId));
    }
    else {
        setDescription(LocalizationUtil.removeLocalization(
                getDescription(), "Description", languageId));
    }
}
项目:liferaylms-portlet    文件:CompetenceModelImpl.java   
public void setDiplomaTemplate(String diplomaTemplate, Locale locale,
    Locale defaultLocale) {
    String languageId = LocaleUtil.toLanguageId(locale);
    String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale);

    if (Validator.isNotNull(diplomaTemplate)) {
        setDiplomaTemplate(LocalizationUtil.updateLocalization(
                getDiplomaTemplate(), "DiplomaTemplate", diplomaTemplate,
                languageId, defaultLanguageId));
    }
    else {
        setDiplomaTemplate(LocalizationUtil.removeLocalization(
                getDiplomaTemplate(), "DiplomaTemplate", languageId));
    }
}
项目:liferaylms-portlet    文件:LearningActivityModelImpl.java   
public void setTitle(String title, Locale locale, Locale defaultLocale) {
    String languageId = LocaleUtil.toLanguageId(locale);
    String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale);

    if (Validator.isNotNull(title)) {
        setTitle(LocalizationUtil.updateLocalization(getTitle(), "Title",
                title, languageId, defaultLanguageId));
    }
    else {
        setTitle(LocalizationUtil.removeLocalization(getTitle(), "Title",
                languageId));
    }
}
项目:liferaylms-portlet    文件:LearningActivityModelImpl.java   
public void setDescription(String description, Locale locale,
    Locale defaultLocale) {
    String languageId = LocaleUtil.toLanguageId(locale);
    String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale);

    if (Validator.isNotNull(description)) {
        setDescription(LocalizationUtil.updateLocalization(
                getDescription(), "Description", description, languageId,
                defaultLanguageId));
    }
    else {
        setDescription(LocalizationUtil.removeLocalization(
                getDescription(), "Description", languageId));
    }
}
项目:org.portletbeans    文件:DynamicElements.java   
private Locale findLocale(final String languageId) {
    Locale locale = this.locales.get(languageId);
    if (locale == null) {
        locale = LocaleUtil.fromLanguageId(languageId, false);
        this.locales.put(languageId, locale);
    }
    return locale;
}
项目:org.portletbeans    文件:DynamicElements.java   
private void findAvailableLocales(final DynamicElementsContainer container, final Set<Locale> availableLocales,
        final StringBuilder locales) {
    for (final DynamicElement element : container) {
        for (final Locale locale : element.getValues().keySet()) {
            if (availableLocales.add(locale)) {
                if (locales.length() > 0) {
                    locales.append(',');
                }
                locales.append(LocaleUtil.toLanguageId(locale));
            }
        }
        findAvailableLocales(element, availableLocales, locales);
    }
}
项目:liferay-dummy-factory    文件:SiteDefaultDummyGenerator.java   
@Override
protected void exec(ActionRequest request, SiteContext paramContext) throws PortalException {

    //Tracking progress start
    ProgressManager progressManager = new ProgressManager();
    progressManager.start(request);

    System.out.println("Starting to create " + paramContext.getNumberOfSites() + " sites");

    @SuppressWarnings("serial")
    Map<Locale, String> descriptionMap = new ConcurrentHashMap<Locale, String>() {
        {put(LocaleUtil.getDefault(), StringPool.BLANK);}
    };      

    for (long i = 1; i <= paramContext.getNumberOfSites(); i++) {
        //Update progress
        progressManager.trackProgress(i, paramContext.getNumberOfSites());

        //Create Site Name
        StringBundler siteName = new StringBundler(2);
        siteName.append(paramContext.getBaseSiteName());

        //Add number more then one site
        if(1 < paramContext.getNumberOfSites()) {
            siteName.append(i);
        }

        @SuppressWarnings("serial")
        Map<Locale, String> nameMap = new ConcurrentHashMap<Locale, String>() {
            {put(LocaleUtil.getDefault(), siteName.toString());}
        };

        try {

            _groupLocalService.addGroup(
                paramContext.getServiceContext().getUserId(), //userId
                paramContext.getParentGroupId(), // parentGroupId
                null, // className
                0, //classPK
                paramContext.getLiveGroupId(), //liveGroupId
                nameMap, // nameMap
                descriptionMap, // descriptionMap
                paramContext.getSiteType(), //type
                paramContext.isManualMembership(), //manualMembership
                GroupConstants.DEFAULT_MEMBERSHIP_RESTRICTION, // membershipRestriction
                StringPool.BLANK, //friendlyURL
                paramContext.isSite(), //site
                paramContext.isInheritContent(), //inheritContent
                paramContext.isActive(), //active
                paramContext.getServiceContext()); //serviceContext

        } catch (Exception e) {
            if (e instanceof DuplicateGroupException ) {
                _log.error("Site <" + siteName.toString() + "> is duplicated. Skip : " + e.getMessage());
            }
            else {
                //Finish progress
                progressManager.finish();   
                throw e;
            }
        }
    }

    //Finish progress
    progressManager.finish();   

    System.out.println("Finished creating " + paramContext.getNumberOfSites() + " sites");

}
项目:liferay-dummy-factory    文件:UserDataService.java   
/**
 * Create User data
 * 
 * @param serviceContext
 * @param organizationIds
 * @param groupIds
 * @param roleIds
 * @param userGroupIds
 * @param male
 * @param fakerEnable
 * @param password
 * @param screenName
 * @param emailAddress
 * @param baseScreenName
 * @param index
 * @param localeStr
 * @throws PortalException
 */
public User createUserData(ServiceContext serviceContext, long[] organizationIds, long[] groupIds, long[] roleIds,
        long[] userGroupIds, boolean male, boolean fakerEnable, String password, String screenName,
        String emailAddress, String baseScreenName, long index, String localeStr) throws PortalException {

    // For generating dummy user name
    Faker faker = _commonUtil.createFaker(localeStr);

    // Generate first / last name
    String firstName = (fakerEnable) ? faker.name().firstName() : baseScreenName;
    String lastName = (fakerEnable) ? faker.name().lastName() : String.valueOf(index);

       User user = null;

    try {
        // Create User
        user = _userLocalService.addUserWithWorkflow(
                serviceContext.getUserId(), 
                serviceContext.getCompanyId(), // companyId,
                false, // autoPassword,
                password, // password1,
                password, // password2,
                false, // autoScreenName,
                screenName.toString(), emailAddress.toString(), 0, // facebookId,
                StringPool.BLANK, // openId,
                LocaleUtil.getDefault(), // locale,
                firstName, // firstName,
                StringPool.BLANK, // middleName,
                lastName, // lastName,
                0, // prefixId,
                0, // suffixId,
                male, // male
                1, // birthdayMonth,
                1, // birthdayDay,
                1970, // birthdayYear,
                StringPool.BLANK, // jobTitle,
                groupIds,
                organizationIds, 
                getRegularRoleIds(roleIds), // this is only for reguler roles
                userGroupIds, // userGroupIds,
                false, // sendEmail
                serviceContext // serviceContext
        );

        if (_log.isDebugEnabled()) {
            _log.debug("user <" + user.getScreenName() + ">");
            _log.debug(user.toString());
            _log.debug("----------");
        }

        // Set site roles
        setSiteRoles(user.getUserId(), groupIds, roleIds);

        // Set org roles
        setOrgRoles(user.getUserId(), organizationIds, roleIds);

    } catch (UserScreenNameException e) {
        _log.error("User is duplicated. Skip : " + e.getMessage());
    }

       return user;
}
项目:liferay-oidc-plugin    文件:Liferay62Adapter.java   
protected User addUser(
        long companyId, String emailAddress, String firstName, String lastName)
        throws SystemException, PortalException {

    Locale locale = LocaleUtil.getMostRelevantLocale();
    long creatorUserId = 0;
    boolean autoPassword = false;
    String password1 = PwdGenerator.getPassword();
    String password2 = password1;
    boolean autoScreenName = true;
    String screenName = "not_used_but_autogenerated_instead";
    long facebookId = 0;
    String openId = StringPool.BLANK;
    String middleName = StringPool.BLANK;
    int prefixId = 0;
    int suffixId = 0;
    boolean male = true;
    int birthdayMonth = Calendar.JANUARY;
    int birthdayDay = 1;
    int birthdayYear = 1970;
    String jobTitle = StringPool.BLANK;
    long[] groupIds = null;
    long[] organizationIds = null;
    long[] roleIds = null;
    long[] userGroupIds = null;
    boolean sendEmail = false;
    ServiceContext serviceContext = new ServiceContext();

    User user = UserLocalServiceUtil.addUser(
            creatorUserId, companyId, autoPassword, password1, password2,
            autoScreenName, screenName, emailAddress, facebookId, openId,
            locale, firstName, middleName, lastName, prefixId, suffixId, male,
            birthdayMonth, birthdayDay, birthdayYear, jobTitle, groupIds,
            organizationIds, roleIds, userGroupIds, sendEmail, serviceContext);

    // No password
    user.setPasswordReset(false);
    // No reminder query at first login.
    user.setReminderQueryQuestion("x");
    user.setReminderQueryAnswer("y");
    UserLocalServiceUtil.updateUser(user);
    return user;
}
项目:liferay-oidc-plugin    文件:Liferay70Adapter.java   
protected User addUser(
        long companyId, String emailAddress, String firstName, String lastName)
        throws SystemException, PortalException {

    Locale locale = LocaleUtil.getMostRelevantLocale();
    long creatorUserId = 0;
    boolean autoPassword = false;
    String password1 = PwdGenerator.getPassword();
    String password2 = password1;
    boolean autoScreenName = true;
    String screenName = "not_used_but_autogenerated_instead";
    long facebookId = 0;
    String openId = StringPool.BLANK;
    String middleName = StringPool.BLANK;
    int prefixId = 0;
    int suffixId = 0;
    boolean male = true;
    int birthdayMonth = Calendar.JANUARY;
    int birthdayDay = 1;
    int birthdayYear = 1970;
    String jobTitle = StringPool.BLANK;
    long[] groupIds = null;
    long[] organizationIds = null;
    long[] roleIds = null;
    long[] userGroupIds = null;
    boolean sendEmail = false;
    ServiceContext serviceContext = new ServiceContext();

    User user = userLocalService.addUser(
            creatorUserId, companyId, autoPassword, password1, password2,
            autoScreenName, screenName, emailAddress, facebookId, openId,
            locale, firstName, middleName, lastName, prefixId, suffixId, male,
            birthdayMonth, birthdayDay, birthdayYear, jobTitle, groupIds,
            organizationIds, roleIds, userGroupIds, sendEmail, serviceContext);

    // No password
    user.setPasswordReset(false);
    // No reminder query at first login.
    user.setReminderQueryQuestion("x");
    user.setReminderQueryAnswer("y");
    userLocalService.updateUser(user);
    return user;
}
项目:OEPv2    文件:EmpLoyeePortlet.java   
public User addUser(ServiceContext serviceContext, String screenName,String password,String repassword,
            Date birthdate,String fullName,String email) throws PortalException, SystemException{
        //boolean autoPassword
        String[] tg = fullName.split(" ");
        String firstName = tg[0];
        String middleName = "";
        String lastName = "";
        if (tg.length > 1){
            firstName = tg[tg.length-1];
            lastName = tg[0];
        }
        if (tg.length > 2){
            middleName = tg[1];
            for (int i = 2; i < tg.length -1;i++){
                middleName += " " +  tg[i];
            }
        }
        Calendar birthday = CalendarFactoryUtil.getCalendar(); 
        birthday.setTime(birthdate);
        long creatorUserId = 0;
        boolean autoPassword = false;
        //String password1 = "password";
        //String password2 = password1;
        boolean autoScreenName = false;
        //String screenName = "tck";
        String emailAddress = email;
        long facebookId = 0;
        String openId = StringPool.BLANK;
        Locale locale = LocaleUtil.getDefault();

        int prefixId = 0;
        int suffixId = 0;
        boolean male = true;
        int birthdayMonth = birthday.get(Calendar.MONTH);
        int birthdayDay = birthday.get(Calendar.DAY_OF_MONTH);
        int birthdayYear = birthday.get(Calendar.YEAR); 
        String jobTitle = StringPool.BLANK;
        long[] groupIds = null;
        long[] organizationIds = null;
        long[] roleIds = null;
        long[] userGroupIds = null;
        boolean sendEmail = false; 
        //Locale locale = LocaleUtil.US; 
    //  creatorUserId, companyId, autoPassword, password1, password2,
    //  autoScreenName, screenName, emailAddress, facebookId, openId,
    //  locale, firstName, middleName, lastName, prefixId, suffixId,
    //  male, birthdayMonth, birthdayDay, birthdayYear, jobTitle,
    //  groupIds, organizationIds, roleIds, userGroupIds, sendEmail,
//  serviceContext); 
        User user = UserLocalServiceUtil.addUser(creatorUserId, serviceContext.getCompanyId(), autoPassword, password, repassword,
                    autoScreenName, screenName, emailAddress, facebookId, openId,
                locale, firstName, middleName, lastName, prefixId, suffixId,
                    male, birthdayMonth, birthdayDay, birthdayYear, jobTitle,
                    groupIds, organizationIds, roleIds, userGroupIds, sendEmail,
                serviceContext);

        return user;
    }
项目:liferaylms-portlet    文件:LearningActivityClp.java   
public String getTitle(Locale locale) {
    String languageId = LocaleUtil.toLanguageId(locale);

    return getTitle(languageId);
}
项目:liferaylms-portlet    文件:LearningActivityClp.java   
public String getTitle(Locale locale, boolean useDefault) {
    String languageId = LocaleUtil.toLanguageId(locale);

    return getTitle(languageId, useDefault);
}
项目:liferaylms-portlet    文件:LearningActivityClp.java   
public void setTitle(String title, Locale locale) {
    setTitle(title, locale, LocaleUtil.getDefault());
}