Search in sources :

Example 11 with SearchRepositoryEntryParameters

use of org.olat.repository.model.SearchRepositoryEntryParameters in project openolat by klemens.

the class RepositoryManagerQueryTest method testOneShootWithInstitution.

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

Example 12 with SearchRepositoryEntryParameters

use of org.olat.repository.model.SearchRepositoryEntryParameters in project openolat by klemens.

the class RepositoryManagerQueryTest method testOneShootQueryPaging.

@Test
public void testOneShootQueryPaging() {
    List<String> types = Collections.singletonList(TEST_RES_NAME);
    // roles: institution manager search: authorname
    Roles role4 = new Roles(false, false, false, false, false, true, false);
    // test paging
    SearchRepositoryEntryParameters params = new SearchRepositoryEntryParameters(null, "kan", null, types, null, role4, "Volks");
    List<RepositoryEntry> resultOneShootInstitut6 = rm.genericANDQueryWithRolesRestriction(params, 0, 50, true);
    rm.countGenericANDQueryWithRolesRestriction(params);
    assertNotNull(resultOneShootInstitut6);
    assertEquals(50, resultOneShootInstitut6.size());
}
Also used : SearchRepositoryEntryParameters(org.olat.repository.model.SearchRepositoryEntryParameters) Roles(org.olat.core.id.Roles) Test(org.junit.Test)

Example 13 with SearchRepositoryEntryParameters

use of org.olat.repository.model.SearchRepositoryEntryParameters in project openolat by klemens.

the class RepositoryManagerQueryTest method testOneShootQueryWithRoles.

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

Example 14 with SearchRepositoryEntryParameters

use of org.olat.repository.model.SearchRepositoryEntryParameters in project openolat by klemens.

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 15 with SearchRepositoryEntryParameters

use of org.olat.repository.model.SearchRepositoryEntryParameters in project openolat by klemens.

the class RepositoryManagerTest method genericANDQueryWithRolesWithStandardUser.

@Test
public void genericANDQueryWithRolesWithStandardUser() {
    // create 2 identities (repo owner and tutor)
    Identity id1 = JunitTestHelper.createAndPersistIdentityAsUser("re-gen-1-" + UUID.randomUUID().toString());
    Identity id2 = JunitTestHelper.createAndPersistIdentityAsUser("re-gen-2-" + UUID.randomUUID().toString());
    RepositoryEntry re1 = JunitTestHelper.createAndPersistRepositoryEntry();
    RepositoryEntry re2 = JunitTestHelper.createAndPersistRepositoryEntry(true);
    repositoryEntryRelationDao.addRole(id1, re2, GroupRoles.participant.name());
    BusinessGroup group = businessGroupService.createBusinessGroup(null, "teacherg", "tg", null, null, false, false, re1);
    businessGroupRelationDao.addRole(id2, group, GroupRoles.participant.name());
    dbInstance.commitAndCloseSession();
    // check for guest (negative test)
    SearchRepositoryEntryParameters params1 = new SearchRepositoryEntryParameters();
    params1.setRoles(new Roles(false, false, false, false, true, false, false));
    List<RepositoryEntry> entries1 = repositoryManager.genericANDQueryWithRolesRestriction(params1, 0, -1, true);
    Assert.assertNotNull(entries1);
    Assert.assertFalse(entries1.contains(re1));
    Assert.assertFalse(entries1.contains(re2));
    for (RepositoryEntry entry : entries1) {
        Assert.assertTrue(entry.getAccess() >= RepositoryEntry.ACC_USERS_GUESTS);
    }
    // check for identity 1 (participant re2 + re1 accessible to all users)
    SearchRepositoryEntryParameters params2 = new SearchRepositoryEntryParameters();
    params2.setIdentity(id1);
    params2.setRoles(new Roles(false, false, false, false, false, false, false));
    List<RepositoryEntry> entries2 = repositoryManager.genericANDQueryWithRolesRestriction(params2, 0, -1, true);
    Assert.assertNotNull(entries2);
    Assert.assertFalse(entries2.isEmpty());
    Assert.assertTrue(entries2.contains(re1));
    Assert.assertTrue(entries2.contains(re2));
    for (RepositoryEntry entry : entries2) {
        if (!entry.equals(re2)) {
            Assert.assertTrue(entry.getAccess() >= RepositoryEntry.ACC_USERS);
        }
    }
    // check for identity 1 (re1 accessible to all users)
    SearchRepositoryEntryParameters params3 = new SearchRepositoryEntryParameters();
    params3.setIdentity(id2);
    params3.setRoles(new Roles(false, false, false, false, false, false, false));
    List<RepositoryEntry> entries3 = repositoryManager.genericANDQueryWithRolesRestriction(params3, 0, -1, true);
    Assert.assertNotNull(entries3);
    Assert.assertFalse(entries3.isEmpty());
    Assert.assertTrue(entries3.contains(re1));
    Assert.assertFalse(entries3.contains(re2));
    for (RepositoryEntry entry : entries3) {
        Assert.assertTrue(entry.getAccess() >= RepositoryEntry.ACC_USERS);
    }
}
Also used : SearchRepositoryEntryParameters(org.olat.repository.model.SearchRepositoryEntryParameters) BusinessGroup(org.olat.group.BusinessGroup) GroupRoles(org.olat.basesecurity.GroupRoles) Roles(org.olat.core.id.Roles) Identity(org.olat.core.id.Identity) 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