Skip to content

Commit

Permalink
feat(FC): Add function to get user metadata for list of lfns
Browse files Browse the repository at this point in the history
  • Loading branch information
ILCDIRAC authored and andresailer committed Jul 31, 2024
1 parent 71def4b commit d9d8e11
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/DIRAC/DataManagementSystem/DB/FileCatalogDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -769,6 +769,23 @@ def getFileDescendents(self, lfns, depths, credDict):
successful = res["Value"]["Successful"]
return S_OK({"Successful": successful, "Failed": failed})

def getFileDetailsPublic(self, lfns, credDict):
"""Return all the metadata, including user defined, for those lfns that exist.
:return: S_OK with a dictionary of LFNs to detailed information
"""

res = self._checkPathPermissions("getFileMetadata", lfns, credDict)
if not res["OK"]:
return res
failed = res["Value"]["Failed"]

# if no successful, just return empty dict
if not res["Value"]["Successful"]:
return S_OK({})

return self.getFileDetails(res["Value"]["Successful"], credDict)

def getFileDetails(self, lfnList, credDict):
"""Get all the metadata for the given files"""
connection = False
Expand Down
6 changes: 6 additions & 0 deletions src/DIRAC/DataManagementSystem/Service/FileCatalogHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,12 @@ def export_getFileMetadata(self, lfns):
"""Get the metadata associated to supplied lfns"""
return self.fileCatalogDB.getFileMetadata(lfns, self.getRemoteCredentials())

types_getFileDetails = [[list, dict, str]]

def export_getFileDetails(self, lfns):
"""Get all the metadata associated to supplied lfns, including user metadata"""
return self.fileCatalogDB.getFileDetailsPublic(lfns, self.getRemoteCredentials())

types_getReplicas = [[list, dict, str], bool]

def export_getReplicas(self, lfns, allStatus=False):
Expand Down

0 comments on commit d9d8e11

Please sign in to comment.