summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-app-common
diff options
context:
space:
mode:
Diffstat (limited to 'ecomp-sdk/epsdk-app-common')
-rw-r--r--ecomp-sdk/epsdk-app-common/db-scripts/EcompSdkMySql_Rollback_2_2_to_2_1_Common.sql11
-rw-r--r--ecomp-sdk/epsdk-app-common/db-scripts/EcompSdkMySql_Upgrade_2_1_to_2_2_Common.sql12
-rw-r--r--ecomp-sdk/epsdk-app-common/pom.xml101
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/service/OnBoardingApiServiceImpl.java54
-rw-r--r--ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/service/OnBoardingApiServiceImplTest.java13
5 files changed, 155 insertions, 36 deletions
diff --git a/ecomp-sdk/epsdk-app-common/db-scripts/EcompSdkMySql_Rollback_2_2_to_2_1_Common.sql b/ecomp-sdk/epsdk-app-common/db-scripts/EcompSdkMySql_Rollback_2_2_to_2_1_Common.sql
new file mode 100644
index 00000000..f8a7fbce
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-common/db-scripts/EcompSdkMySql_Rollback_2_2_to_2_1_Common.sql
@@ -0,0 +1,11 @@
+use ecomp_sdk;
+
+
+ALTER TABLE fn_function
+DROP COLUMN type;
+
+
+ALTER TABLE fn_function
+DROP COLUMN action;
+
+commit; \ No newline at end of file
diff --git a/ecomp-sdk/epsdk-app-common/db-scripts/EcompSdkMySql_Upgrade_2_1_to_2_2_Common.sql b/ecomp-sdk/epsdk-app-common/db-scripts/EcompSdkMySql_Upgrade_2_1_to_2_2_Common.sql
new file mode 100644
index 00000000..32540c69
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-common/db-scripts/EcompSdkMySql_Upgrade_2_1_to_2_2_Common.sql
@@ -0,0 +1,12 @@
+use ecomp_sdk;
+
+SET FOREIGN_KEY_CHECKS=0;
+
+alter table fn_function
+add type VARCHAR(20) NULL DEFAULT NULL;
+
+
+alter table fn_function
+add action VARCHAR(20) NULL DEFAULT NULL;
+
+commit; \ No newline at end of file
diff --git a/ecomp-sdk/epsdk-app-common/pom.xml b/ecomp-sdk/epsdk-app-common/pom.xml
index ae2cb96c..74621092 100644
--- a/ecomp-sdk/epsdk-app-common/pom.xml
+++ b/ecomp-sdk/epsdk-app-common/pom.xml
@@ -129,17 +129,17 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
- <version>2.6.3</version>
+ <version>2.9.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
- <version>2.6.3</version>
+ <version>2.9.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
- <version>2.6.3</version>
+ <version>2.9.2</version>
</dependency>
<dependency>
<groupId>com.mchange</groupId>
@@ -244,5 +244,100 @@
<version>${jacoco.version}</version>
<classifier>runtime</classifier>
</dependency>
+ <dependency>
+ <groupId>org.apache.lucene</groupId>
+ <artifactId>lucene-queryparser</artifactId>
+ <version>7.2.1</version>
+ </dependency>
+ <dependency>
+ <groupId>com.thoughtworks.xstream</groupId>
+ <artifactId>xstream</artifactId>
+ <version>1.4.10</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.wicket</groupId>
+ <artifactId>wicket-core</artifactId>
+ <version>1.5.16</version>
+ </dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-core</artifactId>
+ <version>1.2.3</version>
+ </dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ <version>1.2.3</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-fileupload</groupId>
+ <artifactId>commons-fileupload</artifactId>
+ <version>1.3.3</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-beanutils</groupId>
+ <artifactId>commons-beanutils</artifactId>
+ <version>1.9.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.poi</groupId>
+ <artifactId>poi</artifactId>
+ <version>3.17</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.poi</groupId>
+ <artifactId>poi-ooxml</artifactId>
+ <version>3.17</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.poi</groupId>
+ <artifactId>poi-scratchpad</artifactId>
+ <version>3.17</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.poi</groupId>
+ <artifactId>poi-contrib</artifactId>
+ <version>3.5-FINAL</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
</dependencies>
</project>
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 bfd0fc89..f19a14b6 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
@@ -108,6 +108,7 @@ public class OnBoardingApiServiceImpl implements IPortalRestAPIService, IPortalR
.getProperty(PortalApiConstants.ROLE_ACCESS_CENTRALIZED);
private static final String isCentralized = "remote";
+ private static String portalApiVersion = "/v1";
public OnBoardingApiServiceImpl() {
// Defend against null-pointer exception during server startup
@@ -229,11 +230,12 @@ public class OnBoardingApiServiceImpl implements IPortalRestAPIService, IPortalR
try {
if (logger.isDebugEnabled())
logger.debug(EELFLoggerDelegate.debugLogger, "## REST API ## loginId: {}", loginId);
-
+
User user = null;
- if(isCentralized.equals(isAccessCentralized)){
- String responseString = restApiRequestBuilder.getViaREST("/user/" + loginId, true, loginId);
- user = userService.userMapper(responseString);
+ if (isCentralized.equals(isAccessCentralized)) {
+ String responseString = restApiRequestBuilder.getViaREST(portalApiVersion+"/user/" + loginId, true,
+ loginId);
+ user = userService.userMapper(responseString);
}
else{
user = userProfileService.getUserByLoginId(loginId);
@@ -359,30 +361,30 @@ public class OnBoardingApiServiceImpl implements IPortalRestAPIService, IPortalR
logger.debug(EELFLoggerDelegate.debugLogger, "## REST API ## loginId: {}", loginId);
List<EcompRole> ecompRoles = new ArrayList<EcompRole>();
try {
-
- if(isCentralized.equals(isAccessCentralized)){
+
+ if (isCentralized.equals(isAccessCentralized)) {
User user = null;
- String responseString = restApiRequestBuilder.getViaREST("/user/" + loginId, true, loginId);
- user = userService.userMapper(responseString);
- SortedSet<Role> currentRoles = null;
- if (user != null) {
- currentRoles = user.getRoles();
- if (currentRoles != null)
- for (Role role : currentRoles)
- ecompRoles.add(UserUtils.convertToEcompRole(role));
- }
- }
- else{
- User user = userProfileService.getUserByLoginId(loginId);
- SortedSet<Role> currentRoles = null;
- if (user != null) {
- currentRoles = user.getRoles();
- currentRoles.removeIf(role -> (role.getActive() == false));
- if (currentRoles != null)
- for (Role role : currentRoles)
- ecompRoles.add(UserUtils.convertToEcompRole(role));
+ String responseString = restApiRequestBuilder.getViaREST(portalApiVersion+"/user/" + loginId, true,
+ loginId);
+ user = userService.userMapper(responseString);
+ SortedSet<Role> currentRoles = null;
+ if (user != null) {
+ currentRoles = user.getRoles();
+ if (currentRoles != null)
+ for (Role role : currentRoles)
+ ecompRoles.add(UserUtils.convertToEcompRole(role));
+ }
+ } else {
+ User user = userProfileService.getUserByLoginId(loginId);
+ SortedSet<Role> currentRoles = null;
+ if (user != null) {
+ currentRoles = user.getRoles();
+ currentRoles.removeIf(role -> (role.getActive() == false));
+ if (currentRoles != null)
+ for (Role role : currentRoles)
+ ecompRoles.add(UserUtils.convertToEcompRole(role));
+ }
}
- }
return ecompRoles;
} catch (Exception e) {
String response = "OnboardingApiService.getUserRoles failed";
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 39b61b40..98ea0f8f 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
@@ -39,7 +39,6 @@ package org.onap.portalapp.service;
import java.io.IOException;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -129,7 +128,7 @@ public class OnBoardingApiServiceImplTest {
Assert.assertTrue(true);
}
- @Test(expected = PortalAPIException.class)
+ @Test(expected = org.onap.portalsdk.core.onboarding.exception.PortalAPIException.class)
public void pushUserExceptionTest() throws Exception {
PowerMockito.mockStatic(PortalApiProperties.class);
Mockito.when(PortalApiProperties.getProperty(PortalApiConstants.ROLE_ACCESS_CENTRALIZED)).thenReturn("remote");
@@ -173,7 +172,7 @@ public class OnBoardingApiServiceImplTest {
Mockito.when(PortalApiProperties.getProperty(PortalApiConstants.ROLE_ACCESS_CENTRALIZED)).thenReturn("remote");
String responseString = "Response";
- Mockito.when(restApiRequestBuilder.getViaREST("/user/" + loginId, true, loginId)).thenReturn(responseString);
+ Mockito.when(restApiRequestBuilder.getViaREST("/v1/user/" + loginId, true, loginId)).thenReturn(responseString);
Mockito.when(userService.userMapper(responseString)).thenReturn(new User());
OnBoardingApiServiceImpl onBoardingApiServiceImpl = new OnBoardingApiServiceImpl();
@@ -201,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("/user/" + loginId, true, loginId)).thenThrow(IOException.class);
+ Mockito.when(restApiRequestBuilder.getViaREST("/v1/user/" + loginId, true, loginId)).thenThrow(IOException.class);
Mockito.when(userService.userMapper(responseString)).thenReturn(null);
OnBoardingApiServiceImpl onBoardingApiServiceImpl = new OnBoardingApiServiceImpl();
@@ -320,7 +319,7 @@ public class OnBoardingApiServiceImplTest {
public void getUserRolesTest() throws Exception {
String loginId = "123";
String responseString = "Response";
- Mockito.when(restApiRequestBuilder.getViaREST("/user/" + loginId, true, loginId)).thenReturn(responseString);
+ Mockito.when(restApiRequestBuilder.getViaREST("/v1/user/" + loginId, true, loginId)).thenReturn(responseString);
User user = new User();
SortedSet<Role> currentRoles = new TreeSet<>();
Role role = new Role();
@@ -333,10 +332,10 @@ public class OnBoardingApiServiceImplTest {
Assert.assertNotNull(ecompRoles);
}
- @Test(expected = PortalAPIException.class)
+ @Test(expected = org.onap.portalsdk.core.onboarding.exception.PortalAPIException.class)
public void getUserRolesExceptionTest() throws Exception {
String loginId = "123";
- Mockito.when(restApiRequestBuilder.getViaREST("/user/" + loginId, true, loginId)).thenThrow(IOException.class);
+ Mockito.when(restApiRequestBuilder.getViaREST("/v1/user/" + loginId, true, loginId)).thenThrow(IOException.class);
OnBoardingApiServiceImpl onBoardingApiServiceImpl = new OnBoardingApiServiceImpl();
onBoardingApiServiceImpl.getUserRoles(loginId);
}