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.business.prefs;
35  
36  import java.util.List;
37  
38  /**
39   * Preferences DAO interface
40   */
41  public interface IPreferencesDAO
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 load( String strUserId, String strKey, String strDefault );
55  
56      /**
57       * Get the list of user id associated with the given key and value
58       * 
59       * @param strKey
60       *            The preference's key
61       * @param strValue
62       *            The preference's value
63       * @return The list of user id associated with the given key and value. If there is no user id associated with the parameters, then an empty list is
64       *         returned
65       */
66      List<String> getUserId( String strKey, String strValue );
67  
68      /**
69       * Store a preference for a given user
70       * 
71       * @param strUserId
72       *            The user's ID
73       * @param strKey
74       *            The preference's key
75       * @param strValue
76       *            The value
77       */
78      void store( String strUserId, String strKey, String strValue );
79  
80      /**
81       * Get all preference keys for a given user
82       * 
83       * @param strUserId
84       *            The user's ID
85       * @return The keys
86       */
87      List<String> keys( String strUserId );
88  
89      /**
90       * Clear all preferences for a given user
91       * 
92       * @param strUserId
93       *            The user's ID
94       */
95      void remove( String strUserId );
96  
97      /**
98       * Clear all preferences for a given user
99       * 
100      * @param strUserId
101      *            The user's ID
102      * @param strKey
103      *            The preference's key
104      */
105     void removeKey( String strUserId, String strKey );
106 
107     /**
108      * Clear all preferences for a given user
109      * 
110      * @param strUserId
111      *            The user's ID
112      * @param strKeyPrefix
113      *            The key prefix
114      */
115     void removeKeyPrefix( String strUserId, String strKeyPrefix );
116 
117     /**
118      * Cheks if a preference key exists
119      * 
120      * @param strUserId
121      *            The User ID
122      * @param strKey
123      *            The Pref key
124      * @return 1 if exists otherwise false
125      */
126     boolean existsKey( String strUserId, String strKey );
127 
128     /**
129      * Checks if a value is already used for a preference given key
130      * 
131      * @param strKey
132      *            The Pref key
133      * @param strValue
134      *            The Pref value
135      * @return 1 if exists otherwise false
136      */
137     boolean existsValueForKey( String strKey, String strValue );
138 
139 }