use of org.obiba.mica.security.service.SubjectAclService in project mica2 by obiba.
the class DraftHarmonizedDatasetsResource method list.
/**
* Get all {@link HarmonizationDataset}, optionally filtered by study.
*
* @param studyId can be null, in which case all datasets are returned
* @return
*/
@GET
@Path("/harmonized-datasets")
@Timed
public List<Mica.DatasetDto> list(@QueryParam("study") String studyId, @QueryParam("query") String query, @QueryParam("from") @DefaultValue("0") Integer from, @QueryParam("limit") Integer limit, @QueryParam("sort") @DefaultValue("id") String sort, @QueryParam("order") @DefaultValue("asc") String order, @QueryParam("filter") @DefaultValue("ALL") String filter, @Context HttpServletResponse response) {
long totalCount;
EntityStateFilter entityStateFilter = EntityStateFilter.valueOf(filter);
List<String> filteredIds = datasetService.getIdsByStateFilter(entityStateFilter);
Searcher.IdFilter accessibleIdFilter = AccessibleIdFilterBuilder.newBuilder().aclService(subjectAclService).resources(Lists.newArrayList("/draft/harmonized-dataset")).ids(filteredIds).build();
if (limit == null)
limit = MAX_LIMIT;
if (limit < 0)
throw new IllegalArgumentException("limit cannot be negative");
DocumentService.Documents<HarmonizationDataset> datasets = draftDatasetService.find(from, limit, sort, order, studyId, query, null, null, accessibleIdFilter);
totalCount = datasets.getTotal();
response.addHeader("X-Total-Count", Long.toString(totalCount));
return datasets.getList().stream().map(dataset -> dtos.asDto(dataset, true)).collect(toList());
}
Aggregations