aboutsummaryrefslogtreecommitdiffstats
path: root/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DestInfo.java
blob: ac8c3186198575ae23f9661b19151c8c5db24667 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
/*******************************************************************************
 * ============LICENSE_START==================================================
 * * org.onap.dmaap
 * * ===========================================================================
 * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
 * * ===========================================================================
 * * Licensed under the Apache License, Version 2.0 (the "License");
 * * you may not use this file except in compliance with the License.
 * * You may obtain a copy of the License at
 * *
 *  *      http://www.apache.org/licenses/LICENSE-2.0
 * *
 *  * Unless required by applicable law or agreed to in writing, software
 * * distributed under the License is distributed on an "AS IS" BASIS,
 * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * * See the License for the specific language governing permissions and
 * * limitations under the License.
 * * ============LICENSE_END====================================================
 * *
 * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
 * *
 ******************************************************************************/


package org.onap.dmaap.datarouter.node;

import org.onap.dmaap.datarouter.node.config.NodeConfig;

/**
 * Information for a delivery destination that doesn't change from message to message.
 */
public class DestInfo {

    private String name;
    private String spool;
    private String subid;
    private String logdata;
    private String url;
    private String authuser;
    private String authentication;
    private boolean metaonly;
    private boolean use100;
    private boolean privilegedSubscriber;
    private boolean decompress;
    private boolean followRedirects;

    /**
     * Create a destination information object.
     *
     * @param destInfoBuilder DestInfo Object Builder
     */
    public DestInfo(DestInfoBuilder destInfoBuilder) {
        this.name = destInfoBuilder.getName();
        this.spool = destInfoBuilder.getSpool();
        this.subid = destInfoBuilder.getSubid();
        this.logdata = destInfoBuilder.getLogdata();
        this.url = destInfoBuilder.getUrl();
        this.authuser = destInfoBuilder.getAuthuser();
        this.authentication = destInfoBuilder.getAuthentication();
        this.metaonly = destInfoBuilder.isMetaonly();
        this.use100 = destInfoBuilder.isUse100();
        this.privilegedSubscriber = destInfoBuilder.isPrivilegedSubscriber();
        this.followRedirects = destInfoBuilder.isFollowRedirects();
        this.decompress = destInfoBuilder.isDecompress();
    }

    /**
     * Create a destination information object.
     *
     * @param name n:fqdn or s:subid
     * @param spool The directory where files are spooled.
     * @param subscription The subscription.
     */
    public DestInfo(String name, String spool, NodeConfig.ProvSubscription subscription) {
        this.name = name;
        this.spool = spool;
        this.subid = subscription.getSubId();
        this.logdata = subscription.getFeedId();
        this.url = subscription.getURL();
        this.authuser = subscription.getAuthUser();
        this.authentication = subscription.getCredentials();
        this.metaonly = subscription.isMetaDataOnly();
        this.use100 = subscription.isUsing100();
        this.privilegedSubscriber = subscription.isPrivilegedSubscriber();
        this.followRedirects = subscription.getFollowRedirect();
        this.decompress = subscription.isDecompress();
    }

    public boolean equals(Object object) {
        return ((object instanceof DestInfo) && ((DestInfo) object).spool.equals(spool));
    }

    public int hashCode() {
        return (spool.hashCode());
    }

    /**
     * Get the name of this destination.
     */
    public String getName() {
        return (name);
    }

    /**
     * Get the spool directory for this destination.
     *
     * @return The spool directory
     */
    public String getSpool() {
        return (spool);
    }

    /**
     * Get the subscription ID.
     *
     * @return Subscription ID or null if this is a node to node delivery.
     */
    public String getSubId() {
        return (subid);
    }

    /**
     * Get the log data.
     *
     * @return Text to be included in a log message about delivery attempts.
     */
    public String getLogData() {
        return (logdata);
    }

    /**
     * Get the delivery URL.
     *
     * @return The URL to deliver to (the primary URL).
     */
    public String getURL() {
        return (url);

    }

    /**
     * Get the user for authentication.
     *
     * @return The name of the user for logging
     */
    public String getAuthUser() {
        return (authuser);
    }

    /**
     * Get the authentication header.
     *
     * @return The string to use to authenticate to the recipient.
     */
    public String getAuth() {
        return (authentication);
    }

    /**
     * Is this a metadata only delivery.
     *
     * @return True if this is a metadata only delivery
     */
    public boolean isMetaDataOnly() {
        return (metaonly);
    }

    /**
     * Should I send expect 100-continue header.
     *
     * @return True if I should.
     */
    public boolean isUsing100() {
        return (use100);
    }

    /**
     * Should we wait to receive a file processed acknowledgement before deleting file.
     */
    public boolean isPrivilegedSubscriber() {
        return (privilegedSubscriber);
    }

    /**
     * Should I follow redirects.
     *
     * @return True if I should.
     */
    public boolean isFollowRedirects() {
        return (followRedirects);
    }

    /**
     * Should i decompress the file before sending it on.
     *
     * @return True if I should.
     */
    public boolean isDecompress() {
        return (decompress);
    }


}