diff options
author | Manoop Talasila <talasila@research.att.com> | 2019-09-16 15:50:47 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-09-16 15:50:47 +0000 |
commit | 99a220e3fccdabca5c5d1f63582a77a0379ac057 (patch) | |
tree | ae04eb1f1b17b1e7b0c80704d291df3e09d3baa9 /portal-BE/src/main | |
parent | 510f243992dc434f51178d1797a8045de839c25f (diff) | |
parent | bfb078b48e3558777b60a91775ea3c239a1f3a05 (diff) |
Merge changes Ia1e5c405,Ie890b499,Ie8b58f17,I76c96d30,I7814f090, ...
* changes:
WidgetsControllerTest up
WidgetsCatalogController up
WidgetsCatalogMarkupController up
WidgetsController Up
WidgetsController Up
WidgetsController Up
portal-BE documentation up
Docker-compose up
Coverity Scan issues fix
Diffstat (limited to 'portal-BE/src/main')
142 files changed, 3442 insertions, 1384 deletions
diff --git a/portal-BE/src/main/java/org/onap/portal/configuration/SecurityConfig.java b/portal-BE/src/main/java/org/onap/portal/configuration/SecurityConfig.java index b9e60334..3fae09cf 100644 --- a/portal-BE/src/main/java/org/onap/portal/configuration/SecurityConfig.java +++ b/portal-BE/src/main/java/org/onap/portal/configuration/SecurityConfig.java @@ -75,7 +75,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter { protected void configure(HttpSecurity http) throws Exception { http .authorizeRequests() - .antMatchers("/static/img/**").permitAll() + .antMatchers("/img/**").permitAll() .anyRequest().authenticated() .and() .formLogin() diff --git a/portal-BE/src/main/java/org/onap/portal/controller/LoginController.java b/portal-BE/src/main/java/org/onap/portal/controller/LoginController.java index 0d6de152..3ada12fd 100644 --- a/portal-BE/src/main/java/org/onap/portal/controller/LoginController.java +++ b/portal-BE/src/main/java/org/onap/portal/controller/LoginController.java @@ -41,13 +41,12 @@ package org.onap.portal.controller; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; @Controller public class LoginController { - @RequestMapping(value = "login", method = RequestMethod.GET) + @GetMapping(value = "login") public String loginView() { return "login"; } diff --git a/portal-BE/src/main/java/org/onap/portal/controller/UserController.java b/portal-BE/src/main/java/org/onap/portal/controller/UserController.java index abc91855..c2dcccd6 100644 --- a/portal-BE/src/main/java/org/onap/portal/controller/UserController.java +++ b/portal-BE/src/main/java/org/onap/portal/controller/UserController.java @@ -50,10 +50,11 @@ import org.onap.portal.validation.DataValidator; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.onap.portalsdk.core.onboarding.util.CipherUtil; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.MediaType; import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; @RestController @@ -73,7 +74,7 @@ public class UserController { this.dataValidator = dataValidator; } - @RequestMapping(value = {"/portalApi/loggedinUser"}, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = {"/portalApi/loggedinUser"}, produces = MediaType.APPLICATION_JSON_VALUE) public PortalRestResponse<ProfileDetail> getLoggedinUser(Principal principal) { PortalRestResponse<ProfileDetail> portalRestResponse = null; try { @@ -90,8 +91,7 @@ public class UserController { return portalRestResponse; } - @RequestMapping(value = { - "/portalApi/modifyLoggedinUser"}, method = RequestMethod.PUT, produces = "application/json") + @PutMapping(value = {"/portalApi/modifyLoggedinUser"}, produces = MediaType.APPLICATION_JSON_VALUE) public PortalRestResponse<String> modifyLoggedinUser(Principal principal, @RequestBody ProfileDetail profileDetail) { PortalRestResponse<String> portalRestResponse = null; @@ -99,7 +99,8 @@ public class UserController { String errorMsg = ""; if (!dataValidator.isValid(profileDetail)) { errorMsg = "Required field(s) is missing"; - portalRestResponse = new PortalRestResponse<>(PortalRestStatusEnum.ERROR, dataValidator.getConstraintViolationsString(profileDetail), null); + portalRestResponse = new PortalRestResponse<>(PortalRestStatusEnum.ERROR, + dataValidator.getConstraintViolationsString(profileDetail), null); logger.error(EELFLoggerDelegate.errorLogger, "modifyLoggedinUser failed", errorMsg); } else { FnUser user = userService.loadUserByUsername(principal.getName()); @@ -109,7 +110,8 @@ public class UserController { user.setMiddleName(profileDetail.getMiddleName()); user.setLoginId(profileDetail.getLoginId()); if (!HIDDEN_DEFAULT_PASSWORD.equals(profileDetail.getLoginPassword())) { - user.setLoginPwd(CipherUtil.encryptPKC(profileDetail.getLoginPassword(), "AGLDdG4D04BKm2IxIWEr8o==!")); + user.setLoginPwd(CipherUtil + .encryptPKC(profileDetail.getLoginPassword(), "AGLDdG4D04BKm2IxIWEr8o==!")); } userService.saveFnUser(principal, user); // Update user info in the session diff --git a/portal-BE/src/main/java/org/onap/portal/controller/WidgetsCatalogController.java b/portal-BE/src/main/java/org/onap/portal/controller/WidgetsCatalogController.java new file mode 100644 index 00000000..decf625d --- /dev/null +++ b/portal-BE/src/main/java/org/onap/portal/controller/WidgetsCatalogController.java @@ -0,0 +1,430 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * + */ +package org.onap.portal.controller; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.security.Principal; +import java.util.ArrayList; +import java.util.List; +import javax.servlet.ServletContext; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import org.apache.commons.lang.StringUtils; +import org.onap.portal.domain.db.fn.FnUser; +import org.onap.portal.domain.dto.PortalRestResponse; +import org.onap.portal.domain.dto.PortalRestStatusEnum; +import org.onap.portal.domain.dto.ecomp.MicroserviceParameter; +import org.onap.portal.domain.dto.ecomp.WidgetCatalog; +import org.onap.portal.domain.dto.ecomp.WidgetCatalogParameter; +import org.onap.portal.domain.dto.ecomp.WidgetParameterResult; +import org.onap.portal.domain.dto.ecomp.WidgetServiceHeaders; +import org.onap.portal.logging.aop.EPAuditLog; +import org.onap.portal.service.WidgetMService; +import org.onap.portal.service.ep.EpMicroserviceParameterService; +import org.onap.portal.service.ep.EpWidgetCatalogParameterService; +import org.onap.portal.service.fn.FnUserService; +import org.onap.portal.utils.EPCommonSystemProperties; +import org.onap.portal.utils.EcompPortalUtils; +import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.onap.portalsdk.core.util.SystemProperties; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.core.io.FileSystemResource; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.client.RestTemplate; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.multipart.MultipartHttpServletRequest; + +@RestController +@EnableAspectJAutoProxy +@EPAuditLog +public class WidgetsCatalogController { + + private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(WidgetsCatalogController.class); + + private static final String MS_WIDGET_LOCAL_PORT = "microservices.widget.local.port"; + private static final String UNAUTHORIZED_OR_FORBIDDEN_FOR_A_DISABLED_USER = "Unauthorized or Forbidden for a disabled user"; + private RestTemplate template = new RestTemplate(); + private String whatService = "widgets-service"; + + private final EpWidgetCatalogParameterService epWidgetCatalogParameterService; + private final EpMicroserviceParameterService epMicroserviceParameterService; + private final WidgetMService widgetMService; + private final FnUserService fnUserService; + + @Autowired + public WidgetsCatalogController(final EpWidgetCatalogParameterService epWidgetCatalogParameterService, + final EpMicroserviceParameterService epMicroserviceParameterService, + final WidgetMService widgetMService, + final FnUserService fnUserService) { + this.epWidgetCatalogParameterService = epWidgetCatalogParameterService; + this.epMicroserviceParameterService = epMicroserviceParameterService; + this.widgetMService = widgetMService; + this.fnUserService = fnUserService; + } + + + @GetMapping(value = { + "/portalApi/microservices/widgetCatalog/{loginName}"}, produces = MediaType.APPLICATION_JSON_VALUE) + public List<WidgetCatalog> getUserWidgetCatalog(@PathVariable("loginName") String loginName) { + List<WidgetCatalog> widgets; + try { + ResponseEntity<List> ans = template.exchange( + EcompPortalUtils.widgetMsProtocol() + "://" + + widgetMService.getServiceLocation(whatService, + SystemProperties.getProperty(EPCommonSystemProperties.MS_WIDGET_LOCAL_PORT)) + + "/widget/microservices/widgetCatalog/" + loginName, + HttpMethod.GET, new HttpEntity<>(WidgetServiceHeaders.getInstance()), List.class); + widgets = ans.getBody(); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "getUserWidgetCatalog failed", e); + return null; + } + return widgets; + } + + @GetMapping(value = {"/portalApi/microservices/widgetCatalog"}, produces = MediaType.APPLICATION_JSON_VALUE) + public List<WidgetCatalog> getWidgetCatalog() { + List<WidgetCatalog> widgets; + try { + ResponseEntity<List> ans = template.exchange( + EcompPortalUtils.widgetMsProtocol() + "://" + + widgetMService.getServiceLocation(whatService, + SystemProperties.getProperty(EPCommonSystemProperties.MS_WIDGET_LOCAL_PORT)) + + "/widget/microservices/widgetCatalog", + HttpMethod.GET, new HttpEntity<>(WidgetServiceHeaders.getInstance()), List.class); + widgets = ans.getBody(); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "getWidgetCatalog failed", e); + return null; + } + return widgets; + } + + @PutMapping(value = { + "/portalApi/microservices/widgetCatalog/{widgetId}"}, produces = MediaType.APPLICATION_JSON_VALUE) + public void updateWidgetCatalog(@RequestBody WidgetCatalog newWidgetCatalog, + @PathVariable("widgetId") long widgetId) throws Exception { + template.exchange( + EcompPortalUtils.widgetMsProtocol() + "://" + + widgetMService.getServiceLocation(whatService, + SystemProperties.getProperty(MS_WIDGET_LOCAL_PORT)) + + "/widget/microservices/widgetCatalog/" + widgetId, + HttpMethod.PUT, new HttpEntity<>(newWidgetCatalog, WidgetServiceHeaders.getInstance()), + String.class); + } + + @DeleteMapping(value = {"/portalApi/microservices/widgetCatalog/{widgetId}"}) + public void deleteOnboardingWidget(@PathVariable("widgetId") long widgetId) throws Exception { + template.exchange( + EcompPortalUtils.widgetMsProtocol() + "://" + + widgetMService.getServiceLocation(whatService, + SystemProperties.getProperty(MS_WIDGET_LOCAL_PORT)) + + "/widget/microservices/widgetCatalog/" + widgetId, + HttpMethod.DELETE, new HttpEntity<>(WidgetServiceHeaders.getInstance()), String.class); + } + + @PostMapping(value = {"/portalApi/microservices/widgetCatalog/{widgetId}"}) + public String updateWidgetCatalogWithFiles(HttpServletRequest request, + @PathVariable("widgetId") long widgetId) { + MultipartHttpServletRequest mRequest; + MultiValueMap<String, Object> multipartRequest = new LinkedMultiValueMap<>(); + String fileName; + String tmpFolderName = "/tmp/"; + String respond = null; + FileOutputStream fo = null; + try { + mRequest = (MultipartHttpServletRequest) request; + MultipartFile mFile = mRequest.getFile("file"); + fileName = mFile.getOriginalFilename(); + fo = new FileOutputStream(tmpFolderName + fileName); + fo.write(mFile.getBytes()); + fo.close(); + fo = null; + + HttpHeaders header = new HttpHeaders(); + header.setContentType(MediaType.MULTIPART_FORM_DATA); + multipartRequest.add("file", new FileSystemResource(tmpFolderName + fileName)); + multipartRequest.add("widget", request.getParameter("newWidget")); + respond = template.postForObject( + EcompPortalUtils.widgetMsProtocol() + "://" + + widgetMService.getServiceLocation(whatService, + SystemProperties.getProperty(EPCommonSystemProperties.MS_WIDGET_LOCAL_PORT)) + + "/widget/microservices/widgetCatalog/" + widgetId, + new HttpEntity<>(multipartRequest, WidgetServiceHeaders.getInstance()), String.class); + File f = new File(tmpFolderName + fileName); + f.delete(); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "updateWidgetCatalogWithFiles failed", e); + } finally { + try { + if (fo != null) { + fo.close(); + } + } catch (IOException e) { + logger.error(EELFLoggerDelegate.errorLogger, "updateWidgetCatalogWithFiles failed 2", e); + } + } + return respond; + } + + @PostMapping(value = {"/portalApi/microservices/widgetCatalog"}) + public String createWidgetCatalog(HttpServletRequest request) + throws Exception { + + if (StringUtils.isNotBlank(SystemProperties.getProperty(EPCommonSystemProperties.MS_WIDGET_UPLOAD_FLAG)) + && SystemProperties.getProperty(EPCommonSystemProperties.MS_WIDGET_UPLOAD_FLAG) + .equalsIgnoreCase("false")) { + return UNAUTHORIZED_OR_FORBIDDEN_FOR_A_DISABLED_USER; + } + + MultipartHttpServletRequest mRequest; + MultiValueMap<String, Object> multipartRequest = new LinkedMultiValueMap<>(); + String fileName; + String tmpFolderName = "/tmp/"; + String respond = null; + FileOutputStream fo = null; + try { + mRequest = (MultipartHttpServletRequest) request; + MultipartFile mFile = mRequest.getFile("file"); + fileName = mFile.getOriginalFilename(); + fo = new FileOutputStream(tmpFolderName + fileName); + fo.write(mFile.getBytes()); + // silence sonar scan by calling close here + fo.close(); + fo = null; + + HttpHeaders header = new HttpHeaders(); + header.setContentType(MediaType.MULTIPART_FORM_DATA); + multipartRequest.add("file", new FileSystemResource(tmpFolderName + fileName)); + multipartRequest.add("widget", request.getParameter("newWidget")); + + respond = template.postForObject( + EcompPortalUtils.widgetMsProtocol() + "://" + + widgetMService.getServiceLocation(whatService, + SystemProperties.getProperty(EPCommonSystemProperties.MS_WIDGET_LOCAL_PORT)) + + "/widget/microservices/widgetCatalog", + new HttpEntity<>(multipartRequest, WidgetServiceHeaders.getInstance()), String.class); + File f = new File(tmpFolderName + fileName); + f.delete(); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "createWidgetCatalog failed", e); + } finally { + try { + if (fo != null) { + fo.close(); + } + } catch (IOException e) { + logger.error(EELFLoggerDelegate.errorLogger, "createWidgetCatalog failed 2", e); + } + } + return respond; + } + + @GetMapping(value = "/portalApi/microservices/{widgetId}/framework.js") + public String getWidgetFramework(@PathVariable("widgetId") long widgetId) throws Exception { + return template.getForObject(EcompPortalUtils.widgetMsProtocol() + "://" + + widgetMService.getServiceLocation(whatService, + SystemProperties.getProperty(MS_WIDGET_LOCAL_PORT)) + + "/widget/microservices/" + widgetId + "/framework.js", String.class, + WidgetServiceHeaders.getInstance()); + } + + @GetMapping(value = "/portalApi/microservices/{widgetId}/controller.js") + public String getWidgetController(@PathVariable("widgetId") long widgetId) throws Exception { + return template.getForObject(EcompPortalUtils.widgetMsProtocol() + "://" + + widgetMService.getServiceLocation(whatService, + SystemProperties.getProperty(MS_WIDGET_LOCAL_PORT)) + + "/widget/microservices/" + widgetId + "/controller.js", String.class, + WidgetServiceHeaders.getInstance()); + } + + @GetMapping(value = "/portalApi/microservices/{widgetId}/style.css") + public String getWidgetCSS(@PathVariable("widgetId") long widgetId) throws Exception { + return template.getForObject(EcompPortalUtils.widgetMsProtocol() + "://" + + widgetMService.getServiceLocation(whatService, + SystemProperties.getProperty(MS_WIDGET_LOCAL_PORT)) + + "/widget/microservices/" + widgetId + "/styles.css", String.class, + WidgetServiceHeaders.getInstance()); + } + + @GetMapping(value = {"/portalApi/microservices/parameters/{widgetId}"}) + public PortalRestResponse<List<WidgetParameterResult>> getWidgetParameterResult(Principal principal, HttpServletRequest request, + @PathVariable("widgetId") long widgetId) throws Exception { + FnUser user = fnUserService.loadUserByUsername(principal.getName()); + + List<WidgetParameterResult> list = new ArrayList<>(); + Long serviceId = template.exchange( + EcompPortalUtils.widgetMsProtocol() + "://" + + widgetMService.getServiceLocation(whatService, + SystemProperties.getProperty(EPCommonSystemProperties.MS_WIDGET_LOCAL_PORT)) + + "/widget/microservices/widgetCatalog/parameters/" + widgetId, + HttpMethod.GET, new HttpEntity<>(WidgetServiceHeaders.getInstance()), Long.class).getBody(); + if (serviceId == null) { + // return ok/sucess and no service parameter for this widget + return new PortalRestResponse<>(PortalRestStatusEnum.WARN, + "No service parameters for this widget", list); + } else { + List<MicroserviceParameter> defaultParam = epMicroserviceParameterService.getParametersById(serviceId); + for (MicroserviceParameter param : defaultParam) { + WidgetParameterResult userResult = new WidgetParameterResult(); + userResult.setParamId(param.getId()); + userResult.setDefaultValue(param.getPara_value()); + userResult.setParamKey(param.getPara_key()); + WidgetCatalogParameter userValue = epWidgetCatalogParameterService + .getUserParamById(widgetId, user.getId(), + param.getId()); + if (userValue == null) { + userResult.setUserValue(param.getPara_value()); + } else { + userResult.setUserValue(userValue.getUserValue()); + } + list.add(userResult); + } + } + return new PortalRestResponse<List<WidgetParameterResult>>(PortalRestStatusEnum.OK, "SUCCESS", list); + } + + @GetMapping(value = {"/portalApi/microservices/services/{paramId}"}) + public List<WidgetCatalogParameter> getUserParameterById(@PathVariable("paramId") long paramId) { + return epWidgetCatalogParameterService.getUserParameterById(paramId); + } + + @DeleteMapping(value = {"/portalApi/microservices/services/{paramId}"}) + public void deleteUserParameterById(@PathVariable("paramId") long paramId) { + epWidgetCatalogParameterService.deleteUserParameterById(paramId); + } + + @GetMapping(value = {"/portalApi/microservices/download/{widgetId}"}) + public void doDownload(HttpServletRequest request, HttpServletResponse response, + @PathVariable("widgetId") long widgetId) throws Exception { + + ServletContext context = request.getServletContext(); + byte[] byteFile = template + .exchange( + EcompPortalUtils.widgetMsProtocol() + "://" + + widgetMService.getServiceLocation(whatService, + SystemProperties.getProperty(EPCommonSystemProperties.MS_WIDGET_LOCAL_PORT)) + + "/widget/microservices/download/" + widgetId, + HttpMethod.GET, new HttpEntity<>(WidgetServiceHeaders.getInstance()), byte[].class) + .getBody(); + + File downloadFile = File.createTempFile("temp", ".zip"); + try (FileOutputStream stream = new FileOutputStream(downloadFile.getPath())) { + stream.write(byteFile); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "doDownload failed", e); + throw e; + } + + try (FileInputStream inputStream = new FileInputStream(downloadFile); + OutputStream outStream = response.getOutputStream()) { + String mimeType = context.getMimeType(downloadFile.getPath()); + if (mimeType == null) { + mimeType = "application/octet-stream"; + } + + response.setContentType(mimeType); + response.setContentLength((int) downloadFile.length()); + String headerKey = "Content-Disposition"; + String headerValue = String.format("attachment; filename=\"%s\"", downloadFile.getName()); + downloadFile.delete(); + response.setHeader(headerKey, headerValue); + + byte[] buffer = new byte[32 * 1024]; + int bytesRead; + while ((bytesRead = inputStream.read(buffer)) != -1) { + outStream.write(buffer, 0, bytesRead); + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "doDownload failed", e); + throw e; + } + } + + @PostMapping(value = {"/portalApi/microservices/parameters"}) + public PortalRestResponse<String> saveWidgetParameter(Principal principal, HttpServletRequest request, + @RequestBody WidgetCatalogParameter widgetParameters) { + FnUser user = fnUserService.loadUserByUsername(principal.getName()); + widgetParameters.setUserId(user.getId()); + try { + WidgetCatalogParameter oldParam = epWidgetCatalogParameterService + .getUserParamById(widgetParameters.getWidgetId(), + widgetParameters.getUserId(), widgetParameters.getParamId()); + if (oldParam != null) { + widgetParameters.setId(oldParam.getId()); + } + epWidgetCatalogParameterService.saveUserParameter(widgetParameters); + + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "saveWidgetParameter failed", e); + return new PortalRestResponse<String>(PortalRestStatusEnum.ERROR, "FAILURE", e.getMessage()); + } + return new PortalRestResponse<>(PortalRestStatusEnum.OK, "SUCCESS", ""); + } + + @GetMapping(value = {"/portalApi/microservices/uploadFlag"}) + public String getUploadFlag() { + String uplaodFlag = ""; + try { + uplaodFlag = SystemProperties.getProperty(EPCommonSystemProperties.MS_WIDGET_UPLOAD_FLAG); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "uploadFlag failed", e); + return null; + } + return uplaodFlag; + } + +} diff --git a/portal-BE/src/main/java/org/onap/portal/controller/WidgetsCatalogMarkupController.java b/portal-BE/src/main/java/org/onap/portal/controller/WidgetsCatalogMarkupController.java new file mode 100644 index 00000000..06dd62da --- /dev/null +++ b/portal-BE/src/main/java/org/onap/portal/controller/WidgetsCatalogMarkupController.java @@ -0,0 +1,103 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Modifications Copyright (c) 2019 Samsung + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * + */ + +package org.onap.portal.controller; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import org.onap.portal.domain.dto.ecomp.WidgetServiceHeaders; +import org.onap.portal.logging.aop.EPAuditLog; +import org.onap.portal.service.WidgetMService; +import org.onap.portal.utils.EcompPortalUtils; +import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.onap.portalsdk.core.util.SystemProperties; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.client.RestClientException; +import org.springframework.web.client.RestTemplate; +import org.springframework.web.multipart.commons.CommonsMultipartResolver; + +@EPAuditLog +@RestController +@EnableAspectJAutoProxy +public class WidgetsCatalogMarkupController { + + private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(WidgetsCatalogMarkupController.class); + private RestTemplate template = new RestTemplate(); + private final String whatService = "widgets-service"; + + @Autowired + private WidgetMService widgetMService; + + @Bean + public CommonsMultipartResolver multipartResolver() { + return new CommonsMultipartResolver(); + } + + static { + // for localhost testing only + javax.net.ssl.HttpsURLConnection.setDefaultHostnameVerifier(new javax.net.ssl.HostnameVerifier() { + + public boolean verify(String hostname, javax.net.ssl.SSLSession sslSession) { + if (hostname.equals("localhost")) { + return true; + } + return false; + } + }); + } + + @GetMapping(value = "/portalApi/microservices/markup/{widgetId}") + public String getWidgetMarkup(HttpServletRequest request, HttpServletResponse response, + @PathVariable("widgetId") long widgetId) throws RestClientException, Exception { + return template + .getForObject( + EcompPortalUtils.widgetMsProtocol() + "://" + + widgetMService.getServiceLocation(whatService, + SystemProperties.getProperty("microservices.widget.local.port")) + + "/widget/microservices/markup/" + widgetId, + String.class, WidgetServiceHeaders.getInstance()); + } + +} diff --git a/portal-BE/src/main/java/org/onap/portal/controller/WidgetsController.java b/portal-BE/src/main/java/org/onap/portal/controller/WidgetsController.java new file mode 100644 index 00000000..c2915275 --- /dev/null +++ b/portal-BE/src/main/java/org/onap/portal/controller/WidgetsController.java @@ -0,0 +1,224 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Modifications Copyright (c) 2019 Samsung + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * + */ + +package org.onap.portal.controller; + +import java.io.IOException; +import java.security.Principal; +import java.util.List; +import java.util.Optional; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import org.onap.portal.domain.db.fn.FnUser; +import org.onap.portal.domain.dto.transport.FieldsValidator; +import org.onap.portal.domain.dto.transport.OnboardingWidget; +import org.onap.portal.domain.dto.transport.WidgetCatalogPersonalization; +import org.onap.portal.logging.aop.EPAuditLog; +import org.onap.portal.service.AdminRolesService; +import org.onap.portal.service.PersUserWidgetService; +import org.onap.portal.service.WidgetService; +import org.onap.portal.service.fn.FnUserService; +import org.onap.portal.utils.EcompPortalUtils; +import org.onap.portal.validation.DataValidator; +import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +@EPAuditLog +@RestController +@EnableAspectJAutoProxy +public class WidgetsController { + + private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(WidgetsController.class); + + private final FnUserService fnUserService; + private final WidgetService widgetService; + private final AdminRolesService adminRolesService; + private final DataValidator dataValidator; + private final PersUserWidgetService persUserWidgetService; + + @Autowired + public WidgetsController(final FnUserService fnUserService, final WidgetService widgetService, + final AdminRolesService adminRolesService, final DataValidator dataValidator, + final PersUserWidgetService persUserWidgetService) { + this.fnUserService = fnUserService; + this.widgetService = widgetService; + this.adminRolesService = adminRolesService; + this.dataValidator = dataValidator; + this.persUserWidgetService = persUserWidgetService; + } + + @GetMapping(value = {"/portalApi/widgets"}, produces = MediaType.APPLICATION_JSON_VALUE) + public List<OnboardingWidget> getOnboardingWidgets(Principal principal, HttpServletRequest request, + HttpServletResponse response) { + FnUser user = fnUserService.loadUserByUsername(principal.getName()); + List<OnboardingWidget> onboardingWidgets = null; + + if (user.getGuest()) { + EcompPortalUtils.setBadPermissions(user, response, "getOnboardingWidgets"); + } else { + String getType = request.getHeader("X-Widgets-Type"); + if (!getType.isEmpty() && ("managed".equals(getType) || "all".equals(getType))) { + onboardingWidgets = widgetService.getOnboardingWidgets(user, "managed".equals(getType)); + } else { + logger.debug(EELFLoggerDelegate.debugLogger, + "WidgetsController.getOnboardingApps - request must contain header 'X-Widgets-Type' with 'all' or 'managed'"); + response.setStatus(HttpServletResponse.SC_BAD_REQUEST); + } + } + + EcompPortalUtils + .logAndSerializeObject(logger, "/portalApi/widgets", "GET result =", response.getStatus()); + return onboardingWidgets; + } + + @PutMapping(value = {"/portalApi/widgets/{widgetId}"}, produces = MediaType.APPLICATION_JSON_VALUE) + public FieldsValidator putOnboardingWidget(Principal principal, HttpServletRequest request, + @PathVariable("widgetId") Long widgetId, + @RequestBody OnboardingWidget onboardingWidget, HttpServletResponse response) { + FnUser user = fnUserService.loadUserByUsername(principal.getName()); + FieldsValidator fieldsValidator = null; + if (onboardingWidget != null) { + if (!dataValidator.isValid(onboardingWidget)) { + fieldsValidator = new FieldsValidator(); + fieldsValidator.setHttpStatusCode((long) HttpServletResponse.SC_NOT_ACCEPTABLE); + return fieldsValidator; + } + } + + if (userHasPermissions(user, response, "putOnboardingWidget")) { + assert onboardingWidget != null; + onboardingWidget.setId(widgetId); + onboardingWidget.normalize(); + fieldsValidator = widgetService.setOnboardingWidget(user, onboardingWidget); + response.setStatus(fieldsValidator.getHttpStatusCode().intValue()); + } + EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/widgets/" + widgetId, "GET result =", + response.getStatus()); + + return fieldsValidator; + } + + private boolean userHasPermissions(FnUser user, HttpServletResponse response, String invocator) { + if (!adminRolesService.isSuperAdmin(user) && !adminRolesService.isAccountAdmin(user)) { + EcompPortalUtils.setBadPermissions(user, response, invocator); + return false; + } + return true; + } + + @PostMapping(value = {"/portalApi/widgets"}, produces = MediaType.APPLICATION_JSON_VALUE) + public FieldsValidator postOnboardingWidget(Principal principal, HttpServletRequest request, + @RequestBody OnboardingWidget onboardingWidget, HttpServletResponse response) { + FnUser user = fnUserService.loadUserByUsername(principal.getName()); + FieldsValidator fieldsValidator = null; + + if (onboardingWidget != null) { + if (!dataValidator.isValid(onboardingWidget)) { + fieldsValidator = new FieldsValidator(); + fieldsValidator.setHttpStatusCode((long) HttpServletResponse.SC_NOT_ACCEPTABLE); + return fieldsValidator; + } + } + + if (userHasPermissions(user, response, "postOnboardingWidget")) { + onboardingWidget.setId(null); + onboardingWidget.normalize(); + fieldsValidator = widgetService.setOnboardingWidget(user, onboardingWidget); + response.setStatus(fieldsValidator.getHttpStatusCode().intValue()); + } + + EcompPortalUtils + .logAndSerializeObject(logger, "/portalApi/widgets", "POST result =", response.getStatus()); + return fieldsValidator; + } + + @DeleteMapping(value = {"/portalApi/widgets/{widgetId}"}, produces = MediaType.APPLICATION_JSON_VALUE) + public FieldsValidator deleteOnboardingWidget(Principal principal, HttpServletRequest request, + @PathVariable("widgetId") Long widgetId, HttpServletResponse response) { + FnUser user = fnUserService.loadUserByUsername(principal.getName()); + FieldsValidator fieldsValidator = null; + + if (userHasPermissions(user, response, "deleteOnboardingWidget")) { + fieldsValidator = widgetService.deleteOnboardingWidget(user, widgetId); + response.setStatus(fieldsValidator.getHttpStatusCode().intValue()); + } + + EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/widgets/" + widgetId, "DELETE result =", + response.getStatus()); + return fieldsValidator; + } + + @PutMapping(value = {"portalApi/widgetCatalogSelection"}, produces = MediaType.APPLICATION_JSON_VALUE) + public FieldsValidator putWidgetCatalogSelection(Principal principal, HttpServletRequest request, + @RequestBody WidgetCatalogPersonalization persRequest, HttpServletResponse response) throws IOException { + FieldsValidator result = new FieldsValidator(); + FnUser user = fnUserService.loadUserByUsername(principal.getName()); + + if (persRequest != null) { + if (!dataValidator.isValid(persRequest)) { + result.setHttpStatusCode((long) HttpServletResponse.SC_NOT_ACCEPTABLE); + return result; + } + } + try { + if (persRequest.getWidgetId() == null || user == null) { + EcompPortalUtils.setBadPermissions(user, response, "putWidgetCatalogSelection"); + } else { + persUserWidgetService + .setPersUserAppValue(user, persRequest.getWidgetId(), persRequest.getSelect()); + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "Failed in putAppCatalogSelection", e); + response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.toString()); + } + result.setHttpStatusCode((long) HttpServletResponse.SC_OK); + return result; + } +} diff --git a/portal-BE/src/main/java/org/onap/portal/dao/ep/EpMicroserviceParameterDao.java b/portal-BE/src/main/java/org/onap/portal/dao/ep/EpMicroserviceParameterDao.java new file mode 100644 index 00000000..4bcca7ef --- /dev/null +++ b/portal-BE/src/main/java/org/onap/portal/dao/ep/EpMicroserviceParameterDao.java @@ -0,0 +1,61 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Modifications Copyright (c) 2019 Samsung + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * + */ + +package org.onap.portal.dao.ep; + +import java.util.List; +import org.onap.portal.domain.db.ep.EpMicroserviceParameter; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; +import org.springframework.transaction.annotation.Transactional; + +@Repository +@Transactional +public interface EpMicroserviceParameterDao extends JpaRepository<EpMicroserviceParameter, Long> { + + @Query + void deleteByServiceId(@Param("SERVICEID") Long userId); + @Query + void deleteMicroserviceParameterById(@Param("PARAMID") Long userId); + @Query + List<EpMicroserviceParameter> getParametersById(@Param("SERVICEID") long serviceId); +} diff --git a/portal-BE/src/main/java/org/onap/portal/dao/ep/EpPersUserWidgetSelDao.java b/portal-BE/src/main/java/org/onap/portal/dao/ep/EpPersUserWidgetSelDao.java new file mode 100644 index 00000000..899fc1f0 --- /dev/null +++ b/portal-BE/src/main/java/org/onap/portal/dao/ep/EpPersUserWidgetSelDao.java @@ -0,0 +1,58 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Modifications Copyright (c) 2019 Samsung + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * + */ + +package org.onap.portal.dao.ep; + +import java.util.List; +import java.util.Optional; +import org.onap.portal.domain.db.ep.EpPersUserWidgetSel; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; +import org.springframework.transaction.annotation.Transactional; + +@Repository +@Transactional +public interface EpPersUserWidgetSelDao extends JpaRepository<EpPersUserWidgetSel, Long> { + + @Query + Optional<List<EpPersUserWidgetSel>> getEpPersUserWidgetSelForUserIdAndWidgetId(@Param("USERID") Long userId, @Param("WIDGETID") Long widgetId); +} diff --git a/portal-BE/src/main/java/org/onap/portal/dao/ep/EpWidgetCatalogParameterDao.java b/portal-BE/src/main/java/org/onap/portal/dao/ep/EpWidgetCatalogParameterDao.java new file mode 100644 index 00000000..04c12324 --- /dev/null +++ b/portal-BE/src/main/java/org/onap/portal/dao/ep/EpWidgetCatalogParameterDao.java @@ -0,0 +1,25 @@ +package org.onap.portal.dao.ep; + +import java.util.List; +import java.util.Optional; +import org.onap.portal.domain.db.ep.EpWidgetCatalogParameter; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; +import org.springframework.transaction.annotation.Transactional; + +@Repository +@Transactional +public interface EpWidgetCatalogParameterDao extends JpaRepository<EpWidgetCatalogParameter, Long> { + + @Query + Optional<List<EpWidgetCatalogParameter>> retrieveByParamId(@Param("PARAMID") Long paramId); + + @Query + void deleteWidgetCatalogParameter(@Param("PARAMID") Long paramId); + + @Query + Optional<List<EpWidgetCatalogParameter>> getUserParamById(@Param("WIDGETID") Long widgetId, + @Param("USERID") Long userId, @Param("PARAMID") Long paramId); +} diff --git a/portal-BE/src/main/java/org/onap/portal/dao/fn/EpWidgetCatalogDao.java b/portal-BE/src/main/java/org/onap/portal/dao/fn/EpWidgetCatalogDao.java new file mode 100644 index 00000000..1e8de2bb --- /dev/null +++ b/portal-BE/src/main/java/org/onap/portal/dao/fn/EpWidgetCatalogDao.java @@ -0,0 +1,48 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Modifications Copyright (c) 2019 Samsung + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * + */ + +package org.onap.portal.dao.fn; + +import org.onap.portal.domain.db.ep.EpWidgetCatalog; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface EpWidgetCatalogDao extends JpaRepository<EpWidgetCatalog, Long> { + +} diff --git a/portal-BE/src/main/java/org/onap/portal/dao/fn/FnAppDao.java b/portal-BE/src/main/java/org/onap/portal/dao/fn/FnAppDao.java new file mode 100644 index 00000000..616ee2d1 --- /dev/null +++ b/portal-BE/src/main/java/org/onap/portal/dao/fn/FnAppDao.java @@ -0,0 +1,12 @@ +package org.onap.portal.dao.fn; + +import org.onap.portal.domain.db.fn.FnApp; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; +import org.springframework.transaction.annotation.Transactional; + +@Repository +@Transactional +public interface FnAppDao extends JpaRepository<FnApp, Long> { + +} diff --git a/portal-BE/src/main/java/org/onap/portal/dao/fn/FnWidgetDao.java b/portal-BE/src/main/java/org/onap/portal/dao/fn/FnWidgetDao.java new file mode 100644 index 00000000..a47a1a0d --- /dev/null +++ b/portal-BE/src/main/java/org/onap/portal/dao/fn/FnWidgetDao.java @@ -0,0 +1,52 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Modifications Copyright (c) 2019 Samsung + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * + */ + +package org.onap.portal.dao.fn; + +import org.onap.portal.domain.db.fn.FnWidget; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; +import org.springframework.transaction.annotation.Transactional; + +@Repository +@Transactional +public interface FnWidgetDao extends JpaRepository<FnWidget, Long> { + +} diff --git a/portal-BE/src/main/java/org/onap/portal/domain/builder/FnUserBuilder.java b/portal-BE/src/main/java/org/onap/portal/domain/builder/FnUserBuilder.java deleted file mode 100644 index ccf20aa3..00000000 --- a/portal-BE/src/main/java/org/onap/portal/domain/builder/FnUserBuilder.java +++ /dev/null @@ -1,469 +0,0 @@ -/* - * ============LICENSE_START========================================== - * ONAP Portal - * =================================================================== - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * =================================================================== - * Modifications Copyright (c) 2019 Samsung - * =================================================================== - * - * Unless otherwise specified, all software contained herein is licensed - * under the Apache License, Version 2.0 (the "License"); - * you may not use this software except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Unless otherwise specified, all documentation contained herein is licensed - * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); - * you may not use this documentation except in compliance with the License. - * You may obtain a copy of the License at - * - * https://creativecommons.org/licenses/by/4.0/ - * - * Unless required by applicable law or agreed to in writing, documentation - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ============LICENSE_END============================================ - * - * - */ - -package org.onap.portal.domain.builder; - -import java.time.LocalDateTime; -import java.util.Set; -import javax.validation.Valid; -import javax.validation.constraints.Digits; -import javax.validation.constraints.Email; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.PastOrPresent; -import javax.validation.constraints.Size; -import org.hibernate.validator.constraints.SafeHtml; -import org.onap.portal.domain.db.cr.CrReportFileHistory; -import org.onap.portal.domain.db.ep.EpPersUserWidgetPlacement; -import org.onap.portal.domain.db.ep.EpPersUserWidgetSel; -import org.onap.portal.domain.db.ep.EpUserNotification; -import org.onap.portal.domain.db.ep.EpUserRolesRequest; -import org.onap.portal.domain.db.ep.EpWidgetCatalogParameter; -import org.onap.portal.domain.db.fn.FnAuditLog; -import org.onap.portal.domain.db.fn.FnLanguage; -import org.onap.portal.domain.db.fn.FnLuAlertMethod; -import org.onap.portal.domain.db.fn.FnLuTimezone; -import org.onap.portal.domain.db.fn.FnMenuFunctional; -import org.onap.portal.domain.db.fn.FnOrg; -import org.onap.portal.domain.db.fn.FnPersUserAppSel; -import org.onap.portal.domain.db.fn.FnRole; -import org.onap.portal.domain.db.fn.FnUser; -import org.onap.portal.domain.db.fn.FnUserRole; -import org.springframework.stereotype.Component; - -@Component -public class FnUserBuilder { - - private @Digits(integer = 11, fraction = 0) Long userId; - private @Valid FnOrg orgId; - private @Valid FnUser managerId; - private @Size(max = 50) - @SafeHtml String firstName; - private @Size(max = 50) - @SafeHtml String middleName; - private @Size(max = 50) - @SafeHtml String lastName; - private @Size(max = 25) - @SafeHtml String phone; - private @Size(max = 25) - @SafeHtml String fax; - private @Size(max = 25) - @SafeHtml String cellular; - private @Size(max = 50) @Email - @SafeHtml String email; - private @Digits(integer = 11, fraction = 0) Long addressId; - private FnLuAlertMethod alertMethodCd; - private @Size(max = 20) - @SafeHtml String hrid; - private @Size(max = 20) - @SafeHtml String orgUserId; - private @Size(max = 30) - @SafeHtml String org_code; - private @Size(max = 25) - @SafeHtml String loginId; - private @Size(max = 100) - @SafeHtml String loginPwd; - private @PastOrPresent LocalDateTime lastLoginDate; - private @Size(max = 1) - @SafeHtml - @NotNull(message = "activeYn must not be null") String activeYn; - private @Valid FnUser createdId; - private @PastOrPresent LocalDateTime createdDate; - private @Valid FnUser modifiedId; - private @PastOrPresent LocalDateTime modifiedDate; - private @Size(max = 1) - @SafeHtml - @NotNull(message = "isInternalYn must not be null") String isInternalYn; - private @Size(max = 100) - @SafeHtml String addressLine1; - private @Size(max = 100) - @SafeHtml String addressLine2; - private @Size(max = 50) - @SafeHtml String city; - private @Size(max = 3) - @SafeHtml String stateCd; - private @Size(max = 11) - @SafeHtml String zipCode; - private @Size(max = 3) - @SafeHtml String countryCd; - private @Size(max = 8) - @SafeHtml String locationClli; - private @Size(max = 20) - @SafeHtml String orgManagerUserId; - private @Size(max = 100) - @SafeHtml String company; - private @Size(max = 200) - @SafeHtml String departmentName; - private @Size(max = 100) - @SafeHtml String jobTitle; - private @Valid FnLuTimezone timezone; - private @Size(max = 25) - @SafeHtml String department; - private @Size(max = 25) - @SafeHtml String businessUnit; - private @Size(max = 100) - @SafeHtml String businessUnitName; - private @Size(max = 25) - @SafeHtml String cost_center; - private @Size(max = 10) - @SafeHtml String finLocCode; - private @Size(max = 10) - @SafeHtml String siloStatus; - private @Valid @NotNull(message = "languageId must not be null") FnLanguage languageId; - private @NotNull(message = "guest must not be null") boolean guest; - private Set<CrReportFileHistory> crReportFileHistorie; - private Set<FnRole> fnRoles; - private Set<FnMenuFunctional> fnRoleList; - private Set<FnAuditLog> fnAuditLogs; - private Set<FnUser> fnUsersCreatedId; - private Set<FnUser> fnUsersManagerId; - private Set<FnUser> fnUsersModifiedId; - private Set<EpUserRolesRequest> epUserRolesRequests; - private Set<FnPersUserAppSel> persUserAppSels; - private Set<EpWidgetCatalogParameter> epWidgetCatalogParameters; - private Set<EpPersUserWidgetPlacement> epPersUserWidgetPlacements; - private Set<EpPersUserWidgetSel> epPersUserWidgetSels; - private Set<FnUserRole> fnUserRoles; - private Set<EpUserNotification> epUserNotifications; - - public FnUserBuilder setUserId(@Digits(integer = 11, fraction = 0) Long userId) { - this.userId = userId; - return this; - } - - public FnUserBuilder setOrgId(@Valid FnOrg orgId) { - this.orgId = orgId; - return this; - } - - public FnUserBuilder setManagerId(@Valid FnUser managerId) { - this.managerId = managerId; - return this; - } - - public FnUserBuilder setFirstName(@Size(max = 50) @SafeHtml String firstName) { - this.firstName = firstName; - return this; - } - - public FnUserBuilder setMiddleName(@Size(max = 50) @SafeHtml String middleName) { - this.middleName = middleName; - return this; - } - - public FnUserBuilder setLastName(@Size(max = 50) @SafeHtml String lastName) { - this.lastName = lastName; - return this; - } - - public FnUserBuilder setPhone(@Size(max = 25) @SafeHtml String phone) { - this.phone = phone; - return this; - } - - public FnUserBuilder setFax(@Size(max = 25) @SafeHtml String fax) { - this.fax = fax; - return this; - } - - public FnUserBuilder setCellular(@Size(max = 25) @SafeHtml String cellular) { - this.cellular = cellular; - return this; - } - - public FnUserBuilder setEmail(@Size(max = 50) @Email @SafeHtml String email) { - this.email = email; - return this; - } - - public FnUserBuilder setAddressId(@Digits(integer = 11, fraction = 0) Long addressId) { - this.addressId = addressId; - return this; - } - - public FnUserBuilder setAlertMethodCd(FnLuAlertMethod alertMethodCd) { - this.alertMethodCd = alertMethodCd; - return this; - } - - public FnUserBuilder setHrid(@Size(max = 20) @SafeHtml String hrid) { - this.hrid = hrid; - return this; - } - - public FnUserBuilder setOrgUserId(@Size(max = 20) @SafeHtml String orgUserId) { - this.orgUserId = orgUserId; - return this; - } - - public FnUserBuilder setOrg_code(@Size(max = 30) @SafeHtml String org_code) { - this.org_code = org_code; - return this; - } - - public FnUserBuilder setLoginId(@Size(max = 25) @SafeHtml String loginId) { - this.loginId = loginId; - return this; - } - - public FnUserBuilder setLoginPwd(@Size(max = 100) @SafeHtml String loginPwd) { - this.loginPwd = loginPwd; - return this; - } - - public FnUserBuilder setLastLoginDate(@PastOrPresent LocalDateTime lastLoginDate) { - this.lastLoginDate = lastLoginDate; - return this; - } - - public FnUserBuilder setActiveYn( - @Size(max = 1) @SafeHtml @NotNull(message = "activeYn must not be null") String activeYn) { - this.activeYn = activeYn; - return this; - } - - public FnUserBuilder setCreatedId(@Valid FnUser createdId) { - this.createdId = createdId; - return this; - } - - public FnUserBuilder setCreatedDate(@PastOrPresent LocalDateTime createdDate) { - this.createdDate = createdDate; - return this; - } - - public FnUserBuilder setModifiedId(@Digits(integer = 11, fraction = 0) FnUser modifiedId) { - this.modifiedId = modifiedId; - return this; - } - - public FnUserBuilder setModifiedDate(@PastOrPresent LocalDateTime modifiedDate) { - this.modifiedDate = modifiedDate; - return this; - } - - public FnUserBuilder setIsInternalYn( - @Size(max = 1) @SafeHtml @NotNull(message = "isInternalYn must not be null") String isInternalYn) { - this.isInternalYn = isInternalYn; - return this; - } - - public FnUserBuilder setAddressLine1(@Size(max = 100) @SafeHtml String addressLine1) { - this.addressLine1 = addressLine1; - return this; - } - - public FnUserBuilder setAddressLine2(@Size(max = 100) @SafeHtml String addressLine2) { - this.addressLine2 = addressLine2; - return this; - } - - public FnUserBuilder setCity(@Size(max = 50) @SafeHtml String city) { - this.city = city; - return this; - } - - public FnUserBuilder setStateCd(@Size(max = 3) @SafeHtml String stateCd) { - this.stateCd = stateCd; - return this; - } - - public FnUserBuilder setZipCode(@Size(max = 11) @SafeHtml String zipCode) { - this.zipCode = zipCode; - return this; - } - - public FnUserBuilder setCountryCd(@Size(max = 3) @SafeHtml String countryCd) { - this.countryCd = countryCd; - return this; - } - - public FnUserBuilder setLocationClli(@Size(max = 8) @SafeHtml String locationClli) { - this.locationClli = locationClli; - return this; - } - - public FnUserBuilder setOrgManagerUserId(@Size(max = 20) @SafeHtml String orgManagerUserId) { - this.orgManagerUserId = orgManagerUserId; - return this; - } - - public FnUserBuilder setCompany(@Size(max = 100) @SafeHtml String company) { - this.company = company; - return this; - } - - public FnUserBuilder setDepartmentName(@Size(max = 200) @SafeHtml String departmentName) { - this.departmentName = departmentName; - return this; - } - - public FnUserBuilder setJobTitle(@Size(max = 100) @SafeHtml String jobTitle) { - this.jobTitle = jobTitle; - return this; - } - - public FnUserBuilder setTimezone(@Valid FnLuTimezone timezone) { - this.timezone = timezone; - return this; - } - - public FnUserBuilder setDepartment(@Size(max = 25) @SafeHtml String department) { - this.department = department; - return this; - } - - public FnUserBuilder setBusinessUnit(@Size(max = 25) @SafeHtml String businessUnit) { - this.businessUnit = businessUnit; - return this; - } - - public FnUserBuilder setBusinessUnitName(@Size(max = 100) @SafeHtml String businessUnitName) { - this.businessUnitName = businessUnitName; - return this; - } - - public FnUserBuilder setCost_center(@Size(max = 25) @SafeHtml String cost_center) { - this.cost_center = cost_center; - return this; - } - - public FnUserBuilder setFinLocCode(@Size(max = 10) @SafeHtml String finLocCode) { - this.finLocCode = finLocCode; - return this; - } - - public FnUserBuilder setSiloStatus(@Size(max = 10) @SafeHtml String siloStatus) { - this.siloStatus = siloStatus; - return this; - } - - public FnUserBuilder setLanguageId( - @Valid @NotNull(message = "languageId must not be null") FnLanguage languageId) { - this.languageId = languageId; - return this; - } - - public FnUserBuilder setGuest(@NotNull(message = "guest must not be null") boolean guest) { - this.guest = guest; - return this; - } - - public FnUserBuilder setCrReportFileHistorie(Set<CrReportFileHistory> crReportFileHistorie) { - this.crReportFileHistorie = crReportFileHistorie; - return this; - } - - public FnUserBuilder setFnRoles(Set<FnRole> fnRoles) { - this.fnRoles = fnRoles; - return this; - } - - public FnUserBuilder setFnRoleList(Set<FnMenuFunctional> fnRoleList) { - this.fnRoleList = fnRoleList; - return this; - } - - public FnUserBuilder setFnAuditLogs(Set<FnAuditLog> fnAuditLogs) { - this.fnAuditLogs = fnAuditLogs; - return this; - } - - public FnUserBuilder setFnUsersCreatedId(Set<FnUser> fnUsersCreatedId) { - this.fnUsersCreatedId = fnUsersCreatedId; - return this; - } - - public FnUserBuilder setFnUsersManagerId(Set<FnUser> fnUsersManagerId) { - this.fnUsersManagerId = fnUsersManagerId; - return this; - } - - public FnUserBuilder setFnUsersModifiedId(Set<FnUser> fnUsersModifiedId) { - this.fnUsersModifiedId = fnUsersModifiedId; - return this; - } - - public FnUserBuilder setEpUserRolesRequests(Set<EpUserRolesRequest> epUserRolesRequests) { - this.epUserRolesRequests = epUserRolesRequests; - return this; - } - - public FnUserBuilder setPersUserAppSels(Set<FnPersUserAppSel> persUserAppSels) { - this.persUserAppSels = persUserAppSels; - return this; - } - - public FnUserBuilder setEpWidgetCatalogParameters(Set<EpWidgetCatalogParameter> epWidgetCatalogParameters) { - this.epWidgetCatalogParameters = epWidgetCatalogParameters; - return this; - } - - public FnUserBuilder setEpPersUserWidgetPlacements(Set<EpPersUserWidgetPlacement> epPersUserWidgetPlacements) { - this.epPersUserWidgetPlacements = epPersUserWidgetPlacements; - return this; - } - - public FnUserBuilder setEpPersUserWidgetSels(Set<EpPersUserWidgetSel> epPersUserWidgetSels) { - this.epPersUserWidgetSels = epPersUserWidgetSels; - return this; - } - - public FnUserBuilder setFnUserRoles(Set<FnUserRole> fnUserRoles) { - this.fnUserRoles = fnUserRoles; - return this; - } - - public FnUserBuilder setEpUserNotifications(Set<EpUserNotification> epUserNotifications) { - this.epUserNotifications = epUserNotifications; - return this; - } - - public FnUser createFnUser() { - return new FnUser(userId, orgId, managerId, firstName, middleName, lastName, phone, fax, cellular, email, - addressId, alertMethodCd, hrid, orgUserId, org_code, loginId, loginPwd, lastLoginDate, activeYn, - createdId, createdDate, modifiedId, modifiedDate, isInternalYn, addressLine1, addressLine2, city, - stateCd, zipCode, countryCd, locationClli, orgManagerUserId, company, departmentName, jobTitle, - timezone, department, businessUnit, businessUnitName, cost_center, finLocCode, siloStatus, - languageId, guest, crReportFileHistorie, fnRoles, fnRoleList, fnAuditLogs, fnUsersCreatedId, - fnUsersManagerId, fnUsersModifiedId, epUserRolesRequests, persUserAppSels, - epWidgetCatalogParameters, epPersUserWidgetPlacements, epPersUserWidgetSels, fnUserRoles, - epUserNotifications); - } -}
\ No newline at end of file diff --git a/portal-BE/src/main/java/org/onap/portal/domain/builder/FnUserDtoBuilder.java b/portal-BE/src/main/java/org/onap/portal/domain/builder/FnUserDtoBuilder.java deleted file mode 100644 index c6075dd6..00000000 --- a/portal-BE/src/main/java/org/onap/portal/domain/builder/FnUserDtoBuilder.java +++ /dev/null @@ -1,331 +0,0 @@ -/* - * ============LICENSE_START========================================== - * ONAP Portal - * =================================================================== - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * =================================================================== - * Modifications Copyright (c) 2019 Samsung - * =================================================================== - * - * Unless otherwise specified, all software contained herein is licensed - * under the Apache License, Version 2.0 (the "License"); - * you may not use this software except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Unless otherwise specified, all documentation contained herein is licensed - * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); - * you may not use this documentation except in compliance with the License. - * You may obtain a copy of the License at - * - * https://creativecommons.org/licenses/by/4.0/ - * - * Unless required by applicable law or agreed to in writing, documentation - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ============LICENSE_END============================================ - * - * - */ - -package org.onap.portal.domain.builder; - -import java.time.LocalDateTime; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import org.onap.portal.domain.dto.fn.FnUserDto; -import org.springframework.stereotype.Component; - -@Component -@NoArgsConstructor -@AllArgsConstructor -@Getter -@Setter -public class FnUserDtoBuilder { - - private Long userId; - private Long orgId; - private Long managerId; - private String firstName; - private String middleName; - private String lastName; - private String phone; - private String fax; - private String cellular; - private String email; - private Long addressId; - private String alertMethodCd; - private String hrid; - private String orgUserId; - private String org_code; - private String loginId; - private String loginPwd; - private LocalDateTime lastLoginDate; - private String activeYn; - private Long createdId; - private LocalDateTime createdDate; - private Long modifiedId; - private LocalDateTime modifiedDate; - private String isInternalYn; - private String addressLine1; - private String addressLine2; - private String city; - private String stateCd; - private String zipCode; - private String countryCd; - private String locationClli; - private String orgManagerUserId; - private String company; - private String departmentName; - private String jobTitle; - private Long timezone; - private String department; - private String businessUnit; - private String businessUnitName; - private String cost_center; - private String finLocCode; - private String siloStatus; - private Long languageId; - private boolean guest; - - public FnUserDtoBuilder setUserId(Long userId) { - this.userId = userId; - return this; - } - - public FnUserDtoBuilder setOrgId(Long orgId) { - this.orgId = orgId; - return this; - } - - public FnUserDtoBuilder setManagerId(Long managerId) { - this.managerId = managerId; - return this; - } - - public FnUserDtoBuilder setFirstName(String firstName) { - this.firstName = firstName; - return this; - } - - public FnUserDtoBuilder setMiddleName(String middleName) { - this.middleName = middleName; - return this; - } - - public FnUserDtoBuilder setLastName(String lastName) { - this.lastName = lastName; - return this; - } - - public FnUserDtoBuilder setPhone(String phone) { - this.phone = phone; - return this; - } - - public FnUserDtoBuilder setFax(String fax) { - this.fax = fax; - return this; - } - - public FnUserDtoBuilder setCellular(String cellular) { - this.cellular = cellular; - return this; - } - - public FnUserDtoBuilder setEmail(String email) { - this.email = email; - return this; - } - - public FnUserDtoBuilder setAddressId(Long addressId) { - this.addressId = addressId; - return this; - } - - public FnUserDtoBuilder setAlertMethodCd(String alertMethodCd) { - this.alertMethodCd = alertMethodCd; - return this; - } - - public FnUserDtoBuilder setHrid(String hrid) { - this.hrid = hrid; - return this; - } - - public FnUserDtoBuilder setOrgUserId(String orgUserId) { - this.orgUserId = orgUserId; - return this; - } - - public FnUserDtoBuilder setOrg_code(String org_code) { - this.org_code = org_code; - return this; - } - - public FnUserDtoBuilder setLoginId(String loginId) { - this.loginId = loginId; - return this; - } - - public FnUserDtoBuilder setLoginPwd(String loginPwd) { - this.loginPwd = loginPwd; - return this; - } - - public FnUserDtoBuilder setLastLoginDate(LocalDateTime lastLoginDate) { - this.lastLoginDate = lastLoginDate; - return this; - } - - public FnUserDtoBuilder setActiveYn(String activeYn) { - this.activeYn = activeYn; - return this; - } - - public FnUserDtoBuilder setCreatedId(Long createdId) { - this.createdId = createdId; - return this; - } - - public FnUserDtoBuilder setCreatedDate(LocalDateTime createdDate) { - this.createdDate = createdDate; - return this; - } - - public FnUserDtoBuilder setModifiedId(Long modifiedId) { - this.modifiedId = modifiedId; - return this; - } - - public FnUserDtoBuilder setModifiedDate(LocalDateTime modifiedDate) { - this.modifiedDate = modifiedDate; - return this; - } - - public FnUserDtoBuilder setIsInternalYn(String isInternalYn) { - this.isInternalYn = isInternalYn; - return this; - } - - public FnUserDtoBuilder setAddressLine1(String addressLine1) { - this.addressLine1 = addressLine1; - return this; - } - - public FnUserDtoBuilder setAddressLine2(String addressLine2) { - this.addressLine2 = addressLine2; - return this; - } - - public FnUserDtoBuilder setCity(String city) { - this.city = city; - return this; - } - - public FnUserDtoBuilder setStateCd(String stateCd) { - this.stateCd = stateCd; - return this; - } - - public FnUserDtoBuilder setZipCode(String zipCode) { - this.zipCode = zipCode; - return this; - } - - public FnUserDtoBuilder setCountryCd(String countryCd) { - this.countryCd = countryCd; - return this; - } - - public FnUserDtoBuilder setLocationClli(String locationClli) { - this.locationClli = locationClli; - return this; - } - - public FnUserDtoBuilder setOrgManagerUserId(String orgManagerUserId) { - this.orgManagerUserId = orgManagerUserId; - return this; - } - - public FnUserDtoBuilder setCompany(String company) { - this.company = company; - return this; - } - - public FnUserDtoBuilder setDepartmentName(String departmentName) { - this.departmentName = departmentName; - return this; - } - - public FnUserDtoBuilder setJobTitle(String jobTitle) { - this.jobTitle = jobTitle; - return this; - } - - public FnUserDtoBuilder setTimezone(Long timezone) { - this.timezone = timezone; - return this; - } - - public FnUserDtoBuilder setDepartment(String department) { - this.department = department; - return this; - } - - public FnUserDtoBuilder setBusinessUnit(String businessUnit) { - this.businessUnit = businessUnit; - return this; - } - - public FnUserDtoBuilder setBusinessUnitName(String businessUnitName) { - this.businessUnitName = businessUnitName; - return this; - } - - public FnUserDtoBuilder setCost_center(String cost_center) { - this.cost_center = cost_center; - return this; - } - - public FnUserDtoBuilder setFinLocCode(String finLocCode) { - this.finLocCode = finLocCode; - return this; - } - - public FnUserDtoBuilder setSiloStatus(String siloStatus) { - this.siloStatus = siloStatus; - return this; - } - - public FnUserDtoBuilder setLanguageId(Long languageId) { - this.languageId = languageId; - return this; - } - - public FnUserDtoBuilder setGuest(boolean guest) { - this.guest = guest; - return this; - } - - public FnUserDto createFnUserDto() { - return new FnUserDto(userId, orgId, managerId, firstName, middleName, lastName, phone, fax, cellular, - email, addressId, alertMethodCd, hrid, orgUserId, org_code, loginId, loginPwd, lastLoginDate, - activeYn, createdId, createdDate, modifiedId, modifiedDate, isInternalYn, addressLine1, - addressLine2, city, stateCd, zipCode, countryCd, locationClli, orgManagerUserId, company, - departmentName, jobTitle, timezone, department, businessUnit, businessUnitName, cost_center, - finLocCode, siloStatus, languageId, guest); - } -}
\ No newline at end of file diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/SchemaInfo.java b/portal-BE/src/main/java/org/onap/portal/domain/db/SchemaInfo.java index dee9aa5f..32e99ac6 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/SchemaInfo.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/SchemaInfo.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db; +import java.io.Serializable; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; @@ -73,7 +74,7 @@ CREATE TABLE `schema_info` ( @Getter @Setter @Entity -public class SchemaInfo { +public class SchemaInfo implements Serializable { @Id @Column(name = "SCHEMA_ID", length = 25, nullable = false) @Size(max = 25) diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/VUrlAccess.java b/portal-BE/src/main/java/org/onap/portal/domain/db/VUrlAccess.java index 1638d4ed..9f50f3bd 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/VUrlAccess.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/VUrlAccess.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db; +import java.io.Serializable; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; @@ -66,7 +67,7 @@ import org.hibernate.annotations.Subselect; + " from fn_restricted_url r") @Getter @NoArgsConstructor -public class VUrlAccess { +public class VUrlAccess implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "id", nullable = false) diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrFavoriteReports.java b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrFavoriteReports.java index a1d4a9a0..6c8296a7 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrFavoriteReports.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrFavoriteReports.java @@ -74,7 +74,7 @@ CREATE TABLE `cr_favorite_reports` ( @Setter @IdClass(CrFavoriteReportsId.class) @Entity -public class CrFavoriteReports { +public class CrFavoriteReports implements Serializable{ @Id @Column(name = "user_id", length = 11, nullable = false) @Digits(integer = 11, fraction = 0) diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrFilehistLog.java b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrFilehistLog.java index c96806a2..3dec4ee1 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrFilehistLog.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrFilehistLog.java @@ -46,7 +46,6 @@ import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.Table; import javax.validation.constraints.Digits; -import javax.validation.constraints.Positive; import javax.validation.constraints.Size; import lombok.AllArgsConstructor; import lombok.Getter; @@ -76,7 +75,6 @@ public class CrFilehistLog { @Id @Column(name = "schedule_id", length = 11, nullable = false) @Digits(integer = 11, fraction = 0) - @Positive private Long scheduledId; //TODO URL @URL @URL diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrFolder.java b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrFolder.java index 1791eae7..44e3902f 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrFolder.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrFolder.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.cr; +import java.io.Serializable; import java.time.LocalDateTime; import java.util.Set; import javax.persistence.CascadeType; @@ -90,7 +91,7 @@ CREATE TABLE `cr_folder` ( @Getter @Setter @Entity -public class CrFolder { +public class CrFolder implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "folder_id", length = 11, nullable = false) diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrFolderAccess.java b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrFolderAccess.java index 44507ac2..05ec2465 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrFolderAccess.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrFolderAccess.java @@ -41,6 +41,7 @@ package org.onap.portal.domain.db.cr; +import java.io.Serializable; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; @@ -77,7 +78,7 @@ CREATE TABLE `cr_folder_access` ( @Getter @Setter @Entity -public class CrFolderAccess { +public class CrFolderAccess implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "folder_access_id", length = 11, nullable = false) diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrLuFileType.java b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrLuFileType.java index 21ac92b0..94201c58 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrLuFileType.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrLuFileType.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.cr; +import java.io.Serializable; import java.util.Set; import javax.persistence.CascadeType; import javax.persistence.Column; @@ -77,7 +78,7 @@ CREATE TABLE `cr_lu_file_type` ( @Getter @Setter @Entity -public class CrLuFileType { +public class CrLuFileType implements Serializable { @Id @Column(name = "lookup_id", length = 2, nullable = false) @Digits(integer = 2, fraction = 0) diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrRaptorActionImg.java b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrRaptorActionImg.java index ed153b42..b81fc3ac 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrRaptorActionImg.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrRaptorActionImg.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.cr; +import java.io.Serializable; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; @@ -68,7 +69,7 @@ CREATE TABLE `cr_raptor_action_img` ( @Getter @Setter @Entity -public class CrRaptorActionImg { +public class CrRaptorActionImg implements Serializable { @Id @Column(name = "image_id", length = 100, nullable = false) @Size(max = 100) diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrRaptorPdfImg.java b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrRaptorPdfImg.java index 129e6e09..c75733e6 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrRaptorPdfImg.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrRaptorPdfImg.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.cr; +import java.io.Serializable; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; @@ -66,7 +67,7 @@ CREATE TABLE `cr_raptor_pdf_img` ( @Getter @Setter @Entity -public class CrRaptorPdfImg { +public class CrRaptorPdfImg implements Serializable { @Id @Column(name = "image_id", length = 100, nullable = false) @Size(max = 100) diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrRemoteSchemaInfo.java b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrRemoteSchemaInfo.java index 95d991f8..fe6e77ad 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrRemoteSchemaInfo.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrRemoteSchemaInfo.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.cr; +import java.io.Serializable; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; @@ -68,7 +69,7 @@ CREATE TABLE `cr_remote_schema_info` ( @Getter @Setter @Entity -public class CrRemoteSchemaInfo { +public class CrRemoteSchemaInfo implements Serializable { @Id @Column(name = "schema_prefix", length = 5, nullable = false) @Size(max = 5) diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrReportDwnldLog.java b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrReportDwnldLog.java index 368bd0ff..5c3a21af 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrReportDwnldLog.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrReportDwnldLog.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.cr; +import java.io.Serializable; import java.time.LocalDateTime; import javax.persistence.Column; import javax.persistence.Entity; @@ -74,7 +75,7 @@ CREATE TABLE `cr_report_dwnld_log` ( @Getter @Setter @Entity -public class CrReportDwnldLog { +public class CrReportDwnldLog implements Serializable { @Id @Column(name = "user_id", nullable = false) @Digits(integer = 11, fraction = 0) diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrReportEmailSentLog.java b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrReportEmailSentLog.java index da87cf75..e43c5c76 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrReportEmailSentLog.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrReportEmailSentLog.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.cr; +import java.io.Serializable; import java.time.LocalDateTime; import javax.persistence.CascadeType; import javax.persistence.Column; @@ -87,7 +88,7 @@ CREATE TABLE `cr_report_email_sent_log` ( @Getter @Setter @Entity -public class CrReportEmailSentLog { +public class CrReportEmailSentLog implements Serializable { @Id @Column(name = "log_id", nullable = false) @Digits(integer = 11, fraction = 0) diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrReportFileHistory.java b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrReportFileHistory.java index 510e1958..05696ab6 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrReportFileHistory.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrReportFileHistory.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.cr; +import java.io.Serializable; import java.time.LocalDateTime; import java.util.Set; import javax.persistence.CascadeType; @@ -104,7 +105,7 @@ CREATE TABLE `cr_report_file_history` ( @Getter @Setter @Entity -public class CrReportFileHistory { +public class CrReportFileHistory implements Serializable { @Id @Column(name = "hist_id", nullable = false, length = 11) @Digits(integer = 11, fraction = 0) diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrReportLog.java b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrReportLog.java index 95088b62..30a0b27f 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrReportLog.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrReportLog.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.cr; +import java.io.Serializable; import java.time.LocalDateTime; import javax.persistence.CascadeType; import javax.persistence.Column; @@ -84,7 +85,7 @@ CREATE TABLE `cr_report_log` ( @Getter @Setter @Entity -public class CrReportLog { +public class CrReportLog implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) @JoinColumn(name = "id") diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrReportSchedule.java b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrReportSchedule.java index 6d09aa40..611dd194 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrReportSchedule.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrReportSchedule.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.cr; +import java.io.Serializable; import java.time.LocalDateTime; import java.util.Set; import javax.persistence.CascadeType; @@ -99,7 +100,7 @@ CREATE TABLE `cr_report_schedule` ( @Getter @Setter @Entity -public class CrReportSchedule { +public class CrReportSchedule implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "schedule_id", length = 11, nullable = false) diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrReportScheduleUsers.java b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrReportScheduleUsers.java index fe8e4b11..237956c1 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrReportScheduleUsers.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrReportScheduleUsers.java @@ -82,7 +82,7 @@ CREATE TABLE `cr_report_schedule_users` ( @Setter @Entity @IdClass(CrReportScheduleUsersId.class) -public class CrReportScheduleUsers { +public class CrReportScheduleUsers implements Serializable{ @Id @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) @JoinColumn(name = "schedule_id", nullable = false) diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrReportTemplateMap.java b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrReportTemplateMap.java index 88f056bf..a886bfd4 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrReportTemplateMap.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrReportTemplateMap.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.cr; +import java.io.Serializable; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; @@ -67,7 +68,7 @@ CREATE TABLE `cr_report_template_map` ( @Getter @Setter @Entity -public class CrReportTemplateMap { +public class CrReportTemplateMap implements Serializable { @Id @Column(name = "report_id", nullable = false) @NotNull diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrScheduleActivityLog.java b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrScheduleActivityLog.java index d6f8ac6e..015a4771 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrScheduleActivityLog.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrScheduleActivityLog.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.cr; +import java.io.Serializable; import java.time.LocalDateTime; import javax.persistence.Column; import javax.persistence.Entity; @@ -69,7 +70,7 @@ CREATE TABLE `cr_schedule_activity_log` ( @Getter @Setter @Entity -public class CrScheduleActivityLog { +public class CrScheduleActivityLog implements Serializable { @Id @Column(name = "schedule_id", nullable = false) @Digits(integer = 11, fraction = 0) diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrTableJoin.java b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrTableJoin.java index b4881ca6..eb1117cb 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrTableJoin.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrTableJoin.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.cr; +import java.io.Serializable; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; @@ -82,7 +83,7 @@ CREATE TABLE `cr_table_join` ( @Getter @Setter @Entity -public class CrTableJoin { +public class CrTableJoin implements Serializable { //TODO Unique constrains {srcTableName, destTableName}? @Id @GeneratedValue(strategy = GenerationType.AUTO) diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrTableRole.java b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrTableRole.java index 445e87aa..7b6a3013 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrTableRole.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrTableRole.java @@ -78,7 +78,7 @@ CREATE TABLE `cr_table_role` ( @Setter @Entity @IdClass(CrTableRoleId.class) -public class CrTableRole { +public class CrTableRole implements Serializable{ @Id @Valid @JoinColumn(name = "table_name", nullable = false) diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrTableSource.java b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrTableSource.java index ebe15c40..791e5617 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrTableSource.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrTableSource.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.cr; +import java.io.Serializable; import java.util.Set; import javax.persistence.CascadeType; import javax.persistence.Column; @@ -76,7 +77,7 @@ CREATE TABLE `cr_table_source` ( @Getter @Setter @Entity -public class CrTableSource { +public class CrTableSource implements Serializable { @Id @Column(name = "table_name", length = 30, nullable = false) @Size(max = 30) diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpAppFunction.java b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpAppFunction.java index 0f2f9500..d37c71ec 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpAppFunction.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpAppFunction.java @@ -84,7 +84,7 @@ CREATE TABLE `ep_app_function` ( @IdClass(EpAppFunctionId.class) @NoArgsConstructor @AllArgsConstructor -public class EpAppFunction { +public class EpAppFunction implements Serializable{ @Id @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) @JoinColumn(name = "app_id") diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpAppRoleFunction.java b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpAppRoleFunction.java index c41c55f4..8a60688b 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpAppRoleFunction.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpAppRoleFunction.java @@ -41,6 +41,7 @@ package org.onap.portal.domain.db.ep; +import java.io.Serializable; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; @@ -91,7 +92,7 @@ CREATE TABLE `ep_app_role_function` ( @Getter @Setter @Entity -public class EpAppRoleFunction { +public class EpAppRoleFunction implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "id", length = 11, nullable = false, columnDefinition = "int(11) NOT NULL AUTO_INCREMENT") diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpBasicAuthAccount.java b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpBasicAuthAccount.java index 130e987f..c65c0d34 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpBasicAuthAccount.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpBasicAuthAccount.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.ep; +import java.io.Serializable; import java.util.Set; import javax.persistence.CascadeType; import javax.persistence.Column; @@ -77,7 +78,7 @@ CREATE TABLE `ep_basic_auth_account` ( @Getter @Setter @Entity -public class EpBasicAuthAccount { +public class EpBasicAuthAccount implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "id", length = 11, nullable = false, columnDefinition = "int(11) AUTO_INCREMENT") diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpEndpoints.java b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpEndpoints.java index ed1fabdf..ccb1bb29 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpEndpoints.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpEndpoints.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.ep; +import java.io.Serializable; import java.util.Set; import javax.persistence.CascadeType; import javax.persistence.Column; @@ -74,7 +75,7 @@ CREATE TABLE `ep_endpoints` ( @Getter @Setter @Entity -public class EpEndpoints { +public class EpEndpoints implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "id", length = 11, nullable = false, columnDefinition = "int(11) AUTO_INCREMENT") diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpEndpointsBasicAuthAccount.java b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpEndpointsBasicAuthAccount.java index 63411860..9cf7d36b 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpEndpointsBasicAuthAccount.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpEndpointsBasicAuthAccount.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.ep; +import java.io.Serializable; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; @@ -92,7 +93,7 @@ CREATE TABLE `ep_endpoints_basic_auth_account` ( @Getter @Setter @Entity -public class EpEndpointsBasicAuthAccount { +public class EpEndpointsBasicAuthAccount implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "id", length = 11, nullable = false, columnDefinition = "int(11) AUTO_INCREMENT") diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpMicroservice.java b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpMicroservice.java index 2388c53e..6c6b39cc 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpMicroservice.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpMicroservice.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.ep; +import java.io.Serializable; import java.util.Set; import javax.persistence.CascadeType; import javax.persistence.Column; @@ -88,11 +89,10 @@ CREATE TABLE `ep_microservice` ( }) @NoArgsConstructor @AllArgsConstructor - @Getter @Setter @Entity -public class EpMicroservice { +public class EpMicroservice implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "id", length = 11, nullable = false) diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpMicroserviceParameter.java b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpMicroserviceParameter.java index 30de49a5..554dd7b5 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpMicroserviceParameter.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpMicroserviceParameter.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.ep; +import java.io.Serializable; import java.util.Set; import javax.persistence.CascadeType; import javax.persistence.Column; @@ -78,7 +79,14 @@ CREATE TABLE `ep_microservice_parameter` ( @NamedQueries({ @NamedQuery( name = "EpMicroserviceParameter.deleteByServiceId", - query = "FROM EpMicroserviceParameter WHERE service_id =:serviceId") + query = "DELETE FROM EpMicroserviceParameter WHERE service_id =:SERVICEID"), + @NamedQuery( + name = "EpMicroserviceParameter.getParametersById", + query = "FROM EpMicroserviceParameter WHERE service_id =:SERVICEID"), + @NamedQuery( + name = "EpMicroserviceParameter.deleteMicroserviceParameterById", + query = "DELETE FROM EpMicroserviceParameter WHERE id =:PARAMID" + ) }) @Table(name = "ep_microservice_parameter", indexes = { @@ -86,11 +94,10 @@ CREATE TABLE `ep_microservice_parameter` ( }) @NoArgsConstructor @AllArgsConstructor - @Getter @Setter @Entity -public class EpMicroserviceParameter { +public class EpMicroserviceParameter implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpMlModel.java b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpMlModel.java index d865fa41..3d929d84 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpMlModel.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpMlModel.java @@ -69,12 +69,11 @@ CREATE TABLE `ep_ml_model` ( @Table(name = "ep_ml_model") @NoArgsConstructor @AllArgsConstructor - @Getter @Setter @Entity @IdClass(EpMlModelId.class) -public class EpMlModel { +public class EpMlModel implements Serializable{ @Id @Digits(integer = 11, fraction = 0) @Column(name = "group_id", length = 11, nullable = false) diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpMlRec.java b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpMlRec.java index 08c5fdf7..6422a27a 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpMlRec.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpMlRec.java @@ -69,12 +69,11 @@ CREATE TABLE `ep_ml_rec` ( @Table(name = "ep_ml_rec") @NoArgsConstructor @AllArgsConstructor - @Getter @Setter @Entity @IdClass(EpMlRecId.class) -public class EpMlRec { +public class EpMlRec implements Serializable{ @Id @Column(name = "time_stamp", nullable = false, columnDefinition = "datetime DEFAULT current_timestamp()") private LocalDateTime timeStamp; diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpMlUser.java b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpMlUser.java index c47f3d31..7febda8f 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpMlUser.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpMlUser.java @@ -71,12 +71,11 @@ CREATE TABLE `ep_ml_user` ( @Table(name = "ep_ml_user") @NoArgsConstructor @AllArgsConstructor - @Getter @Setter @Entity @IdClass(EpMlUserId.class) -public class EpMlUser { +public class EpMlUser implements Serializable{ @Id @Column(name = "time_stamp", nullable = false, columnDefinition = "datetime DEFAULT current_timestamp()") private LocalDateTime timeStamp; diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpNotification.java b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpNotification.java index 12c161f6..424f61b8 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpNotification.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpNotification.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.ep; +import java.io.Serializable; import java.time.LocalDateTime; import java.util.Set; import javax.persistence.CascadeType; @@ -88,7 +89,7 @@ CREATE TABLE `ep_notification` ( @Getter @Setter @Entity -public class EpNotification { +public class EpNotification implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "notification_ID", length = 11, nullable = false) diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpPersUserAppSort.java b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpPersUserAppSort.java index 5f6e9799..1976533e 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpPersUserAppSort.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpPersUserAppSort.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.ep; +import java.io.Serializable; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; @@ -90,7 +91,7 @@ CREATE TABLE `ep_pers_user_app_sort` ( @Getter @Setter @Entity -public class EpPersUserAppSort { +public class EpPersUserAppSort implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "id", length = 11, nullable = false, columnDefinition = "int(11) AUTO_INCREMENT") diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpPersUserWidgetPlacement.java b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpPersUserWidgetPlacement.java index 060ca425..b1e472f8 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpPersUserWidgetPlacement.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpPersUserWidgetPlacement.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.ep; +import java.io.Serializable; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; @@ -95,7 +96,7 @@ CREATE TABLE `ep_pers_user_widget_placement` ( @Getter @Setter @Entity -public class EpPersUserWidgetPlacement { +public class EpPersUserWidgetPlacement implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "id", length = 11, nullable = false, columnDefinition = "int(11) AUTO_INCREMENT") diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpPersUserWidgetSel.java b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpPersUserWidgetSel.java index 6c439c8b..9cee72a3 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpPersUserWidgetSel.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpPersUserWidgetSel.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.ep; +import java.io.Serializable; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; @@ -49,6 +50,8 @@ import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; import javax.persistence.Table; import javax.persistence.UniqueConstraint; import javax.validation.Valid; @@ -61,6 +64,7 @@ import lombok.NoArgsConstructor; import lombok.Setter; import org.hibernate.validator.constraints.SafeHtml; import org.onap.portal.domain.db.fn.FnUser; +import org.onap.portal.domain.dto.DomainVo; /* CREATE TABLE `ep_pers_user_widget_sel` ( @@ -75,7 +79,11 @@ CREATE TABLE `ep_pers_user_widget_sel` ( CONSTRAINT `fk_2_ep_pers_user_wid_sel_ep_wid` FOREIGN KEY (`widget_id`) REFERENCES `ep_widget_catalog` (`widget_id`) ) */ - +@NamedQueries({ + @NamedQuery( + name = "EpPersUserWidgetSel.getEpPersUserWidgetSelForUserIdAndWidgetId", + query = "FROM EpPersUserWidgetSel WHERE userId = :USERID and widgetId = :WIDGETID") +}) @Table(name = "ep_pers_user_widget_sel", uniqueConstraints = { @UniqueConstraint(columnNames = {"user_id", "widget_id"}) }) @@ -84,13 +92,14 @@ CREATE TABLE `ep_pers_user_widget_sel` ( @Getter @Setter @Entity -public class EpPersUserWidgetSel { +public class EpPersUserWidgetSel extends DomainVo implements Serializable { + @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "id", length = 11, nullable = false) @Digits(integer = 11, fraction = 0) private Long id; - @ManyToOne(fetch = FetchType.LAZY,cascade = CascadeType.ALL) + @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) @JoinColumn(name = "user_id", nullable = false) @NotNull @Valid diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpRoleNotification.java b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpRoleNotification.java index 80f8676b..94df52d5 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpRoleNotification.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpRoleNotification.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.ep; +import java.io.Serializable; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; @@ -84,7 +85,7 @@ CREATE TABLE `ep_role_notification` ( @Getter @Setter @Entity -public class EpRoleNotification { +public class EpRoleNotification implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "ID", length = 11, nullable = false, columnDefinition = "int(11) AUTO_INCREMENT") diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpUserNotification.java b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpUserNotification.java index 47e195a4..15bb2b9a 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpUserNotification.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpUserNotification.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.ep; +import java.io.Serializable; import java.time.LocalDateTime; import javax.persistence.CascadeType; import javax.persistence.Column; @@ -88,7 +89,7 @@ CREATE TABLE `ep_user_notification` ( @Getter @Setter @Entity -public class EpUserNotification { +public class EpUserNotification implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "ID", length = 11, nullable = false, columnDefinition = "int(11) AUTO_INCREMENT") diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpUserRolesRequest.java b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpUserRolesRequest.java index 13d26f71..52d06b2a 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpUserRolesRequest.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpUserRolesRequest.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.ep; +import java.io.Serializable; import java.time.LocalDateTime; import java.util.Set; import javax.persistence.CascadeType; @@ -88,7 +89,7 @@ CREATE TABLE `ep_user_roles_request` ( @Getter @Setter @Entity -public class EpUserRolesRequest { +public class EpUserRolesRequest implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "req_id", length = 11, nullable = false, columnDefinition = "int(11) AUTO_INCREMENT") diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpUserRolesRequestDet.java b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpUserRolesRequestDet.java index 1b27ee7b..76044530 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpUserRolesRequestDet.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpUserRolesRequestDet.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.ep; +import java.io.Serializable; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; @@ -86,7 +87,7 @@ CREATE TABLE `ep_user_roles_request_det` ( @Getter @Setter @Entity -public class EpUserRolesRequestDet { +public class EpUserRolesRequestDet implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpWebAnalyticsSource.java b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpWebAnalyticsSource.java index 1a15518f..429bac1b 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpWebAnalyticsSource.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpWebAnalyticsSource.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.ep; +import java.io.Serializable; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; @@ -82,7 +83,7 @@ CREATE TABLE `ep_web_analytics_source` ( @Getter @Setter @Entity -public class EpWebAnalyticsSource { +public class EpWebAnalyticsSource implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "resource_id", length = 11, nullable = false, columnDefinition = "int(11) AUTO_INCREMENT") diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpWidgetCatalog.java b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpWidgetCatalog.java index a125e1d1..a19af285 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpWidgetCatalog.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpWidgetCatalog.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.ep; +import java.io.Serializable; import java.util.Set; import javax.persistence.CascadeType; import javax.persistence.Column; @@ -82,7 +83,7 @@ CREATE TABLE `ep_widget_catalog` ( @Getter @Setter @Entity -public class EpWidgetCatalog { +public class EpWidgetCatalog implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "widget_id", length = 11, nullable = false) diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpWidgetCatalogFiles.java b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpWidgetCatalogFiles.java index db9fc152..fe91d235 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpWidgetCatalogFiles.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpWidgetCatalogFiles.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.ep; +import java.io.Serializable; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; @@ -74,7 +75,7 @@ CREATE TABLE `ep_widget_catalog_files` ( @Getter @Setter @Entity -public class EpWidgetCatalogFiles { +public class EpWidgetCatalogFiles implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "file_id", length = 11, nullable = false, columnDefinition = "int(11) AUTO_INCREMENT") diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpWidgetCatalogParameter.java b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpWidgetCatalogParameter.java index c63245cc..2ac07cc3 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpWidgetCatalogParameter.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpWidgetCatalogParameter.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.ep; +import java.io.Serializable; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; @@ -50,6 +51,8 @@ import javax.persistence.Id; import javax.persistence.Index; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; import javax.persistence.Table; import javax.validation.Valid; import javax.validation.constraints.Digits; @@ -79,6 +82,19 @@ CREATE TABLE `ep_widget_catalog_parameter` ( ) */ +@NamedQueries({ + @NamedQuery( + name = "EpWidgetCatalogParameter.retrieveByParamId", + query = "FROM EpWidgetCatalogParameter WHERE paramId = :PARAMID"), + @NamedQuery( + name = "EpWidgetCatalogParameter.deleteWidgetCatalogParameter", + query = "DELETE FROM EpWidgetCatalogParameter WHERE paramId = :PARAMID"), + @NamedQuery( + name = "EpWidgetCatalogParameter.getUserParamById", + query = "FROM EpWidgetCatalogParameter WHERE paramId = :PARAMID and userId = :USERID and widgetId = :WIDGETID" + ) +}) + @Table(name = "ep_widget_catalog_parameter", indexes = { @Index(name = "EP_FN_USER_WIDGET_PARAMETER_FK", columnList = "user_id"), @Index(name = "EP_WIDGET_CATALOG_WIDGET_PARAMETER_FK", columnList = "widget_id"), @@ -89,12 +105,13 @@ CREATE TABLE `ep_widget_catalog_parameter` ( @Getter @Setter @Entity -public class EpWidgetCatalogParameter { +public class EpWidgetCatalogParameter implements Serializable { + @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "id", length = 11, nullable = false, columnDefinition = "int(11) AUTO_INCREMENT") @Digits(integer = 11, fraction = 0) - private Integer id; + private Long id; @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) @JoinColumn(name = "widget_id", nullable = false) @NotNull diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpWidgetCatalogRole.java b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpWidgetCatalogRole.java index d2191814..b226b92d 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpWidgetCatalogRole.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpWidgetCatalogRole.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.ep; +import java.io.Serializable; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; @@ -83,8 +84,7 @@ CREATE TABLE `ep_widget_catalog_role` ( @Getter @Setter @Entity -//TODO there is something wrong with "KEY" -public class EpWidgetCatalogRole { +public class EpWidgetCatalogRole implements Serializable { @Id @Column(name = "id", length = 11, nullable = false) @Digits(integer = 11, fraction = 0) diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpWidgetPreviewFiles.java b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpWidgetPreviewFiles.java index b66ef624..d96524e1 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpWidgetPreviewFiles.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpWidgetPreviewFiles.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.ep; +import java.io.Serializable; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; @@ -69,7 +70,7 @@ CREATE TABLE `ep_widget_preview_files` ( @Getter @Setter @Entity -public class EpWidgetPreviewFiles { +public class EpWidgetPreviewFiles implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "preview_id", length = 11, nullable = false, columnDefinition = "int(11) AUTO_INCREMENT") diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnApp.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnApp.java index cdc20897..399cb55c 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnApp.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnApp.java @@ -172,17 +172,9 @@ public class FnApp extends DomainVo implements Serializable { @NotNull private String appPassword; @Column(name = "open", length = 1, columnDefinition = "char(1) default 'N'") - @Pattern(regexp = "[YNyn]") - @Size(max = 1) - @NotNull - @SafeHtml - private String open; + private Boolean open; @Column(name = "ENABLED", length = 1, columnDefinition = "char(1) default 'N'") - @Pattern(regexp = "[YNyn]") - @Size(max = 1) - @NotNull - @SafeHtml - private String enabled; + private Boolean enabled; @Column(name = "active_yn", length = 1, columnDefinition = "char(1) default 'Y'") @Pattern(regexp = "[YNyn]") @Size(max = 1) @@ -211,11 +203,7 @@ public class FnApp extends DomainVo implements Serializable { @Digits(integer = 11, fraction = 0) private Long appType; @Column(name = "auth_central", length = 1, columnDefinition = "char(1) not null default 'N'", nullable = false) - @Pattern(regexp = "[YNyn]") - @Size(max = 1) - @NotNull - @SafeHtml - private String authCentral; + private Boolean authCentral; @Column(name = "auth_namespace", length = 100) @Size(max = 100) @SafeHtml @@ -283,4 +271,8 @@ public class FnApp extends DomainVo implements Serializable { fetch = FetchType.LAZY ) private Set<FnPersUserAppSel> fnPersUserAppSels; + + public Boolean isRestrictedApp() { + return (this.appType == 2); + } } diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnAuditAction.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnAuditAction.java index d85ee2ae..da60049b 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnAuditAction.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnAuditAction.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.fn; +import java.io.Serializable; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; @@ -73,7 +74,7 @@ CREATE TABLE `fn_audit_action` ( @Getter @Setter @Entity -public class FnAuditAction { +public class FnAuditAction implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "role_id", nullable = false) diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnAuditActionLog.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnAuditActionLog.java index ccea932e..df73f42c 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnAuditActionLog.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnAuditActionLog.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.fn; +import java.io.Serializable; import java.time.LocalDateTime; import javax.persistence.Column; import javax.persistence.Entity; @@ -76,7 +77,7 @@ CREATE TABLE `fn_audit_action_log` ( @Getter @Setter @Entity -public class FnAuditActionLog { +public class FnAuditActionLog implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnAuditLog.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnAuditLog.java index 469fb74a..911f32a2 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnAuditLog.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnAuditLog.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.fn; +import java.io.Serializable; import java.time.LocalDateTime; import javax.persistence.CascadeType; import javax.persistence.Column; @@ -88,7 +89,7 @@ CREATE TABLE `fn_audit_log` ( @Getter @Setter @Entity -public class FnAuditLog { +public class FnAuditLog implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "log_id", length = 11, nullable = false, columnDefinition = "int(11) AUTO_INCREMENT") diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnBroadcastMessage.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnBroadcastMessage.java index c863fcbd..e9cfc20d 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnBroadcastMessage.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnBroadcastMessage.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.fn; +import java.io.Serializable; import java.time.LocalDateTime; import javax.persistence.Column; import javax.persistence.Entity; @@ -77,7 +78,7 @@ CREATE TABLE `fn_broadcast_message` ( @Getter @Setter @Entity -public class FnBroadcastMessage { +public class FnBroadcastMessage implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnChatLogs.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnChatLogs.java index 93a07f1c..d57bfd33 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnChatLogs.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnChatLogs.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.fn; +import java.io.Serializable; import java.time.LocalDateTime; import javax.persistence.Column; import javax.persistence.Entity; @@ -69,7 +70,7 @@ CREATE TABLE `fn_chat_logs` ( @Getter @Setter @Entity -public class FnChatLogs { +public class FnChatLogs implements Serializable { @Id @Column(name = "chat_log_id", nullable = false) private Long chatLogId; diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnChatRoom.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnChatRoom.java index c61d9f19..abf96539 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnChatRoom.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnChatRoom.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.fn; +import java.io.Serializable; import java.time.LocalDateTime; import javax.persistence.Column; import javax.persistence.Entity; @@ -74,7 +75,7 @@ CREATE TABLE `fn_chat_room` ( @Getter @Setter @Entity -public class FnChatRoom { +public class FnChatRoom implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "chat_room_id", nullable = false) diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnChatUsers.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnChatUsers.java index 85e9b59a..c0e28143 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnChatUsers.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnChatUsers.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.fn; +import java.io.Serializable; import java.time.LocalDateTime; import javax.persistence.Column; import javax.persistence.Entity; @@ -72,7 +73,7 @@ CREATE TABLE `fn_chat_users` ( @Getter @Setter @Entity -public class FnChatUsers { +public class FnChatUsers implements Serializable { @Id @Column(name = "id", length = 11, nullable = false) @Digits(integer = 11, fraction = 0) diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnCommonWidgetData.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnCommonWidgetData.java index ac8f23c4..1255aa1d 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnCommonWidgetData.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnCommonWidgetData.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.fn; +import java.io.Serializable; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; @@ -73,7 +74,7 @@ CREATE TABLE `fn_common_widget_data` ( @Getter @Setter @Entity -public class FnCommonWidgetData { +public class FnCommonWidgetData implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "id", nullable = false, columnDefinition = "int(11) AUTO_INCREMENT") diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnDatasource.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnDatasource.java index 73dfa8a0..87ee3592 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnDatasource.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnDatasource.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.fn; +import java.io.Serializable; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; @@ -81,7 +82,7 @@ CREATE TABLE `fn_datasource` ( @Getter @Setter @Entity -public class FnDatasource { +public class FnDatasource implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "message_id", length = 11, nullable = false, columnDefinition = "int(11) AUTO_INCREMENT") diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnDisplayText.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnDisplayText.java index e79126c4..348cf9ec 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnDisplayText.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnDisplayText.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.fn; +import java.io.Serializable; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; @@ -71,7 +72,7 @@ CREATE TABLE `fn_display_text` ( @Getter @Setter @Entity -public class FnDisplayText { +public class FnDisplayText implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnFunction.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnFunction.java index 41ac1d6b..3375fd09 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnFunction.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnFunction.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.fn; +import java.io.Serializable; import java.util.Set; import javax.persistence.CascadeType; import javax.persistence.Column; @@ -70,7 +71,7 @@ CREATE TABLE `fn_function` ( @Getter @Setter @Entity -public class FnFunction { +public class FnFunction implements Serializable { @Id @Column(name = "function_cd", length = 30, nullable = false) @Size(max = 30) diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLanguage.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLanguage.java index 57fd9993..4b9186eb 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLanguage.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLanguage.java @@ -41,6 +41,7 @@ package org.onap.portal.domain.db.fn; import com.fasterxml.jackson.annotation.JsonInclude; +import java.io.Serializable; import java.util.Set; import javax.persistence.CascadeType; import javax.persistence.Column; @@ -56,6 +57,7 @@ import javax.validation.constraints.Digits; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; @@ -72,13 +74,13 @@ CREATE TABLE `fn_language` ( @Table(name = "fn_language") @NoArgsConstructor @AllArgsConstructor - +@Builder @Getter @Setter @Entity @JsonInclude() @SequenceGenerator(name="seq", initialValue=1000, allocationSize=100000) -public class FnLanguage { +public class FnLanguage implements Serializable { @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq") diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLuActivity.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLuActivity.java index 6b0b47c5..f4d0d709 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLuActivity.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLuActivity.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.fn; +import java.io.Serializable; import java.util.Set; import javax.persistence.CascadeType; import javax.persistence.Column; @@ -70,7 +71,7 @@ CREATE TABLE `fn_lu_activity` ( @Getter @Setter @Entity -public class FnLuActivity { +public class FnLuActivity implements Serializable { @Id @Column(name = "activity_cd", length = 50, nullable = false) @Size(max = 50) diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLuAlertMethod.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLuAlertMethod.java index 6ee07167..740f052b 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLuAlertMethod.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLuAlertMethod.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.fn; +import java.io.Serializable; import java.util.Set; import javax.persistence.CascadeType; import javax.persistence.Column; @@ -70,7 +71,7 @@ CREATE TABLE `fn_lu_alert_method` ( @Getter @Setter @Entity -public class FnLuAlertMethod { +public class FnLuAlertMethod implements Serializable { @Id @Column(name = "alert_method_cd", length = 10, nullable = false) @Size(max = 50) diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLuBroadcastSite.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLuBroadcastSite.java index 6d1c723e..b0d16e58 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLuBroadcastSite.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLuBroadcastSite.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.fn; +import java.io.Serializable; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; @@ -65,7 +66,7 @@ CREATE TABLE `fn_lu_broadcast_site` ( @Getter @Setter @Entity -public class FnLuBroadcastSite { +public class FnLuBroadcastSite implements Serializable { @Id @Column(name = "broadcast_site_cd", length = 50, nullable = false) @Size(max = 50) diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLuMenuSet.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLuMenuSet.java index 3ac88232..ff5e4736 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLuMenuSet.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLuMenuSet.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.fn; +import java.io.Serializable; import java.util.Set; import javax.persistence.CascadeType; import javax.persistence.Column; @@ -72,7 +73,7 @@ CREATE TABLE `fn_lu_menu_set` ( @Getter @Setter @Entity -public class FnLuMenuSet { +public class FnLuMenuSet implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLuPriority.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLuPriority.java index 1c96abb7..4e5e2335 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLuPriority.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLuPriority.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.fn; +import java.io.Serializable; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; @@ -72,7 +73,7 @@ CREATE TABLE `fn_lu_priority` ( @Getter @Setter @Entity -public class FnLuPriority { +public class FnLuPriority implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "priority_id", nullable = false, length = 11) diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLuRoleType.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLuRoleType.java index 9f500219..525ba0de 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLuRoleType.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLuRoleType.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.fn; +import java.io.Serializable; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; @@ -67,7 +68,7 @@ CREATE TABLE `fn_lu_role_type` ( @Getter @Setter @Entity -public class FnLuRoleType { +public class FnLuRoleType implements Serializable { @Id @Column(name = "role_type_id", nullable = false, length = 11) @Digits(integer = 11, fraction = 0) diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLuTabSet.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLuTabSet.java index c8c7be22..06e982ca 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLuTabSet.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLuTabSet.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.fn; +import java.io.Serializable; import java.util.Set; import javax.persistence.CascadeType; import javax.persistence.Column; @@ -70,7 +71,7 @@ CREATE TABLE `fn_lu_tab_set` ( @Getter @Setter @Entity -public class FnLuTabSet { +public class FnLuTabSet implements Serializable { @Id @Column(name = "tab_set_cd", length = 30, nullable = false) @Size(max = 30) diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLuTimezone.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLuTimezone.java index 53b54f41..54b4bc5c 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLuTimezone.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLuTimezone.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.fn; +import java.io.Serializable; import java.util.Set; import javax.persistence.CascadeType; import javax.persistence.Column; @@ -73,7 +74,7 @@ CREATE TABLE `fn_lu_timezone` ( @Getter @Setter @Entity -public class FnLuTimezone { +public class FnLuTimezone implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "timezone_id", length = 11, nullable = false) diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnMenu.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnMenu.java index 3ba60c78..7407213c 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnMenu.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnMenu.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.fn; +import java.io.Serializable; import java.util.Set; import javax.persistence.CascadeType; import javax.persistence.Column; @@ -101,7 +102,7 @@ CREATE TABLE `fn_menu` ( @Getter @Setter @Entity -public class FnMenu { +public class FnMenu implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "menu_id", nullable = false, length = 11, columnDefinition = "int(11) auto_increment") diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnMenuFunctional.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnMenuFunctional.java index cd9a362d..e348a01f 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnMenuFunctional.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnMenuFunctional.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.fn; +import java.io.Serializable; import java.util.Set; import javax.persistence.CascadeType; import javax.persistence.Column; @@ -89,7 +90,7 @@ CREATE TABLE `fn_menu_functional` ( @Getter @Setter @Entity -public class FnMenuFunctional { +public class FnMenuFunctional implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "menu_id", nullable = false, length = 11) diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnMenuFunctionalAncestors.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnMenuFunctionalAncestors.java index 5dd037f5..309f11ea 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnMenuFunctionalAncestors.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnMenuFunctionalAncestors.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.fn; +import java.io.Serializable; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; @@ -81,7 +82,7 @@ CREATE TABLE `fn_menu_functional_ancestors` ( @Getter @Setter @Entity -public class FnMenuFunctionalAncestors { +public class FnMenuFunctionalAncestors implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "id", nullable = false, length = 11, columnDefinition = "int(11) AUTO_INCREMENT") diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnMenuFunctionalRoles.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnMenuFunctionalRoles.java index c1ed7514..3e9ae0e0 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnMenuFunctionalRoles.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnMenuFunctionalRoles.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.fn; +import java.io.Serializable; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; @@ -85,7 +86,7 @@ CREATE TABLE `fn_menu_functional_roles` ( @Getter @Setter @Entity -public class FnMenuFunctionalRoles { +public class FnMenuFunctionalRoles implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "id", nullable = false, length = 11, columnDefinition = "int(11) AUTO_INCREMENT") diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnOrg.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnOrg.java index 46f9dcc3..9dea65ed 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnOrg.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnOrg.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.fn; +import java.io.Serializable; import java.util.Set; import javax.persistence.CascadeType; import javax.persistence.Column; @@ -75,11 +76,10 @@ CREATE TABLE `fn_org` ( }) @NoArgsConstructor @AllArgsConstructor - @Getter @Setter @Entity -public class FnOrg { +public class FnOrg implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "org_id", nullable = false, length = 11) @@ -90,7 +90,7 @@ public class FnOrg { @SafeHtml @NotNull private String orgName; - @Column(name = "access_cd", length = 10, columnDefinition = "varchar(10) DEFAULT NULL") + @Column(name = "access_cd", length = 10) @Size(max = 10) @SafeHtml private String accessCd; diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnPersUserAppSel.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnPersUserAppSel.java index 8aead523..1da9c219 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnPersUserAppSel.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnPersUserAppSel.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.fn; +import java.io.Serializable; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; @@ -85,7 +86,7 @@ CREATE TABLE `fn_pers_user_app_sel` ( @Getter @Setter @Entity -public class FnPersUserAppSel extends DomainVo { +public class FnPersUserAppSel extends DomainVo implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "id", length = 11, nullable = false, columnDefinition = "int(11) AUTO_INCREMENT") diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzBlobTriggers.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzBlobTriggers.java index c110fdc6..1c5c3b5d 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzBlobTriggers.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzBlobTriggers.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.fn; +import java.io.Serializable; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; @@ -81,7 +82,7 @@ CREATE TABLE `fn_qz_blob_triggers` ( @Setter @Entity @IdClass(FnQzTriggersId.class) -public class FnQzBlobTriggers { +public class FnQzBlobTriggers implements Serializable { @Id @ManyToOne @JoinColumns(value = { diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzCalendars.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzCalendars.java index d13ac345..a3499247 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzCalendars.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzCalendars.java @@ -73,7 +73,7 @@ CREATE TABLE `fn_qz_calendars` ( @Setter @Entity @IdClass(FnQzCalendarsId.class) -public class FnQzCalendars { +public class FnQzCalendars implements Serializable{ @Id @SafeHtml @Column(name = "SCHED_NAME", length = 120, insertable = false, updatable = false) diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzCronTriggers.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzCronTriggers.java index 4013e4f6..84c11629 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzCronTriggers.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzCronTriggers.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.fn; +import java.io.Serializable; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; @@ -77,7 +78,7 @@ CREATE TABLE `fn_qz_cron_triggers` ( @Setter @Entity @IdClass(FnQzTriggersId.class) -public class FnQzCronTriggers { +public class FnQzCronTriggers implements Serializable { @Id @ManyToOne @JoinColumns(value = { diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzFiredTriggers.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzFiredTriggers.java index e4c15d28..77583fd8 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzFiredTriggers.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzFiredTriggers.java @@ -100,7 +100,7 @@ CREATE TABLE `fn_qz_fired_triggers` ( @Setter @Entity @IdClass(FnQzFiredTriggersID.class) -public class FnQzFiredTriggers { +public class FnQzFiredTriggers implements Serializable{ @Id @Size(max = 120) @SafeHtml diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzJobDetails.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzJobDetails.java index 04426353..5da7b4fa 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzJobDetails.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzJobDetails.java @@ -90,7 +90,7 @@ CREATE TABLE `fn_qz_job_details` ( @Setter @Entity @IdClass(FnQzJobDetailsID.class) -public class FnQzJobDetails { +public class FnQzJobDetails implements Serializable{ @Id @SafeHtml @Size(max = 120) diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzLocks.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzLocks.java index cee0ebae..72558b52 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzLocks.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzLocks.java @@ -71,7 +71,7 @@ CREATE TABLE `fn_qz_locks` ( @Setter @Entity @IdClass(FnQzLocksID.class) -public class FnQzLocks { +public class FnQzLocks implements Serializable{ @Id @Size(max = 120) @SafeHtml diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzPausedTriggerGrps.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzPausedTriggerGrps.java index 38c65400..4e515f6b 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzPausedTriggerGrps.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzPausedTriggerGrps.java @@ -71,7 +71,7 @@ CREATE TABLE `fn_qz_paused_trigger_grps` ( @Setter @Entity @IdClass(FnQzPausedTriggerGrpsID.class) -public class FnQzPausedTriggerGrps { +public class FnQzPausedTriggerGrps implements Serializable{ @Id @Size(max = 120) @SafeHtml diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzSchedulerState.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzSchedulerState.java index b9005a66..3c00f959 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzSchedulerState.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzSchedulerState.java @@ -76,7 +76,7 @@ CREATE TABLE `fn_qz_scheduler_state` ( @Setter @Entity @IdClass(FnQzSchedulerStateID.class) -public class FnQzSchedulerState { +public class FnQzSchedulerState implements Serializable{ @Id @Size(max = 120) @SafeHtml diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzSimpleTriggers.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzSimpleTriggers.java index 6c1f355f..6f67381f 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzSimpleTriggers.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzSimpleTriggers.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.fn; +import java.io.Serializable; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; @@ -80,7 +81,7 @@ CREATE TABLE `fn_qz_simple_triggers` ( @Setter @Entity @IdClass(FnQzTriggersId.class) -public class FnQzSimpleTriggers { +public class FnQzSimpleTriggers implements Serializable { @Id @ManyToOne @JoinColumns(value = { diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzSimpropTriggers.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzSimpropTriggers.java index 378705c9..f1a42275 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzSimpropTriggers.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzSimpropTriggers.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.fn; +import java.io.Serializable; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; @@ -87,7 +88,7 @@ CREATE TABLE `fn_qz_simprop_triggers` ( @Setter @Entity @IdClass(FnQzTriggersId.class) -public class FnQzSimpropTriggers { +public class FnQzSimpropTriggers implements Serializable { @Id @ManyToOne @JoinColumns(value = { diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzTriggers.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzTriggers.java index 526de117..35fb1307 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzTriggers.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzTriggers.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.fn; +import java.io.Serializable; import java.math.BigInteger; import javax.persistence.Column; import javax.persistence.Entity; @@ -116,7 +117,7 @@ CREATE TABLE `fn_qz_triggers` ( @Setter @Entity @IdClass(FnQzTriggersId.class) -public class FnQzTriggers { +public class FnQzTriggers implements Serializable { @ManyToOne @JoinColumns(value = { @JoinColumn(name = "SCHED_NAME", referencedColumnName = "SCHED_NAME"), diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnRestrictedUrl.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnRestrictedUrl.java index 35b619cf..74e81ebe 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnRestrictedUrl.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnRestrictedUrl.java @@ -80,7 +80,7 @@ CREATE TABLE `fn_restricted_url` ( @Setter @Entity @IdClass(FnRestrictedUrlId.class) -public class FnRestrictedUrl { +public class FnRestrictedUrl implements Serializable{ @Column(name = "restricted_url", length = 250, nullable = false) @Size(max = 250) @SafeHtml diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnRole.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnRole.java index 05c3cf08..8465ce23 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnRole.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnRole.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.fn; +import java.io.Serializable; import java.util.Set; import javax.persistence.CascadeType; import javax.persistence.Column; @@ -58,7 +59,6 @@ import javax.persistence.OneToMany; import javax.persistence.Table; import javax.validation.constraints.Digits; import javax.validation.constraints.NotNull; -import javax.validation.constraints.Pattern; import javax.validation.constraints.Size; import lombok.AllArgsConstructor; import lombok.Getter; @@ -121,7 +121,7 @@ CREATE TABLE `fn_role` ( @Getter @Setter @Entity -public class FnRole extends DomainVo { +public class FnRole extends DomainVo implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnRoleFunction.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnRoleFunction.java index b62e8c22..944d7395 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnRoleFunction.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnRoleFunction.java @@ -81,7 +81,7 @@ CREATE TABLE `fn_role_function` ( @Setter @Entity @IdClass(FnRoleFunctionId.class) -public class FnRoleFunction { +public class FnRoleFunction implements Serializable{ @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) @JoinColumn(name = "role_Id", nullable = false) diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnRoleV.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnRoleV.java index 7eb96d6f..e1c4cded 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnRoleV.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnRoleV.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.fn; +import java.io.Serializable; import java.math.BigInteger; import javax.persistence.Column; import javax.persistence.Entity; @@ -62,7 +63,7 @@ import org.hibernate.annotations.Subselect; + " from fn_role where isnull(fn_role.app_id)") @Getter @NoArgsConstructor -public class FnRoleV { +public class FnRoleV implements Serializable { @Id @Column(name = "role_id") private Integer roleId; diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnScheduleWorkflows.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnScheduleWorkflows.java index e361b113..620532ee 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnScheduleWorkflows.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnScheduleWorkflows.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.fn; +import java.io.Serializable; import java.math.BigInteger; import java.time.LocalDateTime; import javax.persistence.Column; @@ -79,7 +80,7 @@ CREATE TABLE `fn_schedule_workflows` ( @Getter @Setter @Entity -public class FnScheduleWorkflows { +public class FnScheduleWorkflows implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "id_schedule_workflows", nullable = false, length = 25, columnDefinition = "bigint(25) AUTO_INCREMENT") diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnSharedContext.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnSharedContext.java index 48045701..7c021837 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnSharedContext.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnSharedContext.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.fn; +import java.io.Serializable; import java.time.LocalDateTime; import javax.persistence.Column; import javax.persistence.Entity; @@ -78,7 +79,7 @@ CREATE TABLE `fn_shared_context` ( @Getter @Setter @Entity -public class FnSharedContext { +public class FnSharedContext implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "id", nullable = false, length = 11, columnDefinition = "int(11) AUTO_INCREMENT") diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnTab.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnTab.java index bfc7834c..634fb649 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnTab.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnTab.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.fn; +import java.io.Serializable; import java.math.BigInteger; import java.util.Set; import javax.persistence.CascadeType; @@ -91,7 +92,7 @@ CREATE TABLE `fn_tab` ( @Getter @Setter @Entity -public class FnTab { +public class FnTab implements Serializable { @Id @Column(name = "tab_cd", length = 30, nullable = false) @Size(max = 30) diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnTabSelected.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnTabSelected.java index f62668e1..14b243dd 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnTabSelected.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnTabSelected.java @@ -78,7 +78,7 @@ CREATE TABLE `fn_tab_selected` ( @Setter @Entity @IdClass(FnTabSelectedId.class) -public class FnTabSelected { +public class FnTabSelected implements Serializable{ @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) @JoinColumn(name = "selected_tab_cd", nullable = false) @NotNull diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnUser.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnUser.java index 1c3435df..ce28d0fd 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnUser.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnUser.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.fn; +import java.io.Serializable; import java.time.LocalDateTime; import java.util.Collection; import java.util.Set; @@ -67,6 +68,7 @@ import javax.validation.constraints.NotNull; import javax.validation.constraints.PastOrPresent; import javax.validation.constraints.Size; import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; @@ -177,11 +179,12 @@ CREATE TABLE `fn_user` ( @Getter @Setter @Entity +@Builder @NoArgsConstructor @AllArgsConstructor @DynamicUpdate @SequenceGenerator(name = "seq", initialValue = 1000, allocationSize = 100000) -public class FnUser extends DomainVo implements UserDetails { +public class FnUser extends DomainVo implements UserDetails, Serializable { @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq") @@ -189,74 +192,71 @@ public class FnUser extends DomainVo implements UserDetails { @Digits(integer = 11, fraction = 0) private Long userId; @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) - @JoinColumn(name = "org_id", columnDefinition = "int(11) DEFAULT NULL") + @JoinColumn(name = "org_id") private FnOrg orgId; @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) @JoinColumn(name = "manager_id") private FnUser managerId; - @Column(name = "first_name", length = 50, columnDefinition = "varchar(50) DEFAULT NULL") + @Column(name = "first_name", length = 50) @Size(max = 50) @SafeHtml private String firstName; - @Column(name = "middle_name", length = 50, columnDefinition = "varchar(50) DEFAULT NULL") + @Column(name = "middle_name", length = 50) @Size(max = 50) @SafeHtml private String middleName; - @Column(name = "last_name", length = 50, columnDefinition = "varchar(50) DEFAULT NULL") + @Column(name = "last_name", length = 50) @Size(max = 50) @SafeHtml private String lastName; - @Column(name = "phone", length = 25, columnDefinition = "varchar(25) DEFAULT NULL") + @Column(name = "phone", length = 25) @Size(max = 25) @SafeHtml private String phone; - @Column(name = "fax", length = 25, columnDefinition = "varchar(25) DEFAULT NULL") + @Column(name = "fax", length = 25) @Size(max = 25) @SafeHtml private String fax; - @Column(name = "cellular", length = 25, columnDefinition = "varchar(25) DEFAULT NULL") + @Column(name = "cellular", length = 25) @Size(max = 25) @SafeHtml private String cellular; - @Column(name = "email", length = 50, columnDefinition = "varchar(50) DEFAULT NULL") + @Column(name = "email", length = 50) @Size(max = 50) @Email @SafeHtml private String email; - @Column(name = "address_id", columnDefinition = "decimal(11,0) DEFAULT NULL") + @Column(name = "address_id") @Digits(integer = 11, fraction = 0) private Long addressId; @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) - @JoinColumn(name = "alert_method_cd", columnDefinition = "varchar(10) DEFAULT NULL") + @JoinColumn(name = "alert_method_cd") private FnLuAlertMethod alertMethodCd; - @Column(name = "hrid", length = 20, columnDefinition = "varchar(20) DEFAULT NULL") + @Column(name = "hrid", length = 20) @Size(max = 20) @SafeHtml private String hrid; - @Column(name = "org_user_id", length = 20, columnDefinition = "varchar(20) DEFAULT NULL") + @Column(name = "org_user_id", length = 20) @Size(max = 20) @SafeHtml private String orgUserId; - @Column(name = "org_code", length = 30, columnDefinition = "varchar(30) DEFAULT NULL") + @Column(name = "org_code", length = 30) @Size(max = 30) @SafeHtml private String org_code; - @Column(name = "login_id", length = 25, columnDefinition = "varchar(25) DEFAULT NULL") + @Column(name = "login_id", length = 25) @Size(max = 25) @SafeHtml private String loginId; - @Column(name = "login_pwd", length = 100, columnDefinition = "varchar(100) DEFAULT NULL") + @Column(name = "login_pwd", length = 100) @Size(max = 100) @SafeHtml private String loginPwd; @Column(name = "last_login_date", nullable = false, columnDefinition = "datetime DEFAULT current_timestamp() ON UPDATE current_timestamp()") @PastOrPresent protected LocalDateTime lastLoginDate; - @Column(name = "active_yn", length = 1, columnDefinition = "character varying(1) default 'y'", nullable = false) - @Size(max = 1) - @SafeHtml - @NotNull(message = "activeYn must not be null") - private String activeYn; + @Column(name = "active_yn", nullable = false) + private Boolean activeYn; @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) @JoinColumn(name = "created_id") private FnUser createdId; @@ -269,79 +269,76 @@ public class FnUser extends DomainVo implements UserDetails { @Column(name = "modified_date", nullable = false, columnDefinition = "datetime default now()") @PastOrPresent protected LocalDateTime modifiedDate; - @Column(name = "is_internal_yn", length = 1, columnDefinition = "character varying(1) default 'n'", nullable = false) - @Size(max = 1) - @SafeHtml - @NotNull(message = "isInternalYn must not be null") - private String isInternalYn; - @Column(name = "address_line_1", length = 100, columnDefinition = "varchar(100) DEFAULT NULL") + @Column(name = "is_internal_yn", nullable = false, columnDefinition = "bit DEFAULT 0") + private Boolean isInternalYn; + @Column(name = "address_line_1", length = 100) @Size(max = 100) @SafeHtml private String addressLine1; - @Column(name = "address_line_2", length = 100, columnDefinition = "varchar(100) DEFAULT NULL") + @Column(name = "address_line_2", length = 100) @Size(max = 100) @SafeHtml private String addressLine2; - @Column(name = "city", length = 50, columnDefinition = "varchar(50) DEFAULT NULL") + @Column(name = "city", length = 50) @Size(max = 50) @SafeHtml private String city; - @Column(name = "state_cd", length = 3, columnDefinition = "varchar(3) DEFAULT NULL") + @Column(name = "state_cd", length = 3) @Size(max = 3) @SafeHtml private String stateCd; - @Column(name = "zip_code", length = 11, columnDefinition = "varchar(11) DEFAULT NULL") + @Column(name = "zip_code", length = 11) @Size(max = 11) @SafeHtml private String zipCode; - @Column(name = "country_cd", length = 3, columnDefinition = "varchar(3) DEFAULT NULL") + @Column(name = "country_cd", length = 3) @Size(max = 3) @SafeHtml private String countryCd; - @Column(name = "location_clli", length = 8, columnDefinition = "varchar(8) DEFAULT NULL") + @Column(name = "location_clli", length = 8) @Size(max = 8) @SafeHtml private String locationClli; - @Column(name = "org_manager_userid", length = 20, columnDefinition = "varchar(20) DEFAULT NULL") + @Column(name = "org_manager_userid", length = 20) @Size(max = 20) @SafeHtml private String orgManagerUserId; - @Column(name = "company", length = 100, columnDefinition = "varchar(100) DEFAULT NULL") + @Column(name = "company", length = 100) @Size(max = 100) @SafeHtml private String company; - @Column(name = "department_name", length = 200, columnDefinition = "varchar(100) DEFAULT NULL") + @Column(name = "department_name", length = 200) @Size(max = 200) @SafeHtml private String departmentName; - @Column(name = "job_title", length = 100, columnDefinition = "varchar(100) DEFAULT NULL") + @Column(name = "job_title", length = 100) @Size(max = 100) @SafeHtml private String jobTitle; @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) - @JoinColumn(name = "timezone", columnDefinition = "int(11) DEFAULT NULL") + @JoinColumn(name = "timezone") private FnLuTimezone timezone; - @Column(name = "department", length = 25, columnDefinition = "varchar(25) DEFAULT NULL") + @Column(name = "department", length = 25) @Size(max = 25) @SafeHtml private String department; - @Column(name = "business_unit", length = 25, columnDefinition = "varchar(25) DEFAULT NULL") + @Column(name = "business_unit", length = 25) @Size(max = 25) @SafeHtml private String businessUnit; - @Column(name = "business_unit_name", length = 100, columnDefinition = "varchar(100) DEFAULT NULL") + @Column(name = "business_unit_name", length = 100) @Size(max = 100) @SafeHtml private String businessUnitName; - @Column(name = "cost_center", length = 25, columnDefinition = "varchar(25) DEFAULT NULL") + @Column(name = "cost_center", length = 25) @Size(max = 25) @SafeHtml private String cost_center; - @Column(name = "fin_loc_code", length = 10, columnDefinition = "varchar(10) DEFAULT NULL") + @Column(name = "fin_loc_code", length = 10) @Size(max = 10) @SafeHtml private String finLocCode; - @Column(name = "silo_status", length = 10, columnDefinition = "varchar(10) DEFAULT NULL") + @Column(name = "silo_status", length = 10) @Size(max = 10) @SafeHtml private String siloStatus; @@ -349,9 +346,9 @@ public class FnUser extends DomainVo implements UserDetails { @JoinColumn(name = "language_id", nullable = false, columnDefinition = "int(11) DEFAULT 1") @NotNull(message = "languageId must not be null") private FnLanguage languageId; - @Column(name = "is_guest", columnDefinition = "boolean default 0", nullable = false) + @Column(name = "is_guest", nullable = false, columnDefinition = "bit DEFAULT 0") @NotNull(message = "guest must not be null") - private boolean guest; + private Boolean guest; @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "fnUserList") private Set<CrReportFileHistory> crReportFileHistorie; @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER) diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnUserRole.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnUserRole.java index da709e31..390ef8b4 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnUserRole.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnUserRole.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.fn; +import java.io.Serializable; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; @@ -106,7 +107,7 @@ CREATE TABLE `fn_user_role` ( @Getter @Setter @Entity -public class FnUserRole { +public class FnUserRole implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnWidget.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnWidget.java new file mode 100644 index 00000000..649267bf --- /dev/null +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnWidget.java @@ -0,0 +1,71 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Modifications Copyright (c) 2019 Samsung + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * + */ + +package org.onap.portal.domain.db.fn; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +@Table(name = "fn_widget") +@NoArgsConstructor +@AllArgsConstructor +@Getter +@Setter +@Entity +public class FnWidget { + @Id + private Long widgetId; + @Column(name = "WDG_NAME") + private String name; + @Column(name = "WDG_WIDTH") + private Integer width; + @Column(name = "WDG_HEIGHT") + private Integer height; + @Column(name = "WDG_URL") + private String url; + @Column(name = "APP_ID") + private Long appId; +} diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnWorkflow.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnWorkflow.java index da8619df..b5a4ecb6 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnWorkflow.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnWorkflow.java @@ -40,6 +40,7 @@ package org.onap.portal.domain.db.fn; +import java.io.Serializable; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; @@ -82,7 +83,7 @@ CREATE TABLE `fn_workflow` ( @Getter @Setter @Entity -public class FnWorkflow { +public class FnWorkflow implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "id", nullable = false, length = 9, columnDefinition = "mediumint(9) AUTO_INCREMENT") diff --git a/portal-BE/src/main/java/org/onap/portal/domain/dto/DomainVo.java b/portal-BE/src/main/java/org/onap/portal/domain/dto/DomainVo.java index df99ed87..6901aeef 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/dto/DomainVo.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/dto/DomainVo.java @@ -45,7 +45,7 @@ import java.io.ByteArrayOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; -import java.util.Date; +import java.time.LocalDateTime; import java.util.Set; import javax.persistence.Inheritance; import javax.persistence.InheritanceType; @@ -66,8 +66,8 @@ public class DomainVo extends FusionVo implements Serializable, Cloneable, Compa private static final long serialVersionUID = 1L; protected Long id; - protected Date created; - protected Date modified; + protected LocalDateTime created; + protected LocalDateTime modified; protected FnUser createdId; protected FnUser modifiedId; protected Long rowNum; @@ -108,4 +108,22 @@ public class DomainVo extends FusionVo implements Serializable, Cloneable, Compa public Object clone() throws CloneNotSupportedException { return super.clone(); } + + public boolean equals(Object other) { + if (this == other) { + return true; + } else if (other == null) { + return false; + } else if (!(other instanceof DomainVo)) { + return false; + } else { + DomainVo castOther = (DomainVo)other; + return this.getId().equals(castOther.getId()) + && this.getCreated().equals(castOther.getCreated()) + && this.getCreatedId().equals(castOther.getCreatedId()) + && this.getModified().equals(castOther.getModified()) + && this.getModifiedId() == castOther.getModifiedId(); + } + } + } diff --git a/portal-BE/src/main/java/org/onap/portal/domain/dto/ecomp/EPUserApp.java b/portal-BE/src/main/java/org/onap/portal/domain/dto/ecomp/EPUserApp.java index 5eb0da96..52d42fb9 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/dto/ecomp/EPUserApp.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/dto/ecomp/EPUserApp.java @@ -60,8 +60,15 @@ public class EPUserApp extends DomainVo implements java.io.Serializable, Compara private EPApp app; @Valid private EPRole role; + private Integer priority; - + + public EPUserApp(final Long userId, final EPApp app, final EPRole role) { + this.userId = userId; + this.app = app; + this.role = role; + } + public Long getAppId() { return this.getApp().getId(); } diff --git a/portal-BE/src/main/java/org/onap/portal/domain/dto/ecomp/Widget.java b/portal-BE/src/main/java/org/onap/portal/domain/dto/ecomp/Widget.java index 86c92269..206484fa 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/dto/ecomp/Widget.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/dto/ecomp/Widget.java @@ -66,6 +66,12 @@ public class Widget extends DomainVo { this.url = ""; } + public Widget(Long appId, String name, String url) { + this.name = name; + this.url = url; + this.appId = appId; + } + public void setName(String name) { if (StringUtils.isEmpty(name)) { name = ""; diff --git a/portal-BE/src/main/java/org/onap/portal/domain/dto/ecomp/WidgetCatalogParameter.java b/portal-BE/src/main/java/org/onap/portal/domain/dto/ecomp/WidgetCatalogParameter.java index cd1b2a7b..e5e7255b 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/dto/ecomp/WidgetCatalogParameter.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/dto/ecomp/WidgetCatalogParameter.java @@ -58,6 +58,6 @@ public class WidgetCatalogParameter extends DomainVo{ private Long widgetId; private Long userId; private Long paramId; - private String user_value; + private String userValue; } diff --git a/portal-BE/src/main/java/org/onap/portal/domain/dto/ecomp/WidgetServiceHeaders.java b/portal-BE/src/main/java/org/onap/portal/domain/dto/ecomp/WidgetServiceHeaders.java index 3e665fc2..2be8c550 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/dto/ecomp/WidgetServiceHeaders.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/dto/ecomp/WidgetServiceHeaders.java @@ -41,9 +41,7 @@ package org.onap.portal.domain.dto.ecomp; import java.nio.charset.Charset; -import lombok.AllArgsConstructor; import lombok.Getter; -import lombok.NoArgsConstructor; import lombok.Setter; import org.apache.commons.codec.binary.Base64; import org.onap.portal.utils.EcompPortalUtils; diff --git a/portal-BE/src/main/java/org/onap/portal/domain/dto/fn/FnUserDto.java b/portal-BE/src/main/java/org/onap/portal/domain/dto/fn/FnUserDto.java index f8ae95d2..c107d192 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/dto/fn/FnUserDto.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/dto/fn/FnUserDto.java @@ -42,13 +42,14 @@ package org.onap.portal.domain.dto.fn; import java.time.LocalDateTime; import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; @Setter @Getter - +@Builder @NoArgsConstructor @AllArgsConstructor public class FnUserDto { @@ -70,12 +71,12 @@ public class FnUserDto { private String loginId; private String loginPwd; protected LocalDateTime lastLoginDate; - private String activeYn; + private Boolean activeYn; private Long createdId; protected LocalDateTime createdDate; private Long modifiedId; protected LocalDateTime modifiedDate; - private String isInternalYn = "n"; + private Boolean isInternalYn = false; private String addressLine1; private String addressLine2; private String city; diff --git a/portal-BE/src/main/java/org/onap/portal/domain/dto/transport/CentralV2RoleFunction.java b/portal-BE/src/main/java/org/onap/portal/domain/dto/transport/CentralV2RoleFunction.java index 17f63823..4aa79cc3 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/dto/transport/CentralV2RoleFunction.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/dto/transport/CentralV2RoleFunction.java @@ -46,11 +46,11 @@ import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; -import org.onap.portalsdk.core.domain.support.DomainVo; +import org.onap.portal.domain.dto.DomainVo; @Getter @Setter -@EqualsAndHashCode() +@EqualsAndHashCode @NoArgsConstructor @AllArgsConstructor public class CentralV2RoleFunction extends DomainVo implements Serializable, Comparable { diff --git a/portal-BE/src/main/java/org/onap/portal/domain/dto/transport/CentralV2UserApp.java b/portal-BE/src/main/java/org/onap/portal/domain/dto/transport/CentralV2UserApp.java index 8cc3a5a5..ed07408a 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/dto/transport/CentralV2UserApp.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/dto/transport/CentralV2UserApp.java @@ -60,14 +60,13 @@ public class CentralV2UserApp implements Serializable, Comparable { private CentralV2Role role; private Integer priority; - public int compareTo(Object other) { - CentralV2UserApp castOther = (CentralV2UserApp) other; - - Long c1 = (this.getUserId() == null ? 0 : this.getUserId()) + (this.priority == null ? 0 : this.priority); - Long c2 = (castOther.getUserId() == null ? 0 : castOther.getUserId()); - c2 += (castOther.getApp() == null || castOther.getApp().getId() == null ? 0 : castOther.getApp().getId()); - c2 += (castOther.priority == null ? 0 : castOther.priority); + public int compareTo(Object other){ + CentralV2UserApp castOther = (CentralV2UserApp) other; + Long c1 = (this.getUserId() == null ? 0 : this.getUserId()) + (this.priority == null ? 0 : this.priority); + Long c2 = (castOther.getUserId() == null ? 0 : castOther.getUserId()); + c2 += (castOther.getApp() == null || castOther.getApp().getId() == null ? 0 : castOther.getApp().getId()); + c2 += (castOther.priority == null ? 0 : castOther.priority); return c1.compareTo(c2); } diff --git a/portal-BE/src/main/java/org/onap/portal/domain/dto/transport/CommonWidget.java b/portal-BE/src/main/java/org/onap/portal/domain/dto/transport/CommonWidget.java index f06e517b..c9fce6d2 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/dto/transport/CommonWidget.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/dto/transport/CommonWidget.java @@ -50,7 +50,7 @@ import lombok.NoArgsConstructor; import lombok.Setter; import lombok.ToString; import org.hibernate.validator.constraints.SafeHtml; -import org.onap.portalsdk.core.domain.support.DomainVo; +import org.onap.portal.domain.dto.DomainVo; @Getter @@ -59,7 +59,7 @@ import org.onap.portalsdk.core.domain.support.DomainVo; @NoArgsConstructor @AllArgsConstructor @JsonInclude(JsonInclude.Include.NON_NULL) -public class CommonWidget extends DomainVo{ +public class CommonWidget extends DomainVo { private static final long serialVersionUID = 7897021982887364557L; diff --git a/portal-BE/src/main/java/org/onap/portal/domain/dto/transport/EpNotificationItem.java b/portal-BE/src/main/java/org/onap/portal/domain/dto/transport/EpNotificationItem.java index 2efc3dc2..a3f8af6e 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/dto/transport/EpNotificationItem.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/dto/transport/EpNotificationItem.java @@ -53,13 +53,13 @@ import lombok.NoArgsConstructor; import lombok.Setter; import lombok.ToString; import org.hibernate.validator.constraints.SafeHtml; -import org.onap.portalsdk.core.domain.support.DomainVo; +import org.onap.portal.domain.dto.DomainVo; @Getter @Setter @Builder @ToString -@EqualsAndHashCode() +@EqualsAndHashCode(callSuper = false) @NoArgsConstructor @AllArgsConstructor public class EpNotificationItem extends DomainVo { diff --git a/portal-BE/src/main/java/org/onap/portal/domain/dto/transport/EpNotificationItemVO.java b/portal-BE/src/main/java/org/onap/portal/domain/dto/transport/EpNotificationItemVO.java index 6f36dd71..3c80e167 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/dto/transport/EpNotificationItemVO.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/dto/transport/EpNotificationItemVO.java @@ -45,7 +45,7 @@ import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; -import org.onap.portalsdk.core.domain.support.DomainVo; +import org.onap.portal.domain.dto.DomainVo; @Getter @Setter diff --git a/portal-BE/src/main/java/org/onap/portal/domain/dto/transport/EpRoleNotificationItem.java b/portal-BE/src/main/java/org/onap/portal/domain/dto/transport/EpRoleNotificationItem.java index 248ad732..1f6f1619 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/dto/transport/EpRoleNotificationItem.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/dto/transport/EpRoleNotificationItem.java @@ -45,7 +45,7 @@ import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; -import org.onap.portalsdk.core.domain.support.DomainVo; +import org.onap.portal.domain.dto.DomainVo; @Getter @Setter diff --git a/portal-BE/src/main/java/org/onap/portal/domain/dto/transport/ExternalAccessPerms.java b/portal-BE/src/main/java/org/onap/portal/domain/dto/transport/ExternalAccessPerms.java index 1358233d..de176af4 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/dto/transport/ExternalAccessPerms.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/dto/transport/ExternalAccessPerms.java @@ -118,12 +118,8 @@ public class ExternalAccessPerms implements Serializable, Comparable { return false; } if (type == null) { - if (other.type != null) { - return false; - } - } else if (!type.equals(other.type)) { - return false; - } - return true; + return other.type == null; + } else + return type.equals(other.type); } } diff --git a/portal-BE/src/main/java/org/onap/portal/domain/dto/transport/FieldsValidator.java b/portal-BE/src/main/java/org/onap/portal/domain/dto/transport/FieldsValidator.java index d2bdd944..1999d236 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/dto/transport/FieldsValidator.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/dto/transport/FieldsValidator.java @@ -60,6 +60,10 @@ public class FieldsValidator { private Long errorCode; private List<FieldName> fields = new ArrayList<>(); + public void addProblematicFieldName(String fieldName){ + fields.add(new FieldName(fieldName)); + } + @Getter @Setter @ToString @@ -68,5 +72,4 @@ public class FieldsValidator { public class FieldName { public String name; } - } diff --git a/portal-BE/src/main/java/org/onap/portal/domain/dto/transport/OnboardingWidget.java b/portal-BE/src/main/java/org/onap/portal/domain/dto/transport/OnboardingWidget.java index e08d0339..de13bec5 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/dto/transport/OnboardingWidget.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/dto/transport/OnboardingWidget.java @@ -41,7 +41,6 @@ package org.onap.portal.domain.dto.transport; import java.io.Serializable; -import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; @@ -50,30 +49,43 @@ import org.hibernate.validator.constraints.SafeHtml; @Getter @Setter @NoArgsConstructor -@AllArgsConstructor public class OnboardingWidget implements Serializable { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - private Long id; - @SafeHtml - private String name; - private Long appId; - @SafeHtml - private String appName; - private Integer width; - private Integer height; - @SafeHtml - private String url; + private Long id; + @SafeHtml + private String name; + private Long appId; + @SafeHtml + private String appName; + private Integer width; + private Integer height; + @SafeHtml + private String url; - public void normalize() { - this.name = (this.name == null) ? "" : this.name.trim(); - this.appName = (this.appName == null) ? "" : this.appName.trim(); - if (this.width == null) - this.width = 0; - if (this.height == null) - this.height = 0; - this.url = (this.url == null) ? "" : this.url.trim(); - } + public OnboardingWidget(Long id, String name, Long appId, + String appName, Integer width, Integer height, + String url) { + this.id = id; + this.name = name; + this.appId = appId; + this.appName = appName; + this.width = width; + this.height = height; + this.url = url; + } + + public void normalize() { + this.name = (this.name == null) ? "" : this.name.trim(); + this.appName = (this.appName == null) ? "" : this.appName.trim(); + if (this.width == null) { + this.width = 0; + } + if (this.height == null) { + this.height = 0; + } + this.url = (this.url == null) ? "" : this.url.trim(); + } } diff --git a/portal-BE/src/main/java/org/onap/portal/domain/mapper/FnUserMapper.java b/portal-BE/src/main/java/org/onap/portal/domain/mapper/FnUserMapper.java index 757eff51..869ba81d 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/mapper/FnUserMapper.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/mapper/FnUserMapper.java @@ -41,120 +41,109 @@ package org.onap.portal.domain.mapper; import lombok.NoArgsConstructor; -import org.onap.portal.domain.builder.FnUserBuilder; -import org.onap.portal.domain.builder.FnUserDtoBuilder; import org.onap.portal.domain.db.fn.FnUser; import org.onap.portal.domain.dto.fn.FnUserDto; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @Component @NoArgsConstructor public class FnUserMapper { + public FnUserDto fnUserToFnUserDto(final FnUser fnUser){ + return FnUserDto.builder() + .userId(fnUser.getUserId()) + .orgId(fnUser.getOrgId().getOrgId()) + .managerId(fnUser.getManagerId().getUserId()) + .firstName(fnUser.getFirstName()) + .middleName(fnUser.getMiddleName()) + .lastName(fnUser.getLastName()) + .phone(fnUser.getPhone()) + .fax(fnUser.getFax()) + .cellular(fnUser.getCellular()) + .email(fnUser.getEmail()) + .addressId(fnUser.getAddressId()) + .alertMethodCd(fnUser.getAlertMethodCd().getAlertMethodCd()) + .hrid(fnUser.getHrid()) + .orgUserId(fnUser.getOrgUserId()) + .org_code(fnUser.getOrg_code()) + .loginId(fnUser.getLoginId()) + .loginPwd(fnUser.getLoginPwd()) + .lastLoginDate(fnUser.getLastLoginDate()) + .activeYn(fnUser.getActiveYn()) + .createdId(fnUser.getCreatedId().getUserId()) + .createdDate(fnUser.getCreatedDate()) + .modifiedId(fnUser.getModifiedId().getUserId()) + .modifiedDate(fnUser.getModifiedDate()) + .isInternalYn(fnUser.getIsInternalYn()) + .addressLine1(fnUser.getAddressLine1()) + .addressLine2(fnUser.getAddressLine2()) + .city(fnUser.getCity()) + .stateCd(fnUser.getStateCd()) + .zipCode(fnUser.getZipCode()) + .countryCd(fnUser.getCountryCd()) + .locationClli(fnUser.getLocationClli()) + .orgManagerUserId(fnUser.getOrgManagerUserId()) + .company(fnUser.getCompany()) + .departmentName(fnUser.getDepartmentName()) + .jobTitle(fnUser.getJobTitle()) + .timezone(fnUser.getTimezone().getTimezoneId()) + .department(fnUser.getDepartment()) + .businessUnit(fnUser.getBusinessUnit()) + .businessUnitName(fnUser.getBusinessUnitName()) + .cost_center(fnUser.getCost_center()) + .finLocCode(fnUser.getFinLocCode()) + .siloStatus(fnUser.getSiloStatus()) + .languageId(fnUser.getLanguageId().getLanguageId()) + .guest(fnUser.getGuest()) + .build(); - private FnUserDtoBuilder fnUserDtoBuilder; - private FnUserBuilder fnUserBuilder; - - @Autowired - public FnUserMapper(final FnUserDtoBuilder fnUserDtoBuilder, - FnUserBuilder fnUserBuilder) { - this.fnUserDtoBuilder = fnUserDtoBuilder; - this.fnUserBuilder = fnUserBuilder; - } - - public FnUserDto fnUserToFnUserDto(final FnUser fnUser){ - return fnUserDtoBuilder - .setUserId(fnUser.getUserId()) - .setOrgId(fnUser.getOrgId().getOrgId()) - .setManagerId(fnUser.getManagerId().getUserId()) - .setFirstName(fnUser.getFirstName()) - .setMiddleName(fnUser.getMiddleName()) - .setLastName(fnUser.getLastName()) - .setPhone(fnUser.getPhone()) - .setFax(fnUser.getFax()) - .setCellular(fnUser.getCellular()) - .setEmail(fnUser.getEmail()) - .setAddressId(fnUser.getAddressId()) - .setAlertMethodCd(fnUser.getAlertMethodCd().getAlertMethodCd()) - .setHrid(fnUser.getHrid()) - .setOrgUserId(fnUser.getOrgUserId()) - .setOrg_code(fnUser.getOrg_code()) - .setLoginId(fnUser.getLoginId()) - .setLoginPwd(fnUser.getLoginPwd()) - .setLastLoginDate(fnUser.getLastLoginDate()) - .setActiveYn(fnUser.getActiveYn()) - .setCreatedId(fnUser.getCreatedId().getUserId()) - .setCreatedDate(fnUser.getCreatedDate()) - .setModifiedId(fnUser.getModifiedId().getUserId()) - .setModifiedDate(fnUser.getModifiedDate()) - .setIsInternalYn(fnUser.getIsInternalYn()) - .setAddressLine1(fnUser.getAddressLine1()) - .setAddressLine2(fnUser.getAddressLine2()) - .setCity(fnUser.getCity()) - .setStateCd(fnUser.getStateCd()) - .setZipCode(fnUser.getZipCode()) - .setCountryCd(fnUser.getCountryCd()) - .setLocationClli(fnUser.getLocationClli()) - .setOrgManagerUserId(fnUser.getOrgManagerUserId()) - .setCompany(fnUser.getCompany()) - .setDepartmentName(fnUser.getDepartmentName()) - .setJobTitle(fnUser.getJobTitle()) - .setTimezone(fnUser.getTimezone().getTimezoneId()) - .setDepartment(fnUser.getDepartment()) - .setBusinessUnit(fnUser.getBusinessUnit()) - .setBusinessUnitName(fnUser.getBusinessUnitName()) - .setCost_center(fnUser.getCost_center()) - .setFinLocCode(fnUser.getFinLocCode()) - .setSiloStatus(fnUser.getSiloStatus()) - .setLanguageId(fnUser.getLanguageId().getLanguageId()) - .setGuest(fnUser.isGuest()).createFnUserDto(); } public FnUser fnUserToFnUser(final FnUser fnUser){ - return fnUserBuilder - .setUserId(fnUser.getUserId()) - .setOrgId(fnUser.getOrgId()) - .setManagerId(fnUser.getManagerId()) - .setFirstName(fnUser.getFirstName()) - .setMiddleName(fnUser.getMiddleName()) - .setLastName(fnUser.getLastName()) - .setPhone(fnUser.getPhone()) - .setFax(fnUser.getFax()) - .setCellular(fnUser.getCellular()) - .setEmail(fnUser.getEmail()) - .setAddressId(fnUser.getAddressId()) - .setAlertMethodCd(fnUser.getAlertMethodCd()) - .setHrid(fnUser.getHrid()) - .setOrgUserId(fnUser.getOrgUserId()) - .setOrg_code(fnUser.getOrg_code()) - .setLoginId(fnUser.getLoginId()) - .setLoginPwd(fnUser.getLoginPwd()) - .setLastLoginDate(fnUser.getLastLoginDate()) - .setActiveYn(fnUser.getActiveYn()) - .setCreatedId(fnUser.getCreatedId()) - .setCreatedDate(fnUser.getCreatedDate()) - .setModifiedId(fnUser.getModifiedId()) - .setModifiedDate(fnUser.getModifiedDate()) - .setIsInternalYn(fnUser.getIsInternalYn()) - .setAddressLine1(fnUser.getAddressLine1()) - .setAddressLine2(fnUser.getAddressLine2()) - .setCity(fnUser.getCity()) - .setStateCd(fnUser.getStateCd()) - .setZipCode(fnUser.getZipCode()) - .setCountryCd(fnUser.getCountryCd()) - .setLocationClli(fnUser.getLocationClli()) - .setOrgManagerUserId(fnUser.getOrgManagerUserId()) - .setCompany(fnUser.getCompany()) - .setDepartmentName(fnUser.getDepartmentName()) - .setJobTitle(fnUser.getJobTitle()) - .setTimezone(fnUser.getTimezone()) - .setDepartment(fnUser.getDepartment()) - .setBusinessUnit(fnUser.getBusinessUnit()) - .setBusinessUnitName(fnUser.getBusinessUnitName()) - .setCost_center(fnUser.getCost_center()) - .setFinLocCode(fnUser.getFinLocCode()) - .setSiloStatus(fnUser.getSiloStatus()) - .setLanguageId(fnUser.getLanguageId()) - .setGuest(fnUser.isGuest()).createFnUser(); + return FnUser.builder() + .userId(fnUser.getUserId()) + .orgId(fnUser.getOrgId()) + .managerId(fnUser.getManagerId()) + .firstName(fnUser.getFirstName()) + .middleName(fnUser.getMiddleName()) + .lastName(fnUser.getLastName()) + .phone(fnUser.getPhone()) + .fax(fnUser.getFax()) + .cellular(fnUser.getCellular()) + .email(fnUser.getEmail()) + .addressId(fnUser.getAddressId()) + .alertMethodCd(fnUser.getAlertMethodCd()) + .hrid(fnUser.getHrid()) + .orgUserId(fnUser.getOrgUserId()) + .org_code(fnUser.getOrg_code()) + .loginId(fnUser.getLoginId()) + .loginPwd(fnUser.getLoginPwd()) + .lastLoginDate(fnUser.getLastLoginDate()) + .activeYn(fnUser.getActiveYn()) + .createdId(fnUser.getCreatedId()) + .createdDate(fnUser.getCreatedDate()) + .modifiedId(fnUser.getModifiedId()) + .modifiedDate(fnUser.getModifiedDate()) + .isInternalYn(fnUser.getIsInternalYn()) + .addressLine1(fnUser.getAddressLine1()) + .addressLine2(fnUser.getAddressLine2()) + .city(fnUser.getCity()) + .stateCd(fnUser.getStateCd()) + .zipCode(fnUser.getZipCode()) + .countryCd(fnUser.getCountryCd()) + .locationClli(fnUser.getLocationClli()) + .orgManagerUserId(fnUser.getOrgManagerUserId()) + .company(fnUser.getCompany()) + .departmentName(fnUser.getDepartmentName()) + .jobTitle(fnUser.getJobTitle()) + .timezone(fnUser.getTimezone()) + .department(fnUser.getDepartment()) + .businessUnit(fnUser.getBusinessUnit()) + .businessUnitName(fnUser.getBusinessUnitName()) + .cost_center(fnUser.getCost_center()) + .finLocCode(fnUser.getFinLocCode()) + .siloStatus(fnUser.getSiloStatus()) + .languageId(fnUser.getLanguageId()) + .guest(fnUser.getGuest()) + .build(); } } diff --git a/portal-BE/src/main/java/org/onap/portal/logging/aop/EPAuditLog.java b/portal-BE/src/main/java/org/onap/portal/logging/aop/EPAuditLog.java new file mode 100644 index 00000000..43306c44 --- /dev/null +++ b/portal-BE/src/main/java/org/onap/portal/logging/aop/EPAuditLog.java @@ -0,0 +1,52 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Modifications Copyright (c) 2019 Samsung + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * + */ + +package org.onap.portal.logging.aop; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target({ElementType.METHOD, ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +public @interface EPAuditLog { + String value() default ""; +} diff --git a/portal-BE/src/main/java/org/onap/portal/logging/aop/EPEELFLoggerAdvice.java b/portal-BE/src/main/java/org/onap/portal/logging/aop/EPEELFLoggerAdvice.java new file mode 100644 index 00000000..fa8ab5d5 --- /dev/null +++ b/portal-BE/src/main/java/org/onap/portal/logging/aop/EPEELFLoggerAdvice.java @@ -0,0 +1,406 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Modifications Copyright (c) 2019 Samsung + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * + */ + +package org.onap.portal.logging.aop; + +import com.att.eelf.configuration.Configuration; +import java.net.InetAddress; +import java.security.Principal; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.UUID; +import javax.servlet.http.HttpServletRequest; +import org.onap.portal.domain.db.fn.FnApp; +import org.onap.portal.domain.db.fn.FnUser; +import org.onap.portal.service.fn.FnUserService; +import org.onap.portal.service.fn.old.AppsCacheService; +import org.onap.portal.utils.EPCommonSystemProperties; +import org.onap.portal.utils.EcompPortalUtils; +import org.onap.portalsdk.core.exception.SessionExpiredException; +import org.onap.portalsdk.core.logging.format.AlarmSeverityEnum; +import org.onap.portalsdk.core.logging.format.AuditLogFormatter; +import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.onap.portalsdk.core.util.SystemProperties; +import org.onap.portalsdk.core.util.SystemProperties.SecurityEventTypeEnum; +import org.onap.portalsdk.core.web.support.UserUtils; +import org.slf4j.MDC; +import org.springframework.beans.factory.annotation.Autowired; + +@org.springframework.context.annotation.Configuration +public class EPEELFLoggerAdvice { + + private EELFLoggerDelegate adviceLogger = EELFLoggerDelegate.getLogger(EPEELFLoggerAdvice.class); + + private final AppsCacheService appCacheService; + private final FnUserService fnUserService; + + @Autowired + public EPEELFLoggerAdvice(AppsCacheService appCacheService, FnUserService fnUserService) { + this.appCacheService = appCacheService; + this.fnUserService = fnUserService; + } + + public static String getCurrentDateTimeUTC() { + SimpleDateFormat ecompLogDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX"); + return ecompLogDateFormat.format(new Date()); + } + + public void loadServletRequestBasedDefaults(Principal principal, HttpServletRequest req, SecurityEventTypeEnum securityEventType) { + try { + setHttpRequestBasedDefaultsIntoGlobalLoggingContext(principal, req, securityEventType, req.getServletPath()); + } catch (Exception e) { + adviceLogger.error(EELFLoggerDelegate.errorLogger, "loadServletRequestBasedDefaults failed", e); + } + } + + public Object[] before(Principal principal, SecurityEventTypeEnum securityEventType, Object[] args, Object[] passOnArgs) { + String className = ""; + if (passOnArgs.length > 0 && passOnArgs[0] != null) + className = passOnArgs[0].toString(); + String methodName = EPCommonSystemProperties.ECOMP_PORTAL_BE; + if (passOnArgs.length > 1 && passOnArgs[1] != null) + methodName = passOnArgs[1].toString(); + + MDC.put(className + methodName + EPCommonSystemProperties.METRICSLOG_BEGIN_TIMESTAMP, getCurrentDateTimeUTC()); + MDC.put(EPCommonSystemProperties.TARGET_ENTITY, EPCommonSystemProperties.ECOMP_PORTAL_BE); + MDC.put(EPCommonSystemProperties.TARGET_SERVICE_NAME, methodName); + if (MDC.get(Configuration.MDC_KEY_REQUEST_ID) == null||MDC.get(Configuration.MDC_KEY_REQUEST_ID).isEmpty()){ + String requestId = UUID.randomUUID().toString(); + MDC.put(Configuration.MDC_KEY_REQUEST_ID, requestId); + } + MDC.put(EPCommonSystemProperties.PARTNER_NAME, "Unknown"); + MDC.put(Configuration.MDC_SERVICE_NAME, EPCommonSystemProperties.ECOMP_PORTAL_BE); + + if (securityEventType != null) { + MDC.put(className + methodName + EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP, + getCurrentDateTimeUTC()); + HttpServletRequest req; + if (args.length > 0 && args[0] != null && args[0] instanceof HttpServletRequest) { + req = (HttpServletRequest) args[0]; + this.setHttpRequestBasedDefaultsIntoGlobalLoggingContext(principal, req, securityEventType, methodName); + } + } + + EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(className); + logger.debug(EELFLoggerDelegate.debugLogger, "EPEELFLoggerAdvice#before: entering {}", methodName); + return new Object[] { "" }; + } + + public void after(Principal principal, SecurityEventTypeEnum securityEventType, String statusCode, String responseCode, Object[] args, + Object[] returnArgs, Object[] passOnArgs) { + String className = ""; + if (passOnArgs.length > 0 && passOnArgs[0] != null) + className = passOnArgs[0].toString(); + String methodName = EPCommonSystemProperties.ECOMP_PORTAL_BE; + if (passOnArgs.length > 1 && passOnArgs[1] != null) + methodName = passOnArgs[1].toString(); + + if (MDC.get(EPCommonSystemProperties.TARGET_SERVICE_NAME) == null + || "".equals(MDC.get(EPCommonSystemProperties.TARGET_SERVICE_NAME))) + MDC.put(EPCommonSystemProperties.TARGET_SERVICE_NAME, methodName); + + if (MDC.get(EPCommonSystemProperties.TARGET_ENTITY) == null + || "".equals(MDC.get(EPCommonSystemProperties.TARGET_ENTITY))) + MDC.put(EPCommonSystemProperties.TARGET_ENTITY, EPCommonSystemProperties.ECOMP_PORTAL_BE); + + if (MDC.get(Configuration.MDC_KEY_REQUEST_ID) == null||MDC.get(Configuration.MDC_KEY_REQUEST_ID).isEmpty()){ + String requestId = UUID.randomUUID().toString(); + MDC.put(Configuration.MDC_KEY_REQUEST_ID, requestId); + } + + if (MDC.get(EPCommonSystemProperties.PARTNER_NAME) == null|| MDC.get(EPCommonSystemProperties.PARTNER_NAME).isEmpty()){ + MDC.put(EPCommonSystemProperties.PARTNER_NAME, "Unknown"); + } + + MDC.put(Configuration.MDC_SERVICE_NAME, EPCommonSystemProperties.ECOMP_PORTAL_BE); + + + MDC.put(EPCommonSystemProperties.METRICSLOG_BEGIN_TIMESTAMP, + MDC.get(className + methodName + EPCommonSystemProperties.METRICSLOG_BEGIN_TIMESTAMP)); + MDC.put(EPCommonSystemProperties.METRICSLOG_END_TIMESTAMP, getCurrentDateTimeUTC()); + this.calculateDateTimeDifference(MDC.get(EPCommonSystemProperties.METRICSLOG_BEGIN_TIMESTAMP), + MDC.get(EPCommonSystemProperties.METRICSLOG_END_TIMESTAMP)); + + if (securityEventType != null && args.length > 0 && args[0] != null && args[0] instanceof HttpServletRequest + && securityEventType == SecurityEventTypeEnum.INCOMING_REST_MESSAGE + && (MDC.get(EPCommonSystemProperties.FULL_URL) == null + || MDC.get(EPCommonSystemProperties.FULL_URL).isEmpty())) { + HttpServletRequest req = (HttpServletRequest) args[0]; + this.setHttpRequestBasedDefaultsIntoGlobalLoggingContext(principal, req, securityEventType, methodName); + } + + String externalAPIResponseCode = MDC.get(EPCommonSystemProperties.EXTERNAL_API_RESPONSE_CODE); + if (externalAPIResponseCode == null || "".equals(externalAPIResponseCode) + || externalAPIResponseCode.trim().equalsIgnoreCase("200")) { + MDC.put(EPCommonSystemProperties.RESPONSE_CODE, responseCode); + MDC.put(EPCommonSystemProperties.STATUS_CODE, statusCode); + } else { + MDC.put(EPCommonSystemProperties.RESPONSE_CODE, externalAPIResponseCode); + MDC.put(EPCommonSystemProperties.STATUS_CODE, "ERROR"); + } + + EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(className); + logger.debug(EELFLoggerDelegate.debugLogger, "EPEELFLoggerAdvice#after: finished {}", methodName); + + logger.info(EELFLoggerDelegate.metricsLogger, methodName + " operation is completed."); + + if (securityEventType != null) { + MDC.put(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP, + MDC.get(className + methodName + EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP)); + MDC.put(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP, getCurrentDateTimeUTC()); + this.calculateDateTimeDifference(MDC.get(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP), + MDC.get(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP)); + + this.logSecurityMessage(logger, securityEventType, methodName); + + if (securityEventType != SecurityEventTypeEnum.OUTGOING_REST_MESSAGE + && securityEventType != SecurityEventTypeEnum.LDAP_PHONEBOOK_USER_SEARCH) { + MDC.remove(Configuration.MDC_KEY_REQUEST_ID); + MDC.remove(EPCommonSystemProperties.PARTNER_NAME); + MDC.remove(Configuration.MDC_SERVICE_NAME); + MDC.remove(EPCommonSystemProperties.MDC_LOGIN_ID); + MDC.remove(EPCommonSystemProperties.EXTERNAL_API_RESPONSE_CODE); + }else{ + MDC.remove(Configuration.MDC_KEY_REQUEST_ID); + MDC.remove(EPCommonSystemProperties.PARTNER_NAME); + MDC.remove(Configuration.MDC_SERVICE_NAME); + } + + + MDC.remove(EPCommonSystemProperties.FULL_URL); + MDC.remove(EPCommonSystemProperties.PROTOCOL); + MDC.remove(EPCommonSystemProperties.STATUS_CODE); + MDC.remove(className + methodName + EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP); + MDC.remove(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP); + MDC.remove(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP); + MDC.remove(EPCommonSystemProperties.RESPONSE_CODE); + } + MDC.remove(className + methodName + EPCommonSystemProperties.METRICSLOG_BEGIN_TIMESTAMP); + MDC.remove(EPCommonSystemProperties.METRICSLOG_BEGIN_TIMESTAMP); + MDC.remove(EPCommonSystemProperties.METRICSLOG_END_TIMESTAMP); + MDC.remove(EPCommonSystemProperties.MDC_TIMER); + MDC.remove(EPCommonSystemProperties.TARGET_ENTITY); + MDC.remove(EPCommonSystemProperties.TARGET_SERVICE_NAME); + + } + + private void logSecurityMessage(EELFLoggerDelegate logger, SecurityEventTypeEnum securityEventType, + String restMethod) { + StringBuilder additionalInfoAppender = new StringBuilder(); + String auditMessage; + + if (securityEventType == SecurityEventTypeEnum.OUTGOING_REST_MESSAGE) { + additionalInfoAppender.append(String.format("%s '%s' request was initiated.", restMethod, + MDC.get(EPCommonSystemProperties.TARGET_SERVICE_NAME))); + } else if (securityEventType == SecurityEventTypeEnum.LDAP_PHONEBOOK_USER_SEARCH) { + additionalInfoAppender.append("LDAP Phonebook search operation is performed."); + } else { + additionalInfoAppender.append(String.format("%s request was received.", restMethod)); + + if (securityEventType == SecurityEventTypeEnum.FE_LOGIN_ATTEMPT) { + String loginId; + String additionalMessage = " Successfully authenticated."; + loginId = MDC.get(EPCommonSystemProperties.MDC_LOGIN_ID); + if (loginId == null || "".equals(loginId) || EPCommonSystemProperties.UNKNOWN.equals(loginId)) { + additionalMessage = " No cookies are found."; + } + additionalInfoAppender.append(additionalMessage); + } else if (securityEventType == SecurityEventTypeEnum.FE_LOGOUT) { + additionalInfoAppender.append(" User has been successfully logged out."); + } + } + + String fullURL = MDC.get(EPCommonSystemProperties.FULL_URL); + if (fullURL != null && !"".equals(fullURL)) { + additionalInfoAppender.append(" Request-URL:").append(MDC.get(EPCommonSystemProperties.FULL_URL)); + } + + auditMessage = AuditLogFormatter.getInstance().createMessage(MDC.get(EPCommonSystemProperties.PROTOCOL), + securityEventType.name(), MDC.get(EPCommonSystemProperties.MDC_LOGIN_ID), + additionalInfoAppender.toString()); + + logger.info(EELFLoggerDelegate.auditLogger, auditMessage); + } + + private void setHttpRequestBasedDefaultsIntoGlobalLoggingContext(Principal principal, HttpServletRequest req, + SecurityEventTypeEnum securityEventType, String restMethod) { + + if (req != null) { + if (securityEventType != SecurityEventTypeEnum.OUTGOING_REST_MESSAGE + && securityEventType != SecurityEventTypeEnum.LDAP_PHONEBOOK_USER_SEARCH + && securityEventType != SecurityEventTypeEnum.INCOMING_UEB_MESSAGE) { + loadRequestId(req); + + loadPartnerName(req); + + loadLoginId(principal, req); + + loadUrlProtocol(req); + + loadServicePath(req, restMethod); + + loadClientAddress(req); + + } else if (securityEventType == SecurityEventTypeEnum.LDAP_PHONEBOOK_USER_SEARCH) { + MDC.put(EPCommonSystemProperties.TARGET_ENTITY, "Phonebook"); + MDC.put(EPCommonSystemProperties.TARGET_SERVICE_NAME, "search"); + } + } else { + MDC.put(Configuration.MDC_SERVICE_NAME, restMethod); + MDC.put(EPCommonSystemProperties.PARTNER_NAME, EPCommonSystemProperties.ECOMP_PORTAL_FE); + } + + MDC.put(Configuration.MDC_SERVICE_INSTANCE_ID, ""); + MDC.put(Configuration.MDC_ALERT_SEVERITY, AlarmSeverityEnum.INFORMATIONAL.severity()); + try { + MDC.put(Configuration.MDC_SERVER_FQDN, InetAddress.getLocalHost().getCanonicalHostName()); + MDC.put(Configuration.MDC_SERVER_IP_ADDRESS, InetAddress.getLocalHost().getHostAddress()); + MDC.put(Configuration.MDC_INSTANCE_UUID, SystemProperties.getProperty(SystemProperties.INSTANCE_UUID)); + } catch (Exception e) { + adviceLogger.error(EELFLoggerDelegate.errorLogger, + "setHttpRequestBasedDefaultsIntoGlobalLoggingContext failed", e); + } + } + + private void loadClientAddress(HttpServletRequest req) { + String clientIPAddress; + clientIPAddress = req.getHeader("X-FORWARDED-FOR"); + if (clientIPAddress == null) { + clientIPAddress = req.getRemoteAddr(); + } + MDC.put(EPCommonSystemProperties.CLIENT_IP_ADDRESS, clientIPAddress); + } + + private void loadServicePath(HttpServletRequest req, String restMethod) { + MDC.put(Configuration.MDC_SERVICE_NAME, restMethod); + String restPath = req.getServletPath(); + if (restPath != null && restPath.trim().length()>0) { + + MDC.put(Configuration.MDC_SERVICE_NAME, restPath); + } + } + + private void loadUrlProtocol(HttpServletRequest req) { + String restURL; + MDC.put(EPCommonSystemProperties.FULL_URL, EPCommonSystemProperties.UNKNOWN); + MDC.put(EPCommonSystemProperties.PROTOCOL, EPCommonSystemProperties.HTTP); + restURL = UserUtils.getFullURL(req); + if (restURL.trim().length() > 0) { + MDC.put(EPCommonSystemProperties.FULL_URL, restURL); + if (restURL.toLowerCase().contains("https")) { + MDC.put(EPCommonSystemProperties.PROTOCOL, EPCommonSystemProperties.HTTPS); + } + } + } + + private void loadRequestId(HttpServletRequest req) { + String requestId = UserUtils.getRequestId(req); + if (requestId == null||requestId.trim().length()==0) { + requestId = UUID.randomUUID().toString(); + } + MDC.put(Configuration.MDC_KEY_REQUEST_ID, requestId); + } + + private void loadLoginId(Principal principal, HttpServletRequest req) { + String loginId = "NoUser"; + try { + FnUser user = fnUserService.loadUserByUsername(principal.getName()); + loginId = (user != null ? user.getOrgUserId(): loginId); + } catch (SessionExpiredException se) { + adviceLogger.debug(EELFLoggerDelegate.debugLogger, + "setHttpRequestBasedDefaultsIntoGlobalLoggingContext: No user found in session"); + } + + final String nameHeader = req.getHeader(EPCommonSystemProperties.USERNAME); + if (nameHeader != null) { + loginId = nameHeader; + } + + final String authHeader = req.getHeader(EPCommonSystemProperties.AUTHORIZATION); + if (authHeader != null) { + String[] accountNamePassword = EcompPortalUtils.getUserNamePassword(authHeader); + if (accountNamePassword != null && accountNamePassword.length == 2) { + loginId = accountNamePassword[0]; + } + } + + MDC.put(EPCommonSystemProperties.MDC_LOGIN_ID, loginId ); + } + + private void loadPartnerName(HttpServletRequest req) { + + + // Load user agent into MDC context, if available. + String accessingClient = req.getHeader(SystemProperties.USERAGENT_NAME); + accessingClient = (accessingClient == null || accessingClient.trim().length()==0)?"Unknown":accessingClient; + if (accessingClient != null && accessingClient.trim().length()==0 && (accessingClient.contains("Mozilla") + || accessingClient.contains("Chrome") || accessingClient.contains("Safari"))) { + accessingClient = EPCommonSystemProperties.ECOMP_PORTAL_FE; + } + MDC.put(EPCommonSystemProperties.PARTNER_NAME, accessingClient); + + String uebVal = req.getHeader(EPCommonSystemProperties.UEB_KEY); + if(uebVal != null) { + FnApp appRecord = appCacheService.getAppFromUeb(uebVal); + MDC.put(EPCommonSystemProperties.PARTNER_NAME, appRecord.getAppName()); + } + + + } + + private void calculateDateTimeDifference(String beginDateTime, String endDateTime) { + if (beginDateTime != null && endDateTime != null && !beginDateTime.isEmpty()&&!endDateTime.isEmpty()) { + try { + SimpleDateFormat ecompLogDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX"); + Date beginDate = ecompLogDateFormat.parse(beginDateTime); + Date endDate = ecompLogDateFormat.parse(endDateTime); + String timeDifference = String.format("%d", endDate.getTime() - beginDate.getTime()); + MDC.put(SystemProperties.MDC_TIMER, timeDifference); + } catch (Exception e) { + adviceLogger.error(EELFLoggerDelegate.errorLogger, "calculateDateTimeDifference failed", e); + } + } + } + + public String getInternalResponseCode() { + return MDC.get(EPCommonSystemProperties.RESPONSE_CODE); + } + +} diff --git a/portal-BE/src/main/java/org/onap/portal/logging/aop/EPMetricsLog.java b/portal-BE/src/main/java/org/onap/portal/logging/aop/EPMetricsLog.java new file mode 100644 index 00000000..4f290d9f --- /dev/null +++ b/portal-BE/src/main/java/org/onap/portal/logging/aop/EPMetricsLog.java @@ -0,0 +1,52 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Modifications Copyright (c) 2019 Samsung + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * + */ + +package org.onap.portal.logging.aop; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target({ElementType.METHOD, ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +public @interface EPMetricsLog { + String value() default ""; +} diff --git a/portal-BE/src/main/java/org/onap/portal/logging/format/EPAppMessagesEnum.java b/portal-BE/src/main/java/org/onap/portal/logging/format/EPAppMessagesEnum.java index d7fbe052..d4bd55f1 100644 --- a/portal-BE/src/main/java/org/onap/portal/logging/format/EPAppMessagesEnum.java +++ b/portal-BE/src/main/java/org/onap/portal/logging/format/EPAppMessagesEnum.java @@ -46,10 +46,8 @@ import org.onap.portalsdk.core.logging.format.ErrorSeverityEnum; import org.onap.portalsdk.core.logging.format.ErrorTypeEnum; /** - * - * Add ONAP Portal Specific Error Code Enums here, for generic - * ones (ones you think are useful not only Portal but also SDK), add it - * to the enum class AppMessagesEnum defined in SDK. + * Add ONAP Portal Specific Error Code Enums here, for generic ones (ones you think are useful not only Portal but also + * SDK), add it to the enum class AppMessagesEnum defined in SDK. */ public enum EPAppMessagesEnum implements EELFResolvableErrorEnum { /* @@ -81,227 +79,303 @@ public enum EPAppMessagesEnum implements EELFResolvableErrorEnum { 900-999 Unknown Errors - Unexpected exception */ - - BeUebAuthenticationError(EPErrorCodesEnum.BEUEBAUTHENTICATIONERROR_ONE_ARGUMENT, ErrorTypeEnum.AUTHENTICATION_PROBLEM, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, - "ERR100E", "An Authentication failure occurred during access to UEB server", "Details: {0}.", "Please check UEB server list and keys configured under Portal.Properties file."), - - BeRestApiAuthenticationError(EPErrorCodesEnum.BERESTAPIAUTHENTICATIONERROR, ErrorTypeEnum.AUTHENTICATION_PROBLEM, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, - "ERR101E", "Rejected an incoming REST API request due to invalid credentials", "", "Please check application credentials defined in Database or properties files."), - - InternalAuthenticationInfo(EPErrorCodesEnum.INTERNALAUTHENTICATIONINFO_ONE_ARGUMENT, ErrorTypeEnum.AUTHENTICATION_PROBLEM, AlarmSeverityEnum.INFORMATIONAL, ErrorSeverityEnum.INFO, - "ERR199I", "Internal authentication problem", "Details: {0}.", "Please check the logs for more information."), - - InternalAuthenticationWarning(EPErrorCodesEnum.INTERNALAUTHENTICATIONWARNING_ONE_ARGUMENT, ErrorTypeEnum.AUTHENTICATION_PROBLEM, AlarmSeverityEnum.MINOR, ErrorSeverityEnum.WARN, - "ERR199W", "Internal authentication problem", "Details: {0}.", "Please check the logs for more information."), - - InternalAuthenticationError(EPErrorCodesEnum.INTERNALAUTHENTICATIONERROR_ONE_ARGUMENT, ErrorTypeEnum.AUTHENTICATION_PROBLEM, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, - "ERR199E", "Internal authentication problem", "Details: {0}.", "Please check the logs for more information."), - - InternalAuthenticationFatal(EPErrorCodesEnum.INTERNALAUTHENTICATIONFATAL_ONE_ARGUMENT, ErrorTypeEnum.AUTHENTICATION_PROBLEM, AlarmSeverityEnum.CRITICAL, ErrorSeverityEnum.FATAL, - "ERR199F", "Internal authentication problem", "Details: {0}.", "Please check the logs for more information."), - - BeHealthCheckError(EPErrorCodesEnum.BeHEALTHCHECKERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.CRITICAL, ErrorSeverityEnum.ERROR, - "ERR200E", "ECOMP-PORTAL Back-end probably lost connectivity to either one of the following components: MySQL DB, UEB Cluster", "", "Please check the logs for more information."), - - BeHealthCheckMySqlError(EPErrorCodesEnum.BEHEALTHCHECKMYSQLERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.CRITICAL, ErrorSeverityEnum.ERROR, - "ERR201E", "ECOMP-PORTAL Back-end probably lost connectivity to MySQL DB", "", "Check connectivity to MYSQL is configured correctly under system.properties file."), - - BeHealthCheckUebClusterError(EPErrorCodesEnum.BEHEALTHCHECKUEBCLUSTERERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.CRITICAL, ErrorSeverityEnum.ERROR, - "ERR203E", "ECOMP-PORTAL Back-end probably lost connectivity to UEB Cluster", "", "Check connectivity to UEB cluster which is configured under portal.properties file."), - - FeHealthCheckError(EPErrorCodesEnum.FEHEALTHCHECKERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.CRITICAL, ErrorSeverityEnum.ERROR, - "ERR204E", "Unable to connect to a valid ECOMP-PORTAL Back-end Server.", "", "Please check connectivity from this FE instance towards BE or BE Load Balancer."), - - BeHealthCheckRecovery(EPErrorCodesEnum.BEHEALTHCHECKRECOVERY, ErrorTypeEnum.RECOVERY, AlarmSeverityEnum.INFORMATIONAL, ErrorSeverityEnum.INFO, - "ERR205I", "ECOMP-PORTAL Back-end Recovery to either one of the following components: MySQL DB, UEB Cluster", "", "Please check logs for more specific information about the problem."), - - BeHealthCheckMySqlRecovery(EPErrorCodesEnum.BEHEALTHCHECKMYSQLRECOVERY, ErrorTypeEnum.RECOVERY, AlarmSeverityEnum.INFORMATIONAL, ErrorSeverityEnum.INFO, - "ERR206I", "ECOMP-PORTAL Back-end connection recovery to MySQL DB", "", "Please check logs for more specific information about the problem."), - - BeHealthCheckUebClusterRecovery(EPErrorCodesEnum.BEHEALTHCHECKUEBCLUSTERRECOVERY, ErrorTypeEnum.RECOVERY, AlarmSeverityEnum.INFORMATIONAL, ErrorSeverityEnum.INFO, - "ERR208I", "ECOMP-PORTAL Back-end connection recovery to UEB Cluster", "", "Please check logs for more specific information about the problem."), - - FeHealthCheckRecovery(EPErrorCodesEnum.FEHEALTHCHECKRECOVERY, ErrorTypeEnum.RECOVERY, AlarmSeverityEnum.INFORMATIONAL, ErrorSeverityEnum.INFO, - "ERR209I", "Connectivity to ECOMP-PORTAL Front-end Server is recovered", "", "Please check logs for more specific information about the problem."), - - BeUebConnectionError(EPErrorCodesEnum.BEUEBCONNECTIONERROR_ONE_ARGUMENT, ErrorTypeEnum.CONNECTION_PROBLEM, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, - "ERR210E", "ECOMP-PORTAL Back-end probably lost connectivity to UEB Cluster", "Details: {0}.", "Please check UEB server list and keys configured under Portal.Properties file."), - - BeUebUnkownHostError(EPErrorCodesEnum.BEUEBUNKOWNHOSTERROR_ONE_ARGUMENT, ErrorTypeEnum.CONNECTION_PROBLEM, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, - "ERR211E", "ECOMP-PORTAL Back-end probably lost connectivity to UEB Cluster", "Cannot reach host: {0}.", "Please check UEB server list and keys configured under Portal.Properties file."), - - BeUebRegisterOnboardingAppError(EPErrorCodesEnum.BEUEBREGISTERONBOARDINGAPPERROR, ErrorTypeEnum.CONNECTION_PROBLEM, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, - "ERR212E", "Failed to register the On-boarding application with UEB Communication server", "Details: {0}.", "Please check UEB server list and keys configured under Portal.Properties file."), - - BeHttpConnectionError(EPErrorCodesEnum.BEHTTPCONNECTIONERROR_ONE_ARGUMENT, ErrorTypeEnum.CONNECTION_PROBLEM, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, - "ERR213E", "It could be that communication to an external application might resulted an exception or failed to reach the external application", - "Details: {0}.", "Please check logs for more information."), - MusicHealthCheckZookeeperError(EPErrorCodesEnum.MUSICHEALTHCHECKZOOKEEPERERROR_ONE_ARGUMENT, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, - "ERR214E", "Connectivity to Music Cluster -zookeeper server", "Details: {0}.", "Please check zookeeper server list and check the logs for more information"), - - MusicHealthCheckCassandraError(EPErrorCodesEnum.MUSICHEALTHCHECKCASSANDRAERROR_ONE_ARGUMENT, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, - "ERR215E", "Connectivity to Music Cluster -Cassandra server", "Details: {0}.", "Please check Cassandra server list and check the logs for more information"), - - InternalConnectionInfo(EPErrorCodesEnum.INTERNALCONNECTIONINFO_ONE_ARGUMENT, ErrorTypeEnum.CONNECTION_PROBLEM, AlarmSeverityEnum.INFORMATIONAL, ErrorSeverityEnum.INFO, - "ERR299I", "Internal Connection problem", "Details: {0}.", "Please check logs for more information."), - - InternalConnectionWarning(EPErrorCodesEnum.INTERNALCONNECTIONWARNING_ONE_ARGUMENT, ErrorTypeEnum.CONNECTION_PROBLEM, AlarmSeverityEnum.MINOR, ErrorSeverityEnum.WARN, - "ERR299W", "Internal Connection problem", "Details: {0}.", "Please check logs for more information."), - - InternalConnectionError(EPErrorCodesEnum.INTERNALCONNECTIONERROR_ONE_ARGUMENT, ErrorTypeEnum.CONNECTION_PROBLEM, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, - "ERR299E", "Internal Connection problem", "Details: {0}.", "Please check logs for more information."), - - InternalConnectionFatal(EPErrorCodesEnum.INTERNALCONNECTIONFATAL_ONE_ARGUMENT, ErrorTypeEnum.CONNECTION_PROBLEM, AlarmSeverityEnum.CRITICAL, ErrorSeverityEnum.FATAL, - "ERR299F", "Internal Connection problem", "Details: {0}.", "Please check logs for more information."), - - BeUebObjectNotFoundError(EPErrorCodesEnum.BEUEBOBJECTNOTFOUNDERROR_ONE_ARGUMENT, ErrorTypeEnum.DATA_ERROR, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, - "ERR303E", "Error occurred during access to U-EB Server.", "Data not found: {0}.", "An error occurred during access to UEB Server, {1} failed to either register or unregister to/from UEB topic."), - - BeUserMissingError(EPErrorCodesEnum.BEUSERMISSINGERROR_ONE_ARGUMENT, ErrorTypeEnum.DATA_ERROR, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, - "ERR310E", "User is not found", "", "User {0} must be added to the corresponding application with proper user roles."), - - BeUserInactiveWarning(EPErrorCodesEnum.BEUSERINACTIVEWARNING_ONE_ARGUMENT, ErrorTypeEnum.DATA_ERROR, AlarmSeverityEnum.MINOR, ErrorSeverityEnum.WARN, - "ERR313W", "User is found but in-active", "", "User {0} must be added to the corresponding application with proper user roles."), - - BeUserAdminPrivilegesInfo(EPErrorCodesEnum.BEUSERADMINPRIVILEGESINFO_ONE_ARGUMENT, ErrorTypeEnum.DATA_ERROR, AlarmSeverityEnum.MINOR, ErrorSeverityEnum.WARN, - "ERR314W", "User is found but don't have administrative privileges", "", "User {0} should be given administrator role for the corresponding application to perform the necessary actions."), - - BeInvalidJsonInput(EPErrorCodesEnum.BEINVALIDJSONINPUT, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, - "ERR405E", "Failed to convert JSON input to object", "", "Please check logs for more information."), - - BeIncorrectHttpStatusError(EPErrorCodesEnum.BEINCORRECTHTTPSTATUSERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, - "ERR407E", "Communication to an external application is resulted in with Incorrect Http response code", "", "Please check logs for more information."), - - BeInitializationError(EPErrorCodesEnum.BEINITIALIZATIONERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.CRITICAL, ErrorSeverityEnum.ERROR, - "ERR500E", "ECOMP-PORTAL Back-end was not initialized properly", "", "Please check logs for more information."), - - BeUebSystemError(EPErrorCodesEnum.BEUEBSYSTEMERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, - "ERR502E", "Error occurred during access to U-EB Server", "Details: {0}.", "An error occurred in {1} distribution mechanism. Please check the logs for more information."), - - BeDaoSystemError(EPErrorCodesEnum.BEDAOSYSTEMERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.CRITICAL, ErrorSeverityEnum.ERROR, - "ERR505E", "Performing DDL or DML operations on database might have failed", "", "Please check MySQL DB health or look at the logs for more details."), - - BeSystemError(EPErrorCodesEnum.BESYSTEMERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.CRITICAL, ErrorSeverityEnum.ERROR, - "ERR506E", "Unexpected error during operation", "", "Please check logs for more information."), - - BeExecuteRollbackError(EPErrorCodesEnum.BEEXECUTEROLLBACKERROR, ErrorTypeEnum.DATA_ERROR, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, - "ERR507E", "Roll-back operation towards database has failed", "", "Please check MYSQL DB health or look at the logs for more details."), - - FeHttpLoggingError(EPErrorCodesEnum.FEHTTPLOGGINGERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.MINOR, ErrorSeverityEnum.ERROR, - "ERR517E", "Error when logging FE HTTP request/response", "", "Please check MYSQL DB health or look at the logs for more details."), - - FePortalServletError(EPErrorCodesEnum.FEPORTALSERVLETERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, - "ERR518E", "Error when trying to access FE Portal page.", "", "Please check logs for more information."), - - BeDaoCloseSessionError(EPErrorCodesEnum.BEDAOCLOSESESSIONERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, - "ERR519E", "Close local session operation with database failed", "", "Please check MYSQL DB health or look at the logs form more details."), - - BeRestApiGeneralError(EPErrorCodesEnum.BERESTAPIGENERALERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.CRITICAL, ErrorSeverityEnum.ERROR, - "ERR900E", "Unexpected error during ECOMP-PORTAL Back-end REST API execution", "", "Please check error log for more information."), - - FeHealthCheckGeneralError(EPErrorCodesEnum.FEHEALTHCHECKGENERALERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.CRITICAL, ErrorSeverityEnum.ERROR, - "ERR901E", "General error during FE Health Check", "", "Please check error log for more information."), - - InternalUnexpectedInfo(EPErrorCodesEnum.INTERNALUNEXPECTEDINFO_ONE_ARGUMENT, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.INFORMATIONAL, ErrorSeverityEnum.INFO, - "ERR999I", "Unexpected error", "Details: {0}.", "Please check logs for more information."), - - InternalUnexpectedWarning(EPErrorCodesEnum.INTERNALUNEXPECTEDWARNING_ONE_ARGUMENT, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.MINOR, ErrorSeverityEnum.WARN, - "ERR999W", "Unexpected error", "Details: {0}.", "Please check logs for more information."), - - InternalUnexpectedError(EPErrorCodesEnum.INTERNALUNEXPECTEDERROR_ONE_ARGUMENT, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, - "ERR999E", "Unexpected error", "Details: {0}.", "Please check logs for more information."), - - InternalUnexpectedFatal(EPErrorCodesEnum.INTERNALUNEXPECTEDFATAL_ONE_ARGUMENT, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.CRITICAL, ErrorSeverityEnum.FATAL, - "ERR999F", "Unexpected error", "Details: {0}.", "Please check logs for more information."), - - ExternalAuthAccessConnectionError(EPErrorCodesEnum.EXTERNALAUTHACCESS_CONNECTIONERROR, ErrorTypeEnum.CONNECTION_PROBLEM, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, - "ERR220E", "AAF Connection problem", "Details: {0}.", "Please check logs for more information."), - - ExternalAuthAccessAuthenticationError(EPErrorCodesEnum.EXTERNALAUTHACCESS_AUTHENTICATIONERROR, ErrorTypeEnum.AUTHENTICATION_PROBLEM, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, - "ERR120E", "AAF authentication problem", "Details: {0}.", "Please check logs for more information."), - - ExternalAuthAccessGeneralError(EPErrorCodesEnum.EXTERNALAUTHACCESS_GENERALERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, - "ERR520E", "Unexpected error", "Details: {0}.", "Please check logs for more information."), - - SchedulerAccessConnectionError(EPErrorCodesEnum.SCHEDULER_ACCESS_CONNECTIONERROR, ErrorTypeEnum.CONNECTION_PROBLEM, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, - "ERR240E", "Scheduler Connection problem", "Details: {0}.", "Please check logs for more information."), - - SchedulerAuxAccessAuthenticationError(EPErrorCodesEnum.SCHEDULERAUX_ACCESS_AUTHENTICATIONERROR, ErrorTypeEnum.AUTHENTICATION_PROBLEM, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, - "ERR140E", "SchedulerAux authentication problem", "Details: {0}.", "Please check logs for more information."), - - SchedulerAccessGeneralError(EPErrorCodesEnum.SCHEDULER_ACCESS_GENERALERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, - "ERR540E", "Unexpected Scheduler error", "Details: {0}.", "Please check logs for more information."), - - SchedulerInvalidAttributeError(EPErrorCodesEnum.SCHEDULER_INVALID_ATTRIBUTEERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, - "ERR515E", "Unable to create Scheduler", "Details: {0}.", "Please check logs for more information."), - - ; - - ErrorTypeEnum eType; - AlarmSeverityEnum alarmSeverity; - EPErrorCodesEnum messageCode; - ErrorSeverityEnum errorSeverity; - String errorCode; - String errorDescription; - String details; - String resolution; - - EPAppMessagesEnum(EPErrorCodesEnum messageCode, ErrorTypeEnum eType, AlarmSeverityEnum alarmSeverity, ErrorSeverityEnum errorSeverity, String errorCode, String errorDescription, - String details, String resolution) { - this.messageCode = messageCode; - this.eType = eType; - this.alarmSeverity = alarmSeverity; - this.errorSeverity = errorSeverity; - this.errorCode = errorCode; - this.errorDescription = errorDescription; - this.details = details; - this.resolution = resolution; - } - - public String getDetails() { - return this.details; - } - - public String getResolution() { - return this.resolution; - } - public String getErrorCode() { - return this.errorCode; - } - - public String getErrorDescription() { - return this.errorDescription; - } - - public ErrorSeverityEnum getErrorSeverity() { - return this.errorSeverity; - } - - public void setErrorSeverity(ErrorSeverityEnum errorSeverity) { - this.errorSeverity = errorSeverity; - } - - public EPErrorCodesEnum getMessageCode() { - return messageCode; - } - - public void setMessageCode(EPErrorCodesEnum messageCode) { - this.messageCode = messageCode; - } - - public AlarmSeverityEnum getAlarmSeverity() { - return alarmSeverity; - } - - public void setAlarmSeverity(AlarmSeverityEnum alarmSeverity) { - this.alarmSeverity = alarmSeverity; - } - - public ErrorTypeEnum getErrorType() { - return eType; - } - - public void setErrorType(ErrorTypeEnum eType) { - this.eType = eType; - } + + BeUebAuthenticationError(EPErrorCodesEnum.BEUEBAUTHENTICATIONERROR_ONE_ARGUMENT, + ErrorTypeEnum.AUTHENTICATION_PROBLEM, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, + "ERR100E", "An Authentication failure occurred during access to UEB server", "Details: {0}.", + "Please check UEB server list and keys configured under Portal.Properties file."), + + BeRestApiAuthenticationError(EPErrorCodesEnum.BERESTAPIAUTHENTICATIONERROR, ErrorTypeEnum.AUTHENTICATION_PROBLEM, + AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, + "ERR101E", "Rejected an incoming REST API request due to invalid credentials", "", + "Please check application credentials defined in Database or properties files."), + + InternalAuthenticationInfo(EPErrorCodesEnum.INTERNALAUTHENTICATIONINFO_ONE_ARGUMENT, + ErrorTypeEnum.AUTHENTICATION_PROBLEM, AlarmSeverityEnum.INFORMATIONAL, ErrorSeverityEnum.INFO, + "ERR199I", "Internal authentication problem", "Details: {0}.", + "Please check the logs for more information."), + + InternalAuthenticationWarning(EPErrorCodesEnum.INTERNALAUTHENTICATIONWARNING_ONE_ARGUMENT, + ErrorTypeEnum.AUTHENTICATION_PROBLEM, AlarmSeverityEnum.MINOR, ErrorSeverityEnum.WARN, + "ERR199W", "Internal authentication problem", "Details: {0}.", + "Please check the logs for more information."), + + InternalAuthenticationError(EPErrorCodesEnum.INTERNALAUTHENTICATIONERROR_ONE_ARGUMENT, + ErrorTypeEnum.AUTHENTICATION_PROBLEM, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, + "ERR199E", "Internal authentication problem", "Details: {0}.", + "Please check the logs for more information."), + + InternalAuthenticationFatal(EPErrorCodesEnum.INTERNALAUTHENTICATIONFATAL_ONE_ARGUMENT, + ErrorTypeEnum.AUTHENTICATION_PROBLEM, AlarmSeverityEnum.CRITICAL, ErrorSeverityEnum.FATAL, + "ERR199F", "Internal authentication problem", "Details: {0}.", + "Please check the logs for more information."), + + BeHealthCheckError(EPErrorCodesEnum.BeHEALTHCHECKERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.CRITICAL, + ErrorSeverityEnum.ERROR, + "ERR200E", + "ECOMP-PORTAL Back-end probably lost connectivity to either one of the following components: MySQL DB, UEB Cluster", + "", "Please check the logs for more information."), + + BeHealthCheckMySqlError(EPErrorCodesEnum.BEHEALTHCHECKMYSQLERROR, ErrorTypeEnum.SYSTEM_ERROR, + AlarmSeverityEnum.CRITICAL, ErrorSeverityEnum.ERROR, + "ERR201E", "ECOMP-PORTAL Back-end probably lost connectivity to MySQL DB", "", + "Check connectivity to MYSQL is configured correctly under system.properties file."), + + BeHealthCheckUebClusterError(EPErrorCodesEnum.BEHEALTHCHECKUEBCLUSTERERROR, ErrorTypeEnum.SYSTEM_ERROR, + AlarmSeverityEnum.CRITICAL, ErrorSeverityEnum.ERROR, + "ERR203E", "ECOMP-PORTAL Back-end probably lost connectivity to UEB Cluster", "", + "Check connectivity to UEB cluster which is configured under portal.properties file."), + + FeHealthCheckError(EPErrorCodesEnum.FEHEALTHCHECKERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.CRITICAL, + ErrorSeverityEnum.ERROR, + "ERR204E", "Unable to connect to a valid ECOMP-PORTAL Back-end Server.", "", + "Please check connectivity from this FE instance towards BE or BE Load Balancer."), + + BeHealthCheckRecovery(EPErrorCodesEnum.BEHEALTHCHECKRECOVERY, ErrorTypeEnum.RECOVERY, + AlarmSeverityEnum.INFORMATIONAL, ErrorSeverityEnum.INFO, + "ERR205I", + "ECOMP-PORTAL Back-end Recovery to either one of the following components: MySQL DB, UEB Cluster", "", + "Please check logs for more specific information about the problem."), + + BeHealthCheckMySqlRecovery(EPErrorCodesEnum.BEHEALTHCHECKMYSQLRECOVERY, ErrorTypeEnum.RECOVERY, + AlarmSeverityEnum.INFORMATIONAL, ErrorSeverityEnum.INFO, + "ERR206I", "ECOMP-PORTAL Back-end connection recovery to MySQL DB", "", + "Please check logs for more specific information about the problem."), + + BeHealthCheckUebClusterRecovery(EPErrorCodesEnum.BEHEALTHCHECKUEBCLUSTERRECOVERY, ErrorTypeEnum.RECOVERY, + AlarmSeverityEnum.INFORMATIONAL, ErrorSeverityEnum.INFO, + "ERR208I", "ECOMP-PORTAL Back-end connection recovery to UEB Cluster", "", + "Please check logs for more specific information about the problem."), + + FeHealthCheckRecovery(EPErrorCodesEnum.FEHEALTHCHECKRECOVERY, ErrorTypeEnum.RECOVERY, + AlarmSeverityEnum.INFORMATIONAL, ErrorSeverityEnum.INFO, + "ERR209I", "Connectivity to ECOMP-PORTAL Front-end Server is recovered", "", + "Please check logs for more specific information about the problem."), + + BeUebConnectionError(EPErrorCodesEnum.BEUEBCONNECTIONERROR_ONE_ARGUMENT, ErrorTypeEnum.CONNECTION_PROBLEM, + AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, + "ERR210E", "ECOMP-PORTAL Back-end probably lost connectivity to UEB Cluster", "Details: {0}.", + "Please check UEB server list and keys configured under Portal.Properties file."), + + BeUebUnkownHostError(EPErrorCodesEnum.BEUEBUNKOWNHOSTERROR_ONE_ARGUMENT, ErrorTypeEnum.CONNECTION_PROBLEM, + AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, + "ERR211E", "ECOMP-PORTAL Back-end probably lost connectivity to UEB Cluster", "Cannot reach host: {0}.", + "Please check UEB server list and keys configured under Portal.Properties file."), + + BeUebRegisterOnboardingAppError(EPErrorCodesEnum.BEUEBREGISTERONBOARDINGAPPERROR, + ErrorTypeEnum.CONNECTION_PROBLEM, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, + "ERR212E", "Failed to register the On-boarding application with UEB Communication server", + "Details: {0}.", "Please check UEB server list and keys configured under Portal.Properties file."), + + BeHttpConnectionError(EPErrorCodesEnum.BEHTTPCONNECTIONERROR_ONE_ARGUMENT, ErrorTypeEnum.CONNECTION_PROBLEM, + AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, + "ERR213E", + "It could be that communication to an external application might resulted an exception or failed to reach the external application", + "Details: {0}.", "Please check logs for more information."), + MusicHealthCheckZookeeperError(EPErrorCodesEnum.MUSICHEALTHCHECKZOOKEEPERERROR_ONE_ARGUMENT, + ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, + "ERR214E", "Connectivity to Music Cluster -zookeeper server", "Details: {0}.", + "Please check zookeeper server list and check the logs for more information"), + + MusicHealthCheckCassandraError(EPErrorCodesEnum.MUSICHEALTHCHECKCASSANDRAERROR_ONE_ARGUMENT, + ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, + "ERR215E", "Connectivity to Music Cluster -Cassandra server", "Details: {0}.", + "Please check Cassandra server list and check the logs for more information"), + + InternalConnectionInfo(EPErrorCodesEnum.INTERNALCONNECTIONINFO_ONE_ARGUMENT, ErrorTypeEnum.CONNECTION_PROBLEM, + AlarmSeverityEnum.INFORMATIONAL, ErrorSeverityEnum.INFO, + "ERR299I", "Internal Connection problem", "Details: {0}.", "Please check logs for more information."), + + InternalConnectionWarning(EPErrorCodesEnum.INTERNALCONNECTIONWARNING_ONE_ARGUMENT, + ErrorTypeEnum.CONNECTION_PROBLEM, AlarmSeverityEnum.MINOR, ErrorSeverityEnum.WARN, + "ERR299W", "Internal Connection problem", "Details: {0}.", "Please check logs for more information."), + + InternalConnectionError(EPErrorCodesEnum.INTERNALCONNECTIONERROR_ONE_ARGUMENT, ErrorTypeEnum.CONNECTION_PROBLEM, + AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, + "ERR299E", "Internal Connection problem", "Details: {0}.", "Please check logs for more information."), + + InternalConnectionFatal(EPErrorCodesEnum.INTERNALCONNECTIONFATAL_ONE_ARGUMENT, ErrorTypeEnum.CONNECTION_PROBLEM, + AlarmSeverityEnum.CRITICAL, ErrorSeverityEnum.FATAL, + "ERR299F", "Internal Connection problem", "Details: {0}.", "Please check logs for more information."), + + BeUebObjectNotFoundError(EPErrorCodesEnum.BEUEBOBJECTNOTFOUNDERROR_ONE_ARGUMENT, ErrorTypeEnum.DATA_ERROR, + AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, + "ERR303E", "Error occurred during access to U-EB Server.", "Data not found: {0}.", + "An error occurred during access to UEB Server, {1} failed to either register or unregister to/from UEB topic."), + + BeUserMissingError(EPErrorCodesEnum.BEUSERMISSINGERROR_ONE_ARGUMENT, ErrorTypeEnum.DATA_ERROR, + AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, + "ERR310E", "User is not found", "", + "User {0} must be added to the corresponding application with proper user roles."), + + BeUserInactiveWarning(EPErrorCodesEnum.BEUSERINACTIVEWARNING_ONE_ARGUMENT, ErrorTypeEnum.DATA_ERROR, + AlarmSeverityEnum.MINOR, ErrorSeverityEnum.WARN, + "ERR313W", "User is found but in-active", "", + "User {0} must be added to the corresponding application with proper user roles."), + + BeUserAdminPrivilegesInfo(EPErrorCodesEnum.BEUSERADMINPRIVILEGESINFO_ONE_ARGUMENT, ErrorTypeEnum.DATA_ERROR, + AlarmSeverityEnum.MINOR, ErrorSeverityEnum.WARN, + "ERR314W", "User is found but don't have administrative privileges", "", + "User {0} should be given administrator role for the corresponding application to perform the necessary actions."), + + BeInvalidJsonInput(EPErrorCodesEnum.BEINVALIDJSONINPUT, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.MAJOR, + ErrorSeverityEnum.ERROR, + "ERR405E", "Failed to convert JSON input to object", "", "Please check logs for more information."), + + BeIncorrectHttpStatusError(EPErrorCodesEnum.BEINCORRECTHTTPSTATUSERROR, ErrorTypeEnum.SYSTEM_ERROR, + AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, + "ERR407E", "Communication to an external application is resulted in with Incorrect Http response code", + "", "Please check logs for more information."), + + BeInitializationError(EPErrorCodesEnum.BEINITIALIZATIONERROR, ErrorTypeEnum.SYSTEM_ERROR, + AlarmSeverityEnum.CRITICAL, ErrorSeverityEnum.ERROR, + "ERR500E", "ECOMP-PORTAL Back-end was not initialized properly", "", + "Please check logs for more information."), + + BeUebSystemError(EPErrorCodesEnum.BEUEBSYSTEMERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.MAJOR, + ErrorSeverityEnum.ERROR, + "ERR502E", "Error occurred during access to U-EB Server", "Details: {0}.", + "An error occurred in {1} distribution mechanism. Please check the logs for more information."), + + BeDaoSystemError(EPErrorCodesEnum.BEDAOSYSTEMERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.CRITICAL, + ErrorSeverityEnum.ERROR, + "ERR505E", "Performing DDL or DML operations on database might have failed", "", + "Please check MySQL DB health or look at the logs for more details."), + + BeSystemError(EPErrorCodesEnum.BESYSTEMERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.CRITICAL, + ErrorSeverityEnum.ERROR, + "ERR506E", "Unexpected error during operation", "", "Please check logs for more information."), + + BeExecuteRollbackError(EPErrorCodesEnum.BEEXECUTEROLLBACKERROR, ErrorTypeEnum.DATA_ERROR, + AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, + "ERR507E", "Roll-back operation towards database has failed", "", + "Please check MYSQL DB health or look at the logs for more details."), + + FeHttpLoggingError(EPErrorCodesEnum.FEHTTPLOGGINGERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.MINOR, + ErrorSeverityEnum.ERROR, + "ERR517E", "Error when logging FE HTTP request/response", "", + "Please check MYSQL DB health or look at the logs for more details."), + + FePortalServletError(EPErrorCodesEnum.FEPORTALSERVLETERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.MAJOR, + ErrorSeverityEnum.ERROR, + "ERR518E", "Error when trying to access FE Portal page.", "", "Please check logs for more information."), + + BeDaoCloseSessionError(EPErrorCodesEnum.BEDAOCLOSESESSIONERROR, ErrorTypeEnum.SYSTEM_ERROR, + AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, + "ERR519E", "Close local session operation with database failed", "", + "Please check MYSQL DB health or look at the logs form more details."), + + BeRestApiGeneralError(EPErrorCodesEnum.BERESTAPIGENERALERROR, ErrorTypeEnum.SYSTEM_ERROR, + AlarmSeverityEnum.CRITICAL, ErrorSeverityEnum.ERROR, + "ERR900E", "Unexpected error during ECOMP-PORTAL Back-end REST API execution", "", + "Please check error log for more information."), + + FeHealthCheckGeneralError(EPErrorCodesEnum.FEHEALTHCHECKGENERALERROR, ErrorTypeEnum.SYSTEM_ERROR, + AlarmSeverityEnum.CRITICAL, ErrorSeverityEnum.ERROR, + "ERR901E", "General error during FE Health Check", "", "Please check error log for more information."), + + InternalUnexpectedInfo(EPErrorCodesEnum.INTERNALUNEXPECTEDINFO_ONE_ARGUMENT, ErrorTypeEnum.SYSTEM_ERROR, + AlarmSeverityEnum.INFORMATIONAL, ErrorSeverityEnum.INFO, + "ERR999I", "Unexpected error", "Details: {0}.", "Please check logs for more information."), + + InternalUnexpectedWarning(EPErrorCodesEnum.INTERNALUNEXPECTEDWARNING_ONE_ARGUMENT, ErrorTypeEnum.SYSTEM_ERROR, + AlarmSeverityEnum.MINOR, ErrorSeverityEnum.WARN, + "ERR999W", "Unexpected error", "Details: {0}.", "Please check logs for more information."), + + InternalUnexpectedError(EPErrorCodesEnum.INTERNALUNEXPECTEDERROR_ONE_ARGUMENT, ErrorTypeEnum.SYSTEM_ERROR, + AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, + "ERR999E", "Unexpected error", "Details: {0}.", "Please check logs for more information."), + + InternalUnexpectedFatal(EPErrorCodesEnum.INTERNALUNEXPECTEDFATAL_ONE_ARGUMENT, ErrorTypeEnum.SYSTEM_ERROR, + AlarmSeverityEnum.CRITICAL, ErrorSeverityEnum.FATAL, + "ERR999F", "Unexpected error", "Details: {0}.", "Please check logs for more information."), + + ExternalAuthAccessConnectionError(EPErrorCodesEnum.EXTERNALAUTHACCESS_CONNECTIONERROR, + ErrorTypeEnum.CONNECTION_PROBLEM, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, + "ERR220E", "AAF Connection problem", "Details: {0}.", "Please check logs for more information."), + + ExternalAuthAccessAuthenticationError(EPErrorCodesEnum.EXTERNALAUTHACCESS_AUTHENTICATIONERROR, + ErrorTypeEnum.AUTHENTICATION_PROBLEM, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, + "ERR120E", "AAF authentication problem", "Details: {0}.", "Please check logs for more information."), + + ExternalAuthAccessGeneralError(EPErrorCodesEnum.EXTERNALAUTHACCESS_GENERALERROR, ErrorTypeEnum.SYSTEM_ERROR, + AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, + "ERR520E", "Unexpected error", "Details: {0}.", "Please check logs for more information."), + + SchedulerAccessConnectionError(EPErrorCodesEnum.SCHEDULER_ACCESS_CONNECTIONERROR, + ErrorTypeEnum.CONNECTION_PROBLEM, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, + "ERR240E", "Scheduler Connection problem", "Details: {0}.", "Please check logs for more information."), + + SchedulerAuxAccessAuthenticationError(EPErrorCodesEnum.SCHEDULERAUX_ACCESS_AUTHENTICATIONERROR, + ErrorTypeEnum.AUTHENTICATION_PROBLEM, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, + "ERR140E", "SchedulerAux authentication problem", "Details: {0}.", + "Please check logs for more information."), + + SchedulerAccessGeneralError(EPErrorCodesEnum.SCHEDULER_ACCESS_GENERALERROR, ErrorTypeEnum.SYSTEM_ERROR, + AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, + "ERR540E", "Unexpected Scheduler error", "Details: {0}.", "Please check logs for more information."), + + SchedulerInvalidAttributeError(EPErrorCodesEnum.SCHEDULER_INVALID_ATTRIBUTEERROR, ErrorTypeEnum.SYSTEM_ERROR, + AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR, + "ERR515E", "Unable to create Scheduler", "Details: {0}.", "Please check logs for more information."), + + ; + + ErrorTypeEnum eType; + AlarmSeverityEnum alarmSeverity; + EPErrorCodesEnum messageCode; + ErrorSeverityEnum errorSeverity; + String errorCode; + String errorDescription; + String details; + String resolution; + + EPAppMessagesEnum(EPErrorCodesEnum messageCode, ErrorTypeEnum eType, AlarmSeverityEnum alarmSeverity, + ErrorSeverityEnum errorSeverity, String errorCode, String errorDescription, + String details, String resolution) { + this.messageCode = messageCode; + this.eType = eType; + this.alarmSeverity = alarmSeverity; + this.errorSeverity = errorSeverity; + this.errorCode = errorCode; + this.errorDescription = errorDescription; + this.details = details; + this.resolution = resolution; + } + + public String getDetails() { + return this.details; + } + + public String getResolution() { + return this.resolution; + } + + public String getErrorCode() { + return this.errorCode; + } + + public String getErrorDescription() { + return this.errorDescription; + } + + public ErrorSeverityEnum getErrorSeverity() { + return this.errorSeverity; + } + + + public EPErrorCodesEnum getMessageCode() { + return messageCode; + } + + + public AlarmSeverityEnum getAlarmSeverity() { + return alarmSeverity; + } + + + public ErrorTypeEnum getErrorType() { + return eType; + } + } diff --git a/portal-BE/src/main/java/org/onap/portal/service/AdminRolesService.java b/portal-BE/src/main/java/org/onap/portal/service/AdminRolesService.java new file mode 100644 index 00000000..c948ece4 --- /dev/null +++ b/portal-BE/src/main/java/org/onap/portal/service/AdminRolesService.java @@ -0,0 +1,146 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Modifications Copyright (c) 2019 Samsung + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * + */ + +package org.onap.portal.service; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.persistence.EntityManager; +import org.onap.portal.domain.db.fn.FnRole; +import org.onap.portal.domain.db.fn.FnUser; +import org.onap.portal.domain.db.fn.FnUserRole; +import org.onap.portal.domain.dto.ecomp.UserRole; +import org.onap.portal.logging.format.EPAppMessagesEnum; +import org.onap.portal.logging.logic.EPLogUtil; +import org.onap.portal.service.fn.FnUserService; +import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class AdminRolesService { + + private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(AdminRolesService.class); + + private final Long SYS_ADMIN_ROLE_ID = 1L; + private final Long ACCOUNT_ADMIN_ROLE_ID = 999L; + private final Long ECOMP_APP_ID = 1L; + private final String ADMIN_ACCOUNT= "Is account admin for user {}"; + + private final EntityManager entityManager; + private final FnUserService fnUserService; + + @Autowired + public AdminRolesService(final EntityManager entityManager, + FnUserService fnUserService) { + this.entityManager = entityManager; + this.fnUserService = fnUserService; + } + + public boolean isSuperAdmin(FnUser user) { + if ((user != null) && (user.getOrgUserId() != null)) { + String sql = "SELECT user.USER_ID, user.org_user_id, userrole.ROLE_ID, userrole.APP_ID FROM fn_user_role userrole " + + "INNER JOIN fn_user user ON user.USER_ID = userrole.USER_ID " + "WHERE user.org_user_id = '" + + user.getOrgUserId() + "' " + "AND userrole.ROLE_ID = '" + SYS_ADMIN_ROLE_ID + "' " + + "AND userrole.APP_ID = '" + ECOMP_APP_ID + "';"; + try { + List userRoleList = entityManager.createNativeQuery(sql, UserRole.class).getResultList(); + if (userRoleList != null && userRoleList.size() > 0) { + return true; + } + } catch (Exception e) { + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeDaoSystemError, e); + logger.error(EELFLoggerDelegate.errorLogger, + "Exception occurred while executing isSuperAdmin operation", e); + } + } + return false; + } + + public boolean isAccountAdmin(FnUser user) { + try { + final Map<String, Long> userParams = new HashMap<>(); + userParams.put("userId", user.getId()); + logger.debug(EELFLoggerDelegate.debugLogger, ADMIN_ACCOUNT, user.getId()); + List<Integer> userAdminApps; + String query = "select fa.app_id from fn_user_role ur,fn_app fa where ur.user_id =:userId and ur.app_id=fa.app_id and ur.role_id= 999 and (fa.enabled = 'Y' || fa.app_id=1)"; + userAdminApps = entityManager.createQuery(query, Integer.class).setParameter("userId", user.getId()).getResultList(); + logger.debug(EELFLoggerDelegate.debugLogger, "Is account admin for userAdminApps() - for user {}, found userAdminAppsSize {}", user.getOrgUserId(), userAdminApps.size()); + + + if (user.getId() != null) { + for (FnUserRole userApp : user.getFnUserRoles()) { + if (userApp.getRoleId().getId().equals(ACCOUNT_ADMIN_ROLE_ID)||(userAdminApps.size()>1)) { + logger.debug(EELFLoggerDelegate.debugLogger, "Is account admin for userAdminApps() - for user {}, found Id {}", user.getOrgUserId(), userApp.getRoleId().getId()); + return true; + } + } + } + } catch (Exception e) { + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeDaoSystemError, e); + logger.error(EELFLoggerDelegate.errorLogger, "Exception occurred while executing isAccountAdmin operation", + e); + } + return false; + } + + public boolean isUser(FnUser user) { + try { + FnUser currentUser = fnUserService.getUser(user.getId()).orElseThrow(Exception::new); + if (currentUser != null && currentUser.getId() != null) { + for (FnUserRole userApp : currentUser.getFnUserRoles()) { + if (!userApp.getAppId().getId().equals(ECOMP_APP_ID)) { + FnRole role = userApp.getRoleId(); + if (!role.getId().equals(SYS_ADMIN_ROLE_ID) && !role.getId().equals(ACCOUNT_ADMIN_ROLE_ID)) { + if (role.getActiveYn()) { + return true; + } + } + } + } + } + } catch (Exception e) { + EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeDaoSystemError, e); + logger.error(EELFLoggerDelegate.errorLogger, "Exception occurred while executing isUser operation", e); + } + return false; + } +} diff --git a/portal-BE/src/main/java/org/onap/portal/service/PersUserWidgetService.java b/portal-BE/src/main/java/org/onap/portal/service/PersUserWidgetService.java new file mode 100644 index 00000000..364085c4 --- /dev/null +++ b/portal-BE/src/main/java/org/onap/portal/service/PersUserWidgetService.java @@ -0,0 +1,111 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Modifications Copyright (c) 2019 Samsung + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * + */ + +package org.onap.portal.service; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; +import org.onap.portal.dao.ep.EpPersUserWidgetSelDao; +import org.onap.portal.dao.fn.EpWidgetCatalogDao; +import org.onap.portal.domain.db.ep.EpPersUserWidgetSel; +import org.onap.portal.domain.db.fn.FnUser; +import org.onap.portal.domain.dto.ecomp.PersUserWidgetSelection; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class PersUserWidgetService { + + private final EpPersUserWidgetSelDao epPersUserWidgetSelDao; + private final EpWidgetCatalogDao epWidgetCatalogDao; + + @Autowired + public PersUserWidgetService(final EpPersUserWidgetSelDao epPersUserWidgetSelDao, + final EpWidgetCatalogDao epWidgetCatalogDao) { + this.epPersUserWidgetSelDao = epPersUserWidgetSelDao; + this.epWidgetCatalogDao = epWidgetCatalogDao; + } + + public void setPersUserAppValue(FnUser user, Long widgetId, Boolean select) { + if (user == null || widgetId == null) { + throw new IllegalArgumentException("setPersUserAppValue: Null values"); + } + + List<PersUserWidgetSelection> persList = getUserWidgetSelction(user, widgetId); + // Key constraint limits to 1 row + PersUserWidgetSelection persRow = null; + if (persList.size() == 1) { + persRow = persList.get(0); + } else { + persRow = new PersUserWidgetSelection(null, user.getId(), widgetId, null); + } + if (select) { + if (persRow.getId() != null) { + epPersUserWidgetSelDao.deleteById(persRow.getId()); + } + persRow.setStatusCode("S"); // show + EpPersUserWidgetSel epPersUserWidgetSel = new EpPersUserWidgetSel(); + epPersUserWidgetSel.setUserId(user); + epPersUserWidgetSel.setWidgetId(epWidgetCatalogDao.findById(widgetId).get()); + epPersUserWidgetSelDao.saveAndFlush(epPersUserWidgetSel); + } else { + if (persRow.getId() != null) { + epPersUserWidgetSelDao.deleteById(persRow.getId()); + } + persRow.setStatusCode("H"); // Hide + EpPersUserWidgetSel epPersUserWidgetSel = new EpPersUserWidgetSel(); + epPersUserWidgetSel.setUserId(user); + epPersUserWidgetSel.setWidgetId(epWidgetCatalogDao.findById(widgetId).get()); + epPersUserWidgetSelDao.saveAndFlush(epPersUserWidgetSel); + } + } + + private List<PersUserWidgetSelection> getUserWidgetSelction(FnUser user, Long widgetId) { + return epPersUserWidgetSelDao.getEpPersUserWidgetSelForUserIdAndWidgetId(user.getId(), widgetId) + .orElse(new ArrayList<>()).stream().map( + this::epPersUserWidgetSelToPersUserWidgetSelection).collect(Collectors.toList()); + } + + private PersUserWidgetSelection epPersUserWidgetSelToPersUserWidgetSelection(EpPersUserWidgetSel widgetSel) { + return new PersUserWidgetSelection(widgetSel.getId(), widgetSel.getUserId().getId(), + widgetSel.getWidgetId().getWidgetId(), widgetSel.getStatusCd()); + } +} diff --git a/portal-BE/src/main/java/org/onap/portal/service/WidgetMService.java b/portal-BE/src/main/java/org/onap/portal/service/WidgetMService.java new file mode 100644 index 00000000..624beed8 --- /dev/null +++ b/portal-BE/src/main/java/org/onap/portal/service/WidgetMService.java @@ -0,0 +1,60 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Modifications Copyright (c) 2019 Samsung + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * + */ + +package org.onap.portal.service; + +import org.onap.portal.utils.EcompPortalUtils; +import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.springframework.stereotype.Service; + +@Service +public class WidgetMService { + + private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(WidgetMService.class); + + public String getServiceLocation(String service, String fallbackPortOnLocalHost) { + logger.debug(EELFLoggerDelegate.debugLogger, "Requested Service: " + service); + String localFallbackServiceLocation = + EcompPortalUtils.localOrDockerHost() + ":" + fallbackPortOnLocalHost; + logger.debug(EELFLoggerDelegate.debugLogger, + "returned service location: " + localFallbackServiceLocation); + return localFallbackServiceLocation; + } +} diff --git a/portal-BE/src/main/java/org/onap/portal/service/WidgetService.java b/portal-BE/src/main/java/org/onap/portal/service/WidgetService.java new file mode 100644 index 00000000..794f9336 --- /dev/null +++ b/portal-BE/src/main/java/org/onap/portal/service/WidgetService.java @@ -0,0 +1,265 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Modifications Copyright (c) 2019 Samsung + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * + */ + +package org.onap.portal.service; + +import java.util.ArrayList; +import java.util.List; +import javax.persistence.EntityManager; +import javax.servlet.http.HttpServletResponse; +import org.onap.portal.dao.fn.FnWidgetDao; +import org.onap.portal.domain.db.fn.FnUser; +import org.onap.portal.domain.db.fn.FnWidget; +import org.onap.portal.domain.dto.ecomp.EPUserApp; +import org.onap.portal.domain.dto.ecomp.Widget; +import org.onap.portal.domain.dto.transport.FieldsValidator; +import org.onap.portal.domain.dto.transport.OnboardingWidget; +import org.onap.portal.utils.EPCommonSystemProperties; +import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +public class WidgetService { + + private final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(WidgetService.class); + private final Long LONG_ECOMP_APP_ID = 1L; + private final Long ACCOUNT_ADMIN_ROLE_ID = 999L; + + private static String baseSqlToken = + " new org.onap.portal.domain.dto.transport.OnboardingWidget(" + + "widget.WIDGET_ID,widget.WDG_NAME,widget.APP_ID," + + "app.APP_NAME,widget.WDG_WIDTH,widget.WDG_HEIGHT," + + "widget.WDG_URL) widget.WIDGET_ID,widget.WDG_NAME,widget.APP_ID,app.APP_NAME,widget.WDG_WIDTH,widget.WDG_HEIGHT,widget.WDG_URL from FN_WIDGET widget join FN_APP app ON widget.APP_ID = app.APP_ID"; + + private static final String urlField = "url"; + private static final Long DUBLICATED_FIELD_VALUE_ECOMP_ERROR = new Long( + EPCommonSystemProperties.DUBLICATED_FIELD_VALUE_ECOMP_ERROR); + private static final String nameField = "name"; + + private final AdminRolesService adminRolesService; + private final EntityManager entityManager; + private final FnWidgetDao fnWidgetDao; + + @Autowired + public WidgetService(final AdminRolesService adminRolesService, final EntityManager entityManager, + final FnWidgetDao fnWidgetDao) { + this.adminRolesService = adminRolesService; + this.entityManager = entityManager; + this.fnWidgetDao = fnWidgetDao; + } + + private static final Object syncRests = new Object(); + + public List<OnboardingWidget> getOnboardingWidgets(FnUser user, boolean managed) { + if (adminRolesService.isSuperAdmin(user)) { + return entityManager.createQuery(sqlWidgetsForAllApps(), OnboardingWidget.class).getResultList(); + } else if (managed) { + if (adminRolesService.isAccountAdmin(user)) { + return entityManager + .createQuery(sqlWidgetsForAllAppsWhereUserIsAdmin(), OnboardingWidget.class) + .setParameter("USERID", user.getId()).getResultList(); + } + } else if (adminRolesService.isAccountAdmin(user) || adminRolesService.isUser(user)) { + return entityManager + .createQuery(sqlWidgetsForAllAppsWhereUserHasAnyRole(), OnboardingWidget.class) + .setParameter("USERID", user.getId()).getResultList(); + } + return new ArrayList<>(); + } + + private String sqlWidgetsForAllApps() { + return "SELECT" + baseSqlToken; + } + + private String sqlWidgetsForAllAppsWhereUserIsAdmin() { + return "SELECT" + baseSqlToken + + " join FN_USER_ROLE ON FN_USER_ROLE.APP_ID = app.APP_ID where FN_USER_ROLE.USER_ID = :USERID AND FN_USER_ROLE.ROLE_ID = " + + ACCOUNT_ADMIN_ROLE_ID; + } + + private String sqlWidgetsForAllAppsWhereUserHasAnyRole() { + return "SELECT DISTINCT" + baseSqlToken + + " join FN_USER_ROLE ON FN_USER_ROLE.APP_ID = app.APP_ID where FN_USER_ROLE.USER_ID = " + + ":USERID"; + } + + public FieldsValidator setOnboardingWidget(FnUser user, OnboardingWidget onboardingWidget) { + if (onboardingWidget.getAppName().isEmpty() || onboardingWidget.getUrl().isEmpty() + || onboardingWidget.getAppId() == null + || onboardingWidget.getAppId().equals(LONG_ECOMP_APP_ID) || onboardingWidget.getWidth() <= 0 || + onboardingWidget.getHeight() <= 0) { + FieldsValidator fieldsValidator = new FieldsValidator(); + fieldsValidator.setHttpStatusCode((long) HttpServletResponse.SC_BAD_REQUEST); + return fieldsValidator; + } + return this.updateOrSaveWidget(adminRolesService.isSuperAdmin(user), user.getId(), onboardingWidget); + } + + private FieldsValidator updateOrSaveWidget(boolean superAdmin, Long userId, OnboardingWidget onboardingWidget) { + FieldsValidator fieldsValidator = new FieldsValidator(); + if (!this.isUserAdminOfAppForWidget(superAdmin, userId, onboardingWidget.getAppId())) { + fieldsValidator.setHttpStatusCode((long) HttpServletResponse.SC_FORBIDDEN); + return fieldsValidator; + } + synchronized (syncRests) { + if (onboardingWidget.getId() == null) { + this.validateOnboardingWidget(onboardingWidget, fieldsValidator); + } else { + FnWidget widget = fnWidgetDao.getOne(onboardingWidget.getId()); + if (widget == null || widget.getAppId() == null) { + fieldsValidator.setHttpStatusCode((long) HttpServletResponse.SC_NOT_FOUND); + return fieldsValidator; + } + this.validateOnboardingWidget(onboardingWidget, fieldsValidator); + } + if (fieldsValidator.getHttpStatusCode() == HttpServletResponse.SC_OK) { + this.applyOnboardingWidget(onboardingWidget, fieldsValidator); + } + } + return fieldsValidator; + } + + private boolean isUserAdminOfAppForWidget(boolean superAdmin, Long userId, Long appId) { + if (!superAdmin) { + List<EPUserApp> userRoles = getAdminUserRoles(userId, appId); + return (userRoles.size() > 0); + } + return true; + } + + private List<EPUserApp> getAdminUserRoles(Long userId, Long appId) { + return entityManager.createQuery( + "SELECT new org.onap.portal.domain.dto.ecomp.EPUserApp(fn.userId, fn.roleId, fn.appId) FROM FnUserRole fn" + + "WHERE fn.userId = :USERID " + + "AND fn.roleId = :ROLEID " + + "AND fn.appId = :APPID", EPUserApp.class) + .setParameter("USERID", userId) + .setParameter("ROLEID", ACCOUNT_ADMIN_ROLE_ID) + .setParameter("APPID", appId) + .getResultList(); + } + + @Transactional + private void applyOnboardingWidget(OnboardingWidget onboardingWidget, FieldsValidator fieldsValidator) { + boolean result; + FnWidget widget; + if (onboardingWidget.getId() == null) { + widget = new FnWidget(); + } else { + widget = fnWidgetDao.getOne(onboardingWidget.getId()); + } + widget.setAppId(onboardingWidget.getAppId()); + widget.setName(onboardingWidget.getName()); + widget.setWidth(onboardingWidget.getWidth()); + widget.setHeight(onboardingWidget.getHeight()); + widget.setUrl(onboardingWidget.getUrl()); + result = widget.equals(fnWidgetDao.saveAndFlush(widget)); + if (!result) { + fieldsValidator.setHttpStatusCode((long) HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + } + } + + private void validateOnboardingWidget(OnboardingWidget onboardingWidget, FieldsValidator fieldsValidator) { + List<Widget> widgets = getWidgets(onboardingWidget); + boolean dublicatedUrl = false; + boolean dublicatedName = false; + for (Widget widget : widgets) { + if (onboardingWidget.getId() != null && onboardingWidget.getId().equals(widget.getId())) { + // widget should not be compared with itself + continue; + } + if (!dublicatedUrl && widget.getUrl().equals(onboardingWidget.getUrl())) { + dublicatedUrl = true; + if (dublicatedName) { + break; + } + } + if (!dublicatedName && widget.getName().equalsIgnoreCase(onboardingWidget.getName()) && widget + .getAppId().equals(onboardingWidget.getAppId())) { + dublicatedName = true; + if (dublicatedUrl) { + break; + } + } + } + if (dublicatedUrl || dublicatedName) { + if (dublicatedUrl) { + fieldsValidator.addProblematicFieldName(urlField); + } + if (dublicatedName) { + fieldsValidator.addProblematicFieldName(nameField); + } + fieldsValidator.setHttpStatusCode((long) HttpServletResponse.SC_CONFLICT); + fieldsValidator.setErrorCode(DUBLICATED_FIELD_VALUE_ECOMP_ERROR); + } + } + + private List<Widget> getWidgets(OnboardingWidget onboardingWidget) { + return entityManager.createQuery( + "SELECT new org.onap.portal.domain.dto.ecomp.Widget(fn.APP_ID, fn.WDG_NAME, fn.WDG_URL) FROM FnWidget fn" + + "WHERE fn.WDG_URL = :WDGURL " + + "AND fn.WDG_NAME = :WDGNAME " + + "AND fn.APP_ID = :APPID", Widget.class) + .setParameter("WDGURL", onboardingWidget.getUrl()) + .setParameter("WDGNAME", onboardingWidget.getName()) + .getResultList(); + } + + @Transactional + public FieldsValidator deleteOnboardingWidget(FnUser user, Long onboardingWidgetId) { + FieldsValidator fieldsValidator = new FieldsValidator(); + synchronized (syncRests) { + FnWidget widget = fnWidgetDao.getOne(onboardingWidgetId); + if (widget != null && widget.getAppId() != null) { // widget exists + if (!this.isUserAdminOfAppForWidget(adminRolesService.isSuperAdmin(user), user.getId(), + widget.getAppId())) { + fieldsValidator.setHttpStatusCode((long) HttpServletResponse.SC_FORBIDDEN); + } else { + fnWidgetDao.deleteById(onboardingWidgetId); + fieldsValidator.setHttpStatusCode( + (long) HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + } + } + } + return fieldsValidator; + } +} diff --git a/portal-BE/src/main/java/org/onap/portal/service/ep/EpMicroserviceParameterService.java b/portal-BE/src/main/java/org/onap/portal/service/ep/EpMicroserviceParameterService.java new file mode 100644 index 00000000..2544ae6a --- /dev/null +++ b/portal-BE/src/main/java/org/onap/portal/service/ep/EpMicroserviceParameterService.java @@ -0,0 +1,87 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Modifications Copyright (c) 2019 Samsung + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * + */ + +package org.onap.portal.service.ep; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; +import org.hibernate.criterion.Criterion; +import org.hibernate.criterion.Restrictions; +import org.onap.portal.dao.ep.EpMicroserviceParameterDao; +import org.onap.portal.domain.db.ep.EpMicroserviceParameter; +import org.onap.portal.domain.dto.ecomp.MicroserviceParameter; +import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class EpMicroserviceParameterService { + + EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(EpWidgetCatalogParameterService.class); + + private final EpMicroserviceParameterDao epMicroserviceParameterDao; + + @Autowired + public EpMicroserviceParameterService( + final EpMicroserviceParameterDao epMicroserviceParameterDao) { + this.epMicroserviceParameterDao = epMicroserviceParameterDao; + } + + public List<MicroserviceParameter> getParametersById(long serviceId) { + List<Criterion> restrictionsList = new ArrayList<>(); + Criterion contextIdCrit = Restrictions.eq("serviceId", serviceId); + restrictionsList.add(contextIdCrit); + List<MicroserviceParameter> list = mapToMicroserviceParameterList(epMicroserviceParameterDao.getParametersById(serviceId)); + logger.debug(EELFLoggerDelegate.debugLogger, + "getParametersById: microservice parameters list size: " + list.size()); + return list; + } + + private MicroserviceParameter epWidgetCatalogParameterToMicroserviceParameter( + final EpMicroserviceParameter microservice) { + return new MicroserviceParameter(microservice.getId(), microservice.getServiceId().getId(), + microservice.getParaKey(), microservice.getParaValue()); + } + + private List<MicroserviceParameter> mapToMicroserviceParameterList(final List<EpMicroserviceParameter> list){ + return list.stream().map(this::epWidgetCatalogParameterToMicroserviceParameter).collect(Collectors.toList()); + } +} diff --git a/portal-BE/src/main/java/org/onap/portal/service/ep/EpWidgetCatalogParameterService.java b/portal-BE/src/main/java/org/onap/portal/service/ep/EpWidgetCatalogParameterService.java new file mode 100644 index 00000000..8488e5ad --- /dev/null +++ b/portal-BE/src/main/java/org/onap/portal/service/ep/EpWidgetCatalogParameterService.java @@ -0,0 +1,127 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Modifications Copyright (c) 2019 Samsung + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * + */ + +package org.onap.portal.service.ep; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; +import org.onap.portal.dao.ep.EpMicroserviceParameterDao; +import org.onap.portal.dao.ep.EpWidgetCatalogParameterDao; +import org.onap.portal.dao.fn.EpWidgetCatalogDao; +import org.onap.portal.dao.fn.FnUserDao; +import org.onap.portal.domain.db.ep.EpWidgetCatalogParameter; +import org.onap.portal.domain.dto.ecomp.WidgetCatalogParameter; +import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class EpWidgetCatalogParameterService { + + EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(EpWidgetCatalogParameterService.class); + + private final EpWidgetCatalogParameterDao epWidgetCatalogParameterDao; + private final EpMicroserviceParameterDao epMicroserviceParameterDao; + private final EpWidgetCatalogDao epWidgetCatalogDao; + private final FnUserDao fnUserDao; + + @Autowired + public EpWidgetCatalogParameterService( + final EpWidgetCatalogParameterDao epWidgetCatalogParameterDao, + final EpMicroserviceParameterDao epMicroserviceParameterDao, + EpWidgetCatalogDao epWidgetCatalogDao, FnUserDao fnUserDao) { + this.epWidgetCatalogParameterDao = epWidgetCatalogParameterDao; + this.epMicroserviceParameterDao = epMicroserviceParameterDao; + this.epWidgetCatalogDao = epWidgetCatalogDao; + this.fnUserDao = fnUserDao; + } + + public List<WidgetCatalogParameter> getUserParameterById(Long paramId) { + return mapEpWidgetListToWidgetList( + epWidgetCatalogParameterDao.retrieveByParamId(paramId).orElse(new ArrayList<>())); + } + + public void deleteUserParameterById(Long paramId) { + epWidgetCatalogParameterDao.deleteWidgetCatalogParameter(paramId); + epMicroserviceParameterDao.deleteMicroserviceParameterById(paramId); + } + + public WidgetCatalogParameter getUserParamById(Long widgetId, Long userId, Long paramId) { + WidgetCatalogParameter widgetParam = null; + List<WidgetCatalogParameter> list = mapEpWidgetListToWidgetList( + epWidgetCatalogParameterDao.getUserParamById(widgetId, userId, paramId) + .orElse(new ArrayList<>())); + if (list.size() != 0) { + widgetParam = list.get(0); + } + logger.debug(EELFLoggerDelegate.debugLogger, + "getUserParamById: widget parameters: " + widgetParam); + return widgetParam; + } + + public void saveUserParameter(WidgetCatalogParameter newParameter) { + epWidgetCatalogParameterDao.saveAndFlush(mapToEpWidgetCatalogParameter(newParameter)); + } + + private EpWidgetCatalogParameter mapToEpWidgetCatalogParameter(WidgetCatalogParameter wcp){ + + return new EpWidgetCatalogParameter(wcp.getId(), epWidgetCatalogDao.findById(wcp.getWidgetId()).get(), + fnUserDao.findById(wcp.getUserId()).get(), + epMicroserviceParameterDao.findById(wcp.getParamId()).get(), + wcp.getUserValue()); + } + + private List<EpWidgetCatalogParameter> mapToList(List<WidgetCatalogParameter> list){ + return list.stream().map(this::mapToEpWidgetCatalogParameter).collect(Collectors.toList()); + } + + private WidgetCatalogParameter mapEpWidgetCatalogParametertoWidgetCatalogParameter( + EpWidgetCatalogParameter ewcp) { + return new WidgetCatalogParameter(ewcp.getId(), ewcp.getWidgetId().getWidgetId(), + ewcp.getUserId().getId(), ewcp.getParamId().getId(), ewcp.getUserValue()); + } + + private List<WidgetCatalogParameter> mapEpWidgetListToWidgetList( + List<EpWidgetCatalogParameter> epWidgetCatalogParameters) { + return epWidgetCatalogParameters.stream().map(this::mapEpWidgetCatalogParametertoWidgetCatalogParameter) + .collect(Collectors.toList()); + } +} diff --git a/portal-BE/src/main/java/org/onap/portal/service/fn/FnAppService.java b/portal-BE/src/main/java/org/onap/portal/service/fn/FnAppService.java new file mode 100644 index 00000000..75b32dd3 --- /dev/null +++ b/portal-BE/src/main/java/org/onap/portal/service/fn/FnAppService.java @@ -0,0 +1,105 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Modifications Copyright (c) 2019 Samsung + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * + */ + +package org.onap.portal.service.fn; + +import java.util.List; +import org.onap.portal.dao.fn.FnAppDao; +import org.onap.portal.domain.db.fn.FnApp; +import org.onap.portal.domain.dto.transport.OnboardingApp; +import org.onap.portal.utils.EPCommonSystemProperties; +import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.onap.portalsdk.core.onboarding.util.CipherUtil; +import org.onap.portalsdk.core.util.SystemProperties; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class FnAppService { + + private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(FnAppService.class); + + private final FnAppDao fnAppDao; + + @Autowired + public FnAppService(final FnAppDao fnAppDao) { + this.fnAppDao = fnAppDao; + } + + public List<FnApp> getAppsFullList() { + return fnAppDao.findAll(); + } + + public void createOnboardingFromApp(FnApp app, OnboardingApp onboardingApp) { + onboardingApp.setId(app.getId()); + onboardingApp.setName(app.getAppName()); + onboardingApp.setImageUrl(app.getAppImageUrl()); + onboardingApp.setDescription(app.getAppDescription()); + onboardingApp.setNotes(app.getAppNotes()); + onboardingApp.setUrl(app.getAppUrl()); + onboardingApp.setAlternateUrl(app.getAppAlternateUrl()); + onboardingApp.setRestUrl(app.getAppRestEndpoint()); + onboardingApp.setIsOpen(app.getOpen()); + onboardingApp.setIsEnabled(app.getEnabled()); + onboardingApp.setUsername(app.getAppUsername()); + onboardingApp.setAppPassword((app.getAppPassword().equals(EPCommonSystemProperties.APP_DISPLAY_PASSWORD)) + ? EPCommonSystemProperties.APP_DISPLAY_PASSWORD : decryptedPassword(app.getAppPassword(), app)); + onboardingApp.setUebTopicName(app.getUebTopicName()); + onboardingApp.setUebKey(app.getUebKey()); + onboardingApp.setUebSecret(app.getUebSecret()); + onboardingApp.setIsCentralAuth(app.getAuthCentral()); + onboardingApp.setNameSpace(app.getAuthNamespace()); + onboardingApp.setRestrictedApp(app.isRestrictedApp()); + } + + private String decryptedPassword(String encryptedAppPwd, FnApp app) { + String result = ""; + if (encryptedAppPwd != null && !encryptedAppPwd.isEmpty()) { + try { + result = CipherUtil.decryptPKC(encryptedAppPwd, + SystemProperties.getProperty(SystemProperties.Decryption_Key)); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, + "decryptedPassword failed for app " + app.getAppName(), e); + } + } + return result; + } +} diff --git a/portal-BE/src/main/java/org/onap/portal/service/fn/FnUserService.java b/portal-BE/src/main/java/org/onap/portal/service/fn/FnUserService.java index 8c5806ea..855e827d 100644 --- a/portal-BE/src/main/java/org/onap/portal/service/fn/FnUserService.java +++ b/portal-BE/src/main/java/org/onap/portal/service/fn/FnUserService.java @@ -44,7 +44,6 @@ import java.security.Principal; import java.util.ArrayList; import java.util.List; import java.util.Optional; -import java.util.stream.Collectors; import org.onap.portal.dao.fn.FnUserDao; import org.onap.portal.domain.db.fn.FnUser; import org.springframework.beans.factory.annotation.Autowired; @@ -89,7 +88,6 @@ public class FnUserService implements UserDetailsService { } List<FnUser> getUsersByOrgIds(final List<String> orgIds){ - String ids = "(" + orgIds.stream().map(s -> "'" + s + "'").collect(Collectors.joining()) + ")"; return fnUserDao.getUsersByOrgIds(orgIds).orElse(new ArrayList<>()); } diff --git a/portal-BE/src/main/java/org/onap/portal/service/fn/old/AppsCacheService.java b/portal-BE/src/main/java/org/onap/portal/service/fn/old/AppsCacheService.java new file mode 100644 index 00000000..7703420b --- /dev/null +++ b/portal-BE/src/main/java/org/onap/portal/service/fn/old/AppsCacheService.java @@ -0,0 +1,170 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Modifications Copyright (c) 2019 Samsung + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * + */ + +package org.onap.portal.service.fn.old; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import javax.annotation.PostConstruct; +import org.onap.portal.domain.db.fn.FnApp; +import org.onap.portal.domain.dto.transport.OnboardingApp; +import org.onap.portal.service.fn.FnAppService; +import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.stereotype.Service; + +@Service("appsCacheService") +@Configuration +@EnableAspectJAutoProxy +public class AppsCacheService { + @Autowired + private + FnAppService appsService; + + private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(AppsCacheService.class); + + final class CacheConfiguration { + + private long updateTime = 0; + private int updateInterval = 10; + + public CacheConfiguration (long _updateTime, int _updateInterval) { + updateTime = _updateTime; + updateInterval = _updateInterval; + } + } + + private CacheConfiguration quickRefreshCacheConf = null; + private CacheConfiguration slowRefreshCacheConf = null; + + + private static volatile Map<Long, FnApp> appsMap; + private static volatile Map<String, FnApp> uebAppsMap; + + @PostConstruct + public void init() { + quickRefreshCacheConf = new CacheConfiguration(0, 120); + slowRefreshCacheConf = new CacheConfiguration(0, 3600); + + this.refreshAppsMap(quickRefreshCacheConf); + } + + private void refreshAppsMap(CacheConfiguration conf) { + long now = System.currentTimeMillis(); + + if(noNeedToUpdate(now, conf)) + return; + + synchronized (this) { + if(noNeedToUpdate(now, conf)) + return; + List<FnApp> allApps = appsService.getAppsFullList(); + Map<Long, FnApp> newAppsMap = new HashMap<>(); + for (FnApp app : allApps) { + newAppsMap.put(app.getId(), app); + } + + Map<String, FnApp> newUebAppsMap = new HashMap<>(); + for (FnApp app : allApps) { + newUebAppsMap.put(app.getUebKey(), app); + } + // Switch cache with the new one. + appsMap = newAppsMap; + uebAppsMap = newUebAppsMap; + conf.updateTime = now; + } + + } + + private boolean noNeedToUpdate(long now, CacheConfiguration conf) { + long secondsPassed = (now - conf.updateTime)/1000; + if(secondsPassed < conf.updateInterval){ + logger.debug(EELFLoggerDelegate.debugLogger, "no need to refresh yet, seconds since last refresh: " + secondsPassed + ", refresh interval (sec) = " + conf.updateInterval); + return true; // no need to update cache + } + return false; // its time to update + } + + public String getAppEndpoint(Long appId) { + refreshAppsMap(quickRefreshCacheConf); + FnApp app = appsMap.get(appId); + if(app != null) + return app.getAppRestEndpoint(); + return null; + } + + public List<OnboardingApp> getAppsFullList() { + refreshAppsMap(quickRefreshCacheConf); + List<FnApp> appList = new ArrayList<>(appsMap.values()); + appList.removeIf(app -> app.getId() == 1); + List<FnApp> appsFinalList = appList.stream() + .filter(app -> app.getEnabled() && !app.getOpen()).collect(Collectors.toList()); + + List<OnboardingApp> onboardingAppsList = new ArrayList<>(); + for (FnApp app : appsFinalList) { + OnboardingApp onboardingApp = new OnboardingApp(); + appsService.createOnboardingFromApp(app, onboardingApp); + onboardingAppsList.add(onboardingApp); + } + return onboardingAppsList; + } + + public FnApp getApp(Long appId) { + refreshAppsMap(quickRefreshCacheConf); + FnApp app = appsMap.get(appId); + return app; + } + + public FnApp getAppFromUeb(String appKey) { + return getAppFromUeb(appKey,0); + } + + public FnApp getAppFromUeb(String appKey, Integer quickCacheRefresh) { + refreshAppsMap(quickCacheRefresh == 1 ? quickRefreshCacheConf:slowRefreshCacheConf); + FnApp app = uebAppsMap.get(appKey); + return app; + } + +} diff --git a/portal-BE/src/main/java/org/onap/portal/utils/EcompPortalUtils.java b/portal-BE/src/main/java/org/onap/portal/utils/EcompPortalUtils.java index 9e3a5d4b..ed03f4a2 100644 --- a/portal-BE/src/main/java/org/onap/portal/utils/EcompPortalUtils.java +++ b/portal-BE/src/main/java/org/onap/portal/utils/EcompPortalUtils.java @@ -103,7 +103,7 @@ public class EcompPortalUtils { * @return List of tokens split from the source */ public static List<String> parsingByRegularExpression(String source, String regex) { - List<String> tokens = new ArrayList<String>(); + List<String> tokens = new ArrayList<>(); if (source != null && source.length() > 0) { String[] parsed = source.split(regex); for (String token : parsed) { @@ -225,7 +225,7 @@ public class EcompPortalUtils { String responseCode = MDC.get(EPCommonSystemProperties.EXTERNAL_API_RESPONSE_CODE); int responseCodeInt = 0; try { - if (responseCode != null && responseCode != "") { + if (responseCode != null && !responseCode.isEmpty()) { responseCodeInt = Integer.valueOf(responseCode); } } catch (Exception e) { @@ -530,7 +530,7 @@ public class EcompPortalUtils { logger.error(EELFLoggerDelegate.errorLogger, "Please check in system.properties whether the property exists or not!"); return false; - } else if (new Boolean(rmtCentralAccess)) { + } else if (Boolean.valueOf(rmtCentralAccess)) { logger.debug(EELFLoggerDelegate.debugLogger, "checkIfRemoteCentralAccessAllowed: {}", rmtCentralAccess); result = true; } diff --git a/portal-BE/src/main/java/org/onap/portal/utils/PortalConstants.java b/portal-BE/src/main/java/org/onap/portal/utils/PortalConstants.java index 0379bbe6..521826f8 100644 --- a/portal-BE/src/main/java/org/onap/portal/utils/PortalConstants.java +++ b/portal-BE/src/main/java/org/onap/portal/utils/PortalConstants.java @@ -41,13 +41,13 @@ package org.onap.portal.utils; public interface PortalConstants { - public static final Long PORTAL_APP_ID = 1L; - public static final Long DEFAULT_NOTIFICATION_CREATOR = 1L; - public static final String REST_AUX_API = "/auxapi"; - public static final String PORTAL_AUX_API = "/portalApi"; - public static final Long ACCOUNT_ADMIN_ROLE_ID = 999L; - public static final Long SYS_ADMIN_ROLE_ID = 1L; - public static final String ADMIN_ROLE = "Account Administrator"; - public static final String PORTAL_ADMIN_ROLE = "System Administrator"; - public static final Integer AUDIT_LOG_COMMENT_SIZE = 990; + Long PORTAL_APP_ID = 1L; + Long DEFAULT_NOTIFICATION_CREATOR = 1L; + String REST_AUX_API = "/auxapi"; + String PORTAL_AUX_API = "/portalApi"; + Long ACCOUNT_ADMIN_ROLE_ID = 999L; + Long SYS_ADMIN_ROLE_ID = 1L; + String ADMIN_ROLE = "Account Administrator"; + String PORTAL_ADMIN_ROLE = "System Administrator"; + Integer AUDIT_LOG_COMMENT_SIZE = 990; } diff --git a/portal-BE/src/main/resources/application.properties b/portal-BE/src/main/resources/application.properties index e31dcc30..30c0beeb 100644 --- a/portal-BE/src/main/resources/application.properties +++ b/portal-BE/src/main/resources/application.properties @@ -1,16 +1,21 @@ server.port=8080 -spring.datasource.url=jdbc:mysql://localhost:3306/testdb?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC +spring.datasource.url=jdbc:mysql://portal-db:3306/testdb?createDatabaseIfNotExist=true&useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver spring.datasource.initialization-mode=always spring.session.jdbc.initialize-schema=always spring.datasource.continueOnError=true -spring.datasource.username=root -spring.datasource.password=root +spring.datasource.username=portal +spring.datasource.password=Test123456 +log4j.logger.org.hibernate=info + +#H2 config +spring.h2.console.settings.web-allow-others=true +spring.h2.console.enabled=true spring.jpa.database-platform=org.hibernate.dialect.MariaDBDialect spring.jpa.hibernate.ddl-auto=update spring.jpa.database=mysql spring.jpa.show-sql=true -spring.jooq.sql-dialect=MARIADB +spring.jooq.sql-dialect=MARIADB
\ No newline at end of file diff --git a/portal-BE/src/main/resources/data.sql b/portal-BE/src/main/resources/data.sql index f6d8f6e0..a1b8e8a3 100644 --- a/portal-BE/src/main/resources/data.sql +++ b/portal-BE/src/main/resources/data.sql @@ -462,7 +462,7 @@ UNLOCK TABLES; LOCK TABLES `fn_user` WRITE; /*!40000 ALTER TABLE `fn_user` DISABLE KEYS */; -INSERT INTO `fn_user` (`user_id`, `org_id`, `manager_id`, `first_name`, `middle_name`, `last_name`, `phone`, `fax`, `cellular`, `email`, `address_id`, `alert_method_cd`, `hrid`, `org_user_id`, `org_code`, `login_id`, `login_pwd`, `last_login_date`, `active_yn`, `created_id`, `created_date`, `modified_id`, `modified_date`, `is_internal_yn`, `address_line_1`, `address_line_2`, `city`, `state_cd`, `zip_code`, `country_cd`, `location_clli`, `org_manager_userid`, `company`, `department_name`, `job_title`, `timezone`, `department`, `business_unit`, `business_unit_name`, `cost_center`, `fin_loc_code`, `silo_status`, `language_id`) VALUES (1,NULL,NULL,'Demo',NULL,'User',NULL,NULL,NULL,'demo@openecomp.org',NULL,NULL,NULL,'demo',NULL,'demo','4Gl6WL1bmwviYm+XZa6pS1vC0qKXWtn9wcZWdLx61L0=','2019-08-08 12:18:17','Y',NULL,'2016-10-14 21:00:00',1,'2019-08-08 12:18:17','N',NULL,NULL,NULL,'NJ',NULL,'US',NULL,NULL,NULL,NULL,NULL,10,NULL,NULL,NULL,NULL,NULL,NULL,1),(2,NULL,NULL,'Jimmy',NULL,'Hendrix',NULL,NULL,NULL,'admin@onap.org',NULL,NULL,NULL,'jh0003',NULL,'jh0003','4Gl6WL1bmwviYm+XZa6pS1vC0qKXWtn9wcZWdLx61L0=','2019-08-08 10:16:11','Y',NULL,'2016-10-14 21:00:00',1,'2019-08-08 10:16:11','N',NULL,NULL,NULL,'NJ',NULL,'US',NULL,NULL,NULL,NULL,NULL,10,NULL,NULL,NULL,NULL,NULL,NULL,1),(3,NULL,NULL,'Carlos',NULL,'Santana',NULL,NULL,NULL,'designer@onap.org',NULL,NULL,NULL,'cs0008',NULL,'cs0008','4Gl6WL1bmwviYm+XZa6pS1vC0qKXWtn9wcZWdLx61L0=','2016-10-20 15:11:16','Y',NULL,'2016-10-14 21:00:00',1,'2016-10-20 15:11:16','N',NULL,NULL,NULL,'NJ',NULL,'US',NULL,NULL,NULL,NULL,NULL,10,NULL,NULL,NULL,NULL,NULL,NULL,1),(4,NULL,NULL,'Joni',NULL,'Mitchell',NULL,NULL,NULL,'tester@onap.org',NULL,NULL,NULL,'jm0007',NULL,'jm0007','4Gl6WL1bmwviYm+XZa6pS1vC0qKXWtn9wcZWdLx61L0=','2016-10-20 15:11:16','Y',NULL,'2016-10-14 21:00:00',1,'2016-10-20 15:11:16','N',NULL,NULL,NULL,'NJ',NULL,'US',NULL,NULL,NULL,NULL,NULL,10,NULL,NULL,NULL,NULL,NULL,NULL,1),(5,NULL,NULL,'Steve',NULL,'Regev',NULL,NULL,NULL,'ops@onap.org',NULL,NULL,NULL,'op0001',NULL,'op0001','4Gl6WL1bmwviYm+XZa6pS1vC0qKXWtn9wcZWdLx61L0=','2016-10-20 15:11:16','Y',NULL,'2016-10-14 21:00:00',1,'2016-10-20 15:11:16','N',NULL,NULL,NULL,'NJ',NULL,'US',NULL,NULL,NULL,NULL,NULL,10,NULL,NULL,NULL,NULL,NULL,NULL,1),(6,NULL,NULL,'David',NULL,'Shadmi',NULL,NULL,NULL,'governor@onap.org',NULL,NULL,NULL,'gv0001',NULL,'gv0001','4Gl6WL1bmwviYm+XZa6pS1vC0qKXWtn9wcZWdLx61L0=','2016-10-20 15:11:16','Y',NULL,'2016-10-14 21:00:00',1,'2016-10-20 15:11:16','N',NULL,NULL,NULL,'NJ',NULL,'US',NULL,NULL,NULL,NULL,NULL,10,NULL,NULL,NULL,NULL,NULL,NULL,1),(7,NULL,NULL,'Teddy',NULL,'Isashar',NULL,NULL,NULL,'pm1@onap.org',NULL,NULL,NULL,'pm0001',NULL,'pm0001','4Gl6WL1bmwviYm+XZa6pS1vC0qKXWtn9wcZWdLx61L0=','2016-10-20 15:11:16','Y',NULL,'2016-10-14 21:00:00',1,'2016-10-20 15:11:16','N',NULL,NULL,NULL,'NJ',NULL,'US',NULL,NULL,NULL,NULL,NULL,10,NULL,NULL,NULL,NULL,NULL,NULL,1),(8,NULL,NULL,'Eden',NULL,'Rozin',NULL,NULL,NULL,'ps1@onap.org',NULL,NULL,NULL,'ps0001',NULL,'ps0001','4Gl6WL1bmwviYm+XZa6pS1vC0qKXWtn9wcZWdLx61L0=','2016-10-20 15:11:16','Y',NULL,'2016-10-14 21:00:00',1,'2016-10-20 15:11:16','N',NULL,NULL,NULL,'NJ',NULL,'US',NULL,NULL,NULL,NULL,NULL,10,NULL,NULL,NULL,NULL,NULL,NULL,1),(9,NULL,NULL,'vid1',NULL,'user',NULL,NULL,NULL,'vid1@onap.org',NULL,NULL,NULL,'vid1',NULL,'vid1','4Gl6WL1bmwviYm+XZa6pS1vC0qKXWtn9wcZWdLx61L0=','2016-10-20 15:11:16','Y',NULL,'2016-10-14 21:00:00',1,'2016-10-20 15:11:16','N',NULL,NULL,NULL,'NJ',NULL,'US',NULL,NULL,NULL,NULL,NULL,10,NULL,NULL,NULL,NULL,NULL,NULL,1),(10,NULL,NULL,'vid2',NULL,'user',NULL,NULL,NULL,'vid2@onap.org',NULL,NULL,NULL,'vid2',NULL,'vid2','4Gl6WL1bmwviYm+XZa6pS1vC0qKXWtn9wcZWdLx61L0=','2016-10-20 15:11:16','Y',NULL,'2016-10-14 21:00:00',1,'2016-10-20 15:11:16','N',NULL,NULL,NULL,'NJ',NULL,'US',NULL,NULL,NULL,NULL,NULL,10,NULL,NULL,NULL,NULL,NULL,NULL,1),(11,NULL,NULL,'vid3',NULL,'user',NULL,NULL,NULL,'vid3@onap.org',NULL,NULL,NULL,'vid3',NULL,'vid3','4Gl6WL1bmwviYm+XZa6pS1vC0qKXWtn9wcZWdLx61L0=','2016-10-20 15:11:16','Y',NULL,'2016-10-14 21:00:00',1,'2016-10-20 15:11:16','N',NULL,NULL,NULL,'NJ',NULL,'US',NULL,NULL,NULL,NULL,NULL,10,NULL,NULL,NULL,NULL,NULL,NULL,1),(12,NULL,NULL,'steve',NULL,'user',NULL,NULL,NULL,'steve@onap.org',NULL,NULL,NULL,'steve',NULL,'steve','4Gl6WL1bmwviYm+XZa6pS1vC0qKXWtn9wcZWdLx61L0=','2017-05-19 15:11:16','Y',NULL,'2017-05-19 21:00:00',1,'2017-05-19 15:11:16','N',NULL,NULL,NULL,'NJ',NULL,'US',NULL,NULL,NULL,NULL,NULL,10,NULL,NULL,NULL,NULL,NULL,NULL,1); +INSERT INTO `fn_user` (`user_id`, `org_id`, `manager_id`, `first_name`, `middle_name`, `last_name`, `phone`, `fax`, `cellular`, `email`, `address_id`, `alert_method_cd`, `hrid`, `org_user_id`, `org_code`, `login_id`, `login_pwd`, `last_login_date`, `active_yn`, `created_id`, `created_date`, `modified_id`, `modified_date`, `is_internal_yn`, `address_line_1`, `address_line_2`, `city`, `state_cd`, `zip_code`, `country_cd`, `location_clli`, `org_manager_userid`, `company`, `department_name`, `job_title`, `timezone`, `department`, `business_unit`, `business_unit_name`, `cost_center`, `fin_loc_code`, `silo_status`, `language_id`) VALUES (1,NULL,NULL,'Demo',NULL,'User',NULL,NULL,NULL,'demo@openecomp.org',NULL,NULL,NULL,'demo',NULL,'demo','demo123','2019-08-08 12:18:17','Y',NULL,'2016-10-14 21:00:00',1,'2019-08-08 12:18:17','N',NULL,NULL,NULL,'NJ',NULL,'US',NULL,NULL,NULL,NULL,NULL,10,NULL,NULL,NULL,NULL,NULL,NULL,1),(2,NULL,NULL,'Jimmy',NULL,'Hendrix',NULL,NULL,NULL,'admin@onap.org',NULL,NULL,NULL,'jh0003',NULL,'jh0003','demo123','2019-08-08 10:16:11','Y',NULL,'2016-10-14 21:00:00',1,'2019-08-08 10:16:11','N',NULL,NULL,NULL,'NJ',NULL,'US',NULL,NULL,NULL,NULL,NULL,10,NULL,NULL,NULL,NULL,NULL,NULL,1),(3,NULL,NULL,'Carlos',NULL,'Santana',NULL,NULL,NULL,'designer@onap.org',NULL,NULL,NULL,'cs0008',NULL,'cs0008','demo123','2016-10-20 15:11:16','Y',NULL,'2016-10-14 21:00:00',1,'2016-10-20 15:11:16','N',NULL,NULL,NULL,'NJ',NULL,'US',NULL,NULL,NULL,NULL,NULL,10,NULL,NULL,NULL,NULL,NULL,NULL,1),(4,NULL,NULL,'Joni',NULL,'Mitchell',NULL,NULL,NULL,'tester@onap.org',NULL,NULL,NULL,'jm0007',NULL,'jm0007','demo123','2016-10-20 15:11:16','Y',NULL,'2016-10-14 21:00:00',1,'2016-10-20 15:11:16','N',NULL,NULL,NULL,'NJ',NULL,'US',NULL,NULL,NULL,NULL,NULL,10,NULL,NULL,NULL,NULL,NULL,NULL,1),(5,NULL,NULL,'Steve',NULL,'Regev',NULL,NULL,NULL,'ops@onap.org',NULL,NULL,NULL,'op0001',NULL,'op0001','demo123','2016-10-20 15:11:16','Y',NULL,'2016-10-14 21:00:00',1,'2016-10-20 15:11:16','N',NULL,NULL,NULL,'NJ',NULL,'US',NULL,NULL,NULL,NULL,NULL,10,NULL,NULL,NULL,NULL,NULL,NULL,1),(6,NULL,NULL,'David',NULL,'Shadmi',NULL,NULL,NULL,'governor@onap.org',NULL,NULL,NULL,'gv0001',NULL,'gv0001','demo123','2016-10-20 15:11:16','Y',NULL,'2016-10-14 21:00:00',1,'2016-10-20 15:11:16','N',NULL,NULL,NULL,'NJ',NULL,'US',NULL,NULL,NULL,NULL,NULL,10,NULL,NULL,NULL,NULL,NULL,NULL,1),(7,NULL,NULL,'Teddy',NULL,'Isashar',NULL,NULL,NULL,'pm1@onap.org',NULL,NULL,NULL,'pm0001',NULL,'pm0001','demo123','2016-10-20 15:11:16','Y',NULL,'2016-10-14 21:00:00',1,'2016-10-20 15:11:16','N',NULL,NULL,NULL,'NJ',NULL,'US',NULL,NULL,NULL,NULL,NULL,10,NULL,NULL,NULL,NULL,NULL,NULL,1),(8,NULL,NULL,'Eden',NULL,'Rozin',NULL,NULL,NULL,'ps1@onap.org',NULL,NULL,NULL,'ps0001',NULL,'ps0001','demo123','2016-10-20 15:11:16','Y',NULL,'2016-10-14 21:00:00',1,'2016-10-20 15:11:16','N',NULL,NULL,NULL,'NJ',NULL,'US',NULL,NULL,NULL,NULL,NULL,10,NULL,NULL,NULL,NULL,NULL,NULL,1),(9,NULL,NULL,'vid1',NULL,'user',NULL,NULL,NULL,'vid1@onap.org',NULL,NULL,NULL,'vid1',NULL,'vid1','demo123','2016-10-20 15:11:16','Y',NULL,'2016-10-14 21:00:00',1,'2016-10-20 15:11:16','N',NULL,NULL,NULL,'NJ',NULL,'US',NULL,NULL,NULL,NULL,NULL,10,NULL,NULL,NULL,NULL,NULL,NULL,1),(10,NULL,NULL,'vid2',NULL,'user',NULL,NULL,NULL,'vid2@onap.org',NULL,NULL,NULL,'vid2',NULL,'vid2','demo123','2016-10-20 15:11:16','Y',NULL,'2016-10-14 21:00:00',1,'2016-10-20 15:11:16','N',NULL,NULL,NULL,'NJ',NULL,'US',NULL,NULL,NULL,NULL,NULL,10,NULL,NULL,NULL,NULL,NULL,NULL,1),(11,NULL,NULL,'vid3',NULL,'user',NULL,NULL,NULL,'vid3@onap.org',NULL,NULL,NULL,'vid3',NULL,'vid3','demo123','2016-10-20 15:11:16','Y',NULL,'2016-10-14 21:00:00',1,'2016-10-20 15:11:16','N',NULL,NULL,NULL,'NJ',NULL,'US',NULL,NULL,NULL,NULL,NULL,10,NULL,NULL,NULL,NULL,NULL,NULL,1),(12,NULL,NULL,'steve',NULL,'user',NULL,NULL,NULL,'steve@onap.org',NULL,NULL,NULL,'steve',NULL,'steve','demo123','2017-05-19 15:11:16','Y',NULL,'2017-05-19 21:00:00',1,'2017-05-19 15:11:16','N',NULL,NULL,NULL,'NJ',NULL,'US',NULL,NULL,NULL,NULL,NULL,10,NULL,NULL,NULL,NULL,NULL,NULL,1); /*!40000 ALTER TABLE `fn_user` ENABLE KEYS */; UNLOCK TABLES; |