summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-core
diff options
context:
space:
mode:
Diffstat (limited to 'ecomp-sdk/epsdk-core')
-rw-r--r--ecomp-sdk/epsdk-core/pom.xml4
-rw-r--r--ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/AccessConfiguration.java8
-rw-r--r--ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/LoginServiceCentralizedImpl.java4
-rw-r--r--ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/ProfileServiceCentralizedImpl.java13
-rw-r--r--ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/RestApiRequestBuilder.java11
-rw-r--r--ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/RoleService.java8
-rw-r--r--ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/RoleServiceCentralizedAccess.java64
-rw-r--r--ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/UrlAccessCentalizedImpl.java2
-rw-r--r--ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/UrlAccessImpl.java10
-rw-r--r--ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/UserProfileService.java1
-rw-r--r--ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/UserProfileServiceCentalizedImpl.java137
-rw-r--r--ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/UserProfileServiceImpl.java6
-rw-r--r--ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/UserService.java16
-rw-r--r--ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/UserServiceCentalizedImpl.java96
-rw-r--r--ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/UserServiceImpl.java27
-rw-r--r--ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/web/support/UserUtils.java6
16 files changed, 210 insertions, 203 deletions
diff --git a/ecomp-sdk/epsdk-core/pom.xml b/ecomp-sdk/epsdk-core/pom.xml
index 63689523..9a88f73a 100644
--- a/ecomp-sdk/epsdk-core/pom.xml
+++ b/ecomp-sdk/epsdk-core/pom.xml
@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId> org.openecomp.ecompsdkos</groupId>
+ <groupId>org.openecomp.ecompsdkos</groupId>
<artifactId>epsdk-project</artifactId>
<version>1.3.0-SNAPSHOT</version>
</parent>
@@ -94,7 +94,7 @@
<!-- internal -->
<dependency>
- <groupId> org.openecomp.ecompsdkos</groupId>
+ <groupId>org.openecomp.ecompsdkos</groupId>
<artifactId>epsdk-fw</artifactId>
<version>${project.version}</version>
<exclusions>
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 ae6bd309..ee97bc93 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
@@ -58,8 +58,8 @@ public class AccessConfiguration {
*/
@Bean
@Conditional(LocalAccessCondition.class)
- public UserProfileService userProfileServiceImpl() {
- return new UserProfileServiceImpl();
+ public UserService userServiceImpl() {
+ return new UserServiceImpl();
}
@@ -69,8 +69,8 @@ public class AccessConfiguration {
*/
@Bean
@Conditional(CentralAccessCondition.class)
- public UserProfileService userProfileServiceCentalizedImpl() {
- return new UserProfileServiceCentalizedImpl();
+ public UserService userServiceCentalizedImpl() {
+ return new UserServiceCentalizedImpl();
}
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 45eff80c..6d723afa 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
@@ -21,9 +21,12 @@ 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;
import com.fasterxml.jackson.databind.ObjectMapper;
+
+@Transactional
public class LoginServiceCentralizedImpl extends FusionService implements LoginService {
private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(LoginServiceCentralizedImpl.class);
@@ -102,7 +105,6 @@ public class LoginServiceCentralizedImpl extends FusionService implements LoginS
Set appMenu = getMenuBuilder().getMenu(
SystemProperties.getProperty(SystemProperties.APPLICATION_MENU_SET_NAME), dataAccessService);
bean.setMenu(appMenu != null ? appMenu : new HashSet());
- System.out.println(appMenu);
Set businessDirectMenu = getMenuBuilder().getMenu(
SystemProperties.getProperty(SystemProperties.BUSINESS_DIRECT_MENU_SET_NAME),
dataAccessService);
diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/ProfileServiceCentralizedImpl.java b/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/ProfileServiceCentralizedImpl.java
index c4da3338..e0b97254 100644
--- a/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/ProfileServiceCentralizedImpl.java
+++ b/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/ProfileServiceCentralizedImpl.java
@@ -6,10 +6,11 @@ import org.openecomp.portalsdk.core.domain.Profile;
import org.openecomp.portalsdk.core.domain.User;
import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.type.TypeFactory;
+@Transactional
public class ProfileServiceCentralizedImpl implements ProfileService{
private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ProfileServiceCentralizedImpl.class);
@@ -31,16 +32,10 @@ public class ProfileServiceCentralizedImpl implements ProfileService{
@Autowired
RestApiRequestBuilder restApiRequestBuilder ;
+ @SuppressWarnings("unchecked")
@Override
public List<Profile> findAll() throws Exception{
-
- List<Profile> profileList =null;
- ObjectMapper mapper = new ObjectMapper();
-
- String user = restApiRequestBuilder.getViaREST("/findAllProfiles", true,null);
- profileList = mapper.readValue(user,
- TypeFactory.defaultInstance().constructCollectionType(List.class, Profile.class));
- return profileList;
+ return getDataAccessService().getList(Profile.class, null);
}
@Override
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 6a2f7a47..f7a9cbec 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
@@ -19,7 +19,7 @@ public class RestApiRequestBuilder {
public static String content_type = "application/json";
- public String getViaREST(String restEndPoint, boolean isBasicAuth,String userId) {
+ public String getViaREST(String restEndPoint, boolean isBasicAuth,String userId) throws Exception {
String appName = "";
String requestId = "";
String appUserName = "";
@@ -51,13 +51,14 @@ public class RestApiRequestBuilder {
response = RestWebServiceClient.getInstance().getPortalContent(restEndPoint, userId,appName, requestId, appUserName,
decryptedPwd, isBasicAuth);
} catch (Exception ex) {
- response = "Failed to get roles " + ex.toString();
+ response = "Failed to perform GET " + ex.toString();
+ throw new Exception(ex.getMessage());
}
logger.debug(EELFLoggerDelegate.debugLogger, "getRoles response: {}", response);
return response;
}
- public void postViaREST(String restEndPoint, boolean isBasicAuth, String content,String userId) {
+ public void postViaREST(String restEndPoint, boolean isBasicAuth, String content,String userId) throws Exception {
String appName = "";
String requestId = "";
String appUserName = "";
@@ -90,12 +91,13 @@ public class RestApiRequestBuilder {
decryptedPwd, content_type, content, isBasicAuth);
} catch (Exception ex) {
logger.error(EELFLoggerDelegate.debugLogger, "POST response: {}", ex);
+ throw new Exception("Save Failed");
}
logger.debug(EELFLoggerDelegate.debugLogger, "POST response: {}");
}
- public void deleteViaRest(String restEndPoint, boolean isBasicAuth, String content, String filter , String userId) {
+ public void deleteViaRest(String restEndPoint, boolean isBasicAuth, String content, String filter , String userId) throws Exception {
String appName = "";
String requestId = "";
String appUserName = "";
@@ -128,6 +130,7 @@ public class RestApiRequestBuilder {
decryptedPwd, content_type, content, isBasicAuth, filter);
} catch (Exception ex) {
logger.error(EELFLoggerDelegate.debugLogger, "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/RoleService.java b/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/RoleService.java
index f05adf64..ba8d4477 100644
--- a/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/RoleService.java
+++ b/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/RoleService.java
@@ -63,7 +63,7 @@ public interface RoleService {
* @param domainRole Object to be saved
* Method saveRole saves the Role Object
*/
- void saveRole(String requestedLoginId,Role domainRole);
+ void saveRole(String requestedLoginId,Role domainRole) throws Exception;
/**
*
@@ -71,7 +71,7 @@ public interface RoleService {
* @param domainRole Object to be removed
* Method deleteRole deletes the requested Role Object
*/
- void deleteRole(String requestedLoginId,Role domainRole);
+ void deleteRole(String requestedLoginId,Role domainRole) throws Exception;
/**
*
@@ -109,7 +109,7 @@ public interface RoleService {
* @param domainRoleFunction
* Method saveRoleFunction saves the requested RoleFunction object
*/
- void saveRoleFunction(String requestedLoginId,RoleFunction domainRoleFunction);
+ void saveRoleFunction(String requestedLoginId,RoleFunction domainRoleFunction) throws Exception;
/**
*
@@ -117,7 +117,7 @@ public interface RoleService {
* @param domainRoleFunction
* Method deleteRoleFunction deletes the requested RoleFunction object
*/
- void deleteRoleFunction(String requestedLoginId,RoleFunction domainRoleFunction);
+ void deleteRoleFunction(String requestedLoginId,RoleFunction domainRoleFunction) throws Exception;
/**
*
diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/RoleServiceCentralizedAccess.java b/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/RoleServiceCentralizedAccess.java
index f507a7fc..c7445b60 100644
--- a/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/RoleServiceCentralizedAccess.java
+++ b/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/RoleServiceCentralizedAccess.java
@@ -1,5 +1,6 @@
package org.openecomp.portalsdk.core.service;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
@@ -72,41 +73,55 @@ public class RoleServiceCentralizedAccess implements RoleService {
@Override
public Role getRole(String loginId, Long id) throws Exception {
ObjectMapper mapper = new ObjectMapper();
-
String roleString = restApiRequestBuilder.getViaREST("/role/" + id, true, loginId);
Role role = null;
-
role = mapper.readValue(roleString, Role.class);
+ if (role.getRoleFunctions() != null) {
+ @SuppressWarnings("unchecked")
+ Set<RoleFunction> roleFunctionList = role.getRoleFunctions();
+ Set<RoleFunction> roleFunctionListNew = new HashSet<>();
+ Iterator<RoleFunction> itetaror = roleFunctionList.iterator();
+ while (itetaror.hasNext()) {
+ Object nextValue = itetaror.next();
+ RoleFunction roleFun = mapper.convertValue(nextValue, RoleFunction.class);
+ roleFunctionListNew.add(roleFun);
+ }
+ role.setRoleFunctions(roleFunctionListNew);
+ }
logger.info(EELFLoggerDelegate.applicationLogger, "role_id" + role.getId());
return role;
}
@Override
- public void saveRole(String loginId, Role domainRole) {
+ public void saveRole(String loginId, Role domainRole) throws Exception {
+ ObjectMapper mapper = new ObjectMapper();
+ String role = mapper.writeValueAsString(domainRole);
try {
- restApiRequestBuilder.postViaREST("/saveRole", true, domainRole.toString(), loginId);
+ restApiRequestBuilder.postViaREST("/saveRole", true, role, loginId);
} catch (Exception e) {
logger.error(EELFLoggerDelegate.errorLogger, "saveRole Failed", e);
+ throw new Exception(e.getMessage());
}
}
@Override
- public void deleteRole(String loginId, Role domainRole) {
-
+ public void deleteRole(String loginId, Role domainRole) throws Exception {
+ ObjectMapper mapper = new ObjectMapper();
+ String role = mapper.writeValueAsString(domainRole);
String filter = " where active_yn = 'Y' ";
try {
- restApiRequestBuilder.deleteViaRest("/deleteRole", true, domainRole.toString(), filter, loginId);
+ restApiRequestBuilder.deleteViaRest("/deleteRole", true, role, filter, loginId);
} catch (Exception e) {
logger.error(EELFLoggerDelegate.errorLogger, "deleteRole Failed", e);
+ throw new Exception(e.getMessage());
}
}
@Override
public List<Role> getAvailableRoles(String requestedLoginId) throws Exception {
ObjectMapper mapper = new ObjectMapper();
-
String roleList = restApiRequestBuilder.getViaREST("/getRoles", true, requestedLoginId);
List<Role> roles = null;
roles = mapper.readValue(roleList,
@@ -117,7 +132,7 @@ public class RoleServiceCentralizedAccess implements RoleService {
@Override
public List<Role> getActiveRoles(String requestedLoginId) throws Exception {
ObjectMapper mapper = new ObjectMapper();
- String roleString = restApiRequestBuilder.getViaREST("/activeRoles?active_yn = 'Y'", true, requestedLoginId);
+ String roleString = restApiRequestBuilder.getViaREST("/activeRoles", true, requestedLoginId);
List<Role> roles = null;
roles = mapper.readValue(roleString,
TypeFactory.defaultInstance().constructCollectionType(List.class, Role.class));
@@ -127,38 +142,41 @@ public class RoleServiceCentralizedAccess implements RoleService {
@Override
public RoleFunction getRoleFunction(String requestedLoginId, String code) throws Exception {
-
ObjectMapper mapper = new ObjectMapper();
String responseString = restApiRequestBuilder.getViaREST("/getRoleFunction/" + code, true, requestedLoginId);
- RoleFunction roleFunction = null;
- roleFunction = mapper.readValue(responseString, RoleFunction.class);
+ RoleFunction roleFunction = new RoleFunction();
+ if (!responseString.isEmpty()) {
+ roleFunction = mapper.readValue(responseString, RoleFunction.class);
+ }
return roleFunction;
}
@Override
- public void saveRoleFunction(String requestedLoginId, RoleFunction domainRoleFunction) {
- try {
- restApiRequestBuilder.postViaREST("/saveRoleFunction", true, domainRoleFunction.toString(),
- requestedLoginId);
- } catch (Exception e) {
- logger.error(EELFLoggerDelegate.errorLogger, "saveRoleFunction Failed", e);
+ public void saveRoleFunction(String requestedLoginId, RoleFunction domainRoleFunction) throws Exception {
+ ObjectMapper mapper = new ObjectMapper();
+ String roleFunction = mapper.writeValueAsString(domainRoleFunction);
+ try{
+ restApiRequestBuilder.postViaREST("/saveRoleFunction", true, roleFunction, requestedLoginId);
+ }catch(Exception e){
+ logger.error(EELFLoggerDelegate.errorLogger, "deleteDependcyRoleRecord Failed", e);
+ throw new Exception(e.getMessage());
}
}
@Override
- public void deleteRoleFunction(String requestedLoginId, RoleFunction domainRoleFunction) {
-
+ public void deleteRoleFunction(String requestedLoginId, RoleFunction domainRoleFunction) throws Exception {
+ ObjectMapper mapper = new ObjectMapper();
+ String roleFunction = mapper.writeValueAsString(domainRoleFunction);
try {
- restApiRequestBuilder.deleteViaRest("/deleteRoleFucntion", true, domainRoleFunction.toString(), null,
- requestedLoginId);
+ restApiRequestBuilder.deleteViaRest("/deleteRoleFunction", true, roleFunction, null, requestedLoginId);
} catch (Exception e) {
logger.error(EELFLoggerDelegate.errorLogger, "deleteRoleFunction Failed", e);
+ throw new Exception(e.getMessage());
}
}
@Override
public void deleteDependcyRoleRecord(String requestedLoginId, Long id) {
-
try {
restApiRequestBuilder.deleteViaRest("/deleteDependcyRoleRecord/" + id, true, null, null, requestedLoginId);
} catch (Exception e) {
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
index c0275b87..528f1bbb 100644
--- 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
@@ -14,7 +14,9 @@ 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
diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/UrlAccessImpl.java b/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/UrlAccessImpl.java
index e01abfbb..7074f512 100644
--- a/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/UrlAccessImpl.java
+++ b/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/UrlAccessImpl.java
@@ -9,14 +9,14 @@ import javax.servlet.http.HttpServletRequest;
import org.openecomp.portalsdk.core.domain.UrlsAccessible;
import org.openecomp.portalsdk.core.web.support.UserUtils;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+@Transactional
public class UrlAccessImpl implements UrlAccessService{
@Autowired
DataAccessService dataAccessService;
-
-
@Override
public boolean isUrlAccessible(HttpServletRequest request, String currentUrl) {
boolean isAccessible = false;
@@ -27,12 +27,6 @@ public class UrlAccessImpl implements UrlAccessService{
// loop through the list of restricted URL's
if (list != null && list.size() > 0) {
for (int i = 0; i < list.size(); i++) {
- /*
- * Object[] restrictedUrl = (Object[])list.get(i);
- *
- * String url = (String)restrictedUrl[0]; String functionCd =
- * (String)restrictedUrl[1];
- */
UrlsAccessible urlFunctions = (UrlsAccessible) list.get(i);
// String url = (String) urlFunctions.getUrl();
String functionCd = (String) urlFunctions.getFunctionCd();
diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/UserProfileService.java b/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/UserProfileService.java
index b844fb0c..2273bad1 100644
--- a/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/UserProfileService.java
+++ b/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/UserProfileService.java
@@ -26,7 +26,6 @@ import org.openecomp.portalsdk.core.domain.User;
public interface UserProfileService {
List<User> findAll();
- User getUser(String id);
User getUserByLoginId(String loginId);
void saveUser(User user);
public List<User> findAllUserWithOnOffline(String originOrgUserId);
diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/UserProfileServiceCentalizedImpl.java b/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/UserProfileServiceCentalizedImpl.java
deleted file mode 100644
index 3e7b2b14..00000000
--- a/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/UserProfileServiceCentalizedImpl.java
+++ /dev/null
@@ -1,137 +0,0 @@
-package org.openecomp.portalsdk.core.service;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.SortedSet;
-
-import org.openecomp.portalsdk.core.domain.Role;
-import org.openecomp.portalsdk.core.domain.User;
-import org.openecomp.portalsdk.core.domain.support.CollaborateList;
-import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.transaction.annotation.Transactional;
-
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.databind.JsonMappingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.type.TypeFactory;
-
-
-@Transactional
-public class UserProfileServiceCentalizedImpl implements UserProfileService {
-
- private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(UserProfileServiceCentalizedImpl.class);
-
- @Autowired
- AppService appService;
-
- @Autowired
- RestApiRequestBuilder restApiRequestBuilder;
-
- @Autowired
- private DataAccessService dataAccessService;
-
- public DataAccessService getDataAccessService() {
- return dataAccessService;
- }
-
- public void setDataAccessService(DataAccessService dataAccessService) {
- this.dataAccessService = dataAccessService;
- }
-
- @Override
- public List<User> findAll() {
- List<User> roles = new ArrayList<>();
- ObjectMapper mapper = new ObjectMapper();
-
- String user = restApiRequestBuilder.getViaREST("/findAll", true,null);
- try {
- roles = mapper.readValue(user,
- TypeFactory.defaultInstance().constructCollectionType(List.class, User.class));
- } catch (JsonParseException e) {
- logger.error(EELFLoggerDelegate.errorLogger, "Json parsing failed", e);
- } catch (JsonMappingException e) {
- logger.error(EELFLoggerDelegate.errorLogger, "Json mapping failed", e);
- } catch (IOException e) {
- logger.error(EELFLoggerDelegate.errorLogger, "IO exception", e);
- }
-
- return roles;
- }
-
- @Override
- public User getUser(String id) {
- ObjectMapper mapper = new ObjectMapper();
- User user = new User();
- String responseString = restApiRequestBuilder.getViaREST("/getUser/" + id, true,id);
- try {
-
- user = mapper.readValue(responseString, User.class);
- } catch (JsonParseException e) {
- logger.error(EELFLoggerDelegate.errorLogger, "Json parsing failed", e);
- } catch (JsonMappingException e) {
- logger.error(EELFLoggerDelegate.errorLogger, "Json mapping failed", e);
- } catch (IOException e) {
- logger.error(EELFLoggerDelegate.errorLogger, "IO exception", e);
- }
-
- return user;
- }
-
- @Override
- public User getUserByLoginId(String loginId) {
- return getUser(loginId);
- }
-
- @Override
- public void saveUser(User user) {
- try {
- getDataAccessService().saveDomainObject(user, null);
- } catch (Exception e) {
- logger.error(EELFLoggerDelegate.errorLogger, "saveUser Failed", e);
- }
- }
-
- @Override
- public List<User> findAllUserWithOnOffline(String originOrgUserId) {
- HashSet<String> onlineUser = CollaborateList.getInstance().getAllUserName();
- List<User> users = findAll();
- for (User u : users) {
- if (onlineUser.contains(u.getOrgUserId()))
- u.setOnline(true);
- if (u.getOrgUserId() != null) {
- if (originOrgUserId.compareTo(u.getOrgUserId()) > 0) {
- u.setChatId(originOrgUserId + "-" + u.getOrgUserId());
- } else
- u.setChatId(u.getOrgUserId() + "-" + originOrgUserId);
- }
- }
- return users;
- }
-
- @Override
- public List<User> findAllActive() {
- List<User> users = findAll();
- Iterator<User> itr = users.iterator();
- while (itr.hasNext()) {
- User u = (User) itr.next();
- if (!u.getActive())
- itr.remove();// if not active remove user from list
- else {
- SortedSet<Role> roles = u.getRoles();
- Iterator<Role> itrRoles = roles.iterator();
- while (itrRoles.hasNext()) {
- Role role = (Role) itrRoles.next();
- if (!role.getActive())
- u.removeRole(role.getId());// if not active remove role
- // from list
- }
- }
- }
- return users;
- }
-
-}
diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/UserProfileServiceImpl.java b/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/UserProfileServiceImpl.java
index 866318c5..93b87594 100644
--- a/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/UserProfileServiceImpl.java
+++ b/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/UserProfileServiceImpl.java
@@ -31,8 +31,10 @@ import org.openecomp.portalsdk.core.domain.Role;
import org.openecomp.portalsdk.core.domain.User;
import org.openecomp.portalsdk.core.domain.support.CollaborateList;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
+@Service("userProfile")
@Transactional
public class UserProfileServiceImpl implements UserProfileService{
@@ -45,10 +47,6 @@ public class UserProfileServiceImpl implements UserProfileService{
return getDataAccessService().getList(User.class, null);
}
- public User getUser(String userId){
- return (User) getDataAccessService().getDomainObject(User.class, Long.parseLong(userId), null);
- }
-
@SuppressWarnings("unchecked")
public User getUserByLoginId(String loginId){
User user=null;
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
new file mode 100644
index 00000000..2cc28cc2
--- /dev/null
+++ b/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/UserService.java
@@ -0,0 +1,16 @@
+package org.openecomp.portalsdk.core.service;
+
+import org.openecomp.portalsdk.core.domain.User;
+
+public interface UserService {
+
+
+ /**
+ *
+ * @param id orgUserID
+ * @return
+ * @throws Exception
+ * Method getUser returns the User Object
+ */
+ User getUser(String id) 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
new file mode 100644
index 00000000..17691908
--- /dev/null
+++ b/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/UserServiceCentalizedImpl.java
@@ -0,0 +1,96 @@
+package org.openecomp.portalsdk.core.service;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+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.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+@Transactional
+public class UserServiceCentalizedImpl implements UserService {
+
+ @Autowired
+ AppService appService;
+
+ @Autowired
+ RestApiRequestBuilder restApiRequestBuilder;
+
+ @Autowired
+ LoginService loginService;
+
+ @Autowired
+ private DataAccessService dataAccessService;
+
+ public DataAccessService getDataAccessService() {
+ return dataAccessService;
+ }
+
+ public void setDataAccessService(DataAccessService dataAccessService) {
+ this.dataAccessService = dataAccessService;
+ }
+
+
+ @Override
+ public User getUser(String id) throws Exception {
+ ObjectMapper mapper = new ObjectMapper();
+ User user = new User();
+ HashSet<RoleFunction> rolefun = null;
+ String orgUserId = getUserByProfileId(id);
+ String responseString = restApiRequestBuilder.getViaREST("/getUser/" + orgUserId, true, id);
+ user = mapper.readValue(responseString, User.class);
+
+ @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();
+
+ Set<RoleFunction> roleFunctionList = role.getRoleFunctions();
+ Set<RoleFunction> roleFunctionListNew = new HashSet<>();
+ 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
new file mode 100644
index 00000000..24404fda
--- /dev/null
+++ b/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/UserServiceImpl.java
@@ -0,0 +1,27 @@
+package org.openecomp.portalsdk.core.service;
+
+import org.openecomp.portalsdk.core.domain.User;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+
+@Transactional
+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);
+
+ }
+
+}
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 6b3dc4dc..ea26b969 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
@@ -26,7 +26,6 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
-import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import java.util.UUID;
@@ -37,7 +36,6 @@ import javax.servlet.http.HttpSession;
import org.openecomp.portalsdk.core.domain.Role;
import org.openecomp.portalsdk.core.domain.RoleFunction;
-import org.openecomp.portalsdk.core.domain.UrlsAccessible;
import org.openecomp.portalsdk.core.domain.User;
import org.openecomp.portalsdk.core.exception.SessionExpiredException;
import org.openecomp.portalsdk.core.lm.FusionLicenseManager;
@@ -46,7 +44,6 @@ import org.openecomp.portalsdk.core.menu.MenuBuilder;
import org.openecomp.portalsdk.core.restful.domain.EcompRole;
import org.openecomp.portalsdk.core.restful.domain.EcompUser;
import org.openecomp.portalsdk.core.service.DataAccessService;
-import org.openecomp.portalsdk.core.service.UrlAccessService;
import org.openecomp.portalsdk.core.util.SystemProperties;
import org.springframework.beans.factory.annotation.Autowired;
@@ -72,9 +69,6 @@ public class UserUtils {
getRoleFunctions(request);
- // truncate the role (and therefore the role function) data to save
- // memory in the session
- user.setRoles(null);
session.setAttribute(SystemProperties.getProperty(SystemProperties.USER_NAME), user.getFullName());
session.setAttribute(SystemProperties.FIRST_NAME, user.getFirstName());
session.setAttribute(SystemProperties.LAST_NAME, user.getLastName());