Remove major and minor code smells in dr-node
[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
32     private String name;
33     private String spool;
34     private String subid;
35     private String logdata;
36     private String url;
37     private String authuser;
38     private String authentication;
39     private boolean metaonly;
40     private boolean use100;
41     private boolean privilegedSubscriber;
42     private boolean decompress;
43     private boolean followRedirects;
44
45     /**
46      * Create a destination information object.
47      *
48      * @param destInfoBuilder DestInfo Object Builder
49      */
50     public DestInfo(DestInfoBuilder destInfoBuilder) {
51         this.name = destInfoBuilder.getName();
52         this.spool = destInfoBuilder.getSpool();
53         this.subid = destInfoBuilder.getSubid();
54         this.logdata = destInfoBuilder.getLogdata();
55         this.url = destInfoBuilder.getUrl();
56         this.authuser = destInfoBuilder.getAuthuser();
57         this.authentication = destInfoBuilder.getAuthentication();
58         this.metaonly = destInfoBuilder.isMetaonly();
59         this.use100 = destInfoBuilder.isUse100();
60         this.privilegedSubscriber = destInfoBuilder.isPrivilegedSubscriber();
61         this.followRedirects = destInfoBuilder.isFollowRedirects();
62         this.decompress = destInfoBuilder.isDecompress();
63     }
64
65     /**
66      * Create a destination information object.
67      *
68      * @param name n:fqdn or s:subid
69      * @param spool The directory where files are spooled.
70      * @param subscription The subscription.
71      */
72     public DestInfo(String name, String spool, NodeConfig.ProvSubscription subscription) {
73         this.name = name;
74         this.spool = spool;
75         this.subid = subscription.getSubId();
76         this.logdata = subscription.getFeedId();
77         this.url = subscription.getURL();
78         this.authuser = subscription.getAuthUser();
79         this.authentication = subscription.getCredentials();
80         this.metaonly = subscription.isMetaDataOnly();
81         this.use100 = subscription.isUsing100();
82         this.privilegedSubscriber = subscription.isPrivilegedSubscriber();
83         this.followRedirects = subscription.getFollowRedirect();
84         this.decompress = subscription.isDecompress();
85     }
86
87     public boolean equals(Object object) {
88         return ((object instanceof DestInfo) && ((DestInfo) object).spool.equals(spool));
89     }
90
91     public int hashCode() {
92         return (spool.hashCode());
93     }
94
95     /**
96      * Get the name of this destination.
97      */
98     public String getName() {
99         return (name);
100     }
101
102     /**
103      * Get the spool directory for this destination.
104      *
105      * @return The spool directory
106      */
107     public String getSpool() {
108         return (spool);
109     }
110
111     /**
112      * Get the subscription ID.
113      *
114      * @return Subscription ID or null if this is a node to node delivery.
115      */
116     public String getSubId() {
117         return (subid);
118     }
119
120     /**
121      * Get the log data.
122      *
123      * @return Text to be included in a log message about delivery attempts.
124      */
125     public String getLogData() {
126         return (logdata);
127     }
128
129     /**
130      * Get the delivery URL.
131      *
132      * @return The URL to deliver to (the primary URL).
133      */
134     public String getURL() {
135         return (url);
136
137     }
138
139     /**
140      * Get the user for authentication.
141      *
142      * @return The name of the user for logging
143      */
144     public String getAuthUser() {
145         return (authuser);
146     }
147
148     /**
149      * Get the authentication header.
150      *
151      * @return The string to use to authenticate to the recipient.
152      */
153     public String getAuth() {
154         return (authentication);
155     }
156
157     /**
158      * Is this a metadata only delivery.
159      *
160      * @return True if this is a metadata only delivery
161      */
162     public boolean isMetaDataOnly() {
163         return (metaonly);
164     }
165
166     /**
167      * Should I send expect 100-continue header.
168      *
169      * @return True if I should.
170      */
171     public boolean isUsing100() {
172         return (use100);
173     }
174
175     /**
176      * Should we wait to receive a file processed acknowledgement before deleting file.
177      */
178     public boolean isPrivilegedSubscriber() {
179         return (privilegedSubscriber);
180     }
181
182     /**
183      * Should I follow redirects.
184      *
185      * @return True if I should.
186      */
187     public boolean isFollowRedirects() {
188         return (followRedirects);
189     }
190
191     /**
192      * Should i decompress the file before sending it on.
193      *
194      * @return True if I should.
195      */
196     public boolean isDecompress() {
197         return (decompress);
198     }
199
200
201 }