]> git.mxchange.org Git - jaddressbook-lib.git/blob - src/org/mxchange/addressbook/model/addressbook/AddressbookSessionBeanRemote.java
8cc597c508ebc3c10371a01ea41ccdd818b01df9
[jaddressbook-lib.git] / src / org / mxchange / addressbook / model / addressbook / AddressbookSessionBeanRemote.java
1 /*
2  * Copyright (C) 2016 - 2020 Free Software Foundation
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.model.addressbook;
18
19 import java.io.Serializable;
20 import java.util.List;
21 import javax.ejb.Remote;
22 import org.mxchange.jaddressbook.exceptions.AddressbookNameAlreadyUsedException;
23 import org.mxchange.jaddressbook.exceptions.AddressbookNotFoundException;
24 import org.mxchange.jaddressbook.model.addressbook.Addressbook;
25 import org.mxchange.jaddressbook.model.addressbook.entry.AddressbookEntry;
26 import org.mxchange.jusercore.model.user.User;
27
28 /**
29  * A remote session interface for addressbook handling
30  * <p>
31  * @author Roland Häder<roland@mxchange.org>
32  */
33 @Remote
34 public interface AddressbookSessionBeanRemote extends Serializable {
35
36         /**
37          * Some getter for an address book instance from given id number. If the
38          * address book is not found, an exception is thrown.
39          * <p>
40          * @param addressbookId Id number for address book instance
41          * <p>
42          * @return Address book instance
43          * <p>
44          * @throws AddressbookNotFoundException If the address book cannot be found
45          * by given id number
46          * @throws NullPointerException If addressbookId is null
47          * @throws IllegalArgumentException If the id number is below 1
48          */
49         Addressbook getAddressbookById (final Long addressbookId) throws AddressbookNotFoundException;
50
51         /**
52          * Returns a list of all entries of given address book, whether the assigned
53          * user is the "owner" or "sharer" of the entry.
54          * <p>
55          * @param addressbook Address book instance
56          * <p>
57          * @return List of all entries
58          */
59         List<AddressbookEntry> allEntries (final Addressbook addressbook);
60
61         /**
62          * Some "getter" for a list of address books the logged-in user has created
63          * <p>
64          * @param loggedInUser Logged-in user
65          * <p>
66          * @return List of all address books
67          */
68         List<Addressbook> getUsersAddressbookList (final User loggedInUser);
69
70         /**
71          * Creates given address book by persisting it. A User instance must be set,
72          * else an exception is thrown.
73          * <p>
74          * @param addressbook Address book instance to create
75          * <p>
76          * @return Updated address book instance
77          * <p>
78          * @throws AddressbookNameAlreadyUsedException If the address book's name
79          * has already been used by the user.
80          */
81         Addressbook createAddressbook (final Addressbook addressbook) throws AddressbookNameAlreadyUsedException;
82
83         /**
84          * Checks whether the given address book id is used (means available).
85          * <p>
86          * @param addressbookId Address book id to check
87          * <p>
88          * @return Whether the id is valid
89          */
90         boolean isAddressbookIdUsed (final Long addressbookId);
91
92         /**
93          * Checks if the given address book's name is already used by the user.
94          * <p>
95          * @param addressbook Address bok instance to check
96          * <p>
97          * @return Whether the name has already been used by the user
98          */
99         boolean isAddressbookNameUsed (final Addressbook addressbook);
100
101 }