summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk
diff options
context:
space:
mode:
authorsa282w <sa282w@att.com>2018-05-02 17:00:20 -0400
committersa282w <sa282w@att.com>2018-05-03 16:51:59 -0400
commit22ed5d7b533cec97713c3b5aef37319d5dead6a3 (patch)
treedf40d050750cab3cf9b78e9820dd0bde8d16eaa9 /ecomp-sdk
parentc607da68bfb7f7440d5be7f0396609dc01eb0e90 (diff)
API Versioning for ECOMP Components in SDK
Issue-ID: PORTAL-263 Included the api version changes for SDK. Change-Id: Ib81c5aabe585f6e2775e73a692153d1f286d1f45 Signed-off-by: sa282w <sa282w@att.com>
Diffstat (limited to 'ecomp-sdk')
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/AngularAdminController.java3
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/service/OnBoardingApiServiceImpl.java11
-rw-r--r--ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/service/OnBoardingApiServiceImplTest.java12
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-directives/footer.js2
-rw-r--r--ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/FunctionalMenuListServiceCentralizedImpl.java3
-rw-r--r--ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/RoleServiceCentralizedAccess.java4
-rw-r--r--ecomp-sdk/epsdk-core/src/test/java/org/onap/portalsdk/core/service/FunctionalMenuListServiceCentralizedImplTest.java2
-rw-r--r--ecomp-sdk/epsdk-core/src/test/java/org/onap/portalsdk/core/service/RoleServiceCentralizedAccessTest.java10
-rw-r--r--ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/IPortalRestAPIService.java3
-rw-r--r--ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/PortalRestAPICentralServiceImpl.java24
-rw-r--r--ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/PortalRestAPIProxy.java42
-rw-r--r--ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/SessionCommunicationService.java3
-rw-r--r--ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/rest/FunctionalMenuClient.java3
-rw-r--r--ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/rest/RestWebServiceClient.java5
-rw-r--r--ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/util/PortalApiConstants.java2
-rw-r--r--ecomp-sdk/epsdk-fw/src/test/java/org/onap/portalsdk/fw/test/SessionSlotCheckIntervalTest.java9
16 files changed, 103 insertions, 35 deletions
diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/AngularAdminController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/AngularAdminController.java
index 138a805d..3aeb0147 100644
--- a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/AngularAdminController.java
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/AngularAdminController.java
@@ -49,8 +49,9 @@ import org.springframework.web.servlet.ModelAndView;
@Controller
@RequestMapping("/")
public class AngularAdminController extends RestrictedBaseController{
+ public static final String API_VERSION = "/v3";
- @RequestMapping(value = {"/userProfile" }, method = RequestMethod.GET)
+ @RequestMapping(value = {API_VERSION + "/userProfile" }, method = RequestMethod.GET)
public ModelAndView view() {
Map<String, Object> model = new HashMap<>();
return new ModelAndView("user_profile_list","model", model);
diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/service/OnBoardingApiServiceImpl.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/service/OnBoardingApiServiceImpl.java
index 46306817..871a3750 100644
--- a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/service/OnBoardingApiServiceImpl.java
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/service/OnBoardingApiServiceImpl.java
@@ -106,7 +106,7 @@ public class OnBoardingApiServiceImpl implements IPortalRestAPIService, IPortalR
.getProperty(PortalApiConstants.ROLE_ACCESS_CENTRALIZED);
private static final String isCentralized = "remote";
- private static String portalApiVersion = "/v1";
+ private static String portalApiVersion = "/v3";
public OnBoardingApiServiceImpl() {
// Defend against null-pointer exception during server startup
@@ -267,7 +267,7 @@ public class OnBoardingApiServiceImpl implements IPortalRestAPIService, IPortalR
if (isCentralized.equals(isAccessCentralized)) {
List<EcompUser> UsersList = new ArrayList<>();
List<EcompUser> finalUsersList = new ArrayList<>();
- users_List = restApiRequestBuilder.getViaREST("/users", true, null);
+ users_List = restApiRequestBuilder.getViaREST(portalApiVersion + "/users", true, null);
ObjectMapper mapper = new ObjectMapper();
UsersList = mapper.readValue(users_List,
TypeFactory.defaultInstance().constructCollectionType(List.class, EcompUser.class));
@@ -476,4 +476,11 @@ public class OnBoardingApiServiceImpl implements IPortalRestAPIService, IPortalR
credentialsMap.put("appName", appName);
return credentialsMap;
}
+
+ @Override
+ public Map<String, String> getCredentials() throws PortalAPIException{
+ return getAppCredentials();
+ }
+
+
}
diff --git a/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/service/OnBoardingApiServiceImplTest.java b/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/service/OnBoardingApiServiceImplTest.java
index 857a25eb..6ddcbcfb 100644
--- a/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/service/OnBoardingApiServiceImplTest.java
+++ b/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/service/OnBoardingApiServiceImplTest.java
@@ -172,7 +172,7 @@ public class OnBoardingApiServiceImplTest {
Mockito.when(PortalApiProperties.getProperty(PortalApiConstants.ROLE_ACCESS_CENTRALIZED)).thenReturn("remote");
String responseString = "Response";
- Mockito.when(restApiRequestBuilder.getViaREST("/v1/user/" + loginId, true, loginId)).thenReturn(responseString);
+ Mockito.when(restApiRequestBuilder.getViaREST("/v3/user/" + loginId, true, loginId)).thenReturn(responseString);
Mockito.when(userService.userMapper(responseString)).thenReturn(new User());
OnBoardingApiServiceImpl onBoardingApiServiceImpl = new OnBoardingApiServiceImpl();
@@ -200,7 +200,7 @@ public class OnBoardingApiServiceImplTest {
PowerMockito.mockStatic(PortalApiProperties.class);
Mockito.when(PortalApiProperties.getProperty(PortalApiConstants.ROLE_ACCESS_CENTRALIZED)).thenReturn("local");
String responseString = "Response";
- Mockito.when(restApiRequestBuilder.getViaREST("/v1/user/" + loginId, true, loginId)).thenThrow(IOException.class);
+ Mockito.when(restApiRequestBuilder.getViaREST("/v3/user/" + loginId, true, loginId)).thenThrow(IOException.class);
Mockito.when(userService.userMapper(responseString)).thenReturn(null);
OnBoardingApiServiceImpl onBoardingApiServiceImpl = new OnBoardingApiServiceImpl();
@@ -215,7 +215,7 @@ public class OnBoardingApiServiceImplTest {
OnBoardingApiServiceImpl onBoardingApiServiceImpl = new OnBoardingApiServiceImpl();
String responseString = "[ {\"firstName\":\"Name\"}]";
- Mockito.when(restApiRequestBuilder.getViaREST("/users", true, null)).thenReturn(responseString);
+ Mockito.when(restApiRequestBuilder.getViaREST("/v3/users", true, null)).thenReturn(responseString);
List<EcompUser> users = onBoardingApiServiceImpl.getUsers();
Assert.assertNotNull(users);
}
@@ -227,7 +227,7 @@ public class OnBoardingApiServiceImplTest {
OnBoardingApiServiceImpl onBoardingApiServiceImpl = new OnBoardingApiServiceImpl();
String responseString = " { [ {\"firstName\":\"Name\"} ] }";
- Mockito.when(restApiRequestBuilder.getViaREST("/users", true, null)).thenReturn(responseString);
+ Mockito.when(restApiRequestBuilder.getViaREST("/v3/users", true, null)).thenReturn(responseString);
onBoardingApiServiceImpl.getUsers();
}
@@ -319,7 +319,7 @@ public class OnBoardingApiServiceImplTest {
public void getUserRolesTest() throws Exception {
String loginId = "123";
String responseString = "Response";
- Mockito.when(restApiRequestBuilder.getViaREST("/v1/user/" + loginId, true, loginId)).thenReturn(responseString);
+ Mockito.when(restApiRequestBuilder.getViaREST("/v3/user/" + loginId, true, loginId)).thenReturn(responseString);
User user = new User();
SortedSet<Role> currentRoles = new TreeSet<>();
Role role = new Role();
@@ -335,7 +335,7 @@ public class OnBoardingApiServiceImplTest {
@Test(expected = org.onap.portalsdk.core.onboarding.exception.PortalAPIException.class)
public void getUserRolesExceptionTest() throws Exception {
String loginId = "123";
- Mockito.when(restApiRequestBuilder.getViaREST("/v1/user/" + loginId, true, loginId)).thenThrow(IOException.class);
+ Mockito.when(restApiRequestBuilder.getViaREST("/v3/user/" + loginId, true, loginId)).thenThrow(IOException.class);
OnBoardingApiServiceImpl onBoardingApiServiceImpl = new OnBoardingApiServiceImpl();
onBoardingApiServiceImpl.getUserRoles(loginId);
}
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-directives/footer.js b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-directives/footer.js
index e11c3a05..34eaab9d 100644
--- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-directives/footer.js
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-directives/footer.js
@@ -17,7 +17,7 @@ $(function() {
portalHook();
function portalHook() {
var script = document.createElement('script');
- script.src = "api/v2/analytics"
+ script.src = "api/v3/analytics"
script.async = true;
script.onload = function() {
runAnalytics(); //runAnaltics() has endpoint in epsdk-fw library.
diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/FunctionalMenuListServiceCentralizedImpl.java b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/FunctionalMenuListServiceCentralizedImpl.java
index 1d503a81..cdcd1d7a 100644
--- a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/FunctionalMenuListServiceCentralizedImpl.java
+++ b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/FunctionalMenuListServiceCentralizedImpl.java
@@ -51,6 +51,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.type.TypeFactory;
public class FunctionalMenuListServiceCentralizedImpl implements FunctionalMenuListService {
+ private static String portalApiVersion = "/v3";
@Autowired
private RestApiRequestBuilder restApiRequestBuilder;
@@ -59,7 +60,7 @@ public class FunctionalMenuListServiceCentralizedImpl implements FunctionalMenuL
public List<RoleFunction> getFunctionCDList(HttpServletRequest request) throws IOException {
User user = UserUtils.getUserSession(request);
ObjectMapper mapper = new ObjectMapper();
- String menuList = restApiRequestBuilder.getViaREST("/menuFunctions", true, user.getOrgUserId());
+ String menuList = restApiRequestBuilder.getViaREST( portalApiVersion + "/menuFunctions", true, user.getOrgUserId());
List<RoleFunction> roleFunctionFinalList = mapper.readValue(menuList,
TypeFactory.defaultInstance().constructCollectionType(List.class, String.class));
return roleFunctionFinalList;
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 88633abe..02a5ed30 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
@@ -61,7 +61,7 @@ public class RoleServiceCentralizedAccess implements RoleService {
@Autowired
private RestApiRequestBuilder restApiRequestBuilder;
- private static String portalApiVersion = "/v1";
+ private static String portalApiVersion = "/v3";
@Override
public List<RoleFunction> getRoleFunctions(String loginId) throws IOException {
@@ -137,7 +137,7 @@ public class RoleServiceCentralizedAccess implements RoleService {
@Override
public void deleteRole(String loginId, Role domainRole) throws IOException {
Long roleId = domainRole.getId();
- restApiRequestBuilder.deleteViaRest("v2/deleteRole/" + roleId, true, null, loginId);
+ restApiRequestBuilder.deleteViaRest("v3/deleteRole/" + roleId, true, null, loginId);
}
@Override
diff --git a/ecomp-sdk/epsdk-core/src/test/java/org/onap/portalsdk/core/service/FunctionalMenuListServiceCentralizedImplTest.java b/ecomp-sdk/epsdk-core/src/test/java/org/onap/portalsdk/core/service/FunctionalMenuListServiceCentralizedImplTest.java
index d1bd2dd3..e7f9d41b 100644
--- a/ecomp-sdk/epsdk-core/src/test/java/org/onap/portalsdk/core/service/FunctionalMenuListServiceCentralizedImplTest.java
+++ b/ecomp-sdk/epsdk-core/src/test/java/org/onap/portalsdk/core/service/FunctionalMenuListServiceCentralizedImplTest.java
@@ -70,7 +70,7 @@ public class FunctionalMenuListServiceCentralizedImplTest {
user.setOrgId(123L);
PowerMockito.mockStatic(UserUtils.class);
Mockito.when(UserUtils.getUserSession(mockedRequest)).thenReturn(user);
- Mockito.when(restApiRequestBuilder.getViaREST("/menuFunctions", true, user.getOrgUserId())).thenReturn("");
+ Mockito.when(restApiRequestBuilder.getViaREST("/v3/menuFunctions", true, user.getOrgUserId())).thenReturn("");
fmServiceCentralizedImpl.getFunctionCDList(mockedRequest);
}
diff --git a/ecomp-sdk/epsdk-core/src/test/java/org/onap/portalsdk/core/service/RoleServiceCentralizedAccessTest.java b/ecomp-sdk/epsdk-core/src/test/java/org/onap/portalsdk/core/service/RoleServiceCentralizedAccessTest.java
index bb8fb6da..c53eb2a4 100644
--- a/ecomp-sdk/epsdk-core/src/test/java/org/onap/portalsdk/core/service/RoleServiceCentralizedAccessTest.java
+++ b/ecomp-sdk/epsdk-core/src/test/java/org/onap/portalsdk/core/service/RoleServiceCentralizedAccessTest.java
@@ -74,7 +74,7 @@ public class RoleServiceCentralizedAccessTest {
String loginId = "123";
Long roleId = null;
String response ="[ { \"active\" : true, \"name\" : \"xyz\" } ]";
- Mockito.when(restApiRequestBuilder.getViaREST("/v1/roles", true, loginId)).thenReturn(response);
+ Mockito.when(restApiRequestBuilder.getViaREST("/v3/roles", true, loginId)).thenReturn(response);
List<Role> roles = roleServiceCntrlAccess.getAvailableChildRoles(loginId, roleId);
Assert.assertNotNull(roles);
}
@@ -84,7 +84,7 @@ public class RoleServiceCentralizedAccessTest {
String loginId = "123";
Long roleId = 0L;
String response ="[ { \"active\" : true, \"name\" : \"xyz\" } ]";
- Mockito.when(restApiRequestBuilder.getViaREST("/v1/roles", true, loginId)).thenReturn(response);
+ Mockito.when(restApiRequestBuilder.getViaREST("/v3/roles", true, loginId)).thenReturn(response);
List<Role> roles = roleServiceCntrlAccess.getAvailableChildRoles(loginId, roleId);
Assert.assertNotNull(roles);
}
@@ -94,9 +94,9 @@ public class RoleServiceCentralizedAccessTest {
String loginId = "123";
Long roleId = 123L;
String response ="[ { \"active\" : false, \"name\" : \"xyz\" } ]";
- Mockito.when(restApiRequestBuilder.getViaREST("/v1/roles", true, loginId)).thenReturn(response);
+ Mockito.when(restApiRequestBuilder.getViaREST("/v3/roles", true, loginId)).thenReturn(response);
String roleResponse =" { \"active\" : true, \"name\" : \"xyz\", \"roleFunctions\" : [ { \"code\" : \"abc\", \"name\" : \"RF1\" , \"type\" : \"abc\", \"action\" : \"abc\" }, { \"code\" : \"pqr\", \"name\" : \"RF2\" , \"type\" : \"abc\", \"action\" : \"abc\" } ] , \"parentRoles\": [ {\"active\" : false, \"name\" : \"XYZ-ABC\"}, {\"active\" : true, \"name\" : \"ABC\"} ] } ";
- Mockito.when(restApiRequestBuilder.getViaREST("/v1/role/" + roleId, true, loginId)).thenReturn(roleResponse);
+ Mockito.when(restApiRequestBuilder.getViaREST("/v3/role/" + roleId, true, loginId)).thenReturn(roleResponse);
roleServiceCntrlAccess.getAvailableChildRoles(loginId, roleId);
Assert.assertTrue(true);
}
@@ -122,7 +122,7 @@ public class RoleServiceCentralizedAccessTest {
public void getActiveRolesTest() throws Exception {
String requestedLoginId ="1234";
String response ="[ { \"active\" : true, \"name\" : \"role1\" }, { \"active\" : false, \"name\" : \"role2\" } ]";
- Mockito.when(restApiRequestBuilder.getViaREST("/v1/activeRoles", true, requestedLoginId)).thenReturn(response);
+ Mockito.when(restApiRequestBuilder.getViaREST("/v3/activeRoles", true, requestedLoginId)).thenReturn(response);
List<Role> roles = roleServiceCntrlAccess.getActiveRoles(requestedLoginId);
Assert.assertNotNull(roles);
}
diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/IPortalRestAPIService.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/IPortalRestAPIService.java
index 6f8c50ae..f82e8737 100644
--- a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/IPortalRestAPIService.java
+++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/IPortalRestAPIService.java
@@ -38,6 +38,7 @@
package org.onap.portalsdk.core.onboarding.crossapi;
import java.util.List;
+import java.util.Map;
import javax.servlet.http.HttpServletRequest;
@@ -190,5 +191,7 @@ public interface IPortalRestAPIService {
* If an unexpected error occurs while processing the request.
*/
public String getUserId(HttpServletRequest request) throws PortalAPIException;
+
+ public Map<String, String> getCredentials() throws PortalAPIException;
}
diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/PortalRestAPICentralServiceImpl.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/PortalRestAPICentralServiceImpl.java
index a82517d8..208e8c3d 100644
--- a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/PortalRestAPICentralServiceImpl.java
+++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/PortalRestAPICentralServiceImpl.java
@@ -39,15 +39,19 @@ package org.onap.portalsdk.core.onboarding.crossapi;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
+import org.onap.portalsdk.core.onboarding.exception.CipherUtilException;
import org.onap.portalsdk.core.onboarding.exception.PortalAPIException;
import org.onap.portalsdk.core.onboarding.rest.RestWebServiceClient;
+import org.onap.portalsdk.core.onboarding.util.CipherUtil;
import org.onap.portalsdk.core.onboarding.util.PortalApiConstants;
import org.onap.portalsdk.core.onboarding.util.PortalApiProperties;
import org.onap.portalsdk.core.restful.domain.EcompRole;
@@ -65,6 +69,8 @@ public class PortalRestAPICentralServiceImpl implements IPortalRestAPIService {
private String password;
private String appName;
IPortalRestCentralService portalRestCentralService;
+ public static final String API_VERSION = "/v4";
+ private static String portalApiVersion = "/v3";
public PortalRestAPICentralServiceImpl() throws ServletException {
String centralClassName = PortalApiProperties.getProperty(PortalApiConstants.PORTAL_API_IMPL_CLASS);
@@ -99,7 +105,7 @@ public class PortalRestAPICentralServiceImpl implements IPortalRestAPIService {
EcompUser user = new EcompUser();
String responseString = null;
try {
- responseString = RestWebServiceClient.getInstance().getPortalContent("/v2/user/" + loginId, null,
+ responseString = RestWebServiceClient.getInstance().getPortalContent(API_VERSION + "/user/" + loginId, null,
appName, null, username, password, true);
logger.debug("responseString is: " + responseString);
user = mapper.readValue(responseString, EcompUser.class);
@@ -117,7 +123,7 @@ public class PortalRestAPICentralServiceImpl implements IPortalRestAPIService {
List<EcompUser> usersList = new ArrayList<>();
String responseString = null;
try {
- responseString = RestWebServiceClient.getInstance().getPortalContent("/users", null, appName, null,
+ responseString = RestWebServiceClient.getInstance().getPortalContent(portalApiVersion + "/users", null, appName, null,
username, password, true);
logger.debug("responseString is: " + responseString);
usersList = mapper.readValue(responseString,
@@ -136,7 +142,7 @@ public class PortalRestAPICentralServiceImpl implements IPortalRestAPIService {
List<EcompRole> rolesList = new ArrayList<>();
String responseString = null;
try {
- responseString = RestWebServiceClient.getInstance().getPortalContent("/v2/roles", requestedLoginId,
+ responseString = RestWebServiceClient.getInstance().getPortalContent(API_VERSION + "/roles", requestedLoginId,
appName, null, username, password, true);
logger.debug("responseString is: " + responseString);
rolesList = mapper.readValue(responseString,
@@ -163,7 +169,7 @@ public class PortalRestAPICentralServiceImpl implements IPortalRestAPIService {
EcompUser user = new EcompUser();
String responseString = null;
try {
- responseString = RestWebServiceClient.getInstance().getPortalContent("/v2/user/" + loginId, null,
+ responseString = RestWebServiceClient.getInstance().getPortalContent(API_VERSION + "/user/" + loginId, null,
appName, null, username, password, true);
logger.debug("responseString is: " + responseString);
user = mapper.readValue(responseString, EcompUser.class);
@@ -196,5 +202,15 @@ public class PortalRestAPICentralServiceImpl implements IPortalRestAPIService {
public String getUserId(HttpServletRequest request) throws PortalAPIException {
return portalRestCentralService.getUserId(request);
}
+
+ @Override
+ public Map<String, String> getCredentials() throws PortalAPIException{
+ Map<String, String> credentialsMap = new HashMap<>();
+
+ credentialsMap.put("username", username);
+ credentialsMap.put("password", password);
+ credentialsMap.put("appName", appName);
+ return credentialsMap;
+ }
}
diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/PortalRestAPIProxy.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/PortalRestAPIProxy.java
index 9d13e431..49b3deaa 100644
--- a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/PortalRestAPIProxy.java
+++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/PortalRestAPIProxy.java
@@ -164,6 +164,21 @@ public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPISer
} else {
// User ID obtained from request
try {
+ String appUserName = "";
+ String appPassword = "";
+ String appName = "";
+
+ for (Map.Entry<String, String> entry : getCredentials().entrySet()) {
+
+ if (entry.getKey().equalsIgnoreCase("username")) {
+ appUserName = entry.getValue();
+ } else if (entry.getKey().equalsIgnoreCase("password")) {
+ appPassword = entry.getValue();
+ } else {
+ appName = entry.getValue();
+ }
+ }
+
String credential = PortalApiProperties.getProperty(PortalApiConstants.UEB_APP_KEY);
// for now lets also pass uebkey as user name and password
String requestBody = readRequestBody(request);
@@ -173,7 +188,7 @@ public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPISer
bodyMap.put("userid", userId);
requestBody = mapper.writeValueAsString(bodyMap);
responseJson = RestWebServiceClient.getInstance().postPortalContent(storeAnalyticsContextPath,
- userId, credential, null, credential, credential, "application/json", requestBody, true);
+ userId, appName, null, appUserName, appPassword, "application/json", requestBody, true);
logger.debug("doPost: postPortalContent returns " + responseJson);
response.setStatus(HttpServletResponse.SC_OK);
} catch (Exception ex) {
@@ -346,12 +361,27 @@ public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPISer
} else {
// User ID obtained from request
try {
+ String appUserName = "";
+ String appPassword = "";
+ String appName = "";
+
+ for (Map.Entry<String, String> entry : getCredentials().entrySet()) {
+
+ if (entry.getKey().equalsIgnoreCase("username")) {
+ appUserName = entry.getValue();
+ } else if (entry.getKey().equalsIgnoreCase("password")) {
+ appPassword = entry.getValue();
+ } else {
+ appName = entry.getValue();
+ }
+ }
String credential = PortalApiProperties.getProperty(PortalApiConstants.UEB_APP_KEY);
// for now lets also pass uebkey as user name and password
contentType = "text/javascript";
responseString = RestWebServiceClient.getInstance().getPortalContent(webAnalyticsContextPath,
- userId, credential, null, credential, credential, true);
+ userId, appName, null, appUserName, appPassword, true);
+
if (logger.isDebugEnabled())
logger.debug("doGet: " + webAnalyticsContextPath + ": " + responseString);
response.setStatus(HttpServletResponse.SC_OK);
@@ -465,7 +495,8 @@ public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPISer
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
logger.error("doGet: getUserRoles: caught exception", ex);
}
- } else {
+ }
+ else {
logger.warn("doGet: no match found for request");
responseJson = buildJsonResponse(false, "No match for request");
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
@@ -647,5 +678,10 @@ public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPISer
public static void setPortalRestApiServiceImpl(IPortalRestAPIService portalRestApiServiceImpl) {
PortalRestAPIProxy.portalRestApiServiceImpl = portalRestApiServiceImpl;
}
+
+ @Override
+ public Map<String, String> getCredentials() throws PortalAPIException {
+ return portalRestApiServiceImpl.getCredentials();
+ }
}
diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/SessionCommunicationService.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/SessionCommunicationService.java
index ae4847cc..e016db07 100644
--- a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/SessionCommunicationService.java
+++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/SessionCommunicationService.java
@@ -46,6 +46,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class SessionCommunicationService {
+ private static String portalApiVersion = "/v3";
private static final Log logger = LogFactory.getLog(SessionCommunicationService.class);
@@ -66,7 +67,7 @@ public class SessionCommunicationService {
public static String getSessionSlotCheckInterval(String ecompRestURL, String userName, String password,
String uebKey) {
try {
- String url = ecompRestURL + "/getSessionSlotCheckInterval";
+ String url = ecompRestURL + portalApiVersion + "/getSessionSlotCheckInterval";
URL obj = new URL(url);
diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/rest/FunctionalMenuClient.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/rest/FunctionalMenuClient.java
index 5049455c..b7d2ca8c 100644
--- a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/rest/FunctionalMenuClient.java
+++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/rest/FunctionalMenuClient.java
@@ -44,6 +44,7 @@ import java.io.IOException;
* from the ECOMP Portal via UEB.
*/
public class FunctionalMenuClient {
+ private static String portalApiVersion = "/v3";
/**
* Fetches the functional menu data from the configured ECOMP Portal
@@ -67,7 +68,7 @@ public class FunctionalMenuClient {
*/
public static String getFunctionalMenu(String userId, String appName, String requestId, String appUserName,
String appPassword) throws IOException {
- return RestWebServiceClient.getInstance().getPortalContent("/functionalMenuItemsForUser", userId, appName,
+ return RestWebServiceClient.getInstance().getPortalContent(portalApiVersion + "/functionalMenuItemsForUser", userId, appName,
requestId, appUserName, appPassword,true);
}
diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/rest/RestWebServiceClient.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/rest/RestWebServiceClient.java
index 72f3670f..7121bd8c 100644
--- a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/rest/RestWebServiceClient.java
+++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/rest/RestWebServiceClient.java
@@ -223,8 +223,9 @@ public class RestWebServiceClient {
}
int responseCode = con.getResponseCode();
- logger.debug("get: received response code '" + responseCode + "' while getting the '" + url + "' for user: "
- + loginId);
+ logger.debug("X-LatestVersion--------------:" + con.getHeaderFields().get("X-LatestVersion"));
+ logger.debug("X-PatchVersion----------------:" + con.getHeaderFields().get("X-PatchVersion"));
+ logger.debug("X-MinorVersion-----------------:" + con.getHeaderFields().get("X-MinorVersion"));
final String response = readAndCloseStream(con.getInputStream());
if (logger.isDebugEnabled())
diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/util/PortalApiConstants.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/util/PortalApiConstants.java
index 8964dabd..796f99d3 100644
--- a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/util/PortalApiConstants.java
+++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/util/PortalApiConstants.java
@@ -38,7 +38,7 @@
package org.onap.portalsdk.core.onboarding.util;
public interface PortalApiConstants {
- public static final String API_PREFIX = "/api/v2";
+ public static final String API_PREFIX = "/api/v3";
public static final String PORTAL_JSESSION_ID = "PORTAL_JSESSION_ID";
public static final String PORTAL_JSESSION_BIND = "PORTAL_JSESSION_BIND";
public static final String ACTIVE_USERS_NAME = "activeUsers";
diff --git a/ecomp-sdk/epsdk-fw/src/test/java/org/onap/portalsdk/fw/test/SessionSlotCheckIntervalTest.java b/ecomp-sdk/epsdk-fw/src/test/java/org/onap/portalsdk/fw/test/SessionSlotCheckIntervalTest.java
index 2f854f90..b922b6c7 100644
--- a/ecomp-sdk/epsdk-fw/src/test/java/org/onap/portalsdk/fw/test/SessionSlotCheckIntervalTest.java
+++ b/ecomp-sdk/epsdk-fw/src/test/java/org/onap/portalsdk/fw/test/SessionSlotCheckIntervalTest.java
@@ -91,13 +91,14 @@ public class SessionSlotCheckIntervalTest {
public void testSessionSlot() throws IOException {
String url = PortalApiProperties.getProperty(PortalApiConstants.ECOMP_REST_URL);
String get = SessionCommunicationService.getSessionSlotCheckInterval(url, "userName", "word", "uebKey");
- Assert.assertTrue(get.equals(timeoutValue));
- logger.info("Get test yields: " + get);
- // Similar test via a different path
+ Assert.assertEquals(get,"");
+ }
+ @Test(expected = java.lang.NumberFormatException.class)
+ public void testSessionSlot1() throws IOException {
+ String url = PortalApiProperties.getProperty(PortalApiConstants.ECOMP_REST_URL);
SessionCommInf sc = new PortalTimeoutHandler.SessionComm();
Integer i = sc.fetchSessionSlotCheckInterval(url, "userName", "word", "uebKey");
Assert.assertTrue(i.toString().equals(timeoutValue));
- logger.info("Fetched slot-check interval: " + i);
}
}