List of usage examples for com.liferay.portal.kernel.util PropsKeys LOCALES
String LOCALES
To view the source code for com.liferay.portal.kernel.util PropsKeys LOCALES.
Click Source Link
From source file:com.liferay.content.targeting.service.test.util.GroupTestUtil.java
License:Open Source License
public static Group updateDisplaySettings(long groupId, Locale[] availableLocales, Locale defaultLocale) throws Exception { UnicodeProperties typeSettingsProperties = new UnicodeProperties(); boolean inheritLocales = false; if ((availableLocales == null) && (defaultLocale == null)) { inheritLocales = true;//www . ja va 2 s. co m } typeSettingsProperties.put("inheritLocales", String.valueOf(inheritLocales)); if (availableLocales != null) { typeSettingsProperties.put(PropsKeys.LOCALES, StringUtil.merge(LocaleUtil.toLanguageIds(availableLocales))); } if (defaultLocale != null) { typeSettingsProperties.put("languageId", LocaleUtil.toLanguageId(defaultLocale)); } Group group = GroupLocalServiceUtil.updateGroup(groupId, typeSettingsProperties.toString()); ThreadLocalCacheManager.clearAll(Lifecycle.REQUEST); return group; }
From source file:com.liferay.tools.sourceformatter.XMLSourceProcessor.java
License:Open Source License
protected String formatWebXML(String fileName, String content) throws Exception { if (!portalSource) { String webXML = ContentUtil.get("com/liferay/portal/deploy/dependencies/web.xml"); if (content.equals(webXML)) { processErrorMessage(fileName, fileName); }/*from w w w . j a v a 2 s . c o m*/ return content; } Properties properties = new Properties(); String propertiesContent = fileUtil.read(BASEDIR + "portal-impl/src/portal.properties"); PropertiesUtil.load(properties, propertiesContent); String[] locales = StringUtil.split(properties.getProperty(PropsKeys.LOCALES)); Arrays.sort(locales); Set<String> urlPatterns = new TreeSet<String>(); for (String locale : locales) { int pos = locale.indexOf(StringPool.UNDERLINE); String languageCode = locale.substring(0, pos); urlPatterns.add(languageCode); urlPatterns.add(locale); } StringBundler sb = new StringBundler(6 * urlPatterns.size()); for (String urlPattern : urlPatterns) { sb.append("\t<servlet-mapping>\n"); sb.append("\t\t<servlet-name>I18n Servlet</servlet-name>\n"); sb.append("\t\t<url-pattern>/"); sb.append(urlPattern); sb.append("/*</url-pattern>\n"); sb.append("\t</servlet-mapping>\n"); } int x = content.indexOf("<servlet-mapping>"); x = content.indexOf("<servlet-name>I18n Servlet</servlet-name>", x); x = content.lastIndexOf("<servlet-mapping>", x) - 1; int y = content.lastIndexOf("<servlet-name>I18n Servlet</servlet-name>"); y = content.indexOf("</servlet-mapping>", y) + 19; String newContent = content.substring(0, x) + sb.toString() + content.substring(y); x = newContent.indexOf("<security-constraint>"); x = newContent.indexOf("<web-resource-name>/c/portal/protected</web-resource-name>", x); x = newContent.indexOf("<url-pattern>", x) - 3; y = newContent.indexOf("<http-method>", x); y = newContent.lastIndexOf("</url-pattern>", y) + 15; sb = new StringBundler(3 * urlPatterns.size() + 1); sb.append("\t\t\t<url-pattern>/c/portal/protected</url-pattern>\n"); for (String urlPattern : urlPatterns) { sb.append("\t\t\t<url-pattern>/"); sb.append(urlPattern); sb.append("/c/portal/protected</url-pattern>\n"); } return newContent.substring(0, x) + sb.toString() + newContent.substring(y); }