use of org.sagebionetworks.repo.web.service.StorageUsageService in project Synapse-Repository-Services by Sage-Bionetworks.
the class StorageUsageController method getItemizedStorageUsageForCurrentUser.
/**
* Retrieves detailed, itemized usage for the current user.
*
* @throws NotFoundException
* When the specified user does not exist.
*/
@ResponseStatus(HttpStatus.OK)
@RequestMapping(value = UrlHelpers.STORAGE_DETAILS, method = RequestMethod.GET)
@ResponseBody
public PaginatedResults<StorageUsage> getItemizedStorageUsageForCurrentUser(@RequestParam(value = AuthorizationConstants.USER_ID_PARAM, required = false) String currUserId, @RequestParam(value = ServiceConstants.PAGINATION_OFFSET_PARAM, required = false, defaultValue = ServiceConstants.DEFAULT_PAGINATION_OFFSET_PARAM_NEW) Integer offset, @RequestParam(value = ServiceConstants.PAGINATION_LIMIT_PARAM, required = false, defaultValue = ServiceConstants.DEFAULT_PRINCIPALS_PAGINATION_LIMIT_PARAM) Integer limit, HttpServletRequest request) throws NotFoundException, DatastoreException {
// XXX: Need a better way to wire in the URL
String url = request.getServletPath() + UrlHelpers.STORAGE_DETAILS;
StorageUsageService service = serviceProvider.getStorageUsageService();
PaginatedResults<StorageUsage> results = service.getUsageInRangeForUser(currUserId, currUserId, offset, limit, url);
return results;
}
use of org.sagebionetworks.repo.web.service.StorageUsageService in project Synapse-Repository-Services by Sage-Bionetworks.
the class StorageUsageController method getUsageForAdmin.
@ResponseStatus(HttpStatus.OK)
@RequestMapping(value = UrlHelpers.ADMIN_STORAGE_SUMMARY, method = RequestMethod.GET)
@ResponseBody
public StorageUsageSummaryList getUsageForAdmin(@RequestParam(value = AuthorizationConstants.USER_ID_PARAM, required = true) String currUserId, @RequestParam(value = ServiceConstants.AGGREGATION_DIMENSION, required = false) String aggregation) throws IllegalArgumentException, UnauthorizedException, NotFoundException, DatastoreException {
List<StorageUsageDimension> dList = getAggregatingDimensionList(aggregation);
StorageUsageService service = serviceProvider.getStorageUsageService();
StorageUsageSummaryList storageSummaries = service.getUsage(currUserId, dList);
return storageSummaries;
}
use of org.sagebionetworks.repo.web.service.StorageUsageService in project Synapse-Repository-Services by Sage-Bionetworks.
the class StorageUsageController method getItemizedStorageUsageForUser.
/**
* Retrieves detailed, itemized usage for the specified user. The current user must have
* the privilege (e.g. being administrator) to view the user's storage usage.
*
* @param userId
* The user whose storage usage is being queried.
* @param currUserId
* The current user, the user who is querying the storage usage.
* @throws UnauthorizedException
* When the current user is not authorized to view the specified user's storage usage.
* @throws NotFoundException
* When the specified user does not exist.
*/
@ResponseStatus(HttpStatus.OK)
@RequestMapping(value = UrlHelpers.STORAGE_DETAILS_USER_ID, method = RequestMethod.GET)
@ResponseBody
public PaginatedResults<StorageUsage> getItemizedStorageUsageForUser(@PathVariable(value = UrlHelpers.STORAGE_USER_ID) String userId, @RequestParam(value = AuthorizationConstants.USER_ID_PARAM, required = false) String currUserId, @RequestParam(value = ServiceConstants.PAGINATION_OFFSET_PARAM, required = false, defaultValue = ServiceConstants.DEFAULT_PAGINATION_OFFSET_PARAM_NEW) Integer offset, @RequestParam(value = ServiceConstants.PAGINATION_LIMIT_PARAM, required = false, defaultValue = ServiceConstants.DEFAULT_PRINCIPALS_PAGINATION_LIMIT_PARAM) Integer limit, HttpServletRequest request) throws UnauthorizedException, NotFoundException, DatastoreException {
// XXX: Need a better way to wire in the URL
String url = request.getServletPath() + UrlHelpers.STORAGE_DETAILS_USER_ID;
StorageUsageService service = serviceProvider.getStorageUsageService();
PaginatedResults<StorageUsage> results = service.getUsageInRangeForUser(currUserId, userId, offset, limit, url);
return results;
}
use of org.sagebionetworks.repo.web.service.StorageUsageService in project Synapse-Repository-Services by Sage-Bionetworks.
the class StorageUsageController method getUsageForCurrentUser.
/**
* Retrieves the aggregated usage for the current user. Aggregation is done over the supplied dimensions,
* for example, ['storage_provider', 'content_type']. If no dimension is passed, the returned results
* will contain only the grand total.
*
* @param aggregation
* Aggregating dimensions/columns. This must be concatenated values of the StorageUsageDimension enum.
* @throws IllegalArgumentException
* When the supplied list of aggregating dimensions has invalid values. See StorageUsageDimension for valid values.
* @throws NotFoundException
* When the user does not exist.
*/
@ResponseStatus(HttpStatus.OK)
@RequestMapping(value = UrlHelpers.STORAGE_SUMMARY, method = RequestMethod.GET)
@ResponseBody
public StorageUsageSummaryList getUsageForCurrentUser(@RequestParam(value = AuthorizationConstants.USER_ID_PARAM, required = true) String currUserId, @RequestParam(value = ServiceConstants.AGGREGATION_DIMENSION, required = false) String aggregation) throws IllegalArgumentException, NotFoundException, DatastoreException {
List<StorageUsageDimension> dList = getAggregatingDimensionList(aggregation);
StorageUsageService service = serviceProvider.getStorageUsageService();
StorageUsageSummaryList storageSummaries = service.getUsageForUser(currUserId, currUserId, dList);
return storageSummaries;
}
use of org.sagebionetworks.repo.web.service.StorageUsageService in project Synapse-Repository-Services by Sage-Bionetworks.
the class StorageUsageController method getUsageForUser.
/**
* Retrieves the aggregated usage for the specified user. Aggregation is done over the supplied dimensions,
* for example, ['storage_provider', 'content_type']. If no dimension is passed, the returned results
* will contain only the grand total. The current user must have the privilege (e.g. admin) to view
* a different user's storage usage.
*
* @param userId
* The user whose storage usage is being queried.
* @param currUserId
* The current user, the user who is querying the storage usage.
* @param aggregation
* Aggregating dimensions/columns. This must be concatenated values of the StorageUsageDimension enum.
* @throws IllegalArgumentException
* When the supplied list of aggregating dimensions has invalid values. See StorageUsageDimension for valid values.
* @throws UnauthorizedException
* When the current user is not authorized to view the specified user's storage usage.
* @throws NotFoundException
* When the specified user does not exist.
*/
@ResponseStatus(HttpStatus.OK)
@RequestMapping(value = UrlHelpers.STORAGE_SUMMARY_USER_ID, method = RequestMethod.GET)
@ResponseBody
public StorageUsageSummaryList getUsageForUser(@PathVariable(value = UrlHelpers.STORAGE_USER_ID) String userId, @RequestParam(value = AuthorizationConstants.USER_ID_PARAM, required = true) String currUserId, @RequestParam(value = ServiceConstants.AGGREGATION_DIMENSION, required = false) String aggregation) throws IllegalArgumentException, UnauthorizedException, NotFoundException, DatastoreException {
List<StorageUsageDimension> dList = getAggregatingDimensionList(aggregation);
StorageUsageService service = serviceProvider.getStorageUsageService();
StorageUsageSummaryList storageSummaries = service.getUsageForUser(currUserId, userId, dList);
return storageSummaries;
}
Aggregations