Commit 71efae42 authored by Cristiano Urban's avatar Cristiano Urban
Browse files

Added 'getCreatorId()' method for VOSpace nodes.

parent 7ddb87ae
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -67,6 +67,25 @@ class DbConnector(object):
        else:
            return False

    def getCreatorId(self, vospacePath):
        """Returns the creator ID for a given vospace path representing a node."""
        with self.getConnection() as conn:
            try:
                cursor = conn.cursor(cursor_factory = RealDictCursor)
                cursor.execute("""
                    SELECT creator_id
                    FROM node_vos_path nvp
                    JOIN node n ON nvp.node_id = n.node_id
                    WHERE vos_path = %s;
                    """, 
                    (vospacePath,))
                result = cursor.fetchall()
            except Exception as e:
                if not conn.closed:
                    conn.rollback()
                print(e)
        return result[0]["creator_id"]

    def getOSPath(self, vospacePath):
        """Returns a list containing full path, storage type and username for a VOSpace path."""
        with self.getConnection() as conn: