method = RequestMethod.GET,
produces = "application/json")
@ResponseBody
@Timed
public Group getGroup(@PathVariable("groupId") String groupId) {
User currentUser = authenticationService.getCurrentUser();
String domain = DomainUtil.getDomainFromLogin(currentUser.getLogin());
Group publicGroup = groupService.getGroupById(domain, groupId);
if (publicGroup != null && publicGroup.isPublicGroup()) {
Group result = getGroupFromUser(currentUser, groupId);
Group groupClone = (Group) publicGroup.clone();
if (result != null) {
groupClone.setMember(true);
}
if (isGroupManagedByCurrentUser(publicGroup)) {
groupClone.setAdministrator(true);
}
return groupClone;
} else {
Group result = getGroupFromUser(currentUser, groupId);
Group groupClone = null;
if (result == null) {
log.info("Permission denied! User {} tried to access group ID = {} ", currentUser.getLogin(), groupId);
return null;
} else {
groupClone = (Group) result.clone();
groupClone.setMember(true);
if (isGroupManagedByCurrentUser(publicGroup)) {