Skip to content

Commit

Permalink
Merge branch 'develop' into fli-iam#fli-iam#1864
Browse files Browse the repository at this point in the history
  • Loading branch information
youennmerel authored Sep 25, 2023
2 parents 05c4af1 + 6a7065e commit abd47b1
Show file tree
Hide file tree
Showing 236 changed files with 3,046 additions and 2,210 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ jobs:
packages: write
contents: read
steps:
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 11
java-version: 17

- name: Check out the repo
uses: actions/checkout@v3
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
CREATE TABLE `dataset_property` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`name` varchar(255) DEFAULT NULL,
`value` varchar(255) DEFAULT NULL,
`dataset_id` bigint(20) DEFAULT NULL,
`dataset_processing_id` bigint(20) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `FK1mcyt0h60808jmj3shlvge9c8` (`dataset_id`),
KEY `FKl09g6qevg8filjycsylycbdxw` (`dataset_processing_id`),
CONSTRAINT `FK1mcyt0h60808jmj3shlvge9c8` FOREIGN KEY (`dataset_id`) REFERENCES `dataset` (`id`),
CONSTRAINT `FKl09g6qevg8filjycsylycbdxw` FOREIGN KEY (`dataset_processing_id`) REFERENCES `dataset_processing` (`id`)
)

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
CREATE TABLE `processing_resource` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`resource_id` varchar(255) NOT NULL,
`dataset_id` bigint(20) DEFAULT NULL,
`processing_id` bigint(20) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `FK7971ykr4l94b3qgns4do405qe` (`dataset_id`),
KEY `FKtkm1ww8m49x3jdwdtocijhrha` (`processing_id`),
CONSTRAINT `FK7971ykr4l94b3qgns4do405qe` FOREIGN KEY (`dataset_id`) REFERENCES `dataset` (`id`),
CONSTRAINT `FKtkm1ww8m49x3jdwdtocijhrha` FOREIGN KEY (`processing_id`) REFERENCES `dataset_processing` (`id`)
)
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@

package org.shanoir.ng;

import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.databind.Module;
import com.fasterxml.jackson.databind.module.SimpleModule;
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import org.shanoir.ng.shared.paging.PageSerializer;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
Expand All @@ -22,12 +26,6 @@
import org.springframework.data.web.config.EnableSpringDataWebSupport;
import org.springframework.scheduling.annotation.EnableScheduling;

import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.databind.Module;
import com.fasterxml.jackson.databind.module.SimpleModule;

import io.swagger.v3.oas.annotations.OpenAPIDefinition;

