Browse Source

HUE-4506 [editor] Provide more information why query couldn't be saved

Romain Rigaux 9 years ago
parent
commit
c215733

+ 4 - 4
desktop/core/src/desktop/models.py

@@ -1121,7 +1121,7 @@ class Document2(models.Model):
         url = '/jobsub/#edit-design/%s' % self.data_dict.get('object_id', '')
         url = '/jobsub/#edit-design/%s' % self.data_dict.get('object_id', '')
       else:
       else:
         url = reverse('oozie:edit_workflow') + '?workflow=' + str(self.id)
         url = reverse('oozie:edit_workflow') + '?workflow=' + str(self.id)
-    except NoReverseMatch, e:
+    except NoReverseMatch:
       LOG.warn('Could not perform reverse lookup for type %s, app may be blacklisted.' % self.type)
       LOG.warn('Could not perform reverse lookup for type %s, app may be blacklisted.' % self.type)
     return url
     return url
 
 
@@ -1178,9 +1178,9 @@ class Document2(models.Model):
 
 
   def validate(self):
   def validate(self):
     # Validate document name
     # Validate document name
-    invalid_chars = re.compile(r"[<>/{}[\]~`]");
-    if invalid_chars.search(self.name):
-      raise FilesystemException(_('Document %s contains an invalid character.') % self.name)
+    invalid_chars = re.findall(re.compile(r"[<>/{}[\]~`]"), self.name)
+    if invalid_chars:
+      raise FilesystemException(_('Document %s contains some special characters: %s') % (self.name, invalid_chars))
 
 
     # Validate home and Trash directories are only created once per user and cannot be created or modified after
     # Validate home and Trash directories are only created once per user and cannot be created or modified after
     if self.name in [Document2.HOME_DIR, Document2.TRASH_DIR] and self.type == 'directory' and \
     if self.name in [Document2.HOME_DIR, Document2.TRASH_DIR] and self.type == 'directory' and \

+ 1 - 0
desktop/libs/notebook/src/notebook/api.py

@@ -329,6 +329,7 @@ def _save_notebook(notebook, user):
 
 
   return notebook_doc, save_as
   return notebook_doc, save_as
 
 
+@api_error_handler
 @require_POST
 @require_POST
 @check_document_modify_permission()
 @check_document_modify_permission()
 def save_notebook(request):
 def save_notebook(request):

+ 4 - 1
desktop/libs/notebook/src/notebook/decorators.py

@@ -26,7 +26,7 @@ from django.utils.translation import ugettext as _
 from desktop.lib.django_util import JsonResponse
 from desktop.lib.django_util import JsonResponse
 from desktop.lib.exceptions_renderable import PopupException
 from desktop.lib.exceptions_renderable import PopupException
 from desktop.lib.i18n import smart_unicode
 from desktop.lib.i18n import smart_unicode
-from desktop.models import Document2, Document
+from desktop.models import Document2, Document, FilesystemException
 
 
 from notebook.connectors.base import QueryExpired, QueryError, SessionExpired, AuthenticationRequired, OperationTimeout
 from notebook.connectors.base import QueryExpired, QueryError, SessionExpired, AuthenticationRequired, OperationTimeout
 
 
@@ -91,6 +91,9 @@ def api_error_handler(func):
       response['message'] = e.message
       response['message'] = e.message
     except OperationTimeout, e:
     except OperationTimeout, e:
       response['status'] = -4
       response['status'] = -4
+    except FilesystemException, e:
+      response['status'] = 2
+      response['message'] = e.message
     except QueryError, e:
     except QueryError, e:
       LOG.exception('Error running %s' % func)
       LOG.exception('Error running %s' % func)
       response['status'] = 1
       response['status'] = 1