diff options
Diffstat (limited to 'ecomp-portal-BE-common/src/main/java/org/onap')
30 files changed, 325 insertions, 123 deletions
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/DashboardController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/DashboardController.java index d8e8aeb0..4b364995 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/DashboardController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/DashboardController.java @@ -171,8 +171,7 @@ public class DashboardController extends EPRestrictedBaseController { * @return Rest response wrapped around a String; e.g., "success" or "ERROR" */ @RequestMapping(value = "/widgetData", method = RequestMethod.POST, produces = "application/json") - public PortalRestResponse<String> saveWidgetData(@RequestBody CommonWidget commonWidget, HttpServletRequest request, - HttpServletResponse response) { + public PortalRestResponse<String> saveWidgetData(@RequestBody CommonWidget commonWidget, HttpServletRequest request, HttpServletResponse response) { logger.debug(EELFLoggerDelegate.debugLogger, "saveWidgetData: argument is {}", commonWidget); EPUser user = EPUserUtils.getUserSession(request); if (adminRolesService.isSuperAdmin(user)) { diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/ExternalAccessRolesController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/ExternalAccessRolesController.java index 0be015ee..ff254e85 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/ExternalAccessRolesController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/ExternalAccessRolesController.java @@ -39,6 +39,7 @@ package org.onap.portalapp.portal.controller; import java.io.IOException; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -69,10 +70,15 @@ import org.onap.portalapp.portal.utils.PortalConstants; import org.onap.portalsdk.core.domain.AuditLog; import org.onap.portalsdk.core.domain.Role; import org.onap.portalsdk.core.domain.RoleFunction; +import org.onap.portalsdk.core.domain.User; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.onap.portalsdk.core.restful.domain.EcompRole; import org.onap.portalsdk.core.restful.domain.EcompUser; import org.onap.portalsdk.core.service.AuditService; +import org.onap.portalsdk.core.service.UserService; +import org.onap.portalsdk.core.service.UserServiceCentalizedImpl; import org.onap.portalsdk.core.util.SystemProperties; +import org.onap.portalsdk.core.web.support.UserUtils; import org.slf4j.MDC; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -87,6 +93,7 @@ import org.springframework.web.client.RestTemplate; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.type.TypeFactory; import io.swagger.annotations.ApiOperation; @@ -117,6 +124,9 @@ public class ExternalAccessRolesController implements BasicAuthenticationControl @Autowired private ExternalAccessRolesService externalAccessRolesService; + @Autowired + private UserService userservice = new UserServiceCentalizedImpl(); + @ApiOperation(value = "Gets user role for an application.", response = CentralUser.class, responseContainer="List") @RequestMapping(value = { "/user/{loginId}" }, method = RequestMethod.GET, produces = "application/json") @@ -804,4 +814,56 @@ public class ExternalAccessRolesController implements BasicAuthenticationControl response.setStatus(HttpServletResponse.SC_BAD_REQUEST); } } + + @ApiOperation(value = "Gets ecompUser of an application.", response = CentralUser.class, responseContainer = "List") + @RequestMapping(value = { "/ecompUser/{loginId}" }, method = RequestMethod.GET, produces = "application/json") + public String getEcompUser(HttpServletRequest request, HttpServletResponse response, + @PathVariable("loginId") String loginId) throws Exception { + EcompUser user = new EcompUser(); + ObjectMapper mapper = new ObjectMapper(); + CentralUser answer = null; + try { + fieldsValidation(request); + answer = externalAccessRolesService.getUserRoles(loginId, request.getHeader(UEBKEY)); + if (answer != null) { + String res = mapper.writeValueAsString(answer); + User ecompUser = userservice.userMapper(res); + user = UserUtils.convertToEcompUser(ecompUser); + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "getEcompUser failed", e); + throw e; + } + return mapper.writeValueAsString(user); + } + + @ApiOperation(value = "Gets user ecomp role for an application.", response = CentralUser.class, responseContainer = "List") + @RequestMapping(value = { "/ecompRoles" }, method = RequestMethod.GET, produces = "application/json") + public List<EcompRole> getEcompRolesOfApplication(HttpServletRequest request, HttpServletResponse response) + throws Exception { + List<EcompRole> ecompRoles = new ArrayList<EcompRole>(); + ObjectMapper mapper = new ObjectMapper(); + List<CentralV2Role> cenRole = null; + try { + fieldsValidation(request); + EPApp app = externalAccessRolesService.getApp(request.getHeader(UEBKEY)).get(0); + // Sync all roles from external system into Ecomp portal DB + logger.debug(EELFLoggerDelegate.debugLogger, "getRolesForApp: Entering into syncApplicationRolesWithEcompDB"); + externalAccessRolesService.syncApplicationRolesWithEcompDB(app); + logger.debug(EELFLoggerDelegate.debugLogger, "getRolesForApp: Finished syncApplicationRolesWithEcompDB"); + cenRole = externalAccessRolesService.getActiveRoles(request.getHeader(UEBKEY)); + } catch (Exception e) { + sendErrorResponse(response, e); + logger.error(EELFLoggerDelegate.errorLogger, "getActiveRoles failed", e); + } + String res = mapper.writeValueAsString(cenRole); + if (res != null) { + List<Role> roles = mapper.readValue(res, + TypeFactory.defaultInstance().constructCollectionType(List.class, Role.class)); + for (Role role : roles) + ecompRoles.add(UserUtils.convertToEcompRole(role)); + logger.debug(EELFLoggerDelegate.debugLogger, "Request completed for getEcompRolesOfApplication"); + } + return ecompRoles; + } } diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/SchedulerAuxController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/SchedulerAuxController.java index c676fa98..fce1f387 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/SchedulerAuxController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/SchedulerAuxController.java @@ -58,11 +58,6 @@ import org.onap.portalapp.portal.utils.PortalConstants; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.EnableAspectJAutoProxy; -/*import org.openecomp.vid.policy.PolicyProperties; -import org.openecomp.vid.policy.PolicyResponseWrapper; -import org.openecomp.vid.policy.PolicyRestInterfaceFactory; -import org.openecomp.vid.policy.PolicyRestInterfaceIfc; -import org.openecomp.vid.policy.PolicyUtil;*/ import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RequestMapping; diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/EPUserAppsManualSortPreference.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/EPUserAppsManualSortPreference.java index 4d943f62..b597b9d2 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/EPUserAppsManualSortPreference.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/EPUserAppsManualSortPreference.java @@ -42,14 +42,14 @@ import org.onap.portalsdk.core.domain.support.DomainVo; public class EPUserAppsManualSortPreference extends DomainVo { private static final long serialVersionUID = -6270136291139278216L; - private int userId; + private Long userId; private Long appId; private int appManualSortOrder; - public int getUserId() { + public Long getUserId() { return userId; } - public void setUserId(int userId) { + public void setUserId(Long userId) { this.userId = userId; } public Long getAppId() { diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/EPWidgetsManualSortPreference.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/EPWidgetsManualSortPreference.java index 552e2e0f..9c324047 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/EPWidgetsManualSortPreference.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/EPWidgetsManualSortPreference.java @@ -42,17 +42,17 @@ import org.onap.portalsdk.core.domain.support.DomainVo; public class EPWidgetsManualSortPreference extends DomainVo{ private static final long serialVersionUID = 4607102334801223570L; - private int userId; + private Long userId; private Long widgetId; private int widgetRow; private int widgetCol; private int widgetWidth; private int widgetHeight; - public int getUserId() { + public Long getUserId() { return userId; } - public void setUserId(int userId) { + public void setUserId(Long userId) { this.userId = userId; } public Long getWidgetId() { diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/ExternalSystemAccess.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/ExternalSystemAccess.java index 29b4fe35..c7d5d207 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/ExternalSystemAccess.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/ExternalSystemAccess.java @@ -61,6 +61,37 @@ public class ExternalSystemAccess { public void setAccessValue(Boolean accessValue) { this.accessValue = accessValue; } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((accessValue == null) ? 0 : accessValue.hashCode()); + result = prime * result + ((key == null) ? 0 : key.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + ExternalSystemAccess other = (ExternalSystemAccess) obj; + if (accessValue == null) { + if (other.accessValue != null) + return false; + } else if (!accessValue.equals(other.accessValue)) + return false; + if (key == null) { + if (other.key != null) + return false; + } else if (!key.equals(other.key)) + return false; + return true; + } diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/FunctionalMenuItemWithAppID.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/FunctionalMenuItemWithAppID.java index a9455d61..ecb17875 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/FunctionalMenuItemWithAppID.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/FunctionalMenuItemWithAppID.java @@ -47,7 +47,7 @@ import javax.persistence.Id; import javax.persistence.Transient; /*** * - * This class is almost identical to org.openecomp.portalapp.portal.transport.FunctionalMenuItem + * This class is almost identical to org.onap.portalapp.portal.transport.FunctionalMenuItem * The only difference is the appId field. In FunctionMenuItem, we used @Transient as an attribute, and we are using @Column in this class. * In some sql queries, we need to have appId, but it's not a field in fn_menu_functional table. * diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/exceptions/SyncUserRolesException.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/exceptions/SyncUserRolesException.java new file mode 100644 index 00000000..f7f19a5f --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/exceptions/SyncUserRolesException.java @@ -0,0 +1,48 @@ +/*- + * ============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============================================ + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ + +package org.onap.portalapp.portal.exceptions; + +@SuppressWarnings("serial") +public class SyncUserRolesException extends Exception{ + + public SyncUserRolesException(String msg) { + super(msg); + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/interceptor/PortalResourceInterceptor.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/interceptor/PortalResourceInterceptor.java index 5d2f399b..8cf20ba8 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/interceptor/PortalResourceInterceptor.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/interceptor/PortalResourceInterceptor.java @@ -245,7 +245,7 @@ public class PortalResourceInterceptor extends ResourceInterceptor { BasicAuthCredentials creds; try { creds = basicAuthService.getBasicAuthCredentialByUsernameAndPassword(accountNamePassword[0], - encrypted(accountNamePassword[1])); + accountNamePassword[1]); } catch (Exception e) { logger.error(EELFLoggerDelegate.errorLogger, "checkBasicAuth failed to get credentials", e); final String msg = "Failed while getting basic authentication credential: "; diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/logging/format/EPErrorCodesEnum.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/logging/format/EPErrorCodesEnum.java index e4cd38e7..b505eedd 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/logging/format/EPErrorCodesEnum.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/logging/format/EPErrorCodesEnum.java @@ -116,6 +116,6 @@ public enum EPErrorCodesEnum implements EELFResolvableErrorEnum { * Here this application loads messages from three bundles */ static { - EELFResourceManager.loadMessageBundle("org/openecomp/portalapp/portal/logging/format/ApplicationCodes"); + EELFResourceManager.loadMessageBundle("org/onap/portalapp/portal/logging/format/ApplicationCodes"); } } diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduler/client/HttpsBasicClient.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduler/client/HttpsBasicClient.java index 53848e02..3caede7e 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduler/client/HttpsBasicClient.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduler/client/HttpsBasicClient.java @@ -80,7 +80,7 @@ public class HttpsBasicClient{ String methodName = "getClient"; ClientConfig config = new ClientConfig(); //config.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE); - //config.getClasses().add(org.openecomp.aai.util.CustomJacksonJaxBJsonProvider.class); + //config.getClasses().add(org.onap.aai.util.CustomJacksonJaxBJsonProvider.class); SSLContext ctx = null; diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduleraux/SchedulerAuxUtil.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduleraux/SchedulerAuxUtil.java index 678073c8..0a935ae4 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduleraux/SchedulerAuxUtil.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduleraux/SchedulerAuxUtil.java @@ -43,9 +43,6 @@ import java.util.Date; import org.glassfish.jersey.client.ClientResponse; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; -/*import org.openecomp.vid.policy.PolicyResponseWrapper; -import org.openecomp.vid.policy.PolicyUtil; -import org.openecomp.vid.policy.RestObject;*/ import com.fasterxml.jackson.databind.ObjectMapper; diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/AppContactUsServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/AppContactUsServiceImpl.java index edffafc3..67e2ae32 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/AppContactUsServiceImpl.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/AppContactUsServiceImpl.java @@ -74,7 +74,7 @@ public class AppContactUsServiceImpl implements AppContactUsService { /* * (non-Javadoc) * - * @see org.openecomp.portalapp.portal.service.AppContactUsService# + * @see org.onap.portalapp.portal.service.AppContactUsService# * getAppContactUs() */ @SuppressWarnings("unchecked") @@ -89,7 +89,7 @@ public class AppContactUsServiceImpl implements AppContactUsService { /* * (non-Javadoc) * - * @see org.openecomp.portalapp.portal.service.AppContactUsService# + * @see org.onap.portalapp.portal.service.AppContactUsService# * getAllAppsAndContacts() */ @SuppressWarnings("unchecked") diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ApplicationsRestClientServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ApplicationsRestClientServiceImpl.java index 18717204..1460a61c 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ApplicationsRestClientServiceImpl.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ApplicationsRestClientServiceImpl.java @@ -53,7 +53,6 @@ import javax.ws.rs.core.Response; import org.apache.commons.lang.StringUtils; import org.apache.cxf.jaxrs.client.WebClient; import org.apache.cxf.transport.http.HTTPException; -import org.onap.portalapp.portal.service.AppsCacheService; import org.onap.portalapp.portal.domain.EPApp; import org.onap.portalapp.portal.logging.aop.EPAuditLog; import org.onap.portalapp.portal.logging.aop.EPMetricsLog; @@ -252,7 +251,7 @@ public class ApplicationsRestClientServiceImpl implements ApplicationsRestClient * (non-Javadoc) * * @see - * org.openecomp.portalapp.portal.service.ApplicationsRestClientService#get( + * org.onap.portalapp.portal.service.ApplicationsRestClientService#get( * java.lang.Class, long, java.lang.String, boolean) */ @Override @@ -354,13 +353,15 @@ public class ApplicationsRestClientServiceImpl implements ApplicationsRestClient WebClient client = null; Response response = null; T t = null; - + logger.debug(EELFLoggerDelegate.debugLogger, "Entering to createClientForApp method for payload: {} and restPath: {} and appId: {}", payload.toString(), restPath, appId); client = createClientForApp(appId, restPath); EcompPortalUtils.logAndSerializeObject(logger, restPath, "POST request =", payload); - + logger.debug(EELFLoggerDelegate.debugLogger, "Finished createClientForApp method for payload: {} and restPath: {} and appId: {}", payload.toString(), restPath, appId); try { if (client != null) { + logger.debug(EELFLoggerDelegate.debugLogger, "Entering to POST for payload: {} and restPath: {} and appId: {}", payload.toString(), restPath, appId); response = client.post(payload); + logger.debug(EELFLoggerDelegate.debugLogger, "Finished to POST for payload: {} and restPath: {} and appId: {}", payload.toString(), restPath, appId); } else { logger.error(EELFLoggerDelegate.errorLogger, "Unable to create the Webclient to make the '" + restPath + "' API call."); @@ -396,12 +397,21 @@ public class ApplicationsRestClientServiceImpl implements ApplicationsRestClient Response response = null; T t = null; + logger.debug(EELFLoggerDelegate.debugLogger, "Entering to createClientForApp method for payload: {} and restPath: {} and appId: {}", payload.toString(), restPath, appId); + client = createClientForApp(appId, restPath); EcompPortalUtils.logAndSerializeObject(logger, restPath, "PUT request =", payload); + + logger.debug(EELFLoggerDelegate.debugLogger, "Finished createClientForApp method for payload: {} and restPath: {} and appId: {}", payload.toString(), restPath, appId); try { if (client != null) { + logger.debug(EELFLoggerDelegate.debugLogger, "Entering to PUT for payload: {} and restPath: {} and appId: {}", payload.toString(), restPath, appId); + response = client.put(payload); + + logger.debug(EELFLoggerDelegate.debugLogger, "Finished to PUT for payload: {} and restPath: {} and appId: {}", payload.toString(), restPath, appId); + } else { logger.error(EELFLoggerDelegate.errorLogger, "Unable to create the Webclient to make the '" + restPath + "' API call."); diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/BasicAuthenticationCredentialServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/BasicAuthenticationCredentialServiceImpl.java index b50eb391..7241059e 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/BasicAuthenticationCredentialServiceImpl.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/BasicAuthenticationCredentialServiceImpl.java @@ -47,7 +47,10 @@ import org.onap.portalapp.portal.domain.EPEndpoint; import org.onap.portalapp.portal.domain.EPEndpointAccount; import org.onap.portalapp.portal.logging.aop.EPMetricsLog; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.onap.portalsdk.core.onboarding.exception.CipherUtilException; +import org.onap.portalsdk.core.onboarding.util.CipherUtil; import org.onap.portalsdk.core.service.DataAccessService; +import org.onap.portalsdk.core.util.SystemProperties; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.stereotype.Service; @@ -68,20 +71,31 @@ public class BasicAuthenticationCredentialServiceImpl implements BasicAuthentica List<Criterion> restrictionsList = new ArrayList<Criterion>(); Criterion contextUserNameCrit = Restrictions.eq("username", username); restrictionsList.add(contextUserNameCrit); - Criterion contextPasswordCrit = Restrictions.eq("password", password); - restrictionsList.add(contextPasswordCrit); @SuppressWarnings("unchecked") List<BasicAuthCredentials> credList = (List<BasicAuthCredentials>) dataAccessService .getList(BasicAuthCredentials.class, null, restrictionsList, null); - if (credList == null || credList.size() == 0) { + if (credList ==null || credList.isEmpty()) { logger.error(EELFLoggerDelegate.errorLogger, "getBasicAuthCredentialByAppName: no credential(s) for " + username); return null; } logger.debug(EELFLoggerDelegate.debugLogger, "getBasicAuthCredentialByAppName: cred list size: " + credList.size()); - BasicAuthCredentials cred = (BasicAuthCredentials) credList.get(0); + BasicAuthCredentials cred = null; + for (BasicAuthCredentials basicAuthCredentials : credList) { + try { + final String dbDecryptedPwd = CipherUtil.decryptPKC(basicAuthCredentials.getPassword()); + if (dbDecryptedPwd.equals(password)) { + cred= (BasicAuthCredentials) basicAuthCredentials; + break; + } + } catch (CipherUtilException e) { + logger.error(EELFLoggerDelegate.errorLogger, "getBasicAuthCredentialByUsernameAndPassword() failed", e); + } + + } + if (cred!=null && cred.getId()!=null) cred.setEndpoints(getEndpointsByAccountId(cred.getId())); return cred; } diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/EPAppCommonServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/EPAppCommonServiceImpl.java index 8c055b2d..b2e9ebc5 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/EPAppCommonServiceImpl.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/EPAppCommonServiceImpl.java @@ -100,7 +100,6 @@ import com.att.nsa.cambria.client.CambriaClient.CambriaApiException; import com.att.nsa.cambria.client.CambriaClientBuilders; import com.att.nsa.cambria.client.CambriaIdentityManager; import com.att.nsa.cambria.client.CambriaTopicManager; -import com.google.common.primitives.Ints; public class EPAppCommonServiceImpl implements EPAppService { @@ -515,8 +514,8 @@ public class EPAppCommonServiceImpl implements EPAppService { * (non-Javadoc) * * @see - * org.openecomp.portalapp.portal.service.EPAppService#getAppCatalog( - * org.openecomp.portalapp.portal.domain.EPUser) + * org.onap.portalapp.portal.service.EPAppService#getAppCatalog( + * org.onap.portalapp.portal.domain.EPUser) */ @Override public List<AppCatalogItem> getUserAppCatalog(EPUser user) { @@ -532,8 +531,8 @@ public class EPAppCommonServiceImpl implements EPAppService { * (non-Javadoc) * * @see - * org.openecomp.portalapp.portal.service.EPAppService#getAdminAppCatalog( - * org.openecomp.portalapp.portal.domain.EPUser) + * org.onap.portalapp.portal.service.EPAppService#getAdminAppCatalog( + * org.onap.portalapp.portal.domain.EPUser) */ @Override public List<AppCatalogItem> getAdminAppCatalog(EPUser user) { @@ -1404,7 +1403,7 @@ public class EPAppCommonServiceImpl implements EPAppService { epWidgetsManualSort.setWidgetCol(epWidgetsManPref.getCol()); epWidgetsManualSort.setWidgetWidth(epWidgetsManPref.getSizeX()); epWidgetsManualSort.setWidgetHeight(epWidgetsManPref.getSizeY()); - HashMap<String, Integer> additionalUpdateParam = new HashMap<String, Integer>(); + HashMap<String, Long> additionalUpdateParam = new HashMap<>(); additionalUpdateParam.put("userId", epWidgetsManualSort.getUserId()); dataAccessService.saveDomainObject(epWidgetsManualSort, additionalUpdateParam); } else { @@ -1414,7 +1413,7 @@ public class EPAppCommonServiceImpl implements EPAppService { epWidgetsManualSort.setWidgetCol(epWidgetsManPref.getCol()); epWidgetsManualSort.setWidgetWidth(epWidgetsManPref.getSizeX()); epWidgetsManualSort.setWidgetHeight(epWidgetsManPref.getSizeY()); - epWidgetsManualSort.setUserId(Ints.checkedCast(user.getId())); + epWidgetsManualSort.setUserId(user.getId()); dataAccessService.saveDomainObject(epWidgetsManualSort, null); } fieldsValidator.httpStatusCode = new Long(HttpServletResponse.SC_OK); @@ -1485,7 +1484,7 @@ public class EPAppCommonServiceImpl implements EPAppService { EPUserAppsManualSortPreference epAppsManualSort = existingAppIds.get(appid); epAppsManualSort .setAppManualSortOrder((epAppsManPref.getCol() + (6 * epAppsManPref.getRow())) + 1); - HashMap<String, Integer> additionalUpdateParam = new HashMap<String, Integer>(); + HashMap<String, Long> additionalUpdateParam = new HashMap<>(); additionalUpdateParam.put("userId", epAppsManualSort.getUserId()); dataAccessService.saveDomainObject(epAppsManualSort, additionalUpdateParam); } else { @@ -1493,7 +1492,7 @@ public class EPAppCommonServiceImpl implements EPAppService { epAppsManualSort.setAppId(epAppsManPref.getAppid()); epAppsManualSort .setAppManualSortOrder((epAppsManPref.getCol() + (6 * epAppsManPref.getRow())) + 1); - epAppsManualSort.setUserId(Ints.checkedCast(user.getId())); + epAppsManualSort.setUserId(user.getId()); dataAccessService.saveDomainObject(epAppsManualSort, null); } fieldsValidator.httpStatusCode = new Long(HttpServletResponse.SC_OK); @@ -1509,9 +1508,9 @@ public class EPAppCommonServiceImpl implements EPAppService { /* * (non-Javadoc) * - * @see org.openecomp.portalapp.portal.service.EPAppService# + * @see org.onap.portalapp.portal.service.EPAppService# * deleteUserAppSortManual(java.lang.String, - * org.openecomp.portalapp.portal.domain.EPUser) + * org.onap.portalapp.portal.domain.EPUser) */ @SuppressWarnings("unchecked") @Override @@ -1550,7 +1549,7 @@ public class EPAppCommonServiceImpl implements EPAppService { epSortTypes = dataAccessService.executeNamedQuery("userAppsSortPreferenceQuery", params, null); if (epSortTypes.size() == 0) { usrSortPr = new EPUserAppsSortPreference(); - usrSortPr.setUserId(Ints.checkedCast(user.getId())); + usrSortPr.setUserId((int)(long)(user.getId())); usrSortPr.setSortPref(appsSortPreference.getValue()); dataAccessService.saveDomainObject(usrSortPr, null); fieldsValidator.httpStatusCode = new Long(HttpServletResponse.SC_OK); diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/EPAuditServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/EPAuditServiceImpl.java index 1b3dfade..cb94147c 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/EPAuditServiceImpl.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/EPAuditServiceImpl.java @@ -73,7 +73,7 @@ public class EPAuditServiceImpl implements EPAuditService { * (non-Javadoc) * * @see - * org.openecomp.portalapp.portal.service.EPUserService#getGuestLastLogin( + * org.onap.portalapp.portal.service.EPUserService#getGuestLastLogin( * java.lang.String) */ public Date getGuestLastLogin(String userId) { @@ -102,7 +102,7 @@ public class EPAuditServiceImpl implements EPAuditService { * (non-Javadoc) * * @see - * org.openecomp.portalapp.portal.service.EPAuditService#delAuditLogFromDay( + * org.onap.portalapp.portal.service.EPAuditService#delAuditLogFromDay( * ) */ @Override diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/EPLeftMenuServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/EPLeftMenuServiceImpl.java index 98d31b16..243b7261 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/EPLeftMenuServiceImpl.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/EPLeftMenuServiceImpl.java @@ -75,7 +75,7 @@ public class EPLeftMenuServiceImpl implements EPLeftMenuService { * (non-Javadoc) * * @see - * org.openecomp.portalapp.portal.service.EPLeftMenuService#getLeftMenuItems + * org.onap.portalapp.portal.service.EPLeftMenuService#getLeftMenuItems * (java.util.Set) */ @Override diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/EPLoginServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/EPLoginServiceImpl.java index eff297f5..1ec71d78 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/EPLoginServiceImpl.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/EPLoginServiceImpl.java @@ -44,6 +44,7 @@ import java.util.List; import java.util.Map; import java.util.Set; +import org.apache.commons.lang.StringUtils; import org.onap.portalapp.command.EPLoginBean; import org.onap.portalapp.portal.domain.EPUser; import org.onap.portalapp.portal.logging.aop.EPMetricsLog; @@ -52,6 +53,8 @@ import org.onap.portalapp.portal.logging.logic.EPLogUtil; import org.onap.portalapp.util.EPUserUtils; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.onap.portalsdk.core.menu.MenuBuilder; +import org.onap.portalsdk.core.onboarding.exception.CipherUtilException; +import org.onap.portalsdk.core.onboarding.util.CipherUtil; import org.onap.portalsdk.core.service.DataAccessService; import org.onap.portalsdk.core.service.support.FusionService; import org.onap.portalsdk.core.util.SystemProperties; @@ -74,7 +77,7 @@ public class EPLoginServiceImpl extends FusionService implements EPLoginService /* * (non-Javadoc) - * @see org.openecomp.portalapp.portal.service.EPLoginService#findUser(org.openecomp.portalapp.command.EPLoginBean, java.lang.String, java.util.HashMap) + * @see org.onap.portalapp.portal.service.EPLoginService#findUser(org.openecomp.portalapp.command.EPLoginBean, java.lang.String, java.util.HashMap) */ @SuppressWarnings("rawtypes") public EPLoginBean findUser(EPLoginBean bean, String menuPropertiesFilename, HashMap additionalParams) @@ -84,7 +87,7 @@ public class EPLoginServiceImpl extends FusionService implements EPLoginService /* * (non-Javadoc) - * @see org.openecomp.portalapp.portal.service.EPLoginService#findUser(org.openecomp.portalapp.command.EPLoginBean, java.lang.String, java.util.HashMap, boolean) + * @see org.onap.portalapp.portal.service.EPLoginService#findUser(org.onap.portalapp.command.EPLoginBean, java.lang.String, java.util.HashMap, boolean) */ @SuppressWarnings("rawtypes") public EPLoginBean findUser(EPLoginBean bean, String menuPropertiesFilename_ignored, HashMap additionalParams, @@ -179,19 +182,31 @@ public class EPLoginServiceImpl extends FusionService implements EPLoginService * @param password * @return EPUser object; null on error or if no match. */ - @SuppressWarnings("rawtypes") + @SuppressWarnings({ "rawtypes", "unchecked" }) private EPUser findUser(String loginId, String password) { Map<String, String> params = new HashMap<>(); params.put("login_id", loginId); - params.put("login_pwd", password); - List list = null; + List<EPUser> list = null; try { - list = dataAccessService.executeNamedQuery("getEPUserByLoginIdLoginPwd", params, new HashMap()); + list = dataAccessService.executeNamedQuery("getEPUserByLoginId", params, new HashMap()); + for (EPUser user : list) { + try { + if (StringUtils.isNotBlank(user.getLoginPwd())) { + final String dbDecryptedPwd = CipherUtil.decryptPKC(user.getLoginPwd()); + if (dbDecryptedPwd.equals(password)) { + return user; + } + } + } catch (CipherUtilException e) { + logger.error(EELFLoggerDelegate.errorLogger, "findUser() failed", e); + } + } + } catch (Exception e) { EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeDaoSystemError, e); logger.error(EELFLoggerDelegate.errorLogger, "findUser failed on " + loginId, e); } - return (list == null || list.isEmpty()) ? null : (EPUser) list.get(0); + return null; } @SuppressWarnings("rawtypes") diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ExternalAccessRolesService.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ExternalAccessRolesService.java index d65f1152..1d198f76 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ExternalAccessRolesService.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ExternalAccessRolesService.java @@ -49,6 +49,7 @@ import org.onap.portalapp.portal.domain.EPApp; import org.onap.portalapp.portal.domain.EPRole; import org.onap.portalapp.portal.domain.EPUser; import org.onap.portalapp.portal.domain.ExternalRoleDetails; +import org.onap.portalapp.portal.exceptions.InvalidUserException; import org.onap.portalapp.portal.transport.CentralRole; import org.onap.portalapp.portal.transport.CentralUser; import org.onap.portalapp.portal.transport.CentralV2Role; @@ -100,7 +101,7 @@ public interface ExternalAccessRolesService { * @return EPUser object * @throws Exception */ - List<EPUser> getUser(String loginId) throws Exception; + List<EPUser> getUser(String loginId) throws InvalidUserException; /** * It returns complete user information including application roles permissions diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ExternalAccessRolesServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ExternalAccessRolesServiceImpl.java index e867c3d6..af5b5001 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ExternalAccessRolesServiceImpl.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ExternalAccessRolesServiceImpl.java @@ -122,10 +122,8 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.client.HttpClientErrorException; import org.springframework.web.client.RestTemplate; -import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.type.TypeFactory; @@ -1105,10 +1103,14 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic @Override @SuppressWarnings("unchecked") - public List<EPUser> getUser(String loginId){ + public List<EPUser> getUser(String loginId) throws InvalidUserException{ final Map<String, String> userParams = new HashMap<>(); userParams.put("org_user_id", loginId); - return (List<EPUser>) dataAccessService.executeNamedQuery("getEPUserByOrgUserId", userParams, null); + List<EPUser> userList = dataAccessService.executeNamedQuery("getEPUserByOrgUserId", userParams, null); + if (userList.isEmpty()) { + throw new InvalidUserException("User not found"); + } + return userList; } @Override @@ -2777,9 +2779,11 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic extRoleParams.put(APP_ID, app.getId().toString()); roleList = dataAccessService.executeNamedQuery(GET_ROLE_TO_UPDATE_IN_EXTERNAL_AUTH_SYSTEM, extRoleParams, null); } - EPRole updateRoleInactive = roleList.get(0); - updateRoleInactive.setActive(false); - dataAccessService.saveDomainObject(updateRoleInactive, null); + if(!roleList.isEmpty()) { + EPRole updateRoleInactive = roleList.get(0); + updateRoleInactive.setActive(false); + dataAccessService.saveDomainObject(updateRoleInactive, null); + } } } catch (Exception e) { logger.error(EELFLoggerDelegate.errorLogger, @@ -2875,8 +2879,8 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic EPAppRoleFunction checkRoleFunctionExits = roleFunctionsMap.get(externalpermission.getInstance()); if (checkRoleFunctionExits == null) { String funcCode = externalpermission.getType().substring(app.getNameSpace().length() + 1) - + FUNCTION_PIPE + externalAccessPerms.getInstance() + FUNCTION_PIPE - + externalAccessPerms.getAction(); + + FUNCTION_PIPE + externalpermission.getInstance() + FUNCTION_PIPE + + externalpermission.getAction(); EPAppRoleFunction checkRoleFunctionPipeExits = roleFunctionsMap.get(funcCode); if (checkRoleFunctionPipeExits == null) { try { diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/GetAccessServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/GetAccessServiceImpl.java index fb0bf7f7..59385554 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/GetAccessServiceImpl.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/GetAccessServiceImpl.java @@ -62,7 +62,7 @@ public class GetAccessServiceImpl implements GetAccessService{ /* * (non-Javadoc) - * @see org.openecomp.portalapp.portal.service.GetAccessService#getAppAccessList() + * @see org.onap.portalapp.portal.service.GetAccessService#getAppAccessList() */ @SuppressWarnings("unchecked") @Override diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ManifestServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ManifestServiceImpl.java index 6ea66fe1..368c1cf6 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ManifestServiceImpl.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ManifestServiceImpl.java @@ -59,7 +59,7 @@ public class ManifestServiceImpl implements ManifestService { /* * (non-Javadoc) - * @see org.openecomp.portalapp.portal.service.ManifestService#getWebappManifest() + * @see org.onap.portalapp.portal.service.ManifestService#getWebappManifest() */ public Attributes getWebappManifest() throws IOException { EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ManifestServiceImpl.class); diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/PersUserAppServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/PersUserAppServiceImpl.java index 39b88f63..a0b32644 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/PersUserAppServiceImpl.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/PersUserAppServiceImpl.java @@ -38,25 +38,21 @@ package org.onap.portalapp.portal.service; import java.util.ArrayList; -import java.util.HashMap; -import java.util.LinkedHashMap; import java.util.List; -import java.util.Map; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.EnableAspectJAutoProxy; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import org.hibernate.criterion.Criterion; import org.hibernate.criterion.Restrictions; import org.onap.portalapp.portal.domain.EPApp; import org.onap.portalapp.portal.domain.EPUser; import org.onap.portalapp.portal.domain.EPUserApp; import org.onap.portalapp.portal.domain.PersUserAppSelection; -import org.onap.portalapp.portal.domain.PersUserWidgetSelection; import org.onap.portalapp.portal.logging.aop.EPMetricsLog; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.onap.portalsdk.core.service.DataAccessService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; @Service("persUserAppService") @Transactional @@ -81,9 +77,9 @@ public class PersUserAppServiceImpl implements PersUserAppService { /* * (non-Javadoc) * - * @see org.openecomp.portalapp.portal.service.UserAppSelectService# - * setAppCatalogSelection(org.openecomp.portalapp.portal.domain.EPUser, - * org.openecomp.portalapp.portal.transport.AppCatalogSelection) + * @see org.onap.portalapp.portal.service.UserAppSelectService# + * setAppCatalogSelection(org.onap.portalapp.portal.domain.EPUser, + * org.onap.portalapp.portal.transport.AppCatalogSelection) */ @Override public void setPersUserAppValue(EPUser user, EPApp app, boolean select, boolean pending) { diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/SharedContextServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/SharedContextServiceImpl.java index a950c5ff..49513525 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/SharedContextServiceImpl.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/SharedContextServiceImpl.java @@ -71,7 +71,7 @@ public class SharedContextServiceImpl implements SharedContextService { /* * (non-Javadoc) * - * @see org.openecomp.portalsdk.core.service.SharedContextService# + * @see org.onap.portalsdk.core.service.SharedContextService# * getSharedContexts() */ @Override @@ -89,7 +89,7 @@ public class SharedContextServiceImpl implements SharedContextService { /* * (non-Javadoc) * - * @see org.openecomp.portalsdk.core.service.SharedContextService# + * @see org.onap.portalsdk.core.service.SharedContextService# * getSharedContext(java. lang.String, java.lang.String) */ @Override @@ -112,7 +112,7 @@ public class SharedContextServiceImpl implements SharedContextService { /* * (non-Javadoc) * - * @see org.openecomp.portalapp.portal.service.SharedContextService# + * @see org.onap.portalapp.portal.service.SharedContextService# * addSharedContext(java.lang.String, java.lang.String, java.lang.String) */ @Override @@ -124,8 +124,8 @@ public class SharedContextServiceImpl implements SharedContextService { /* * (non-Javadoc) * - * @see org.openecomp.portalsdk.core.service.SharedContextService# - * saveSharedContext(org.openecomp.portalapp.portal.domain.SharedContext) + * @see org.onap.portalsdk.core.service.SharedContextService# + * saveSharedContext(org.onap.portalapp.portal.domain.SharedContext) */ @Override public void saveSharedContext(SharedContext context) { @@ -135,8 +135,8 @@ public class SharedContextServiceImpl implements SharedContextService { /* * (non-Javadoc) * - * @see org.openecomp.portalsdk.core.service.SharedContextService# - * deleteSharedContext(org.openecomp.portalapp.portal.domain.SharedContext) + * @see org.onap.portalsdk.core.service.SharedContextService# + * deleteSharedContext(org.onap.portalapp.portal.domain.SharedContext) */ @Override public void deleteSharedContext(SharedContext context) { @@ -146,7 +146,7 @@ public class SharedContextServiceImpl implements SharedContextService { /* * (non-Javadoc) * - * @see org.openecomp.portalapp.portal.service.SharedContextService# + * @see org.onap.portalapp.portal.service.SharedContextService# * deleteSharedContexts(java.lang.String) */ @Override @@ -167,7 +167,7 @@ public class SharedContextServiceImpl implements SharedContextService { /* * (non-Javadoc) * - * @see org.openecomp.portalapp.portal.service.SharedContextService# + * @see org.onap.portalapp.portal.service.SharedContextService# * expireSharedContexts(int) */ @Override diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/UserNotificationServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/UserNotificationServiceImpl.java index 130c99e7..aa3a4b12 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/UserNotificationServiceImpl.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/UserNotificationServiceImpl.java @@ -73,7 +73,7 @@ public class UserNotificationServiceImpl implements UserNotificationService { /* * (non-Javadoc) * - * @see org.openecomp.portalapp.portal.service.UserNotificationService# + * @see org.onap.portalapp.portal.service.UserNotificationService# * getNotifications(java.lang.Long) */ @Override @@ -93,7 +93,7 @@ public class UserNotificationServiceImpl implements UserNotificationService { /* * (non-Javadoc) * - * @see org.openecomp.portalapp.portal.service.UserNotificationService# + * @see org.onap.portalapp.portal.service.UserNotificationService# * getNotificationHistoryVO(java.lang.Long) */ @Override @@ -109,7 +109,7 @@ public class UserNotificationServiceImpl implements UserNotificationService { /* * (non-Javadoc) * - * @see org.openecomp.portalapp.portal.service.UserNotificationService# + * @see org.onap.portalapp.portal.service.UserNotificationService# * getAdminNotificationVOS() */ @Override @@ -125,7 +125,7 @@ public class UserNotificationServiceImpl implements UserNotificationService { /* * (non-Javadoc) * - * @see org.openecomp.portalapp.portal.service.UserNotificationService# + * @see org.onap.portalapp.portal.service.UserNotificationService# * getNotificationRoles(java.lang.Long) */ @Override @@ -141,7 +141,7 @@ public class UserNotificationServiceImpl implements UserNotificationService { /* * (non-Javadoc) * - * @see org.openecomp.portalapp.portal.service.UserNotificationService# + * @see org.onap.portalapp.portal.service.UserNotificationService# * getAppRoleList() */ @SuppressWarnings("unchecked") @@ -155,7 +155,7 @@ public class UserNotificationServiceImpl implements UserNotificationService { /* * (non-Javadoc) * - * @see org.openecomp.portalapp.portal.service.UserNotificationService# + * @see org.onap.portalapp.portal.service.UserNotificationService# * setNotificationsRead(java.lang.Long, int) */ @Override @@ -171,8 +171,8 @@ public class UserNotificationServiceImpl implements UserNotificationService { /* * (non-Javadoc) * - * @see org.openecomp.portalapp.portal.service.UserNotificationService# - * saveNotification(org.openecomp.portalapp.portal.transport. + * @see org.onap.portalapp.portal.service.UserNotificationService# + * saveNotification(org.onap.portalapp.portal.transport. * EpNotificationItem) */ @Override @@ -196,7 +196,9 @@ public class UserNotificationServiceImpl implements UserNotificationService { if (notificationItem.getNotificationId() != null) { EpNotificationItem updateNotificationItem = (EpNotificationItem) getDataAccessService() .getDomainObject(EpNotificationItem.class, notificationItem.getNotificationId(), null); - notificationItem.setRoles(updateNotificationItem.getRoles()); + if(updateNotificationItem != null) { + notificationItem.setRoles(updateNotificationItem.getRoles()); + } } if (notificationItem.msgSource == null) { notificationItem.setMsgSource("EP"); diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/UserRolesCommonServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/UserRolesCommonServiceImpl.java index c65b4af9..ab4044d1 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/UserRolesCommonServiceImpl.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/UserRolesCommonServiceImpl.java @@ -63,7 +63,6 @@ import org.hibernate.SessionFactory; import org.hibernate.Transaction; import org.json.JSONArray; import org.json.JSONObject; -import org.onap.portalapp.portal.service.SearchService; import org.onap.portalapp.externalsystemapproval.model.ExternalSystemRoleApproval; import org.onap.portalapp.externalsystemapproval.model.ExternalSystemUser; import org.onap.portalapp.portal.domain.EPApp; @@ -75,6 +74,7 @@ import org.onap.portalapp.portal.domain.EPUserAppRoles; import org.onap.portalapp.portal.domain.EPUserAppRolesRequest; import org.onap.portalapp.portal.domain.EPUserAppRolesRequestDetail; import org.onap.portalapp.portal.domain.ExternalSystemAccess; +import org.onap.portalapp.portal.exceptions.SyncUserRolesException; import org.onap.portalapp.portal.logging.aop.EPMetricsLog; import org.onap.portalapp.portal.logging.format.EPAppMessagesEnum; import org.onap.portalapp.portal.logging.logic.EPLogUtil; @@ -246,7 +246,6 @@ public class UserRolesCommonServiceImpl { */ protected void syncUserRoles(SessionFactory sessionFactory, String userId, Long appId, EcompRole[] userAppRoles, Boolean extRequestValue, String reqType) throws Exception { - boolean result = false; Session localSession = null; Transaction transaction = null; String roleActive = null; @@ -361,23 +360,17 @@ public class UserRolesCommonServiceImpl { } } transaction.commit(); - result = true; } catch (Exception e) { logger.error(EELFLoggerDelegate.errorLogger, "syncUserRoles failed", e); EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeDaoSystemError, e); EcompPortalUtils.rollbackTransaction(transaction, "Exception occurred in syncUserRoles, Details: " + e.toString()); if("DELETE".equals(reqType)){ - throw new Exception(e.getMessage()); + throw new SyncUserRolesException(e.getMessage()); } } finally { - if (localSession != null) { - localSession.close(); - } - if (!result && !"DELETE".equals(reqType)) { - throw new Exception( - "Exception occurred in syncUserRoles while closing database session for app: '" + appId + "'."); - } + if(localSession != null) + localSession.close(); } } @@ -759,7 +752,7 @@ public class UserRolesCommonServiceImpl { /* * (non-Javadoc) * - * @see org.openecomp.portalapp.portal.service.UserRolesService# + * @see org.onap.portalapp.portal.service.UserRolesService# * importRolesFromRemoteApplication(java.lang.Long) */ public List<EPRole> importRolesFromRemoteApplication(Long appId) throws HTTPException { @@ -851,9 +844,9 @@ public class UserRolesCommonServiceImpl { /* * (non-Javadoc) * - * @see org.openecomp.portalapp.portal.service.UserRolesService# - * setAppWithUserRoleStateForUser(org.openecomp.portalapp.portal.domain. - * EPUser, org.openecomp.portalapp.portal.transport.AppWithRolesForUser) + * @see org.onap.portalapp.portal.service.UserRolesService# + * setAppWithUserRoleStateForUser(org.onap.portalapp.portal.domain. + * EPUser, org.onap.portalapp.portal.transport.AppWithRolesForUser) */ public boolean setAppWithUserRoleStateForUser(EPUser user, AppWithRolesForUser newAppRolesForUser) { boolean result = false; @@ -1572,7 +1565,7 @@ public class UserRolesCommonServiceImpl { /* * (non-Javadoc) * - * @see org.openecomp.portalapp.portal.service.UserRolesService# + * @see org.onap.portalapp.portal.service.UserRolesService# * getAppRolesForUser(java.lang.Long, java.lang.String) */ @SuppressWarnings("unchecked") @@ -1606,7 +1599,7 @@ public class UserRolesCommonServiceImpl { activeRoleList.add(role); } } - + } EPUser localUser = getUserFromApp(userId, app, applicationsRestClientService); // If localUser does not exists return roles @@ -1623,7 +1616,9 @@ public class UserRolesCommonServiceImpl { EcompRole[] appRoles = null; List<EcompRole> roles = new ArrayList<>(); if(app.getCentralAuth()){ - List<EPRole> applicationRoles = dataAccessService.getList(EPRole.class, " where app_id = "+app.getId()+ " and active_yn = 'Y'", null, null);; + final Map<String, Long> appParams = new HashMap<>(); + appParams.put("appId", app.getId()); + List<EPRole> applicationRoles = dataAccessService.executeNamedQuery("getActiveRolesOfApplication", appParams, null); for(EPRole role : applicationRoles){ EcompRole ecompRole = new EcompRole(); ecompRole.setId(role.getId()); @@ -1739,10 +1734,11 @@ public class UserRolesCommonServiceImpl { return result; } + @SuppressWarnings("unchecked") public FieldsValidator putUserAppRolesRequest(AppWithRolesForUser userAppRolesData, EPUser user) { FieldsValidator fieldsValidator = new FieldsValidator(); final Map<String, Long> params = new HashMap<>(); - EPUserAppRoles appRole= new EPUserAppRoles(); + List<EPUserAppRoles> appRole= null; try { logger.error(EELFLoggerDelegate.errorLogger,"Should not be reached here, still the endpoint is yet to be defined"); boolean result = postUserRolesToMylogins(userAppRolesData, applicationsRestClientService, userAppRolesData.appId, user.getId()); @@ -1762,13 +1758,15 @@ public class UserRolesCommonServiceImpl { Boolean isAppliedVal = userAppRoles.isApplied; params.put("appRoleId", userAppRoles.roleId); if (isAppliedVal) { - appRole = (EPUserAppRoles) dataAccessService.executeNamedQuery("appRoles", params, null).get(0); - EPUserAppRolesRequestDetail epAppRoleDetail = new EPUserAppRolesRequestDetail(); - epAppRoleDetail.setReqRoleId(appRole.getRoleId()); - epAppRoleDetail.setReqType("P"); - epAppRoleDetail.setEpRequestIdData(epAppRolesRequestData); - dataAccessService.saveDomainObject(epAppRoleDetail, null); - } + appRole = (List<EPUserAppRoles>) dataAccessService.executeNamedQuery("appRoles", params, null); + if (!appRole.isEmpty()) { + EPUserAppRolesRequestDetail epAppRoleDetail = new EPUserAppRolesRequestDetail(); + epAppRoleDetail.setReqRoleId(appRole.get(0).getRoleId()); + epAppRoleDetail.setReqType("P"); + epAppRoleDetail.setEpRequestIdData(epAppRolesRequestData); + dataAccessService.saveDomainObject(epAppRoleDetail, null); + } + } } epAppRolesRequestData.setEpRequestIdDetail(appRoleDetails); fieldsValidator.httpStatusCode = new Long(HttpServletResponse.SC_OK); @@ -1831,7 +1829,7 @@ public class UserRolesCommonServiceImpl { /* * (non-Javadoc) * - * @see org.openecomp.portalapp.portal.service.UserRolesService# + * @see org.onap.portalapp.portal.service.UserRolesService# * getCachedAppRolesForUser(java.lang.Long, java.lang.Long) */ public List<EPUserApp> getCachedAppRolesForUser(Long appId, Long userId) { diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/transport/EventWidget.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/transport/EventWidget.java index 96562399..d96f1821 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/transport/EventWidget.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/transport/EventWidget.java @@ -36,7 +36,7 @@ package org.onap.portalapp.portal.transport; * * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ -/*package org.openecomp.portalapp.portal.transport; +/*package org.onap.portalapp.portal.transport; import javax.persistence.Column; import javax.persistence.Entity; @@ -45,7 +45,7 @@ import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Table; -import org.openecomp.portalsdk.core.domain.support.DomainVo; +import org.onap.portalsdk.core.domain.support.DomainVo; import com.fasterxml.jackson.annotation.JsonInclude; *//** diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/transport/ExternalRequestFieldsValidator.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/transport/ExternalRequestFieldsValidator.java index 75418df5..67dba090 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/transport/ExternalRequestFieldsValidator.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/transport/ExternalRequestFieldsValidator.java @@ -60,6 +60,37 @@ public class ExternalRequestFieldsValidator { this.detailMessage = detailMessage; } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((detailMessage == null) ? 0 : detailMessage.hashCode()); + result = prime * result + (this.result ? 1231 : 1237); + return result; + } + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + ExternalRequestFieldsValidator other = (ExternalRequestFieldsValidator) obj; + if (detailMessage == null) { + if (other.detailMessage != null) + return false; + } else if (!detailMessage.equals(other.detailMessage)) + return false; + if (result != other.result) + return false; + return true; + } + + + + + } diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/utils/CustomLoggingFilter.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/utils/CustomLoggingFilter.java index 0b564eec..4b580e0a 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/utils/CustomLoggingFilter.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/utils/CustomLoggingFilter.java @@ -59,7 +59,7 @@ public class CustomLoggingFilter extends Filter<ILoggingEvent> { try { if ((event.getLevel() != Level.ERROR || event.getLevel() != Level.WARN) && (event.getThreadName().equalsIgnoreCase("UEBConsumerThread")) && - (event.getLoggerName().contains("org.openecomp.nsa") || event.getLoggerName().contains("org.apache.http")) + (event.getLoggerName().contains("org.onap.nsa") || event.getLoggerName().contains("org.apache.http")) ) { return FilterReply.DENY; } else { |