I'm trying to bulk remove users from a portal. In the absence of a fluent api I'm trying
portal.removeFromPortalUsers(portaluser)
and
user.removeFromPortalUsers(portaluser)
in both cases I'm getting an error which only differs depending on what object is calling the method. In the case of portal I get:
[v.3.1 Sep 20 2014 14:06:21] Validation failures: Validation failure for com.avoka.fc.core.entity.PortalUser.portal: \"portal\" is required.
and invoking on user I get:
[v.3.1 Sep 20 2014 14:06:21] Validation failures: Validation failure for com.avoka.fc.core.entity.PortalUser.user: \"user\" is required.
Is there a way around this?
Full code below:
portal = new com.avoka.fc.core.dao.PortalDao().getPortalByName('My Portal')
users = portal.getPortalUsers()
outsiders = users.findAll { ! it.getUser().isActive() }
outsiders.each { pu ->
u = pu.getUser()
u.removeFromPortalUsers(pu)
}