use of org.summerb.users.api.exceptions.UserServiceUnexpectedException in project summerb by skarpushin.
the class PermissionServiceImpl method grantPermission.
@Override
@Transactional(rollbackFor = Throwable.class)
public void grantPermission(String optionalDomainName, String userUuid, String optionalSubjectId, String permissionKey) {
Preconditions.checkArgument(StringUtils.hasText(permissionKey));
Preconditions.checkArgument(StringUtils.hasText(userUuid));
String domainName = getOptionalParamValue(optionalDomainName);
String subjectId = getOptionalParamValue(optionalSubjectId);
try {
permissionDao.grantPermission(domainName, userUuid, subjectId, permissionKey);
} catch (DuplicateKeyException dke) {
// it's ok
log.debug("Duplicate key exception sealed. Looks like same permission is already granted.", dke);
} catch (Throwable t) {
String msg = String.format("Failed to grant permission '%s' to user '%s' on subject '%s' in domain '%s'", permissionKey, userUuid, subjectId, domainName);
throw new UserServiceUnexpectedException(msg, t);
}
}
use of org.summerb.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.users.api.exceptions.UserServiceUnexpectedException in project summerb by skarpushin.
the class PermissionServiceImpl method findUserPermissionsForSubject.
@Override
public List<String> findUserPermissionsForSubject(String optionalDomainName, String userUuid, String optionalSubjectId) {
Preconditions.checkArgument(StringUtils.hasText(userUuid));
String domainName = getOptionalParamValue(optionalDomainName);
String subjectId = getOptionalParamValue(optionalSubjectId);
try {
return permissionDao.getUserPermissionsForSubject(domainName, userUuid, subjectId);
} catch (Throwable t) {
String msg = String.format("Failed to get user '%s' permissions for subject '%s' in domain '%s'", userUuid, subjectId, domainName);
throw new UserServiceUnexpectedException(msg, t);
}
}
use of org.summerb.users.api.exceptions.UserServiceUnexpectedException in project summerb by skarpushin.
the class PermissionServiceImpl method findSubjectsUserHasPermissionsFor.
@Override
public List<String> findSubjectsUserHasPermissionsFor(String optionalDomainName, String userUuid, String optionalRequiredPermission) {
Preconditions.checkArgument(StringUtils.hasText(userUuid));
String domainName = getOptionalParamValue(optionalDomainName);
try {
if (!StringUtils.hasText(optionalRequiredPermission)) {
return permissionDao.getSubjectsUserHasPermissionFor(domainName, userUuid);
} else {
return permissionDao.getSubjectsUserHasPermissionForFiltered(domainName, userUuid, optionalRequiredPermission);
}
} catch (Throwable t) {
String msg = String.format("Failed to get subject list user '%s' has permissions (optional = '%s') for in domain '%s'", userUuid, optionalRequiredPermission, domainName);
throw new UserServiceUnexpectedException(msg, t);
}
}
use of org.summerb.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);
}
}
Aggregations