/**
* Shanoir-NG microservice datasets application.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@

package org.shanoir.ng.bids.controller;

import java.io.IOException;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import org.shanoir.ng.bids.model.BidsElement;
import org.shanoir.ng.shared.exception.RestServiceException;
import org.springframework.http.ResponseEntity;
Expand All @@ -12,13 +17,7 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import java.io.IOException;

@Tag(name = "bids")
@RequestMapping("/bids")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,9 @@
package org.shanoir.ng.bids.controller;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.SimpleDateFormat;
import java.util.stream.Stream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

import io.swagger.v3.oas.annotations.Parameter;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;

import org.apache.commons.io.FileUtils;
import org.joda.time.DateTime;
import org.shanoir.ng.bids.BidsDeserializer;
Expand All @@ -35,7 +23,17 @@
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;

import io.swagger.v3.oas.annotations.Parameter;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.SimpleDateFormat;
import java.util.stream.Stream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

@Controller
public class BidsApiController implements BidsApi {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@

package org.shanoir.ng.configuration.amqp;

import java.io.IOException;
import java.util.*;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.solr.client.solrj.SolrServerException;
import org.shanoir.ng.bids.service.BIDSService;
import org.shanoir.ng.dataset.dto.StudyStorageVolumeDTO;
Expand Down Expand Up @@ -46,11 +44,8 @@
import org.slf4j.LoggerFactory;
import org.springframework.amqp.AmqpRejectAndDontRequeueException;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.rabbit.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Component;
Expand All @@ -59,7 +54,8 @@
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;

import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
import java.util.*;

/**
* RabbitMQ configuration.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@

package org.shanoir.ng.configuration.security;

import java.util.Collection;
import java.util.Map;
import java.util.stream.Collectors;

import org.shanoir.ng.dicom.web.StowRSMultipartRelatedRequestFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
Expand All @@ -40,6 +36,10 @@
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;

import java.util.Collection;
import java.util.Map;
import java.util.stream.Collectors;

/**
* Spring security configuration.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,6 @@

package org.shanoir.ng.dataset.controler;

import java.io.IOException;

import org.shanoir.ng.shared.exception.RestServiceException;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
Expand All @@ -32,6 +23,15 @@
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import org.shanoir.ng.shared.exception.EntityNotFoundException;
import org.shanoir.ng.shared.exception.RestServiceException;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import java.io.IOException;

/**
* @author Alae Es-saki
Expand All @@ -51,6 +51,6 @@ public interface CarminDataApi {
produces = { "application/json", "application/octet-stream" },
method = RequestMethod.GET)
ResponseEntity<?> getPath(@Parameter(name = "the complete path on which to request information. It can contain non-encoded slashes. Except for the \"exists\" action, any request on a non-existing path should return an error", required=true) @PathVariable("completePath") String completePath, @NotNull @Parameter(name = "The \"content\" action downloads the raw file. If the path points to a directory, a tarball of this directory is returned. The \"exists\" action returns a BooleanResponse object (see definition) indicating if the path exists or not. The \"properties\" action returns a Path object (see definition) with the path properties. The \"list\" action returns a DirectoryList object (see definition) with the properties of all the files of the directory (if the path is not a directory an error must be returned). The \"md5\" action is optional and returns a PathMd5 object (see definition)." ,required=true
) @Valid @RequestParam(value = "action", required = true) String action, @Valid @RequestParam(value = "format", required = false, defaultValue = "dcm") final String format, HttpServletResponse response) throws IOException, RestServiceException;
) @Valid @RequestParam(value = "action", required = true) String action, @Valid @RequestParam(value = "format", required = false, defaultValue = "dcm") final String format, HttpServletResponse response) throws IOException, RestServiceException, EntityNotFoundException;

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,46 +15,73 @@

package org.shanoir.ng.dataset.controler;

import java.io.IOException;

import io.swagger.v3.oas.annotations.Parameter;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import org.shanoir.ng.dataset.model.Dataset;
import org.shanoir.ng.dataset.service.DatasetDownloaderServiceImpl;
import org.shanoir.ng.processing.carmin.service.ProcessingResourceService;
import org.shanoir.ng.shared.exception.EntityNotFoundException;
import org.shanoir.ng.shared.exception.RestServiceException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;

import io.swagger.v3.oas.annotations.Parameter;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import java.io.IOException;
import java.util.List;

@Controller
public class CarminDataApiController implements CarminDataApi{

private static final Logger LOG = LoggerFactory.getLogger(CarminDataApiController.class);

private static final String DCM = "dcm";

@Autowired
private DatasetDownloaderServiceImpl datasetDownloaderService;

@Autowired
private ProcessingResourceService processingResourceService;

@Override
public ResponseEntity<?> getPath(@Parameter(name = "the complete path on which to request information. It can contain non-encoded slashes. Except for the \"exists\" action, any request on a non-existing path should return an error", required=true) @PathVariable("completePath") String completePath, @NotNull @Parameter(name = "The \"content\" action downloads the raw file. If the path points to a directory, a tarball of this directory is returned. The \"exists\" action returns a BooleanResponse object (see definition) indicating if the path exists or not. The \"properties\" action returns a Path object (see definition) with the path properties. The \"list\" action returns a DirectoryList object (see definition) with the properties of all the files of the directory (if the path is not a directory an error must be returned). The \"md5\" action is optional and returns a PathMd5 object (see definition)." ,required=true
) @Valid @RequestParam(value = "action", required = true, defaultValue = "content") String action, @Valid @RequestParam(value = "format", required = false, defaultValue = DCM) final String format, HttpServletResponse response) throws IOException, RestServiceException {
public ResponseEntity<?> getPath(
@Parameter(name = "the complete path on which to request information. It can contain non-encoded slashes. Except for the \"exists\" action, any request on a non-existing path should return an error",
required=true)
@PathVariable("completePath") String completePath,
@NotNull @Parameter(name = "The \"content\" action downloads the raw file. If the path points to a directory, a tarball of this directory is returned. The \"exists\" action returns a BooleanResponse object (see definition) indicating if the path exists or not. The \"properties\" action returns a Path object (see definition) with the path properties. The \"list\" action returns a DirectoryList object (see definition) with the properties of all the files of the directory (if the path is not a directory an error must be returned). The \"md5\" action is optional and returns a PathMd5 object (see definition).",
required=true)
@Valid @RequestParam(value = "action", required = true, defaultValue = "content") String action,
@Valid @RequestParam(value = "format", required = false, defaultValue = DCM) final String format,
HttpServletResponse response) throws IOException, RestServiceException, EntityNotFoundException {
// TODO implement those actions
switch (action){
case "exists":
case "list":
case "md5":
case "properties":
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
case "content":{
datasetDownloaderService.downloadDatasetById(Long.parseLong(completePath),null, format, response, true);
case "content":

List<Dataset> datasets = this.processingResourceService.findDatasetsByResourceId(completePath);

if(datasets.isEmpty()){
LOG.error("No dataset found for resource id [{}]", completePath);
return new ResponseEntity<Void>(HttpStatus.BAD_REQUEST);
}

datasetDownloaderService.massiveDownload(format, datasets, response, true);

return new ResponseEntity<Void>(HttpStatus.OK);
}
}

return new ResponseEntity<Void>(HttpStatus.BAD_REQUEST);

}

}
Loading

0 comments on commit abd47b1

Please sign in to comment.