summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-core/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'ecomp-sdk/epsdk-core/src/main')
-rw-r--r--ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/domain/AuditLog.java9
-rw-r--r--ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/domain/RoleFunction.java19
-rw-r--r--ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/LoginServiceCentralizedImpl.java4
-rw-r--r--ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/RoleServiceCentralizedAccess.java14
-rw-r--r--ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/UserServiceCentalizedImpl.java7
-rw-r--r--ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web/support/UserUtils.java48
6 files changed, 84 insertions, 17 deletions
diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/domain/AuditLog.java b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/domain/AuditLog.java
index b9f49519..2dbe28a3 100644
--- a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/domain/AuditLog.java
+++ b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/domain/AuditLog.java
@@ -77,7 +77,14 @@ public class AuditLog extends DomainVo {
public AuditLog() {
setCreated(new Date());
}
-
+
+ public AuditLog(String activityCode, String affectedRecordId, String comments, Long userId){
+ this.activityCode = activityCode;
+ this.affectedRecordId = affectedRecordId;
+ this.comments = comments;
+ this.userId = userId;
+ setCreated(new Date());
+ }
public String getActivityCode() {
return activityCode;
}
diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/domain/RoleFunction.java b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/domain/RoleFunction.java
index 48c8a4f5..678f95b6 100644
--- a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/domain/RoleFunction.java
+++ b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/domain/RoleFunction.java
@@ -40,6 +40,7 @@ package org.onap.portalsdk.core.domain;
import org.onap.portalsdk.core.domain.support.DomainVo;
import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonInclude;
/**
* <p>
@@ -57,6 +58,24 @@ public class RoleFunction extends DomainVo {
private static final long serialVersionUID = 1L;
private String code;
private String name;
+ private String type;
+ private String action;
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getAction() {
+ return action;
+ }
+
+ public void setAction(String action) {
+ this.action = action;
+ }
public String getName() {
return name;
diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/LoginServiceCentralizedImpl.java b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/LoginServiceCentralizedImpl.java
index 6acd433c..4b31596d 100644
--- a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/LoginServiceCentralizedImpl.java
+++ b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/LoginServiceCentralizedImpl.java
@@ -71,6 +71,8 @@ public class LoginServiceCentralizedImpl extends FusionService implements LoginS
@Autowired
private UserService userService;
+
+ private static String portalApiVersion = "/v1";
@Override
public LoginBean findUser(LoginBean bean, String menuPropertiesFilename,
@@ -210,7 +212,7 @@ public class LoginServiceCentralizedImpl extends FusionService implements LoginS
}
private User findUser(LoginBean bean) throws IOException {
- String repsonse = restApiRequestBuilder.getViaREST("/user/" + bean.getUserid(), true, bean.getUserid());
+ String repsonse = restApiRequestBuilder.getViaREST(portalApiVersion+"/user/" + bean.getUserid(), true, bean.getUserid());
User user = userService.userMapper(repsonse);
user.setId(getUserIdByOrgUserId(user.getOrgUserId()));
return user;
diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/RoleServiceCentralizedAccess.java b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/RoleServiceCentralizedAccess.java
index 777968e5..9f2a48c5 100644
--- a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/RoleServiceCentralizedAccess.java
+++ b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/RoleServiceCentralizedAccess.java
@@ -60,10 +60,12 @@ public class RoleServiceCentralizedAccess implements RoleService {
@Autowired
private RestApiRequestBuilder restApiRequestBuilder;
+
+ private static String portalApiVersion = "/v1";
@Override
public List<RoleFunction> getRoleFunctions(String loginId) throws IOException {
- String roleFunctionString = restApiRequestBuilder.getViaREST("/functions", true, loginId);
+ String roleFunctionString = restApiRequestBuilder.getViaREST(portalApiVersion+"/functions", true, loginId);
ObjectMapper mapper = new ObjectMapper();
List<RoleFunction> roleFunctionList = mapper.readValue(roleFunctionString,
TypeFactory.defaultInstance().constructCollectionType(List.class, RoleFunction.class));
@@ -105,7 +107,7 @@ public class RoleServiceCentralizedAccess implements RoleService {
@Override
public Role getRole(String loginId, Long id) throws IOException {
ObjectMapper mapper = new ObjectMapper();
- String roleString = restApiRequestBuilder.getViaREST("/role/" + id, true, loginId);
+ String roleString = restApiRequestBuilder.getViaREST(portalApiVersion+"/role/" + id, true, loginId);
Role role = mapper.readValue(roleString, Role.class);
if (role.getRoleFunctions() != null) {
@SuppressWarnings("unchecked")
@@ -141,7 +143,7 @@ public class RoleServiceCentralizedAccess implements RoleService {
@Override
public List<Role> getAvailableRoles(String requestedLoginId) throws IOException {
ObjectMapper mapper = new ObjectMapper();
- String roleList = restApiRequestBuilder.getViaREST("/roles", true, requestedLoginId);
+ String roleList = restApiRequestBuilder.getViaREST(portalApiVersion+"/roles", true, requestedLoginId);
List<Role> roles = mapper.readValue(roleList,
TypeFactory.defaultInstance().constructCollectionType(List.class, Role.class));
return roles;
@@ -150,7 +152,7 @@ public class RoleServiceCentralizedAccess implements RoleService {
@Override
public List<Role> getActiveRoles(String requestedLoginId) throws IOException {
ObjectMapper mapper = new ObjectMapper();
- String roleString = restApiRequestBuilder.getViaREST("/activeRoles", true, requestedLoginId);
+ String roleString = restApiRequestBuilder.getViaREST(portalApiVersion+"/activeRoles", true, requestedLoginId);
List<Role> roles = mapper.readValue(roleString,
TypeFactory.defaultInstance().constructCollectionType(List.class, Role.class));
return roles;
@@ -159,7 +161,7 @@ public class RoleServiceCentralizedAccess implements RoleService {
@Override
public RoleFunction getRoleFunction(String requestedLoginId, String code) throws IOException {
ObjectMapper mapper = new ObjectMapper();
- String responseString = restApiRequestBuilder.getViaREST("/function/" + code, true, requestedLoginId);
+ String responseString = restApiRequestBuilder.getViaREST(portalApiVersion+"/function/" + code, true, requestedLoginId);
RoleFunction roleFunction = new RoleFunction();
if (!responseString.isEmpty()) {
roleFunction = mapper.readValue(responseString, RoleFunction.class);
@@ -171,7 +173,7 @@ public class RoleServiceCentralizedAccess implements RoleService {
public void saveRoleFunction(String requestedLoginId, RoleFunction domainRoleFunction) throws IOException {
ObjectMapper mapper = new ObjectMapper();
String roleFunction = mapper.writeValueAsString(domainRoleFunction);
- restApiRequestBuilder.postViaREST("/roleFunction", true, roleFunction, requestedLoginId);
+ restApiRequestBuilder.postViaREST(portalApiVersion+"/roleFunction", true, roleFunction, requestedLoginId);
}
@Override
diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/UserServiceCentalizedImpl.java b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/UserServiceCentalizedImpl.java
index d1b05695..646581ae 100644
--- a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/UserServiceCentalizedImpl.java
+++ b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/UserServiceCentalizedImpl.java
@@ -51,6 +51,7 @@ import org.onap.portalsdk.core.domain.Role;
import org.onap.portalsdk.core.domain.RoleFunction;
import org.onap.portalsdk.core.domain.User;
import org.onap.portalsdk.core.domain.UserApp;
+import org.onap.portalsdk.core.web.support.UserUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
@@ -64,6 +65,8 @@ public class UserServiceCentalizedImpl implements UserService {
@Autowired
private DataAccessService dataAccessService;
+
+ private static String portalApiVersion = "/v1";
public DataAccessService getDataAccessService() {
return dataAccessService;
@@ -76,7 +79,7 @@ public class UserServiceCentalizedImpl implements UserService {
@Override
public User getUser(String id) throws IOException {
String orgUserId = getUserByProfileId(id);
- String responseString = restApiRequestBuilder.getViaREST("/user/" + orgUserId, true, id);
+ String responseString = restApiRequestBuilder.getViaREST(portalApiVersion+"/user/" + orgUserId, true, id);
User user = userMapper(responseString);
return user;
}
@@ -96,7 +99,6 @@ public class UserServiceCentalizedImpl implements UserService {
public User userMapper(String res) throws IOException {
ObjectMapper mapper = new ObjectMapper();
User user = mapper.readValue(res, User.class);
- Set<RoleFunction> roleFunctionListNew = new HashSet<>();
SortedSet<UserApp> userAppSet = new TreeSet<>();
@SuppressWarnings("unchecked")
Set<UserApp> setAppsObj = user.getUserApps();
@@ -108,6 +110,7 @@ public class UserServiceCentalizedImpl implements UserService {
@SuppressWarnings("unchecked")
Set<RoleFunction> roleFunctionList = role.getRoleFunctions();
Iterator<RoleFunction> roleFnIter = roleFunctionList.iterator();
+ Set<RoleFunction> roleFunctionListNew = new HashSet<>();
while (roleFnIter.hasNext()) {
Object nextValue = roleFnIter.next();
RoleFunction roleFunction = mapper.convertValue(nextValue, RoleFunction.class);
diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web/support/UserUtils.java b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web/support/UserUtils.java
index bd7d5ed5..a6ed1e95 100644
--- a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web/support/UserUtils.java
+++ b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web/support/UserUtils.java
@@ -60,9 +60,12 @@ import org.onap.portalsdk.core.exception.SessionExpiredException;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.onap.portalsdk.core.menu.MenuBuilder;
import org.onap.portalsdk.core.restful.domain.EcompRole;
+import org.onap.portalsdk.core.restful.domain.EcompRoleFunction;
import org.onap.portalsdk.core.restful.domain.EcompUser;
import org.onap.portalsdk.core.util.SystemProperties;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
@SuppressWarnings("rawtypes")
public class UserUtils {
@@ -333,6 +336,8 @@ public class UserUtils {
* @return EcompUser with a subset of fields.
*/
public static EcompUser convertToEcompUser(User user) {
+ ObjectMapper mapper = new ObjectMapper();
+
EcompUser userJson = new EcompUser();
userJson.setEmail(user.getEmail());
userJson.setFirstName(user.getFirstName());
@@ -348,7 +353,12 @@ public class UserUtils {
userJson.setOrgUserId(user.getOrgUserId());
userJson.setActive(user.getActive());
Set<EcompRole> ecompRoles = new TreeSet<>();
- for (Role role : user.getRoles()) {
+ Set<Role> roles = user.getRoles();
+ Iterator<Role> roleIter = roles.iterator();
+
+ while (roleIter.hasNext()) {
+ Object nextValue = roleIter.next();
+ Role role = mapper.convertValue(nextValue, Role.class);
ecompRoles.add(convertToEcompRole(role));
}
userJson.setRoles(ecompRoles);
@@ -362,11 +372,35 @@ public class UserUtils {
* @param role
* @return EcompRole with a subset of fields: ID and name
*/
- public static EcompRole convertToEcompRole(Role role) {
- EcompRole ecompRole = new EcompRole();
- ecompRole.setId(role.getId());
- ecompRole.setName(role.getName());
- return ecompRole;
- }
+ public static EcompRole convertToEcompRole(Role role) {
+ ObjectMapper mapper = new ObjectMapper();
+
+ EcompRole ecompRole = new EcompRole();
+ ecompRole.setId(role.getId());
+ ecompRole.setName(role.getName());
+ Set<EcompRoleFunction> ecompRolefunctions = new TreeSet<>();
+ @SuppressWarnings("unchecked")
+ Set<RoleFunction> rolefunctions = role.getRoleFunctions();
+ Iterator<RoleFunction> roleFnIter = rolefunctions.iterator();
+ while (roleFnIter.hasNext()) {
+ Object nextValue = roleFnIter.next();
+ RoleFunction roleFunction = mapper.convertValue(nextValue, RoleFunction.class);
+ ecompRolefunctions.add(convertToEcompRoleFunction(roleFunction));
+ }
+ ecompRole.setRoleFunctions(ecompRolefunctions);
+ return ecompRole;
+ }
+
+ public static EcompRoleFunction convertToEcompRoleFunction(RoleFunction rolefun)
+ {
+ EcompRoleFunction ecompRoleFunction = new EcompRoleFunction();
+ ecompRoleFunction.setName(rolefun.getName());
+ ecompRoleFunction.setCode(rolefun.getCode());
+ ecompRoleFunction.setType(rolefun.getType());
+ ecompRoleFunction.setAction(rolefun.getAction());
+ return ecompRoleFunction;
+ }
+
+
}