]> git.mxchange.org Git - addressbook-war.git/blob - src/java/org/mxchange/addressbook/beans/addressbook/AddressbookWebController.java
Implemented isOwnAddressbook() and isOtherAddressbook()
[addressbook-war.git] / src / java / org / mxchange / addressbook / beans / addressbook / AddressbookWebController.java
1 /*
2  * Copyright (C) 2015 Roland Haeder
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17 package org.mxchange.addressbook.beans.addressbook;
18
19 import java.io.Serializable;
20 import java.util.Calendar;
21 import java.util.List;
22 import org.mxchange.addressbook.events.addressbook.AddressbookLoadedEvent;
23 import org.mxchange.addressbook.model.addressbook.Addressbook;
24 import org.mxchange.addressbook.model.addressbook.entry.AddressbookEntry;
25 import org.mxchange.addressbook.model.addressbook.shared.ShareableAddressbook;
26 import org.mxchange.jusercore.events.login.UserLoggedInEvent;
27 import org.mxchange.jusercore.model.user.User;
28
29 /**
30  * An interface for address book beans
31  * <p>
32  * @author Roland Haeder<roland@mxchange.org>
33  */
34 public interface AddressbookWebController extends Serializable {
35
36         /**
37          * Checks whether the user has created addressbooks. For this method to work
38          * it is vital that the user is logged into his/her account.
39          * <p>
40          * @return Whether the user has created at least one addressbook
41          */
42         boolean hasCreatedAddressbooks ();
43
44         /**
45          * Creates a new address book with a name and redirects to proper target.
46          * For this method to work it is vital that the user is logged into his/her
47          * account.
48          * <p>
49          * @return Target to redirect to
50          */
51         String addAddressbook ();
52
53         /**
54          * Getter for address book name
55          * <p>
56          * @return Address book name
57          */
58         String getAddressbookName ();
59
60         /**
61          * Setter for address book name
62          * <p>
63          * @param addressbookName Address book name
64          */
65         void setAddressbookName (final String addressbookName);
66
67         /**
68          * Checks if the given address book name is already used by the user.
69          * <p>
70          * @param addressbookName Address book name to check
71          * <p>
72          * @return Whether the name has already been used by the user
73          */
74         boolean isAddressbookNameUsed (final String addressbookName);
75
76         /**
77          * Returns all address books with this user
78          * <p>
79          * @return A list of all address books by this user
80          */
81         List<Addressbook> allAddressbooks ();
82
83         /**
84          * Returns a list of all address book entries for given address book
85          * <p>
86          * @param addressbook Address book instance
87          * <p>
88          * @return List of all entries
89          */
90         List<AddressbookEntry> allEntries (final Addressbook addressbook);
91
92         /**
93          * Returns a list of all address books the user is sharing with others.
94          * <p>
95          * @return List of all shared address books
96          */
97         List<ShareableAddressbook> allShares ();
98
99         /**
100          * Size of all entries in given address book
101          * <p>
102          * @param addressbook Address book instance
103          * <p>
104          * @return Size of the entries in address book
105          */
106         int allEntriesSize (final Addressbook addressbook);
107
108         /**
109          * Getter for address book id number
110          * <p>
111          * @return Address book id number
112          */
113         Long getAddressbookId ();
114
115         /**
116          * Setter for address book id number
117          * <p>
118          * @param addressbookId Address book id number
119          */
120         void setAddressbookId (final Long addressbookId);
121
122         /**
123          * Getter for address book user (owner)
124          * <p>
125          * @return Address book user (owner)
126          */
127         User getAddressbookUser ();
128
129         /**
130          * Setter for address book user (owner)
131          * <p>
132          * @param addressbookUser Address book user (owner)
133          */
134         void setAddressbookUser (final User addressbookUser);
135
136         /**
137          * Getter for when the address book has been created
138          * <p>
139          * @return When the address book has been created
140          */
141         Calendar getAddressbookCreated ();
142
143         /**
144          * Setter for when the address book has been created
145          * <p>
146          * @param addressbookCreated When the address book has been created
147          */
148         void setAddressbookCreated (final Calendar addressbookCreated);
149
150         /**
151          * This method is called when an address book has been successfully loaded
152          * from JPA.
153          * <p>
154          * @param event Event with address book instance
155          */
156         void afterAddressbookLoadedEvent (final AddressbookLoadedEvent event);
157
158         /**
159          * Count all shared address books by given user id
160          * <p>
161          * @param user User instance to look for
162          * <p>
163          * @return Count of user's shared address books
164          */
165         Integer countAllUserSharedAddressbooks (final User user);
166
167         /**
168          * This method is called when a user has successfully logged in his/her
169          * account.
170          * <p>
171          * @param event
172          */
173         void afterLoginEvent (final UserLoggedInEvent event);
174
175         /**
176          * Checks if the user is logged in and if so if it matches the current
177          * address book owner.
178          * <p>
179          * @return Whether the owner matches currently logged-in user
180          */
181         boolean isOwnAddressbook ();
182
183         /**
184          * Checks if the owner of the current address book is NOT matching the
185          * logged-in user.
186          * <p>
187          * @return Whether the user does NOT match
188          */
189         boolean isOtherAddressbook ();
190
191 }