2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017 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 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22 package org.onap.aai.rest.db;
25 import java.util.Optional;
27 import javax.ws.rs.core.HttpHeaders;
28 import javax.ws.rs.core.UriInfo;
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 {
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;
60 * Instantiates a new DB request.
62 * @param method the method
64 * @param parser the parser
66 * @param headers the headers
67 * @param info the info
68 * @param transactionId the transaction id
70 private DBRequest(Builder builder) {
71 this.method = builder.getMethod();
72 this.parser = builder.getParser();
73 this.introspector = builder.getIntrospector();
74 this.headers = builder.getHeaders();
75 this.transactionId = builder.getTransactionId();
76 this.info = builder.getInfo();
77 this.uri = builder.getUri();
78 this.marshallerProperties = builder.getMarshallerProperties();
79 this.rawRequestContent = builder.getRawRequestContent();
87 public HttpHeaders getHeaders() {
93 * Gets the transaction id.
95 * @return the transaction id
97 public String getTransactionId() {
106 public UriInfo getInfo() {
115 public QueryParser getParser() {
120 * Gets the introspector.
122 * @return the introspector
124 public Introspector getIntrospector() {
133 public HttpMethod getMethod() {
142 public URI getUri() {
147 * Gets the raw content.
149 * @return the raw content
151 public Optional<String> getRawRequestContent() {
152 return rawRequestContent;
155 public Optional<MarshallerProperties> getMarshallerProperties() {
156 return marshallerProperties;
161 public static class Builder {
163 private QueryParser parser = null;
165 private Introspector introspector = null;
167 private HttpHeaders headers = null;
169 private String transactionId = null;
171 private UriInfo info = null;
173 private HttpMethod method = null;
175 private URI uri = null;
177 private Optional<MarshallerProperties> marshallerProperties = Optional.empty();
179 private Optional<String> rawRequestContent = Optional.empty();
181 * Instantiates a new DB request.
183 * @param method the method
185 * @param parser the parser
187 * @param headers the headers
188 * @param info the info
189 * @param transactionId the transaction id
191 public Builder(HttpMethod method, URI uri, QueryParser parser, Introspector obj, HttpHeaders headers, UriInfo info, String transactionId) {
192 this.method = method;
193 this.parser = parser;
194 this.introspector = obj;
195 this.headers = headers;
196 this.transactionId = transactionId;
202 public QueryParser getParser() {
206 public Introspector getIntrospector() {
210 public HttpHeaders getHeaders() {
214 public String getTransactionId() {
215 return transactionId;
218 public UriInfo getInfo() {
222 public HttpMethod getMethod() {
226 public URI getUri() {
230 public Builder customMarshaller(MarshallerProperties properties) {
231 this.marshallerProperties = Optional.of(properties);
235 public Builder rawRequestContent(String content) {
236 this.rawRequestContent = Optional.of(content);
239 protected Optional<MarshallerProperties> getMarshallerProperties() {
240 return marshallerProperties;
242 protected Optional<String> getRawRequestContent() {
243 return rawRequestContent;
245 public DBRequest build() {
247 return new DBRequest(this);