2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.dmaap.dbcapi.model;
23 import javax.xml.bind.annotation.XmlRootElement;
25 import org.onap.dmaap.dbcapi.util.RandomString;
27 import java.util.Objects;
30 public class DR_Pub extends DmaapObject {
32 private String dcaeLocationName;
33 private String username;
34 private String userpwd;
35 private String feedId;
38 // NOTE: the following fields are optional in the API but not stored in the DB
39 private String feedName;
40 private String feedVersion;
44 status = DmaapObject_Status.EMPTY;
48 public DR_Pub( String dLN ) {
49 this.dcaeLocationName = dLN;
50 this.status = DmaapObject_Status.STAGED;
53 public DR_Pub( String dLN,
58 this.dcaeLocationName = dLN;
63 this.status = DmaapObject_Status.VALID;
67 public DR_Pub( String dLN,
71 this.dcaeLocationName = dLN;
75 this.pubId = fI + "." + DR_Pub.nextKey();
76 this.status = DmaapObject_Status.VALID;
80 public String getDcaeLocationName() {
81 return dcaeLocationName;
84 public void setDcaeLocationName(String dcaeLocationName) {
85 this.dcaeLocationName = dcaeLocationName;
88 public String getUsername() {
92 public void setUsername(String username) {
93 this.username = username;
96 public String getUserpwd() {
100 public void setUserpwd(String userpwd) {
101 this.userpwd = userpwd;
104 public String getFeedId() {
108 public void setFeedId(String feedId) {
109 this.feedId = feedId;
112 public String getPubId() {
116 public void setPubId(String pubId) {
120 public void setNextPubId() {
121 this.pubId = this.feedId + "." + DR_Pub.nextKey();
124 public String getFeedName() {
128 public void setFeedName(String feedName) {
129 this.feedName = feedName;
132 public String getFeedVersion() {
136 public void setFeedVersion(String feedVersion) {
137 this.feedVersion = feedVersion;
140 public DR_Pub setRandomUserName() {
141 RandomString r = new RandomString(15);
142 this.username = "tmp_" + r.nextString();
145 public DR_Pub setRandomPassword() {
146 RandomString r = new RandomString(15);
147 this.userpwd = r.nextString();
151 public static String nextKey() {
152 RandomString ri = new RandomString(5);
153 return ri.nextString();
158 public boolean equals(Object o) {
159 if (this == o) return true;
160 if (o == null || getClass() != o.getClass()) return false;
161 DR_Pub dr_pub = (DR_Pub) o;
162 return Objects.equals(dcaeLocationName, dr_pub.dcaeLocationName) &&
163 Objects.equals(username, dr_pub.username) &&
164 Objects.equals(userpwd, dr_pub.userpwd) &&
165 Objects.equals(feedId, dr_pub.feedId) &&
166 Objects.equals(pubId, dr_pub.pubId);
170 public int hashCode() {
172 return Objects.hash(dcaeLocationName, username, userpwd, feedId, pubId);
176 public String toString() {
178 "dcaeLocationName='" + dcaeLocationName + '\'' +
179 ", username='" + username + '\'' +
180 ", userpwd='" + userpwd + '\'' +
181 ", feedId='" + feedId + '\'' +
182 ", pubId='" + pubId + '\'' +
183 ", feedName='" + feedName + '\'' +
184 ", feedVersion='" + feedVersion + '\'' +