Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,21 @@ public class SubmissionConfigReader {
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(SubmissionConfigReader.class);

/**
* The fully qualified pathname of the directory containing the Item Submission Configuration file
* The fully qualified pathname of the directory containing the Item Submission Configuration file.
* Initialized lazily to avoid calling DSpaceServicesFactory.getInstance() before the DSpace kernel
* service manager has fully started (which would cause a NullPointerException when this class is
* instantiated during the kernel's own Spring context initialization).
*/
private String configDir = DSpaceServicesFactory.getInstance()
.getConfigurationService().getProperty("dspace.dir")
+ File.separator + "config" + File.separator;
private String configDir = null;

private String getConfigDir() {
if (configDir == null) {
configDir = DSpaceServicesFactory.getInstance()
.getConfigurationService().getProperty("dspace.dir")
+ File.separator + "config" + File.separator;
}
return configDir;
}

/**
* Hashmap which stores which submission process configuration is used by
Expand Down Expand Up @@ -122,14 +132,14 @@ public class SubmissionConfigReader {
* @throws SubmissionConfigReaderException if servlet error
*/
public SubmissionConfigReader() throws SubmissionConfigReaderException {
buildInputs(configDir + SUBMIT_DEF_FILE_PREFIX + SUBMIT_DEF_FILE_SUFFIX);
buildInputs(getConfigDir() + SUBMIT_DEF_FILE_PREFIX + SUBMIT_DEF_FILE_SUFFIX);
}

public void reload() throws SubmissionConfigReaderException {
collectionToSubmissionConfig = null;
stepDefns = null;
submitDefns = null;
buildInputs(configDir + SUBMIT_DEF_FILE_PREFIX + SUBMIT_DEF_FILE_SUFFIX);
buildInputs(getConfigDir() + SUBMIT_DEF_FILE_PREFIX + SUBMIT_DEF_FILE_SUFFIX);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1020,10 +1020,13 @@ private DiscoverResult retrieveCollectionsWithSubmit(Context context, DiscoverQu
discoverQuery.addFilterQueries("search.entitytype:" + entityType);
}
if (StringUtils.isNotBlank(q)) {
StringBuilder buildQuery = new StringBuilder();
String escapedQuery = ClientUtils.escapeQueryChars(q);
buildQuery.append("(").append(escapedQuery).append(" OR ").append(escapedQuery).append("*").append(")");
discoverQuery.setQuery(buildQuery.toString());
// Build a title prefix filter using dc.title_sort (lowerCaseSort type).
// This field stores the entire title as a single lowercased token, enabling
// reliable case-insensitive prefix matching without analysis/stemming interference.
// The whole query (lowercased) is used as a prefix – e.g. query "te" matches any
// title that starts with "te" (case-insensitive).
String lowerQ = ClientUtils.escapeQueryChars(q.trim().toLowerCase());
discoverQuery.addFilterQueries("dc.title_sort:" + lowerQ + "*");
Comment on lines +1027 to +1029
}
DiscoverResult resp = searchService.search(context, discoverQuery);
return resp;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ List<IndexableObject> search(Context context, String query, String orderfield, b
*
* @param context The relevant DSpace Context.
* @param field the field of the filter query
* @param operator equals/notequals/notcontains/authority/notauthority
* @param operator equals/notequals/notcontains/authority/notauthority/startsWith
* @param value the filter query value
* @param config (nullable) the discovery configuration (if not null, field's corresponding facet.type checked to
* be standard so suffix is not added for equals operator)
Expand Down
13 changes: 11 additions & 2 deletions dspace-api/src/main/java/org/dspace/discovery/SolrServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -1252,7 +1252,11 @@ public DiscoverFilterQuery toFilterQuery(Context context, String field, String o
filterQuery.append(field);


if (operator.endsWith("equals")) {
if ("startsWith".equals(operator)) {
// Use _sort field: lowerCaseSort type stores whole value as a single lowercased token,
// enabling case-insensitive prefix matching with wildcards.
filterQuery.append("_sort");
} else if (operator.endsWith("equals")) {
final boolean isStandardField
= Optional.ofNullable(config)
.flatMap(c -> Optional.ofNullable(c.getSidebarFacet(field)))
Expand All @@ -1272,7 +1276,12 @@ public DiscoverFilterQuery toFilterQuery(Context context, String field, String o


filterQuery.append(":");
if ("equals".equals(operator) || "notequals".equals(operator)) {
if ("startsWith".equals(operator)) {
// Lowercase and escape the value, then append wildcard for prefix matching.
// The _sort field uses lowerCaseSort type, so both indexed and query values are lowercased.
value = ClientUtils.escapeQueryChars(value.toLowerCase());
filterQuery.append(value).append("*");
} else if ("equals".equals(operator) || "notequals".equals(operator)) {
//DO NOT ESCAPE RANGE QUERIES !
if (!value.matches("\\[.*TO.*\\]")) {
value = ClientUtils.escapeQueryChars(value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ public SolrInputDocument buildDocument(Context context, IndexableCollection inde
rights_license);
addContainerMetadataField(doc, highlightedMetadataFields, toIgnoreMetadataFields, "dc.title", title);
doc.addField("dc.title_sort", title);
// Also index as "title_sort" so the standard searchFilterTitle-based
// discovery filter (f.title + startsWith) works for collections.
doc.addField("title_sort", title);
Comment on lines +131 to +133

if (StringUtils.isBlank(entityType)) {
entityType = Constants.ENTITY_TYPE_NONE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ public SolrInputDocument buildDocument(Context context, IndexableCommunity index
addContainerMetadataField(doc, highlightedMetadataFields, toIgnoreMetadataFields, "dc.rights", rights);
addContainerMetadataField(doc, highlightedMetadataFields, toIgnoreMetadataFields, "dc.title", title);
doc.addField("dc.title_sort", title);
// Also index as "title_sort" so the standard searchFilterTitle-based
// discovery filter (f.title + startsWith) works for communities.
doc.addField("title_sort", title);
Comment on lines +105 to +107
return doc;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import org.dspace.content.InProgressSubmission;
import org.dspace.content.Item;
import org.dspace.eperson.EPerson;
import javax.annotation.PostConstruct;

import org.dspace.submit.factory.SubmissionServiceFactory;
Comment on lines +28 to 30
import org.dspace.submit.service.SubmissionConfigService;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -54,13 +56,12 @@ public abstract class AInprogressItemConverter<T extends InProgressSubmission,
@Autowired
private SubmissionSectionConverter submissionSectionConverter;

protected SubmissionConfigService submissionConfigService;

@Autowired
SubmissionService submissionService;
@Autowired
protected SubmissionConfigService submissionConfigService;

public AInprogressItemConverter() throws SubmissionConfigReaderException {
submissionConfigService = SubmissionServiceFactory.getInstance().getSubmissionConfigService();
public AInprogressItemConverter() {
Comment on lines 59 to +64
}

protected void fillFromModel(T obj, R witem, Projection projection) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import org.dspace.app.rest.model.WorkflowItemRest;
import org.dspace.app.rest.projection.Projection;
import org.dspace.app.util.SubmissionConfigReaderException;
import org.dspace.discovery.IndexableObject;
import org.dspace.xmlworkflow.storedcomponents.XmlWorkflowItem;
import org.springframework.stereotype.Component;
Expand All @@ -25,7 +24,7 @@
public class WorkflowItemConverter
extends AInprogressItemConverter<XmlWorkflowItem, org.dspace.app.rest.model.WorkflowItemRest> {

public WorkflowItemConverter() throws SubmissionConfigReaderException {
public WorkflowItemConverter() {
super();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import org.dspace.app.rest.model.WorkspaceItemRest;
import org.dspace.app.rest.projection.Projection;
import org.dspace.app.util.SubmissionConfigReaderException;
import org.dspace.content.WorkspaceItem;
import org.dspace.discovery.IndexableObject;
import org.springframework.stereotype.Component;
Expand All @@ -24,7 +23,7 @@
public class WorkspaceItemConverter
extends AInprogressItemConverter<WorkspaceItem, WorkspaceItemRest> {

public WorkspaceItemConverter() throws SubmissionConfigReaderException {
public WorkspaceItemConverter() {
super();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ public static List<String> getListOfAllowedSearchOperatorStrings() {
allowedSearchOperatorStrings.add(restSearchOperator.getDspaceOperator());
}
allowedSearchOperatorStrings.add("query");
allowedSearchOperatorStrings.add("startsWith");
return allowedSearchOperatorStrings;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.dspace.core.Context;
import org.dspace.submit.factory.SubmissionServiceFactory;
import org.dspace.submit.service.SubmissionConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.security.access.prepost.PreAuthorize;
Expand All @@ -38,8 +39,9 @@ public class SubmissionDefinitionRestRepository extends DSpaceRestRepository<Sub

private CollectionService collectionService = ContentServiceFactory.getInstance().getCollectionService();

public SubmissionDefinitionRestRepository() throws SubmissionConfigReaderException {
submissionConfigService = SubmissionServiceFactory.getInstance().getSubmissionConfigService();
@Autowired
public SubmissionDefinitionRestRepository(SubmissionConfigService submissionConfigService) {
this.submissionConfigService = submissionConfigService;
}
Comment on lines +42 to 45

@PreAuthorize("hasAuthority('AUTHENTICATED')")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.dspace.core.Context;
import org.dspace.submit.factory.SubmissionServiceFactory;
import org.dspace.submit.service.SubmissionConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.security.access.prepost.PreAuthorize;
Expand All @@ -33,8 +34,9 @@ public class SubmissionPanelRestRepository extends DSpaceRestRepository<Submissi

private SubmissionConfigService submissionConfigService;

public SubmissionPanelRestRepository() throws SubmissionConfigReaderException {
submissionConfigService = SubmissionServiceFactory.getInstance().getSubmissionConfigService();
@Autowired
public SubmissionPanelRestRepository(SubmissionConfigService submissionConfigService) {
this.submissionConfigService = submissionConfigService;
}

@PreAuthorize("hasAuthority('AUTHENTICATED')")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,9 @@ public class WorkflowItemRestRepository extends DSpaceRestRepository<WorkflowIte

private SubmissionConfigService submissionConfigService;

public WorkflowItemRestRepository() throws SubmissionConfigReaderException {
submissionConfigService = SubmissionServiceFactory.getInstance().getSubmissionConfigService();
@Autowired
public WorkflowItemRestRepository(SubmissionConfigService submissionConfigService) {
this.submissionConfigService = submissionConfigService;
}
Comment on lines +119 to 122

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,9 @@ public class WorkspaceItemRestRepository extends DSpaceRestRepository<WorkspaceI

private SubmissionConfigService submissionConfigService;

public WorkspaceItemRestRepository() throws SubmissionConfigReaderException {
submissionConfigService = SubmissionServiceFactory.getInstance().getSubmissionConfigService();
@Autowired
public WorkspaceItemRestRepository(SubmissionConfigService submissionConfigService) {
this.submissionConfigService = submissionConfigService;
Comment on lines +149 to +151
}

@PreAuthorize("hasPermission(#id, 'WORKSPACEITEM', 'READ')")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ public class SubmissionService {
private ConverterService converter;
@Autowired
private org.dspace.app.rest.utils.Utils utils;
@Autowired
private SubmissionConfigService submissionConfigService;

public SubmissionService() throws SubmissionConfigReaderException {
submissionConfigService = SubmissionServiceFactory.getInstance().getSubmissionConfigService();
public SubmissionService() {
}
Comment on lines 103 to 108

/**
Expand Down
Loading
Loading