Release version 1.13.7
[sdc.git] / catalog-model / src / main / java / org / openecomp / sdc / be / model / User.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
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 package org.openecomp.sdc.be.model;
21
22 import com.fasterxml.jackson.annotation.JsonInclude;
23 import java.time.ZonedDateTime;
24 import lombok.EqualsAndHashCode;
25 import lombok.Getter;
26 import lombok.NoArgsConstructor;
27 import lombok.Setter;
28 import lombok.ToString;
29 import org.openecomp.sdc.be.dao.utils.UserStatusEnum;
30 import org.openecomp.sdc.common.util.NoHtml;
31
32 @JsonInclude
33 @NoArgsConstructor
34 @Getter
35 @Setter
36 @ToString
37 @EqualsAndHashCode
38 public class User {
39
40     public static final String FORCE_DELETE_HEADER_FLAG = "FORCE_DELETE";
41     @NoHtml
42     private String firstName;
43     @NoHtml
44     private String lastName;
45     @NoHtml
46     private String userId;
47     @NoHtml
48     private String email;
49     @NoHtml
50     private String role;
51     private Long lastLoginTime;
52     @ToString.Exclude
53     @EqualsAndHashCode.Exclude
54     private UserStatusEnum status = UserStatusEnum.ACTIVE;
55
56     public User(String userId) {
57         this.userId = userId;
58     }
59
60     public User(String firstName, String lastName, String userId, String emailAddress, String role, Long lastLoginTime) {
61         this.firstName = firstName;
62         this.lastName = lastName;
63         this.userId = userId;
64         this.email = emailAddress;
65         this.role = role;
66         this.lastLoginTime = lastLoginTime;
67     }
68
69     public User(User aUser) {
70         this(aUser.getFirstName(), aUser.getLastName(), aUser.getUserId(), aUser.getEmail(), aUser.getRole(), aUser.getLastLoginTime());
71     }
72
73     public void copyData(User other) {
74         if (other == null) {
75             return;
76         }
77         this.firstName = other.getFirstName();
78         this.lastName = other.getLastName();
79         this.userId = other.getUserId();
80         this.email = other.getEmail();
81         this.role = other.getRole();
82         this.lastLoginTime = other.getLastLoginTime();
83     }
84
85     public String getFullName() {
86         return this.getFirstName() + " " + this.getLastName();
87     }
88
89     public void setLastLoginTime() {
90         this.lastLoginTime = ZonedDateTime.now().toInstant().toEpochMilli();
91     }
92
93 }