diff options
author | st782s <statta@research.att.com> | 2017-07-27 09:57:46 -0400 |
---|---|---|
committer | st782s <statta@research.att.com> | 2017-07-27 12:37:10 -0400 |
commit | ac05129bf7c8fbe62f17647f6233ce01a58ca1a3 (patch) | |
tree | 305fe715730297eaa9a6d12ba40ee19c00c0bb8c /ecomp-sdk | |
parent | cb02f8fc9b1d6233fc75fe37db313abd32edf6cb (diff) |
Role centralization
Adding functionality to account for global roles across all applications
which will be added at portal level
Issue: [PORTAL-21]
Change-Id: I4cdee652aaaa124abddb63410e1e45257b5bb6e0
Signed-off-by: st782s <statta@research.att.com>
Diffstat (limited to 'ecomp-sdk')
9 files changed, 46 insertions, 42 deletions
diff --git a/ecomp-sdk/epsdk-app-common/pom.xml b/ecomp-sdk/epsdk-app-common/pom.xml index 66fd4e35..40f9dfb7 100644 --- a/ecomp-sdk/epsdk-app-common/pom.xml +++ b/ecomp-sdk/epsdk-app-common/pom.xml @@ -18,7 +18,6 @@ <properties> <encoding>UTF-8</encoding> - <epsdk.version>1.3.0-SNAPSHOT</epsdk.version> <springframework.version>4.2.0.RELEASE</springframework.version> <hibernate.version>4.3.11.Final</hibernate.version> <!-- Skip assembling the zip; assemble via mvn -Dskipassembly=false .. --> @@ -158,17 +157,17 @@ <dependency> <groupId>org.onap.portal.sdk</groupId> <artifactId>epsdk-core</artifactId> - <version>${epsdk.version}</version> + <version>${project.version}</version> </dependency> <dependency> <groupId>org.onap.portal.sdk</groupId> <artifactId>epsdk-analytics</artifactId> - <version>${epsdk.version}</version> + <version>${project.version}</version> </dependency> <dependency> <groupId>org.onap.portal.sdk</groupId> <artifactId>epsdk-workflow</artifactId> - <version>${epsdk.version}</version> + <version>${project.version}</version> </dependency> <dependency> <groupId>com.att.eelf</groupId> 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 8b83b389..6b00d3fb 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 @@ -97,27 +97,6 @@ public class AccessConfiguration { return new ProfileServiceCentralizedImpl(); } - /** - * - * @return returns UrlAccessCentalizedImpl bean if CentralAccessCondition is true - */ - @Bean - @Conditional(CentralAccessCondition.class) - public UrlAccessService userUtilsCentalizedImpl() { - return new UrlAccessCentalizedImpl(); - } - - - /** - * - * @return returns UrlAccessImpl bean if LocalAccessCondition is true - */ - @Bean - @Conditional(LocalAccessCondition.class) - public UrlAccessService urlAccessImpl() { - return new UrlAccessImpl(); - } - /** * 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 6d723afa..1bfe2aba 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 @@ -138,7 +138,7 @@ public class LoginServiceCentralizedImpl extends FusionService implements LoginS ObjectMapper mapper = new ObjectMapper(); HashSet<RoleFunction> rolefun = null; - String repsonse = restApiRequestBuilder.getViaREST("/getUser/" + bean.getUserid(), true, bean.getUserid()); + String repsonse = restApiRequestBuilder.getViaREST("/user/" + bean.getUserid(), true, bean.getUserid()); user = mapper.readValue(repsonse, User.class); 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 e0b97254..dd4b16f9 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 @@ -51,7 +51,7 @@ public class ProfileServiceCentralizedImpl implements ProfileService{ public User getUser(String id) throws Exception{ ObjectMapper mapper = new ObjectMapper(); User user = new User(); - String responseString =restApiRequestBuilder.getViaREST("/getUser/" + id, true,id); + String responseString =restApiRequestBuilder.getViaREST("/user/" + id, true,id); user = mapper.readValue(responseString, User.class); return user; 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 c7445b60..eff02543 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 @@ -31,7 +31,7 @@ public class RoleServiceCentralizedAccess implements RoleService { List<RoleFunction> roleFunctionList = null; String role_function_list = ""; - role_function_list = restApiRequestBuilder.getViaREST("/getAllRoleFunctions", true, loginId); + role_function_list = restApiRequestBuilder.getViaREST("/functions", true, loginId); ObjectMapper mapper = new ObjectMapper(); roleFunctionList = mapper.readValue(role_function_list, TypeFactory.defaultInstance().constructCollectionType(List.class, RoleFunction.class)); @@ -74,7 +74,7 @@ public class RoleServiceCentralizedAccess implements RoleService { 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 role = new Role(); role = mapper.readValue(roleString, Role.class); if (role.getRoleFunctions() != null) { @SuppressWarnings("unchecked") @@ -99,7 +99,7 @@ public class RoleServiceCentralizedAccess implements RoleService { ObjectMapper mapper = new ObjectMapper(); String role = mapper.writeValueAsString(domainRole); try { - restApiRequestBuilder.postViaREST("/saveRole", true, role, loginId); + restApiRequestBuilder.postViaREST("/role", true, role, loginId); } catch (Exception e) { logger.error(EELFLoggerDelegate.errorLogger, "saveRole Failed", e); throw new Exception(e.getMessage()); @@ -110,19 +110,18 @@ public class RoleServiceCentralizedAccess implements RoleService { public void deleteRole(String loginId, Role domainRole) throws Exception { ObjectMapper mapper = new ObjectMapper(); String role = mapper.writeValueAsString(domainRole); - String filter = " where active_yn = 'Y' "; + String roleName = domainRole.getName().replaceAll(" ", "%20"); try { - restApiRequestBuilder.deleteViaRest("/deleteRole", true, role, filter, loginId); + restApiRequestBuilder.deleteViaRest("/deleteRole/"+ roleName, true, role, null, 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); + String roleList = restApiRequestBuilder.getViaREST("/roles", true, requestedLoginId); List<Role> roles = null; roles = mapper.readValue(roleList, TypeFactory.defaultInstance().constructCollectionType(List.class, Role.class)); @@ -143,7 +142,7 @@ 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); + String responseString = restApiRequestBuilder.getViaREST("/function/" + code, true, requestedLoginId); RoleFunction roleFunction = new RoleFunction(); if (!responseString.isEmpty()) { roleFunction = mapper.readValue(responseString, RoleFunction.class); @@ -156,21 +155,22 @@ public class RoleServiceCentralizedAccess implements RoleService { ObjectMapper mapper = new ObjectMapper(); String roleFunction = mapper.writeValueAsString(domainRoleFunction); try{ - restApiRequestBuilder.postViaREST("/saveRoleFunction", true, roleFunction, requestedLoginId); + restApiRequestBuilder.postViaREST("/roleFunction", true, roleFunction, requestedLoginId); }catch(Exception e){ - logger.error(EELFLoggerDelegate.errorLogger, "deleteDependcyRoleRecord Failed", e); + logger.error(EELFLoggerDelegate.errorLogger, "saveRoleFunction Failed", e); throw new Exception(e.getMessage()); } } @Override public void deleteRoleFunction(String requestedLoginId, RoleFunction domainRoleFunction) throws Exception { + String code = domainRoleFunction.getCode(); ObjectMapper mapper = new ObjectMapper(); String roleFunction = mapper.writeValueAsString(domainRoleFunction); try { - restApiRequestBuilder.deleteViaRest("/deleteRoleFunction", true, roleFunction, null, requestedLoginId); + restApiRequestBuilder.deleteViaRest("/roleFunction/"+ code, true, roleFunction, null, requestedLoginId); } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "deleteRoleFunction Failed", e); + logger.error(EELFLoggerDelegate.errorLogger, "deleteRoleFunction Failed ", e); throw new Exception(e.getMessage()); } } 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 7074f512..02cb7807 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,9 +9,11 @@ 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.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @Transactional +@Service("urlAccessService") public class UrlAccessImpl implements UrlAccessService{ @Autowired 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 17691908..879b2a9a 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 @@ -48,7 +48,7 @@ public class UserServiceCentalizedImpl implements UserService { User user = new User(); HashSet<RoleFunction> rolefun = null; String orgUserId = getUserByProfileId(id); - String responseString = restApiRequestBuilder.getViaREST("/getUser/" + orgUserId, true, id); + String responseString = restApiRequestBuilder.getViaREST("/user/" + orgUserId, true, id); user = mapper.readValue(responseString, User.class); @SuppressWarnings("unchecked") diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/rest/RestWebServiceClient.java b/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/rest/RestWebServiceClient.java index 1d4feb07..fa7a1478 100644 --- a/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/rest/RestWebServiceClient.java +++ b/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/rest/RestWebServiceClient.java @@ -183,8 +183,16 @@ public class RestWebServiceClient { // Create the connection object HttpURLConnection con = (HttpURLConnection) obj.openConnection(); con.setRequestMethod("GET"); + con.setConnectTimeout(3000); + // if the portal property is set then gets the timeout value from portal properties + if(PortalApiProperties.getProperty(PortalApiConstants.EXT_REQUEST_CONNECTION_TIMEOUT)!= null){ + con.setConnectTimeout(Integer.parseInt(PortalApiProperties.getProperty(PortalApiConstants.EXT_REQUEST_CONNECTION_TIMEOUT))); + } con.setReadTimeout(8000); + if(PortalApiProperties.getProperty(PortalApiConstants.EXT_REQUEST_READ_TIMEOUT)!= null){ + con.setReadTimeout(Integer.parseInt(PortalApiProperties.getProperty(PortalApiConstants.EXT_REQUEST_READ_TIMEOUT))); + } // add request header con.setRequestProperty("uebkey", appUebKey); @@ -325,9 +333,17 @@ public class RestWebServiceClient { // Create the connection object HttpURLConnection con = (HttpURLConnection) obj.openConnection(); con.setRequestMethod("POST"); + con.setConnectTimeout(3000); + // if the portal property is set then gets the timeout value from portal properties + if(PortalApiProperties.getProperty(PortalApiConstants.EXT_REQUEST_CONNECTION_TIMEOUT)!= null){ + con.setConnectTimeout(Integer.parseInt(PortalApiProperties.getProperty(PortalApiConstants.EXT_REQUEST_CONNECTION_TIMEOUT))); + } con.setReadTimeout(15000); - + if(PortalApiProperties.getProperty(PortalApiConstants.EXT_REQUEST_READ_TIMEOUT)!= null){ + con.setReadTimeout(Integer.parseInt(PortalApiProperties.getProperty(PortalApiConstants.EXT_REQUEST_READ_TIMEOUT))); + } + // add request header con.setRequestProperty("uebkey", appUebKey); if (appUserName != null) @@ -414,8 +430,14 @@ public class RestWebServiceClient { HttpURLConnection con = (HttpURLConnection) obj.openConnection(); con.setRequestMethod("DELETE"); con.setConnectTimeout(3000); + // if the portal property is set then gets the timeout value from portal properties + if(PortalApiProperties.getProperty(PortalApiConstants.EXT_REQUEST_CONNECTION_TIMEOUT)!= null){ + con.setConnectTimeout(Integer.parseInt(PortalApiProperties.getProperty(PortalApiConstants.EXT_REQUEST_CONNECTION_TIMEOUT))); + } con.setReadTimeout(15000); - + if(PortalApiProperties.getProperty(PortalApiConstants.EXT_REQUEST_READ_TIMEOUT)!= null){ + con.setReadTimeout(Integer.parseInt(PortalApiProperties.getProperty(PortalApiConstants.EXT_REQUEST_READ_TIMEOUT))); + } // add request header con.setRequestProperty("uebkey", appUebKey); if (appUserName != null) diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/util/PortalApiConstants.java b/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/util/PortalApiConstants.java index 196d2100..7f42a1d5 100644 --- a/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/util/PortalApiConstants.java +++ b/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/util/PortalApiConstants.java @@ -63,4 +63,6 @@ public interface PortalApiConstants { //encrpt key public static final String Decryption_Key = "decryption_key"; + public static final String EXT_REQUEST_CONNECTION_TIMEOUT = "ext_req_connection_timeout"; + public static final String EXT_REQUEST_READ_TIMEOUT = "ext_req_read_timeout"; } |