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=========================================================
20 package org.openecomp.sdc.be.model;
22 import com.fasterxml.jackson.annotation.JsonInclude;
23 import org.joda.time.DateTime;
24 import org.joda.time.DateTimeZone;
25 import org.openecomp.sdc.be.dao.utils.UserStatusEnum;
26 import org.openecomp.sdc.be.resources.data.UserData;
31 public static final String FORCE_DELETE_HEADER_FLAG = "FORCE_DELETE";
32 private String firstName;
33 private String lastName;
34 private String userId;
37 private Long lastLoginTime;
38 private UserStatusEnum status = UserStatusEnum.ACTIVE;
43 public User(String userId) {
47 public User(UserData userDate) {
48 this(userDate.getFirstName(), userDate.getLastName(), userDate.getUserId(), userDate.getEmail(), userDate.getRole(),
49 userDate.getLastLoginTime());
52 public User(String firstName, String lastName, String userId, String emailAddress, String role, Long lastLoginTime) {
53 this.firstName = firstName;
54 this.lastName = lastName;
56 this.email = emailAddress;
58 this.lastLoginTime = lastLoginTime;
61 public User(User aUser) {
62 this(aUser.getFirstName(), aUser.getLastName(), aUser.getUserId(), aUser.getEmail(), aUser.getRole(), aUser.getLastLoginTime());
65 public void copyData(User other) {
69 this.firstName = other.getFirstName();
70 this.lastName = other.getLastName();
71 this.userId = other.getUserId();
72 this.email = other.getEmail();
73 this.role = other.getRole();
74 this.lastLoginTime = other.getLastLoginTime();
77 public String getFirstName() {
81 public void setFirstName(String firstName) {
82 this.firstName = firstName;
85 public String getLastName() {
89 public void setLastName(String lastName) {
90 this.lastName = lastName;
93 public String getUserId() {
97 public void setUserId(String userId) {
101 public String getEmail() {
105 public void setEmail(String email) {
109 public String getRole() {
113 public void setRole(String role) {
117 public String getFullName() {
118 return this.getFirstName() + " " + this.getLastName();
121 public void setLastLoginTime() {
122 DateTime now = new DateTime(DateTimeZone.UTC);
123 this.lastLoginTime = now.getMillis();
126 public Long getLastLoginTime() {
127 return this.lastLoginTime;
130 public void setLastLoginTime(Long time) {
131 this.lastLoginTime = time;
135 public int hashCode() {
136 final int prime = 31;
138 result = prime * result + ((userId == null) ? 0 : userId.hashCode());
139 result = prime * result + ((email == null) ? 0 : email.hashCode());
140 result = prime * result + ((firstName == null) ? 0 : firstName.hashCode());
141 result = prime * result + ((lastName == null) ? 0 : lastName.hashCode());
142 result = prime * result + ((role == null) ? 0 : role.hashCode());
143 result = prime * result + ((lastLoginTime == null) ? 0 : lastLoginTime.hashCode());
148 public boolean equals(Object obj) {
155 if (getClass() != obj.getClass()) {
158 User other = (User) obj;
159 if (userId == null) {
160 if (other.userId != null) {
163 } else if (!userId.equals(other.userId)) {
167 if (other.email != null) {
170 } else if (!email.equals(other.email)) {
173 if (firstName == null) {
174 if (other.firstName != null) {
177 } else if (!firstName.equals(other.firstName)) {
180 if (lastName == null) {
181 if (other.lastName != null) {
184 } else if (!lastName.equals(other.lastName)) {
188 if (other.role != null) {
191 } else if (!role.equals(other.role)) {
194 if (lastLoginTime == null) {
195 if (other.lastLoginTime != null) {
198 } else if (!lastLoginTime.equals(other.lastLoginTime)) {
204 public UserStatusEnum getStatus() {
208 public void setStatus(UserStatusEnum status) {
209 this.status = status;
213 public String toString() {
214 return "User [firstName=" + firstName + ", lastName=" + lastName + ", userId=" + userId + ", email=" + email + ", role=" + role
215 + ", last login time=" + lastLoginTime + "]";