protected void updateURLTitle(long groupId, String articleId, String urlTitle) throws Exception { String normalizedURLTitle = FriendlyURLNormalizerUtil.normalize(urlTitle, _friendlyURLPattern); if (urlTitle.equals(normalizedURLTitle)) { return; } normalizedURLTitle = JournalArticleLocalServiceUtil.getUniqueUrlTitle(groupId, articleId, normalizedURLTitle); Connection con = null; PreparedStatement ps = null; try { con = DataAccess.getUpgradeOptimizedConnection(); ps = con.prepareStatement("update JournalArticle set urlTitle = ? where urlTitle = ?"); ps.setString(1, normalizedURLTitle); ps.setString(2, urlTitle); ps.executeUpdate(); } finally { DataAccess.cleanUp(con, ps); } }
protected Group addScopeGroup() throws Exception { Group group = GroupTestUtil.addGroup(); Layout layout = LayoutTestUtil.addLayout(group.getGroupId(), ServiceTestUtil.randomString()); String name = ServiceTestUtil.randomString(); ServiceContext serviceContext = ServiceTestUtil.getServiceContext(group.getGroupId()); Group scopeGroup = GroupLocalServiceUtil.addGroup( TestPropsValues.getUserId(), group.getParentGroupId(), Layout.class.getName(), layout.getPlid(), GroupConstants.DEFAULT_LIVE_GROUP_ID, name, ServiceTestUtil.randomString(), GroupConstants.TYPE_SITE_OPEN, true, GroupConstants.DEFAULT_MEMBERSHIP_RESTRICTION, StringPool.SLASH + FriendlyURLNormalizerUtil.normalize(name), false, true, serviceContext); return scopeGroup; }
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; }
private void _buildNormalizedHeaderNames(List<String> headerNames) { if (headerNames == null) { return; } _normalizedHeaderNames = new ArrayList<>(headerNames.size()); for (String headerName : headerNames) { _normalizedHeaderNames.add(FriendlyURLNormalizerUtil.normalize(headerName)); } }
/** See {@link com.liferay.knowledge.base.util.KnowledgeBaseUtil#getUrlTitle(long, String)} */ private String _getUrlTitle(long id, String title) { if (title == null) { return String.valueOf(id); } title = StringUtil.toLowerCase(title.trim()); if (Validator.isNull(title) || Validator.isNumber(title) || title.equals("rss")) { title = String.valueOf(id); } else { title = FriendlyURLNormalizerUtil.normalize(title, _normalizationFriendlyUrlPattern); } return title.substring(0, 75); }
@Test public void testWithModuleLayoutTypeController() throws Exception { final String prpName = "categoryId"; final String prpValue = RandomTestUtil.randomString( FriendlyURLRandomizerBumper.INSTANCE, NumericStringRandomizerBumper.INSTANCE, UniqueStringRandomizerBumper.INSTANCE); final AtomicBoolean success = new AtomicBoolean(false); properties.put( "com.liferay.portlet.application-type", new String[] { ApplicationType.FULL_PAGE_APPLICATION.toString(), ApplicationType.WIDGET.toString() }); properties.put("javax.portlet.supported-public-render-parameter", prpName); testPortlet = new TestPortlet() { @Override public void render(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException { PrintWriter writer = renderResponse.getWriter(); String value = renderRequest.getParameter(prpName); if (prpValue.equals(value)) { success.set(true); } writer.write(value); } }; setUpPortlet(testPortlet, properties, TEST_PORTLET_ID, false); Portlet portlet = PortletLocalServiceUtil.getPortletById(TestPropsValues.getCompanyId(), TEST_PORTLET_ID); Assert.assertFalse(portlet.isUndeployedPortlet()); String name = RandomTestUtil.randomString( FriendlyURLRandomizerBumper.INSTANCE, NumericStringRandomizerBumper.INSTANCE, UniqueStringRandomizerBumper.INSTANCE); layout = LayoutLocalServiceUtil.addLayout( TestPropsValues.getUserId(), group.getGroupId(), false, LayoutConstants.DEFAULT_PARENT_LAYOUT_ID, name, null, null, "full_page_application", false, StringPool.SLASH + FriendlyURLNormalizerUtil.normalize(name), ServiceContextTestUtil.getServiceContext()); HttpServletRequest httpServletRequest = getHttpServletRequest(); PortletURL portletURL = new PortletURLImpl( httpServletRequest, TEST_PORTLET_ID, layout.getPlid(), PortletRequest.RENDER_PHASE); portletURL.setParameter(prpName, prpValue); String portletURLString = portletURL.toString(); Assert.assertTrue(portletURLString.contains(PortletQName.PUBLIC_RENDER_PARAMETER_NAMESPACE)); Map<String, List<String>> responseMap = request(portletURLString); Assert.assertEquals("200", getString(responseMap, "code")); Assert.assertTrue(success.get()); }