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