2 * Copyright 2016 Huawei Technologies Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package org.openo.nfvo.jujuvnfmadapter.service.entity;
19 import java.text.SimpleDateFormat;
20 import java.util.Date;
22 import net.sf.json.JSONObject;
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;
37 * @version NFVO 0.5 Sep 12, 2016
47 private String version;
49 private String userName;
57 private String extraInfo;
59 private String status;
61 private String createAt;
63 private String updateAt;
65 public String getId() {
69 public void setId(String id) {
73 public String getType() {
77 public void setType(String type) {
81 public String getName() {
85 public void setName(String name) {
89 public String getVersion() {
93 public void setVersion(String version) {
94 this.version = version;
97 public String getUserName() {
101 public void setUserName(String userName) {
102 this.userName = userName;
105 public String getUrl() {
109 public void setUrl(String url) {
113 public String getPwd() {
117 public void setPwd(String pwd) {
121 public String getSites() {
125 public void setSites(String sites) {
129 public String getExtraInfo() {
133 public void setExtraInfo(String extraInfo) {
134 this.extraInfo = extraInfo;
137 public String getStatus() {
141 public void setStatus(String status) {
142 this.status = status;
145 public String getCreateAt() {
149 public void setCreateAt(String createAt) {
150 this.createAt = createAt;
153 public String getUpdateAt() {
157 public void setUpdateAt(String updateAt) {
158 this.updateAt = updateAt;
164 public String toString() {
165 return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
169 public int hashCode() {
170 final int prime = 31;
172 result = prime * result + ((id == null) ? 0 : id.hashCode());
177 public boolean equals(Object obj) {
184 if(!(obj instanceof Vnfm)) {
187 if(getClass() != obj.getClass()) {
190 Vnfm other = (Vnfm)obj;
192 if(other.id != null) {
195 } else if(!id.equals(other.id)) {
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"));
213 if(!StringUtils.isEmpty(vnfmName)) {
214 this.name = vnfmName;
217 if(!StringUtils.isEmpty(vnfmUserName)) {
218 this.userName = vnfmUserName;
221 if(!StringUtils.isEmpty(vnfmPwd)) {
225 String vnfmExtraInfo = otherVnfm.get("extraInfo").toString();
226 if(!StringUtils.isEmpty(vnfmExtraInfo)) {
227 this.extraInfo = vnfmExtraInfo;
230 this.updateAt = new SimpleDateFormat(Constant.DATE_FORMAT).format(new Date());