001
014
015 package com.liferay.portlet.documentlibrary;
016
017 import com.liferay.portal.kernel.exception.PortalException;
018 import com.liferay.portal.kernel.settings.FallbackKeys;
019 import com.liferay.portal.kernel.settings.GroupServiceSettingsLocator;
020 import com.liferay.portal.kernel.settings.LocalizedValuesMap;
021 import com.liferay.portal.kernel.settings.ParameterMapSettings;
022 import com.liferay.portal.kernel.settings.Settings;
023 import com.liferay.portal.kernel.settings.SettingsFactoryUtil;
024 import com.liferay.portal.kernel.settings.TypedSettings;
025 import com.liferay.portal.kernel.util.LocalizationUtil;
026 import com.liferay.portal.kernel.util.PropsKeys;
027 import com.liferay.portlet.documentlibrary.constants.DLConstants;
028
029 import java.util.Map;
030
031
034 @Settings.Config(settingsIds = DLConstants.SERVICE_NAME)
035 public class DLGroupServiceSettings {
036
037 public static DLGroupServiceSettings getInstance(long groupId)
038 throws PortalException {
039
040 Settings settings = SettingsFactoryUtil.getSettings(
041 new GroupServiceSettingsLocator(groupId, DLConstants.SERVICE_NAME));
042
043 return new DLGroupServiceSettings(settings);
044 }
045
046 public static DLGroupServiceSettings getInstance(
047 long groupId, Map<String, String[]> parameterMap)
048 throws PortalException {
049
050 Settings settings = SettingsFactoryUtil.getSettings(
051 new GroupServiceSettingsLocator(groupId, DLConstants.SERVICE_NAME));
052
053 Settings parameterMapSettings = new ParameterMapSettings(
054 parameterMap, settings);
055
056 return new DLGroupServiceSettings(parameterMapSettings);
057 }
058
059 public static void registerSettingsMetadata() {
060 SettingsFactoryUtil.registerSettingsMetadata(
061 DLGroupServiceSettings.class, null, _getFallbackKeys());
062 }
063
064 public DLGroupServiceSettings(Settings settings) {
065 _typedSettings = new TypedSettings(settings);
066 }
067
068 public LocalizedValuesMap getEmailFileEntryAddedBody() {
069 return _typedSettings.getLocalizedValuesMap("emailFileEntryAddedBody");
070 }
071
072 @Settings.Property(ignore = true)
073 public String getEmailFileEntryAddedBodyXml() {
074 return LocalizationUtil.getXml(
075 getEmailFileEntryAddedBody(), "emailFileEntryAdded");
076 }
077
078 public LocalizedValuesMap getEmailFileEntryAddedSubject() {
079 return _typedSettings.getLocalizedValuesMap(
080 "emailFileEntryAddedSubject");
081 }
082
083 @Settings.Property(ignore = true)
084 public String getEmailFileEntryAddedSubjectXml() {
085 return LocalizationUtil.getXml(
086 getEmailFileEntryAddedSubject(), "emailFileEntryAddedSubject");
087 }
088
089 public LocalizedValuesMap getEmailFileEntryUpdatedBody() {
090 return _typedSettings.getLocalizedValuesMap(
091 "emailFileEntryUpdatedBody");
092 }
093
094 @Settings.Property(ignore = true)
095 public String getEmailFileEntryUpdatedBodyXml() {
096 return LocalizationUtil.getXml(
097 getEmailFileEntryUpdatedBody(), "emailFileEntryUpdatedBody");
098 }
099
100 public LocalizedValuesMap getEmailFileEntryUpdatedSubject() {
101 return _typedSettings.getLocalizedValuesMap(
102 "emailFileEntryUpdatedSubject");
103 }
104
105 @Settings.Property(ignore = true)
106 public String getEmailFileEntryUpdatedSubjectXml() {
107 return LocalizationUtil.getXml(
108 getEmailFileEntryUpdatedSubject(), "emailFileEntryUpdatedSubject");
109 }
110
111 public String getEmailFromAddress() {
112 return _typedSettings.getValue("emailFromAddress");
113 }
114
115 public String getEmailFromName() {
116 return _typedSettings.getValue("emailFromName");
117 }
118
119 public boolean isEmailFileEntryAddedEnabled() {
120 return _typedSettings.getBooleanValue("emailFileEntryAddedEnabled");
121 }
122
123 public boolean isEmailFileEntryUpdatedEnabled() {
124 return _typedSettings.getBooleanValue("emailFileEntryUpdatedEnabled");
125 }
126
127 public boolean isShowHiddenMountFolders() {
128 return _typedSettings.getBooleanValue("showHiddenMountFolders");
129 }
130
131 private static FallbackKeys _getFallbackKeys() {
132 FallbackKeys fallbackKeys = new FallbackKeys();
133
134 fallbackKeys.add(
135 "emailFileEntryAddedBody",
136 PropsKeys.DL_EMAIL_FILE_ENTRY_ADDED_BODY);
137 fallbackKeys.add(
138 "emailFileEntryAddedEnabled",
139 PropsKeys.DL_EMAIL_FILE_ENTRY_ADDED_ENABLED);
140 fallbackKeys.add(
141 "emailFileEntryAddedSubject",
142 PropsKeys.DL_EMAIL_FILE_ENTRY_ADDED_SUBJECT);
143 fallbackKeys.add(
144 "emailFileEntryUpdatedBody",
145 PropsKeys.DL_EMAIL_FILE_ENTRY_UPDATED_BODY);
146 fallbackKeys.add(
147 "emailFileEntryUpdatedEnabled",
148 PropsKeys.DL_EMAIL_FILE_ENTRY_UPDATED_ENABLED);
149 fallbackKeys.add(
150 "emailFileEntryUpdatedSubject",
151 PropsKeys.DL_EMAIL_FILE_ENTRY_UPDATED_SUBJECT);
152 fallbackKeys.add(
153 "emailFromAddress", PropsKeys.DL_EMAIL_FROM_ADDRESS,
154 PropsKeys.ADMIN_EMAIL_FROM_ADDRESS);
155 fallbackKeys.add(
156 "emailFromName", PropsKeys.DL_EMAIL_FROM_NAME,
157 PropsKeys.ADMIN_EMAIL_FROM_NAME);
158 fallbackKeys.add(
159 "enableCommentRatings", PropsKeys.DL_COMMENT_RATINGS_ENABLED);
160 fallbackKeys.add("enableRatings", PropsKeys.DL_RATINGS_ENABLED);
161 fallbackKeys.add(
162 "enableRelatedAssets", PropsKeys.DL_RELATED_ASSETS_ENABLED);
163 fallbackKeys.add(
164 "entriesPerPage", PropsKeys.SEARCH_CONTAINER_PAGE_DEFAULT_DELTA);
165 fallbackKeys.add("entryColumns", PropsKeys.DL_ENTRY_COLUMNS);
166 fallbackKeys.add("fileEntryColumns", PropsKeys.DL_FILE_ENTRY_COLUMNS);
167 fallbackKeys.add("folderColumns", PropsKeys.DL_FOLDER_COLUMNS);
168 fallbackKeys.add(
169 "foldersPerPage", PropsKeys.SEARCH_CONTAINER_PAGE_DEFAULT_DELTA);
170 fallbackKeys.add(
171 "fileEntriesPerPage",
172 PropsKeys.SEARCH_CONTAINER_PAGE_DEFAULT_DELTA);
173 fallbackKeys.add(
174 "showFoldersSearch", PropsKeys.DL_FOLDERS_SEARCH_VISIBLE);
175 fallbackKeys.add(
176 "showHiddenMountFolders", PropsKeys.DL_SHOW_HIDDEN_MOUNT_FOLDERS);
177 fallbackKeys.add("showSubfolders", PropsKeys.DL_SUBFOLDERS_VISIBLE);
178
179 return fallbackKeys;
180 }
181
182 static {
183 SettingsFactoryUtil.registerSettingsMetadata(
184 DLGroupServiceSettings.class, null, _getFallbackKeys());
185 }
186
187 private final TypedSettings _typedSettings;
188
189 }