Sonar fix too many method param
[dmaap/datarouter.git] / datarouter-node / src / main / java / org / onap / dmaap / datarouter / node / DestInfo.java
1 /*******************************************************************************
2  * ============LICENSE_START==================================================
3  * * org.onap.dmaap
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
10  * *
11  *  *      http://www.apache.org/licenses/LICENSE-2.0
12  * *
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====================================================
19  * *
20  * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
21  * *
22  ******************************************************************************/
23
24
25 package org.onap.dmaap.datarouter.node;
26
27 /**
28  * Information for a delivery destination that doesn't change from message to message
29  */
30 public class DestInfo {
31     private String name;
32     private String spool;
33     private String subid;
34     private String logdata;
35     private String url;
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;
44
45     public static class DestInfoBuilder {
46         private String name;
47         private String spool;
48         private String subid;
49         private String logdata;
50         private String url;
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;
59
60         public DestInfoBuilder setName(String name) {
61             this.name = name;
62             return this;
63         }
64
65         public DestInfoBuilder setSpool(String spool) {
66             this.spool = spool;
67             return this;
68         }
69
70         public DestInfoBuilder setSubid(String subid) {
71             this.subid = subid;
72             return this;
73         }
74
75         public DestInfoBuilder setLogdata(String logdata) {
76             this.logdata = logdata;
77             return this;
78         }
79
80         public DestInfoBuilder setUrl(String url) {
81             this.url = url;
82             return this;
83         }
84
85         public DestInfoBuilder setAuthuser(String authuser) {
86             this.authuser = authuser;
87             return this;
88         }
89
90         public DestInfoBuilder setAuthentication(String authentication) {
91             this.authentication = authentication;
92             return this;
93         }
94
95         public DestInfoBuilder setMetaonly(boolean metaonly) {
96             this.metaonly = metaonly;
97             return this;
98         }
99
100         public DestInfoBuilder setUse100(boolean use100) {
101             this.use100 = use100;
102             return this;
103         }
104
105         public DestInfoBuilder setPrivilegedSubscriber(boolean privilegedSubscriber) {
106             this.privilegedSubscriber = privilegedSubscriber;
107             return this;
108         }
109
110         public DestInfoBuilder setFollowRedirects(boolean followRedirects) {
111             this.followRedirects = followRedirects;
112             return this;
113         }
114
115         public DestInfoBuilder setDecompress(boolean decompress) {
116             this.decompress = decompress;
117             return this;
118         }
119
120         public DestInfoBuilder setSubscription(NodeConfig.ProvSubscription subscription) {
121             this.subscription = subscription;
122             return this;
123         }
124
125         public DestInfo createDestInfo() {
126             return new DestInfo(this);
127         }
128     }
129
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;
143     }
144
145     /**
146      * Create a destination information object.
147      *
148      * @param    name    n:fqdn or s:subid
149      * @param    spool    The directory where files are spooled.
150      * @param    subscription    The subscription.
151      */
152     public DestInfo(String name, String spool, NodeConfig.ProvSubscription subscription) {
153         this.name = name;
154         this.spool = spool;
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();
165     }
166
167     public boolean equals(Object o) {
168         return ((o instanceof DestInfo) && ((DestInfo) o).spool.equals(spool));
169     }
170
171     public int hashCode() {
172         return (spool.hashCode());
173     }
174
175     /**
176      * Get the name of this destination
177      */
178     public String getName() {
179         return (name);
180     }
181
182     /**
183      * Get the spool directory for this destination.
184      *
185      * @return The spool directory
186      */
187     public String getSpool() {
188         return (spool);
189     }
190
191     /**
192      * Get the subscription ID.
193      *
194      * @return Subscription ID or null if this is a node to node delivery.
195      */
196     public String getSubId() {
197         return (subid);
198     }
199
200     /**
201      * Get the log data.
202      *
203      * @return Text to be included in a log message about delivery attempts.
204      */
205     public String getLogData() {
206         return (logdata);
207     }
208
209     /**
210      * Get the delivery URL.
211      *
212      * @return The URL to deliver to (the primary URL).
213      */
214     public String getURL() {
215         return (url);
216
217     }
218
219     /**
220      * Get the user for authentication
221      *
222      * @return The name of the user for logging
223      */
224     public String getAuthUser() {
225         return (authuser);
226     }
227
228     /**
229      * Get the authentication header
230      *
231      * @return The string to use to authenticate to the recipient.
232      */
233     public String getAuth() {
234         return (authentication);
235     }
236
237     /**
238      * Is this a metadata only delivery?
239      *
240      * @return True if this is a metadata only delivery
241      */
242     public boolean isMetaDataOnly() {
243         return (metaonly);
244     }
245
246     /**
247      * Should I send expect 100-continue header?
248      *
249      * @return True if I should.
250      */
251     public boolean isUsing100() {
252         return (use100);
253     }
254
255     /**
256      * Should we wait to receive a file processed acknowledgement before deleting file
257      */
258     public boolean isPrivilegedSubscriber() {
259         return (privilegedSubscriber);
260     }
261
262     /**
263     * Should I follow redirects?
264     *
265     * @return True if I should.
266     */
267     public boolean isFollowRedirects() {
268         return (followRedirects);
269     }
270
271     /**
272      * Should i decompress the file before sending it on
273      *
274      * @return True if I should.
275      */
276     public boolean isDecompress() {
277         return (decompress);
278     }
279
280
281 }