Fix sql injection vulnerability
[portal.git] / ecomp-portal-BE-common / src / main / java / org / onap / portalapp / portal / domain / EPApp.java
1 /*-
2  * ============LICENSE_START==========================================
3  * ONAP Portal
4  * ===================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ===================================================================
7  *
8  * Unless otherwise specified, all software contained herein is licensed
9  * under the Apache License, Version 2.0 (the "License");
10  * you may not use this software except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *             http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  * Unless otherwise specified, all documentation contained herein is licensed
22  * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
23  * you may not use this documentation except in compliance with the License.
24  * You may obtain a copy of the License at
25  *
26  *             https://creativecommons.org/licenses/by/4.0/
27  *
28  * Unless required by applicable law or agreed to in writing, documentation
29  * distributed under the License is distributed on an "AS IS" BASIS,
30  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31  * See the License for the specific language governing permissions and
32  * limitations under the License.
33  *
34  * ============LICENSE_END============================================
35  *
36  * 
37  */
38 package org.onap.portalapp.portal.domain;
39
40 import java.util.Arrays;
41
42 import javax.persistence.Lob;
43
44 import org.apache.commons.lang.StringUtils;
45 import org.onap.portalsdk.core.domain.support.DomainVo;
46
47 /**
48  * Model for all columns in the fn_app table.
49  */
50 public class EPApp extends DomainVo {
51
52         private static final long serialVersionUID = 1L;
53
54         private String name;
55         private String imageUrl;
56         private String description;
57         private String notes;
58         private String url;
59         private String alternateUrl;
60         private String appRestEndpoint;
61         private String mlAppName;
62         private String mlAppAdminId;
63         private Long motsId;
64         private String username;
65         private String appPassword;
66         @Lob
67         private byte[] thumbnail;
68         private Boolean open;
69         private Boolean enabled;
70         private String uebTopicName;
71         private String uebKey;
72         private String uebSecret;
73         private Integer appType;
74         private AppContactUs contactUs;
75         private Boolean centralAuth;
76         private String  nameSpace;
77
78         public EPApp() {
79                 // Attention!!!
80                 // We set here all default values. We also place protection
81                 // into setters for fields with default values.
82                 // If we don't use such protection we are able to place null
83                 // to these fields and save such fields into DB even if DB has
84                 // default values for these fields.
85                 this.name = "";
86                 this.mlAppName = "";
87                 this.mlAppAdminId = "";
88                 this.username = "";
89                 this.appPassword = "";
90                 this.open = new Boolean(false);
91                 this.enabled = new Boolean(true);
92                 this.uebTopicName = "";
93                 this.uebKey = "";
94                 this.uebSecret = "";
95                 this.appType = 1;
96         }
97
98         public String getName() {
99                 return name;
100         }
101
102         public void setName(String name) {
103                 if (StringUtils.isEmpty(name)) {
104                         name = "";
105                 }
106                 this.name = name;
107         }
108
109         public String getImageUrl() {
110                 return imageUrl;
111         }
112
113         public void setImageUrl(String imageUrl) {
114                 this.imageUrl = imageUrl;
115         }
116
117
118
119         public byte[] getThumbnail() {
120                 return this.thumbnail;
121         }
122
123         public void setThumbnail(byte[] thumbnail) {
124                 this.thumbnail = thumbnail;
125         }
126
127         public String getDescription() {
128                 return description;
129         }
130
131         public void setDescription(String description) {
132                 this.description = description;
133         }
134
135         public String getNotes() {
136                 return notes;
137         }
138
139         public void setNotes(String notes) {
140                 this.notes = notes;
141         }
142
143         public String getUrl() {
144                 return url;
145         }
146
147         public void setUrl(String url) {
148                 this.url = url;
149         }
150
151         public String getAlternateUrl() {
152                 return alternateUrl;
153         }
154
155         public void setAlternateUrl(String alternateUrl) {
156                 this.alternateUrl = alternateUrl;
157         }
158
159         public String getAppRestEndpoint() {
160                 return appRestEndpoint;
161         }
162
163         public void setAppRestEndpoint(String appRestEndpoint) {
164                 this.appRestEndpoint = appRestEndpoint;
165         }
166
167         public String getMlAppName() {
168                 return mlAppName;
169         }
170
171         public void setMlAppName(String mlAppName) {
172                 if (StringUtils.isEmpty(mlAppName)) {
173                         mlAppName = "";
174                 }
175                 this.mlAppName = mlAppName;
176         }
177
178         public String getMlAppAdminId() {
179                 return mlAppAdminId;
180         }
181
182         public void setMlAppAdminId(String mlAppAdminId) {
183                 if (StringUtils.isEmpty(mlAppAdminId)) {
184                         mlAppAdminId = "";
185                 }
186                 this.mlAppAdminId = mlAppAdminId;
187         }
188
189         public Long getMotsId() {
190                 return motsId;
191         }
192
193         public void setMotsId(Long motsId) {
194                 this.motsId = motsId;
195         }
196
197         public String getUsername() {
198                 return username;
199         }
200
201         public void setUsername(String username) {
202                 this.username = username;
203         }
204
205         public String getAppPassword() {
206                 return appPassword;
207         }
208
209         public void setAppPassword(String appPassword) {
210                 if (StringUtils.isEmpty(appPassword)) {
211                         appPassword = "";
212                 }
213                 this.appPassword = appPassword;
214         }
215
216         public Boolean getOpen() {
217                 return open;
218         }
219
220         public void setOpen(Boolean open) {
221                 if (open == null) {
222                         open = new Boolean(false);
223                 }
224                 this.open = open;
225         }
226
227         public Boolean getEnabled() {
228                 return enabled;
229         }
230
231         public void setEnabled(Boolean enabled) {
232                 if (enabled == null) {
233                         enabled = new Boolean(true);
234                 }
235                 this.enabled = enabled;
236         }
237
238         public Integer getAppType() {
239                 return appType;
240         }
241
242         public void setAppType(Integer appType) {
243                 if (appType == null) {
244                         appType = new Integer(1);
245                 }
246                 this.appType = appType;
247         }
248
249         public void setRestrictedApp(Boolean restrictedApp) {
250                 Integer result = 1;
251                 if (restrictedApp) {
252                         result = 2;
253                 }
254                 this.appType = result;
255         }
256
257         public Boolean isRestrictedApp() {
258                 return (this.appType == 2 ? true : false);
259         }
260
261         public int compareTo(Object obj) {
262                 Long c1 = getId();
263                 Long c2 = ((EPApp) obj).getId();
264
265                 return c1.compareTo(c2);
266         }
267
268         public String getUebTopicName() {
269                 return this.uebTopicName;
270         }
271
272         public void setUebTopicName(String topicName) {
273                 if (StringUtils.isEmpty(topicName)) {
274                         this.uebTopicName = "";
275                 }
276                 this.uebTopicName = topicName;
277         }
278
279         public String getUebKey() {
280                 return this.uebKey;
281         }
282
283         public void setUebKey(String uebKey) {
284                 if (StringUtils.isEmpty(uebKey)) {
285                         this.uebKey = "";
286                 }
287                 this.uebKey = uebKey;
288         }
289
290         public String getUebSecret() {
291                 return this.uebSecret;
292         }
293
294         public void setUebSecret(String uebSecret) {
295                 if (StringUtils.isEmpty(uebSecret)) {
296                         this.uebSecret = "";
297                 }
298                 this.uebSecret = uebSecret;
299         }
300
301         public AppContactUs getContactUs() {
302                 return contactUs;
303         }
304
305         public void setContactUs(AppContactUs contactUs) {
306                 this.contactUs = contactUs;
307         }
308         
309         public Boolean getCentralAuth() {
310                 return centralAuth;
311         }
312
313         public void setCentralAuth(Boolean centralAuth) {
314                 if (centralAuth == null) {
315                         centralAuth = new Boolean(false);
316                 }
317                 this.centralAuth = centralAuth;
318         }
319         
320         public String getNameSpace() {
321                 return nameSpace;
322         }
323
324         public void setNameSpace(String nameSpace) {
325                 if (StringUtils.isEmpty(nameSpace)) {
326                         nameSpace = null;
327                 }
328                 this.nameSpace = nameSpace;
329         }
330
331         @Override
332         public String toString() {
333                 String str = "[" + getId() + ":" + getName() + "]";
334                 return str;
335         }
336
337         @Override
338         public int hashCode() {
339                 final int prime = 31;
340                 int result = 1;
341                 result = prime * result + ((alternateUrl == null) ? 0 : alternateUrl.hashCode());
342                 result = prime * result + ((appPassword == null) ? 0 : appPassword.hashCode());
343                 result = prime * result + ((appRestEndpoint == null) ? 0 : appRestEndpoint.hashCode());
344                 result = prime * result + ((appType == null) ? 0 : appType.hashCode());
345                 result = prime * result + ((centralAuth == null) ? 0 : centralAuth.hashCode());
346                 result = prime * result + ((contactUs == null) ? 0 : contactUs.hashCode());
347                 result = prime * result + ((description == null) ? 0 : description.hashCode());
348                 result = prime * result + ((enabled == null) ? 0 : enabled.hashCode());
349                 result = prime * result + ((imageUrl == null) ? 0 : imageUrl.hashCode());
350                 result = prime * result + ((mlAppAdminId == null) ? 0 : mlAppAdminId.hashCode());
351                 result = prime * result + ((mlAppName == null) ? 0 : mlAppName.hashCode());
352                 result = prime * result + ((motsId == null) ? 0 : motsId.hashCode());
353                 result = prime * result + ((name == null) ? 0 : name.hashCode());
354                 result = prime * result + ((nameSpace == null) ? 0 : nameSpace.hashCode());
355                 result = prime * result + ((notes == null) ? 0 : notes.hashCode());
356                 result = prime * result + ((open == null) ? 0 : open.hashCode());
357                 result = prime * result + Arrays.hashCode(thumbnail);
358                 result = prime * result + ((uebKey == null) ? 0 : uebKey.hashCode());
359                 result = prime * result + ((uebSecret == null) ? 0 : uebSecret.hashCode());
360                 result = prime * result + ((uebTopicName == null) ? 0 : uebTopicName.hashCode());
361                 result = prime * result + ((url == null) ? 0 : url.hashCode());
362                 result = prime * result + ((username == null) ? 0 : username.hashCode());
363                 return result;
364         }
365
366         @Override
367         public boolean equals(Object obj) {
368                 if (this == obj)
369                         return true;
370                 if (obj == null)
371                         return false;
372                 if (getClass() != obj.getClass())
373                         return false;
374                 EPApp other = (EPApp) obj;
375                 if (alternateUrl == null) {
376                         if (other.alternateUrl != null)
377                                 return false;
378                 } else if (!alternateUrl.equals(other.alternateUrl))
379                         return false;
380                 if (appPassword == null) {
381                         if (other.appPassword != null)
382                                 return false;
383                 } else if (!appPassword.equals(other.appPassword))
384                         return false;
385                 if (appRestEndpoint == null) {
386                         if (other.appRestEndpoint != null)
387                                 return false;
388                 } else if (!appRestEndpoint.equals(other.appRestEndpoint))
389                         return false;
390                 if (appType == null) {
391                         if (other.appType != null)
392                                 return false;
393                 } else if (!appType.equals(other.appType))
394                         return false;
395                 if (centralAuth == null) {
396                         if (other.centralAuth != null)
397                                 return false;
398                 } else if (!centralAuth.equals(other.centralAuth))
399                         return false;
400                 if (contactUs == null) {
401                         if (other.contactUs != null)
402                                 return false;
403                 } else if (!contactUs.equals(other.contactUs))
404                         return false;
405                 if (description == null) {
406                         if (other.description != null)
407                                 return false;
408                 } else if (!description.equals(other.description))
409                         return false;
410                 if (enabled == null) {
411                         if (other.enabled != null)
412                                 return false;
413                 } else if (!enabled.equals(other.enabled))
414                         return false;
415                 if (imageUrl == null) {
416                         if (other.imageUrl != null)
417                                 return false;
418                 } else if (!imageUrl.equals(other.imageUrl))
419                         return false;
420                 if (mlAppAdminId == null) {
421                         if (other.mlAppAdminId != null)
422                                 return false;
423                 } else if (!mlAppAdminId.equals(other.mlAppAdminId))
424                         return false;
425                 if (mlAppName == null) {
426                         if (other.mlAppName != null)
427                                 return false;
428                 } else if (!mlAppName.equals(other.mlAppName))
429                         return false;
430                 if (motsId == null) {
431                         if (other.motsId != null)
432                                 return false;
433                 } else if (!motsId.equals(other.motsId))
434                         return false;
435                 if (name == null) {
436                         if (other.name != null)
437                                 return false;
438                 } else if (!name.equals(other.name))
439                         return false;
440                 if (nameSpace == null) {
441                         if (other.nameSpace != null)
442                                 return false;
443                 } else if (!nameSpace.equals(other.nameSpace))
444                         return false;
445                 if (notes == null) {
446                         if (other.notes != null)
447                                 return false;
448                 } else if (!notes.equals(other.notes))
449                         return false;
450                 if (open == null) {
451                         if (other.open != null)
452                                 return false;
453                 } else if (!open.equals(other.open))
454                         return false;
455                 if (!Arrays.equals(thumbnail, other.thumbnail))
456                         return false;
457                 if (uebKey == null) {
458                         if (other.uebKey != null)
459                                 return false;
460                 } else if (!uebKey.equals(other.uebKey))
461                         return false;
462                 if (uebSecret == null) {
463                         if (other.uebSecret != null)
464                                 return false;
465                 } else if (!uebSecret.equals(other.uebSecret))
466                         return false;
467                 if (uebTopicName == null) {
468                         if (other.uebTopicName != null)
469                                 return false;
470                 } else if (!uebTopicName.equals(other.uebTopicName))
471                         return false;
472                 if (url == null) {
473                         if (other.url != null)
474                                 return false;
475                 } else if (!url.equals(other.url))
476                         return false;
477                 if (username == null) {
478                         if (other.username != null)
479                                 return false;
480                 } else if (!username.equals(other.username))
481                         return false;
482                 return true;
483         }
484 }