1 /*******************************************************************************
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 ******************************************************************************/
25 package org.onap.dmaap.datarouter.node;
28 * Information for a delivery destination that doesn't change from message to message
30 public class DestInfo {
34 private String logdata;
36 private String authuser;
37 private String authentication;
38 private boolean metaonly;
39 private boolean use100;
40 private boolean privilegedSubscriber;
41 private boolean decompress;
42 private boolean followRedirects;
43 private String aafInstance;
45 public static class DestInfoBuilder {
49 private String logdata;
51 private String authuser;
52 private String authentication;
53 private boolean metaonly;
54 private boolean use100;
55 private boolean privilegedSubscriber;
56 private boolean followRedirects;
57 private boolean decompress;
58 private NodeConfig.ProvSubscription subscription;
60 public DestInfoBuilder setName(String name) {
65 public DestInfoBuilder setSpool(String spool) {
70 public DestInfoBuilder setSubid(String subid) {
75 public DestInfoBuilder setLogdata(String logdata) {
76 this.logdata = logdata;
80 public DestInfoBuilder setUrl(String url) {
85 public DestInfoBuilder setAuthuser(String authuser) {
86 this.authuser = authuser;
90 public DestInfoBuilder setAuthentication(String authentication) {
91 this.authentication = authentication;
95 public DestInfoBuilder setMetaonly(boolean metaonly) {
96 this.metaonly = metaonly;
100 public DestInfoBuilder setUse100(boolean use100) {
101 this.use100 = use100;
105 public DestInfoBuilder setPrivilegedSubscriber(boolean privilegedSubscriber) {
106 this.privilegedSubscriber = privilegedSubscriber;
110 public DestInfoBuilder setFollowRedirects(boolean followRedirects) {
111 this.followRedirects = followRedirects;
115 public DestInfoBuilder setDecompress(boolean decompress) {
116 this.decompress = decompress;
120 public DestInfoBuilder setSubscription(NodeConfig.ProvSubscription subscription) {
121 this.subscription = subscription;
125 public DestInfo createDestInfo() {
126 return new DestInfo(this);
130 public DestInfo(DestInfoBuilder destInfoBuilder) {
131 this.name = destInfoBuilder.name;
132 this.spool = destInfoBuilder.spool;
133 this.subid = destInfoBuilder.subid;
134 this.logdata = destInfoBuilder.logdata;
135 this.url = destInfoBuilder.url;
136 this.authuser = destInfoBuilder.authuser;
137 this.authentication = destInfoBuilder.authentication;
138 this.metaonly = destInfoBuilder.metaonly;
139 this.use100 = destInfoBuilder.use100;
140 this.privilegedSubscriber = destInfoBuilder.privilegedSubscriber;
141 this.followRedirects = destInfoBuilder.followRedirects;
142 this.decompress = destInfoBuilder.decompress;
146 * Create a destination information object.
148 * @param name n:fqdn or s:subid
149 * @param spool The directory where files are spooled.
150 * @param subscription The subscription.
152 public DestInfo(String name, String spool, NodeConfig.ProvSubscription subscription) {
155 this.subid = subscription.getSubId();
156 this.logdata = subscription.getFeedId();
157 this.url = subscription.getURL();
158 this.authuser = subscription.getAuthUser();
159 this.authentication = subscription.getCredentials();
160 this.metaonly = subscription.isMetaDataOnly();
161 this.use100 = subscription.isUsing100();
162 this.privilegedSubscriber = subscription.isPrivilegedSubscriber();
163 this.followRedirects = subscription.getFollowRedirect();
164 this.decompress = subscription.isDecompress();
167 public boolean equals(Object o) {
168 return ((o instanceof DestInfo) && ((DestInfo) o).spool.equals(spool));
171 public int hashCode() {
172 return (spool.hashCode());
176 * Get the name of this destination
178 public String getName() {
183 * Get the spool directory for this destination.
185 * @return The spool directory
187 public String getSpool() {
192 * Get the subscription ID.
194 * @return Subscription ID or null if this is a node to node delivery.
196 public String getSubId() {
203 * @return Text to be included in a log message about delivery attempts.
205 public String getLogData() {
210 * Get the delivery URL.
212 * @return The URL to deliver to (the primary URL).
214 public String getURL() {
220 * Get the user for authentication
222 * @return The name of the user for logging
224 public String getAuthUser() {
229 * Get the authentication header
231 * @return The string to use to authenticate to the recipient.
233 public String getAuth() {
234 return (authentication);
238 * Is this a metadata only delivery?
240 * @return True if this is a metadata only delivery
242 public boolean isMetaDataOnly() {
247 * Should I send expect 100-continue header?
249 * @return True if I should.
251 public boolean isUsing100() {
256 * Should we wait to receive a file processed acknowledgement before deleting file
258 public boolean isPrivilegedSubscriber() {
259 return (privilegedSubscriber);
263 * Should I follow redirects?
265 * @return True if I should.
267 public boolean isFollowRedirects() {
268 return (followRedirects);
272 * Should i decompress the file before sending it on
274 * @return True if I should.
276 public boolean isDecompress() {