Search in sources :

Example 61 with NamespacePermission

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);
}
Also used : UserNamespaceAuthorizationEntity(org.finra.herd.model.jpa.UserNamespaceAuthorizationEntity) NamespacePermission(org.finra.herd.model.annotation.NamespacePermission)

Example 62 with NamespacePermission

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);
}
Also used : UserNamespaceAuthorizationEntity(org.finra.herd.model.jpa.UserNamespaceAuthorizationEntity) NamespacePermission(org.finra.herd.model.annotation.NamespacePermission)

Example 63 with NamespacePermission

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);
}
Also used : UserNamespaceAuthorizationKey(org.finra.herd.model.api.xml.UserNamespaceAuthorizationKey) NamespaceEntity(org.finra.herd.model.jpa.NamespaceEntity) AlreadyExistsException(org.finra.herd.model.AlreadyExistsException) UserNamespaceAuthorizationEntity(org.finra.herd.model.jpa.UserNamespaceAuthorizationEntity) NamespacePermission(org.finra.herd.model.annotation.NamespacePermission)

Aggregations

NamespacePermission (org.finra.herd.model.annotation.NamespacePermission)63 BusinessObjectDefinitionEntity (org.finra.herd.model.jpa.BusinessObjectDefinitionEntity)10 BusinessObjectFormatEntity (org.finra.herd.model.jpa.BusinessObjectFormatEntity)10 NamespaceEntity (org.finra.herd.model.jpa.NamespaceEntity)10 AlreadyExistsException (org.finra.herd.model.AlreadyExistsException)9 AttributeValueListEntity (org.finra.herd.model.jpa.AttributeValueListEntity)6 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)5 BusinessObjectDefinitionKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionKey)5 CustomDdlEntity (org.finra.herd.model.jpa.CustomDdlEntity)5 Credentials (com.amazonaws.services.securitytoken.model.Credentials)4 ArrayList (java.util.ArrayList)4 PublishNotificationMessages (org.finra.herd.model.annotation.PublishNotificationMessages)4 BusinessObjectFormatKey (org.finra.herd.model.api.xml.BusinessObjectFormatKey)4 IamRole (org.finra.herd.model.api.xml.IamRole)4 NamespaceIamRoleAuthorization (org.finra.herd.model.api.xml.NamespaceIamRoleAuthorization)4 BusinessObjectDataEntity (org.finra.herd.model.jpa.BusinessObjectDataEntity)4 NamespaceIamRoleAuthorizationEntity (org.finra.herd.model.jpa.NamespaceIamRoleAuthorizationEntity)4 UserNamespaceAuthorizationEntity (org.finra.herd.model.jpa.UserNamespaceAuthorizationEntity)4 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)3 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)3