Ejemplo n.º 1
0
  /**
   * Set the Permission on a Bitstream.
   *
   * @param c
   * @param g
   * @param actionID
   * @param bs
   * @throws SQLException
   * @throws AuthorizeException
   */
  private void setPermission(Context c, Group g, int actionID, Bitstream bs)
      throws SQLException, AuthorizeException {
    if (!isTest) {
      // remove the default policy
      AuthorizeManager.removeAllPolicies(c, bs);

      // add the policy
      ResourcePolicy rp = ResourcePolicy.create(c);

      rp.setResource(bs);
      rp.setAction(actionID);
      rp.setGroup(g);

      rp.update();
    } else {
      if (actionID == Constants.READ) {
        System.out.println("\t\tpermissions: READ for " + g.getName());
      } else if (actionID == Constants.WRITE) {
        System.out.println("\t\tpermissions: WRITE for " + g.getName());
      }
    }
  }