diff options
Diffstat (limited to 'ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service')
15 files changed, 139 insertions, 100 deletions
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) { |