Search in sources :

Example 71 with RepositoryManager

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);
}
Also used : ArrayList(java.util.ArrayList) RepositoryManager(org.olat.repository.RepositoryManager) RepositoryEntry(org.olat.repository.RepositoryEntry)

Example 72 with RepositoryManager

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);
}
Also used : RepositoryManager(org.olat.repository.RepositoryManager) RepositoryEntry(org.olat.repository.RepositoryEntry)

Example 73 with RepositoryManager

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);
}
Also used : SearchRepositoryEntryParameters(org.olat.repository.model.SearchRepositoryEntryParameters) ArrayList(java.util.ArrayList) RepositoryManager(org.olat.repository.RepositoryManager) RepositoryEntry(org.olat.repository.RepositoryEntry)

Example 74 with RepositoryManager

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();
}
Also used : MailPackage(org.olat.core.util.mail.MailPackage) IdentitiesAddEvent(org.olat.admin.securitygroup.gui.IdentitiesAddEvent) RepositoryManager(org.olat.repository.RepositoryManager) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) RestSecurityHelper.getIdentity(org.olat.restapi.security.RestSecurityHelper.getIdentity) RestSecurityHelper.getUserRequest(org.olat.restapi.security.RestSecurityHelper.getUserRequest) UserRequest(org.olat.core.gui.UserRequest) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) PUT(javax.ws.rs.PUT)

Example 75 with RepositoryManager

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();
}
Also used : MailPackage(org.olat.core.util.mail.MailPackage) IdentitiesAddEvent(org.olat.admin.securitygroup.gui.IdentitiesAddEvent) RepositoryManager(org.olat.repository.RepositoryManager) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) RestSecurityHelper.getIdentity(org.olat.restapi.security.RestSecurityHelper.getIdentity) RestSecurityHelper.getUserRequest(org.olat.restapi.security.RestSecurityHelper.getUserRequest) UserRequest(org.olat.core.gui.UserRequest) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) PUT(javax.ws.rs.PUT)

Aggregations

RepositoryManager (org.olat.repository.RepositoryManager)136 RepositoryEntry (org.olat.repository.RepositoryEntry)122 Path (javax.ws.rs.Path)42 Identity (org.olat.core.id.Identity)32 Produces (javax.ws.rs.Produces)30 Roles (org.olat.core.id.Roles)30 RestSecurityHelper.getIdentity (org.olat.restapi.security.RestSecurityHelper.getIdentity)26 ArrayList (java.util.ArrayList)20 Consumes (javax.ws.rs.Consumes)20 PUT (javax.ws.rs.PUT)18 MailPackage (org.olat.core.util.mail.MailPackage)16 GET (javax.ws.rs.GET)14 BaseSecurity (org.olat.basesecurity.BaseSecurity)14 AssertException (org.olat.core.logging.AssertException)14 SearchRepositoryEntryParameters (org.olat.repository.model.SearchRepositoryEntryParameters)14 IdentitiesAddEvent (org.olat.admin.securitygroup.gui.IdentitiesAddEvent)12 Controller (org.olat.core.gui.control.Controller)12 OLATResourceable (org.olat.core.id.OLATResourceable)12 UserRequest (org.olat.core.gui.UserRequest)10 WindowControl (org.olat.core.gui.control.WindowControl)10