[SO] Release so 1.13.0 image
[so.git] / mso-catalog-db / src / main / java / org / onap / so / db / catalog / beans / CloudIdentity.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
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.so.db.catalog.beans;
22
23 import java.util.Date;
24 import javax.persistence.Column;
25 import javax.persistence.Entity;
26 import javax.persistence.EnumType;
27 import javax.persistence.Enumerated;
28 import javax.persistence.Id;
29 import javax.persistence.PrePersist;
30 import javax.persistence.PreUpdate;
31 import javax.persistence.Table;
32 import javax.persistence.Temporal;
33 import javax.persistence.TemporalType;
34 import org.apache.commons.lang3.builder.EqualsBuilder;
35 import org.apache.commons.lang3.builder.HashCodeBuilder;
36 import org.apache.commons.lang3.builder.ToStringBuilder;
37 import org.apache.commons.lang3.builder.ToStringStyle;
38 import com.fasterxml.jackson.annotation.JsonProperty;
39 import com.openpojo.business.annotation.BusinessKey;
40 import uk.co.blackpepper.bowman.annotation.RemoteResource;
41
42 /**
43  * EntityBean class for a CloudIdentity. This bean represents a cloud identity service instance (i.e. a DCP node) in the
44  * NVP/AIC cloud. It will be loaded via CloudConfig object, of which it is a component.
45  *
46  */
47 @Entity
48 @RemoteResource("/cloudIdentity")
49 @Table(name = "identity_services")
50 public class CloudIdentity {
51
52     @JsonProperty
53     @BusinessKey
54     @Id
55     @Column(name = "ID")
56     private String id;
57
58     @JsonProperty("identity_url")
59     @BusinessKey
60     @Column(name = "IDENTITY_URL")
61     private String identityUrl;
62
63     @JsonProperty("mso_id")
64     @BusinessKey
65     @Column(name = "MSO_ID")
66     private String msoId;
67
68     @JsonProperty("mso_pass")
69     @BusinessKey
70     @Column(name = "MSO_PASS")
71     private String msoPass;
72
73     @JsonProperty("project_domain_name")
74     @BusinessKey
75     @Column(name = "PROJECT_DOMAIN_NAME")
76     private String projectDomainName;
77
78     @JsonProperty("admin_project_domain_name")
79     @BusinessKey
80     @Column(name = "ADMIN_PROJECT_DOMAIN_NAME", nullable = false)
81     private String adminProjectDomainName = "Default";
82
83     @JsonProperty("user_domain_name")
84     @BusinessKey
85     @Column(name = "USER_DOMAIN_NAME")
86     private String userDomainName;
87
88     @JsonProperty("admin_tenant")
89     @BusinessKey
90     @Column(name = "ADMIN_TENANT")
91     private String adminTenant;
92
93     @JsonProperty("member_role")
94     @BusinessKey
95     @Column(name = "MEMBER_ROLE")
96     private String memberRole;
97
98     @JsonProperty("tenant_metadata")
99     @BusinessKey
100     @Column(name = "TENANT_METADATA")
101     private Boolean tenantMetadata;
102
103     @JsonProperty("identity_server_type")
104     @BusinessKey
105     @Enumerated(EnumType.STRING)
106     @Column(name = "IDENTITY_SERVER_TYPE")
107     private ServerType identityServerType;
108
109     @JsonProperty("identity_authentication_type")
110     @BusinessKey
111     @Enumerated(EnumType.STRING)
112     @Column(name = "IDENTITY_AUTHENTICATION_TYPE")
113     private AuthenticationType identityAuthenticationType;
114
115     @JsonProperty("last_updated_by")
116     @BusinessKey
117     @Column(name = "LAST_UPDATED_BY")
118     private String lastUpdatedBy;
119
120     @JsonProperty("creation_timestamp")
121     @BusinessKey
122     @Column(name = "CREATION_TIMESTAMP", updatable = false)
123     @Temporal(TemporalType.TIMESTAMP)
124     private Date created;
125
126     @JsonProperty("update_timestamp")
127     @BusinessKey
128     @Column(name = "UPDATE_TIMESTAMP")
129     @Temporal(TemporalType.TIMESTAMP)
130     private Date updated;
131
132     public CloudIdentity() {}
133
134     @PrePersist
135     protected void onCreate() {
136         this.created = new Date();
137         this.updated = new Date();
138     }
139
140     @PreUpdate
141     protected void onUpdate() {
142         this.updated = new Date();
143     }
144
145     public String getId() {
146         return id;
147     }
148
149     public void setId(String id) {
150         this.id = id;
151     }
152
153     public String getIdentityUrl() {
154         return this.identityUrl;
155     }
156
157     public void setIdentityUrl(String url) {
158         this.identityUrl = url;
159     }
160
161     public String getMsoId() {
162         return msoId;
163     }
164
165     public void setMsoId(String id) {
166         this.msoId = id;
167     }
168
169     public String getMsoPass() {
170         return msoPass;
171     }
172
173     public void setMsoPass(String pwd) {
174         this.msoPass = pwd;
175     }
176
177     public String getAdminTenant() {
178         return adminTenant;
179     }
180
181     public String getLastUpdatedBy() {
182         return lastUpdatedBy;
183     }
184
185     public Date getCreated() {
186         return created;
187     }
188
189     public Date getUpdated() {
190         return updated;
191     }
192
193     public void setLastUpdatedBy(String lastUpdatedBy) {
194         this.lastUpdatedBy = lastUpdatedBy;
195     }
196
197     public void setCreated(Date created) {
198         this.created = created;
199     }
200
201     public void setUpdated(Date updated) {
202         this.updated = updated;
203     }
204
205     public void setAdminTenant(String tenant) {
206         this.adminTenant = tenant;
207     }
208
209     public String getMemberRole() {
210         return memberRole;
211     }
212
213     public void setMemberRole(String role) {
214         this.memberRole = role;
215     }
216
217     public Boolean getTenantMetadata() {
218         return tenantMetadata;
219     }
220
221     public void setTenantMetadata(Boolean meta) {
222         this.tenantMetadata = meta;
223     }
224
225     public ServerType getIdentityServerType() {
226         return this.identityServerType;
227     }
228
229     public void setIdentityServerType(ServerType ist) {
230         this.identityServerType = ist;
231     }
232
233     public String getIdentityServerTypeAsString() {
234         return this.identityServerType.toString();
235     }
236
237     /**
238      * @return the identityAuthenticationType
239      */
240     public AuthenticationType getIdentityAuthenticationType() {
241         return identityAuthenticationType;
242     }
243
244     /**
245      * @param identityAuthenticationType the identityAuthenticationType to set
246      */
247     public void setIdentityAuthenticationType(AuthenticationType identityAuthenticationType) {
248         this.identityAuthenticationType = identityAuthenticationType;
249     }
250
251     public String getProjectDomainName() {
252         return projectDomainName;
253     }
254
255     public void setProjectDomainName(String projectDomainName) {
256         this.projectDomainName = projectDomainName;
257     }
258
259     public String getAdminProjectDomainName() {
260         return adminProjectDomainName;
261     }
262
263     public void setAdminProjectDomainName(String adminProjectDomainName) {
264         this.adminProjectDomainName = adminProjectDomainName;
265     }
266
267     public String getUserDomainName() {
268         return userDomainName;
269     }
270
271     public void setUserDomainName(String userDomainName) {
272         this.userDomainName = userDomainName;
273     }
274
275     @Override
276     public CloudIdentity clone() {
277         CloudIdentity cloudIdentityCopy = new CloudIdentity();
278
279         cloudIdentityCopy.id = this.id;
280         cloudIdentityCopy.identityUrl = this.identityUrl;
281         cloudIdentityCopy.msoId = this.msoId;
282         cloudIdentityCopy.msoPass = this.msoPass;
283         cloudIdentityCopy.adminTenant = this.adminTenant;
284         cloudIdentityCopy.memberRole = this.memberRole;
285         cloudIdentityCopy.tenantMetadata = this.tenantMetadata;
286         cloudIdentityCopy.identityServerType = this.identityServerType;
287         cloudIdentityCopy.identityAuthenticationType = this.identityAuthenticationType;
288         cloudIdentityCopy.projectDomainName = this.projectDomainName;
289         cloudIdentityCopy.adminProjectDomainName = this.adminProjectDomainName;
290         cloudIdentityCopy.userDomainName = this.userDomainName;
291
292         return cloudIdentityCopy;
293     }
294
295     @Override
296     public String toString() {
297         return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("id", getId())
298                 .append("identityUrl", getIdentityUrl()).append("msoId", getMsoId())
299                 .append("projectDomain", getProjectDomainName()).append("userDomain", getUserDomainName())
300                 .append("adminTenant", getAdminTenant()).append("memberRole", getMemberRole())
301                 .append("tenantMetadata", getTenantMetadata()).append("identityServerType", getIdentityServerType())
302                 .append("identityAuthenticationType", getIdentityAuthenticationType())
303                 .append("adminProjectDomainName", getAdminProjectDomainName()).toString();
304     }
305
306     @Override
307     public boolean equals(final Object other) {
308         if (other == null) {
309             return false;
310         }
311         if (!getClass().equals(other.getClass())) {
312             return false;
313         }
314         CloudIdentity castOther = (CloudIdentity) other;
315         return new EqualsBuilder().append(getId(), castOther.getId())
316                 .append(getIdentityUrl(), castOther.getIdentityUrl()).append(getMsoId(), castOther.getMsoId())
317                 .append(getMsoPass(), castOther.getMsoPass()).append(getAdminTenant(), castOther.getAdminTenant())
318                 .append(getProjectDomainName(), castOther.getProjectDomainName())
319                 .append(getUserDomainName(), castOther.getUserDomainName())
320                 .append(getMemberRole(), castOther.getMemberRole())
321                 .append(getTenantMetadata(), castOther.getTenantMetadata())
322                 .append(getIdentityServerType(), castOther.getIdentityServerType())
323                 .append(getIdentityAuthenticationType(), castOther.getIdentityAuthenticationType())
324                 .append(getAdminProjectDomainName(), castOther.getAdminProjectDomainName()).isEquals();
325     }
326
327     @Override
328     public int hashCode() {
329         return new HashCodeBuilder(1, 31).append(getId()).append(getIdentityUrl()).append(getMsoId())
330                 .append(getMsoPass()).append(getProjectDomainName()).append(getUserDomainName())
331                 .append(getAdminTenant()).append(getMemberRole()).append(getTenantMetadata())
332                 .append(getIdentityServerType()).append(getIdentityAuthenticationType())
333                 .append(getAdminProjectDomainName()).toHashCode();
334     }
335 }