Search in sources :

Example 1 with SearchRepositoryEntryParameters

use of org.olat.repository.model.SearchRepositoryEntryParameters in project OpenOLAT by OpenOLAT.

the class WikisWebService method getAccessibleWikiRepositoryEntries.

/**
 * returns all accessiblewikiRepositoryEntries of type wiki
 *
 * @param httpRequest
 * @return
 */
private static List<RepositoryEntry> getAccessibleWikiRepositoryEntries(HttpServletRequest httpRequest) {
    Roles roles = getRoles(httpRequest);
    Identity identity = getIdentity(httpRequest);
    RepositoryManager rm = RepositoryManager.getInstance();
    SearchRepositoryEntryParameters params = new SearchRepositoryEntryParameters(identity, roles, new String[] { WikiResource.TYPE_NAME });
    List<RepositoryEntry> res = rm.genericANDQueryWithRolesRestriction(params, 0, -1, true);
    return res;
}
Also used : SearchRepositoryEntryParameters(org.olat.repository.model.SearchRepositoryEntryParameters) RestSecurityHelper.getRoles(org.olat.restapi.security.RestSecurityHelper.getRoles) Roles(org.olat.core.id.Roles) RepositoryManager(org.olat.repository.RepositoryManager) RepositoryEntry(org.olat.repository.RepositoryEntry) RestSecurityHelper.getIdentity(org.olat.restapi.security.RestSecurityHelper.getIdentity) Identity(org.olat.core.id.Identity)

Example 2 with SearchRepositoryEntryParameters

use of org.olat.repository.model.SearchRepositoryEntryParameters in project OpenOLAT by OpenOLAT.

the class RepositoryManagerQueryTest method testOneShootQueryWithAuthorRole.

@Test
public void testOneShootQueryWithAuthorRole() {
    List<String> types = Collections.singletonList(TEST_RES_NAME);
    // roles: author + institution manager
    Roles role2 = new Roles(false, false, false, true, false, false, false);
    SearchRepositoryEntryParameters params = new SearchRepositoryEntryParameters(null, null, null, types, null, role2, null);
    List<RepositoryEntry> resultOneShoot = rm.genericANDQueryWithRolesRestriction(params, 0, -1, true);
    assertNotNull(resultOneShoot);
    assertFalse(resultOneShoot.isEmpty());
}
Also used : SearchRepositoryEntryParameters(org.olat.repository.model.SearchRepositoryEntryParameters) Roles(org.olat.core.id.Roles) Test(org.junit.Test)

Example 3 with SearchRepositoryEntryParameters

use of org.olat.repository.model.SearchRepositoryEntryParameters in project OpenOLAT by OpenOLAT.

the class RepositoryManagerQueryTest method testOneShootWithInstitutionAndSearchByAuthorName.

@Test
public void testOneShootWithInstitutionAndSearchByAuthorName() {
    List<String> types = Collections.singletonList(TEST_RES_NAME);
    // roles: institution manager search: authorname
    Roles role4 = new Roles(false, false, false, false, false, true, false);
    SearchRepositoryEntryParameters params = new SearchRepositoryEntryParameters(null, "kan", null, types, null, role4, "Volks");
    List<RepositoryEntry> resultOneShootInstitut4 = rm.genericANDQueryWithRolesRestriction(params, 0, -1, true);
    assertNotNull(resultOneShootInstitut4);
    assertFalse(resultOneShootInstitut4.isEmpty());
}
Also used : SearchRepositoryEntryParameters(org.olat.repository.model.SearchRepositoryEntryParameters) Roles(org.olat.core.id.Roles) Test(org.junit.Test)

Example 4 with SearchRepositoryEntryParameters

use of org.olat.repository.model.SearchRepositoryEntryParameters in project OpenOLAT by OpenOLAT.

the class RepositoryManagerTest method genericANDQueryWithRoles_byauthor.

