Refactor datatrore handling in API requests
[cps.git] / cps-ncmp-rest / src / main / java / org / onap / cps / ncmp / rest / controller / handlers / TaskManagementDefaultHandler.java
1 /*
2  *  ============LICENSE_START=======================================================
3  *  Copyright (C) 2023 Nordix Foundation
4  *  ================================================================================
5  *  Licensed under the Apache License, Version 2.0 (the "License");
6  *  you may not use this file except in compliance with the License.
7  *  You may obtain a copy of the License at
8  *
9  *        http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  *
17  *  SPDX-License-Identifier: Apache-2.0
18  *  ============LICENSE_END=========================================================
19  */
20
21 package org.onap.cps.ncmp.rest.controller.handlers;
22
23 import java.util.List;
24 import java.util.function.Supplier;
25 import org.onap.cps.spi.FetchDescendantsOption;
26
27 public interface TaskManagementDefaultHandler {
28
29     String NO_REQUEST_ID = null;
30     String NO_TOPIC = null;
31     Supplier<Object> NO_OBJECT_SUPPLIER = null;
32
33     default Supplier<Object> getTaskSupplierForGetRequest(final String datastoreName,
34                                                           final String cmHandleId,
35                                                           final String resourceIdentifier,
36                                                           final String optionsParamInQuery,
37                                                           final String topicParamInQuery,
38                                                           final String requestId,
39                                                           final boolean includeDescendant) {
40         return NO_OBJECT_SUPPLIER;
41     }
42
43     default Supplier<Object> getTaskSupplierForQueryRequest(final String cmHandleId,
44                                                             final String resourceIdentifier,
45                                                             final boolean includeDescendant) {
46         return NO_OBJECT_SUPPLIER;
47     }
48
49     default Supplier<Object> getTaskSupplierForBulkRequest(final String datastoreName,
50                                                            final List<String> cmHandleIds,
51                                                            final String resourceIdentifier,
52                                                            final String optionsParamInQuery,
53                                                            final String topicParamInQuery,
54                                                            final String requestId,
55                                                            final boolean includeDescendant) {
56         return NO_OBJECT_SUPPLIER;
57     }
58
59     static FetchDescendantsOption getFetchDescendantsOption(final boolean includeDescendants) {
60         return includeDescendants ? FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS
61                 : FetchDescendantsOption.OMIT_DESCENDANTS;
62     }
63 }