From 8f07c9eadb79857fdea3a9239142e8eb818a8127 Mon Sep 17 00:00:00 2001
From: Sinisa Veseli <sveseli@aps.anl.gov>
Date: Thu, 8 Oct 2015 07:07:50 +0000
Subject: [PATCH] added stat file interface

---
 .../service/fileSessionController.py             | 16 ++++++++++++++++
 .../service/impl/fileSessionControllerImpl.py    |  7 +++++++
 2 files changed, 23 insertions(+)

diff --git a/src/python/dm/ds_web_service/service/fileSessionController.py b/src/python/dm/ds_web_service/service/fileSessionController.py
index 8dcbfb2f..b28d8987 100755
--- a/src/python/dm/ds_web_service/service/fileSessionController.py
+++ b/src/python/dm/ds_web_service/service/fileSessionController.py
@@ -33,3 +33,19 @@ class FileSessionController(DmSessionController):
         self.logger.debug('Returning: %s' % response)
         return response
 
+    @cherrypy.expose
+    @DmSessionController.require(DmSessionController.isAdministrator())
+    @DmSessionController.execute
+    def statFile(self, **kwargs):
+        encodedFileInfo = kwargs.get('fileInfo')
+        if not encodedFileInfo:
+            raise InvalidRequest('Invalid file info provided.')
+        fileInfo = json.loads(Encoder.decode(encodedFileInfo))
+
+        if not fileInfo.has_key('experimentFilePath'):
+            raise InvalidRequest('Experiment file path is missing.')
+        if not fileInfo.has_key('experimentName'):
+            raise InvalidRequest('Experiment name is missing.')
+        response = self.fileSessionControllerImpl.statFile(fileInfo).getFullJsonRep()
+        self.logger.debug('Returning: %s' % response)
+        return response
diff --git a/src/python/dm/ds_web_service/service/impl/fileSessionControllerImpl.py b/src/python/dm/ds_web_service/service/impl/fileSessionControllerImpl.py
index 8c50368c..f527e6e1 100755
--- a/src/python/dm/ds_web_service/service/impl/fileSessionControllerImpl.py
+++ b/src/python/dm/ds_web_service/service/impl/fileSessionControllerImpl.py
@@ -25,3 +25,10 @@ class FileSessionControllerImpl(DmObjectManager):
         experiment = self.experimentDbApi.getExperimentByName(experimentName)
         ExperimentManager.getInstance().processExperimentFile(experimentFilePath, experiment, fileInfo)
         return FileMetadata(fileInfo)
+
+    def statFile(self, fileInfo):
+        experimentFilePath = fileInfo.get('experimentFilePath')
+        experimentName = fileInfo.get('experimentName')
+        experiment = self.experimentDbApi.getExperimentByName(experimentName)
+        ExperimentManager.getInstance().statExperimentFile(experimentFilePath, experiment, fileInfo)
+        return FileMetadata(fileInfo)
-- 
GitLab