Skip to content
Snippets Groups Projects
Commit 1d99226d authored by uhensler's avatar uhensler
Browse files

OO-3605: Restrict to share a question only in a pool with access rights

parent aafc7c4c
No related branches found
No related tags found
No related merge requests found
...@@ -92,7 +92,7 @@ public class PoolDAO { ...@@ -92,7 +92,7 @@ public class PoolDAO {
public int removeFromPool(List<QuestionItemShort> items, Pool pool) { public int removeFromPool(List<QuestionItemShort> items, Pool pool) {
if(items == null || items.isEmpty()) return 0; if(items == null || items.isEmpty()) return 0;
List<Long> keys = new ArrayList<Long>(); List<Long> keys = new ArrayList<>();
for(QuestionItemShort item:items) { for(QuestionItemShort item:items) {
keys.add(item.getKey()); keys.add(item.getKey());
} }
......
...@@ -363,7 +363,7 @@ public class QuestionPoolServiceImpl implements QPoolService { ...@@ -363,7 +363,7 @@ public class QuestionPoolServiceImpl implements QPoolService {
private List<Long> toKeys(List<? extends QuestionItemShort> items) { private List<Long> toKeys(List<? extends QuestionItemShort> items) {
if(items == null || items.isEmpty()) return Collections.emptyList(); if(items == null || items.isEmpty()) return Collections.emptyList();
List<Long> keys = new ArrayList<Long>(items.size()); List<Long> keys = new ArrayList<>(items.size());
for(QuestionItemShort item:items) { for(QuestionItemShort item:items) {
keys.add(item.getKey()); keys.add(item.getKey());
} }
...@@ -502,7 +502,7 @@ public class QuestionPoolServiceImpl implements QPoolService { ...@@ -502,7 +502,7 @@ public class QuestionPoolServiceImpl implements QPoolService {
return;//nothing to do return;//nothing to do
} }
List<SecurityGroup> secGroups = new ArrayList<SecurityGroup>(pools.size()); List<SecurityGroup> secGroups = new ArrayList<>(pools.size());
for(Pool pool:pools) { for(Pool pool:pools) {
SecurityGroup secGroup = ((PoolImpl)pool).getOwnerGroup(); SecurityGroup secGroup = ((PoolImpl)pool).getOwnerGroup();
secGroups.add(secGroup); secGroups.add(secGroup);
...@@ -607,7 +607,7 @@ public class QuestionPoolServiceImpl implements QPoolService { ...@@ -607,7 +607,7 @@ public class QuestionPoolServiceImpl implements QPoolService {
if(searchParams.isFulltextSearch()) { if(searchParams.isFulltextSearch()) {
try { try {
String queryString = searchParams.getSearchString(); String queryString = searchParams.getSearchString();
List<String> condQueries = new ArrayList<String>(); List<String> condQueries = new ArrayList<>();
if(searchParams.getCondQueries() != null) { if(searchParams.getCondQueries() != null) {
condQueries.addAll(searchParams.getCondQueries()); condQueries.addAll(searchParams.getCondQueries());
} }
...@@ -616,17 +616,17 @@ public class QuestionPoolServiceImpl implements QPoolService { ...@@ -616,17 +616,17 @@ public class QuestionPoolServiceImpl implements QPoolService {
searchParams.getIdentity(), searchParams.getRoles(), 0, MAX_NUMBER_DOCS); searchParams.getIdentity(), searchParams.getRoles(), 0, MAX_NUMBER_DOCS);
if(results.isEmpty()) { if(results.isEmpty()) {
return new DefaultResultInfos<QuestionItemView>(); return new DefaultResultInfos<>();
} }
List<QuestionItemView> items = itemQueriesDao.getItemsOfPool(searchParams, results, firstResult, maxResults, orderBy); List<QuestionItemView> items = itemQueriesDao.getItemsOfPool(searchParams, results, firstResult, maxResults, orderBy);
return new DefaultResultInfos<QuestionItemView>(firstResult + items.size(), results.size(), items); return new DefaultResultInfos<>(firstResult + items.size(), results.size(), items);
} catch (Exception e) { } catch (Exception e) {
log.error("", e); log.error("", e);
} }
return new DefaultResultInfos<QuestionItemView>(); return new DefaultResultInfos<>();
} else { } else {
List<QuestionItemView> items = itemQueriesDao.getItemsOfPool(searchParams, searchParams.getItemKeys(), firstResult, maxResults, orderBy); List<QuestionItemView> items = itemQueriesDao.getItemsOfPool(searchParams, searchParams.getItemKeys(), firstResult, maxResults, orderBy);
return new DefaultResultInfos<QuestionItemView>(firstResult + items.size(), -1, items); return new DefaultResultInfos<>(firstResult + items.size(), -1, items);
} }
} }
...@@ -635,7 +635,7 @@ public class QuestionPoolServiceImpl implements QPoolService { ...@@ -635,7 +635,7 @@ public class QuestionPoolServiceImpl implements QPoolService {
if(searchParams.isFulltextSearch()) { if(searchParams.isFulltextSearch()) {
try { try {
String queryString = searchParams.getSearchString(); String queryString = searchParams.getSearchString();
List<String> condQueries = new ArrayList<String>(); List<String> condQueries = new ArrayList<>();
if(searchParams.getCondQueries() != null) { if(searchParams.getCondQueries() != null) {
condQueries.addAll(searchParams.getCondQueries()); condQueries.addAll(searchParams.getCondQueries());
} }
...@@ -644,17 +644,17 @@ public class QuestionPoolServiceImpl implements QPoolService { ...@@ -644,17 +644,17 @@ public class QuestionPoolServiceImpl implements QPoolService {
searchParams.getIdentity(), searchParams.getRoles(), 0, MAX_NUMBER_DOCS); searchParams.getIdentity(), searchParams.getRoles(), 0, MAX_NUMBER_DOCS);
if(results.isEmpty()) { if(results.isEmpty()) {
return new DefaultResultInfos<QuestionItemView>(); return new DefaultResultInfos<>();
} }
List<QuestionItemView> items = itemQueriesDao.getItemsByAuthor(searchParams, results, firstResult, maxResults, orderBy); List<QuestionItemView> items = itemQueriesDao.getItemsByAuthor(searchParams, results, firstResult, maxResults, orderBy);
return new DefaultResultInfos<QuestionItemView>(firstResult + items.size(), results.size(), items); return new DefaultResultInfos<>(firstResult + items.size(), results.size(), items);
} catch (Exception e) { } catch (Exception e) {
log.error("", e); log.error("", e);
} }
return new DefaultResultInfos<QuestionItemView>(); return new DefaultResultInfos<>();
} else { } else {
List<QuestionItemView> items = itemQueriesDao.getItemsByAuthor(searchParams, searchParams.getItemKeys(), firstResult, maxResults, orderBy); List<QuestionItemView> items = itemQueriesDao.getItemsByAuthor(searchParams, searchParams.getItemKeys(), firstResult, maxResults, orderBy);
return new DefaultResultInfos<QuestionItemView>(firstResult + items.size(), -1, items); return new DefaultResultInfos<>(firstResult + items.size(), -1, items);
} }
} }
...@@ -675,7 +675,7 @@ public class QuestionPoolServiceImpl implements QPoolService { ...@@ -675,7 +675,7 @@ public class QuestionPoolServiceImpl implements QPoolService {
List<Long> favoritKeys = questionItemDao.getFavoritKeys(searchParams.getIdentity()); List<Long> favoritKeys = questionItemDao.getFavoritKeys(searchParams.getIdentity());
String queryString = searchParams.getSearchString(); String queryString = searchParams.getSearchString();
List<String> condQueries = new ArrayList<String>(); List<String> condQueries = new ArrayList<>();
if(searchParams.getCondQueries() != null) { if(searchParams.getCondQueries() != null) {
condQueries.addAll(searchParams.getCondQueries()); condQueries.addAll(searchParams.getCondQueries());
} }
...@@ -684,17 +684,17 @@ public class QuestionPoolServiceImpl implements QPoolService { ...@@ -684,17 +684,17 @@ public class QuestionPoolServiceImpl implements QPoolService {
searchParams.getIdentity(), searchParams.getRoles(), 0, MAX_NUMBER_DOCS); searchParams.getIdentity(), searchParams.getRoles(), 0, MAX_NUMBER_DOCS);
if(results.isEmpty()) { if(results.isEmpty()) {
return new DefaultResultInfos<QuestionItemView>(); return new DefaultResultInfos<>();
} }
List<QuestionItemView> items = itemQueriesDao.getFavoritItems(searchParams, results, firstResult, maxResults, orderBy); List<QuestionItemView> items = itemQueriesDao.getFavoritItems(searchParams, results, firstResult, maxResults, orderBy);
return new DefaultResultInfos<QuestionItemView>(firstResult + items.size(), results.size(), items); return new DefaultResultInfos<>(firstResult + items.size(), results.size(), items);
} catch (Exception e) { } catch (Exception e) {
log.error("", e); log.error("", e);
} }
return new DefaultResultInfos<QuestionItemView>(); return new DefaultResultInfos<>();
} else { } else {
List<QuestionItemView> items = itemQueriesDao.getFavoritItems(searchParams, searchParams.getItemKeys(), firstResult, maxResults, orderBy); List<QuestionItemView> items = itemQueriesDao.getFavoritItems(searchParams, searchParams.getItemKeys(), firstResult, maxResults, orderBy);
return new DefaultResultInfos<QuestionItemView>(firstResult + items.size(), -1, items); return new DefaultResultInfos<>(firstResult + items.size(), -1, items);
} }
} }
...@@ -719,7 +719,7 @@ public class QuestionPoolServiceImpl implements QPoolService { ...@@ -719,7 +719,7 @@ public class QuestionPoolServiceImpl implements QPoolService {
return;//nothing to do return;//nothing to do
} }
List<OLATResource> resources = new ArrayList<OLATResource>(groups.size()); List<OLATResource> resources = new ArrayList<>(groups.size());
for(BusinessGroup group:groups) { for(BusinessGroup group:groups) {
resources.add(group.getResource()); resources.add(group.getResource());
} }
...@@ -752,7 +752,7 @@ public class QuestionPoolServiceImpl implements QPoolService { ...@@ -752,7 +752,7 @@ public class QuestionPoolServiceImpl implements QPoolService {
if(searchParams != null && searchParams.isFulltextSearch()) { if(searchParams != null && searchParams.isFulltextSearch()) {
try { try {
String queryString = searchParams.getSearchString(); String queryString = searchParams.getSearchString();
List<String> condQueries = new ArrayList<String>(); List<String> condQueries = new ArrayList<>();
if(searchParams.getCondQueries() != null) { if(searchParams.getCondQueries() != null) {
condQueries.addAll(searchParams.getCondQueries()); condQueries.addAll(searchParams.getCondQueries());
} }
...@@ -760,11 +760,11 @@ public class QuestionPoolServiceImpl implements QPoolService { ...@@ -760,11 +760,11 @@ public class QuestionPoolServiceImpl implements QPoolService {
List<Long> results = searchClient.doSearch(queryString, condQueries, List<Long> results = searchClient.doSearch(queryString, condQueries,
searchParams.getIdentity(), searchParams.getRoles(), 0, MAX_NUMBER_DOCS); searchParams.getIdentity(), searchParams.getRoles(), 0, MAX_NUMBER_DOCS);
if(results.isEmpty()) { if(results.isEmpty()) {
return new DefaultResultInfos<QuestionItemView>(); return new DefaultResultInfos<>();
} }
List<QuestionItemView> items = itemQueriesDao.getSharedItemByResource(searchParams.getIdentity(), resource, results, List<QuestionItemView> items = itemQueriesDao.getSharedItemByResource(searchParams.getIdentity(), resource, results,
searchParams.getFormat(), firstResult, maxResults); searchParams.getFormat(), firstResult, maxResults);
return new DefaultResultInfos<QuestionItemView>(firstResult + items.size(), results.size(), items); return new DefaultResultInfos<>(firstResult + items.size(), results.size(), items);
} catch (Exception e) { } catch (Exception e) {
log.error("", e); log.error("", e);
} }
...@@ -772,7 +772,7 @@ public class QuestionPoolServiceImpl implements QPoolService { ...@@ -772,7 +772,7 @@ public class QuestionPoolServiceImpl implements QPoolService {
} else { } else {
List<QuestionItemView> items = itemQueriesDao.getSharedItemByResource(searchParams.getIdentity(), resource, null, List<QuestionItemView> items = itemQueriesDao.getSharedItemByResource(searchParams.getIdentity(), resource, null,
searchParams.getFormat(), firstResult, maxResults, orderBy); searchParams.getFormat(), firstResult, maxResults, orderBy);
return new DefaultResultInfos<QuestionItemView>(firstResult + items.size(), -1, items); return new DefaultResultInfos<>(firstResult + items.size(), -1, items);
} }
} }
...@@ -836,7 +836,7 @@ public class QuestionPoolServiceImpl implements QPoolService { ...@@ -836,7 +836,7 @@ public class QuestionPoolServiceImpl implements QPoolService {
try { try {
List<Long> content = collectionDao.getItemKeysOfCollection(collection); List<Long> content = collectionDao.getItemKeysOfCollection(collection);
String queryString = searchParams.getSearchString(); String queryString = searchParams.getSearchString();
List<String> condQueries = new ArrayList<String>(); List<String> condQueries = new ArrayList<>();
if(searchParams.getCondQueries() != null) { if(searchParams.getCondQueries() != null) {
condQueries.addAll(searchParams.getCondQueries()); condQueries.addAll(searchParams.getCondQueries());
} }
...@@ -845,19 +845,19 @@ public class QuestionPoolServiceImpl implements QPoolService { ...@@ -845,19 +845,19 @@ public class QuestionPoolServiceImpl implements QPoolService {
searchParams.getIdentity(), searchParams.getRoles(), 0, MAX_NUMBER_DOCS); searchParams.getIdentity(), searchParams.getRoles(), 0, MAX_NUMBER_DOCS);
if(results.isEmpty()) { if(results.isEmpty()) {
return new DefaultResultInfos<QuestionItemView>(); return new DefaultResultInfos<>();
} }
List<QuestionItemView> items = itemQueriesDao.getItemsOfCollection(searchParams.getIdentity(), collection, results, List<QuestionItemView> items = itemQueriesDao.getItemsOfCollection(searchParams.getIdentity(), collection, results,
searchParams.getFormat(), firstResult, maxResults, orderBy); searchParams.getFormat(), firstResult, maxResults, orderBy);
return new DefaultResultInfos<QuestionItemView>(firstResult + items.size(), results.size(), items); return new DefaultResultInfos<>(firstResult + items.size(), results.size(), items);
} catch (Exception e) { } catch (Exception e) {
log.error("", e); log.error("", e);
} }
return new DefaultResultInfos<QuestionItemView>(); return new DefaultResultInfos<>();
} else { } else {
List<QuestionItemView> items = itemQueriesDao.getItemsOfCollection(searchParams.getIdentity(), collection, searchParams.getItemKeys(), List<QuestionItemView> items = itemQueriesDao.getItemsOfCollection(searchParams.getIdentity(), collection, searchParams.getItemKeys(),
searchParams.getFormat(), firstResult, maxResults, orderBy); searchParams.getFormat(), firstResult, maxResults, orderBy);
return new DefaultResultInfos<QuestionItemView>(firstResult + items.size(), -1, items); return new DefaultResultInfos<>(firstResult + items.size(), -1, items);
} }
} }
...@@ -884,7 +884,7 @@ public class QuestionPoolServiceImpl implements QPoolService { ...@@ -884,7 +884,7 @@ public class QuestionPoolServiceImpl implements QPoolService {
@Override @Override
public ResultInfos<Pool> getPools(int firstResult, int maxResults, SortKey... orderBy) { public ResultInfos<Pool> getPools(int firstResult, int maxResults, SortKey... orderBy) {
List<Pool> pools = poolDao.getPools(firstResult, maxResults); List<Pool> pools = poolDao.getPools(firstResult, maxResults);
return new DefaultResultInfos<Pool>(firstResult + pools.size(), -1, pools); return new DefaultResultInfos<>(firstResult + pools.size(), -1, pools);
} }
@Override @Override
...@@ -943,6 +943,7 @@ public class QuestionPoolServiceImpl implements QPoolService { ...@@ -943,6 +943,7 @@ public class QuestionPoolServiceImpl implements QPoolService {
} }
} }
@Override
public Taxonomy getQPoolTaxonomy() { public Taxonomy getQPoolTaxonomy() {
TaxonomyRef ref = getQPoolTaxonomyRef() ; TaxonomyRef ref = getQPoolTaxonomyRef() ;
return ref == null ? null: taxonomyDao.loadByKey(ref.getKey()); return ref == null ? null: taxonomyDao.loadByKey(ref.getKey());
......
...@@ -25,7 +25,6 @@ import java.util.List; ...@@ -25,7 +25,6 @@ import java.util.List;
import java.util.Set; import java.util.Set;
import org.olat.core.CoreSpringFactory; import org.olat.core.CoreSpringFactory;
import org.olat.core.commons.persistence.ResultInfos;
import org.olat.core.gui.UserRequest; import org.olat.core.gui.UserRequest;
import org.olat.core.gui.components.form.flexible.FormItem; import org.olat.core.gui.components.form.flexible.FormItem;
import org.olat.core.gui.components.form.flexible.FormItemContainer; import org.olat.core.gui.components.form.flexible.FormItemContainer;
...@@ -103,8 +102,8 @@ public class PoolsController extends FormBasicController { ...@@ -103,8 +102,8 @@ public class PoolsController extends FormBasicController {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(true, Cols.publicPool.i18nKey(), Cols.publicPool.ordinal(), columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(true, Cols.publicPool.i18nKey(), Cols.publicPool.ordinal(),
true, "publicPool", FlexiColumnModel.ALIGNMENT_LEFT, true, "publicPool", FlexiColumnModel.ALIGNMENT_LEFT,
new BooleanCellRenderer( new BooleanCellRenderer(
new CSSIconFlexiCellRenderer("o_public"), new CSSIconFlexiCellRenderer("o_icon_pool_public"),
new CSSIconFlexiCellRenderer("o_private")) new CSSIconFlexiCellRenderer("o_icon_pool_private"))
)); ));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.name.i18nKey(), Cols.name.ordinal(), true, "name")); columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.name.i18nKey(), Cols.name.ordinal(), true, "name"));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("select", translate("select"), "select-pool")); columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("select", translate("select"), "select-pool"));
...@@ -113,7 +112,7 @@ public class PoolsController extends FormBasicController { ...@@ -113,7 +112,7 @@ public class PoolsController extends FormBasicController {
poolTable = uifactory.addTableElement(getWindowControl(), "pools", model, getTranslator(), formLayout); poolTable = uifactory.addTableElement(getWindowControl(), "pools", model, getTranslator(), formLayout);
poolTable.setMultiSelect(true); poolTable.setMultiSelect(true);
poolTable.setRendererType(FlexiTableRendererType.classic); poolTable.setRendererType(FlexiTableRendererType.classic);
reloadModel(); reloadModel(ureq);
FormLayoutContainer buttonsCont = FormLayoutContainer.createButtonLayout("buttons", getTranslator()); FormLayoutContainer buttonsCont = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
buttonsCont.setRootForm(mainForm); buttonsCont.setRootForm(mainForm);
...@@ -122,9 +121,9 @@ public class PoolsController extends FormBasicController { ...@@ -122,9 +121,9 @@ public class PoolsController extends FormBasicController {
uifactory.addFormCancelButton("cancel", buttonsCont, ureq, getWindowControl()); uifactory.addFormCancelButton("cancel", buttonsCont, ureq, getWindowControl());
} }
private void reloadModel() { private void reloadModel(UserRequest ureq) {
ResultInfos<Pool> pools = qpoolService.getPools(0, -1); List<Pool> pools = qpoolService.getPools(getIdentity(), ureq.getUserSession().getRoles());
model.setObjects(pools.getObjects()); model.setObjects(pools);
poolTable.reset(); poolTable.reset();
} }
...@@ -141,7 +140,7 @@ public class PoolsController extends FormBasicController { ...@@ -141,7 +140,7 @@ public class PoolsController extends FormBasicController {
} else if(source == selectButton) { } else if(source == selectButton) {
Set<Integer> selectIndexes = poolTable.getMultiSelectedIndex(); Set<Integer> selectIndexes = poolTable.getMultiSelectedIndex();
if(!selectIndexes.isEmpty()) { if(!selectIndexes.isEmpty()) {
List<Pool> rows = new ArrayList<Pool>(selectIndexes.size()); List<Pool> rows = new ArrayList<>(selectIndexes.size());
for(Integer index:selectIndexes) { for(Integer index:selectIndexes) {
Pool row = model.getObject(index.intValue()); Pool row = model.getObject(index.intValue());
rows.add(row); rows.add(row);
...@@ -225,7 +224,7 @@ public class PoolsController extends FormBasicController { ...@@ -225,7 +224,7 @@ public class PoolsController extends FormBasicController {
@Override @Override
public void setObjects(List<Pool> objects) { public void setObjects(List<Pool> objects) {
rows = new ArrayList<Pool>(objects); rows = new ArrayList<>(objects);
} }
@Override @Override
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment