use of org.finra.herd.model.annotation.NamespacePermission in project herd by FINRAOS.
the class UserNamespaceAuthorizationServiceImpl method updateUserNamespaceAuthorization.
@NamespacePermission(fields = "#key?.namespace", permissions = NamespacePermissionEnum.GRANT)
@Override
public UserNamespaceAuthorization updateUserNamespaceAuthorization(UserNamespaceAuthorizationKey key, UserNamespaceAuthorizationUpdateRequest request) {
// Validate and trim the key.
validateUserNamespaceAuthorizationKey(key);
// Validate and trim the request parameters.
validateUserNamespaceAuthorizationUpdateRequest(request);
// Retrieve and ensure that a user namespace authorization exists with the specified key.
UserNamespaceAuthorizationEntity userNamespaceAuthorizationEntity = getUserNamespaceAuthorizationEntity(key);
// Update the permissions.
updateNamespacePermissions(userNamespaceAuthorizationEntity, request.getNamespacePermissions());
userNamespaceAuthorizationDao.saveAndRefresh(userNamespaceAuthorizationEntity);
// Create and return the user namespace authorization object from the updated entity.
return createUserNamespaceAuthorizationFromEntity(userNamespaceAuthorizationEntity);
}
use of org.finra.herd.model.annotation.NamespacePermission in project herd by FINRAOS.
the class UserNamespaceAuthorizationServiceImpl method deleteUserNamespaceAuthorization.
@NamespacePermission(fields = "#key?.namespace", permissions = NamespacePermissionEnum.GRANT)
@Override
public UserNamespaceAuthorization deleteUserNamespaceAuthorization(UserNamespaceAuthorizationKey key) {
// Validate and trim the key.
validateUserNamespaceAuthorizationKey(key);
// Retrieve and ensure that a user namespace authorization exists with the specified key.
UserNamespaceAuthorizationEntity userNamespaceAuthorizationEntity = getUserNamespaceAuthorizationEntity(key);
// Delete the business object definition.
userNamespaceAuthorizationDao.delete(userNamespaceAuthorizationEntity);
// Create and return the user namespace authorization object from the deleted entity.
return createUserNamespaceAuthorizationFromEntity(userNamespaceAuthorizationEntity);
}
use of org.finra.herd.model.annotation.NamespacePermission in project herd by FINRAOS.
the class UserNamespaceAuthorizationServiceImpl method createUserNamespaceAuthorization.
@NamespacePermission(fields = "#request?.userNamespaceAuthorizationKey?.namespace", permissions = NamespacePermissionEnum.GRANT)
@Override
public UserNamespaceAuthorization createUserNamespaceAuthorization(UserNamespaceAuthorizationCreateRequest request) {
// Validate and trim the request parameters.
validateUserNamespaceAuthorizationCreateRequest(request);
// Get the user namespace authorization key.
UserNamespaceAuthorizationKey key = request.getUserNamespaceAuthorizationKey();
// Ensure a user namespace authorization with the specified name doesn't already exist for the specified namespace.
UserNamespaceAuthorizationEntity userNamespaceAuthorizationEntity = userNamespaceAuthorizationDao.getUserNamespaceAuthorizationByKey(key);
if (userNamespaceAuthorizationEntity != null) {
throw new AlreadyExistsException(String.format("Unable to create user namespace authorization with user id \"%s\" and namespace \"%s\" because it already exists.", key.getUserId(), key.getNamespace()));
}
// Retrieve and ensure that namespace exists with the specified user namespace authorization namespace code.
NamespaceEntity namespaceEntity = namespaceDaoHelper.getNamespaceEntity(key.getNamespace());
// Create and persist a new user namespace authorization entity from the request information.
userNamespaceAuthorizationEntity = createUserNamespaceAuthorizationEntity(key.getUserId(), namespaceEntity, request.getNamespacePermissions());
// Create and return the user namespace authorization object from the persisted entity.
return createUserNamespaceAuthorizationFromEntity(userNamespaceAuthorizationEntity);
}
Aggregations