Loading src/main/java/it/inaf/ia2/transfer/FileServiceApplication.java +10 −0 Original line number Original line Diff line number Diff line Loading @@ -15,8 +15,13 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.web.servlet.FilterRegistrationBean; import org.springframework.boot.web.servlet.FilterRegistrationBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean; import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate; import org.springframework.context.annotation.Import; import it.inaf.oats.vospace.parent.persistence.LinkedServiceDAO; import it.inaf.ia2.aa.ServiceLocator; import it.inaf.ia2.aa.ServletRapClient; @SpringBootApplication @SpringBootApplication @Import(LinkedServiceDAO.class) public class FileServiceApplication { public class FileServiceApplication { @Value("${jwks_uri}") @Value("${jwks_uri}") Loading @@ -40,6 +45,11 @@ public class FileServiceApplication { return registration; return registration; } } @Bean public ServletRapClient servletRapClient() { return (ServletRapClient) ServiceLocator.getInstance().getRapClient(); } @Bean @Bean public RestTemplate restTemplate() { public RestTemplate restTemplate() { return new RestTemplate(); return new RestTemplate(); Loading src/main/java/it/inaf/ia2/transfer/controller/ArchiveFileController.java +6 −2 Original line number Original line Diff line number Diff line Loading @@ -12,6 +12,7 @@ import it.inaf.ia2.transfer.service.ArchiveService; import it.inaf.oats.vospace.exception.PermissionDeniedException; import it.inaf.oats.vospace.exception.PermissionDeniedException; import java.io.File; import java.io.File; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders; Loading @@ -30,6 +31,9 @@ public class ArchiveFileController extends AuthenticatedFileController { @Autowired @Autowired private ArchiveService archiveService; private ArchiveService archiveService; @Autowired private HttpServletRequest servletRequest; @Autowired @Autowired private HttpServletResponse response; private HttpServletResponse response; Loading @@ -42,10 +46,10 @@ public class ArchiveFileController extends AuthenticatedFileController { job.setPrincipal(getPrincipal()); job.setPrincipal(getPrincipal()); job.setJobId(archiveRequest.getJobId()); job.setJobId(archiveRequest.getJobId()); job.setType(type); job.setType(type); job.setVosPaths(archiveRequest.getPaths()); job.setEntryDescriptors(archiveRequest.getEntryDescriptors()); CompletableFuture.runAsync(() -> { CompletableFuture.runAsync(() -> { handleFileJob(() -> archiveService.createArchive(job), job.getJobId()); handleFileJob(() -> archiveService.createArchive(job, servletRequest), job.getJobId()); }); }); HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders(); Loading src/main/java/it/inaf/ia2/transfer/controller/ArchiveRequest.java +6 −5 Original line number Original line Diff line number Diff line Loading @@ -5,13 +5,14 @@ */ */ package it.inaf.ia2.transfer.controller; package it.inaf.ia2.transfer.controller; import it.inaf.oats.vospace.parent.exchange.ArchiveEntryDescriptor; import java.util.List; import java.util.List; public class ArchiveRequest { public class ArchiveRequest { private String type; private String type; private String jobId; private String jobId; private List<String> paths; private List<ArchiveEntryDescriptor> entryDescriptors; public String getType() { public String getType() { return type; return type; Loading @@ -29,11 +30,11 @@ public class ArchiveRequest { this.jobId = jobId; this.jobId = jobId; } } public List<String> getPaths() { public List<ArchiveEntryDescriptor> getEntryDescriptors() { return paths; return entryDescriptors; } } public void setPaths(List<String> paths) { public void setEntryDescriptors(List<ArchiveEntryDescriptor> entryDescriptors) { this.paths = paths; this.entryDescriptors = entryDescriptors; } } } } src/main/java/it/inaf/ia2/transfer/persistence/FileDAO.java +10 −5 Original line number Original line Diff line number Diff line Loading @@ -47,7 +47,7 @@ public class FileDAO { + "accept_views, provide_views, l.location_type, n.path <> n.relative_path AS virtual_parent,\n" + "accept_views, provide_views, l.location_type, n.path <> n.relative_path AS virtual_parent,\n" + "(SELECT user_name FROM users WHERE user_id = creator_id) AS username, n.job_id,\n" + "(SELECT user_name FROM users WHERE user_id = creator_id) AS username, n.job_id,\n" + "base_path, get_os_path(n.node_id) AS os_path, ? AS vos_path, false AS is_directory,\n" + "base_path, get_os_path(n.node_id) AS os_path, ? AS vos_path, false AS is_directory,\n" + "type = 'link' AS is_link,\n" + "n.type = 'link' AS is_link, n.target,\n" + "fs_path \n" + "fs_path \n" + "FROM node n\n" + "FROM node n\n" + "JOIN location l ON (n.location_id IS NOT NULL AND n.location_id = l.location_id) OR (n.location_id IS NULL AND l.location_id = ?)\n" + "JOIN location l ON (n.location_id IS NOT NULL AND n.location_id = l.location_id) OR (n.location_id IS NULL AND l.location_id = ?)\n" Loading Loading @@ -180,7 +180,7 @@ public class FileDAO { + "(SELECT user_name FROM users WHERE user_id = n.creator_id) AS username,\n" + "(SELECT user_name FROM users WHERE user_id = n.creator_id) AS username,\n" + "base_path, get_os_path(n.node_id) AS os_path, get_vos_path(n.node_id) AS vos_path,\n" + "base_path, get_os_path(n.node_id) AS os_path, get_vos_path(n.node_id) AS vos_path,\n" + "n.type = 'container' AS is_directory, n.name, n.location_id, n.job_id,\n" + "n.type = 'container' AS is_directory, n.name, n.location_id, n.job_id,\n" + "n.type = 'link' AS is_link, l.location_type\n" + "n.type = 'link' AS is_link, n.target, l.location_type\n" + "FROM node n\n" + "FROM node n\n" + "JOIN node p ON p.path @> n.path\n" + "JOIN node p ON p.path @> n.path\n" + "LEFT JOIN location l ON l.location_id = n.location_id\n" + "LEFT JOIN location l ON l.location_id = n.location_id\n" Loading Loading @@ -213,7 +213,7 @@ public class FileDAO { + "(SELECT user_name FROM users WHERE user_id = n.creator_id) AS username,\n" + "(SELECT user_name FROM users WHERE user_id = n.creator_id) AS username,\n" + "base_path, get_os_path(n.node_id) AS os_path, get_vos_path(n.node_id) AS vos_path,\n" + "base_path, get_os_path(n.node_id) AS os_path, get_vos_path(n.node_id) AS vos_path,\n" + "n.type = 'container' AS is_directory, n.name, n.location_id, n.job_id,\n" + "n.type = 'container' AS is_directory, n.name, n.location_id, n.job_id,\n" + "n.type = 'link' AS is_link, l.location_type\n" + "n.type = 'link' AS is_link, n.target, l.location_type\n" + "FROM node n\n" + "FROM node n\n" + "JOIN node p ON p.path @> n.path\n" + "JOIN node p ON p.path @> n.path\n" + "LEFT JOIN location l ON l.location_id = n.location_id\n" + "LEFT JOIN location l ON l.location_id = n.location_id\n" Loading Loading @@ -293,7 +293,12 @@ public class FileDAO { fi.setContentMd5(rs.getString("content_md5")); fi.setContentMd5(rs.getString("content_md5")); fi.setContentType(rs.getString("content_type")); fi.setContentType(rs.getString("content_type")); fi.setDirectory(rs.getBoolean("is_directory")); fi.setDirectory(rs.getBoolean("is_directory")); fi.setLink(rs.getBoolean("is_link")); if(rs.getBoolean("is_link")){ fi.setLink(true); fi.setTarget(rs.getString("target")); } else { fi.setLink(false); } fi.setJobId(rs.getString("job_id")); fi.setJobId(rs.getString("job_id")); int locationId = rs.getInt("location_id"); int locationId = rs.getInt("location_id"); if (!rs.wasNull()) { if (!rs.wasNull()) { Loading src/main/java/it/inaf/ia2/transfer/persistence/model/FileInfo.java +10 −1 Original line number Original line Diff line number Diff line Loading @@ -22,6 +22,7 @@ public class FileInfo { private boolean virtualParent; private boolean virtualParent; private boolean directory; private boolean directory; private boolean link; private boolean link; private String target; private List<String> groupRead; private List<String> groupRead; private List<String> groupWrite; private List<String> groupWrite; private String ownerId; private String ownerId; Loading @@ -36,6 +37,14 @@ public class FileInfo { private String locationType; private String locationType; private String jobId; private String jobId; public String getTarget() { return target; } public void setTarget(String target) { this.target = target; } public int getNodeId() { public int getNodeId() { return nodeId; return nodeId; } } Loading Loading
src/main/java/it/inaf/ia2/transfer/FileServiceApplication.java +10 −0 Original line number Original line Diff line number Diff line Loading @@ -15,8 +15,13 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.web.servlet.FilterRegistrationBean; import org.springframework.boot.web.servlet.FilterRegistrationBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean; import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate; import org.springframework.context.annotation.Import; import it.inaf.oats.vospace.parent.persistence.LinkedServiceDAO; import it.inaf.ia2.aa.ServiceLocator; import it.inaf.ia2.aa.ServletRapClient; @SpringBootApplication @SpringBootApplication @Import(LinkedServiceDAO.class) public class FileServiceApplication { public class FileServiceApplication { @Value("${jwks_uri}") @Value("${jwks_uri}") Loading @@ -40,6 +45,11 @@ public class FileServiceApplication { return registration; return registration; } } @Bean public ServletRapClient servletRapClient() { return (ServletRapClient) ServiceLocator.getInstance().getRapClient(); } @Bean @Bean public RestTemplate restTemplate() { public RestTemplate restTemplate() { return new RestTemplate(); return new RestTemplate(); Loading
src/main/java/it/inaf/ia2/transfer/controller/ArchiveFileController.java +6 −2 Original line number Original line Diff line number Diff line Loading @@ -12,6 +12,7 @@ import it.inaf.ia2.transfer.service.ArchiveService; import it.inaf.oats.vospace.exception.PermissionDeniedException; import it.inaf.oats.vospace.exception.PermissionDeniedException; import java.io.File; import java.io.File; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders; Loading @@ -30,6 +31,9 @@ public class ArchiveFileController extends AuthenticatedFileController { @Autowired @Autowired private ArchiveService archiveService; private ArchiveService archiveService; @Autowired private HttpServletRequest servletRequest; @Autowired @Autowired private HttpServletResponse response; private HttpServletResponse response; Loading @@ -42,10 +46,10 @@ public class ArchiveFileController extends AuthenticatedFileController { job.setPrincipal(getPrincipal()); job.setPrincipal(getPrincipal()); job.setJobId(archiveRequest.getJobId()); job.setJobId(archiveRequest.getJobId()); job.setType(type); job.setType(type); job.setVosPaths(archiveRequest.getPaths()); job.setEntryDescriptors(archiveRequest.getEntryDescriptors()); CompletableFuture.runAsync(() -> { CompletableFuture.runAsync(() -> { handleFileJob(() -> archiveService.createArchive(job), job.getJobId()); handleFileJob(() -> archiveService.createArchive(job, servletRequest), job.getJobId()); }); }); HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders(); Loading
src/main/java/it/inaf/ia2/transfer/controller/ArchiveRequest.java +6 −5 Original line number Original line Diff line number Diff line Loading @@ -5,13 +5,14 @@ */ */ package it.inaf.ia2.transfer.controller; package it.inaf.ia2.transfer.controller; import it.inaf.oats.vospace.parent.exchange.ArchiveEntryDescriptor; import java.util.List; import java.util.List; public class ArchiveRequest { public class ArchiveRequest { private String type; private String type; private String jobId; private String jobId; private List<String> paths; private List<ArchiveEntryDescriptor> entryDescriptors; public String getType() { public String getType() { return type; return type; Loading @@ -29,11 +30,11 @@ public class ArchiveRequest { this.jobId = jobId; this.jobId = jobId; } } public List<String> getPaths() { public List<ArchiveEntryDescriptor> getEntryDescriptors() { return paths; return entryDescriptors; } } public void setPaths(List<String> paths) { public void setEntryDescriptors(List<ArchiveEntryDescriptor> entryDescriptors) { this.paths = paths; this.entryDescriptors = entryDescriptors; } } } }
src/main/java/it/inaf/ia2/transfer/persistence/FileDAO.java +10 −5 Original line number Original line Diff line number Diff line Loading @@ -47,7 +47,7 @@ public class FileDAO { + "accept_views, provide_views, l.location_type, n.path <> n.relative_path AS virtual_parent,\n" + "accept_views, provide_views, l.location_type, n.path <> n.relative_path AS virtual_parent,\n" + "(SELECT user_name FROM users WHERE user_id = creator_id) AS username, n.job_id,\n" + "(SELECT user_name FROM users WHERE user_id = creator_id) AS username, n.job_id,\n" + "base_path, get_os_path(n.node_id) AS os_path, ? AS vos_path, false AS is_directory,\n" + "base_path, get_os_path(n.node_id) AS os_path, ? AS vos_path, false AS is_directory,\n" + "type = 'link' AS is_link,\n" + "n.type = 'link' AS is_link, n.target,\n" + "fs_path \n" + "fs_path \n" + "FROM node n\n" + "FROM node n\n" + "JOIN location l ON (n.location_id IS NOT NULL AND n.location_id = l.location_id) OR (n.location_id IS NULL AND l.location_id = ?)\n" + "JOIN location l ON (n.location_id IS NOT NULL AND n.location_id = l.location_id) OR (n.location_id IS NULL AND l.location_id = ?)\n" Loading Loading @@ -180,7 +180,7 @@ public class FileDAO { + "(SELECT user_name FROM users WHERE user_id = n.creator_id) AS username,\n" + "(SELECT user_name FROM users WHERE user_id = n.creator_id) AS username,\n" + "base_path, get_os_path(n.node_id) AS os_path, get_vos_path(n.node_id) AS vos_path,\n" + "base_path, get_os_path(n.node_id) AS os_path, get_vos_path(n.node_id) AS vos_path,\n" + "n.type = 'container' AS is_directory, n.name, n.location_id, n.job_id,\n" + "n.type = 'container' AS is_directory, n.name, n.location_id, n.job_id,\n" + "n.type = 'link' AS is_link, l.location_type\n" + "n.type = 'link' AS is_link, n.target, l.location_type\n" + "FROM node n\n" + "FROM node n\n" + "JOIN node p ON p.path @> n.path\n" + "JOIN node p ON p.path @> n.path\n" + "LEFT JOIN location l ON l.location_id = n.location_id\n" + "LEFT JOIN location l ON l.location_id = n.location_id\n" Loading Loading @@ -213,7 +213,7 @@ public class FileDAO { + "(SELECT user_name FROM users WHERE user_id = n.creator_id) AS username,\n" + "(SELECT user_name FROM users WHERE user_id = n.creator_id) AS username,\n" + "base_path, get_os_path(n.node_id) AS os_path, get_vos_path(n.node_id) AS vos_path,\n" + "base_path, get_os_path(n.node_id) AS os_path, get_vos_path(n.node_id) AS vos_path,\n" + "n.type = 'container' AS is_directory, n.name, n.location_id, n.job_id,\n" + "n.type = 'container' AS is_directory, n.name, n.location_id, n.job_id,\n" + "n.type = 'link' AS is_link, l.location_type\n" + "n.type = 'link' AS is_link, n.target, l.location_type\n" + "FROM node n\n" + "FROM node n\n" + "JOIN node p ON p.path @> n.path\n" + "JOIN node p ON p.path @> n.path\n" + "LEFT JOIN location l ON l.location_id = n.location_id\n" + "LEFT JOIN location l ON l.location_id = n.location_id\n" Loading Loading @@ -293,7 +293,12 @@ public class FileDAO { fi.setContentMd5(rs.getString("content_md5")); fi.setContentMd5(rs.getString("content_md5")); fi.setContentType(rs.getString("content_type")); fi.setContentType(rs.getString("content_type")); fi.setDirectory(rs.getBoolean("is_directory")); fi.setDirectory(rs.getBoolean("is_directory")); fi.setLink(rs.getBoolean("is_link")); if(rs.getBoolean("is_link")){ fi.setLink(true); fi.setTarget(rs.getString("target")); } else { fi.setLink(false); } fi.setJobId(rs.getString("job_id")); fi.setJobId(rs.getString("job_id")); int locationId = rs.getInt("location_id"); int locationId = rs.getInt("location_id"); if (!rs.wasNull()) { if (!rs.wasNull()) { Loading
src/main/java/it/inaf/ia2/transfer/persistence/model/FileInfo.java +10 −1 Original line number Original line Diff line number Diff line Loading @@ -22,6 +22,7 @@ public class FileInfo { private boolean virtualParent; private boolean virtualParent; private boolean directory; private boolean directory; private boolean link; private boolean link; private String target; private List<String> groupRead; private List<String> groupRead; private List<String> groupWrite; private List<String> groupWrite; private String ownerId; private String ownerId; Loading @@ -36,6 +37,14 @@ public class FileInfo { private String locationType; private String locationType; private String jobId; private String jobId; public String getTarget() { return target; } public void setTarget(String target) { this.target = target; } public int getNodeId() { public int getNodeId() { return nodeId; return nodeId; } } Loading