Add optional API for PM Mapper
[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
42     /**
43      * Create a destination information object.
44      *
45      * @param    name    n:fqdn or s:subid
46      * @param    spool    The directory where files are spooled.
47      * @param    subid    The subscription ID (if applicable).
48      * @param    logdata    Text to be included in log messages
49      * @param    url    The URL to deliver to.
50      * @param    authuser    The auth user for logging.
51      * @param    authentication    The credentials.
52      * @param    metaonly    Is this a metadata only delivery?
53      * @param    use100    Should I use expect 100-continue?
54      * @param    privilegedSubscriber   Can we wait to receive a file processed acknowledgement before deleting file
55      */
56     public DestInfo(String name, String spool, String subid, String logdata, String url, String authuser, String authentication, boolean metaonly, boolean use100, boolean privilegedSubscriber) {
57         this.name = name;
58         this.spool = spool;
59         this.subid = subid;
60         this.logdata = logdata;
61         this.url = url;
62         this.authuser = authuser;
63         this.authentication = authentication;
64         this.metaonly = metaonly;
65         this.use100 = use100;
66         this.privilegedSubscriber = privilegedSubscriber;
67     }
68
69     /**
70      * Create a destination information object.
71      *
72      * @param    name    n:fqdn or s:subid
73      * @param    spool    The directory where files are spooled.
74      * @param    subscription    The subscription.
75      */
76     public DestInfo(String name, String spool, NodeConfig.ProvSubscription subscription) {
77         this.name = name;
78         this.spool = spool;
79         this.subid = subscription.getSubId();
80         this.logdata = subscription.getFeedId();
81         this.url = subscription.getURL();
82         this.authuser = subscription.getAuthUser();
83         this.authentication = subscription.getCredentials();
84         this.metaonly = subscription.isMetaDataOnly();
85         this.use100 = subscription.isUsing100();
86         this.privilegedSubscriber = subscription.isPrivilegedSubscriber();
87     }
88
89     public boolean equals(Object o) {
90         return ((o instanceof DestInfo) && ((DestInfo) o).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 }