Commit 209bdccf authored by Sonia Zorba's avatar Sonia Zorba
Browse files

Added location type to FileInfo and fixed issue with generation of archives containing async nodes

parent e6b31480
Loading
Loading
Loading
Loading
Loading
+15 −14
Original line number Original line Diff line number Diff line
@@ -175,8 +175,8 @@ public class FileDAO {
                + "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.path <> n.relative_path AS virtual_parent,\n"
                + "(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\n"
                + "n.type = 'link' AS is_link, 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"
@@ -209,7 +209,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\n"
                + "n.type = 'link' AS is_link, 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"
@@ -294,6 +294,7 @@ public class FileDAO {
        int locationId = rs.getInt("location_id");
        int locationId = rs.getInt("location_id");
        if (!rs.wasNull()) {
        if (!rs.wasNull()) {
            fi.setLocationId(locationId);
            fi.setLocationId(locationId);
            fi.setLocationType(rs.getString("location_type"));
        }
        }


        fillOsPath(fi, rs);
        fillOsPath(fi, rs);
+12 −3
Original line number Original line Diff line number Diff line
@@ -28,6 +28,7 @@ public class FileInfo {
    private Long contentLength;
    private Long contentLength;
    private String contentMd5;
    private String contentMd5;
    private Integer locationId;
    private Integer locationId;
    private String locationType;
    private String jobId;
    private String jobId;


    public int getNodeId() {
    public int getNodeId() {
@@ -182,6 +183,14 @@ public class FileInfo {
        this.locationId = locationId;
        this.locationId = locationId;
    }
    }


    public String getLocationType() {
        return locationType;
    }

    public void setLocationType(String locationType) {
        this.locationType = locationType;
    }

    public String getJobId() {
    public String getJobId() {
        return jobId;
        return jobId;
    }
    }
+1 −1
Original line number Original line Diff line number Diff line
@@ -112,7 +112,7 @@ public class ArchiveService {
                        continue;
                        continue;
                    }
                    }


                    if (fileInfo.getLocationId() != null && fileInfo.getLocationId() != uploadLocationId) {
                    if (fileInfo.getLocationId() != null && "portal".equals(fileInfo.getLocationType())) {
                        // remote file
                        // remote file
                        if (portalLocationUrls == null) {
                        if (portalLocationUrls == null) {
                            portalLocationUrls = locationDAO.getPortalLocationUrls();
                            portalLocationUrls = locationDAO.getPortalLocationUrls();
+18 −18
Original line number Original line Diff line number Diff line
@@ -134,7 +134,7 @@ public class FileCopyService {
                    }
                    }
                }
                }


                if (sourceFileInfo.getLocationId() != null && sourceFileInfo.getLocationId() != uploadLocationId) {
                if (sourceFileInfo.getLocationId() != null && "portal".equals(sourceFileInfo.getLocationType())) {
                    // remote file
                    // remote file
                    if (portalLocationUrls == null) {
                    if (portalLocationUrls == null) {
                        portalLocationUrls = locationDAO.getPortalLocationUrls();
                        portalLocationUrls = locationDAO.getPortalLocationUrls();
+4 −0
Original line number Original line Diff line number Diff line
@@ -88,10 +88,14 @@ public class FileDAOTest {


        assertEquals("/home/vospace/upload/user1/file1", fileInfos.get(0).getOsPath());
        assertEquals("/home/vospace/upload/user1/file1", fileInfos.get(0).getOsPath());
        assertEquals("/home/vospace/upload/user1/file2", fileInfos.get(1).getOsPath());
        assertEquals("/home/vospace/upload/user1/file2", fileInfos.get(1).getOsPath());
        assertEquals("user", fileInfos.get(1).getLocationType());
        assertTrue(fileInfos.get(2).isDirectory());
        assertTrue(fileInfos.get(2).isDirectory());
        assertNull(fileInfos.get(2).getLocationType());
        assertEquals("/home/username1/retrieve/subdir1/file3", fileInfos.get(3).getOsPath());
        assertEquals("/home/username1/retrieve/subdir1/file3", fileInfos.get(3).getOsPath());
        assertEquals("/home/username1/retrieve/subdir1/file4", fileInfos.get(4).getOsPath());
        assertEquals("/home/username1/retrieve/subdir1/file4", fileInfos.get(4).getOsPath());
        assertEquals("async", fileInfos.get(4).getLocationType());
        assertEquals("portal-file", fileInfos.get(5).getVirtualName());
        assertEquals("portal-file", fileInfos.get(5).getVirtualName());
        assertEquals("portal", fileInfos.get(5).getLocationType());
    }
    }


    @Test
    @Test