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=========================================================
21 package org.onap.aai.rest.db;
24 import java.util.Optional;
26 import javax.ws.rs.core.HttpHeaders;
27 import javax.ws.rs.core.UriInfo;
29 import org.onap.aai.aailog.logs.DBRequestWrapper;
30 import org.onap.aai.introspection.Introspector;
31 import org.onap.aai.introspection.MarshallerProperties;
32 import org.onap.aai.parsers.query.QueryParser;
33 import org.onap.aai.restcore.HttpMethod;
36 * The Class DBRequest.
38 public class DBRequest implements DBRequestWrapper {
40 private final QueryParser parser;
42 private final Introspector introspector;
44 private final HttpHeaders headers;
46 private final String transactionId;
48 private final UriInfo info;
50 private final HttpMethod method;
52 private final URI uri;
54 private final Optional<String> rawRequestContent;
56 private final Optional<MarshallerProperties> marshallerProperties;
59 * Instantiates a new DB request.
61 * @param method the method
63 * @param parser the parser
65 * @param headers the headers
66 * @param info the info
67 * @param transactionId the transaction id
69 private DBRequest(Builder builder) {
70 this.method = builder.getMethod();
71 this.parser = builder.getParser();
72 this.introspector = builder.getIntrospector();
73 this.headers = builder.getHeaders();
74 this.transactionId = builder.getTransactionId();
75 this.info = builder.getInfo();
76 this.uri = builder.getUri();
77 this.marshallerProperties = builder.getMarshallerProperties();
78 this.rawRequestContent = builder.getRawRequestContent();
86 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;
157 public static class Builder {
159 private QueryParser parser = null;
161 private Introspector introspector = null;
163 private HttpHeaders headers = null;
165 private String transactionId = null;
167 private UriInfo info = null;
169 private HttpMethod method = null;
171 private URI uri = null;
173 private Optional<MarshallerProperties> marshallerProperties = Optional.empty();
175 private Optional<String> rawRequestContent = Optional.empty();
178 * Instantiates a new DB request.
180 * @param method the method
182 * @param parser the parser
184 * @param headers the headers
185 * @param info the info
186 * @param transactionId the transaction id
188 public Builder(HttpMethod method, URI uri, QueryParser parser, Introspector obj, HttpHeaders headers,
189 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);
238 protected Optional<MarshallerProperties> getMarshallerProperties() {
239 return marshallerProperties;
242 protected Optional<String> getRawRequestContent() {
243 return rawRequestContent;
246 public DBRequest build() {
248 return new DBRequest(this);