Search in sources :

Example 16 with NamespacePermission

use of org.finra.herd.model.annotation.NamespacePermission in project herd by FINRAOS.

the class BusinessObjectFormatServiceImpl method updateBusinessObjectFormatAttributes.

@NamespacePermission(fields = "#businessObjectFormatKey.namespace", permissions = NamespacePermissionEnum.WRITE)
@Override
public BusinessObjectFormat updateBusinessObjectFormatAttributes(BusinessObjectFormatKey businessObjectFormatKey, BusinessObjectFormatAttributesUpdateRequest businessObjectFormatAttributesUpdateRequest) {
    // Perform validation and trim the alternate key parameters.
    businessObjectFormatHelper.validateBusinessObjectFormatKey(businessObjectFormatKey);
    Assert.notNull(businessObjectFormatAttributesUpdateRequest, "A business object format attributes update request is required.");
    Assert.notNull(businessObjectFormatAttributesUpdateRequest.getAttributes(), "A business object format attributes list is required.");
    List<Attribute> attributes = businessObjectFormatAttributesUpdateRequest.getAttributes();
    // Validate optional attributes. This is also going to trim the attribute names.
    attributeHelper.validateFormatAttributes(attributes);
    // Retrieve and ensure that a business object format exists.
    BusinessObjectFormatEntity businessObjectFormatEntity = businessObjectFormatDaoHelper.getBusinessObjectFormatEntity(businessObjectFormatKey);
    // Update the business object format attributes
    updateBusinessObjectFormatAttributesHelper(businessObjectFormatEntity, attributes);
    // Persist and refresh the entity.
    businessObjectFormatEntity = businessObjectFormatDao.saveAndRefresh(businessObjectFormatEntity);
    // Create and return the business object format object from the persisted entity.
    return businessObjectFormatHelper.createBusinessObjectFormatFromEntity(businessObjectFormatEntity);
}
Also used : Attribute(org.finra.herd.model.api.xml.Attribute) BusinessObjectFormatEntity(org.finra.herd.model.jpa.BusinessObjectFormatEntity) NamespacePermission(org.finra.herd.model.annotation.NamespacePermission)

Example 17 with NamespacePermission

use of org.finra.herd.model.annotation.NamespacePermission in project herd by FINRAOS.

the class BusinessObjectFormatServiceImpl method updateBusinessObjectFormatAttributeDefinitions.

@NamespacePermission(fields = "#businessObjectFormatKey.namespace", permissions = NamespacePermissionEnum.WRITE)
@Override
public BusinessObjectFormat updateBusinessObjectFormatAttributeDefinitions(BusinessObjectFormatKey businessObjectFormatKey, BusinessObjectFormatAttributeDefinitionsUpdateRequest businessObjectFormatAttributeDefinitionsUpdateRequest) {
    // Perform validation and trim the alternate key parameters.
    businessObjectFormatHelper.validateBusinessObjectFormatKey(businessObjectFormatKey);
    Assert.notNull(businessObjectFormatAttributeDefinitionsUpdateRequest, "A business object format attribute definitions update request is required.");
    List<AttributeDefinition> attributeDefinitions = businessObjectFormatAttributeDefinitionsUpdateRequest.getAttributeDefinitions();
    // Validate and trim optional attribute definitions. This is also going to trim the attribute definition names.
    validateAndTrimBusinessObjectFormatAttributeDefinitionsHelper(attributeDefinitions);
    // Retrieve and ensure that a business object format exists.
    BusinessObjectFormatEntity businessObjectFormatEntity = businessObjectFormatDaoHelper.getBusinessObjectFormatEntity(businessObjectFormatKey);
    // Update the business object format attributes
    updateBusinessObjectFormatAttributeDefinitionsHelper(businessObjectFormatEntity, attributeDefinitions);
    // Persist and refresh the entity.
    businessObjectFormatEntity = businessObjectFormatDao.saveAndRefresh(businessObjectFormatEntity);
    // Create and return the business object format object from the persisted entity.
    return businessObjectFormatHelper.createBusinessObjectFormatFromEntity(businessObjectFormatEntity);
}
Also used : AttributeDefinition(org.finra.herd.model.api.xml.AttributeDefinition) BusinessObjectFormatEntity(org.finra.herd.model.jpa.BusinessObjectFormatEntity) NamespacePermission(org.finra.herd.model.annotation.NamespacePermission)

Example 18 with NamespacePermission

use of org.finra.herd.model.annotation.NamespacePermission in project herd by FINRAOS.

the class AttributeValueListServiceImpl method deleteAttributeValueList.

@NamespacePermission(fields = "#attributeValueListKey.namespace", permissions = NamespacePermissionEnum.WRITE)
@Override
public AttributeValueList deleteAttributeValueList(AttributeValueListKey attributeValueListKey) {
    // Perform validation and trim.
    attributeValueListHelper.validateAttributeValueListKey(attributeValueListKey);
    // Retrieve and ensure that an attribute value list already exists with the specified key.
    AttributeValueListEntity attributeValueListEntity = attributeValueListDaoHelper.getAttributeValueListEntity(attributeValueListKey);
    // Delete the attribute value list.
    attributeValueListDao.delete(attributeValueListEntity);
    // Create and return the attribute value list object from the deleted entity.
    return attributeValueListDaoHelper.createAttributeValueListFromEntity(attributeValueListEntity);
}
Also used : AttributeValueListEntity(org.finra.herd.model.jpa.AttributeValueListEntity) NamespacePermission(org.finra.herd.model.annotation.NamespacePermission)

Example 19 with NamespacePermission

use of org.finra.herd.model.annotation.NamespacePermission in project herd by FINRAOS.

the class AttributeValueListServiceImpl method getAttributeValueList.

@NamespacePermission(fields = "#attributeValueListKey.namespace", permissions = NamespacePermissionEnum.READ)
@Override
public AttributeValueList getAttributeValueList(AttributeValueListKey attributeValueListKey) {
    // Perform validation and trim.
    attributeValueListHelper.validateAttributeValueListKey(attributeValueListKey);
    // Retrieve and ensure that an attribute value list already exists with the specified key.
    AttributeValueListEntity attributeValueListEntity = attributeValueListDaoHelper.getAttributeValueListEntity(attributeValueListKey);
    // Create and return the attribute value list object from the deleted entity.
    return attributeValueListDaoHelper.createAttributeValueListFromEntity(attributeValueListEntity);
}
Also used : AttributeValueListEntity(org.finra.herd.model.jpa.AttributeValueListEntity) NamespacePermission(org.finra.herd.model.annotation.NamespacePermission)

Example 20 with NamespacePermission

use of org.finra.herd.model.annotation.NamespacePermission in project herd by FINRAOS.

the class AttributeValueListServiceImpl method createAttributeValueList.

@NamespacePermission(fields = "#request.attributeValueListKey.namespace", permissions = NamespacePermissionEnum.WRITE)
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public AttributeValueList createAttributeValueList(AttributeValueListCreateRequest request) {
    // Validate and trim the request parameters.
    attributeValueListHelper.validateAttributeValueListCreateRequest(request);
    // Get the attribute value list key.
    AttributeValueListKey attributeValueListKey = request.getAttributeValueListKey();
    // Retrieve the namespace entity and validate it exists.
    NamespaceEntity namespaceEntity = namespaceDaoHelper.getNamespaceEntity(request.getAttributeValueListKey().getNamespace());
    // Validate the attribute value list does not already exist.
    if (attributeValueListDao.getAttributeValueListByKey(request.getAttributeValueListKey()) != null) {
        throw new AlreadyExistsException(String.format("Unable to create attribute value list with name \"%s\" because it already exists for namespace \"%s\".", attributeValueListKey.getAttributeValueListName(), attributeValueListKey.getNamespace()));
    }
    // Create and persist a new attribute value list entity from the request information.
    AttributeValueListEntity attributeValueListEntity = createAttributeValueListEntity(request, namespaceEntity);
    // Create and return the attribute value list object from the persisted entity.
    return attributeValueListDaoHelper.createAttributeValueListFromEntity(attributeValueListEntity);
}
Also used : NamespaceEntity(org.finra.herd.model.jpa.NamespaceEntity) AlreadyExistsException(org.finra.herd.model.AlreadyExistsException) AttributeValueListEntity(org.finra.herd.model.jpa.AttributeValueListEntity) AttributeValueListKey(org.finra.herd.model.api.xml.AttributeValueListKey) NamespacePermission(org.finra.herd.model.annotation.NamespacePermission) Transactional(org.springframework.transaction.annotation.Transactional)

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