use of org.olat.group.BusinessGroupService in project openolat by klemens.
the class CourseGroupWebService method getGroupList.
/**
* Lists all learn groups of the specified course.
* @response.representation.200.qname {http://www.example.com}groupVO
* @response.representation.200.mediaType application/xml, application/json
* @response.representation.200.doc The list of all learning group of the course
* @response.representation.200.example {@link org.olat.restapi.support.vo.Examples#SAMPLE_GROUPVOes}
* @response.representation.404.doc The context of the group not found
* @param request The HTTP request
* @return
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getGroupList() {
BusinessGroupService bgs = CoreSpringFactory.getImpl(BusinessGroupService.class);
SearchBusinessGroupParams params = new SearchBusinessGroupParams();
List<BusinessGroup> groups = bgs.findBusinessGroups(params, courseEntryRef, 0, -1);
int count = 0;
GroupVO[] vos = new GroupVO[groups.size()];
for (BusinessGroup group : groups) {
vos[count++] = ObjectFactory.get(group);
}
return Response.ok(vos).build();
}
use of org.olat.group.BusinessGroupService in project openolat by klemens.
the class CourseGroupWebService 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 = 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_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 getFolder.
@Path("{groupKey}/folder")
public VFSWebservice getFolder(@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_FOLDER)) {
return null;
}
String relPath = collabTools.getFolderRelPath();
QuotaManager qm = QuotaManager.getInstance();
Quota folderQuota = qm.getCustomQuota(relPath);
if (folderQuota == null) {
Quota defQuota = qm.getDefaultQuota(QuotaConstants.IDENTIFIER_DEFAULT_GROUPS);
folderQuota = QuotaManager.getInstance().createQuota(relPath, defQuota.getQuotaKB(), defQuota.getUlLimitKB());
}
SubscriptionContext subsContext = null;
VFSSecurityCallback secCallback = new VFSWebServiceSecurityCallback(true, true, true, folderQuota, subsContext);
OlatRootFolderImpl rootContainer = new OlatRootFolderImpl(relPath, null);
rootContainer.setLocalSecurityCallback(secCallback);
return new VFSWebservice(rootContainer);
}
use of org.olat.group.BusinessGroupService in project openolat by klemens.
the class LearningGroupWebService method addTutor.
/**
* Adds an owner to the group.
* @response.representation.200.doc The user is added as owner of the group
* @response.representation.401.doc The roles of the authenticated user are not sufficient
* @response.representation.404.doc The business group or the user cannot be found
* @param groupKey The key of the group
* @param identityKey The user's id
* @param request The HTTP request
* @return
*/
@PUT
@Path("{groupKey}/owners/{identityKey}")
public Response addTutor(@PathParam("groupKey") Long groupKey, @PathParam("identityKey") Long identityKey, @Context HttpServletRequest request) {
try {
if (!isGroupManager(request)) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
final UserRequest ureq = RestSecurityHelper.getUserRequest(request);
final BusinessGroupService bgs = CoreSpringFactory.getImpl(BusinessGroupService.class);
final BusinessGroup group = bgs.loadBusinessGroup(groupKey);
final Identity identity = BaseSecurityManager.getInstance().loadIdentityByKey(identityKey, false);
if (identity == null || group == null) {
return Response.serverError().status(Status.NOT_FOUND).build();
}
bgs.addOwners(ureq.getIdentity(), ureq.getUserSession().getRoles(), Collections.singletonList(identity), group, null);
return Response.ok().build();
} catch (Exception e) {
log.error("Trying to add an owner to a group", e);
return Response.serverError().status(Status.INTERNAL_SERVER_ERROR).build();
}
}
use of org.olat.group.BusinessGroupService in project openolat by klemens.
the class LearningGroupWebService method getNews.
/**
* Returns the news.
*
* @response.representation.401.doc The roles of the authenticated user are not sufficient
* @response.representation.404.doc The business group cannot be found or the news tool is not enabled
* @param groupKey The key of the group
* @param request The HTTP Request
* @return
*/
@GET
@Path("{groupKey}/news")
@Produces({ MediaType.TEXT_PLAIN })
public Response getNews(@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 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();
}
}
CollaborationTools tools = CollaborationToolsFactory.getInstance().getOrCreateCollaborationTools(bg);
if (tools.isToolEnabled(CollaborationTools.TOOL_NEWS)) {
String news = tools.lookupNews();
if (news == null) {
return Response.serverError().status(Status.NOT_FOUND).build();
}
return Response.ok(news).build();
} else {
return Response.serverError().status(Status.NOT_FOUND).build();
}
}
Aggregations