/**
   * Method execute
   *
   * @param mapping
   * @param form
   * @param request
   * @param response
   * @return ActionForward
   */
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response) {
    // TODO Auto-generated method stub
    HMaster master = (HMaster) getServlet().getServletContext().getAttribute(HMaster.MASTER);

    authorityOperation ao = new authorityOperation();

    String userType = (String) request.getSession().getAttribute("usertype");
    boolean ifAdmin = userType.equals("admin");
    String username = (String) request.getSession().getAttribute("username");

    if (ifAdmin) {
      try {
        Map<byte[], ACLField> tables = ao.getAllTable(master);

        request.setAttribute("tables", tables);
      } catch (MasterNotRunningException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      } catch (ZooKeeperConnectionException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    } else {
      try {
        Map<byte[], ACLField> tables = ao.getUserTable(master, username);

        request.setAttribute("tables", tables);
      } catch (MasterNotRunningException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      } catch (ZooKeeperConnectionException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }

    return mapping.findForward("success");
  }
Пример #2
0
  /**
   * Method execute
   *
   * @param mapping
   * @param form
   * @param request
   * @param response
   * @return ActionForward
   */
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response) {
    // TODO Auto-generated method stub
    HMaster master = (HMaster) getServlet().getServletContext().getAttribute(HMaster.MASTER);

    tableOperation to = new tableOperation();
    authorityOperation ao = new authorityOperation();

    Configuration conf = master.getConfiguration();
    boolean security = conf.getBoolean("hbase.server.security", false);

    HTableDescriptor[] adminTables = null;
    Map<byte[], ACLField> userTables = null;
    List<String> tableList = new ArrayList<String>();

    if (security) {
      String username = (String) request.getSession().getAttribute("username");
      String usertype = (String) request.getSession().getAttribute("usertype");
      try {
        if (usertype.equals("admin")) {
          adminTables = to.getAllTable(master);
          for (HTableDescriptor tableDesc : adminTables) {
            tableList.add(tableDesc.getNameAsString());
          }
        } else {
          userTables = ao.getUserVisibleTable(master, username);
          for (Map.Entry<byte[], ACLField> entry : userTables.entrySet()) {
            tableList.add(Bytes.toString(entry.getKey()));
          }
        }
      } catch (MasterNotRunningException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      } catch (ZooKeeperConnectionException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    } else {
      try {
        adminTables = to.getAllTable(master);
      } catch (MasterNotRunningException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      } catch (ZooKeeperConnectionException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
      for (HTableDescriptor tableDesc : adminTables) {
        tableList.add(tableDesc.getNameAsString());
      }
    }

    request.setAttribute("tableList", tableList);

    return mapping.findForward("success");
  }