public void editSharing(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { Portlet portlet = ActionUtil.getPortlet(actionRequest); PortletPreferences portletPreferences = ActionUtil.getLayoutPortletSetup(actionRequest, portlet); actionRequest = ActionUtil.getWrappedActionRequest(actionRequest, portletPreferences); updateAnyWebsite(actionRequest, portletPreferences); updateFacebook(actionRequest, portletPreferences); updateFriends(actionRequest, portletPreferences); updateGoogleGadget(actionRequest, portletPreferences); updateNetvibes(actionRequest, portletPreferences); portletPreferences.store(); if (!SessionErrors.isEmpty(actionRequest)) { return; } String portletResource = ParamUtil.getString(actionRequest, "portletResource"); SessionMessages.add( actionRequest, PortalUtil.getPortletId(actionRequest) + SessionMessages.KEY_SUFFIX_REFRESH_PORTLET, portletResource); SessionMessages.add( actionRequest, PortalUtil.getPortletId(actionRequest) + SessionMessages.KEY_SUFFIX_UPDATED_CONFIGURATION); }
protected String getId() { if (Validator.isNotNull(_id)) { return _id; } String id = (String) request.getAttribute("liferay-ui:icon-menu:id"); String message = _message; if (Validator.isNull(message)) { message = _image; } if (Validator.isNotNull(id) && Validator.isNotNull(message)) { id = id.concat(StringPool.UNDERLINE).concat(FriendlyURLNormalizerUtil.normalize(message)); PortletResponse portletResponse = (PortletResponse) request.getAttribute(JavaConstants.JAVAX_PORTLET_RESPONSE); String namespace = StringPool.BLANK; if (portletResponse != null) { namespace = portletResponse.getNamespace(); } id = PortalUtil.getUniqueElementId(getOriginalServletRequest(), namespace, id); } else { id = PortalUtil.generateRandomKey(request, IconTag.class.getName()); } id = HtmlUtil.getAUICompatibleId(id); return id; }
@Override protected String[] doLogin(HttpServletRequest request, HttpServletResponse response) throws Exception { long companyId = PortalUtil.getCompanyId(request); if (!isEnabled(companyId)) { return null; } String login = ParamUtil.getString(request, getLoginParam()); if (Validator.isNull(login)) { return null; } String password = ParamUtil.getString(request, getPasswordParam()); if (Validator.isNull(password)) { return null; } Company company = PortalUtil.getCompany(request); String authType = company.getAuthType(); long userId = 0; if (authType.equals(CompanyConstants.AUTH_TYPE_EA)) { userId = _userLocalService.getUserIdByEmailAddress(company.getCompanyId(), login); } else if (authType.equals(CompanyConstants.AUTH_TYPE_SN)) { userId = _userLocalService.getUserIdByScreenName(company.getCompanyId(), login); } else if (authType.equals(CompanyConstants.AUTH_TYPE_ID)) { userId = GetterUtil.getLong(login); } else { return null; } if (userId > 0) { User user = _userLocalService.getUserById(userId); String userPassword = user.getPassword(); if (!user.isPasswordEncrypted()) { userPassword = PasswordEncryptorUtil.encrypt(userPassword); } String encPassword = PasswordEncryptorUtil.encrypt(password, userPassword); if (!userPassword.equals(password) && !userPassword.equals(encPassword)) { return null; } } String[] credentials = new String[] {String.valueOf(userId), password, Boolean.FALSE.toString()}; return credentials; }
public void editScope(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { Portlet portlet = ActionUtil.getPortlet(actionRequest); PortletPreferences portletPreferences = ActionUtil.getLayoutPortletSetup(actionRequest, portlet); actionRequest = ActionUtil.getWrappedActionRequest(actionRequest, portletPreferences); updateScope(actionRequest, portlet); if (!SessionErrors.isEmpty(actionRequest)) { return; } String portletResource = ParamUtil.getString(actionRequest, "portletResource"); SessionMessages.add( actionRequest, PortalUtil.getPortletId(actionRequest) + SessionMessages.KEY_SUFFIX_REFRESH_PORTLET, portletResource); SessionMessages.add( actionRequest, PortalUtil.getPortletId(actionRequest) + SessionMessages.KEY_SUFFIX_UPDATED_CONFIGURATION); }
@Override public String getURL(PortletRequest portletRequest, PortletResponse portletResponse) { PortletURL portletURL = PortalUtil.getControlPanelPortletURL( portletRequest, MBPortletKeys.MESSAGE_BOARDS_ADMIN, PortletRequest.ACTION_PHASE); portletURL.setParameter(ActionRequest.ACTION_NAME, "/message_boards/edit_message"); try { MBMessage message = ActionUtil.getMessage(portletRequest); MBThread thread = message.getThread(); if (thread.isLocked()) { portletURL.setParameter(Constants.CMD, Constants.UNLOCK); } else { portletURL.setParameter(Constants.CMD, Constants.LOCK); } portletURL.setParameter("redirect", PortalUtil.getCurrentURL(portletRequest)); portletURL.setParameter("threadId", String.valueOf(thread.getThreadId())); } catch (Exception e) { return null; } return portletURL.toString(); }
public static BreadcrumbEntry getGuestGroupBreadcrumbEntry(ThemeDisplay themeDisplay) throws Exception { Group group = GroupLocalServiceUtil.getGroup(themeDisplay.getCompanyId(), GroupConstants.GUEST); if (group.getPublicLayoutsPageCount() == 0) { return null; } LayoutSet layoutSet = LayoutSetLocalServiceUtil.getLayoutSet(group.getGroupId(), false); BreadcrumbEntry breadcrumbEntry = new BreadcrumbEntry(); Account account = themeDisplay.getAccount(); breadcrumbEntry.setTitle(account.getName()); String layoutSetFriendlyURL = PortalUtil.getLayoutSetFriendlyURL(layoutSet, themeDisplay); if (themeDisplay.isAddSessionIdToURL()) { layoutSetFriendlyURL = PortalUtil.getURLWithSessionId(layoutSetFriendlyURL, themeDisplay.getSessionId()); } breadcrumbEntry.setURL(layoutSetFriendlyURL); return breadcrumbEntry; }
protected void sendResponse( ActionRequest actionRequest, ActionResponse actionResponse, String msg, boolean success) throws Exception { StringBundler sb = new StringBundler(7); sb.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>"); sb.append("<response>"); if (success) { sb.append("<error>0</error>"); } else { sb.append("<error>1</error>"); sb.append("<message>"); sb.append(msg); sb.append("</message>"); } sb.append("</response>"); HttpServletRequest request = PortalUtil.getHttpServletRequest(actionRequest); HttpServletResponse response = PortalUtil.getHttpServletResponse(actionResponse); ServletResponseUtil.sendFile( request, response, null, sb.toString().getBytes(StringPool.UTF8), ContentTypes.TEXT_XML_UTF8); }
@Override public void render(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException { try { HttpServletRequest httpServletRequest = PortalUtil.getHttpServletRequest(renderRequest); httpServletRequest = PortalUtil.getOriginalServletRequest(httpServletRequest); String oAuthVerifier = httpServletRequest.getParameter(OAuthConstants.VERIFIER); if (oAuthVerifier != null) { updateAccessToken(renderRequest, oAuthVerifier); } String remoteMVCPath = renderRequest.getParameter("remoteMVCPath"); if (remoteMVCPath != null) { remoteRender(renderRequest, renderResponse); return; } } catch (IOException ioe) { throw ioe; } catch (Exception e) { throw new PortletException(e); } super.render(renderRequest, renderResponse); }
@Override protected Map<String, List<StagedModel>> addDependentStagedModelsMap(Group group) throws Exception { Map<String, List<StagedModel>> dependentStagedModelsMap = new LinkedHashMap<>(); DDMStructure ddmStructure = DDMStructureTestUtil.addStructure(group.getGroupId(), DDLRecordSet.class.getName()); DDMTemplate ddmTemplate1 = DDMTemplateTestUtil.addTemplate( group.getGroupId(), ddmStructure.getStructureId(), PortalUtil.getClassNameId(DDLRecordSet.class)); addDependentStagedModel(dependentStagedModelsMap, DDMTemplate.class, ddmTemplate1); DDMTemplate ddmTemplate2 = DDMTemplateTestUtil.addTemplate( group.getGroupId(), ddmStructure.getStructureId(), PortalUtil.getClassNameId(DDLRecordSet.class)); addDependentStagedModel(dependentStagedModelsMap, DDMTemplate.class, ddmTemplate2); addDependentStagedModel(dependentStagedModelsMap, DDMStructure.class, ddmStructure); return dependentStagedModelsMap; }
@Override public int compare(Portlet portlet1, Portlet portlet2) { String portletTitle1 = StringPool.BLANK; String portletTitle2 = StringPool.BLANK; if (_servletContext != null) { portletTitle1 = PortalUtil.getPortletTitle(portlet1, _servletContext, _locale); portletTitle2 = PortalUtil.getPortletTitle(portlet2, _servletContext, _locale); } else { portletTitle1 = PortalUtil.getPortletTitle(portlet1, _locale); portletTitle2 = PortalUtil.getPortletTitle(portlet2, _locale); } if (Validator.isNull(portletTitle1) && Validator.isNull(portletTitle2)) { return 0; } if (Validator.isNull(portletTitle1)) { return 1; } if (Validator.isNull(portletTitle2)) { return -1; } Collator collator = Collator.getInstance(_locale); return collator.compare(portletTitle1, portletTitle2); }
@Reference(target = ModuleServiceLifecycle.PORTAL_INITIALIZED, unbind = "-") protected void setModuleServiceLifecycle(ModuleServiceLifecycle moduleServiceLifecycle) { _classNameIds = new long[] { PortalUtil.getClassNameId(Company.class), PortalUtil.getClassNameId(Group.class), PortalUtil.getClassNameId(Organization.class) }; }
@Override public URL getURL(String source) throws IOException { int pos = source.indexOf(TemplateConstants.SERVLET_SEPARATOR); if (pos == -1) { return null; } String servletContextName = source.substring(0, pos); if (servletContextName.equals(PortalUtil.getPathContext())) { servletContextName = PortalUtil.getServletContextName(); } ServletContext servletContext = ServletContextPool.get(servletContextName); if (servletContext == null) { _log.error( source + " is not valid because " + servletContextName + " does not map to a servlet context"); return null; } String name = source.substring(pos + TemplateConstants.SERVLET_SEPARATOR.length()); if (_log.isDebugEnabled()) { _log.debug( name + " is associated with the servlet context " + servletContextName + " " + servletContext); } URL url = servletContext.getResource(name); if ((url == null) && name.endsWith("/init_custom.vm")) { if (_log.isWarnEnabled()) { _log.warn("The template " + name + " should be created"); } ServletContext themeClassicServletContext = PortalWebResourcesUtil.getServletContext( PortalWebResourceConstants.RESOURCE_TYPE_THEME_CLASSIC); url = themeClassicServletContext.getResource("/classic/templates/init_custom.vm"); } return url; }
@Before public void setUp() throws Exception { setUpPermissionThreadLocal(); setUpPrincipalThreadLocal(); _group = GroupTestUtil.addGroup(); setUpParentFolder(); setUpResourcePermission(); List<DLFileEntryType> dlFileEntryTypes = DLFileEntryTypeLocalServiceUtil.getFileEntryTypes( PortalUtil.getCurrentAndAncestorSiteGroupIds(_group.getGroupId())); for (DLFileEntryType dlFileEntryType : dlFileEntryTypes) { String fileEntryTypeKey = dlFileEntryType.getFileEntryTypeKey(); if (fileEntryTypeKey.equals(DLFileEntryTypeConstants.FILE_ENTRY_TYPE_KEY_CONTRACT)) { _contractDLFileEntryTypeId = dlFileEntryType.getFileEntryTypeId(); } } ExpandoTable expandoTable = ExpandoTableLocalServiceUtil.addDefaultTable( PortalUtil.getDefaultCompanyId(), DLFileEntry.class.getName()); ExpandoColumnLocalServiceUtil.addColumn( expandoTable.getTableId(), _EXPANDO_ATTRIBUTE_NAME, ExpandoColumnConstants.STRING, StringPool.BLANK); _serviceContext = getServiceContext(); FileEntry fileEntry = DLAppServiceUtil.addFileEntry( _group.getGroupId(), _parentFolder.getFolderId(), _SOURCE_FILE_NAME, ContentTypes.APPLICATION_OCTET_STREAM, _TITLE, StringPool.BLANK, StringPool.BLANK, _DATA_VERSION_1, _serviceContext); _fileVersion = DLFileVersionLocalServiceUtil.getFileVersion( fileEntry.getFileEntryId(), DLFileEntryConstants.VERSION_DEFAULT); }
protected void setBaseRequestParameters( PortletRequest portletRequest, PortletResponse portletResponse, OAuthRequest oAuthRequest) { HttpServletRequest httpServletRequest = PortalUtil.getHttpServletRequest(portletRequest); String clientAuthToken = AuthTokenUtil.getToken(httpServletRequest); addOAuthParameter(oAuthRequest, "clientAuthToken", clientAuthToken); addOAuthParameter(oAuthRequest, "clientPortletId", getClientPortletId()); addOAuthParameter( oAuthRequest, "clientURL", PortalUtil.getCurrentCompleteURL(httpServletRequest)); addOAuthParameter(oAuthRequest, "p_p_id", getServerPortletId()); }
protected DDMFormRenderingContext createDDMFormRenderingContext(DDMForm ddmForm) { String languageId = ParamUtil.getString(_renderRequest, "languageId"); DDMFormRenderingContext ddmFormRenderingContext = new DDMFormRenderingContext(); ddmFormRenderingContext.setDDMFormValues(_ddmFormValuesFactory.create(_renderRequest, ddmForm)); ddmFormRenderingContext.setHttpServletRequest(PortalUtil.getHttpServletRequest(_renderRequest)); ddmFormRenderingContext.setHttpServletResponse( PortalUtil.getHttpServletResponse(_renderResponse)); ddmFormRenderingContext.setLocale(LocaleUtil.fromLanguageId(languageId)); ddmFormRenderingContext.setPortletNamespace(_renderResponse.getNamespace()); return ddmFormRenderingContext; }
@BeforeClass public static void setUpClass() throws Exception { PortalUtil portalUtil = new PortalUtil(); portalUtil.setPortal(new PortalImpl()); PropsUtil.setProps(new PropsImpl()); ThreadLocalDistributor threadLocalDistributor = new ThreadLocalDistributor(); threadLocalDistributor.setThreadLocalSources( Arrays.asList(new KeyValuePair(SPIAgentResponseTest.class.getName(), "_threadLocal"))); threadLocalDistributor.afterPropertiesSet(); }
@BeforeClass public static void setUpClass() throws Exception { _user = UserTestUtil.addUser(); long classNameId = PortalUtil.getClassNameId(LiferayRepository.class.getName()); _group = GroupTestUtil.addGroup(); ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(_group.getGroupId()); _repository = RepositoryLocalServiceUtil.addRepository( TestPropsValues.getUserId(), _group.getGroupId(), classNameId, DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, "Repository A", StringPool.BLANK, "Test Portlet", new UnicodeProperties(), true, serviceContext); Object[] objects = setUp(_group.getGroupId(), StringPool.BLANK, serviceContext); _defaultRepositoryFolder = (Folder) objects[0]; _defaultRepositoryDLFileVersion = (DLFileVersion) objects[1]; objects = setUp(_repository.getRepositoryId(), "-NewRepository", serviceContext); _newRepositoryFolder = (Folder) objects[0]; }
protected void upgradeMicroblogActivities() throws Exception { try (LoggingTimer loggingTimer = new LoggingTimer(); PreparedStatement ps = connection.prepareStatement( "select activityId, extraData from SocialActivity where " + "classNameId = ?")) { ps.setLong(1, PortalUtil.getClassNameId(MicroblogsEntry.class)); try (ResultSet rs = ps.executeQuery()) { while (rs.next()) { long activityId = rs.getLong("activityId"); String extraData = rs.getString("extraData"); JSONObject extraDataJSONObject = JSONFactoryUtil.createJSONObject(extraData); long parentMicroblogsEntryId = extraDataJSONObject.getLong("receiverMicroblogsEntryId"); extraDataJSONObject.put("parentMicroblogsEntryId", parentMicroblogsEntryId); extraDataJSONObject.remove("receiverMicroblogsEntryId"); updateSocialActivity(activityId, extraDataJSONObject); } } } }
protected void updateParentGroupId() throws Exception { try (LoggingTimer loggingTimer = new LoggingTimer()) { long classNameId = PortalUtil.getClassNameId("com.liferay.portal.model.Layout"); try (PreparedStatement ps = connection.prepareStatement( "select groupId, classPK from Group_ where classNameId = " + classNameId); ResultSet rs = ps.executeQuery()) { while (rs.next()) { long groupId = rs.getLong("groupId"); long classPK = rs.getLong("classPK"); Object[] layout = getLayout(classPK); if (layout != null) { long layoutGroupId = (Long) layout[0]; runSQL( "update Group_ set parentGroupId = " + layoutGroupId + " where groupId = " + groupId); } } } } }
protected void remoteProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); OAuthRequest oAuthRequest = new OAuthRequest(Verb.POST, getServerPortletURL()); setRequestParameters(actionRequest, actionResponse, oAuthRequest); addOAuthParameter(oAuthRequest, "p_p_lifecycle", "1"); addOAuthParameter(oAuthRequest, "p_p_state", WindowState.NORMAL.toString()); Response response = getResponse(themeDisplay.getUser(), oAuthRequest); if (response.getCode() == HttpServletResponse.SC_FOUND) { String redirectLocation = response.getHeader(HttpHeaders.LOCATION); actionResponse.sendRedirect(redirectLocation); } else { HttpServletResponse httpServletResponse = PortalUtil.getHttpServletResponse(actionResponse); httpServletResponse.setContentType(response.getHeader(HttpHeaders.CONTENT_TYPE)); ServletResponseUtil.write(httpServletResponse, response.getStream()); } }
protected String addBasicWebContentStructureAndTemplate(long companyId) throws Exception { initJournalDDMCompositeModelsResourceActions(); Group group = _groupLocalService.getCompanyGroup(companyId); long defaultUserId = _userLocalService.getDefaultUserId(companyId); Class<?> clazz = getClass(); _defaultDDMStructureHelper.addDDMStructures( defaultUserId, group.getGroupId(), PortalUtil.getClassNameId(JournalArticle.class), clazz.getClassLoader(), "com/liferay/journal/internal/upgrade/v1_0_0/dependencies" + "/basic-web-content-structure.xml", new ServiceContext()); String defaultLanguageId = UpgradeProcessUtil.getDefaultLanguageId(companyId); Locale defaultLocale = LocaleUtil.fromLanguageId(defaultLanguageId); List<Element> structureElements = getDDMStructures(defaultLocale); Element structureElement = structureElements.get(0); return StringUtil.toUpperCase(structureElement.elementText("name")); }
protected void addDDMTemplateLinks() throws Exception { try (LoggingTimer loggingTimer = new LoggingTimer()) { long classNameId = PortalUtil.getClassNameId(DDMStructure.class.getName()); StringBundler sb = new StringBundler(6); sb.append("select DDMTemplate.templateId, JournalArticle.id_ "); sb.append("from JournalArticle inner join DDMTemplate on ("); sb.append("DDMTemplate.groupId = JournalArticle.groupId and "); sb.append("DDMTemplate.templateKey = "); sb.append("JournalArticle.DDMTemplateKey and "); sb.append("JournalArticle.classNameId != ?)"); try (PreparedStatement ps = connection.prepareStatement(sb.toString())) { ps.setLong(1, classNameId); try (ResultSet rs = ps.executeQuery()) { while (rs.next()) { long templateId = rs.getLong("templateId"); long id = rs.getLong("id_"); _ddmTemplateLinkLocalService.addTemplateLink(classNameId, id, templateId); } } } } }
public PortletURL getPortletURL() throws PortalException { PortletURL portletURL = _liferayPortletResponse.createRenderURL(); User selUser = PortalUtil.getSelectedUser(_request); if (selUser != null) { portletURL.setParameter("p_u_i_d", String.valueOf(selUser.getUserId())); } long[] selectedGroupIds = StringUtil.split(ParamUtil.getString(_request, "selectedGroupIds"), 0L); boolean includeCompany = ParamUtil.getBoolean(_request, "includeCompany"); boolean includeCurrentGroup = ParamUtil.getBoolean(_request, "includeCurrentGroup", true); boolean includeUserPersonalSite = ParamUtil.getBoolean(_request, "includeUserPersonalSite"); String eventName = ParamUtil.getString( _request, "eventName", _liferayPortletResponse.getNamespace() + "selectSite"); String target = ParamUtil.getString(_request, "target"); portletURL.setParameter("groupId", String.valueOf(getGroupId())); portletURL.setParameter("selectedGroupIds", StringUtil.merge(selectedGroupIds)); portletURL.setParameter("type", getType()); portletURL.setParameter("types", getTypes()); portletURL.setParameter("displayStyle", getDisplayStyle()); portletURL.setParameter("filter", getFilter()); portletURL.setParameter("includeCompany", String.valueOf(includeCompany)); portletURL.setParameter("includeCurrentGroup", String.valueOf(includeCurrentGroup)); portletURL.setParameter("includeUserPersonalSite", String.valueOf(includeUserPersonalSite)); portletURL.setParameter("manualMembership", String.valueOf(isManualMembership())); portletURL.setParameter("eventName", eventName); portletURL.setParameter("target", target); return portletURL; }
@Override protected void doDispatch(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException { try { User user = PortalUtil.getUser(renderRequest); RenderRequestImpl renderRequestImpl = (RenderRequestImpl) renderRequest; DynamicServletRequest dynamicRequest = (DynamicServletRequest) renderRequestImpl.getHttpServletRequest(); dynamicRequest.setParameter("p_u_i_d", String.valueOf(user.getUserId())); Group group = user.getGroup(); dynamicRequest.setParameter("groupId", String.valueOf(group.getGroupId())); ActionUtil.getGroup(renderRequest); } catch (Exception e) { throw new PortletException(e); } super.doDispatch(renderRequest, renderResponse); }
protected JournalArticle getArticle(HttpServletRequest request) { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); long groupId = ParamUtil.getLong(request, "groupId", themeDisplay.getScopeGroupId()); long classNameId = ParamUtil.getLong(request, "classNameId"); long classPK = ParamUtil.getLong(request, "classPK"); String articleId = ParamUtil.getString(request, "articleId"); int status = ParamUtil.getInteger(request, "status", WorkflowConstants.STATUS_ANY); JournalArticle article = null; if (Validator.isNotNull(articleId)) { article = _journalArticleLocalService.fetchLatestArticle(groupId, articleId, status); } else if ((classNameId > 0) && (classPK > JournalArticleConstants.CLASSNAME_ID_DEFAULT)) { String className = PortalUtil.getClassName(classNameId); try { article = _journalArticleLocalService.getLatestArticle(groupId, className, classPK); } catch (PortalException pe) { return null; } } return article; }
public void setClassName(String className) { long classNameId = PortalUtil.getClassNameId(className); _classNameIds = new long[] {classNameId}; _toString = null; }
protected AssetVocabulary addAssetVocabulary( long groupId, long companyId, String title, Map<Locale, String> nameMap, Map<Locale, String> descriptionMap) throws Exception { long userId = _userLocalService.getDefaultUserId(companyId); AssetVocabularySettingsHelper assetVocabularySettingsHelper = new AssetVocabularySettingsHelper(); assetVocabularySettingsHelper.setClassNameIdsAndClassTypePKs( new long[] {PortalUtil.getClassNameId(JournalArticle.class.getName())}, new long[] {-1}, new boolean[] {false}); assetVocabularySettingsHelper.setMultiValued(false); ServiceContext serviceContext = new ServiceContext(); serviceContext.setAddGroupPermissions(true); serviceContext.setAddGuestPermissions(true); return _assetVocabularyLocalService.addVocabulary( userId, groupId, title, nameMap, descriptionMap, assetVocabularySettingsHelper.toString(), serviceContext); }
protected boolean isGroupFriendlyURL( Group group, Layout layout, String layoutURL, Locale locale) { if (Validator.isNull(layoutURL)) { return true; } int pos = layoutURL.lastIndexOf(CharPool.SLASH); String layoutURLLanguageId = layoutURL.substring(pos + 1); Locale layoutURLLocale = LocaleUtil.fromLanguageId(layoutURLLanguageId, true, false); if (layoutURLLocale != null) { return true; } if (PortalUtil.isGroupFriendlyURL( layoutURL, group.getFriendlyURL(), layout.getFriendlyURL(locale))) { return true; } return false; }
@Override public ResourceBundle getResourceBundle(Locale locale) { ResourceBundle classResourceBundle = ResourceBundleUtil.getBundle("content.Language", locale, getClass()); return new AggregateResourceBundle(classResourceBundle, PortalUtil.getResourceBundle(locale)); }
public void restoreArchivedSetup(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { Portlet portlet = ActionUtil.getPortlet(actionRequest); ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); Settings portletInstanceSettings = SettingsFactoryUtil.getSettings( new PortletInstanceSettingsLocator(themeDisplay.getLayout(), portlet.getPortletId())); ModifiableSettings portletInstanceModifiableSettings = portletInstanceSettings.getModifiableSettings(); String name = ParamUtil.getString(actionRequest, "name"); ArchivedSettings archivedSettings = SettingsFactoryUtil.getPortletInstanceArchivedSettings( themeDisplay.getSiteGroupId(), portlet.getRootPortletId(), name); portletInstanceModifiableSettings.reset(); portletInstanceModifiableSettings.setValues(archivedSettings); portletInstanceModifiableSettings.store(); String portletResource = ParamUtil.getString(actionRequest, "portletResource"); SessionMessages.add( actionRequest, PortalUtil.getPortletId(actionRequest) + SessionMessages.KEY_SUFFIX_REFRESH_PORTLET, portletResource); }