List of usage examples for com.liferay.portal.kernel.util LocalizationUtil updateLocalization
public static String updateLocalization(String xml, String key, String value, String requestedLanguageId, String defaultLanguageId, boolean cdata, boolean localized)
From source file:com.liferay.appadder.portlet.AppAdderPortlet.java
License:Open Source License
protected AppEntry addAppEntry(ActionRequest actionRequest, String title) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); boolean customEula = false; String description = "Lorem ipsum dolor sit amet, consectetur"; String website = "http://www.liferay.com"; String demoWebsite = "http://www.liferay.com"; String documentationWebsite = "http://www.liferay.com"; String sourceCodeWebsite = "http://www.liferay.com"; String supportWebsite = "http://www.liferay.com"; boolean labs = false; int productType = 0; double retailPrice = 0; String eulaContent = StringPool.BLANK; String defaultLanguageId = "en_US"; String languageId = "en_US"; String ownerClassName = CorpEntry.class.getName(); long ownerClassPK = ParamUtil.getLong(actionRequest, "ownerClassPK"); boolean descriptionLocalized = false; File iconFile = generateIcon(); CurrencyEntry currencyEntry = CurrencyEntryLocalServiceUtil.getCurrencyEntry("USD"); long currencyEntryId = currencyEntry.getCurrencyEntryId(); ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest); if (Validator.isNull(defaultLanguageId)) { defaultLanguageId = themeDisplay.getLanguageId(); }/*from w w w . ja v a 2s . com*/ if (ownerClassName.equals(User.class.getName())) { ownerClassPK = themeDisplay.getUserId(); } description = LocalizationUtil.updateLocalization(StringPool.BLANK, "static-content", description, languageId, languageId, true, descriptionLocalized); AppEntry appEntry = AppEntryServiceUtil.addAppEntry(ownerClassName, ownerClassPK, title, description, website, demoWebsite, documentationWebsite, sourceCodeWebsite, supportWebsite, labs, productType, null, null, iconFile, currencyEntryId, retailPrice, eulaContent, serviceContext); long[] assetAttachmentIds = StringUtil.split(ParamUtil.getString(actionRequest, "assetAttachmentIds"), 0L); AppVersion appVersion = AppVersionLocalServiceUtil.getLatestAppVersion(appEntry.getAppEntryId()); for (long assetAttachmentId : assetAttachmentIds) { AssetAttachmentLocalServiceUtil.updateAssetAttachment(assetAttachmentId, AppVersion.class.getName(), appVersion.getAppVersionId()); } List<AppEntryRel> appEntryRels = AppEntryRelLocalServiceUtil.getAppEntryRels(appEntry.getAppEntryId(), 1); for (AppEntryRel appEntryRel : appEntryRels) { AppEntryRelServiceUtil.deleteAppEntryRel(appEntryRel.getAppEntryRelId()); } long[] supersedesAppEntryIds = StringUtil.split(ParamUtil.getString(actionRequest, "supersedesAppEntryIds"), 0L); for (long supersedesAppEntryId : supersedesAppEntryIds) { AppEntryRelServiceUtil.addAppEntryRel(appEntry.getAppEntryId(), supersedesAppEntryId, 1); } return appEntry; }
From source file:com.liferay.faces.demos.util.WebContentUtil.java
License:Open Source License
public static JournalArticle getArticle(long companyId, long userId, long groupId, long folderId, Locale locale, String title, String content) { JournalArticle journalArticle = null; try {//from w w w .ja va 2s . co m try { String urlTitle = getUrlTitle(title); journalArticle = JournalArticleLocalServiceUtil.getArticleByUrlTitle(groupId, urlTitle); } catch (NoSuchArticleException e) { Map<Locale, String> titleMap = new HashMap<Locale, String>(); titleMap.put(locale, title); Map<Locale, String> descriptionMap = Collections.emptyMap(); String ddmStructureKey = ""; String ddmTemplateKey = ""; ServiceContext serviceContext = new ServiceContext(); serviceContext.setCompanyId(companyId); serviceContext.setScopeGroupId(groupId); serviceContext.setUserId(userId); serviceContext.setAddGroupPermissions(true); serviceContext.setAddGuestPermissions(true); String defaultLanguageId = ""; content = LocalizationUtil.updateLocalization("", "static-content", content, defaultLanguageId, defaultLanguageId, true, false); journalArticle = JournalArticleLocalServiceUtil.addArticle(userId, groupId, folderId, titleMap, descriptionMap, content, ddmStructureKey, ddmTemplateKey, serviceContext); } } catch (Exception e) { logger.error(e); } return journalArticle; }