@Test
public void genericANDQueryWithRoles_byauthor() {
    Identity owner = JunitTestHelper.createAndPersistIdentityAsRndUser("author-re-");
    RepositoryEntry re = JunitTestHelper.createAndPersistRepositoryEntry();
    repositoryEntryRelationDao.addRole(owner, re, GroupRoles.owner.name());
    dbInstance.commitAndCloseSession();
    SearchRepositoryEntryParameters params = new SearchRepositoryEntryParameters();
    params.setRoles(new Roles(true, false, false, false, false, false, false));
    params.setAuthor(owner.getName());
    List<RepositoryEntry> myEntries = repositoryManager.genericANDQueryWithRolesRestriction(params, 0, -1, true);
    Assert.assertNotNull(myEntries);
    Assert.assertEquals(1, myEntries.size());
    Assert.assertTrue(myEntries.contains(re));
}
Also used : SearchRepositoryEntryParameters(org.olat.repository.model.SearchRepositoryEntryParameters) GroupRoles(org.olat.basesecurity.GroupRoles) Roles(org.olat.core.id.Roles) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 5 with SearchRepositoryEntryParameters

use of org.olat.repository.model.SearchRepositoryEntryParameters in project OpenOLAT by OpenOLAT.

the class RepositoryManagerTest method genericANDQueryWithRoles_managed.

@Test
public void genericANDQueryWithRoles_managed() {
    RepositoryEntry managedRe = JunitTestHelper.createAndPersistRepositoryEntry();
    managedRe.setManagedFlagsString("all");
    managedRe = dbInstance.getCurrentEntityManager().merge(managedRe);
    RepositoryEntry freeRe = JunitTestHelper.createAndPersistRepositoryEntry();
    dbInstance.commitAndCloseSession();
    // search managed
    SearchRepositoryEntryParameters paramsManaged = new SearchRepositoryEntryParameters();
    paramsManaged.setRoles(new Roles(true, false, false, false, false, false, false));
    paramsManaged.setManaged(Boolean.TRUE);
    List<RepositoryEntry> managedEntries = repositoryManager.genericANDQueryWithRolesRestriction(paramsManaged, 0, -1, true);
    Assert.assertNotNull(managedEntries);
    Assert.assertTrue(managedEntries.size() > 0);
    Assert.assertTrue(managedEntries.contains(managedRe));
    Assert.assertFalse(managedEntries.contains(freeRe));
    // search unmanaged
    SearchRepositoryEntryParameters paramsFree = new SearchRepositoryEntryParameters();
    paramsFree.setRoles(new Roles(true, false, false, false, false, false, false));
    paramsFree.setManaged(Boolean.FALSE);
    List<RepositoryEntry> freeEntries = repositoryManager.genericANDQueryWithRolesRestriction(paramsFree, 0, -1, true);
    Assert.assertNotNull(freeEntries);
    Assert.assertTrue(freeEntries.size() > 0);
    Assert.assertFalse(freeEntries.contains(managedRe));
    Assert.assertTrue(freeEntries.contains(freeRe));
}
Also used : SearchRepositoryEntryParameters(org.olat.repository.model.SearchRepositoryEntryParameters) GroupRoles(org.olat.basesecurity.GroupRoles) Roles(org.olat.core.id.Roles) Test(org.junit.Test)

Aggregations

SearchRepositoryEntryParameters (org.olat.repository.model.SearchRepositoryEntryParameters)58 Roles (org.olat.core.id.Roles)54 RepositoryEntry (org.olat.repository.RepositoryEntry)38 Test (org.junit.Test)24 Identity (org.olat.core.id.Identity)24 GroupRoles (org.olat.basesecurity.GroupRoles)18 RepositoryManager (org.olat.repository.RepositoryManager)14 RestSecurityHelper.getIdentity (org.olat.restapi.security.RestSecurityHelper.getIdentity)12 RestSecurityHelper.getRoles (org.olat.restapi.security.RestSecurityHelper.getRoles)12 ArrayList (java.util.ArrayList)10 GET (javax.ws.rs.GET)10 Produces (javax.ws.rs.Produces)10 CorruptedCourseException (org.olat.course.CorruptedCourseException)10 WebApplicationException (javax.ws.rs.WebApplicationException)8 ICourse (org.olat.course.ICourse)8 BusinessGroup (org.olat.group.BusinessGroup)6 URI (java.net.URI)4 CourseConfig (org.olat.course.config.CourseConfig)4 Date (java.util.Date)2 HashMap (java.util.HashMap)2