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

    if (principalTypeName.equals(PrincipalTypeEntity.GROUP_PRINCIPAL_TYPE_NAME)) {
      final GroupEntity groupEntity = groupDAO.findGroupByPrincipal(privilegeEntity.getPrincipal());
      groupPrivilegeResponse.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 = clusterDAO.findByResourceId(privilegeEntity.getResource().getId());
          groupPrivilegeResponse.setClusterName(clusterEntity.getClusterName());
          break;
        case VIEW:
          final ViewInstanceEntity viewInstanceEntity = viewInstanceDAO.findByResourceId(privilegeEntity.getResource().getId());
          final ViewEntity viewEntity = viewInstanceEntity.getViewEntity();

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

      groupPrivilegeResponse.setType(resourceType);
    }

    return groupPrivilegeResponse;
  }
Returns the response for the group privilege that should be returned for the group privilege REST endpoint
@param privilegeEntity the privilege data
@param groupName    the group name
@return group privilege response
ambari-server/src/main/java/org/apache/ambari/server/controller/internal/GroupPrivilegeResourceProvider.java