Repository: incubator-atlas
Updated Branches:
  refs/heads/master 606690c49 -> 94a8db33a


ATLAS-853 User's name to be mentioned in the top user drop down (saqeeb.s via 
shwethags)


Project: http://git-wip-us.apache.org/repos/asf/incubator-atlas/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-atlas/commit/6eaeaaa3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-atlas/tree/6eaeaaa3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-atlas/diff/6eaeaaa3

Branch: refs/heads/master
Commit: 6eaeaaa334ede5f52410e60ae0248494ec34d314
Parents: 606690c
Author: Shwetha GS <[email protected]>
Authored: Thu Jun 9 14:40:06 2016 +0530
Committer: Shwetha GS <[email protected]>
Committed: Thu Jun 9 14:40:06 2016 +0530

----------------------------------------------------------------------
 .../simple/AtlasAuthorizationUtils.java         |  2 +
 .../business_catalog/BusinessCatalogHeader.html |  3 +-
 .../public/js/templates/site/header.html        |  6 ++-
 .../public/js/utils/CommonViewFunction.js       | 12 +++++
 dashboardv2/public/js/utils/Globals.js          |  4 ++
 .../business_catalog/BusinessCatalogHeader.js   | 19 +++++++-
 dashboardv2/public/js/views/site/Header.js      | 20 +++++++-
 release-log.txt                                 |  1 +
 .../web/filters/AtlasAuthorizationFilter.java   |  2 +-
 .../atlas/web/resources/AdminResource.java      | 50 ++++++++++++++++----
 10 files changed, 102 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/6eaeaaa3/authorization/src/main/java/org/apache/atlas/authorize/simple/AtlasAuthorizationUtils.java
----------------------------------------------------------------------
diff --git 
a/authorization/src/main/java/org/apache/atlas/authorize/simple/AtlasAuthorizationUtils.java
 
