Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

return 400 for invalid page param #389

Merged
merged 1 commit into from
Dec 16, 2024
Merged
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 @@ -482,7 +482,7 @@ protected Annotation searchLastCreated(String query) throws Exception {
protected AnnotationPage search(String bodyValue, String profile, String limit)
throws Exception {
AnnotationPage annPg = searchAnnotations(bodyValue, null, null, WebAnnotationFields.CREATED, "desc",
"0", limit, profile, null);
"1", limit, profile, null);

assertNotNull(annPg, "AnnotationPage must not be null");
return annPg;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public class ParamValidationI18NException extends HttpException{
public static final String MESSAGE_IDENTIFIER_NOT_NULL = "Identifier must not be set when creating a new Annotation for the given provider!";
public static final String MESSAGE_ANNOTATION_ID_EXISTS = "An annotation with the given identifier already exists in database! Overwrite not allowed in this method!";
public static final String MESSAGE_ANNOTATION_IDENTIFIER_PROVIDED_UPON_CREATION = "The annotation identifier cannot be provided in the input upon the anntation creation!";
public static final String MESSAGE_INVALID_PARAMETER_VALUE = "Invalid request. Parameter value not supported or not allowed!{0}";
public static final String MESSAGE_BLANK_PARAMETER_VALUE = "Invalid request. Parameter value must not be null or empty!";
public static final String MESSAGE_URL_NOT_VALID = "Given URL is not valid!";
public static final String MESSAGE_INVALID_TAG_SIZE = "Invalid tag size. Must be shorter then 64 characters!";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,15 @@ private ResponseEntity<String> searchAnnotation(String wskey, String queryString

// ** Process input params
queryString = queryString.trim();
if (StringUtils.isBlank(queryString))
throw new ParamValidationI18NException(ParamValidationI18NException.MESSAGE_BLANK_PARAMETER_VALUE,
I18nConstantsAnnotation.ANNOTATION_VALIDATION,
new String[] { WebAnnotationFields.PARAM_QUERY, queryString });
if (StringUtils.isBlank(queryString)) {
throw new ParamValidationI18NException(ParamValidationI18NException.MESSAGE_BLANK_PARAMETER_VALUE,
I18nConstantsAnnotation.ANNOTATION_VALIDATION,
new String[] { WebAnnotationFields.PARAM_QUERY, queryString });
}
if (page < Query.DEFAULT_PAGE) {
throw new ParamValidationI18NException(null, I18nConstantsAnnotation.INVALID_PARAM_VALUE,
new String[] { WebAnnotationFields.PAGE, String.valueOf(page) });
}

SearchProfiles searchProfile = getProfile(profile, request);
// here we need a query search profile - dereference is not a query search
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public interface I18nConstantsAnnotation extends eu.europeana.api.commons.defini
String MESSAGE_INVALID_TAG_ID_FORMAT = "error.message_invalid_tag_id_format";
String MESSAGE_MISSING_MANDATORY_FIELD = "error.message_missing_mandatory_field";
String INVALID_PROVIDER = "error.invalid_provider";
String INVALID_PARAM_VALUE = "error.invalid_param_value";
String SOLR_EXCEPTION = "error.solr_exception";
String SOLR_MALFORMED_QUERY_EXCEPTION = "error.solr_malformed_query_exception";

Expand Down
Loading