use of org.summerb.microservices.users.api.exceptions.UserServiceUnexpectedException in project summerb by skarpushin.
the class PermissionServiceImpl method revokeUserPermissions.
@Override
@Transactional(rollbackFor = Throwable.class)
public void revokeUserPermissions(String optionalDomainName, String userUuid) {
Preconditions.checkArgument(StringUtils.hasText(userUuid));
String domainName = getOptionalParamValue(optionalDomainName);
try {
permissionDao.revokeUserPermissions(domainName, userUuid);
} catch (Throwable t) {
String msg = String.format("Failed to revoke user '%s' permissions in domain '%s'", userUuid, domainName);
throw new UserServiceUnexpectedException(msg, t);
}
}
use of org.summerb.microservices.users.api.exceptions.UserServiceUnexpectedException in project summerb by skarpushin.
the class PermissionServiceImpl method revokeAllPermissionsForSubject.
@Override
@Transactional(rollbackFor = Throwable.class)
public void revokeAllPermissionsForSubject(String optionalDomainName, String optionalSubjectId) {
String domainName = getOptionalParamValue(optionalDomainName);
String subjectId = getOptionalParamValue(optionalSubjectId);
try {
permissionDao.clearSubjectPermissions(domainName, subjectId);
} catch (Throwable t) {
String msg = String.format("Failed to clear subject '%s' permissions in domain '%s'", subjectId, domainName);
throw new UserServiceUnexpectedException(msg, t);
}
}
use of org.summerb.microservices.users.api.exceptions.UserServiceUnexpectedException in project summerb by skarpushin.
the class PermissionServiceImpl method findUsersAndTheirPermissionsForSubject.
@Override
public Map<String, List<String>> findUsersAndTheirPermissionsForSubject(String optionalDomainName, String optionalSubjectId) {
String domainName = getOptionalParamValue(optionalDomainName);
String subjectId = getOptionalParamValue(optionalSubjectId);
try {
return permissionDao.getUsersAndTheirPermissionsForSubject(domainName, subjectId);
} catch (Throwable t) {
String msg = String.format("Failed to get users and their permissions for subject '%s' in domain '%s'", subjectId, domainName);
throw new UserServiceUnexpectedException(msg, t);
}
}
use of org.summerb.microservices.users.api.exceptions.UserServiceUnexpectedException in project summerb by skarpushin.
the class UserServiceImpl method deleteUserByUuid.
@Override
@Transactional(rollbackFor = Throwable.class)
public void deleteUserByUuid(String userUuid) throws UserNotFoundException {
Preconditions.checkArgument(userUuid != null, "User uuid required");
Preconditions.checkArgument(StringUtils.hasText(userUuid), "User uuid must be provided");
boolean isDeletedSucceessfully = false;
try {
User userToDelete = userDao.findUserByUuid(userUuid);
if (userToDelete != null) {
isDeletedSucceessfully = userDao.deleteUser(userUuid);
// NOTE: Assumed, that all related stuff will be deleted
// automatically using CASCADE DELETE in the database
eventBus.post(EntityChangedEvent.removedObject(userToDelete));
}
} catch (Throwable t) {
String msg = String.format("Failed to delete user '%s'", userUuid);
throw new UserServiceUnexpectedException(msg, t);
}
if (!isDeletedSucceessfully) {
throw new UserNotFoundException(userUuid);
}
}
use of org.summerb.microservices.users.api.exceptions.UserServiceUnexpectedException in project summerb by skarpushin.
the class UserServiceImpl method getUserByUuid.
@Override
public User getUserByUuid(String userUuid) throws UserNotFoundException {
Assert.hasText(userUuid, "userUuid must be provided");
User foundUser;
try {
foundUser = userDao.findUserByUuid(userUuid);
} catch (Throwable t) {
String msg = String.format("Failed to find user '%s'", userUuid);
throw new UserServiceUnexpectedException(msg, t);
}
if (foundUser == null) {
throw new UserNotFoundException(userUuid);
}
return foundUser;
}
Aggregations