2 * Copyright (C) 2016 Roland Haeder
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Affero General Public License as
6 * published by the Free Software Foundation, either version 3 of the
7 * License, or (at your option) any later version.
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 Affero General Public License for more details.
14 * You should have received a copy of the GNU Affero General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 package org.mxchange.addressbook.beans.addressbook;
19 import java.io.Serializable;
20 import java.util.Calendar;
21 import java.util.List;
22 import org.mxchange.jaddressbookcore.events.addressbook.AddressbookLoadedEvent;
23 import org.mxchange.jaddressbookcore.model.addressbook.Addressbook;
24 import org.mxchange.jaddressbookcore.model.addressbook.entry.AddressbookEntry;
25 import org.mxchange.jusercore.events.login.UserLoggedInEvent;
26 import org.mxchange.jusercore.model.user.User;
29 * An interface for address book beans
31 * @author Roland Haeder<roland@mxchange.org>
33 public interface AddressbookWebSessionController extends Serializable {
36 * Checks whether the user has created addressbooks. For this method to work
37 * it is vital that the user is logged into his/her account.
39 * @return Whether the user has created at least one addressbook
41 boolean hasCreatedAddressbooks ();
44 * Creates a new address book with a name and redirects to proper target.
45 * For this method to work it is vital that the user is logged into his/her
48 * @return Target to redirect to
50 String addAddressbook ();
53 * Getter for address book name
55 * @return Address book name
57 String getAddressbookName ();
60 * Setter for address book name
62 * @param addressbookName Address book name
64 void setAddressbookName (final String addressbookName);
67 * Checks if the given address book name is already used by the user.
69 * @param addressbookName Address book name to check
71 * @return Whether the name has already been used by the user
73 boolean isAddressbookNameUsed (final String addressbookName);
76 * Returns all address books with this user
78 * @return A list of all address books by this user
80 List<Addressbook> allAddressbooks ();
83 * Returns a list of all address book entries for given address book
85 * @param addressbook Address book instance
87 * @return List of all entries
89 List<AddressbookEntry> allEntries (final Addressbook addressbook);
92 * Size of all entries in given address book
94 * @param addressbook Address book instance
96 * @return Size of the entries in address book
98 int allEntriesSize (final Addressbook addressbook);
101 * Getter for address book id number
103 * @return Address book id number
105 Long getAddressbookId ();
108 * Setter for address book id number
110 * @param addressbookId Address book id number
112 void setAddressbookId (final Long addressbookId);
115 * Getter for address book user (owner)
117 * @return Address book user (owner)
119 User getAddressbookUser ();
122 * Setter for address book user (owner)
124 * @param addressbookUser Address book user (owner)
126 void setAddressbookUser (final User addressbookUser);
129 * Getter for when the address book has been created
131 * @return When the address book has been created
133 Calendar getAddressbookCreated ();
136 * Setter for when the address book has been created
138 * @param addressbookCreated When the address book has been created
140 void setAddressbookCreated (final Calendar addressbookCreated);
143 * This method is called when an address book has been successfully loaded
146 * @param event Event with address book instance
148 void afterAddressbookLoadedEvent (final AddressbookLoadedEvent event);
151 * Count all shared address books by given user id
153 * @param user User instance to look for
155 * @return Count of user's shared address books
157 Integer countAllUserSharedAddressbooks (final User user);
160 * This method is called when a user has successfully logged in his/her
165 void afterLoginEvent (final UserLoggedInEvent event);
168 * Checks if the user is logged in and if so if it matches the current
169 * address book owner.
171 * @return Whether the owner matches currently logged-in user
173 boolean isOwnAddressbook ();
176 * Checks if the owner of the current address book is NOT matching the
179 * @return Whether the user does NOT match
181 boolean isOtherAddressbook ();
184 * Getter for address book instance
186 * @return Address book instance
188 Addressbook getAddressbook ();
191 * Setter for address book instance
193 * @param addressbook Address book instance
195 void setAddressbook (final Addressbook addressbook);
198 * Retrieves a list of all users this user is not sharing this address book
201 * @return List of not sharing users
203 List<User> allUsersNotSharing ();
206 * Checks wether an address book has been loaded by checking the id number.
208 * @return Whether the address book is loaded
210 boolean isAddressbookLoaded ();
213 * Loads address book from current id
215 * @return Whether the address book was found
217 boolean loadAddressbook ();