Added audit log for onboarding page details
[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 javax.validation.Valid;
45 import org.apache.commons.lang.StringUtils;
46 import org.hibernate.validator.constraints.SafeHtml;
47 import org.onap.portalsdk.core.domain.support.DomainVo;
48
49 import com.fasterxml.jackson.annotation.JsonProperty;
50 import com.fasterxml.jackson.annotation.JsonProperty.Access;
51
52 /**
53  * Model for all columns in the fn_app table.
54  */
55 public class EPApp extends DomainVo {
56
57         private static final long serialVersionUID = 1L;
58
59         @SafeHtml
60         private String name;
61
62         @SafeHtml
63         private String imageUrl;
64
65         @SafeHtml
66         private String appDescription;
67
68         @SafeHtml
69         private String appNotes;
70
71         @SafeHtml
72         private String landingPage;
73
74         @SafeHtml
75         private String alternateLandingPage;
76
77         @SafeHtml
78         private String appRestEndpoint;
79
80         @SafeHtml
81         private String mlAppName;
82
83         @SafeHtml
84         private String mlAppAdminId;
85         private Long motsId;
86
87         @SafeHtml
88         private String appBasicAuthUsername;
89
90         @SafeHtml
91         @JsonProperty(access = Access.WRITE_ONLY)
92         private String appBasicAuthPassword;
93
94         @Lob
95         private byte[] thumbnail;
96
97         private Boolean open;
98
99         private Boolean enabled;
100
101         @SafeHtml
102         private String uebTopicName;
103
104         @SafeHtml
105         private String uebKey;
106
107         @SafeHtml
108         private String uebSecret;
109
110         private Integer appType;
111
112         @Valid
113         private AppContactUs contactUs;
114
115         private Boolean rolesInAAF;
116         @SafeHtml
117         private String nameSpace;
118
119         @SafeHtml
120         private String modeOfIntegration;
121
122         private Boolean appAck;
123
124         private Boolean usesCadi;
125
126         public EPApp() {
127                 // Attention!!!
128                 // We set here all default values. We also place protection
129                 // into setters for fields with default values.
130                 // If we don't use such protection we are able to place null
131                 // to these fields and save such fields into DB even if DB has
132                 // default values for these fields.
133                 this.name = "";
134                 this.mlAppName = "";
135                 this.mlAppAdminId = "";
136                 this.appBasicAuthUsername = "";
137                 this.appBasicAuthPassword = "";
138                 this.open = new Boolean(false);
139                 this.enabled = new Boolean(true);
140                 this.uebTopicName = "";
141                 this.uebKey = "";
142                 this.uebSecret = "";
143                 this.appType = 1;
144         }
145
146         public String getName() {
147                 return name;
148         }
149
150         public void setName(String name) {
151                 if (StringUtils.isEmpty(name)) {
152                         name = "";
153                 }
154                 this.name = name;
155         }
156
157         public String getImageUrl() {
158                 return imageUrl;
159         }
160
161         public void setImageUrl(String imageUrl) {
162                 this.imageUrl = imageUrl;
163         }
164
165         public byte[] getThumbnail() {
166                 return this.thumbnail;
167         }
168
169         public void setThumbnail(byte[] thumbnail) {
170                 this.thumbnail = thumbnail;
171         }
172
173         public String getAppDescription() {
174                 return appDescription;
175         }
176
177         public void setAppDescription(String appDescription) {
178                 this.appDescription = appDescription;
179         }
180
181         public String getAppNotes() {
182                 return appNotes;
183         }
184
185         public void setAppNotes(String appNotes) {
186                 this.appNotes = appNotes;
187         }
188
189         public String getLandingPage() {
190                 return landingPage;
191         }
192
193         public void setLandingPage(String landingPage) {
194                 this.landingPage = landingPage;
195         }
196
197         public String getAlternateLandingPage() {
198                 return alternateLandingPage;
199         }
200
201         public void setAlternateLandingPage(String alternateLandingPage) {
202                 this.alternateLandingPage = alternateLandingPage;
203         }
204
205         public String getAppRestEndpoint() {
206                 return appRestEndpoint;
207         }
208
209         public void setAppRestEndpoint(String appRestEndpoint) {
210                 this.appRestEndpoint = appRestEndpoint;
211         }
212
213         public String getMlAppName() {
214                 return mlAppName;
215         }
216
217         public void setMlAppName(String mlAppName) {
218                 if (StringUtils.isEmpty(mlAppName)) {
219                         mlAppName = "";
220                 }
221                 this.mlAppName = mlAppName;
222         }
223
224         public String getMlAppAdminId() {
225                 return mlAppAdminId;
226         }
227
228         public void setMlAppAdminId(String mlAppAdminId) {
229                 if (StringUtils.isEmpty(mlAppAdminId)) {
230                         mlAppAdminId = "";
231                 }
232                 this.mlAppAdminId = mlAppAdminId;
233         }
234
235         public Long getMotsId() {
236                 return motsId;
237         }
238
239         public void setMotsId(Long motsId) {
240                 this.motsId = motsId;
241         }
242
243         public String getAppBasicAuthUsername() {
244                 return appBasicAuthUsername;
245         }
246
247         public void setAppBasicAuthUsername(String appBasicAuthUsername) {
248                 this.appBasicAuthUsername = appBasicAuthUsername;
249         }
250
251         public String getAppBasicAuthPassword() {
252                 return appBasicAuthPassword;
253         }
254
255         public void setAppBasicAuthPassword(String appBasicAuthPassword) {
256                 if (StringUtils.isEmpty(appBasicAuthPassword)) {
257                         appBasicAuthPassword = "";
258                 }
259                 this.appBasicAuthPassword = appBasicAuthPassword;
260         }
261         
262         public Boolean getOpen() {
263                 return open;
264         }
265
266         public void setOpen(Boolean open) {
267                 if (open == null) {
268                         open = new Boolean(false);
269                 }
270                 this.open = open;
271         }
272
273         public Boolean getEnabled() {
274                 return enabled;
275         }
276
277         public void setEnabled(Boolean enabled) {
278                 if (enabled == null) {
279                         enabled = new Boolean(true);
280                 }
281                 this.enabled = enabled;
282         }
283
284         public Boolean isRestrictedApp() {
285                 return (this.appType == 2 ? true : false);
286         }
287
288         public int compareTo(Object obj) {
289                 Long c1 = getId();
290                 Long c2 = ((EPApp) obj).getId();
291
292                 return c1.compareTo(c2);
293         }
294
295         public String getUebTopicName() {
296                 return this.uebTopicName;
297         }
298
299         public void setUebTopicName(String topicName) {
300                 if (StringUtils.isEmpty(topicName)) {
301                         this.uebTopicName = "";
302                 }
303                 this.uebTopicName = topicName;
304         }
305
306         public String getUebKey() {
307                 return this.uebKey;
308         }
309
310         public void setUebKey(String uebKey) {
311                 if (StringUtils.isEmpty(uebKey)) {
312                         this.uebKey = "";
313                 }
314                 this.uebKey = uebKey;
315         }
316
317         public String getUebSecret() {
318                 return this.uebSecret;
319         }
320
321         public Integer getAppType() {
322                 return appType;
323         }
324
325         public void setAppType(Integer appType) {
326                 this.appType = appType;
327         }
328
329         public void setUebSecret(String uebSecret) {
330                 if (StringUtils.isEmpty(uebSecret)) {
331                         this.uebSecret = "";
332                 }
333                 this.uebSecret = uebSecret;
334         }
335
336         public AppContactUs getContactUs() {
337                 return contactUs;
338         }
339
340         public void setContactUs(AppContactUs contactUs) {
341                 this.contactUs = contactUs;
342         }
343
344         public Boolean getRolesInAAF() {
345                 return rolesInAAF;
346         }
347
348         public void setRolesInAAF(Boolean rolesInAAF) {
349                 if (rolesInAAF == null) {
350                         rolesInAAF = new Boolean(false);
351                 }
352                 this.rolesInAAF = rolesInAAF;
353         }
354
355         public String getNameSpace() {
356                 return nameSpace;
357         }
358
359         public void setNameSpace(String nameSpace) {
360                 if (StringUtils.isEmpty(nameSpace)) {
361                         nameSpace = null;
362                 }
363                 this.nameSpace = nameSpace;
364         }
365
366         public String getModeOfIntegration() {
367                 return modeOfIntegration;
368         }
369
370         public void setModeOfIntegration(String modeOfIntegration) {
371                 this.modeOfIntegration = modeOfIntegration;
372         }
373
374         public Boolean getAppAck() {
375                 return appAck;
376         }
377
378         public void setAppAck(Boolean appAck) {
379                 this.appAck = appAck;
380         }
381
382         public Boolean getUsesCadi() {
383                 return usesCadi;
384         }
385
386         public void setUsesCadi(Boolean usesCadi) {
387                 this.usesCadi = usesCadi;
388         }
389         
390         @Override
391         public String toString() {
392                 return "EPApp [name=" + name + ", imageUrl=" + imageUrl + ", appDescription=" + appDescription + ", appNotes="
393                                 + appNotes + ", landingPage=" + landingPage + ", alternateLandingPage=" + alternateLandingPage
394                                 + ", appRestEndpoint=" + appRestEndpoint + ", mlAppName=" + mlAppName + ", mlAppAdminId=" + mlAppAdminId
395                                 + ", motsId=" + motsId + ", appBasicAuthUsername=" + appBasicAuthUsername + ", appBasicAuthPassword="
396                                 + appBasicAuthPassword + ", thumbnail=" + Arrays.toString(thumbnail) + ", open=" + open + ", enabled="
397                                 + enabled + ", uebTopicName=" + uebTopicName + ", uebKey=" + uebKey + ", uebSecret=" + uebSecret
398                                 + ", appType=" + appType + ", contactUs=" + contactUs + ", rolesInAAF=" + rolesInAAF + ", nameSpace="
399                                 + nameSpace + ", modeOfIntegration=" + modeOfIntegration + ", appAck=" + appAck + ", usesCadi="
400                                 + usesCadi + "]";
401         }
402
403         @Override
404         public int hashCode() {
405                 final int prime = 31;
406                 int result = 1;
407                 result = prime * result + ((alternateLandingPage == null) ? 0 : alternateLandingPage.hashCode());
408                 result = prime * result + ((appAck == null) ? 0 : appAck.hashCode());
409                 result = prime * result + ((appBasicAuthPassword == null) ? 0 : appBasicAuthPassword.hashCode());
410                 result = prime * result + ((appBasicAuthUsername == null) ? 0 : appBasicAuthUsername.hashCode());
411                 result = prime * result + ((appDescription == null) ? 0 : appDescription.hashCode());
412                 result = prime * result + ((appNotes == null) ? 0 : appNotes.hashCode());
413                 result = prime * result + ((appRestEndpoint == null) ? 0 : appRestEndpoint.hashCode());
414                 result = prime * result + ((appType == null) ? 0 : appType.hashCode());
415                 result = prime * result + ((enabled == null) ? 0 : enabled.hashCode());
416                 result = prime * result + ((imageUrl == null) ? 0 : imageUrl.hashCode());
417                 result = prime * result + ((landingPage == null) ? 0 : landingPage.hashCode());
418                 result = prime * result + ((mlAppAdminId == null) ? 0 : mlAppAdminId.hashCode());
419                 result = prime * result + ((mlAppName == null) ? 0 : mlAppName.hashCode());
420                 result = prime * result + ((modeOfIntegration == null) ? 0 : modeOfIntegration.hashCode());
421                 result = prime * result + ((motsId == null) ? 0 : motsId.hashCode());
422                 result = prime * result + ((name == null) ? 0 : name.hashCode());
423                 result = prime * result + ((nameSpace == null) ? 0 : nameSpace.hashCode());
424                 result = prime * result + ((open == null) ? 0 : open.hashCode());
425                 result = prime * result + ((rolesInAAF == null) ? 0 : rolesInAAF.hashCode());
426                 result = prime * result + Arrays.hashCode(thumbnail);
427                 result = prime * result + ((uebKey == null) ? 0 : uebKey.hashCode());
428                 result = prime * result + ((uebSecret == null) ? 0 : uebSecret.hashCode());
429                 result = prime * result + ((uebTopicName == null) ? 0 : uebTopicName.hashCode());
430                 result = prime * result + ((usesCadi == null) ? 0 : usesCadi.hashCode());
431                 return result;
432         }
433
434         @Override
435         public boolean equals(Object obj) {
436                 if (this == obj)
437                         return true;
438                 if (!super.equals(obj))
439                         return false;
440                 if (!(obj instanceof EPApp))
441                         return false;
442                 EPApp other = (EPApp) obj;
443                 if (alternateLandingPage == null) {
444                         if (other.alternateLandingPage != null)
445                                 return false;
446                 } else if (!alternateLandingPage.equals(other.alternateLandingPage))
447                         return false;
448                 if (appAck == null) {
449                         if (other.appAck != null)
450                                 return false;
451                 } else if (!appAck.equals(other.appAck))
452                         return false;
453                 if (appBasicAuthPassword == null) {
454                         if (other.appBasicAuthPassword != null)
455                                 return false;
456                 } else if (!appBasicAuthPassword.equals(other.appBasicAuthPassword))
457                         return false;
458                 if (appBasicAuthUsername == null) {
459                         if (other.appBasicAuthUsername != null)
460                                 return false;
461                 } else if (!appBasicAuthUsername.equals(other.appBasicAuthUsername))
462                         return false;
463                 if (appDescription == null) {
464                         if (other.appDescription != null)
465                                 return false;
466                 } else if (!appDescription.equals(other.appDescription))
467                         return false;
468                 if (appNotes == null) {
469                         if (other.appNotes != null)
470                                 return false;
471                 } else if (!appNotes.equals(other.appNotes))
472                         return false;
473                 if (appRestEndpoint == null) {
474                         if (other.appRestEndpoint != null)
475                                 return false;
476                 } else if (!appRestEndpoint.equals(other.appRestEndpoint))
477                         return false;
478                 if (appType == null) {
479                         if (other.appType != null)
480                                 return false;
481                 } else if (!appType.equals(other.appType))
482                         return false;
483                 if (enabled == null) {
484                         if (other.enabled != null)
485                                 return false;
486                 } else if (!enabled.equals(other.enabled))
487                         return false;
488                 if (imageUrl == null) {
489                         if (other.imageUrl != null)
490                                 return false;
491                 } else if (!imageUrl.equals(other.imageUrl))
492                         return false;
493                 if (landingPage == null) {
494                         if (other.landingPage != null)
495                                 return false;
496                 } else if (!landingPage.equals(other.landingPage))
497                         return false;
498                 if (mlAppAdminId == null) {
499                         if (other.mlAppAdminId != null)
500                                 return false;
501                 } else if (!mlAppAdminId.equals(other.mlAppAdminId))
502                         return false;
503                 if (mlAppName == null) {
504                         if (other.mlAppName != null)
505                                 return false;
506                 } else if (!mlAppName.equals(other.mlAppName))
507                         return false;
508                 if (modeOfIntegration == null) {
509                         if (other.modeOfIntegration != null)
510                                 return false;
511                 } else if (!modeOfIntegration.equals(other.modeOfIntegration))
512                         return false;
513                 if (motsId == null) {
514                         if (other.motsId != null)
515                                 return false;
516                 } else if (!motsId.equals(other.motsId))
517                         return false;
518                 if (name == null) {
519                         if (other.name != null)
520                                 return false;
521                 } else if (!name.equals(other.name))
522                         return false;
523                 if (nameSpace == null) {
524                         if (other.nameSpace != null)
525                                 return false;
526                 } else if (!nameSpace.equals(other.nameSpace))
527                         return false;
528                 if (open == null) {
529                         if (other.open != null)
530                                 return false;
531                 } else if (!open.equals(other.open))
532                         return false;
533                 if (rolesInAAF == null) {
534                         if (other.rolesInAAF != null)
535                                 return false;
536                 } else if (!rolesInAAF.equals(other.rolesInAAF))
537                         return false;
538                 if (!Arrays.equals(thumbnail, other.thumbnail))
539                         return false;
540                 if (uebKey == null) {
541                         if (other.uebKey != null)
542                                 return false;
543                 } else if (!uebKey.equals(other.uebKey))
544                         return false;
545                 if (uebSecret == null) {
546                         if (other.uebSecret != null)
547                                 return false;
548                 } else if (!uebSecret.equals(other.uebSecret))
549                         return false;
550                 if (uebTopicName == null) {
551                         if (other.uebTopicName != null)
552                                 return false;
553                 } else if (!uebTopicName.equals(other.uebTopicName))
554                         return false;
555                 if (usesCadi == null) {
556                         if (other.usesCadi != null)
557                                 return false;
558                 } else if (!usesCadi.equals(other.usesCadi))
559                         return false;
560                 return true;
561         }
562
563         
564 }