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