diff --git a/lib/galaxy/webapps/galaxy/api/datasets.py b/lib/galaxy/webapps/galaxy/api/datasets.py index 6473150b1f0..05e3414b1d3 100644 --- a/lib/galaxy/webapps/galaxy/api/datasets.py +++ b/lib/galaxy/webapps/galaxy/api/datasets.py @@ -4,12 +4,12 @@ API operations on the contents of a dataset. import logging, os, string, shutil, urllib, re, socket from galaxy import util, datatypes, jobs, web, util from galaxy.visualization.data_providers.genome import FeatureLocationIndexDataProvider -from galaxy.web.base.controller import BaseAPIController, UsesVisualizationMixin +from galaxy.web.base.controller import BaseAPIController, UsesVisualizationMixin, UsesHistoryDatasetAssociationMixin, UsesHistoryMixin from galaxy.web.framework.helpers import is_true log = logging.getLogger( __name__ ) -class DatasetsController( BaseAPIController, UsesVisualizationMixin ): +class DatasetsController( BaseAPIController, UsesVisualizationMixin, UsesHistoryMixin, UsesHistoryDatasetAssociationMixin ): @web.expose_api def index( self, trans, **kwd ): @@ -191,3 +191,31 @@ class DatasetsController( BaseAPIController, UsesVisualizationMixin ): data = data_provider.get_data( **kwargs ) return data + + @web.expose_api_raw + def display( self, trans, history_content_id, history_id, preview=False, filename=None, to_ext=None, chunk=None, **kwd ): + """ + GET /api/histories/{encoded_history_id}/contents/{encoded_content_id}/display + Displays history content (dataset). + """ + # Huge amount of code overlap with lib/galaxy/webapps/galaxy/api/history_content:show here. + hda_dict = {} + try: + # for anon users: + #TODO: check login_required? + #TODO: this isn't actually most_recently_used (as defined in histories) + if( ( trans.user == None ) + and ( history_id == trans.security.encode_id( trans.history.id ) ) ): + history = trans.history + #TODO: dataset/hda by id (from history) OR check_ownership for anon user + hda = self.get_history_dataset_association( trans, history, history_content_id, + check_ownership=False, check_accessible=True ) + + else: + history = self.get_history( trans, history_id, + check_ownership=True, check_accessible=True, deleted=False ) + hda = self.get_history_dataset_association( trans, history, history_content_id, + check_ownership=True, check_accessible=True ) + except: + raise + return hda.datatype.display_data(trans, hda, preview, filename, to_ext, chunk, **kwd) diff --git a/lib/galaxy/webapps/galaxy/api/history_contents.py b/lib/galaxy/webapps/galaxy/api/history_contents.py index 74e236c3269..6c6bf81b0d8 100644 --- a/lib/galaxy/webapps/galaxy/api/history_contents.py +++ b/lib/galaxy/webapps/galaxy/api/history_contents.py @@ -125,33 +125,6 @@ class HistoryContentsController( BaseAPIController, UsesHistoryDatasetAssociatio 'error' : str( exception ) } - @web.expose_api_raw - def display( self, trans, history_content_id, history_id, preview=False, filename=None, to_ext=None, chunk=None, **kwd ): - """ - GET /api/histories/{encoded_history_id}/contents/{encoded_content_id}/display - Displays history content (dataset). - """ - hda_dict = {} - try: - # for anon users: - #TODO: check login_required? - #TODO: this isn't actually most_recently_used (as defined in histories) - if( ( trans.user == None ) - and ( history_id == trans.security.encode_id( trans.history.id ) ) ): - history = trans.history - #TODO: dataset/hda by id (from history) OR check_ownership for anon user - hda = self.get_history_dataset_association( trans, history, history_content_id, - check_ownership=False, check_accessible=True ) - - else: - history = self.get_history( trans, history_id, - check_ownership=True, check_accessible=True, deleted=False ) - hda = self.get_history_dataset_association( trans, history, history_content_id, - check_ownership=True, check_accessible=True ) - except: - raise - return hda.datatype.display_data(trans, hda, preview, filename, to_ext, chunk, **kwd) - @web.expose_api def show( self, trans, id, history_id, **kwd ): """ diff --git a/lib/galaxy/webapps/galaxy/buildapp.py b/lib/galaxy/webapps/galaxy/buildapp.py index 4a3b056ca10..71cf1b793ff 100644 --- a/lib/galaxy/webapps/galaxy/buildapp.py +++ b/lib/galaxy/webapps/galaxy/buildapp.py @@ -85,7 +85,7 @@ def app_factory( global_conf, **kwargs ): parent_resources=dict( member_name='history', collection_name='histories' ) ) webapp.api_mapper.connect("history_contents_display", "/api/histories/:history_id/contents/:history_content_id/display", - controller="history_contents", + controller="datasets", action="display", conditions=dict(method=["GET"])) webapp.api_mapper.resource( 'permission',