diff --git a/src/python/dm/ds_web_service/service/dsWebService.py b/src/python/dm/ds_web_service/service/dsWebService.py index acf8654bd43bca9b5fca6e3a7a0e4e14796f5bbb..6081e77990ee9c8f59bbdcfc0e6addc74ce0b97e 100755 --- a/src/python/dm/ds_web_service/service/dsWebService.py +++ b/src/python/dm/ds_web_service/service/dsWebService.py @@ -9,7 +9,8 @@ from dm.common.service.dmRestWebServiceBase import DmRestWebServiceBase from dm.common.utility.dmModuleManager import DmModuleManager from dm.common.utility.configurationManager import ConfigurationManager -from dm.ds_web_service.service.impl.storageManager import StorageManager +from dm.common.processing.fileProcessingManager import FileProcessingManager +from dm.ds_web_service.service.impl.experimentManager import ExperimentManager from dsWebServiceRouteMapper import DsWebServiceRouteMapper #################################################################### @@ -24,7 +25,8 @@ class DsWebService(DmRestWebServiceBase): # Add modules that will be started. moduleManager = DmModuleManager.getInstance() - moduleManager.addModule(StorageManager.getInstance()) + moduleManager.addModule(ExperimentManager.getInstance()) + moduleManager.addModule(FileProcessingManager.getInstance()) self.logger.debug('Initialized dm modules') def getDefaultServerHost(self): diff --git a/src/python/dm/ds_web_service/service/dsWebServiceRouteMapper.py b/src/python/dm/ds_web_service/service/dsWebServiceRouteMapper.py index ba377b8b6136d58b0dc8c8d99afceb50952a00cf..4f94d36d625b52d7619939f2e1342bd705d69474 100755 --- a/src/python/dm/ds_web_service/service/dsWebServiceRouteMapper.py +++ b/src/python/dm/ds_web_service/service/dsWebServiceRouteMapper.py @@ -13,6 +13,7 @@ from dm.common.utility.configurationManager import ConfigurationManager from dm.common.service.loginRouteDescriptor import LoginRouteDescriptor from userRouteDescriptor import UserRouteDescriptor from experimentRouteDescriptor import ExperimentRouteDescriptor +from fileRouteDescriptor import FileRouteDescriptor from authRouteDescriptor import AuthRouteDescriptor class DsWebServiceRouteMapper: @@ -29,6 +30,7 @@ class DsWebServiceRouteMapper: routes += AuthRouteDescriptor.getRoutes() routes += UserRouteDescriptor.getRoutes() routes += ExperimentRouteDescriptor.getRoutes() + routes += FileRouteDescriptor.getRoutes() # Add routes to dispatcher. d = cherrypy.dispatch.RoutesDispatcher() diff --git a/src/python/dm/ds_web_service/service/experimentRouteDescriptor.py b/src/python/dm/ds_web_service/service/experimentRouteDescriptor.py index 736795fb3a0d01844c0ee3118e0e9d8e64f2bcd2..18a27d81e52618f7e4baeec654d72baed0f47110 100755 --- a/src/python/dm/ds_web_service/service/experimentRouteDescriptor.py +++ b/src/python/dm/ds_web_service/service/experimentRouteDescriptor.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -# User route descriptor. +# Experiment route descriptor. # from dm.common.utility.configurationManager import ConfigurationManager diff --git a/src/python/dm/ds_web_service/service/fileRouteDescriptor.py b/src/python/dm/ds_web_service/service/fileRouteDescriptor.py new file mode 100755 index 0000000000000000000000000000000000000000..375298c5017b1625102736898b7e051d8b668262 --- /dev/null +++ b/src/python/dm/ds_web_service/service/fileRouteDescriptor.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python + +# +# File route descriptor. +# + +from dm.common.utility.configurationManager import ConfigurationManager +from fileSessionController import FileSessionController + +class FileRouteDescriptor: + + @classmethod + def getRoutes(cls): + contextRoot = ConfigurationManager.getInstance().getContextRoot() + + # Static instances shared between different routes + fileSessionController = FileSessionController() + + # Define routes. + routes = [ + + # Process file + { + 'name' : 'processFile', + 'path' : '%s/files/processFile' % contextRoot, + 'controller' : fileSessionController, + 'action' : 'processFile', + 'method' : ['POST'] + }, + + ] + + return routes + + diff --git a/src/python/dm/ds_web_service/service/fileSessionController.py b/src/python/dm/ds_web_service/service/fileSessionController.py new file mode 100755 index 0000000000000000000000000000000000000000..5652a39fc33b2fdc6a8c369788cfd1bdb0b99fd7 --- /dev/null +++ b/src/python/dm/ds_web_service/service/fileSessionController.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python + +import cherrypy + +from dm.common.service.dmSessionController import DmSessionController +from dm.common.exceptions.invalidRequest import InvalidRequest +from dm.common.utility.encoder import Encoder + +from dm.ds_web_service.service.impl.fileSessionControllerImpl import FileSessionControllerImpl + + +class FileSessionController(DmSessionController): + + def __init__(self): + DmSessionController.__init__(self) + self.fileSessionControllerImpl = FileSessionControllerImpl() + + @cherrypy.expose + @DmSessionController.require(DmSessionController.isAdministrator()) + @DmSessionController.execute + def processFile(self, **kwargs): + fileName = kwargs.get('fileName') + if not fileName: + raise InvalidRequest('Missing file name.') + fileName = Encoder.decode(fileName) + filePath = kwargs.get('filePath') + if not filePath: + raise InvalidRequest('Missing file path.') + filePath = Encoder.decode(filePath) + experimentName = kwargs.get('experimentName') + if not experimentName: + raise InvalidRequest('Missing experiment name.') + experimentName = Encoder.decode(experimentName) + + response = self.fileSessionControllerImpl.processFile(fileName, filePath, experimentName).getFullJsonRep() + self.logger.debug('Returning: %s' % response) + return response +