001/*
002 * #%L
003 * HAPI FHIR - Server Framework
004 * %%
005 * Copyright (C) 2014 - 2024 Smile CDR, Inc.
006 * %%
007 * Licensed under the Apache License, Version 2.0 (the "License");
008 * you may not use this file except in compliance with the License.
009 * You may obtain a copy of the License at
010 *
011 *      http://www.apache.org/licenses/LICENSE-2.0
012 *
013 * Unless required by applicable law or agreed to in writing, software
014 * distributed under the License is distributed on an "AS IS" BASIS,
015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016 * See the License for the specific language governing permissions and
017 * limitations under the License.
018 * #L%
019 */
020package ca.uhn.fhir.rest.server;
021
022import ca.uhn.fhir.rest.api.server.IBundleProvider;
023import ca.uhn.fhir.rest.api.server.RequestDetails;
024import jakarta.annotation.Nonnull;
025import jakarta.annotation.Nullable;
026
027public interface IPagingProvider {
028
029        /**
030         * if no _count parameter is provided, use this for the page size
031         */
032        int getDefaultPageSize();
033
034        /**
035         * if the _count parameter is larger than this value, reduce it to this value
036         */
037        int getMaximumPageSize();
038
039        /**
040         * @return true if the paging provider is able to store search results.
041         */
042        default boolean canStoreSearchResults() {
043                return true;
044        }
045
046        /**
047         * Retrieve a result list by Search ID
048         *
049         * @since 4.0.0 - Note that the <code>theRequest</code> parameter was added to this
050         * method in HAPI FHIR 4.0.0. Existing implementations may choose to
051         * add this parameter and not use it if needed.
052         */
053        IBundleProvider retrieveResultList(@Nullable RequestDetails theRequestDetails, @Nonnull String theSearchId);
054
055        /**
056         * Retrieve a result list by Search ID and Page ID
057         *
058         * @since 4.0.0 - Note that the <code>theRequest</code> parameter was added to this
059         * method in HAPI FHIR 4.0.0. Existing implementations may choose to
060         * add this parameter and not use it if needed.
061         */
062        default IBundleProvider retrieveResultList(
063                        @Nullable RequestDetails theRequestDetails, @Nonnull String theSearchId, String thePageId) {
064                return null;
065        }
066
067        /**
068         * Stores a result list and returns an ID with which that list can be returned
069         *
070         * @param theRequestDetails The server request being made (may be null)
071         */
072        String storeResultList(@Nullable RequestDetails theRequestDetails, IBundleProvider theList);
073}