protected UserPrivilegeResponse getResponse(PrivilegeEntity privilegeEntity, String userName) {
    String permissionLabel = privilegeEntity.getPermission().getPermissionLabel();
    String permissionName =  privilegeEntity.getPermission().getPermissionName();
    String principalTypeName = privilegeEntity.getPrincipal().getPrincipalType().getName();
    UserPrivilegeResponse userPrivilegeResponse = new UserPrivilegeResponse(userName, permissionLabel , permissionName,
      privilegeEntity.getId(), PrincipalTypeEntity.PrincipalType.valueOf(principalTypeName));

    if (principalTypeName.equals(PrincipalTypeEntity.USER_PRINCIPAL_TYPE_NAME)) {
      final UserEntity user = userDAO.findUserByPrincipal(privilegeEntity.getPrincipal());
      userPrivilegeResponse.setPrincipalName(user.getUserName());
    } else if (principalTypeName.equals(PrincipalTypeEntity.GROUP_PRINCIPAL_TYPE_NAME)) {
      final GroupEntity groupEntity = getCachedGroupByPrincipal(privilegeEntity.getPrincipal());
      userPrivilegeResponse.setPrincipalName(groupEntity.getGroupName());
    }

    String typeName = privilegeEntity.getResource().getResourceType().getName();
    ResourceType resourceType = ResourceType.translate(typeName);

    if(resourceType != null) {
      switch (resourceType) {
        case AMBARI:
          // there is nothing special to add for this case
          break;
        case CLUSTER:
          final ClusterEntity clusterEntity = clusterCache.get().getUnchecked(privilegeEntity.getResource().getId());
          userPrivilegeResponse.setClusterName(clusterEntity.getClusterName());
          break;
        case VIEW:
          final ViewInstanceEntity viewInstanceEntity = viewInstanceCache.get().getUnchecked(privilegeEntity.getResource().getId());
          final ViewEntity viewEntity = viewInstanceEntity.getViewEntity();

          userPrivilegeResponse.setViewName(viewEntity.getCommonName());
          userPrivilegeResponse.setVersion(viewEntity.getVersion());
          userPrivilegeResponse.setInstanceName(viewInstanceEntity.getName());
          break;
      }

      userPrivilegeResponse.setType(resourceType);
    }

    return userPrivilegeResponse;
  }
Returns response schema instance for /users/{userName}/privileges REST endpoint
@param privilegeEntity {@link PrivilegeEntity}
@param userName   user name
@return {@link UserPrivilegeResponse}
ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UserPrivilegeResourceProvider.java