2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * Copyright © 2017-2018 Amdocs
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.aai.sa.searchdbabstraction.entity;
24 import javax.ws.rs.core.Response;
25 import javax.ws.rs.core.Response.Status;
27 public class OperationResultBuilder {
34 private static final String INTERNAL_SERVER_ERROR_ELASTIC_SEARCH_OPERATION_FAULT =
35 "Internal Error: ElasticSearch operation fault occurred";
37 private OperationResult opResult;
39 public OperationResultBuilder() {
40 opResult = new OperationResult();
43 public OperationResultBuilder(Type type) {
46 opResult = new DocumentOperationResult();
49 opResult = new SearchOperationResult();
52 opResult = new OperationResult();
56 public OperationResult build() {
60 public OperationResultBuilder useDefaults() {
61 opResult.setResultCode(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
62 opResult.setResult(INTERNAL_SERVER_ERROR_ELASTIC_SEARCH_OPERATION_FAULT);
66 public OperationResultBuilder resultCode(int resultCode) {
67 opResult.setResultCode(resultCode);
71 public OperationResultBuilder status(Status status) {
72 return resultCode(status.getStatusCode());
75 public OperationResultBuilder failureCause(String failureCause) {
76 opResult.setFailureCause(failureCause);
80 public OperationResultBuilder result(String resultMsg) {
81 opResult.setResult(resultMsg);
85 public OperationResultBuilder resultVersion(String resultVersion) {
86 opResult.setResultVersion(resultVersion);