2 * Copyright (C) 2015 Roland Haeder
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.
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.
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/>.
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.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;
30 * An interface for address book beans
32 * @author Roland Haeder<roland@mxchange.org>
34 public interface AddressbookWebController extends Serializable {
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.
40 * @return Whether the user has created at least one addressbook
42 boolean hasCreatedAddressbooks ();
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
49 * @return Target to redirect to
51 String addAddressbook ();
54 * Getter for address book name
56 * @return Address book name
58 String getAddressbookName ();
61 * Setter for address book name
63 * @param addressbookName Address book name
65 void setAddressbookName (final String addressbookName);
68 * Checks if the given address book name is already used by the user.
70 * @param addressbookName Address book name to check
72 * @return Whether the name has already been used by the user
74 boolean isAddressbookNameUsed (final String addressbookName);
77 * Returns all address books with this user
79 * @return A list of all address books by this user
81 List<Addressbook> allAddressbooks ();
84 * Returns a list of all address book entries for given address book
86 * @param addressbook Address book instance
88 * @return List of all entries
90 List<AddressbookEntry> allEntries (final Addressbook addressbook);
93 * Returns a list of all address books the user is sharing with others.
95 * @return List of all shared address books
97 List<ShareableAddressbook> allShares ();
100 * Size of all entries in given address book
102 * @param addressbook Address book instance
104 * @return Size of the entries in address book
106 int allEntriesSize (final Addressbook addressbook);
109 * Getter for address book id number
111 * @return Address book id number
113 Long getAddressbookId ();
116 * Setter for address book id number
118 * @param addressbookId Address book id number
120 void setAddressbookId (final Long addressbookId);
123 * Getter for address book user (owner)
125 * @return Address book user (owner)
127 User getAddressbookUser ();
130 * Setter for address book user (owner)
132 * @param addressbookUser Address book user (owner)
134 void setAddressbookUser (final User addressbookUser);
137 * Getter for when the address book has been created
139 * @return When the address book has been created
141 Calendar getAddressbookCreated ();
144 * Setter for when the address book has been created
146 * @param addressbookCreated When the address book has been created
148 void setAddressbookCreated (final Calendar addressbookCreated);
151 * This method is called when an address book has been successfully loaded
154 * @param event Event with address book instance
156 void afterAddressbookLoadedEvent (final AddressbookLoadedEvent event);
159 * Count all shared address books by given user id
161 * @param user User instance to look for
163 * @return Count of user's shared address books
165 Integer countAllUserSharedAddressbooks (final User user);
168 * This method is called when a user has successfully logged in his/her
173 void afterLoginEvent (final UserLoggedInEvent event);
176 * Checks if the user is logged in and if so if it matches the current
177 * address book owner.
179 * @return Whether the owner matches currently logged-in user
181 boolean isOwnAddressbook ();
184 * Checks if the owner of the current address book is NOT matching the
187 * @return Whether the user does NOT match
189 boolean isOtherAddressbook ();