View Javadoc
1   /*
2    * Copyright (c) 2002-2022, City of Paris
3    * All rights reserved.
4    *
5    * Redistribution and use in source and binary forms, with or without
6    * modification, are permitted provided that the following conditions
7    * are met:
8    *
9    *  1. Redistributions of source code must retain the above copyright notice
10   *     and the following disclaimer.
11   *
12   *  2. Redistributions in binary form must reproduce the above copyright notice
13   *     and the following disclaimer in the documentation and/or other materials
14   *     provided with the distribution.
15   *
16   *  3. Neither the name of 'Mairie de Paris' nor 'Lutece' nor the names of its
17   *     contributors may be used to endorse or promote products derived from
18   *     this software without specific prior written permission.
19   *
20   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23   * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
24   * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25   * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26   * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27   * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28   * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30   * POSSIBILITY OF SUCH DAMAGE.
31   *
32   * License 1.0
33   */
34  package fr.paris.lutece.portal.service.prefs;
35  
36  import java.util.List;
37  
38  /**
39   * User Preferences Interface
40   */
41  public interface IUserPreferencesService
42  {
43      /**
44       * Get a preference for a given user
45       * 
46       * @param strUserId
47       *            The user's ID
48       * @param strKey
49       *            The preference's key
50       * @param strDefault
51       *            The default value
52       * @return The preference's value
53       */
54      String get( String strUserId, String strKey, String strDefault );
55  
56      /**
57       * Get an integer preference for a given user
58       * 
59       * @param strUserId
60       *            The user's ID
61       * @param strKey
62       *            The preference's key
63       * @param nDefault
64       *            The default value
65       * @return The preference's value
66       */
67      int getInt( String strUserId, String strKey, int nDefault );
68  
69      /**
70       * Get a boolean preference for a given user
71       * 
72       * @param strUserId
73       *            The user's ID
74       * @param strKey
75       *            The preference's key
76       * @param bDefault
77       *            The default value
78       * @return The preference's value
79       */
80      boolean getBoolean( String strUserId, String strKey, boolean bDefault );
81  
82      /**
83       * Get the list of users associated with a key and a value
84       * 
85       * @param strKey
86       *            The preference's key
87       * @param strValue
88       *            The preference's value
89       * @return The list of user id associated with a key and a value, or an empty list if no user id is associated with the given parameters.
90       */
91      List<String> getUsers( String strKey, String strValue );
92  
93      /**
94       * Put a preference for a given user
95       * 
96       * @param strUserId
97       *            The user's ID
98       * @param strKey
99       *            The preference's key
100      * @param strValue
101      *            The value
102      */
103     void put( String strUserId, String strKey, String strValue );
104 
105     /**
106      * Put an integer preference for a given user
107      * 
108      * @param strUserId
109      *            The user's ID
110      * @param strKey
111      *            The preference's key
112      * @param nValue
113      *            The value
114      */
115     void putInt( String strUserId, String strKey, int nValue );
116 
117     /**
118      * Put a boolean preference for a given user
119      * 
120      * @param strUserId
121      *            The user's ID
122      * @param strKey
123      *            The preference's key
124      * @param bValue
125      *            The value
126      */
127     void putBoolean( String strUserId, String strKey, boolean bValue );
128 
129     /**
130      * Get all preference keys for a given user
131      * 
132      * @param strUserId
133      *            The user's ID
134      * @return The keys
135      */
136     List<String> keys( String strUserId );
137 
138     /**
139      * Clear all preferences for a given user
140      * 
141      * @param strUserId
142      *            The user's ID
143      */
144     void clear( String strUserId );
145 
146     /**
147      * Clear a preference for a given user
148      * 
149      * @param strUserId
150      *            The user's ID
151      * @param strKey
152      *            The preference's key
153      */
154     void clearKey( String strUserId, String strKey );
155 
156     /**
157      * Clear all preferences with a given prefix for a given user
158      * 
159      * @param strUserId
160      *            The user's ID
161      * @param strPrefix
162      *            The keys prefix
163      */
164     void clearKeyPrefix( String strUserId, String strPrefix );
165 
166     /**
167      * Cheks if a preference key exists
168      * 
169      * @param strUserId
170      *            The User ID
171      * @param strKey
172      *            The Pref key
173      * @return 1 if exists otherwise false
174      */
175     boolean existsKey( String strUserId, String strKey );
176 
177     /**
178      * Checks if a value is already used for a preference given key
179      * 
180      * @param strKey
181      *            The Pref key
182      * @param strValue
183      *            The Pref Value
184      * @return 1 if exists otherwise false
185      */
186     boolean existsValueForKey( String strKey, String strValue );
187 }