use of org.olat.restapi.support.vo.GroupInfoVO in project OpenOLAT by OpenOLAT.
the class ObjectFactory method getInformation.
public static GroupInfoVO getInformation(Identity identity, BusinessGroup grp) {
GroupInfoVO vo = new GroupInfoVO();
vo.setKey(grp.getKey());
vo.setName(grp.getName());
vo.setDescription(grp.getDescription());
vo.setMaxParticipants(grp.getMaxParticipants());
vo.setMinParticipants(grp.getMinParticipants());
vo.setType("LearningGroup");
CollaborationTools collabTools = CollaborationToolsFactory.getInstance().getOrCreateCollaborationTools(grp);
if (collabTools.isToolEnabled(CollaborationTools.TOOL_FORUM)) {
vo.setForumKey(collabTools.getForum().getKey());
}
String news = collabTools.lookupNews();
vo.setNews(news);
boolean hasWiki = collabTools.isToolEnabled(CollaborationTools.TOOL_WIKI);
vo.setHasWiki(hasWiki);
boolean hasFolder = collabTools.isToolEnabled(CollaborationTools.TOOL_FOLDER);
vo.setHasFolder(hasFolder);
boolean hasFolderWrite = hasFolder;
if (hasFolder) {
Long access = collabTools.lookupFolderAccess();
if (access != null && access.intValue() == CollaborationTools.FOLDER_ACCESS_OWNERS) {
// is owner?
hasFolderWrite = CoreSpringFactory.getImpl(BusinessGroupService.class).hasRoles(identity, grp, GroupRoles.coach.name());
}
}
vo.setFolderWrite(hasFolderWrite);
return vo;
}
use of org.olat.restapi.support.vo.GroupInfoVO in project OpenOLAT by OpenOLAT.
the class GroupMgmtTest method testGetGroupInfos.
@Test
public void testGetGroupInfos() throws IOException, URISyntaxException {
assertTrue(conn.login("administrator", "openolat"));
URI request = UriBuilder.fromUri(getContextURI()).path("/groups/" + g1.getKey() + "/infos").build();
HttpGet method = conn.createGet(request, MediaType.APPLICATION_JSON, true);
HttpResponse response = conn.execute(method);
assertEquals(200, response.getStatusLine().getStatusCode());
GroupInfoVO vo = conn.parse(response, GroupInfoVO.class);
assertNotNull(vo);
assertEquals(Boolean.TRUE, vo.getHasWiki());
assertEquals("<p>Hello world</p>", vo.getNews());
assertNotNull(vo.getForumKey());
}
use of org.olat.restapi.support.vo.GroupInfoVO in project OpenOLAT by OpenOLAT.
the class GroupMgmtTest method testGetGroupInfos2.
// the web service generate the forum key
@Test
public void testGetGroupInfos2() throws IOException, URISyntaxException {
assertTrue(conn.login("administrator", "openolat"));
URI request = UriBuilder.fromUri(getContextURI()).path("/groups/" + g2.getKey() + "/infos").build();
HttpGet method = conn.createGet(request, MediaType.APPLICATION_JSON, true);
HttpResponse response = conn.execute(method);
assertEquals(200, response.getStatusLine().getStatusCode());
GroupInfoVO vo = conn.parse(response, GroupInfoVO.class);
assertNotNull(vo);
assertEquals(Boolean.FALSE, vo.getHasWiki());
assertNull(vo.getNews());
assertNotNull(vo.getForumKey());
}
use of org.olat.restapi.support.vo.GroupInfoVO in project openolat by klemens.
the class GroupMgmtTest method testGetGroupInfos2.
// the web service generate the forum key
@Test
public void testGetGroupInfos2() throws IOException, URISyntaxException {
assertTrue(conn.login("administrator", "openolat"));
URI request = UriBuilder.fromUri(getContextURI()).path("/groups/" + g2.getKey() + "/infos").build();
HttpGet method = conn.createGet(request, MediaType.APPLICATION_JSON, true);
HttpResponse response = conn.execute(method);
assertEquals(200, response.getStatusLine().getStatusCode());
GroupInfoVO vo = conn.parse(response, GroupInfoVO.class);
assertNotNull(vo);
assertEquals(Boolean.FALSE, vo.getHasWiki());
assertNull(vo.getNews());
assertNotNull(vo.getForumKey());
}
use of org.olat.restapi.support.vo.GroupInfoVO in project openolat by klemens.
the class MyGroupWebService method getUserGroupInfosList.
/**
* Return all groups with information of a user. Paging is mandatory!
* @response.representation.200.qname {http://www.example.com}groupInfoVO
* @response.representation.200.mediaType application/xml;pagingspec=1.0, application/json;pagingspec=1.0
* @response.representation.200.doc The groups of the user
* @response.representation.200.example {@link org.olat.restapi.support.vo.Examples#SAMPLE_GROUPINFOVOes}
* @response.representation.406.doc The request hasn't paging information
* @param start The first result
* @param limit The maximum results
* @param externalId Search with an external ID
* @param managed (true / false) Search only managed / not managed groups
* @param httpRequest The HTTP request
* @param request The REST request
* @return The list of groups with additional informations
*/
@GET
@Path("infos")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getUserGroupInfosList(@QueryParam("start") @DefaultValue("0") Integer start, @QueryParam("limit") @DefaultValue("25") Integer limit, @QueryParam("externalId") String externalId, @QueryParam("managed") Boolean managed, @Context HttpServletRequest httpRequest, @Context Request request) {
BusinessGroupService bgs = CoreSpringFactory.getImpl(BusinessGroupService.class);
SearchBusinessGroupParams params = new SearchBusinessGroupParams(retrievedUser, true, true);
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;
GroupInfoVO[] groupVOs = new GroupInfoVO[groups.size()];
for (BusinessGroup group : groups) {
groupVOs[count++] = ObjectFactory.getInformation(retrievedUser, group);
}
GroupInfoVOes voes = new GroupInfoVOes();
voes.setGroups(groupVOs);
voes.setTotalCount(totalCount);
return Response.ok(voes).build();
} else {
return Response.serverError().status(Status.NOT_ACCEPTABLE).build();
}
}
Aggregations