diff --git a/src/main/java/it/inaf/ia2/transfer/controller/GetFileController.java b/src/main/java/it/inaf/ia2/transfer/controller/GetFileController.java index ac28b3a27aa5b631ad53a730986faac1b34ea7db..31c2aa42165a5750fdaac5b6b69f254b0758c113 100644 --- a/src/main/java/it/inaf/ia2/transfer/controller/GetFileController.java +++ b/src/main/java/it/inaf/ia2/transfer/controller/GetFileController.java @@ -31,9 +31,6 @@ public class GetFileController extends FileController { @Autowired private FileDAO fileDAO; - @Autowired - private JobDAO jobDAO; - @Autowired private AuthorizationService authorizationService; diff --git a/src/main/java/it/inaf/ia2/transfer/persistence/FileDAO.java b/src/main/java/it/inaf/ia2/transfer/persistence/FileDAO.java index b04847b987caa28d015f89769ba581e2670da5ce..3800a25e9c244325e3f39f2f782776506a9d550d 100644 --- a/src/main/java/it/inaf/ia2/transfer/persistence/FileDAO.java +++ b/src/main/java/it/inaf/ia2/transfer/persistence/FileDAO.java @@ -44,9 +44,9 @@ public class FileDAO { String sql = "SELECT n.node_id, is_public, group_read, group_write, creator_id, async_trans,\n" + "content_type, content_encoding, content_length, content_md5, name, n.location_id,\n" - + "accept_views, provide_views, l.location_type, n.path <> n.relative_path AS virtual_parent,\n" + + "accept_views, provide_views, l.location_type,\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, ? AS vos_path, false AS is_directory,\n" + "n.type = 'link' AS is_link, n.target,\n" + "fs_path \n" + "FROM node n\n" @@ -176,9 +176,9 @@ public class FileDAO { String sql = "SELECT n.node_id, n.is_public, n.group_read, n.group_write, n.creator_id, n.async_trans, n.fs_path,\n" + "n.content_type, n.content_encoding, n.content_length, n.content_md5,\n" - + "n.accept_views, n.provide_views, l.location_type, n.path <> n.relative_path AS virtual_parent,\n" + + "n.accept_views, n.provide_views, l.location_type,\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_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 = 'link' AS is_link, n.target, l.location_type\n" + "FROM node n\n" @@ -209,9 +209,9 @@ public class FileDAO { String sql = "SELECT n.node_id, n.is_public, n.group_read, n.group_write, n.creator_id, n.async_trans, n.fs_path,\n" + "n.content_type, n.content_encoding, n.content_length, n.content_md5,\n" - + "n.accept_views, n.provide_views, l.location_type, n.path <> n.relative_path AS virtual_parent,\n" + + "n.accept_views, n.provide_views, l.location_type,\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_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 = 'link' AS is_link, n.target, l.location_type\n" + "FROM node n\n" @@ -281,8 +281,7 @@ public class FileDAO { fi.setOwnerId(rs.getString("creator_id")); fi.setAsyncTrans(rs.getBoolean("async_trans")); fi.setAcceptViews(toList(rs.getArray("accept_views"))); - fi.setProvideViews(toList(rs.getArray("provide_views"))); - fi.setVirtualParent(rs.getBoolean("virtual_parent")); + fi.setProvideViews(toList(rs.getArray("provide_views"))); fi.setVirtualPath(rs.getString("vos_path")); fi.setVirtualName(rs.getString("name")); fi.setContentEncoding(rs.getString("content_encoding")); @@ -345,32 +344,5 @@ public class FileDAO { Path completeFsPath = Path.of(fsPath); fi.setFsPath(completeFsPath.toString()); - } - - private void fillOsPath(FileInfo fi, ResultSet rs) throws SQLException { - - String basePath = rs.getString("base_path"); - if (basePath == null) { - return; - } - - String osPath = rs.getString("os_path"); - if (osPath.startsWith("/")) { - osPath = osPath.substring(1); - } - - Path completeOsPath = Path.of(basePath); - - boolean asyncLocation = "async".equals(rs.getString("location_type")); - - if (asyncLocation) { - String username = rs.getString("username"); - completeOsPath = completeOsPath.resolve(username).resolve("retrieve"); - } else if (fi.hasVirtualParent()) { - completeOsPath = completeOsPath.resolve(fi.getOwnerId()); - } - - completeOsPath = completeOsPath.resolve(osPath); - fi.setOsPath(completeOsPath.toString()); - } + } } diff --git a/src/main/java/it/inaf/ia2/transfer/persistence/model/FileInfo.java b/src/main/java/it/inaf/ia2/transfer/persistence/model/FileInfo.java index 4081d073f024a9e20207badca56991505facd719..f74d2cecab1a43bf4be21293a40d697b00273bf9 100644 --- a/src/main/java/it/inaf/ia2/transfer/persistence/model/FileInfo.java +++ b/src/main/java/it/inaf/ia2/transfer/persistence/model/FileInfo.java @@ -10,16 +10,14 @@ import java.util.List; public class FileInfo { - private int nodeId; - private String osPath; + private int nodeId; private String virtualPath; private String virtualName; private String fsPath; // actualBasePath differs from base path in db due to some location type // dependent manipulations (performed by FileDAO) private String actualBasePath; - private boolean isPublic; - private boolean virtualParent; + private boolean isPublic; private boolean directory; private boolean link; private String target; @@ -85,14 +83,6 @@ public class FileInfo { this.nodeId = nodeId; } - public String getOsPath() { - return osPath; - } - - public void setOsPath(String osPath) { - this.osPath = osPath; - } - public String getVirtualPath() { return virtualPath; } @@ -133,14 +123,6 @@ public class FileInfo { this.link = link; } - public boolean hasVirtualParent() { - return virtualParent; - } - - public void setVirtualParent(boolean virtualParent) { - this.virtualParent = virtualParent; - } - public List<String> getGroupRead() { return groupRead; } diff --git a/src/main/java/it/inaf/ia2/transfer/service/PutFileService.java b/src/main/java/it/inaf/ia2/transfer/service/PutFileService.java index f7462f91f99e7e740f6bbde90ad4aa2532f057c6..7f6e86aa2d9bfdf67c7cb9d3def45f9d8b888880 100644 --- a/src/main/java/it/inaf/ia2/transfer/service/PutFileService.java +++ b/src/main/java/it/inaf/ia2/transfer/service/PutFileService.java @@ -97,12 +97,12 @@ public class PutFileService { // the first upload (fsPath not null) if(destinationFileInfo.getActualBasePath() != null) { if(destinationFileInfo.getFsPath() != null) { - LOG.error("Node {} fsPath is not null: {}. Overwriting.", + LOG.error("Node {} fsPath is not null: {}. Overwriting forbidden.", destinationFileInfo.getVirtualPath(), destinationFileInfo.getFsPath()); throw new InvalidArgumentException("Node " + destinationFileInfo.getVirtualPath() + - " is already populated. Overwriting not allowed."); + " is already populated. Overwriting forbidden."); } destinationFileInfo.setFsPath(this.generateFsPath().toString());