use of org.olat.repository.RepositoryService in project OpenOLAT by OpenOLAT.
the class SearchUserToolExtension method createUserTool.
@Override
public UserTool createUserTool(UserRequest ureq, WindowControl wControl, Locale locale) {
boolean canSearch = isEnabled();
if (canSearch && isSearchOnlyHasInternalSiteMember()) {
String softKey = getInternalSiteSoftKey();
RepositoryEntry repoEntry = RepositoryManager.getInstance().lookupRepositoryEntryBySoftkey(softKey, false);
if (repoEntry != null) {
RepositoryService contextManager = CoreSpringFactory.getImpl(RepositoryService.class);
canSearch = contextManager.isMember(ureq.getUserSession().getIdentity(), repoEntry);
}
}
return canSearch ? new SearchUserTool(wControl) : null;
}
use of org.olat.repository.RepositoryService in project OpenOLAT by OpenOLAT.
the class CourseWebService method getTutors.
/**
* Get all coaches of the course (don't follow the groups)
* @response.representation.200.qname {http://www.example.com}userVO
* @response.representation.200.mediaType application/xml, application/json
* @response.representation.200.doc The array of coaches
* @response.representation.401.doc The roles of the authenticated user are not sufficient
* @response.representation.404.doc The course not found
* @param httpRequest The HTTP request
* @return It returns an array of <code>UserVO</code>
*/
@GET
@Path("tutors")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getTutors(@Context HttpServletRequest httpRequest) {
if (!isAuthorEditor(course, httpRequest) && !isInstitutionalResourceManager(httpRequest)) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
RepositoryEntry repositoryEntry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
RepositoryService repositoryService = CoreSpringFactory.getImpl(RepositoryService.class);
List<Identity> coachList = repositoryService.getMembers(repositoryEntry, GroupRoles.coach.name());
int count = 0;
UserVO[] coaches = new UserVO[coachList.size()];
for (Identity coach : coachList) {
coaches[count++] = UserVOFactory.get(coach);
}
return Response.ok(coaches).build();
}
use of org.olat.repository.RepositoryService in project OpenOLAT by OpenOLAT.
the class CourseWebService method getParticipants.
/**
* Get all participants of the course (don't follow the groups)
* @response.representation.200.qname {http://www.example.com}userVO
* @response.representation.200.mediaType application/xml, application/json
* @response.representation.200.doc The array of participants
* @response.representation.401.doc The roles of the authenticated user are not sufficient
* @response.representation.404.doc The course not found
* @param httpRequest The HTTP request
* @return It returns an array of <code>UserVO</code>
*/
@GET
@Path("participants")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getParticipants(@Context HttpServletRequest httpRequest) {
if (!isAuthorEditor(course, httpRequest) && !isInstitutionalResourceManager(httpRequest)) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
RepositoryEntry repositoryEntry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
RepositoryService repositoryService = CoreSpringFactory.getImpl(RepositoryService.class);
List<Identity> participantList = repositoryService.getMembers(repositoryEntry, GroupRoles.participant.name());
int count = 0;
UserVO[] participants = new UserVO[participantList.size()];
for (Identity participant : participantList) {
participants[count++] = UserVOFactory.get(participant);
}
return Response.ok(participants).build();
}
use of org.olat.repository.RepositoryService in project OpenOLAT by OpenOLAT.
the class CourseWebService method getAuthor.
/**
* Get this specific author and owner of the course
* @response.representation.200.qname {http://www.example.com}userVO
* @response.representation.200.mediaType application/xml, application/json
* @response.representation.200.doc The author
* @response.representation.401.doc The roles of the authenticated user are not sufficient
* @response.representation.404.doc The course not found or the user is not an onwer or author of the course
* @param identityKey The user identifier
* @param httpRequest The HTTP request
* @return It returns an <code>UserVO</code>
*/
@GET
@Path("authors/{identityKey}")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getAuthor(@PathParam("identityKey") Long identityKey, @Context HttpServletRequest httpRequest) {
if (!isAuthorEditor(course, httpRequest) && !isInstitutionalResourceManager(httpRequest)) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
RepositoryService repositoryService = CoreSpringFactory.getImpl(RepositoryService.class);
RepositoryEntry repositoryEntry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
BaseSecurity securityManager = BaseSecurityManager.getInstance();
SecurityGroup authorGroup = securityManager.findSecurityGroupByName(Constants.GROUP_AUTHORS);
Identity author = securityManager.loadIdentityByKey(identityKey, false);
if (repositoryService.hasRole(author, repositoryEntry, GroupRoles.owner.name()) && securityManager.isIdentityInSecurityGroup(author, authorGroup)) {
UserVO vo = UserVOFactory.get(author);
return Response.ok(vo).build();
}
return Response.ok(author).build();
}
use of org.olat.repository.RepositoryService in project OpenOLAT by OpenOLAT.
the class CourseWebService method getAuthors.
/**
* Get all owners and authors of the course
* @response.representation.200.qname {http://www.example.com}userVO
* @response.representation.200.mediaType application/xml, application/json
* @response.representation.200.doc The array of authors
* @response.representation.401.doc The roles of the authenticated user are not sufficient
* @response.representation.404.doc The course not found
* @param httpRequest The HTTP request
* @return It returns an array of <code>UserVO</code>
*/
@GET
@Path("authors")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getAuthors(@Context HttpServletRequest httpRequest) {
if (!isAuthorEditor(course, httpRequest) && !isInstitutionalResourceManager(httpRequest)) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
RepositoryEntry repositoryEntry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
RepositoryService repositoryService = CoreSpringFactory.getImpl(RepositoryService.class);
List<Identity> owners = repositoryService.getMembers(repositoryEntry, GroupRoles.owner.name());
int count = 0;
UserVO[] authors = new UserVO[owners.size()];
for (Identity owner : owners) {
authors[count++] = UserVOFactory.get(owner);
}
return Response.ok(authors).build();
}
Aggregations