mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-16 22:43:12 +00:00
improve robustness of search in index field submit (use filter query) (#10550)
* improve robustness of search in index field submit (use filter query) * fix checkstyle warnings * fix checkstyle warning
This commit is contained in:
@@ -30,6 +30,7 @@ import org.dspace.core.Constants;
|
|||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.discovery.SolrSearchCore;
|
import org.dspace.discovery.SolrSearchCore;
|
||||||
import org.dspace.discovery.indexobject.IndexableCollection;
|
import org.dspace.discovery.indexobject.IndexableCollection;
|
||||||
|
import org.dspace.eperson.EPerson;
|
||||||
import org.dspace.eperson.Group;
|
import org.dspace.eperson.Group;
|
||||||
import org.dspace.eperson.service.GroupService;
|
import org.dspace.eperson.service.GroupService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -124,24 +125,33 @@ public class EntityTypeServiceImpl implements EntityTypeService {
|
|||||||
public List<String> getSubmitAuthorizedTypes(Context context)
|
public List<String> getSubmitAuthorizedTypes(Context context)
|
||||||
throws SQLException, SolrServerException, IOException {
|
throws SQLException, SolrServerException, IOException {
|
||||||
List<String> types = new ArrayList<>();
|
List<String> types = new ArrayList<>();
|
||||||
StringBuilder query = new StringBuilder();
|
StringBuilder query = null;
|
||||||
org.dspace.eperson.EPerson currentUser = context.getCurrentUser();
|
EPerson currentUser = context.getCurrentUser();
|
||||||
if (!authorizeService.isAdmin(context)) {
|
if (!authorizeService.isAdmin(context)) {
|
||||||
String userId = "";
|
String userId = "";
|
||||||
if (currentUser != null) {
|
if (currentUser != null) {
|
||||||
userId = currentUser.getID().toString();
|
userId = currentUser.getID().toString();
|
||||||
|
query = new StringBuilder();
|
||||||
|
query.append("submit:(e").append(userId);
|
||||||
}
|
}
|
||||||
query.append("submit:(e").append(userId);
|
|
||||||
Set<Group> groups = groupService.allMemberGroupsSet(context, currentUser);
|
Set<Group> groups = groupService.allMemberGroupsSet(context, currentUser);
|
||||||
for (Group group : groups) {
|
for (Group group : groups) {
|
||||||
query.append(" OR g").append(group.getID());
|
if (query == null) {
|
||||||
|
query = new StringBuilder();
|
||||||
|
query.append("submit:(g");
|
||||||
|
} else {
|
||||||
|
query.append(" OR g");
|
||||||
|
}
|
||||||
|
query.append(group.getID());
|
||||||
}
|
}
|
||||||
query.append(")");
|
query.append(")");
|
||||||
} else {
|
|
||||||
query.append("*:*");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SolrQuery sQuery = new SolrQuery(query.toString());
|
SolrQuery sQuery = new SolrQuery("*:*");
|
||||||
|
if (query != null) {
|
||||||
|
sQuery.addFilterQuery(query.toString());
|
||||||
|
}
|
||||||
sQuery.addFilterQuery("search.resourcetype:" + IndexableCollection.TYPE);
|
sQuery.addFilterQuery("search.resourcetype:" + IndexableCollection.TYPE);
|
||||||
sQuery.setRows(0);
|
sQuery.setRows(0);
|
||||||
sQuery.addFacetField("search.entitytype");
|
sQuery.addFacetField("search.entitytype");
|
||||||
|
Reference in New Issue
Block a user