Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jargon groupadmin new operations: addUser and removeUserFromGroup #392

Open
a-tsygan opened this issue Aug 21, 2021 · 1 comment
Open

jargon groupadmin new operations: addUser and removeUserFromGroup #392

a-tsygan opened this issue Aug 21, 2021 · 1 comment

Comments

@a-tsygan
Copy link

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);
	}
  1. 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
Copy link
Collaborator

michael-conway commented Aug 21, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants