X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=portal-BE%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fportal%2Fservice%2Ffn%2FFnRoleService.java;h=b0c4e60e15f13edddbebdd561816500ac45f2b09;hb=39fb119cdaea6bd8d801b22d195db39f6d8faaca;hp=aa859dbda6de0e03dc9091c914b0626384c9f02a;hpb=dd4c51e4349b596766f2fda555a7a0d3ba46e9fa;p=portal.git diff --git a/portal-BE/src/main/java/org/onap/portal/service/fn/FnRoleService.java b/portal-BE/src/main/java/org/onap/portal/service/fn/FnRoleService.java index aa859dbd..b0c4e60e 100644 --- a/portal-BE/src/main/java/org/onap/portal/service/fn/FnRoleService.java +++ b/portal-BE/src/main/java/org/onap/portal/service/fn/FnRoleService.java @@ -43,9 +43,12 @@ package org.onap.portal.service.fn; import java.util.ArrayList; import java.util.List; import java.util.Optional; +import java.util.Set; import javax.persistence.EntityExistsException; +import javax.print.attribute.standard.Fidelity; import org.onap.portal.dao.fn.FnRoleDao; import org.onap.portal.domain.db.fn.FnRole; +import org.onap.portal.service.ExternalAccessRolesService; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -70,9 +73,6 @@ public class FnRoleService { } public FnRole getRole(final Long appId, final Long appRoleId) { - - String sql = "SELECT * FROM fn_role where APP_ID = :appId AND APP_ROLE_ID = :appRoleId"; - List roles = Optional.of(fnRoleDao.retrieveAppRoleByAppRoleIdAndByAppId(appId, appRoleId)) .orElse(new ArrayList<>()); if (!roles.isEmpty()) { @@ -87,6 +87,21 @@ public class FnRoleService { return null; } + public List getAppRoles(Long appId) { + List applicationRoles; + try { + if (appId == 1) { + applicationRoles = retrieveAppRolesWhereAppIdIsNull(); + } else { + applicationRoles = retrieveAppRolesByAppId(appId); + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "getAppRoles: failed", e); + throw e; + } + return applicationRoles; + } + public List retrieveAppRoleByAppRoleIdAndByAppId(final Long appId, final Long appRoleId) { return Optional.of(fnRoleDao.retrieveAppRoleByAppRoleIdAndByAppId(appId, appRoleId)).orElse(new ArrayList<>()); } @@ -110,4 +125,26 @@ public class FnRoleService { public List retrieveAppRolesByRoleNameAndByAppId(final String roleName, final Long appId) { return Optional.of(fnRoleDao.retrieveAppRolesByRoleNameAndByAppId(roleName, appId)).orElse(new ArrayList<>()); } + + public List retrieveActiveRolesOfApplication(final Long appId) { + return Optional.of(fnRoleDao.retrieveActiveRolesOfApplication(appId)).orElse(new ArrayList<>()); + } + + public List getGlobalRolesOfPortal() { + List globalRoles = new ArrayList<>(); + try { + globalRoles = Optional.of(fnRoleDao.getGlobalRolesOfPortal()).orElse(new ArrayList<>()); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "getGlobalRolesOfPortal failed", e); + } + return globalRoles; + } + + public void delete(FnRole role) { + fnRoleDao.delete(role); + } + + public FnRole saveOne(final FnRole role){ + return fnRoleDao.save(role); + } }