public void init(String appPath, ServiceConfig params) throws Exception {
}
public Element exec(Element params, ServiceContext context)
throws Exception {
UserSession session = context.getUserSession();
if (!session.isAuthenticated())
return new Element(Geonet.Elem.GROUPS);
// --- retrieve user groups
if (Profile.Administrator == session.getProfile()) {
return context.getBean(GroupRepository.class).findAllAsXml(not(isReserved()));
} else {
final int userIdAsInt = session.getUserIdAsInt();
final Specifications<UserGroup> spec = where(UserGroupSpecs.hasUserId(userIdAsInt)).and(UserGroupSpecs.isReservedGroup(false));
return context.getBean(UserGroupRepository.class).findAllAsXml(spec);
}
}