Skip to content

Package: RoleService

RoleService

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2016, 2022 Eurotech and/or its affiliates and others
3: *
4: * This program and the accompanying materials are made
5: * available under the terms of the Eclipse Public License 2.0
6: * which is available at https://www.eclipse.org/legal/epl-2.0/
7: *
8: * SPDX-License-Identifier: EPL-2.0
9: *
10: * Contributors:
11: * Eurotech - initial API and implementation
12: *******************************************************************************/
13: package org.eclipse.kapua.service.authorization.role;
14:
15: import org.eclipse.kapua.KapuaException;
16: import org.eclipse.kapua.model.id.KapuaId;
17: import org.eclipse.kapua.model.query.KapuaQuery;
18: import org.eclipse.kapua.service.KapuaEntityService;
19: import org.eclipse.kapua.service.KapuaUpdatableEntityService;
20: import org.eclipse.kapua.service.config.KapuaConfigurableService;
21:
22: /**
23: * {@link Role} service definition.
24: *
25: * @since 1.0.0
26: */
27: public interface RoleService extends KapuaEntityService<Role, RoleCreator>,
28: KapuaUpdatableEntityService<Role>,
29: KapuaConfigurableService {
30:
31: /**
32: * Creates a new {@link Role} based on the parameters provided in the {@link RoleCreator}.<br>
33: * {@link Role} must have a unique name within the scope.
34: *
35: * @param roleCreator The creator object from which to create the {@link Role}.
36: * @throws KapuaException
37: * @since 1.0.0
38: */
39: @Override
40: Role create(RoleCreator roleCreator) throws KapuaException;
41:
42: /**
43: * Updates the {@link Role} according the given updated entity.<br>
44: * The {@link Role#getName()} can be updated, but must remain unique within the scope.<br>
45: *
46: * @param role The updated {@link Role}.
47: * @return A {@link Role} with updated values.
48: * @throws KapuaException
49: * @since 1.0.0
50: */
51: @Override
52: Role update(Role role) throws KapuaException;
53:
54: /**
55: * Finds the {@link Role} by scope identifier and {@link Role} id.
56: *
57: * @param scopeId The scope id in which to search.
58: * @param roleId The {@link Role} id to search.
59: * @return The {@link Role} found or {@code null} if no entity was found.
60: * @throws KapuaException
61: * @since 1.0.0
62: */
63: @Override
64: Role find(KapuaId scopeId, KapuaId roleId) throws KapuaException;
65:
66: /**
67: * Returns the {@link RoleListResult} with elements matching the provided query.
68: *
69: * @param query The {@link RoleQuery} used to filter results.
70: * @return The {@link RoleListResult} with elements matching the query parameter.
71: * @throws KapuaException
72: * @since 1.0.0
73: */
74: @Override
75: RoleListResult query(KapuaQuery query) throws KapuaException;
76:
77: /**
78: * Returns the count of the {@link Role} elements matching the provided query.
79: *
80: * @param query The {@link RoleQuery} used to filter results.
81: * @return The count of the {@link Role} elements matching the provided query.
82: * @throws KapuaException
83: * @since 1.0.0
84: */
85: @Override
86: long count(KapuaQuery query) throws KapuaException;
87:
88: /**
89: * Delete the {@link Role} by scope id and {@link Role} id.
90: *
91: * @param scopeId The scope id in which to delete.
92: * @param roleId The {@link Role} id to delete.
93: * @throws KapuaException
94: * @since 1.0.0
95: */
96: @Override
97: void delete(KapuaId scopeId, KapuaId roleId) throws KapuaException;
98:
99: }