2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
20 package org.onap.aai.rest.db;
23 import java.util.Optional;
25 import javax.ws.rs.core.HttpHeaders;
26 import javax.ws.rs.core.UriInfo;
28 import org.onap.aai.introspection.Introspector;
29 import org.onap.aai.introspection.MarshallerProperties;
30 import org.onap.aai.parsers.query.QueryParser;
31 import org.onap.aai.restcore.HttpMethod;
34 * The Class DBRequest.
36 public class DBRequest {
38 private final QueryParser parser;
40 private final Introspector introspector;
42 private final HttpHeaders headers;
44 private final String transactionId;
46 private final UriInfo info;
48 private final HttpMethod method;
50 private final URI uri;
52 private final Optional<String> rawRequestContent;
54 private final Optional<MarshallerProperties> marshallerProperties;
58 * Instantiates a new DB request.
60 * @param method the method
62 * @param parser the parser
64 * @param headers the headers
65 * @param info the info
66 * @param transactionId the transaction id
68 private DBRequest(Builder builder) {
69 this.method = builder.getMethod();
70 this.parser = builder.getParser();
71 this.introspector = builder.getIntrospector();
72 this.headers = builder.getHeaders();
73 this.transactionId = builder.getTransactionId();
74 this.info = builder.getInfo();
75 this.uri = builder.getUri();
76 this.marshallerProperties = builder.getMarshallerProperties();
77 this.rawRequestContent = builder.getRawRequestContent();
85 public HttpHeaders getHeaders() {
91 * Gets the transaction id.
93 * @return the transaction id
95 public String getTransactionId() {
104 public UriInfo getInfo() {
113 public QueryParser getParser() {
118 * Gets the introspector.
120 * @return the introspector
122 public Introspector getIntrospector() {
131 public HttpMethod getMethod() {
140 public URI getUri() {
145 * Gets the raw content.
147 * @return the raw content
149 public Optional<String> getRawRequestContent() {
150 return rawRequestContent;
153 public Optional<MarshallerProperties> getMarshallerProperties() {
154 return marshallerProperties;
159 public static class Builder {
161 private QueryParser parser = null;
163 private Introspector introspector = null;
165 private HttpHeaders headers = null;
167 private String transactionId = null;
169 private UriInfo info = null;
171 private HttpMethod method = null;
173 private URI uri = null;
175 private Optional<MarshallerProperties> marshallerProperties = Optional.empty();
177 private Optional<String> rawRequestContent = Optional.empty();
179 * Instantiates a new DB request.
181 * @param method the method
183 * @param parser the parser
185 * @param headers the headers
186 * @param info the info
187 * @param transactionId the transaction id
189 public Builder(HttpMethod method, URI uri, QueryParser parser, Introspector obj, HttpHeaders headers, UriInfo info, String transactionId) {
190 this.method = method;
191 this.parser = parser;
192 this.introspector = obj;
193 this.headers = headers;
194 this.transactionId = transactionId;
200 public QueryParser getParser() {
204 public Introspector getIntrospector() {
208 public HttpHeaders getHeaders() {
212 public String getTransactionId() {
213 return transactionId;
216 public UriInfo getInfo() {
220 public HttpMethod getMethod() {
224 public URI getUri() {
228 public Builder customMarshaller(MarshallerProperties properties) {
229 this.marshallerProperties = Optional.of(properties);
233 public Builder rawRequestContent(String content) {
234 this.rawRequestContent = Optional.of(content);
237 protected Optional<MarshallerProperties> getMarshallerProperties() {
238 return marshallerProperties;
240 protected Optional<String> getRawRequestContent() {
241 return rawRequestContent;
243 public DBRequest build() {
245 return new DBRequest(this);