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