2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 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=========================================================
21 package org.openecomp.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.openecomp.aai.introspection.Introspector;
30 import org.openecomp.aai.introspection.MarshallerProperties;
31 import org.openecomp.aai.parsers.query.QueryParser;
32 import org.openecomp.aai.restcore.HttpMethod;
35 * The Class DBRequest.
37 public class DBRequest {
39 private final QueryParser parser;
41 private final Introspector introspector;
43 private final HttpHeaders headers;
45 private final String transactionId;
47 private final UriInfo info;
49 private final HttpMethod method;
51 private final URI uri;
53 private final Optional<String> rawRequestContent;
55 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() {
92 * Gets the transaction id.
94 * @return the transaction id
96 public String getTransactionId() {
105 public UriInfo getInfo() {
114 public QueryParser getParser() {
119 * Gets the introspector.
121 * @return the introspector
123 public Introspector getIntrospector() {
132 public HttpMethod getMethod() {
141 public URI getUri() {
146 * Gets the raw content.
148 * @return the raw content
150 public Optional<String> getRawRequestContent() {
151 return rawRequestContent;
154 public Optional<MarshallerProperties> getMarshallerProperties() {
155 return marshallerProperties;
160 public static class Builder {
162 private QueryParser parser = null;
164 private Introspector introspector = null;
166 private HttpHeaders headers = null;
168 private String transactionId = null;
170 private UriInfo info = null;
172 private HttpMethod method = null;
174 private URI uri = null;
176 private Optional<MarshallerProperties> marshallerProperties = Optional.empty();
178 private Optional<String> rawRequestContent = Optional.empty();
180 * Instantiates a new DB request.
182 * @param method the method
184 * @param parser the parser
186 * @param headers the headers
187 * @param info the info
188 * @param transactionId the transaction id
190 public Builder(HttpMethod method, URI uri, QueryParser parser, Introspector obj, HttpHeaders headers, UriInfo info, String transactionId) {
191 this.method = method;
192 this.parser = parser;
193 this.introspector = obj;
194 this.headers = headers;
195 this.transactionId = transactionId;
201 public QueryParser getParser() {
205 public Introspector getIntrospector() {
209 public HttpHeaders getHeaders() {
213 public String getTransactionId() {
214 return transactionId;
217 public UriInfo getInfo() {
221 public HttpMethod getMethod() {
225 public URI getUri() {
229 public Builder customMarshaller(MarshallerProperties properties) {
230 this.marshallerProperties = Optional.of(properties);
234 public Builder rawRequestContent(String content) {
235 this.rawRequestContent = Optional.of(content);
238 protected Optional<MarshallerProperties> getMarshallerProperties() {
239 return marshallerProperties;
241 protected Optional<String> getRawRequestContent() {
242 return rawRequestContent;
244 public DBRequest build() {
246 return new DBRequest(this);