DICE-UNC / jargon

Jargon core libraries
Other
27 stars 31 forks source link

jargon groupadmin new operations: addUser and removeUserFromGroup #392

Open a-tsygan opened 2 years ago

a-tsygan commented 2 years ago

At the moment at least two useful calls in Jargon are missing concerning groupadmin operations (AsGroupAdmin calls). We've made our custom implementation, maybe it will be good to add this to kernel jargon. Two methods to UserAdminInp.java:

  1. addUserAsGroupAdmin:

    public static RugUserAdminImp instanceForRemoveUserToGroup(final String userGroupName, final String userName,
            final String zoneName) throws JargonException {
        if (userGroupName == null || userGroupName.isEmpty()) {
            throw new IllegalArgumentException("null userGroupName");
        }
    
        if (userName == null || userName.isEmpty()) {
            throw new IllegalArgumentException("null UserName");
        }
    
        if (zoneName == null || zoneName.isEmpty()) {
            throw new IllegalArgumentException("null or empty zoneName");
        }
    
        return new RugUserAdminImp("modify", "group", userGroupName, "remove", userName, zoneName, BLANK, BLANK, BLANK, BLANK,
                USER_ADMIN_INP_API_NBR);
    }
  2. removeUserfromGroupAsGroupAdmin:

    
    public static RugUserAdminImp instanceForCreateUser(final User user) throws JargonException {
    
            if (user == null) {
                throw new JargonException("null user");
            }
    
            if (user.getName().isEmpty()) {
                throw new JargonException("blank user name");
            }
    
            if (user.getUserType() == UserTypeEnum.RODS_UNKNOWN) {
                throw new JargonException("unknown user type");
            }
    
            return new RugUserAdminImp("mkuser", user.getName(), user.getUserType().getTextValue(), BLANK, BLANK, BLANK, BLANK,
                    BLANK, BLANK, BLANK, USER_ADMIN_INP_API_NBR);
    }
and then simple change in UserGroupAO:
void removeUserFromGroupAsGroupAdmin(String userGroupName, String userName, String zoneName)
        throws InvalidUserException, InvalidGroupException, JargonException;

void addUserAsGroupAdmin(User p_user)
        throws InvalidUserException, InvalidGroupException, JargonException;
and UserGroupAOImpl:
@Override
public void removeUserFromGroupAsGroupAdmin(final String userGroupName, final String userName, final String zoneName)

        throws InvalidUserException, InvalidGroupException, JargonException {

    log.info("removeUserFromGroup()");

    if (userGroupName == null || userGroupName.isEmpty()) {
        throw new IllegalArgumentException("null or emtpy userGroupName");
    }

    if (userName == null || userName.isEmpty()) {
        throw new IllegalArgumentException("null or emtpy userName");
    }

    log.info("userName:{}", userName);
    log.info("userGroupName:{}", userGroupName);

    if (zoneName != null) {
        log.info("zoneName:{}", zoneName);
    }

    // call the iadmin iRODS service

    RugUserAdminImp adminPI = RugUserAdminImp.instanceForRemoveUserToGroup(userGroupName, userName, zoneName);

    log.debug("executing admin PI");

    getIRODSProtocol().irodsFunction(adminPI);

}

@Override
public void addUserAsGroupAdmin(final User user)

        throws InvalidUserException, InvalidGroupException, JargonException {

    log.info("addUserAsGroupAdmin()");

    RugUserAdminImp adminPI = RugUserAdminImp.instanceForCreateUser(user);

    log.debug("executing admin PI");

    getIRODSProtocol().irodsFunction(adminPI);

}
michael-conway commented 2 years ago

Excellent I will add them!

On Sat, Aug 21, 2021, 10:43 AM Andrey Tsyganov @.***> wrote:

At the moment at least two useful calls in Jargon are missing concerning groupadmin operations (AsGroupAdmin calls). We've made our custom implementation, maybe it will be good to add this to kernel jargon. Two methods to UserAdminInp.java:

  1. addUserAsGroupAdmin:

    public static RugUserAdminImp instanceForRemoveUserToGroup(final String userGroupName, final String userName, final String zoneName) throws JargonException { if (userGroupName == null || userGroupName.isEmpty()) { throw new IllegalArgumentException("null userGroupName"); }

    if (userName == null || userName.isEmpty()) { throw new IllegalArgumentException("null UserName"); }

    if (zoneName == null || zoneName.isEmpty()) { throw new IllegalArgumentException("null or empty zoneName"); }

    return new RugUserAdminImp("modify", "group", userGroupName, "remove", userName, zoneName, BLANK, BLANK, BLANK, BLANK, USER_ADMIN_INP_API_NBR); }

  2. removeUserfromGroupAsGroupAdmin:

    public static RugUserAdminImp instanceForCreateUser(final User user) throws JargonException {

      if (user == null) {
          throw new JargonException("null user");
      }
    
      if (user.getName().isEmpty()) {
          throw new JargonException("blank user name");
      }
    
      if (user.getUserType() == UserTypeEnum.RODS_UNKNOWN) {
          throw new JargonException("unknown user type");
      }
    
      return new RugUserAdminImp("mkuser", user.getName(), user.getUserType().getTextValue(), BLANK, BLANK, BLANK, BLANK,
              BLANK, BLANK, BLANK, USER_ADMIN_INP_API_NBR);

    }

and then simple change in UserGroupAO:

void removeUserFromGroupAsGroupAdmin(String userGroupName, String userName, String zoneName) throws InvalidUserException, InvalidGroupException, JargonException;

void addUserAsGroupAdmin(User p_user) throws InvalidUserException, InvalidGroupException, JargonException;

and UserGroupAOImpl:

@Override public void removeUserFromGroupAsGroupAdmin(final String userGroupName, final String userName, final String zoneName)

      throws InvalidUserException, InvalidGroupException, JargonException {

  log.info("removeUserFromGroup()");

  if (userGroupName == null || userGroupName.isEmpty()) {
      throw new IllegalArgumentException("null or emtpy userGroupName");
  }

  if (userName == null || userName.isEmpty()) {
      throw new IllegalArgumentException("null or emtpy userName");
  }

  log.info("userName:{}", userName);
  log.info("userGroupName:{}", userGroupName);

  if (zoneName != null) {
      log.info("zoneName:{}", zoneName);
  }

  // call the iadmin iRODS service

  RugUserAdminImp adminPI = RugUserAdminImp.instanceForRemoveUserToGroup(userGroupName, userName, zoneName);

  log.debug("executing admin PI");

  getIRODSProtocol().irodsFunction(adminPI);

}

@Override public void addUserAsGroupAdmin(final User user)

      throws InvalidUserException, InvalidGroupException, JargonException {

  log.info("addUserAsGroupAdmin()");

  RugUserAdminImp adminPI = RugUserAdminImp.instanceForCreateUser(user);

  log.debug("executing admin PI");

  getIRODSProtocol().irodsFunction(adminPI);

}

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/DICE-UNC/jargon/issues/392, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIL4LMIRXHA2CD7ZKZIVXLT563SPANCNFSM5CR5IETQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .