use of org.olat.repository.RepositoryManager in project OpenOLAT by OpenOLAT.
the class RepositorySearchController method doSearchForCopyableResourcesLimitType.
/**
* Do search for all resources that the user can copy either because he
* is the owner of the resource or because he has author rights and the resource
* is set to at least BA in the BARG settings and the resource has the flag
* 'canCopy' set to true.
* @param owner The current identity
* @param limitTypes List of Types to limit the search
* @param roles The users roles
*/
public void doSearchForCopyableResourcesLimitType(Identity owner, String[] limitTypes, Roles roles) {
RepositoryManager rm = RepositoryManager.getInstance();
List<String> restrictedTypes = new ArrayList<String>();
if (limitTypes == null) {
restrictedTypes = null;
} else {
restrictedTypes.addAll(Arrays.asList(limitTypes));
}
List<RepositoryEntry> entries = rm.queryCopyableResourcesLimitType(owner, roles, restrictedTypes, null, null, null);
filterRepositoryEntries(entries);
repoTableModel.setObjects(entries);
tableCtr.setFilters(null, null);
tableCtr.modelChanged();
displaySearchResults(null);
}
use of org.olat.repository.RepositoryManager in project OpenOLAT by OpenOLAT.
the class RepositorySearchController method doSearchMyCoursesTeacher.
private void doSearchMyCoursesTeacher(UserRequest ureq, String limitType, boolean updateFilters) {
searchType = SearchType.myAsTeacher;
RepositoryManager rm = RepositoryManager.getInstance();
List<RepositoryEntry> entries = rm.getLearningResourcesAsTeacher(ureq.getIdentity(), 0, -1);
filterRepositoryEntries(entries);
doSearchMyRepositoryEntries(ureq, entries, limitType, updateFilters);
}
use of org.olat.repository.RepositoryManager in project OpenOLAT by OpenOLAT.
the class RepositorySearchController method doSearch.
private void doSearch(UserRequest ureq, String limitType, boolean onlyOwner, boolean updateFilters) {
searchType = SearchType.searchForm;
RepositoryManager rm = RepositoryManager.getInstance();
Collection<String> s = searchForm.getRestrictedTypes();
List<String> restrictedTypes;
if (limitType != null) {
restrictedTypes = Collections.singletonList(limitType);
} else {
restrictedTypes = (s == null) ? null : new ArrayList<String>(s);
}
String author = searchForm.getAuthor();
String displayName = searchForm.getDisplayName();
String description = searchForm.getDescription();
SearchRepositoryEntryParameters params = new SearchRepositoryEntryParameters(displayName, author, description, restrictedTypes, getIdentity(), ureq.getUserSession().getRoles(), getIdentity().getUser().getProperty(UserConstants.INSTITUTIONALNAME, null));
params.setOnlyOwnedResources(onlyOwner);
List<RepositoryEntry> entries = rm.genericANDQueryWithRolesRestriction(params, 0, -1, true);
filterRepositoryEntries(entries);
repoTableModel.setObjects(entries);
if (updateFilters) {
updateFilters(entries, null);
}
tableCtr.modelChanged();
displaySearchResults(ureq);
}
use of org.olat.repository.RepositoryManager in project OpenOLAT by OpenOLAT.
the class CourseWebService method addCoaches.
@PUT
@Path("tutors")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response addCoaches(UserVO[] coaches, @Context HttpServletRequest httpRequest) {
if (!isAuthorEditor(course, httpRequest) && !isInstitutionalResourceManager(httpRequest)) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
List<Identity> coachList = loadIdentities(coaches);
Identity identity = getIdentity(httpRequest);
UserRequest ureq = getUserRequest(httpRequest);
// add the author as owner of the course
RepositoryManager rm = RepositoryManager.getInstance();
RepositoryEntry repositoryEntry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
IdentitiesAddEvent iae = new IdentitiesAddEvent(coachList);
rm.addTutors(identity, ureq.getUserSession().getRoles(), iae, repositoryEntry, new MailPackage(false));
return Response.ok().build();
}
use of org.olat.repository.RepositoryManager in project OpenOLAT by OpenOLAT.
the class CourseWebService method addParticipants.
/**
* Add an participant to the course
* @response.representation.200.doc The user is a participant of the course
* @response.representation.401.doc The roles of the authenticated user are not sufficient
* @response.representation.404.doc The course or the user not found
* @param identityKey The user identifier
* @param httpRequest The HTTP request
* @return It returns 200 if the user is added as owner and author of the course
*/
@PUT
@Path("participants")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response addParticipants(UserVO[] participants, @Context HttpServletRequest httpRequest) {
if (!isAuthorEditor(course, httpRequest) && !isInstitutionalResourceManager(httpRequest)) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
List<Identity> participantList = loadIdentities(participants);
Identity identity = getIdentity(httpRequest);
UserRequest ureq = getUserRequest(httpRequest);
// add the participants to the course
RepositoryManager rm = RepositoryManager.getInstance();
RepositoryEntry repositoryEntry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
IdentitiesAddEvent iae = new IdentitiesAddEvent(participantList);
rm.addParticipants(identity, ureq.getUserSession().getRoles(), iae, repositoryEntry, new MailPackage(false));
return Response.ok().build();
}
Aggregations