b/authorization/src/main/java/org/apache/atlas/authorize/simple/AtlasAuthorizationUtils.java
index 48b536f..291f11b 100644
--- 
a/authorization/src/main/java/org/apache/atlas/authorize/simple/AtlasAuthorizationUtils.java
+++ 
b/authorization/src/main/java/org/apache/atlas/authorize/simple/AtlasAuthorizationUtils.java
@@ -103,6 +103,8 @@ public class AtlasAuthorizationUtils {
         String api = getApi(contextPath);
         if (api.startsWith("types")) {
             resourceTypes.add(AtlasResourceTypes.TYPE);
+        } else if (api.startsWith("admin") && 
contextPath.contains("/session")) {
+            resourceTypes.add(AtlasResourceTypes.UNKNOWN);
         } else if ((api.startsWith("discovery") && 
contextPath.contains("/gremlin")) || api.startsWith("admin")
             || api.startsWith("graph")) {
             resourceTypes.add(AtlasResourceTypes.OPERATION);

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/6eaeaaa3/dashboardv2/public/js/templates/business_catalog/BusinessCatalogHeader.html
----------------------------------------------------------------------
diff --git 
a/dashboardv2/public/js/templates/business_catalog/BusinessCatalogHeader.html 
b/dashboardv2/public/js/templates/business_catalog/BusinessCatalogHeader.html
index 006fe0b..9798b2c 100644
--- 
a/dashboardv2/public/js/templates/business_catalog/BusinessCatalogHeader.html
+++ 
b/dashboardv2/public/js/templates/business_catalog/BusinessCatalogHeader.html
@@ -14,12 +14,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
 -->
-
 <ol class="breadcrumb col-md-6">
 </ol>
 <header class="clearfix">
     <div class="btn-group pull-right">
-        <a href="javascript:void(0);" data-toggle="dropdown" 
aria-haspopup="true" aria-expanded="false" class="user-dropdown"><i class="fa 
fa-user user-circle"></i></a>
+        <a href="javascript:void(0);" data-toggle="dropdown" 
aria-haspopup="true" aria-expanded="false" class="user-dropdown"><span 
class="userName"></span><i class="fa fa-user user-circle"></i></a>
         <ul class="dropdown-menu">
             <!--    <li><a href="#">Edit Profile</a></li>
             <li><a href="#">Change Password</a></li> -->

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/6eaeaaa3/dashboardv2/public/js/templates/site/header.html
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/templates/site/header.html 
b/dashboardv2/public/js/templates/site/header.html
index 8c22e5a..9f8a1ea 100644
--- a/dashboardv2/public/js/templates/site/header.html
+++ b/dashboardv2/public/js/templates/site/header.html
@@ -16,14 +16,16 @@
 -->
 <header class="clearfix">
     <div class="btn-group pull-right">
-        <a href="javascript:void(0);" data-toggle="dropdown" 
aria-haspopup="true" aria-expanded="false" class="user-dropdown"><i class="fa 
fa-user user-circle "></i></a>
+        <a href="javascript:void(0);" data-toggle="dropdown" 
aria-haspopup="true" aria-expanded="false" class="user-dropdown"><span 
class="userName"></span><i class="fa fa-user user-circle "></i></a>
         <ul class="dropdown-menu">
             <!--    <li><a href="#">Edit Profile</a></li>
             <li><a href="#">Change Password</a></li> -->
             <li class="aboutAtlas"><a href="javascript:void(0)">About</a></li>
             <li><a target="_blank" 
href="https://cwiki.apache.org/confluence/display/ATLAS/Atlas+Home";>Help</a></li>
             <li role="separator" class="divider"></li>
-            <li><a href="logout.html"> <i class="fa fa-sign-out"></i> 
Logout</a></li>
+            <li>
+                <a href="logout.html"> <i class="fa fa-sign-out"></i> 
Logout</a>
+            </li>
         </ul>
     </div>
 </header>

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/6eaeaaa3/dashboardv2/public/js/utils/CommonViewFunction.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/utils/CommonViewFunction.js 
b/dashboardv2/public/js/utils/CommonViewFunction.js
index d2de0dc..4df1449 100644
--- a/dashboardv2/public/js/utils/CommonViewFunction.js
+++ b/dashboardv2/public/js/utils/CommonViewFunction.js
@@ -170,5 +170,17 @@ define(['require', 'utils/Utils', 'modules/Modal', 
'utils/Messages'], function(r
         });
         return table;
     }
+    CommonViewFunction.userDataFetch = function(options) {
+        if (options.url) {
+            $.ajax({
+                url: options.url,
+                success: function(response) {
+                    if (options.callback) {
+                        options.callback(response);
+                    }
+                }
+            });
+        }
+    }
     return CommonViewFunction;
 });

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/6eaeaaa3/dashboardv2/public/js/utils/Globals.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/utils/Globals.js 
b/dashboardv2/public/js/utils/Globals.js
index 078881e..4b3cbbc 100644
--- a/dashboardv2/public/js/utils/Globals.js
+++ b/dashboardv2/public/js/utils/Globals.js
@@ -41,6 +41,10 @@ define(['require'], function(require) {
         TAG_ADD: "Tag Added",
         TAG_DELETE: "Tag Deleted"
     }
+    Globals.userLogedIn = {
+        status: false,
+        response: {}
+    }
 
     return Globals;
 });

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/6eaeaaa3/dashboardv2/public/js/views/business_catalog/BusinessCatalogHeader.js
----------------------------------------------------------------------
diff --git 
a/dashboardv2/public/js/views/business_catalog/BusinessCatalogHeader.js 
b/dashboardv2/public/js/views/business_catalog/BusinessCatalogHeader.js
index aad4bab..2f5f2e8 100644
--- a/dashboardv2/public/js/views/business_catalog/BusinessCatalogHeader.js
+++ b/dashboardv2/public/js/views/business_catalog/BusinessCatalogHeader.js
@@ -17,8 +17,10 @@
  */
 
 define(['require',
-    'hbs!tmpl/business_catalog/BusinessCatalogHeader'
-], function(require, tmpl) {
+    'hbs!tmpl/business_catalog/BusinessCatalogHeader',
+    'utils/CommonViewFunction',
+    'utils/Globals'
+], function(require, tmpl, CommonViewFunction, Globals) {
     'use strict';
 
     var BusinessCatalogHeader = Marionette.LayoutView.extend({
@@ -36,7 +38,20 @@ define(['require',
          * @return {[type]} [description]
          */
         render: function() {
+            var that = this;
             $(this.el).html(this.template());
+            if (!Globals.userLogedIn.status) {
+                CommonViewFunction.userDataFetch({
+                    url: Globals.baseURL + "/api/atlas/admin/session",
+                    callback: function(response) {
+                        that.$('.userName').html(response.userName);
+                        Globals.userLogedIn.status = true;
+                        Globals.userLogedIn.response = response;
+                    }
+                });
+            } else {
+                
that.$('.userName').html(Globals.userLogedIn.response.userName);
+            }
             var that = this;
             if (this.url) {
                 var t = [];

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/6eaeaaa3/dashboardv2/public/js/views/site/Header.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/views/site/Header.js 
b/dashboardv2/public/js/views/site/Header.js
index cf97a75..467cbf5 100644
--- a/dashboardv2/public/js/views/site/Header.js
+++ b/dashboardv2/public/js/views/site/Header.js
@@ -18,7 +18,9 @@
 
 define(['require',
     'hbs!tmpl/site/header',
-], function(require, tmpl) {
+    'utils/CommonViewFunction',
+    'utils/Globals'
+], function(require, tmpl, CommonViewFunction, Globals) {
     'use strict';
 
     var Header = Marionette.LayoutView.extend({
@@ -26,7 +28,21 @@ define(['require',
         regions: {},
         events: {},
         initialize: function(options) {},
-        onRender: function() {}
+        onRender: function() {
+            var that = this;
+            if (!Globals.userLogedIn.status) {
+                CommonViewFunction.userDataFetch({
+                    url: Globals.baseURL + "/api/atlas/admin/session",
+                    callback: function(response) {
+                        that.$('.userName').html(response.userName);
+                        Globals.userLogedIn.status = true;
+                        Globals.userLogedIn.response = response;
+                    }
+                });
+            } else {
+                
that.$('.userName').html(Globals.userLogedIn.response.userName);
+            }
+        },
     });
     return Header;
 });

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/6eaeaaa3/release-log.txt
----------------------------------------------------------------------
diff --git a/release-log.txt b/release-log.txt
index 31ad6a8..8e0ad39 100644
--- a/release-log.txt
+++ b/release-log.txt
@@ -22,6 +22,7 @@ ATLAS-409 Atlas will not import avro tables with schema read 
from a file (dosset
 ATLAS-379 Create sqoop and falcon metadata addons 
(venkatnrangan,bvellanki,sowmyaramesh via shwethags)
 
 ALL CHANGES:
+ATLAS-853 User's name to be mentioned in the top user drop down (saqeeb.s via 
shwethags)
 ATLAS-867 Excessive logs: default log level should be set to 'info'; currently 
it is 'debug' (svimal2106 via sumasai )
 ATLAS-870 Add search feature while associating Tags / Terms with entity. 
(Kalyanikashikar via yhemanth)
 ATLAS-865 Edit description functionality for Tags (kevalbhatt18 via yhemanth)

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/6eaeaaa3/webapp/src/main/java/org/apache/atlas/web/filters/AtlasAuthorizationFilter.java
----------------------------------------------------------------------
diff --git 
a/webapp/src/main/java/org/apache/atlas/web/filters/AtlasAuthorizationFilter.java
 
b/webapp/src/main/java/org/apache/atlas/web/filters/AtlasAuthorizationFilter.java
index d87120c..5bd2bd7 100644
--- 
a/webapp/src/main/java/org/apache/atlas/web/filters/AtlasAuthorizationFilter.java
+++ 
b/webapp/src/main/java/org/apache/atlas/web/filters/AtlasAuthorizationFilter.java
@@ -104,7 +104,7 @@ public class AtlasAuthorizationFilter extends 
GenericFilterBean {
             Authentication auth = 
SecurityContextHolder.getContext().getAuthentication();
 
             if (auth != null) {
-                userName = String.valueOf(auth.getPrincipal());
+                userName = auth.getName();
                 Collection<? extends GrantedAuthority> authorities = 
auth.getAuthorities();
                 for (GrantedAuthority c : authorities) {
                     groups.add(c.getAuthority());

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/6eaeaaa3/webapp/src/main/java/org/apache/atlas/web/resources/AdminResource.java
----------------------------------------------------------------------
diff --git 
a/webapp/src/main/java/org/apache/atlas/web/resources/AdminResource.java 
b/webapp/src/main/java/org/apache/atlas/web/resources/AdminResource.java
index 36b7607..3a46068 100755
--- a/webapp/src/main/java/org/apache/atlas/web/resources/AdminResource.java
+++ b/webapp/src/main/java/org/apache/atlas/web/resources/AdminResource.java
@@ -18,7 +18,18 @@
 
 package org.apache.atlas.web.resources;
 
-import com.google.inject.Inject;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.inject.Singleton;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
 import org.apache.atlas.AtlasClient;
 import org.apache.atlas.web.service.ServiceState;
 import org.apache.atlas.web.util.Servlets;
@@ -27,14 +38,11 @@ import 
org.apache.commons.configuration.PropertiesConfiguration;
 import org.apache.commons.lang.StringUtils;
 import org.codehaus.jettison.json.JSONException;
 import org.codehaus.jettison.json.JSONObject;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.GrantedAuthority;
+import org.springframework.security.core.context.SecurityContextHolder;
 
-import javax.inject.Singleton;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
+import com.google.inject.Inject;
 
 /**
  * Jersey Resource for admin operations.
@@ -121,4 +129,30 @@ public class AdminResource {
             throw new WebApplicationException(Servlets.getErrorResponse(e, 
Response.Status.INTERNAL_SERVER_ERROR));
         }
     }
+    
+    @GET
+    @Path("session")
+    @Produces(Servlets.JSON_MEDIA_TYPE)
+    public Response getUserProfile() {
+        JSONObject responseData = new JSONObject();
+        try {
+            Authentication auth = 
SecurityContextHolder.getContext().getAuthentication();
+            String userName = null;
+            Set<String> groups = new HashSet<String>();
+            if (auth != null) {
+                userName = auth.getName();
+                Collection<? extends GrantedAuthority> authorities = 
auth.getAuthorities();
+                for (GrantedAuthority c : authorities) {
+                    groups.add(c.getAuthority());
+                }
+            } 
+            
+            responseData.put("userName", userName);
+            responseData.put("groups", groups);
+            Response response = Response.ok(responseData).build();
+            return response;
+        } catch (JSONException e) {
+            throw new WebApplicationException(Servlets.getErrorResponse(e, 
Response.Status.INTERNAL_SERVER_ERROR));
+        }
+    }
 }

Reply via email to