1. Matthew Shirley
  2. galaxy-central

Commits

Carl Eberhard  committed 72cf2a3

API histories, delete: ensure HTTPExceptions are raised, better return values; API workflows delete: add code 400 to not found clause, change to code 403 for not accessible clause

  • Participants
  • Parent commits 3a27539
  • Branches default

Comments (0)

Files changed (2)

File lib/galaxy/webapps/galaxy/api/histories.py

View file
 
 import pkg_resources
 pkg_resources.require( "Paste" )
-from paste.httpexceptions import HTTPBadRequest, HTTPForbidden
+from paste.httpexceptions import HTTPBadRequest, HTTPForbidden, HTTPInternalServerError, HTTPException
 
 from galaxy import web
 from galaxy.util import string_as_bool, restore_text
         if kwd.get( 'payload', None ):
             purge = string_as_bool( kwd['payload'].get( 'purge', False ) )
 
+        rval = { 'id' : history_id }
         try:
             history = self.get_history( trans, history_id, check_ownership=True, check_accessible=False )
             history.deleted = True
                 # Now mark the history as purged
                 history.purged = True
                 self.sa_session.add( history )
+                rval[ 'purged' ] = True
 
             trans.sa_session.flush()
+            rval[ 'deleted' ] = True
 
-        #TODO: better feedback than this...
-        except Exception, e:
-            return str( e )
+        except HTTPInternalServerError, http_server_err:
+            log.exception( 'Histories API, delete: uncaught HTTPInternalServerError: %s, %s\n%s',
+                           history_id, str( kwd ), str( http_server_err ) )
+            raise
+        except HTTPException, http_exc:
+            raise
+        except Exception, exc:
+            log.exception( 'Histories API, delete: uncaught exception: %s, %s\n%s',
+                           history_id, str( kwd ), str( exc ) )
+            trans.response.status = 500
+            rval.update({ 'error': str( exc ) })
 
-        return 'OK'
+        return rval
 
     @web.expose_api
     def undelete( self, trans, id, **kwd ):

File lib/galaxy/webapps/galaxy/api/workflows.py

View file
 
         try:
             stored_workflow = trans.sa_session.query(self.app.model.StoredWorkflow).get(trans.security.decode_id(workflow_id))
-        except Exception,e:
+        except Exception, e:
+            trans.response.status = 400
             return ("Workflow with ID='%s' can not be found\n Exception: %s") % (workflow_id, str( e ))
 
         # check to see if user has permissions to selected workflow
         if stored_workflow.user != trans.user and not trans.user_is_admin():
             if trans.sa_session.query(trans.app.model.StoredWorkflowUserShareAssociation).filter_by(user=trans.user, stored_workflow=stored_workflow).count() == 0:
-                trans.response.status = 400
+                trans.response.status = 403
                 return("Workflow is not owned by or shared with current user")
 
         #Mark a workflow as deleted