summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-core/src/main/java
diff options
context:
space:
mode:
authorChristopher Lott (cl778h) <clott@research.att.com>2017-08-18 14:37:47 -0400
committerChristopher Lott (cl778h) <clott@research.att.com>2017-08-18 14:39:46 -0400
commitf03552714077df2a3f11fe33a81342558dfe1705 (patch)
tree2ad3b77f2b1fd1f0390a7d4614cd3d050b6f6f38 /ecomp-sdk/epsdk-core/src/main/java
parenta2f5a35c06a526b05e4efd9fe275d6639bf22cd3 (diff)
Repair centralized-role feature.
Also show ONAP logo in EPSDK-app header top left. Issue: PORTAL-21, PORTAL-81 Change-Id: I46953123219d4f7a239ca6c5a05890a3769ed2ea Signed-off-by: Christopher Lott (cl778h) <clott@research.att.com>
Diffstat (limited to 'ecomp-sdk/epsdk-core/src/main/java')
-rw-r--r--ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/AccessConfiguration.java219
-rw-r--r--ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/FnMenuService.java20
-rw-r--r--ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/FnMenuServiceImpl.java97
-rw-r--r--ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/FunctionalMenuListService.java13
-rw-r--r--ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/FunctionalMenuListServiceCentralizedImpl.java42
-rw-r--r--ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/FunctionalMenuListServiceImpl.java33
-rw-r--r--ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/LoginServiceCentralizedImpl.java52
-rw-r--r--ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/RestApiRequestBuilder.java2
-rw-r--r--ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/UserService.java15
-rw-r--r--ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/UserServiceCentalizedImpl.java51
-rw-r--r--ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/UserServiceImpl.java16
11 files changed, 294 insertions, 266 deletions
diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/AccessConfiguration.java b/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/AccessConfiguration.java
index 6b00d3fb..04163d06 100644
--- a/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/AccessConfiguration.java
+++ b/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/AccessConfiguration.java
@@ -6,106 +6,121 @@ import org.springframework.context.annotation.Configuration;
@Configuration
public class AccessConfiguration {
-
-
-
- /**
- *
- * @return RoleServiceImpl bean if LocalAccessCondition is true
- */
- @Bean
- @Conditional(LocalAccessCondition.class)
- public RoleService roleServiceImpl() {
- return new RoleServiceImpl();
- }
-
-
- /**
- *
- * @return RoleServiceCentralizedAccess bean if CentralAccessCondition is true
- */
- @Bean
- @Conditional(CentralAccessCondition.class)
- public RoleService roleServiceCentralizedAccess() {
- return new RoleServiceCentralizedAccess();
- }
-
-
- /**
- *
- * @return LoginServiceImpl bean if LocalAccessCondition is true
- */
- @Bean
- @Conditional(LocalAccessCondition.class)
- public LoginService loginServiceImpl() {
- return new LoginServiceImpl();
- }
-
-
- /**
- *
- * @return LoginServiceCentralizedImpl bean if CentralAccessCondition is true
- */
- @Bean
- @Conditional(CentralAccessCondition.class)
- public LoginService loginServiceCEntralizedImpl() {
- return new LoginServiceCentralizedImpl();
- }
-
- /**
- *
- * @return UserProfileServiceImpl bean if LocalAccessCondition is true
- */
- @Bean
- @Conditional(LocalAccessCondition.class)
- public UserService userServiceImpl() {
- return new UserServiceImpl();
- }
-
-
- /**
- *
- * @return returns UserProfileServiceCentalizedImpl bean if CentralAccessCondition is true
- */
- @Bean
- @Conditional(CentralAccessCondition.class)
- public UserService userServiceCentalizedImpl() {
- return new UserServiceCentalizedImpl();
- }
-
-
-
- /**
- *
- * @return returns ProfileServiceImpl bean if LocalAccessCondition is true
- */
- @Bean
- @Conditional(LocalAccessCondition.class)
- public ProfileService profileServiceImpl() {
- return new ProfileServiceImpl();
- }
-
-
- /**
- *
- * @return returns ProfileServiceCentralizedImpl bean if CentralAccessCondition is true
- */
-
- @Bean
- @Conditional(CentralAccessCondition.class)
- public ProfileService profileServiceCentralizedImpl() {
- return new ProfileServiceCentralizedImpl();
- }
-
-
- /**
- *
- * @return returns RestApiRequestBuilder bean if CentralAccessCondition is true
- */
- @Bean
- @Conditional(CentralAccessCondition.class)
- public RestApiRequestBuilder restApiRequestBuilder() {
- return new RestApiRequestBuilder();
- }
-
+
+ /**
+ *
+ * @return RoleServiceImpl bean if LocalAccessCondition is true
+ */
+ @Bean
+ @Conditional(LocalAccessCondition.class)
+ public RoleService roleServiceImpl() {
+ return new RoleServiceImpl();
+ }
+
+ /**
+ *
+ * @return RoleServiceCentralizedAccess bean if CentralAccessCondition is true
+ */
+ @Bean
+ @Conditional(CentralAccessCondition.class)
+ public RoleService roleServiceCentralizedAccess() {
+ return new RoleServiceCentralizedAccess();
+ }
+
+ /**
+ *
+ * @return LoginServiceImpl bean if LocalAccessCondition is true
+ */
+ @Bean
+ @Conditional(LocalAccessCondition.class)
+ public LoginService loginServiceImpl() {
+ return new LoginServiceImpl();
+ }
+
+ /**
+ *
+ * @return LoginServiceCentralizedImpl bean if CentralAccessCondition is true
+ */
+ @Bean
+ @Conditional(CentralAccessCondition.class)
+ public LoginService loginServiceCEntralizedImpl() {
+ return new LoginServiceCentralizedImpl();
+ }
+
+ /**
+ *
+ * @return UserProfileServiceImpl bean if LocalAccessCondition is true
+ */
+ @Bean
+ @Conditional(LocalAccessCondition.class)
+ public UserService userServiceImpl() {
+ return new UserServiceImpl();
+ }
+
+ /**
+ *
+ * @return returns UserProfileServiceCentalizedImpl bean if
+ * CentralAccessCondition is true
+ */
+ @Bean
+ @Conditional(CentralAccessCondition.class)
+ public UserService userServiceCentalizedImpl() {
+ return new UserServiceCentalizedImpl();
+ }
+
+ /**
+ *
+ * @return returns ProfileServiceImpl bean if LocalAccessCondition is true
+ */
+ @Bean
+ @Conditional(LocalAccessCondition.class)
+ public ProfileService profileServiceImpl() {
+ return new ProfileServiceImpl();
+ }
+
+ /**
+ *
+ * @return returns ProfileServiceCentralizedImpl bean if CentralAccessCondition
+ * is true
+ */
+
+ @Bean
+ @Conditional(CentralAccessCondition.class)
+ public ProfileService profileServiceCentralizedImpl() {
+ return new ProfileServiceCentralizedImpl();
+ }
+
+ /**
+ *
+ * @return returns RestApiRequestBuilder bean if CentralAccessCondition is true
+ */
+ @Bean
+ @Conditional(CentralAccessCondition.class)
+ public RestApiRequestBuilder restApiRequestBuilder() {
+ return new RestApiRequestBuilder();
+ }
+
+ /**
+ *
+ * @return returns FunctionalMenuListServiceImpl bean if LocalAccessCondition is
+ * true
+ */
+ @Bean
+ @Conditional(LocalAccessCondition.class)
+ public FunctionalMenuListService functionalMenuListService() {
+ return new FunctionalMenuListServiceImpl();
+ }
+
+ /**
+ *
+ * @return returns FunctionalMenuListServiceCentralizedImpl bean if
+ * CentralAccessCondition is true
+ */
+
+ @Bean
+ @Conditional(CentralAccessCondition.class)
+ public FunctionalMenuListService functionalMenuListServiceCentralizedImpl() {
+ return new FunctionalMenuListServiceCentralizedImpl();
+ }
+
}
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 913c9de1..0cd65df2 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
@@ -1,6 +1,6 @@
/*-
* ================================================================================
- * eCOMP Portal SDK
+ * ECOMP Portal SDK
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property
* ================================================================================
@@ -23,26 +23,32 @@ 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;
/**
- * Description: this java class is an interface of services for Admin to add/edit/delete menu items from FN_MENU
+ * Services for Admin to add/edit/delete menu items from FN_MENU
*/
public interface FnMenuService {
List<MenuData> getFnMenuItems();
+
void saveFnMenuData(MenuData domainFnMenu);
+
void saveFnMenu(Menu domainFnMenu);
+
void removeMenuItem(MenuData domainFnMenu);
+
MenuData getMenuItemRow(Long id);
+
Menu getMenuItem(Long id);
+
List<Long> getParentId(String label);
+
@SuppressWarnings("rawtypes")
List<List> getParentList();
- List<RoleFunction> getFunctionCDList(HttpServletRequest request) throws Exception;
+
void removeMenuItem(Menu domainFnMenu);
- Map<String, List<MenuData>> setMenuDataStructure(List<List<MenuData>> childItemList, List<MenuData> parentList, Set<MenuData> menuResult) throws Exception;
+
+ 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 22bc9675..6d8667f9 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
@@ -1,6 +1,6 @@
/*-
* ================================================================================
- * eCOMP Portal SDK
+ * ECOMP Portal SDK
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property
* ================================================================================
@@ -21,154 +21,105 @@ package org.openecomp.portalsdk.core.service;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.HashSet;
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;
-import org.openecomp.portalsdk.core.domain.User;
-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.Transactional;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.type.TypeFactory;
-
/**
- * Description: this java class is an implementation of services for Admin to add/edit/delete menu items from FN_MENU
+ * Description: this java class is an implementation of services for Admin to
+ * add/edit/delete menu items from FN_MENU
*/
@Service("fnMenuService")
@Transactional
-public class FnMenuServiceImpl implements FnMenuService{
+public class FnMenuServiceImpl implements FnMenuService {
-
- private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(FnMenuServiceImpl.class);
@Autowired
- private DataAccessService dataAccessService;
-
- @Autowired
- private RestApiRequestBuilder restApiRequestBuilder;
-
- @SuppressWarnings("unchecked")
- public List<MenuData> getFnMenuItems() {
- //List msgDB = getDataAccessService().getList(Profile.class, null);
- return getDataAccessService().getList(MenuData.class, null, "1", null);
+ private DataAccessService dataAccessService;
+ @SuppressWarnings("unchecked")
+ public List<MenuData> getFnMenuItems() {
+ return getDataAccessService().getList(MenuData.class, null, "1", null);
}
-
public DataAccessService getDataAccessService() {
return dataAccessService;
}
-
public void setDataAccessService(DataAccessService dataAccessService) {
this.dataAccessService = dataAccessService;
}
-
@Override
public void saveFnMenuData(MenuData domainFnMenu) {
- // TODO Auto-generated method stub
getDataAccessService().saveDomainObject(domainFnMenu, null);
-
}
@SuppressWarnings("unchecked")
@Override
public List<Long> getParentId(String label) {
- // TODO Auto-generated method stub
- //List<String> functioCDlist = new ArrayList<String>();
- //functioCDlist.add("Mahdy1");
- //functioCDlist.add("Mahdy2");
- Map<String, String> params = new HashMap<String, String>();
- params.put("paramLabel", label);
+ Map<String, String> params = new HashMap<String, String>();
+ params.put("paramLabel", label);
return getDataAccessService().executeNamedQuery("IdForLabelList", params, null);
- }
+ }
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public List<List> getParentList() {
- // TODO Auto-generated method stub
- //List<String> functioCDlist = new ArrayList<String>();
- //functioCDlist.add("Mahdy1");
- //functioCDlist.add("Mahdy2");
return getDataAccessService().executeNamedQuery("parentList", null, null);
-
- //return null;
}
- @SuppressWarnings("unchecked")
- @Override
- public List<RoleFunction> getFunctionCDList(HttpServletRequest request) throws Exception {
- User user = UserUtils.getUserSession(request);
- ObjectMapper mapper = new ObjectMapper();
- List roleFunctionFinalList = new ArrayList<>();
- try {
- String menuList = restApiRequestBuilder.getViaREST("/menuFunctions", true, user.getOrgUserId());
- roleFunctionFinalList = mapper.readValue(menuList,
- TypeFactory.defaultInstance().constructCollectionType(List.class, String.class));
- } catch (Exception e) {
- logger.error(EELFLoggerDelegate.errorLogger, "saveRole Failed", e);
- throw new Exception(e.getMessage());
- }
- return roleFunctionFinalList;
- }
-
@Override
public void removeMenuItem(MenuData domainFnMenu) {
getDataAccessService().deleteDomainObject(domainFnMenu, null);
}
-
+
@Override
public void removeMenuItem(Menu domainFnMenu) {
getDataAccessService().deleteDomainObject(domainFnMenu, null);
}
-
+
public MenuData getMenuItemRow(Long id) {
- return (MenuData)getDataAccessService().getDomainObject(MenuData.class, id, null);
+ return (MenuData) getDataAccessService().getDomainObject(MenuData.class, id, null);
}
-
+
@Override
public Menu getMenuItem(Long id) {
- return (Menu)getDataAccessService().getDomainObject(Menu.class, id, null);
+ return (Menu) getDataAccessService().getDomainObject(Menu.class, id, null);
}
-
+
@Override
public void saveFnMenu(Menu domainFnMenu) {
- // TODO Auto-generated method stub
getDataAccessService().saveDomainObject(domainFnMenu, null);
-
}
+
@Override
- public Map<String, List<MenuData>> setMenuDataStructure(List<List<MenuData>> childItemList, List<MenuData> parentList, Set<MenuData> menuResult) throws Exception{
- for(MenuData menu: menuResult){
+ public Map<String, List<MenuData>> setMenuDataStructure(List<List<MenuData>> childItemList,
+ List<MenuData> parentList, Set<MenuData> menuResult) throws Exception {
+ for (MenuData menu : menuResult) {
MenuData parentData = new MenuData();
parentData.setLabel(menu.getLabel());
parentData.setAction(menu.getAction());
parentData.setImageSrc(menu.getImageSrc());
parentList.add(parentData);
List<MenuData> tempList = new ArrayList<MenuData>();
- for(Object o:menu.getChildMenus()){
- MenuData m = (MenuData)o;
+ for (Object o : menu.getChildMenus()) {
+ MenuData m = (MenuData) o;
MenuData data = new MenuData();
data.setLabel(m.getLabel());
data.setAction(m.getAction());
- data.setImageSrc(m.getImageSrc());
+ data.setImageSrc(m.getImageSrc());
tempList.add(data);
}
childItemList.add(tempList);
}
return null;
}
-
}
diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/FunctionalMenuListService.java b/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/FunctionalMenuListService.java
new file mode 100644
index 00000000..9419f213
--- /dev/null
+++ b/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/FunctionalMenuListService.java
@@ -0,0 +1,13 @@
+package org.openecomp.portalsdk.core.service;
+
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.openecomp.portalsdk.core.domain.RoleFunction;
+
+public interface FunctionalMenuListService {
+
+ List<RoleFunction> getFunctionCDList(HttpServletRequest request) throws Exception;
+
+}
diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/FunctionalMenuListServiceCentralizedImpl.java b/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/FunctionalMenuListServiceCentralizedImpl.java
new file mode 100644
index 00000000..c7474de1
--- /dev/null
+++ b/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/FunctionalMenuListServiceCentralizedImpl.java
@@ -0,0 +1,42 @@
+package org.openecomp.portalsdk.core.service;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.openecomp.portalsdk.core.domain.RoleFunction;
+import org.openecomp.portalsdk.core.domain.User;
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.openecomp.portalsdk.core.web.support.UserUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.type.TypeFactory;
+
+public class FunctionalMenuListServiceCentralizedImpl implements FunctionalMenuListService{
+
+private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(FunctionalMenuListServiceCentralizedImpl.class);
+
+ @Autowired
+ private RestApiRequestBuilder restApiRequestBuilder;
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public List<RoleFunction> getFunctionCDList(HttpServletRequest request) throws Exception {
+ User user = UserUtils.getUserSession(request);
+ ObjectMapper mapper = new ObjectMapper();
+ List roleFunctionFinalList = new ArrayList<>();
+ try {
+ String menuList = restApiRequestBuilder.getViaREST("/menuFunctions", true, user.getOrgUserId());
+ roleFunctionFinalList = mapper.readValue(menuList,
+ TypeFactory.defaultInstance().constructCollectionType(List.class, String.class));
+ } catch (Exception e) {
+ logger.error(EELFLoggerDelegate.errorLogger, "getFunctionCDList Failed", e);
+ throw new Exception(e.getMessage());
+ }
+ return roleFunctionFinalList;
+ }
+
+
+}
diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/FunctionalMenuListServiceImpl.java b/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/FunctionalMenuListServiceImpl.java
new file mode 100644
index 00000000..dd448856
--- /dev/null
+++ b/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/FunctionalMenuListServiceImpl.java
@@ -0,0 +1,33 @@
+package org.openecomp.portalsdk.core.service;
+
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.openecomp.portalsdk.core.domain.RoleFunction;
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.springframework.beans.factory.annotation.Autowired;
+
+public class FunctionalMenuListServiceImpl implements FunctionalMenuListService{
+
+private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(FunctionalMenuListServiceImpl.class);
+
+ @Autowired
+ private DataAccessService dataAccessService;
+
+ public DataAccessService getDataAccessService() {
+ return dataAccessService;
+ }
+
+ public void setDataAccessService(DataAccessService dataAccessService) {
+ this.dataAccessService = dataAccessService;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public List<RoleFunction> getFunctionCDList(HttpServletRequest request) throws Exception {
+ return getDataAccessService().executeNamedQuery("functionCDlist", null, null);
+ }
+
+
+}
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 270369c5..e5d380c9 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
@@ -6,14 +6,10 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
-import java.util.SortedSet;
-import java.util.TreeSet;
import org.openecomp.portalsdk.core.command.LoginBean;
import org.openecomp.portalsdk.core.domain.Role;
-import org.openecomp.portalsdk.core.domain.RoleFunction;
import org.openecomp.portalsdk.core.domain.User;
-import org.openecomp.portalsdk.core.domain.UserApp;
import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.openecomp.portalsdk.core.menu.MenuBuilder;
import org.openecomp.portalsdk.core.service.support.FusionService;
@@ -23,8 +19,6 @@ import org.openecomp.portalsdk.core.web.support.UserUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
@Transactional
public class LoginServiceCentralizedImpl extends FusionService implements LoginService {
@@ -39,6 +33,9 @@ public class LoginServiceCentralizedImpl extends FusionService implements LoginS
@Autowired
RestApiRequestBuilder restApiRequestBuilder;
+
+ @Autowired
+ UserService userService;
@SuppressWarnings("unused")
private MenuBuilder menuBuilder;
@@ -132,51 +129,12 @@ public class LoginServiceCentralizedImpl extends FusionService implements LoginS
@SuppressWarnings("null")
public User findUser(LoginBean bean) throws Exception {
-
User user = null;
-
- ObjectMapper mapper = new ObjectMapper();
- 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();
-
- Iterator<UserApp> it = setAppsObj.iterator();
- while (it.hasNext()) {
- Object next = it.next();
-
- UserApp nextApp = mapper.convertValue(next, UserApp.class);
- rolefun = new HashSet<>();
- Role role = nextApp.getRole();
-
- roleFunctionList = role.getRoleFunctions();
-
- Iterator<RoleFunction> itetaror = roleFunctionList.iterator();
- while (itetaror.hasNext()) {
- Object nextValue = itetaror.next();
- RoleFunction roleFunction = mapper.convertValue(nextValue, RoleFunction.class);
- roleFunctionListNew.add(roleFunction);
- }
-
- role.setRoleFunctions(roleFunctionListNew);
- nextApp.setRole(role);
- nextApp.getRole().getRoleFunctions();
-
- UserAppSet.add(nextApp);
- user.setUserApps(UserAppSet);
- }
-
+ user = userService.userMapper(repsonse);
return user;
}
+
public User findUser(String loginId, String password) {
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 94ecfaf4..00673682 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
@@ -12,7 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired;
public class RestApiRequestBuilder {
- private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(RoleServiceCentralizedAccess.class);
+ private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(RestApiRequestBuilder.class);
@Autowired
AppService appService;
diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/UserService.java b/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/UserService.java
index 170361c3..d1c2f4b4 100644
--- a/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/UserService.java
+++ b/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/UserService.java
@@ -4,13 +4,22 @@ import org.openecomp.portalsdk.core.domain.User;
public interface UserService {
-
/**
+ * Gets the user object for the specified ID.
*
- * @param id orgUserID
+ * @param id
+ * orgUserID
* @return User object
* @throws Exception
- * Method getUser returns the User Object
*/
User getUser(String id) throws Exception;
+
+ /**
+ * Builds a User object from a JSON string.
+ *
+ * @param response
+ * @return User object
+ * @throws Exception
+ */
+ User userMapper(String response) throws Exception;
}
diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/UserServiceCentalizedImpl.java b/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/UserServiceCentalizedImpl.java
index 879b2a9a..979d6658 100644
--- a/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/UserServiceCentalizedImpl.java
+++ b/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/UserServiceCentalizedImpl.java
@@ -44,16 +44,36 @@ public class UserServiceCentalizedImpl implements UserService {
@Override
public User getUser(String id) throws Exception {
- ObjectMapper mapper = new ObjectMapper();
- User user = new User();
- HashSet<RoleFunction> rolefun = null;
+ User user = null;
String orgUserId = getUserByProfileId(id);
String responseString = restApiRequestBuilder.getViaREST("/user/" + orgUserId, true, id);
- user = mapper.readValue(responseString, User.class);
-
+ user = userMapper(responseString);
+ return user;
+ }
+
+ public String getUserByProfileId(String id) {
+ Map<String, Long> params = new HashMap<String, Long>();
+ params.put("user_id", new Long(id));
+ @SuppressWarnings("rawtypes")
+ List list = getDataAccessService().executeNamedQuery("getUserByProfileId", params, null);
+ String orgUserId = "";
+ if (list != null && !list.isEmpty())
+ orgUserId = (String) list.get(0);
+ return orgUserId;
+ }
+
+ @Override
+ public User userMapper(String res) throws Exception
+ {
+ User user= new User();
+ ObjectMapper mapper = new ObjectMapper();
+ HashSet<RoleFunction> rolefun = null;
+ user = mapper.readValue(res, User.class);
+ Set<RoleFunction> roleFunctionListNew = new HashSet<>();
+ Set<RoleFunction> roleFunctionList = new HashSet<>();
+ SortedSet<UserApp> UserAppSet = new TreeSet<>();
@SuppressWarnings("unchecked")
Set<UserApp> setAppsObj = user.getUserApps();
-
Iterator<UserApp> it = setAppsObj.iterator();
while (it.hasNext()) {
Object next = it.next();
@@ -61,36 +81,21 @@ public class UserServiceCentalizedImpl implements UserService {
UserApp nextApp = mapper.convertValue(next, UserApp.class);
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();
RoleFunction roleFunction = mapper.convertValue(nextValue, RoleFunction.class);
roleFunctionListNew.add(roleFunction);
}
-
role.setRoleFunctions(roleFunctionListNew);
nextApp.setRole(role);
nextApp.getRole().getRoleFunctions();
- SortedSet<UserApp> UserAppSet = new TreeSet<>();
+
UserAppSet.add(nextApp);
user.setUserApps(UserAppSet);
}
-
return user;
}
- public String getUserByProfileId(String id) {
- Map<String, Long> params = new HashMap<String, Long>();
- params.put("user_id", new Long(id));
- @SuppressWarnings("rawtypes")
- List list = getDataAccessService().executeNamedQuery("getUserByProfileId", params, null);
- String orgUserId = "";
- if (list != null && !list.isEmpty())
- orgUserId = (String) list.get(0);
- return orgUserId;
- }
-
}
diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/UserServiceImpl.java b/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/UserServiceImpl.java
index 24404fda..80f8bb2a 100644
--- a/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/UserServiceImpl.java
+++ b/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/UserServiceImpl.java
@@ -10,18 +10,14 @@ public class UserServiceImpl implements UserService {
@Autowired
private DataAccessService dataAccessService;
- public DataAccessService getDataAccessService() {
- return dataAccessService;
- }
-
- public void setDataAccessService(DataAccessService dataAccessService) {
- this.dataAccessService = dataAccessService;
- }
-
@Override
public User getUser(String id) {
- return (User) getDataAccessService().getDomainObject(User.class, Long.parseLong(id), null);
-
+ return (User) dataAccessService.getDomainObject(User.class, Long.parseLong(id), null);
+ }
+
+ @Override
+ public User userMapper(String response) throws Exception {
+ throw new UnsupportedOperationException("method cannot be used");
}
}