use of org.olat.group.BusinessGroupService in project openolat by klemens.
the class LearningGroupWebService method getParticipants.
/**
* Returns the list of participants of the group specified by the groupKey.
* @response.representation.200.qname {http://www.example.com}userVO
* @response.representation.200.mediaType application/xml, application/json
* @response.representation.200.doc Participants of the business group
* @response.representation.200.example {@link org.olat.user.restapi.Examples#SAMPLE_USERVOes}
* @response.representation.404.doc The business group cannot be found
* @param groupKey The key of the group
* @param request The HTTP Request
* @return
*/
@GET
@Path("{groupKey}/participants")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getParticipants(@PathParam("groupKey") Long groupKey, @Context HttpServletRequest request) {
BusinessGroupService bgs = CoreSpringFactory.getImpl(BusinessGroupService.class);
BusinessGroup bg = bgs.loadBusinessGroup(groupKey);
if (bg == null) {
return Response.serverError().status(Status.NOT_FOUND).build();
}
if (!isGroupManager(request)) {
Identity identity = RestSecurityHelper.getIdentity(request);
if (!bgs.isIdentityInBusinessGroup(identity, bg)) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
if (!bg.isParticipantsVisibleIntern()) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
}
List<Identity> participants = CoreSpringFactory.getImpl(BusinessGroupService.class).getMembers(bg, GroupRoles.participant.name());
return getIdentityInGroup(participants);
}
use of org.olat.group.BusinessGroupService in project openolat by klemens.
the class LearningGroupWebService method postGroup.
/**
* Updates a group.
* @response.representation.qname {http://www.example.com}groupVO
* @response.representation.mediaType application/xml, application/json
* @response.representation.doc A business group in the OLAT system
* @response.representation.example {@link org.olat.restapi.support.vo.Examples#SAMPLE_GROUPVO}
* @response.representation.200.qname {http://www.example.com}groupVO
* @response.representation.200.mediaType application/xml, application/json
* @response.representation.200.doc The saved business group
* @response.representation.200.example {@link org.olat.restapi.support.vo.Examples#SAMPLE_GROUPVO}
* @response.representation.401.doc The roles of the authenticated user are not sufficient
* @response.representation.404.doc The business group cannot be found
* @param groupKey The key of the group
* @param group The group
* @param request The HTTP request
* @return
*/
@POST
@Path("{groupKey}")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response postGroup(@PathParam("groupKey") Long groupKey, final GroupVO group, @Context HttpServletRequest request) {
if (!isGroupManager(request)) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
final BusinessGroupService bgs = CoreSpringFactory.getImpl(BusinessGroupService.class);
final BusinessGroup bg = bgs.loadBusinessGroup(groupKey);
if (bg == null) {
return Response.serverError().status(Status.NOT_FOUND).build();
}
if (!StringHelper.containsNonWhitespace(group.getName())) {
return Response.serverError().status(Status.NOT_ACCEPTABLE).build();
}
Identity identity = RestSecurityHelper.getIdentity(request);
BusinessGroup mergedBg = bgs.updateBusinessGroup(identity, bg, group.getName(), group.getDescription(), group.getExternalId(), group.getManagedFlags(), normalize(group.getMinParticipants()), normalize(group.getMaxParticipants()));
// save the updated group
GroupVO savedVO = ObjectFactory.get(mergedBg);
return Response.ok(savedVO).build();
}
use of org.olat.group.BusinessGroupService in project openolat by klemens.
the class LearningGroupWebService method findById.
/**
* Return the group specified by the key of the group.
* @response.representation.200.qname {http://www.example.com}groupVO
* @response.representation.200.mediaType application/xml, application/json
* @response.representation.200.doc A business group in the OLAT system
* @response.representation.200.example {@link org.olat.restapi.support.vo.Examples#SAMPLE_GROUPVO}
* @param groupKey The key of the group
* @param request The REST request
* @param httpRequest The HTTP request
* @return
*/
@GET
@Path("{groupKey}")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response findById(@PathParam("groupKey") Long groupKey, @Context Request request, @Context HttpServletRequest httpRequest) {
BusinessGroupService bgs = CoreSpringFactory.getImpl(BusinessGroupService.class);
BusinessGroup bg = CoreSpringFactory.getImpl(BusinessGroupService.class).loadBusinessGroup(groupKey);
if (bg == null) {
return Response.serverError().status(Status.NOT_FOUND).build();
}
Identity identity = RestSecurityHelper.getIdentity(httpRequest);
if (!isGroupManager(httpRequest) && !bgs.isIdentityInBusinessGroup(identity, bg)) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
Date lastModified = bg.getLastModified();
Response.ResponseBuilder response = request.evaluatePreconditions(lastModified);
if (response == null) {
GroupVO vo = ObjectFactory.get(bg);
response = Response.ok(vo);
}
return response.build();
}
use of org.olat.group.BusinessGroupService in project openolat by klemens.
the class LearningGroupWebService method getForum.
/**
* Return the Forum web service
* @param groupKey The key of the group
* @param request The HTTP Request
* @return
*/
@Path("{groupKey}/forum")
public ForumWebService getForum(@PathParam("groupKey") Long groupKey, @Context HttpServletRequest request) {
BusinessGroupService bgs = CoreSpringFactory.getImpl(BusinessGroupService.class);
BusinessGroup bg = CoreSpringFactory.getImpl(BusinessGroupService.class).loadBusinessGroup(groupKey);
if (bg == null) {
return null;
}
if (!isGroupManager(request)) {
Identity identity = RestSecurityHelper.getIdentity(request);
if (!bgs.isIdentityInBusinessGroup(identity, bg)) {
return null;
}
}
CollaborationTools collabTools = CollaborationToolsFactory.getInstance().getOrCreateCollaborationTools(bg);
if (collabTools.isToolEnabled(CollaborationTools.TOOL_FORUM)) {
Forum forum = collabTools.getForum();
return new ForumWebService(forum);
}
return null;
}
use of org.olat.group.BusinessGroupService in project openolat by klemens.
the class LearningGroupWebService method getWiki.
/**
* Return the Forum web service
* @param groupKey The key of the group
* @param request The HTTP Request
* @return
*/
@Path("{groupKey}/wiki")
public GroupWikiWebService getWiki(@PathParam("groupKey") Long groupKey, @Context HttpServletRequest request) {
BusinessGroupService bgs = CoreSpringFactory.getImpl(BusinessGroupService.class);
BusinessGroup bg = bgs.loadBusinessGroup(groupKey);
if (bg == null) {
return null;
}
if (!isGroupManager(request)) {
Identity identity = RestSecurityHelper.getIdentity(request);
if (!bgs.isIdentityInBusinessGroup(identity, bg)) {
return null;
}
}
CollaborationTools collabTools = CollaborationToolsFactory.getInstance().getOrCreateCollaborationTools(bg);
if (collabTools.isToolEnabled(CollaborationTools.TOOL_WIKI)) {
return new GroupWikiWebService(bg);
}
return null;
}
Aggregations