diff options
Diffstat (limited to 'ecomp-sdk/epsdk-core')
6 files changed, 31 insertions, 104 deletions
diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/FnMenuService.java b/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/FnMenuService.java index 040c9d26..2face03a 100644 --- a/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/FnMenuService.java +++ b/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/FnMenuService.java @@ -23,6 +23,8 @@ import java.util.List; import java.util.Map; import java.util.Set; +import javax.servlet.http.HttpServletRequest; + import org.openecomp.portalsdk.core.domain.Menu; import org.openecomp.portalsdk.core.domain.MenuData; import org.openecomp.portalsdk.core.domain.RoleFunction; @@ -40,7 +42,7 @@ public interface FnMenuService { List<Long> getParentId(String label); @SuppressWarnings("rawtypes") List<List> getParentList(); - List<RoleFunction> getFunctionCDList(); + List<RoleFunction> getFunctionCDList(HttpServletRequest request); void removeMenuItem(Menu domainFnMenu); Map<String, List<MenuData>> setMenuDataStructure(List<List<MenuData>> childItemList, List<MenuData> parentList, Set<MenuData> menuResult) throws Exception; } diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/FnMenuServiceImpl.java b/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/FnMenuServiceImpl.java index ca73339d..9b16aabb 100644 --- a/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/FnMenuServiceImpl.java +++ b/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/FnMenuServiceImpl.java @@ -21,21 +21,20 @@ package org.openecomp.portalsdk.core.service; import java.util.ArrayList; import java.util.HashMap; -import java.util.Iterator; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.TreeSet; -import org.openecomp.portalsdk.core.domain.FnMenu; +import javax.servlet.http.HttpServletRequest; + import org.openecomp.portalsdk.core.domain.Menu; import org.openecomp.portalsdk.core.domain.MenuData; -import org.openecomp.portalsdk.core.domain.Role; import org.openecomp.portalsdk.core.domain.RoleFunction; -import org.openecomp.portalsdk.core.service.DataAccessService; +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.portalsdk.core.web.support.UserUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; /** @@ -46,9 +45,14 @@ import org.springframework.transaction.annotation.Transactional; @Transactional public class FnMenuServiceImpl implements FnMenuService{ + + private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(FnMenuServiceImpl.class); @Autowired private DataAccessService dataAccessService; + @Autowired + private RoleService roleService; + @SuppressWarnings("unchecked") public List<MenuData> getFnMenuItems() { //List msgDB = getDataAccessService().getList(Profile.class, null); @@ -100,14 +104,11 @@ public class FnMenuServiceImpl implements FnMenuService{ @SuppressWarnings("unchecked") @Override - public List<RoleFunction> getFunctionCDList() { - // TODO Auto-generated method stub - //List<String> functioCDlist = new ArrayList<String>(); - //functioCDlist.add("Mahdy1"); - //functioCDlist.add("Mahdy2"); - return getDataAccessService().executeNamedQuery("functionCDlist", null, null); - - //return null; + public List<RoleFunction> getFunctionCDList(HttpServletRequest request) { + Set roleFunctionList = new HashSet<>(); + roleFunctionList = UserUtils.getRoleFunctions(request); + List roleFunctionFinalList = new ArrayList<>(roleFunctionList); + return roleFunctionFinalList; } @Override diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/LoginServiceCentralizedImpl.java b/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/LoginServiceCentralizedImpl.java index 1bfe2aba..270369c5 100644 --- a/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/LoginServiceCentralizedImpl.java +++ b/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/LoginServiceCentralizedImpl.java @@ -139,8 +139,13 @@ public class LoginServiceCentralizedImpl extends FusionService implements LoginS HashSet<RoleFunction> rolefun = null; String repsonse = restApiRequestBuilder.getViaREST("/user/" + bean.getUserid(), true, bean.getUserid()); + user = mapper.readValue(repsonse, User.class); + + Set<RoleFunction> roleFunctionListNew = new HashSet<>(); + Set<RoleFunction> roleFunctionList = new HashSet<>(); + SortedSet<UserApp> UserAppSet = new TreeSet<>(); @SuppressWarnings("unchecked") Set<UserApp> setAppsObj = user.getUserApps(); @@ -153,8 +158,8 @@ public class LoginServiceCentralizedImpl extends FusionService implements LoginS rolefun = new HashSet<>(); Role role = nextApp.getRole(); - Set<RoleFunction> roleFunctionList = role.getRoleFunctions(); - Set<RoleFunction> roleFunctionListNew = new HashSet<>(); + roleFunctionList = role.getRoleFunctions(); + Iterator<RoleFunction> itetaror = roleFunctionList.iterator(); while (itetaror.hasNext()) { Object nextValue = itetaror.next(); @@ -165,7 +170,7 @@ public class LoginServiceCentralizedImpl extends FusionService implements LoginS role.setRoleFunctions(roleFunctionListNew); nextApp.setRole(role); nextApp.getRole().getRoleFunctions(); - SortedSet<UserApp> UserAppSet = new TreeSet<>(); + UserAppSet.add(nextApp); user.setUserApps(UserAppSet); } diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/RestApiRequestBuilder.java b/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/RestApiRequestBuilder.java index f7a9cbec..94ecfaf4 100644 --- a/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/RestApiRequestBuilder.java +++ b/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/RestApiRequestBuilder.java @@ -52,9 +52,9 @@ public class RestApiRequestBuilder { decryptedPwd, isBasicAuth); } catch (Exception ex) { response = "Failed to perform GET " + ex.toString(); - throw new Exception(ex.getMessage()); + throw new Exception("get Failed"+ ex); } - logger.debug(EELFLoggerDelegate.debugLogger, "getRoles response: {}", response); + logger.debug(EELFLoggerDelegate.errorLogger, "getRoles response: {}", response); return response; } @@ -90,7 +90,8 @@ public class RestApiRequestBuilder { RestWebServiceClient.getInstance().postPortalContent(restEndPoint, userId, appName, requestId, appUserName, decryptedPwd, content_type, content, isBasicAuth); } catch (Exception ex) { - logger.error(EELFLoggerDelegate.debugLogger, "POST response: {}", ex); + logger.error(EELFLoggerDelegate.errorLogger, "POST response: {}", ex); + throw new Exception("Save Failed"); } logger.debug(EELFLoggerDelegate.debugLogger, "POST response: {}"); @@ -129,7 +130,7 @@ public class RestApiRequestBuilder { RestWebServiceClient.getInstance().deletePortalContent(restEndPoint, userId, appName, requestId, appUserName, decryptedPwd, content_type, content, isBasicAuth, filter); } catch (Exception ex) { - logger.error(EELFLoggerDelegate.debugLogger, "DELETE response: {}", ex); + logger.error(EELFLoggerDelegate.errorLogger, "DELETE response: {}", ex); throw new Exception("Delete Failed"); } logger.debug(EELFLoggerDelegate.debugLogger, "DELETE response: {}"); diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/UrlAccessCentalizedImpl.java b/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/UrlAccessCentalizedImpl.java deleted file mode 100644 index 528f1bbb..00000000 --- a/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/UrlAccessCentalizedImpl.java +++ /dev/null @@ -1,79 +0,0 @@ -package org.openecomp.portalsdk.core.service; - -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpSession; - -import org.openecomp.portalsdk.core.domain.RoleFunction; -import org.openecomp.portalsdk.core.domain.User; -import org.openecomp.portalsdk.core.exception.SessionExpiredException; -import org.openecomp.portalsdk.core.util.SystemProperties; -import org.openecomp.portalsdk.core.web.support.AppUtils; -import org.openecomp.portalsdk.core.web.support.UserUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.transaction.annotation.Transactional; - -@Transactional -public class UrlAccessCentalizedImpl implements UrlAccessService { - - @Autowired - AppService appService; - - @Autowired - RoleService roleService; - - - @Override - public boolean isUrlAccessible(HttpServletRequest request, String currentUrl) { - - boolean isAccessible = false; - User user = UserUtils.getUserSession(request); - - - HttpSession session = AppUtils.getSession(request); - - if (session == null) { - throw new SessionExpiredException(); - } - - @SuppressWarnings("unchecked") - List<RoleFunction> allRoleFunctionsList = (List<RoleFunction>) session.getAttribute(SystemProperties.getProperty(SystemProperties.ROLE_FUNCTION_LIST)); - - List<String> allUrls = new ArrayList<String>(); - - for (int i = 0; i < allRoleFunctionsList.size(); i++) { - if (allRoleFunctionsList.get(i).getCode() != null && ((String) allRoleFunctionsList.get(i).getCode()).substring(0, 4).toUpperCase().equals("url_".toUpperCase())) { - String functionCd = ((String) allRoleFunctionsList.get(i).getCode()).substring(4).toUpperCase(); - allUrls.add(functionCd); - } - } - - @SuppressWarnings("unchecked") - Set<RoleFunction> roleFunction = UserUtils.getRoleFunctions(request); - List list = new ArrayList<>(roleFunction); - List<String> UserURLlist = new ArrayList<String>(); - - if (list != null && list.size() > 0) { - for (int i = 0; i < list.size(); i++) { - if (list.get(i) != null && ((String) list.get(i)).substring(0, 4).toUpperCase().equals("url_".toUpperCase())) { - String functionCd = ((String) list.get(i)).substring(4).toUpperCase(); - UserURLlist.add(functionCd); - } - } - } - - if((!UserURLlist.contains(currentUrl) && !allUrls.contains(currentUrl)) || (UserURLlist.contains(currentUrl) && allUrls.contains(currentUrl))) - { - isAccessible = true; - }else { - isAccessible = false; - } - return isAccessible; - - } - - -} diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/web/support/UserUtils.java b/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/web/support/UserUtils.java index ea26b969..a7850e34 100644 --- a/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/web/support/UserUtils.java +++ b/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/web/support/UserUtils.java @@ -154,9 +154,6 @@ public class UserUtils { session.setAttribute(SystemProperties.getProperty(SystemProperties.ROLE_FUNCTIONS_ATTRIBUTE_NAME), roleFunctions); } - - - return roleFunctions; } |