private boolean validateRegisterUsers()

in custos-services/custos-core-services/iam-admin-core-service/src/main/java/org/apache/custos/iam/validator/IAMInputValidator.java [228:273]


    private boolean validateRegisterUsers(Object obj) {
        if (obj instanceof RegisterUsersRequest) {
            RegisterUsersRequest usersRequest = (RegisterUsersRequest) obj;

            if (usersRequest.getUsersList().isEmpty()) {
                throw new MissingParameterException("You need to have at least one User", null);
            }

            if (usersRequest.getTenantId() == 0) {
                throw new MissingParameterException("Tenant Id should not be null", null);
            }

            if (usersRequest.getAccessToken() == null) {
                throw new MissingParameterException("Access Token  should not be null", null);
            }

            if (usersRequest.getClientId() == null) {
                throw new MissingParameterException("Client Id  should not be null", null);
            }

            List<UserRepresentation> userRepresentationList = usersRequest.getUsersList();

            for (UserRepresentation user : userRepresentationList) {
                if (user.getUsername() == null ||
                        user.getUsername().trim().equals("")) {
                    throw new MissingParameterException("Username should not be null", null);
                }

                if (user.getFirstName() == null ||
                        user.getFirstName().trim().equals("")) {
                    throw new MissingParameterException("Firstname should not be null", null);
                }
                if (user.getLastName() == null ||
                        user.getLastName().trim().equals("")) {
                    throw new MissingParameterException("Lastname should not be null", null);
                }
                if (user.getEmail() == null ||
                        user.getEmail().trim().equals("")) {
                    throw new MissingParameterException("Email should not be null", null);
                }

            }

        }
        return true;
    }