Update gvnfm-driver .gitreview file
[vfc/nfvo/driver/vnfm/gvnfm.git] / juju / juju-vnfmadapter / Juju-vnfmadapterService / service / src / main / java / org / openo / nfvo / jujuvnfmadapter / service / entity / Vnfm.java
1 /*
2  * Copyright 2016 Huawei Technologies Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package org.openo.nfvo.jujuvnfmadapter.service.entity;
18
19 import java.text.SimpleDateFormat;
20 import java.util.Date;
21
22 import net.sf.json.JSONObject;
23
24 import org.apache.commons.lang3.StringUtils;
25 import org.apache.commons.lang3.builder.ToStringBuilder;
26 import org.apache.commons.lang3.builder.ToStringStyle;
27 import org.openo.nfvo.jujuvnfmadapter.common.CryptUtil;
28 import org.openo.nfvo.jujuvnfmadapter.service.constant.Constant;
29
30 /**
31  * 
32  * VNFM class.<br>
33  * <p>
34  * </p>
35  * 
36  * @author
37  * @version     NFVO 0.5  Sep 12, 2016
38  */
39 public class Vnfm {
40
41     private String id;
42
43     private String name;
44
45     private String type;
46
47     private String version;
48
49     private String userName;
50
51     private String pwd;
52
53     private String url;
54
55     private String sites;
56
57     private String extraInfo;
58
59     private String status;
60
61     private String createAt;
62
63     private String updateAt;
64
65     public String getId() {
66         return id;
67     }
68
69     public void setId(String id) {
70         this.id = id;
71     }
72
73     public String getType() {
74         return type;
75     }
76
77     public void setType(String type) {
78         this.type = type;
79     }
80
81     public String getName() {
82         return name;
83     }
84
85     public void setName(String name) {
86         this.name = name;
87     }
88
89     public String getVersion() {
90         return version;
91     }
92
93     public void setVersion(String version) {
94         this.version = version;
95     }
96
97     public String getUserName() {
98         return userName;
99     }
100
101     public void setUserName(String userName) {
102         this.userName = userName;
103     }
104
105     public String getUrl() {
106         return url;
107     }
108
109     public void setUrl(String url) {
110         this.url = url;
111     }
112
113     public String getPwd() {
114         return pwd;
115     }
116
117     public void setPwd(String pwd) {
118         this.pwd = pwd;
119     }
120
121     public String getSites() {
122         return sites;
123     }
124
125     public void setSites(String sites) {
126         this.sites = sites;
127     }
128
129     public String getExtraInfo() {
130         return extraInfo;
131     }
132
133     public void setExtraInfo(String extraInfo) {
134         this.extraInfo = extraInfo;
135     }
136
137     public String getStatus() {
138         return status;
139     }
140
141     public void setStatus(String status) {
142         this.status = status;
143     }
144
145     public String getCreateAt() {
146         return createAt;
147     }
148
149     public void setCreateAt(String createAt) {
150         this.createAt = createAt;
151     }
152
153     public String getUpdateAt() {
154         return updateAt;
155     }
156
157     public void setUpdateAt(String updateAt) {
158         this.updateAt = updateAt;
159     }
160
161
162
163     @Override
164     public String toString() {
165         return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
166     }
167
168     @Override
169     public int hashCode() {
170         final int prime = 31;
171         int result = 1;
172         result = prime * result + ((id == null) ? 0 : id.hashCode());
173         return result;
174     }
175
176     @Override
177     public boolean equals(Object obj) {
178         if(this == obj) {
179             return true;
180         }
181         if(obj == null) {
182             return false;
183         }
184         if(!(obj instanceof Vnfm)) {
185             return false;
186         }
187         if(getClass() != obj.getClass()) {
188             return false;
189         }
190         Vnfm other = (Vnfm)obj;
191         if(id == null) {
192             if(other.id != null) {
193                 return false;
194             }
195         } else if(!id.equals(other.id)) {
196             return false;
197         }
198         return true;
199     }
200
201     /**
202      * 
203      * Update Vnfm.<br>
204      * 
205      * @param otherVnfm
206      * @since  NFVO 0.5
207      */
208     public void updateVnfm(JSONObject otherVnfm) {
209         String vnfmName = otherVnfm.getString("name");
210         String vnfmUserName = otherVnfm.getString("userName");
211         String vnfmPwd = CryptUtil.enCrypt(otherVnfm.getString("pwd"));
212
213         if(!StringUtils.isEmpty(vnfmName)) {
214             this.name = vnfmName;
215         }
216
217         if(!StringUtils.isEmpty(vnfmUserName)) {
218             this.userName = vnfmUserName;
219         }
220
221         if(!StringUtils.isEmpty(vnfmPwd)) {
222             this.pwd = vnfmPwd;
223         }
224
225         String vnfmExtraInfo = otherVnfm.get("extraInfo").toString();
226         if(!StringUtils.isEmpty(vnfmExtraInfo)) {
227             this.extraInfo = vnfmExtraInfo;
228         }
229
230         this.updateAt = new SimpleDateFormat(Constant.DATE_FORMAT).format(new Date());
231     }
232 }