001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.util;
016    
017    import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
018    
019    import java.util.Properties;
020    
021    import javax.portlet.PortletPreferences;
022    
023    /**
024     * @author Brian Wing Shun Chan
025     */
026    public class PrefsPropsUtil {
027    
028            public static boolean getBoolean(long companyId, String name) {
029                    return getPrefsProps().getBoolean(companyId, name);
030            }
031    
032            public static boolean getBoolean(
033                    long companyId, String name, boolean defaultValue) {
034    
035                    return getPrefsProps().getBoolean(companyId, name, defaultValue);
036            }
037    
038            /**
039             * @deprecated As of 7.0.0, replaced by {@link
040             *             #getBoolean(PortletPreferences, String)}
041             */
042            @Deprecated
043            public static boolean getBoolean(
044                    PortletPreferences preferences, long companyId, String name) {
045    
046                    return getBoolean(preferences, name);
047            }
048    
049            /**
050             * @deprecated As of 7.0.0, replaced by {@link
051             *             #getBoolean(PortletPreferences, String, boolean)}
052             */
053            @Deprecated
054            public static boolean getBoolean(
055                    PortletPreferences preferences, long companyId, String name,
056                    boolean defaultValue) {
057    
058                    return getBoolean(preferences, name, defaultValue);
059            }
060    
061            public static boolean getBoolean(
062                    PortletPreferences preferences, String name) {
063    
064                    return getPrefsProps().getBoolean(preferences, name);
065            }
066    
067            public static boolean getBoolean(
068                    PortletPreferences preferences, String name, boolean defaultValue) {
069    
070                    return getPrefsProps().getBoolean(preferences, name, defaultValue);
071            }
072    
073            public static boolean getBoolean(String name) {
074                    return getPrefsProps().getBoolean(name);
075            }
076    
077            public static boolean getBoolean(String name, boolean defaultValue) {
078                    return getPrefsProps().getBoolean(name, defaultValue);
079            }
080    
081            public static String getContent(long companyId, String name) {
082                    return getPrefsProps().getContent(companyId, name);
083            }
084    
085            /**
086             * @deprecated As of 7.0.0, replaced by {@link
087             *             #getContent(PortletPreferences, String)}
088             */
089            @Deprecated
090            public static String getContent(
091                    PortletPreferences preferences, long companyId, String name) {
092    
093                    return getContent(preferences, name);
094            }
095    
096            public static String getContent(
097                    PortletPreferences preferences, String name) {
098    
099                    return getPrefsProps().getContent(preferences, name);
100            }
101    
102            public static String getContent(String name) {
103                    return getPrefsProps().getContent(name);
104            }
105    
106            public static double getDouble(long companyId, String name) {
107                    return getPrefsProps().getDouble(companyId, name);
108            }
109    
110            public static double getDouble(
111                    long companyId, String name, double defaultValue) {
112    
113                    return getPrefsProps().getDouble(companyId, name, defaultValue);
114            }
115    
116            /**
117             * @deprecated As of 7.0.0, replaced by {@link
118             *             #getDouble(PortletPreferences, String)}
119             */
120            @Deprecated
121            public static double getDouble(
122                    PortletPreferences preferences, long companyId, String name) {
123    
124                    return getDouble(preferences, name);
125            }
126    
127            /**
128             * @deprecated As of 7.0.0, replaced by {@link
129             *             #getDouble(PortletPreferences, String, double)}
130             */
131            @Deprecated
132            public static double getDouble(
133                    PortletPreferences preferences, long companyId, String name,
134                    double defaultValue) {
135    
136                    return getDouble(preferences, name, defaultValue);
137            }
138    
139            public static double getDouble(
140                    PortletPreferences preferences, String name) {
141    
142                    return getPrefsProps().getDouble(preferences, name);
143            }
144    
145            public static double getDouble(
146                    PortletPreferences preferences, String name, double defaultValue) {
147    
148                    return getPrefsProps().getDouble(preferences, name, defaultValue);
149            }
150    
151            public static double getDouble(String name) {
152                    return getPrefsProps().getDouble(name);
153            }
154    
155            public static double getDouble(String name, double defaultValue) {
156                    return getPrefsProps().getDouble(name, defaultValue);
157            }
158    
159            public static int getInteger(long companyId, String name) {
160                    return getPrefsProps().getInteger(companyId, name);
161            }
162    
163            public static int getInteger(
164                    long companyId, String name, int defaultValue) {
165    
166                    return getPrefsProps().getInteger(companyId, name, defaultValue);
167            }
168    
169            /**
170             * @deprecated As of 7.0.0, replaced by {@link
171             *             #getInteger(PortletPreferences, String)}
172             */
173            @Deprecated
174            public static int getInteger(
175                    PortletPreferences preferences, long companyId, String name) {
176    
177                    return getInteger(preferences, name);
178            }
179    
180            /**
181             * @deprecated As of 7.0.0, replaced by {@link
182             *             #getInteger(PortletPreferences, String, int)}
183             */
184            @Deprecated
185            public static int getInteger(
186                    PortletPreferences preferences, long companyId, String name,
187                    int defaultValue) {
188    
189                    return getInteger(preferences, name, defaultValue);
190            }
191    
192            public static int getInteger(PortletPreferences preferences, String name) {
193                    return getPrefsProps().getInteger(preferences, name);
194            }
195    
196            public static int getInteger(
197                    PortletPreferences preferences, String name, int defaultValue) {
198    
199                    return getPrefsProps().getInteger(preferences, name, defaultValue);
200            }
201    
202            public static int getInteger(String name) {
203                    return getPrefsProps().getInteger(name);
204            }
205    
206            public static int getInteger(String name, int defaultValue) {
207                    return getPrefsProps().getInteger(name, defaultValue);
208            }
209    
210            public static long getLong(long companyId, String name) {
211                    return getPrefsProps().getLong(companyId, name);
212            }
213    
214            public static long getLong(long companyId, String name, long defaultValue) {
215                    return getPrefsProps().getLong(companyId, name, defaultValue);
216            }
217    
218            /**
219             * @deprecated As of 7.0.0, replaced by {@link
220             *             #getLong(PortletPreferences, String)}
221             */
222            @Deprecated
223            public static long getLong(
224                    PortletPreferences preferences, long companyId, String name) {
225    
226                    return getLong(preferences, name);
227            }
228    
229            /**
230             * @deprecated As of 7.0.0, replaced by {@link
231             *             #getLong(PortletPreferences, String, long)}
232             */
233            @Deprecated
234            public static long getLong(
235                    PortletPreferences preferences, long companyId, String name,
236                    long defaultValue) {
237    
238                    return getLong(preferences, name, defaultValue);
239            }
240    
241            public static long getLong(PortletPreferences preferences, String name) {
242                    return getPrefsProps().getLong(preferences, name);
243            }
244    
245            public static long getLong(
246                    PortletPreferences preferences, String name, long defaultValue) {
247    
248                    return getPrefsProps().getLong(preferences, name, defaultValue);
249            }
250    
251            public static long getLong(String name) {
252                    return getPrefsProps().getLong(name);
253            }
254    
255            public static long getLong(String name, long defaultValue) {
256                    return getPrefsProps().getLong(name, defaultValue);
257            }
258    
259            public static PortletPreferences getPreferences() {
260                    return getPrefsProps().getPreferences();
261            }
262    
263            public static PortletPreferences getPreferences(boolean readOnly) {
264                    return getPrefsProps().getPreferences(readOnly);
265            }
266    
267            public static PortletPreferences getPreferences(long companyId) {
268                    return getPrefsProps().getPreferences(companyId);
269            }
270    
271            public static PortletPreferences getPreferences(
272                    long companyId, boolean readOnly) {
273    
274                    return getPrefsProps().getPreferences(companyId, readOnly);
275            }
276    
277            public static PrefsProps getPrefsProps() {
278                    PortalRuntimePermission.checkGetBeanProperty(PrefsPropsUtil.class);
279    
280                    return _prefsProps;
281            }
282    
283            /**
284             * @deprecated As of 7.0.0, replaced by {@link
285             *             #getProperties(PortletPreferences, String, boolean)}
286             */
287            @Deprecated
288            public static Properties getProperties(
289                    PortletPreferences preferences, long companyId, String prefix,
290                    boolean removePrefix) {
291    
292                    return getProperties(preferences, prefix, removePrefix);
293            }
294    
295            public static Properties getProperties(
296                    PortletPreferences preferences, String prefix, boolean removePrefix) {
297    
298                    return getPrefsProps().getProperties(preferences, prefix, removePrefix);
299            }
300    
301            public static Properties getProperties(
302                    String prefix, boolean removePrefix) {
303    
304                    return getPrefsProps().getProperties(prefix, removePrefix);
305            }
306    
307            public static short getShort(long companyId, String name) {
308                    return getPrefsProps().getShort(companyId, name);
309            }
310    
311            public static short getShort(
312                    long companyId, String name, short defaultValue) {
313    
314                    return getPrefsProps().getShort(companyId, name, defaultValue);
315            }
316    
317            /**
318             * @deprecated As of 7.0.0, replaced by {@link
319             *             #getShort(PortletPreferences, String)}
320             */
321            @Deprecated
322            public static short getShort(
323                    PortletPreferences preferences, long companyId, String name) {
324    
325                    return getShort(preferences, name);
326            }
327    
328            /**
329             * @deprecated As of 7.0.0, replaced by {@link
330             *             #getShort(PortletPreferences, String, short)}
331             */
332            @Deprecated
333            public static short getShort(
334                    PortletPreferences preferences, long companyId, String name,
335                    short defaultValue) {
336    
337                    return getShort(preferences, name, defaultValue);
338            }
339    
340            public static short getShort(PortletPreferences preferences, String name) {
341                    return getPrefsProps().getShort(preferences, name);
342            }
343    
344            public static short getShort(
345                    PortletPreferences preferences, String name, short defaultValue) {
346    
347                    return getPrefsProps().getShort(preferences, name, defaultValue);
348            }
349    
350            public static short getShort(String name) {
351                    return getPrefsProps().getShort(name);
352            }
353    
354            public static short getShort(String name, short defaultValue) {
355                    return getPrefsProps().getShort(name, defaultValue);
356            }
357    
358            public static String getString(long companyId, String name) {
359                    return getPrefsProps().getString(companyId, name);
360            }
361    
362            public static String getString(
363                    long companyId, String name, String defaultValue) {
364    
365                    return getPrefsProps().getString(companyId, name, defaultValue);
366            }
367    
368            /**
369             * @deprecated As of 7.0.0, replaced by {@link
370             *             #getString(PortletPreferences, String)}
371             */
372            @Deprecated
373            public static String getString(
374                    PortletPreferences preferences, long companyId, String name) {
375    
376                    return getString(preferences, name);
377            }
378    
379            /**
380             * @deprecated As of 7.0.0, replaced by {@link
381             *             #getString(PortletPreferences, String, boolean)}
382             */
383            @Deprecated
384            public static String getString(
385                    PortletPreferences preferences, long companyId, String name,
386                    boolean defaultValue) {
387    
388                    return getString(preferences, name, defaultValue);
389            }
390    
391            /**
392             * @deprecated As of 7.0.0, replaced by {@link
393             *             #getString(PortletPreferences, String, double)}
394             */
395            @Deprecated
396            public static String getString(
397                    PortletPreferences preferences, long companyId, String name,
398                    double defaultValue) {
399    
400                    return getString(preferences, name, defaultValue);
401            }
402    
403            /**
404             * @deprecated As of 7.0.0, replaced by {@link
405             *             #getString(PortletPreferences, String, int)}
406             */
407            @Deprecated
408            public static String getString(
409                    PortletPreferences preferences, long companyId, String name,
410                    int defaultValue) {
411    
412                    return getString(preferences, name, defaultValue);
413            }
414    
415            /**
416             * @deprecated As of 7.0.0, replaced by {@link
417             *             #getString(PortletPreferences, String, long)}
418             */
419            @Deprecated
420            public static String getString(
421                    PortletPreferences preferences, long companyId, String name,
422                    long defaultValue) {
423    
424                    return getString(preferences, name, defaultValue);
425            }
426    
427            /**
428             * @deprecated As of 7.0.0, replaced by {@link
429             *             #getString(PortletPreferences, String, short)}
430             */
431            @Deprecated
432            public static String getString(
433                    PortletPreferences preferences, long companyId, String name,
434                    short defaultValue) {
435    
436                    return getString(preferences, name, defaultValue);
437            }
438    
439            /**
440             * @deprecated As of 7.0.0, replaced by {@link
441             *             #getString(PortletPreferences, String, String)}
442             */
443            @Deprecated
444            public static String getString(
445                    PortletPreferences preferences, long companyId, String name,
446                    String defaultValue) {
447    
448                    return getString(preferences, name, defaultValue);
449            }
450    
451            public static String getString(
452                    PortletPreferences preferences, String name) {
453    
454                    return getPrefsProps().getString(preferences, name);
455            }
456    
457            public static String getString(
458                    PortletPreferences preferences, String name, boolean defaultValue) {
459    
460                    return getPrefsProps().getString(preferences, name, defaultValue);
461            }
462    
463            public static String getString(
464                    PortletPreferences preferences, String name, double defaultValue) {
465    
466                    return getPrefsProps().getString(preferences, name, defaultValue);
467            }
468    
469            public static String getString(
470                    PortletPreferences preferences, String name, int defaultValue) {
471    
472                    return getPrefsProps().getString(preferences, name, defaultValue);
473            }
474    
475            public static String getString(
476                    PortletPreferences preferences, String name, long defaultValue) {
477    
478                    return getPrefsProps().getString(preferences, name, defaultValue);
479            }
480    
481            public static String getString(
482                    PortletPreferences preferences, String name, short defaultValue) {
483    
484                    return getPrefsProps().getString(preferences, name, defaultValue);
485            }
486    
487            public static String getString(
488                    PortletPreferences preferences, String name, String defaultValue) {
489    
490                    return getPrefsProps().getString(preferences, name, defaultValue);
491            }
492    
493            public static String getString(String name) {
494                    return getPrefsProps().getString(name);
495            }
496    
497            public static String getString(String name, String defaultValue) {
498                    return getPrefsProps().getString(name, defaultValue);
499            }
500    
501            public static String[] getStringArray(
502                    long companyId, String name, String delimiter) {
503    
504                    return getPrefsProps().getStringArray(companyId, name, delimiter);
505            }
506    
507            public static String[] getStringArray(
508                    long companyId, String name, String delimiter, String[] defaultValue) {
509    
510                    return getPrefsProps().getStringArray(
511                            companyId, name, delimiter, defaultValue);
512            }
513    
514            /**
515             * @deprecated As of 7.0.0, replaced by {@link
516             *             #getStringArray(PortletPreferences, String, String)}
517             */
518            @Deprecated
519            public static String[] getStringArray(
520                    PortletPreferences preferences, long companyId, String name,
521                    String delimiter) {
522    
523                    return getStringArray(preferences, name, delimiter);
524            }
525    
526            /**
527             * @deprecated As of 7.0.0, replaced by {@link
528             *             #getStringArray(PortletPreferences, String, String,
529             *             String[])}
530             */
531            @Deprecated
532            public static String[] getStringArray(
533                    PortletPreferences preferences, long companyId, String name,
534                    String delimiter, String[] defaultValue) {
535    
536                    return getStringArray(preferences, name, delimiter, defaultValue);
537            }
538    
539            public static String[] getStringArray(
540                    PortletPreferences preferences, String name, String delimiter) {
541    
542                    return getPrefsProps().getStringArray(preferences, name, delimiter);
543            }
544    
545            public static String[] getStringArray(
546                    PortletPreferences preferences, String name, String delimiter,
547                    String[] defaultValue) {
548    
549                    return getPrefsProps().getStringArray(
550                            preferences, name, delimiter, defaultValue);
551            }
552    
553            public static String[] getStringArray(String name, String delimiter) {
554                    return getPrefsProps().getStringArray(name, delimiter);
555            }
556    
557            public static String[] getStringArray(
558                    String name, String delimiter, String[] defaultValue) {
559    
560                    return getPrefsProps().getStringArray(name, delimiter, defaultValue);
561            }
562    
563            public static String getStringFromNames(long companyId, String... names) {
564                    return getPrefsProps().getStringFromNames(companyId, names);
565            }
566    
567            public void setPrefsProps(PrefsProps prefsProps) {
568                    PortalRuntimePermission.checkSetBeanProperty(getClass());
569    
570                    _prefsProps = prefsProps;
571            }
572    
573            private static PrefsProps _prefsProps;
574    
575    }