use of org.olat.restapi.support.vo.GroupVOes in project OpenOLAT by OpenOLAT.
the class UserMgmtTest method testUserGroup_owner.
@Test
public void testUserGroup_owner() throws IOException, URISyntaxException {
RestConnection conn = new RestConnection();
assertTrue(conn.login("administrator", "openolat"));
// retrieve all groups
URI uri = UriBuilder.fromUri(getContextURI()).path("users").path(id1.getKey().toString()).path("groups").path("owner").queryParam("start", 0).queryParam("limit", 1).build();
HttpGet method = conn.createGet(uri, MediaType.APPLICATION_JSON + ";pagingspec=1.0", true);
HttpResponse response = conn.execute(method);
assertEquals(200, response.getStatusLine().getStatusCode());
GroupVOes groups = conn.parse(response, GroupVOes.class);
assertNotNull(groups);
assertNotNull(groups.getGroups());
assertEquals(1, groups.getGroups().length);
// g1
assertEquals(1, groups.getTotalCount());
conn.shutdown();
}
use of org.olat.restapi.support.vo.GroupVOes in project openolat by klemens.
the class UserMgmtTest method testUserGroup_owner.
@Test
public void testUserGroup_owner() throws IOException, URISyntaxException {
RestConnection conn = new RestConnection();
assertTrue(conn.login("administrator", "openolat"));
// retrieve all groups
URI uri = UriBuilder.fromUri(getContextURI()).path("users").path(id1.getKey().toString()).path("groups").path("owner").queryParam("start", 0).queryParam("limit", 1).build();
HttpGet method = conn.createGet(uri, MediaType.APPLICATION_JSON + ";pagingspec=1.0", true);
HttpResponse response = conn.execute(method);
assertEquals(200, response.getStatusLine().getStatusCode());
GroupVOes groups = conn.parse(response, GroupVOes.class);
assertNotNull(groups);
assertNotNull(groups.getGroups());
assertEquals(1, groups.getGroups().length);
// g1
assertEquals(1, groups.getTotalCount());
conn.shutdown();
}
use of org.olat.restapi.support.vo.GroupVOes in project openolat by klemens.
the class UserMgmtTest method testUserGroup_participant.
@Test
public void testUserGroup_participant() throws IOException, URISyntaxException {
RestConnection conn = new RestConnection();
assertTrue(conn.login("administrator", "openolat"));
// retrieve all groups
URI uri = UriBuilder.fromUri(getContextURI()).path("users").path(id1.getKey().toString()).path("groups").path("participant").queryParam("start", 0).queryParam("limit", 1).build();
HttpGet method = conn.createGet(uri, MediaType.APPLICATION_JSON + ";pagingspec=1.0", true);
HttpResponse response = conn.execute(method);
assertEquals(200, response.getStatusLine().getStatusCode());
GroupVOes groups = conn.parse(response, GroupVOes.class);
assertNotNull(groups);
assertNotNull(groups.getGroups());
assertEquals(1, groups.getGroups().length);
// g2 and g3
assertEquals(2, groups.getTotalCount());
conn.shutdown();
}
use of org.olat.restapi.support.vo.GroupVOes in project openolat by klemens.
the class MyGroupWebService method getGroupList.
private Response getGroupList(Integer start, Integer limit, String externalId, Boolean managed, boolean owner, boolean participant, HttpServletRequest httpRequest, Request request) {
BusinessGroupService bgs = CoreSpringFactory.getImpl(BusinessGroupService.class);
SearchBusinessGroupParams params = new SearchBusinessGroupParams(retrievedUser, owner, participant);
if (StringHelper.containsNonWhitespace(externalId)) {
params.setExternalId(externalId);
}
params.setManaged(managed);
List<BusinessGroup> groups;
if (MediaTypeVariants.isPaged(httpRequest, request)) {
int totalCount = bgs.countBusinessGroups(params, null);
groups = bgs.findBusinessGroups(params, null, start, limit);
int count = 0;
GroupVO[] groupVOs = new GroupVO[groups.size()];
for (BusinessGroup group : groups) {
groupVOs[count++] = ObjectFactory.get(group);
}
GroupVOes voes = new GroupVOes();
voes.setGroups(groupVOs);
voes.setTotalCount(totalCount);
return Response.ok(voes).build();
} else {
groups = bgs.findBusinessGroups(params, null, 0, -1);
int count = 0;
GroupVO[] groupVOs = new GroupVO[groups.size()];
for (BusinessGroup group : groups) {
groupVOs[count++] = ObjectFactory.get(group);
}
return Response.ok(groupVOs).build();
}
}
use of org.olat.restapi.support.vo.GroupVOes in project OpenOLAT by OpenOLAT.
the class MyGroupWebService method getGroupList.
private Response getGroupList(Integer start, Integer limit, String externalId, Boolean managed, boolean owner, boolean participant, HttpServletRequest httpRequest, Request request) {
BusinessGroupService bgs = CoreSpringFactory.getImpl(BusinessGroupService.class);
SearchBusinessGroupParams params = new SearchBusinessGroupParams(retrievedUser, owner, participant);
if (StringHelper.containsNonWhitespace(externalId)) {
params.setExternalId(externalId);
}
params.setManaged(managed);
List<BusinessGroup> groups;
if (MediaTypeVariants.isPaged(httpRequest, request)) {
int totalCount = bgs.countBusinessGroups(params, null);
groups = bgs.findBusinessGroups(params, null, start, limit);
int count = 0;
GroupVO[] groupVOs = new GroupVO[groups.size()];
for (BusinessGroup group : groups) {
groupVOs[count++] = ObjectFactory.get(group);
}
GroupVOes voes = new GroupVOes();
voes.setGroups(groupVOs);
voes.setTotalCount(totalCount);
return Response.ok(voes).build();
} else {
groups = bgs.findBusinessGroups(params, null, 0, -1);
int count = 0;
GroupVO[] groupVOs = new GroupVO[groups.size()];
for (BusinessGroup group : groups) {
groupVOs[count++] = ObjectFactory.get(group);
}
return Response.ok(groupVOs).build();
}
}
Aggregations