use of org.obiba.mica.file.rest.FileResource in project mica2 by obiba.
the class PublishedNetworkResource method study.
@Path("/file/{fileId}")
public FileResource study(@PathParam("id") String id, @PathParam("fileId") String fileId) {
checkAccess(id);
FileResource fileResource = applicationContext.getBean(FileResource.class);
Network network = getNetwork(id);
if (network.getLogo() == null)
throw NoSuchEntityException.withId(Attachment.class, fileId);
fileResource.setAttachment(network.getLogo());
return fileResource;
}
use of org.obiba.mica.file.rest.FileResource in project mica2 by obiba.
the class DraftHarmonizationStudyResource method file.
@Path("/file/{fileId}")
public FileResource file(@PathParam("fileId") String fileId, @QueryParam("key") String key) {
checkPermission("/draft/harmonization-study", "VIEW", key);
FileResource fileResource = applicationContext.getBean(FileResource.class);
HarmonizationStudy study = studyService.findDraft(id);
if (study.hasLogo() && study.getLogo().getId().equals(fileId)) {
fileResource.setAttachment(study.getLogo());
} else {
List<Attachment> attachments = fileSystemService.findAttachments(String.format("^/harmonization-study/%s", study.getId()), false).stream().filter(a -> a.getId().equals(fileId)).collect(Collectors.toList());
if (attachments.isEmpty())
throw NoSuchEntityException.withId(Attachment.class, fileId);
fileResource.setAttachment(attachments.get(0));
}
return fileResource;
}
use of org.obiba.mica.file.rest.FileResource in project mica2 by obiba.
the class DraftNetworkResource method file.
@Path("/file/{fileId}")
public FileResource file(@PathParam("fileId") String fileId, @QueryParam("key") String key) {
checkPermission("/draft/network", "VIEW", key);
FileResource fileResource = applicationContext.getBean(FileResource.class);
Network network = networkService.findById(id);
if (network.getLogo() == null)
throw NoSuchEntityException.withId(Attachment.class, fileId);
fileResource.setAttachment(network.getLogo());
return fileResource;
}
use of org.obiba.mica.file.rest.FileResource in project mica2 by obiba.
the class DraftProjectResource method file.
@Path("/file/{fileId}")
public FileResource file(@PathParam("fileId") String fileId, @QueryParam("key") String key) {
checkPermission("/draft/project", "VIEW", key);
FileResource fileResource = applicationContext.getBean(FileResource.class);
projectService.findById(id);
return fileResource;
}
use of org.obiba.mica.file.rest.FileResource in project mica2 by obiba.
the class AbstractPublishedStudyResource method getStudyFileResource.
protected FileResource getStudyFileResource(String id, String fileId) {
checkAccess(id);
FileResource fileResource = applicationContext.getBean(FileResource.class);
BaseStudy study = getStudy(id);
if (study.hasLogo() && study.getLogo().getId().equals(fileId)) {
fileResource.setAttachment(study.getLogo());
} else {
List<Attachment> attachments = fileSystemService.findAttachments(String.format("^/%s/%s", getStudyPath(id), id), true).stream().filter(a -> a.getId().equals(fileId)).collect(Collectors.toList());
if (attachments.isEmpty())
throw NoSuchEntityException.withId(Attachment.class, fileId);
fileResource.setAttachment(attachments.get(0));
}
return fileResource;
}
Aggregations