use of org.obiba.mica.core.domain.DocumentSet in project mica2 by obiba.
the class PublishedNetworksSetResource method reportNetworks.
@GET
@Path("/documents/_report")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public Response reportNetworks(@PathParam("id") String id, @QueryParam("locale") @DefaultValue("en") String locale) {
DocumentSet documentSet = getSecuredDocumentSet(id);
ReportGenerator reporter = new NetworkCsvReportGenerator(networkSetService.getPublishedNetworks(documentSet, true), locale, personService);
StreamingOutput stream = reporter::write;
return Response.ok(stream).header("Content-Disposition", "attachment; filename=\"Networks.zip\"").build();
}
use of org.obiba.mica.core.domain.DocumentSet in project mica2 by obiba.
the class AbstractPublishedDocumentsSetResource method getDocumentSet.
protected Mica.DocumentSetDto getDocumentSet(String id) {
DocumentSet documentSet = getSecuredDocumentSet(id);
getDocumentSetService().touch(documentSet);
return dtos.asDto(documentSet);
}
use of org.obiba.mica.core.domain.DocumentSet in project mica2 by obiba.
the class AbstractPublishedDocumentsSetResource method getSecuredDocumentSet.
protected DocumentSet getSecuredDocumentSet(String id) {
DocumentSet documentSet = getDocumentSetService().get(id);
if (!subjectAclService.isCurrentUser(documentSet.getUsername()) && !subjectAclService.isAdministrator() && !subjectAclService.isDataAccessOfficer())
throw new AuthorizationException();
boolean enabled = isCartEnabled(micaConfigService.getConfig());
// cart
if (!enabled && !documentSet.hasName())
throw new AuthorizationException();
if (enabled && !subjectAclService.hasMicaRole() && !documentSet.hasName())
// cart
throw new AuthorizationException();
if (documentSet.hasName() && !subjectAclService.hasMicaRole())
throw new AuthorizationException();
getDocumentSetService().touch(documentSet);
return documentSet;
}
use of org.obiba.mica.core.domain.DocumentSet in project mica2 by obiba.
the class AbstractPublishedDocumentsSetResource method exportDocuments.
protected StreamingOutput exportDocuments(String id) {
DocumentSet documentSet = getSecuredDocumentSet(id);
getDocumentSetService().touch(documentSet);
return toStream(documentSet.getIdentifiers());
}
use of org.obiba.mica.core.domain.DocumentSet in project mica2 by obiba.
the class AbstractPublishedDocumentsSetResource method importDocuments.
protected Mica.DocumentSetDto importDocuments(String id, String body) {
DocumentSet set = getSecuredDocumentSet(id);
if (Strings.isNullOrEmpty(body))
return dtos.asDto(set);
getDocumentSetService().addIdentifiers(id, getDocumentSetService().extractIdentifiers(body));
return dtos.asDto(getDocumentSetService().get(id));
}
Aggregations