source: ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/impl/database/GroupService.java @ 4098

Last change on this file since 4098 was 4098, checked in by George.Georgovassilis@mpi.nl, 10 years ago

#360, #431, #432: JPA and unified component entities

  • Property svn:mime-type set to text/plain
File size: 4.0 KB
Line 
1package clarin.cmdi.componentregistry.impl.database;
2
3import java.util.List;
4
5import org.springframework.transaction.annotation.Transactional;
6
7import clarin.cmdi.componentregistry.model.BaseDescription;
8import clarin.cmdi.componentregistry.model.Group;
9import clarin.cmdi.componentregistry.model.Ownership;
10import clarin.cmdi.componentregistry.model.RegistryUser;
11
12/**
13 * Service for handling groups and component/profile ownership
14 * @author george.georgovassilis@mpi.nl
15 *
16 */
17@Transactional
18public interface GroupService {
19
20    /**
21     * Creates a new group. Will fail with an exception if the (normalised) group name already exists
22     * @param name
23     * @param owner
24     * @return ID of group created
25     * @throws ValidationException
26     */
27    long createNewGroup(String name, String ownerPrincipalName);
28   
29    /**
30     * Gets groups directly owned by a user
31     * @param ownerPrincipalName
32     * @return
33     */
34    List<Group> getGroupsOwnedByUser(String ownerPrincipalName);
35   
36    /**
37     * Get list of groups of which the provided user is a member of. Does not include
38     * groups he owns but is not a member of.
39     * @param principal
40     * @return
41     */
42    List<Group> getGroupsOfWhichUserIsAMember(String principal);
43   
44    /**
45     * Lists all group names
46     * @return
47     */
48    List<String> listGroupNames();
49
50    /**
51     * Determines whether a user is the direct owner of a group
52     * @param groupId
53     * @param user
54     * @return
55     */
56    boolean isUserOwnerOfGroup(long groupId, RegistryUser user);
57   
58    /**
59     * Add an ownership of a user or group to a profile or component. Will check ownership for plausibility and will fail if that ownership already exists.
60     * Will not fail if user/group/component/profile IDs don't correspond to an existing entry.
61     * @param ownership
62     */
63    void addOwnership(Ownership ownership);
64   
65    /**
66     * Removes an existing ownership. Won't complain if the ownership doesn't exist
67     * @param ownership
68     */
69    void removeOwnership(Ownership ownership);
70   
71    /**
72     * Determines whether a user has read access to a component. Factors that allow access are:
73     * 1. The component is public
74     * 2. The user is the creator
75     * 3. The user has an ownership (see {@link #addOwnership(Ownership)})
76     * 4. The user belongs to a group that has ownership
77     * @param user
78     * @param baseDescription
79     * @return
80     */
81    boolean canUserAccessComponentEitherOnHisOwnOrThroughGroupMembership(RegistryUser user, BaseDescription baseDescription);
82
83    /**
84     * Make a user a mamber of a group
85     * @param userName
86     * @param groupName
87     * @return database ID of group membership row
88     */
89    long makeMember(String userName, String groupName);
90   
91    /**
92     * Move ownership of a component or profile from a user to a group
93     * @param principal
94     * @param groupName
95     * @param componentId
96     */
97    void transferItemOwnershipFromUserToGroup(String principal, String groupId, String componentId);
98
99    /**
100     * Move ownership of a component or profile from a user to a group
101     * @param principal
102     * @param groupId
103     * @param componentId
104     */
105    void transferItemOwnershipFromUserToGroupId(String principal, long groupId, String componentId);
106
107    /**
108     * Get component IDs in a group
109     * @param groupId
110     * @return
111     */
112    List<String> getComponentIdsInGroup(long groupId);
113
114    /**
115     * Get a list of groups the item is a member of. While it's technically possible for an item to belong to none, one or multiple groups, the transferXOwnerwhip methods make sure
116     * an item belongs only to a single group at most, thus this method returns at most a single group for all practical purposes.
117     * @param itemId
118     * @return List of groups
119     */
120    List<Group> getGroupsTheItemIsAMemberOf(String itemId);
121   
122    /**
123     * Get profile IDs in a group
124     * @param groupId
125     * @return
126     */
127    List<String> getProfileIdsInGroup(long groupId);
128
129}
Note: See TracBrowser for help on using the repository browser.