List of usage examples for com.liferay.portal.util PrefsPropsUtil getPreferences
public static PortletPreferences getPreferences(long companyId)
From source file:com.liferay.portlet.portalsettings.action.EditLDAPServerAction.java
License:Open Source License
protected UnicodeProperties addLDAPServer(long companyId, UnicodeProperties properties) throws Exception { String defaultPostfix = LDAPSettingsUtil.getPropertyPostfix(0); String[] defaultKeys = new String[_KEYS.length]; for (int i = 0; i < _KEYS.length; i++) { defaultKeys[i] = _KEYS[i] + defaultPostfix; }// ww w .ja va 2 s . c o m long ldapServerId = CounterLocalServiceUtil.increment(); String postfix = LDAPSettingsUtil.getPropertyPostfix(ldapServerId); String[] keys = properties.keySet().toArray(new String[0]); for (String key : keys) { if (ArrayUtil.contains(defaultKeys, key)) { String value = properties.remove(key); if (key.equals(PropsKeys.LDAP_SECURITY_CREDENTIALS + defaultPostfix) && value.equals(Portal.TEMP_OBFUSCATION_VALUE)) { value = PrefsPropsUtil.getString(PropsKeys.LDAP_SECURITY_CREDENTIALS); } properties.setProperty(key.replace(defaultPostfix, postfix), value); } } PortletPreferences preferences = PrefsPropsUtil.getPreferences(companyId); String ldapServerIds = preferences.getValue("ldap.server.ids", StringPool.BLANK); ldapServerIds = StringUtil.add(ldapServerIds, String.valueOf(ldapServerId)); properties.setProperty("ldap.server.ids", ldapServerIds); return properties; }
From source file:com.liferay.portlet.portalsettings.action.EditLDAPServerAction.java
License:Open Source License
protected void deleteLDAPServer(ActionRequest actionRequest) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); long ldapServerId = ParamUtil.getLong(actionRequest, "ldapServerId"); // Remove preferences String postfix = LDAPSettingsUtil.getPropertyPostfix(ldapServerId); String[] keys = new String[_KEYS.length]; for (int i = 0; i < _KEYS.length; i++) { keys[i] = _KEYS[i] + postfix;//from w ww .j ava 2 s. c o m } CompanyServiceUtil.removePreferences(themeDisplay.getCompanyId(), keys); // Update preferences PortletPreferences preferences = PrefsPropsUtil.getPreferences(themeDisplay.getCompanyId()); UnicodeProperties properties = new UnicodeProperties(); String ldapServerIds = preferences.getValue("ldap.server.ids", StringPool.BLANK); ldapServerIds = StringUtil.remove(ldapServerIds, String.valueOf(ldapServerId)); properties.put("ldap.server.ids", ldapServerIds); CompanyServiceUtil.updatePreferences(themeDisplay.getCompanyId(), properties); }