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;
}
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());
}
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());
}
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));
}
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));
}
Aggregations