use of org.olat.group.BusinessGroupService in project OpenOLAT by OpenOLAT.
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();
}
}
use of org.olat.group.BusinessGroupService in project OpenOLAT by OpenOLAT.
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 OpenOLAT.
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;
}
use of org.olat.group.BusinessGroupService in project OpenOLAT by OpenOLAT.
the class LearningGroupWebService method deleteGroup.
/**
* Deletes the business group specified by the groupKey.
* @response.representation.200.doc The business group is deleted
* @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 request The HTTP request
* @return
*/
@DELETE
@Path("{groupKey}")
public Response deleteGroup(@PathParam("groupKey") Long groupKey, @Context HttpServletRequest request) {
if (!isGroupManager(request)) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
BusinessGroupService bgs = CoreSpringFactory.getImpl(BusinessGroupService.class);
BusinessGroup bg = bgs.loadBusinessGroup(groupKey);
if (bg == null) {
return Response.serverError().status(Status.NOT_FOUND).build();
}
bgs.deleteBusinessGroup(bg);
return Response.ok().build();
}
use of org.olat.group.BusinessGroupService in project OpenOLAT by OpenOLAT.
the class LearningGroupWebService method getTutors.
/**
* Returns the list of owners 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 Owners 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}/owners")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getTutors(@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.isOwnersVisibleIntern()) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
}
List<Identity> coaches = CoreSpringFactory.getImpl(BusinessGroupService.class).getMembers(bg, GroupRoles.coach.name());
return getIdentityInGroup(coaches);
}
Aggregations