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