Skip to content

Commit

Permalink
Deprecated userService.delete(User) method
Browse files Browse the repository at this point in the history
Signed-off-by: Alberto Codutti <alberto.codutti@eurotech.com>
  • Loading branch information
Coduz committed Sep 29, 2022
1 parent 695e5ca commit d557dcc
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,7 @@ public void delete(GwtXSRFToken xsrfToken, String gwtScopeId, String gwtUserId)
KapuaId scopeId = GwtKapuaCommonsModelConverter.convertKapuaId(gwtScopeId);
KapuaId userId = GwtKapuaCommonsModelConverter.convertKapuaId(gwtUserId);

User user = USER_SERVICE.find(scopeId, userId);

if (user != null) {
USER_SERVICE.delete(user);
}
USER_SERVICE.delete(scopeId, userId);
} catch (Throwable t) {
KapuaExceptionHandler.handle(t);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@
import org.eclipse.kapua.service.config.KapuaConfigurableService;

/**
* UserService exposes APIs to manage User object under an Account.<br>
* UserService exposes APIs to manage User object under an Account.
* <p>
* It includes APIs to create, update, find, list and delete Users.<br>
* Instances of the UserService can be acquired through the ServiceLocator.
*
* @since 1.0
* @since 1.0.0
*/
public interface UserService extends KapuaEntityService<User, UserCreator>,
KapuaUpdatableEntityService<User>,
Expand Down Expand Up @@ -57,11 +58,13 @@ public interface UserService extends KapuaEntityService<User, UserCreator>,
User update(User user) throws KapuaException;

/**
* Delete the supplied User.
* Deletes the given {@link User}.
*
* @param user
* @param user The {@link User} to delete
* @throws KapuaException
* @deprecated Since 2.0.0. Please make use of {@link #delete(KapuaId, KapuaId)}
*/
@Deprecated
void delete(User user) throws KapuaException;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,17 @@ public User update(User user) throws KapuaException {
}));
}

@Override
public void delete(User user) throws KapuaException {
//
// Argument Validation
ArgumentValidator.notNull(user, "user");

//
// Do delete
delete(user.getScopeId(), user.getId());
}

@Override
//@RaiseServiceEvent
public void delete(KapuaId scopeId, KapuaId userId) throws KapuaException {
Expand Down Expand Up @@ -278,12 +289,6 @@ public void delete(KapuaId scopeId, KapuaId userId) throws KapuaException {
.onAfterHandler((emptyParam) -> entityCache.remove(scopeId, userId)));
}

@Override
public void delete(User user) throws KapuaException {
ArgumentValidator.notNull(user, "user");
delete(user.getScopeId(), user.getId());
}

@Override
public User find(KapuaId scopeId, KapuaId userId)
throws KapuaException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ public void deleteUser() throws Exception {
try {
primeException();
User user = (User) stepData.get("User");
userService.delete(user);
userService.delete(user.getScopeId(), user.getId());
} catch (KapuaException ke) {
verifyException(ke);
}
Expand Down Expand Up @@ -460,7 +460,7 @@ public void deleteNonexistenUser() throws Exception {
User user = (User) stepData.get("User");
try {
primeException();
userService.delete(user);
userService.delete(user.getScopeId(), user.getId());
} catch (KapuaException ke) {
verifyException(ke);
}
Expand Down Expand Up @@ -684,7 +684,7 @@ public void thenDeleteUser(String userName) throws Exception {
try {
User userToDelete = userService.findByName(userName);
if (userToDelete != null) {
userService.delete(userToDelete);
userService.delete(userToDelete.getScopeId(), userToDelete.getId());
}
} catch (KapuaException e) {
verifyException(e);
Expand Down

0 comments on commit d557dcc

Please sign in to comment.