Allow POST dr_sub using FeedName
[dmaap/dbcapi.git] / src / main / java / org / onap / dmaap / dbcapi / model / DR_Pub.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * org.onap.dmaap
4  * ================================================================================
5  * Copyright (C) 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
21 package org.onap.dmaap.dbcapi.model;
22
23 import javax.xml.bind.annotation.XmlRootElement;
24
25 import org.onap.dmaap.dbcapi.util.RandomString;
26
27 @XmlRootElement
28 public class DR_Pub extends DmaapObject {
29
30         private String dcaeLocationName;
31         private String username;
32         private String userpwd;
33         private String feedId;
34         private String pubId;
35         
36         // NOTE: the following fields are optional in the API but not stored in the DB
37         private String  feedName;
38         private String  feedVersion;
39
40         
41         public DR_Pub() {
42                 status = DmaapObject_Status.EMPTY;
43                 
44         }
45         
46         public DR_Pub( String dLN ) {
47                 this.dcaeLocationName = dLN;
48                 this.status = DmaapObject_Status.STAGED;
49         }
50         
51         public DR_Pub( String dLN, 
52                                         String uN,
53                                         String uP,
54                                         String fI,
55                                         String pI ) {
56                 this.dcaeLocationName = dLN;
57                 this.username = uN;
58                 this.userpwd = uP;
59                 this.feedId = fI;
60                 this.pubId = pI;
61                 this.status = DmaapObject_Status.VALID;
62         }
63
64
65         public DR_Pub( String dLN, 
66                                                         String uN,
67                                                         String uP,
68                                                         String fI ) {
69                 this.dcaeLocationName = dLN;
70                 this.username = uN;
71                 this.userpwd = uP;
72                 this.feedId = fI;
73                 this.pubId = fI + "." +  DR_Pub.nextKey();
74                 this.status = DmaapObject_Status.VALID; 
75         }
76                         
77
78         public String getDcaeLocationName() {
79                 return dcaeLocationName;
80         }
81
82         public void setDcaeLocationName(String dcaeLocationName) {
83                 this.dcaeLocationName = dcaeLocationName;
84         }
85
86         public String getUsername() {
87                 return username;
88         }
89
90         public void setUsername(String username) {
91                 this.username = username;
92         }
93
94         public String getUserpwd() {
95                 return userpwd;
96         }
97
98         public void setUserpwd(String userpwd) {
99                 this.userpwd = userpwd;
100         }
101
102         public String getFeedId() {
103                 return feedId;
104         }
105
106         public void setFeedId(String feedId) {
107                 this.feedId = feedId;
108         }
109
110         public String getPubId() {
111                 return pubId;
112         }
113
114         public void setPubId(String pubId) {
115                 this.pubId = pubId;
116         }
117         
118         public void setNextPubId() {
119                 this.pubId = this.feedId + "." +  DR_Pub.nextKey();
120         }
121         
122         public String getFeedName() {
123                 return feedName;
124         }
125
126         public void setFeedName(String feedName) {
127                 this.feedName = feedName;
128         }
129
130         public String getFeedVersion() {
131                 return feedVersion;
132         }
133
134         public void setFeedVersion(String feedVersion) {
135                 this.feedVersion = feedVersion;
136         }
137
138         public DR_Pub setRandomUserName() {
139                 RandomString r = new RandomString(15);
140                 this.username = "tmp_" + r.nextString();        
141                 return this;
142         }
143         public DR_Pub setRandomPassword() {
144                 RandomString r = new RandomString(15);
145                 this.userpwd = r.nextString();
146                 return this;
147         }
148
149         public static String nextKey() {
150                 RandomString ri = new RandomString(5);
151                 return ri.nextString();
152                 
153         }
154         
155 }