package com.yammer.stresstime.resources;

import com.yammer.stresstime.auth.Authorize;
import com.yammer.stresstime.auth.Role;
import com.yammer.stresstime.entities.User;
import io.dropwizard.hibernate.UnitOfWork;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.util.HashMap;
import java.util.Map;

@Path("/current")
@Produces(MediaType.APPLICATION_JSON)
public class AuthorizationResource {

    @GET
    @UnitOfWork
    public Response getCurrent(
            @Authorize({Role.ADMIN, Role.MEMBER, Role.GUEST}) User user) {

        Map<String, Object> response = new HashMap<>();
        response.put("role", user.getRole().toString());
        if (user.getEmployee() != null) {
            response.put("employeeId", user.getEmployee().getId());
        }

        return Response.ok().entity(response).build();
    }
}

@@ -120,16 +120,111 @@
 h.Role;%0A
+import com.yammer.stresstime.entities.Group;%0Aimport com.yammer.stresstime.entities.Membership;%0A
 import c
@@ -493,19 +493,78 @@
 va.util.
-Map
+List;%0Aimport java.util.Map;%0Aimport java.util.stream.Collectors
 ;%0A%0A@Path
@@ -1004,24 +1004,337 @@
 ).getId());%0A
+            List%3CLong%3E groupIds = user.getEmployee().getMemberships().stream()%0A                    .filter(m -%3E m.isAdmin())%0A                    .map(Membership::getGroup)%0A                    .map(Group::getId)%0A                    .collect(Collectors.toList());%0A            response.put(%22groupsAdmin%22, groupIds);%0A
         %7D%0A%0A 

Add group admin information to '/current' request