Browse Source

HTTP 500 trying to mkdir as "admin" user which is not "hdfs" user

Add a note in the error message when the user is a Hue admin but
not a HDFS root.
Remove the notice from chown in order to be consistent with all
the other actions.
Romain Rigaux 13 years ago
parent
commit
de0a128a7e

+ 1 - 5
apps/filebrowser/src/filebrowser/templates/chown.mako

@@ -54,6 +54,7 @@
       % endif
       % endif
     % endif
     % endif
 </%def>
 </%def>
+
 <form action="/filebrowser/chown?next=${next|u}" method="POST" enctype="multipart/form-data" class="form-stacked form-padding-fix">
 <form action="/filebrowser/chown?next=${next|u}" method="POST" enctype="multipart/form-data" class="form-stacked form-padding-fix">
     <div class="modal-header">
     <div class="modal-header">
         <a href="#" class="close">&times;</a>
         <a href="#" class="close">&times;</a>
@@ -80,14 +81,9 @@
             ${ selection("group", [group for group in form.all_groups if group in extra_params['current_user'].get_groups()], extract_field_data(form["group"])) }
             ${ selection("group", [group for group in form.all_groups if group in extra_params['current_user'].get_groups()], extract_field_data(form["group"])) }
             % endif
             % endif
         </div>
         </div>
-
-
     </div>
     </div>
     <div class="modal-footer" style="padding-top: 10px;">
     <div class="modal-footer" style="padding-top: 10px;">
         <input class="btn primary" type="submit" value="Submit" />
         <input class="btn primary" type="submit" value="Submit" />
         <a class="btn" onclick="$('#changeOwnerModal').modal('hide');">Cancel</a>
         <a class="btn" onclick="$('#changeOwnerModal').modal('hide');">Cancel</a>
     </div>
     </div>
 </form>
 </form>
-
-
-<!--<div class="alert-message info modal-footer">Note: Only the Hadoop superuser, on this FS "${extra_params['superuser']}", may change the owner of a file.</div>-->

+ 10 - 3
apps/filebrowser/src/filebrowser/views.py

@@ -117,7 +117,10 @@ def view(request, path):
         else:
         else:
             return display(request, path)
             return display(request, path)
     except (IOError, WebHdfsException), e:
     except (IOError, WebHdfsException), e:
-        raise PopupException("Cannot access: %s" % escape(path), detail=e)
+        msg = "Cannot access: %s." % escape(path)
+        if request.user.is_superuser and not request.user == request.fs.superuser:
+            msg += ' Note: you are a Hue admin but not a HDFS superuser (which is "%s").' % (request.fs.superuser,)
+        raise PopupException(msg , detail=e)
 
 
 
 
 def edit(request, path, form=None):
 def edit(request, path, form=None):
@@ -654,9 +657,13 @@ def generic_op(form_class, request, op, parameter_names, piggyback=None, templat
         if form.is_valid():
         if form.is_valid():
             args = [form.cleaned_data[p] for p in parameter_names]
             args = [form.cleaned_data[p] for p in parameter_names]
             try:
             try:
-              op(*args)
+                op(*args)
             except (IOError, WebHdfsException), e:
             except (IOError, WebHdfsException), e:
-              raise PopupException("Cannot perform operation.", detail=e)
+                msg = "Cannot perform operation."
+                if request.user.is_superuser and not request.user == request.fs.superuser:
+                    msg += ' Note: you are a Hue admin but not a HDFS superuser (which is "%s").' \
+                           % (request.fs.superuser,)
+                raise PopupException(msg, detail=e)
             if next:
             if next:
                 logging.debug("Next: %s" % next)
                 logging.debug("Next: %s" % next)
                 # Doesn't need to be quoted: quoting is done by HttpResponseRedirect.
                 # Doesn't need to be quoted: quoting is done by HttpResponseRedirect.