BlogsUtil.java |
1 /** 2 * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved. 3 * 4 * This library is free software; you can redistribute it and/or modify it under 5 * the terms of the GNU Lesser General Public License as published by the Free 6 * Software Foundation; either version 2.1 of the License, or (at your option) 7 * any later version. 8 * 9 * This library is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 11 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 12 * details. 13 */ 14 15 package com.liferay.portlet.blogs.util; 16 17 import com.liferay.portal.kernel.util.Validator; 18 import com.liferay.portal.util.FriendlyURLNormalizer; 19 20 /** 21 * <a href="BlogsUtil.java.html"><b><i>View Source</i></b></a> 22 * 23 * @author Brian Wing Shun Chan 24 */ 25 public class BlogsUtil { 26 27 public static String getUrlTitle(long entryId, String title) { 28 title = title.trim().toLowerCase(); 29 30 if (Validator.isNull(title) || Validator.isNumber(title) || 31 title.equals("rss")) { 32 33 return String.valueOf(entryId); 34 } 35 else { 36 return FriendlyURLNormalizer.normalize( 37 title, _URL_TITLE_REPLACE_CHARS); 38 } 39 } 40 41 private static final char[] _URL_TITLE_REPLACE_CHARS = new char[] { 42 '.', '/' 43 }; 44 45 }