use of org.finra.herd.model.annotation.NamespacePermission in project herd by FINRAOS.
the class BusinessObjectDataServiceImpl method getBusinessObjectDataVersions.
@NamespacePermission(fields = "#businessObjectDataKey.namespace", permissions = NamespacePermissionEnum.READ)
@Override
public BusinessObjectDataVersions getBusinessObjectDataVersions(BusinessObjectDataKey businessObjectDataKey) {
// Validate and trim the business object data key.
businessObjectDataHelper.validateBusinessObjectDataKey(businessObjectDataKey, false, false);
// Get the business object data versions based on the specified parameters.
List<BusinessObjectDataEntity> businessObjectDataEntities = businessObjectDataDao.getBusinessObjectDataEntities(businessObjectDataKey);
// Create the response.
BusinessObjectDataVersions businessObjectDataVersions = new BusinessObjectDataVersions();
for (BusinessObjectDataEntity businessObjectDataEntity : businessObjectDataEntities) {
BusinessObjectDataVersion businessObjectDataVersion = new BusinessObjectDataVersion();
BusinessObjectDataKey businessObjectDataVersionKey = businessObjectDataHelper.getBusinessObjectDataKey(businessObjectDataEntity);
businessObjectDataVersion.setBusinessObjectDataKey(businessObjectDataVersionKey);
businessObjectDataVersion.setStatus(businessObjectDataEntity.getStatus().getCode());
businessObjectDataVersions.getBusinessObjectDataVersions().add(businessObjectDataVersion);
}
return businessObjectDataVersions;
}
use of org.finra.herd.model.annotation.NamespacePermission in project herd by FINRAOS.
the class BusinessObjectDataServiceImpl method updateBusinessObjectDataAttributes.
@NamespacePermission(fields = "#businessObjectDataKey.namespace", permissions = NamespacePermissionEnum.WRITE)
@Override
public BusinessObjectData updateBusinessObjectDataAttributes(BusinessObjectDataKey businessObjectDataKey, BusinessObjectDataAttributesUpdateRequest businessObjectDataAttributesUpdateRequest) {
// Validate and trim the business object data key.
businessObjectDataHelper.validateBusinessObjectDataKey(businessObjectDataKey, true, true);
// Validate the update request.
Assert.notNull(businessObjectDataAttributesUpdateRequest, "A business object data attributes update request must be specified.");
Assert.notNull(businessObjectDataAttributesUpdateRequest.getAttributes(), "A list of business object data attributes must be specified.");
List<Attribute> attributes = businessObjectDataAttributesUpdateRequest.getAttributes();
// Validate attributes. This is also going to trim the attribute names.
attributeHelper.validateAttributes(attributes);
// Retrieve the business object data and ensure it exists.
BusinessObjectDataEntity businessObjectDataEntity = businessObjectDataDaoHelper.getBusinessObjectDataEntity(businessObjectDataKey);
// Validate attributes against attribute definitions.
attributeDaoHelper.validateAttributesAgainstBusinessObjectDataAttributeDefinitions(attributes, businessObjectDataEntity.getBusinessObjectFormat().getAttributeDefinitions());
// Update the attributes.
attributeDaoHelper.updateBusinessObjectDataAttributes(businessObjectDataEntity, attributes);
// Persist and refresh the entity.
businessObjectDataEntity = businessObjectDataDao.saveAndRefresh(businessObjectDataEntity);
// Create and return the business object data object from the persisted entity.
return businessObjectDataHelper.createBusinessObjectDataFromEntity(businessObjectDataEntity);
}
use of org.finra.herd.model.annotation.NamespacePermission in project herd by FINRAOS.
the class BusinessObjectDataServiceImpl method searchBusinessObjectData.
@NamespacePermission(fields = "#businessObjectDataSearchRequest.businessObjectDataSearchFilters[0].BusinessObjectDataSearchKeys[0].namespace", permissions = NamespacePermissionEnum.READ)
@Override
public BusinessObjectDataSearchResultPagingInfoDto searchBusinessObjectData(Integer pageNum, Integer pageSize, BusinessObjectDataSearchRequest businessObjectDataSearchRequest) {
// TODO: Check name space permission for all entries in the request.
// Validate the business object data search request.
businessObjectDataSearchHelper.validateBusinessObjectDataSearchRequest(businessObjectDataSearchRequest);
// Get the maximum number of results that can be returned on any page of data. The "pageSize" query parameter should not be greater than
// this value or an HTTP status of 400 (Bad Request) error would be returned.
int maxResultsPerPage = configurationHelper.getProperty(ConfigurationValue.BUSINESS_OBJECT_DATA_SEARCH_MAX_PAGE_SIZE, Integer.class);
// Validate the page number and page size
// Set the defaults if pageNum and pageSize are null
// Page number must be greater than 0
// Page size must be greater than 0 and less than maximum page size
pageNum = businessObjectDataSearchHelper.validatePagingParameter("pageNum", pageNum, 1, Integer.MAX_VALUE);
pageSize = businessObjectDataSearchHelper.validatePagingParameter("pageSize", pageSize, maxResultsPerPage, maxResultsPerPage);
// Get the maximum record count that is configured in the system.
Integer businessObjectDataSearchMaxResultCount = configurationHelper.getProperty(ConfigurationValue.BUSINESS_OBJECT_DATA_SEARCH_MAX_RESULT_COUNT, Integer.class);
// Get the business object data search key.
// We assume that the input list contains only one filter with a single search key, since validation should be passed by now.
BusinessObjectDataSearchKey businessObjectDataSearchKey = businessObjectDataSearchRequest.getBusinessObjectDataSearchFilters().get(0).getBusinessObjectDataSearchKeys().get(0);
// Get the total record count.
Long totalRecordCount = businessObjectDataDao.getBusinessObjectDataCountBySearchKey(businessObjectDataSearchKey);
// Validate the total record count.
if (totalRecordCount > businessObjectDataSearchMaxResultCount) {
throw new IllegalArgumentException(String.format("Result limit of %d exceeded. Total result size %d. Modify filters to further limit results.", businessObjectDataSearchMaxResultCount, totalRecordCount));
}
// If total record count is zero, we return an empty result list. Otherwise, execute the search.
List<BusinessObjectData> businessObjectDataList = totalRecordCount == 0 ? new ArrayList<>() : businessObjectDataDao.searchBusinessObjectData(businessObjectDataSearchKey, pageNum, pageSize);
// Get the page count.
Long pageCount = totalRecordCount / pageSize + (totalRecordCount % pageSize > 0 ? 1 : 0);
// Build and return the business object data search result with the paging information.
return new BusinessObjectDataSearchResultPagingInfoDto(pageNum.longValue(), pageSize.longValue(), pageCount, (long) businessObjectDataList.size(), totalRecordCount, (long) maxResultsPerPage, new BusinessObjectDataSearchResult(businessObjectDataList));
}
use of org.finra.herd.model.annotation.NamespacePermission in project herd by FINRAOS.
the class EmrClusterDefinitionServiceImpl method getEmrClusterDefinitions.
@NamespacePermission(fields = "#namespace", permissions = NamespacePermissionEnum.READ)
@Override
public EmrClusterDefinitionKeys getEmrClusterDefinitions(String namespace) {
// Validate the namespace.
Assert.hasText(namespace, "A namespace must be specified.");
// Retrieve and return the list of EMR cluster definition keys.
EmrClusterDefinitionKeys emrClusterDefinitionKeys = new EmrClusterDefinitionKeys();
emrClusterDefinitionKeys.getEmrClusterDefinitionKeys().addAll(emrClusterDefinitionDao.getEmrClusterDefinitionsByNamespace(namespace.trim()));
return emrClusterDefinitionKeys;
}
use of org.finra.herd.model.annotation.NamespacePermission in project herd by FINRAOS.
the class EmrClusterDefinitionServiceImpl method deleteEmrClusterDefinition.
@NamespacePermission(fields = "#emrClusterDefinitionKey?.namespace", permissions = NamespacePermissionEnum.WRITE)
@Override
public EmrClusterDefinitionInformation deleteEmrClusterDefinition(EmrClusterDefinitionKey emrClusterDefinitionKey) throws Exception {
// Perform validate and trim of the EMR cluster definition key.
emrClusterDefinitionHelper.validateEmrClusterDefinitionKey(emrClusterDefinitionKey);
// Retrieve and ensure that a EMR cluster definition already exists with the specified key.
EmrClusterDefinitionEntity emrClusterDefinitionEntity = emrClusterDefinitionDaoHelper.getEmrClusterDefinitionEntity(emrClusterDefinitionKey);
// Log the existing EMR cluster definition.
LOGGER.info("Logging EMR cluster definition being deleted. emrClusterDefinition={}", xmlHelper.objectToXml(createEmrClusterDefinitionFromEntity(emrClusterDefinitionEntity), true));
// Delete the EMR cluster definition.
emrClusterDefinitionDao.delete(emrClusterDefinitionEntity);
// Create and return the EMR cluster definition object from the deleted entity.
return createEmrClusterDefinitionFromEntity(emrClusterDefinitionEntity);
}
Aggregations