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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations